Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f2a11a2

Browse files
committed
Auto merge of rust-lang#79017 - GuillaumeGomez:rollup-5orhudd, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#77151 (Add regression test for issue rust-lang#76042) - rust-lang#77996 (Doc change: Remove mention of `fnv` in HashMap) - rust-lang#78463 (Add type to `ConstKind::Placeholder`) - rust-lang#78984 (Rustdoc check option) - rust-lang#78985 (add dropck test for const params) - rust-lang#78996 (add explicit test for const param promotion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a1f7ca7 + 7ea8e32 commit f2a11a2

File tree

22 files changed

+286
-62
lines changed

22 files changed

+286
-62
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
277277
struct Canonicalizer<'cx, 'tcx> {
278278
infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
279279
tcx: TyCtxt<'tcx>,
280-
variables: SmallVec<[CanonicalVarInfo; 8]>,
280+
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
281281
query_state: &'cx mut OriginalQueryValues<'tcx>,
282282
// Note that indices is only used once `var_values` is big enough to be
283283
// heap-allocated.
@@ -542,7 +542,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
542542
/// or returns an existing variable if `kind` has already been
543543
/// seen. `kind` is expected to be an unbound variable (or
544544
/// potentially a free region).
545-
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: GenericArg<'tcx>) -> BoundVar {
545+
fn canonical_var(&mut self, info: CanonicalVarInfo<'tcx>, kind: GenericArg<'tcx>) -> BoundVar {
546546
let Canonicalizer { variables, query_state, indices, .. } = self;
547547

548548
let var_values = &mut query_state.var_values;
@@ -621,7 +621,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
621621
/// representing the region `r`; return a region referencing it.
622622
fn canonical_var_for_region(
623623
&mut self,
624-
info: CanonicalVarInfo,
624+
info: CanonicalVarInfo<'tcx>,
625625
r: ty::Region<'tcx>,
626626
) -> ty::Region<'tcx> {
627627
let var = self.canonical_var(info, r.into());
@@ -633,7 +633,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
633633
/// if `ty_var` is bound to anything; if so, canonicalize
634634
/// *that*. Otherwise, create a new canonical variable for
635635
/// `ty_var`.
636-
fn canonicalize_ty_var(&mut self, info: CanonicalVarInfo, ty_var: Ty<'tcx>) -> Ty<'tcx> {
636+
fn canonicalize_ty_var(&mut self, info: CanonicalVarInfo<'tcx>, ty_var: Ty<'tcx>) -> Ty<'tcx> {
637637
let infcx = self.infcx.expect("encountered ty-var without infcx");
638638
let bound_to = infcx.shallow_resolve(ty_var);
639639
if bound_to != ty_var {
@@ -650,7 +650,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
650650
/// `const_var`.
651651
fn canonicalize_const_var(
652652
&mut self,
653-
info: CanonicalVarInfo,
653+
info: CanonicalVarInfo<'tcx>,
654654
const_var: &'tcx ty::Const<'tcx>,
655655
) -> &'tcx ty::Const<'tcx> {
656656
let infcx = self.infcx.expect("encountered const-var without infcx");

compiler/rustc_infer/src/infer/canonical/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
8282
fn instantiate_canonical_vars(
8383
&self,
8484
span: Span,
85-
variables: &List<CanonicalVarInfo>,
85+
variables: &List<CanonicalVarInfo<'tcx>>,
8686
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
8787
) -> CanonicalVarValues<'tcx> {
8888
let var_values: IndexVec<BoundVar, GenericArg<'tcx>> = variables
@@ -100,7 +100,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
100100
fn instantiate_canonical_var(
101101
&self,
102102
span: Span,
103-
cv_info: CanonicalVarInfo,
103+
cv_info: CanonicalVarInfo<'tcx>,
104104
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
105105
) -> GenericArg<'tcx> {
106106
match cv_info.kind {
@@ -154,7 +154,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
154154
self.tcx
155155
.mk_const(ty::Const {
156156
val: ty::ConstKind::Placeholder(placeholder_mapped),
157-
ty: self.tcx.ty_error(), // FIXME(const_generics)
157+
ty: name.ty,
158158
})
159159
.into()
160160
}

compiler/rustc_infer/src/infer/higher_ranked/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
9595
self.tcx.mk_const(ty::Const {
9696
val: ty::ConstKind::Placeholder(ty::PlaceholderConst {
9797
universe: next_universe,
98-
name: bound_var,
98+
name: ty::BoundConst { var: bound_var, ty },
9999
}),
100100
ty,
101101
})

compiler/rustc_middle/src/infer/canonical.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Canonical<'tcx, V> {
4040
pub value: V,
4141
}
4242

43-
pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo>;
43+
pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;
4444

4545
/// A set of values corresponding to the canonical variables from some
4646
/// `Canonical`. You can give these values to
@@ -88,11 +88,11 @@ impl Default for OriginalQueryValues<'tcx> {
8888
/// a copy of the canonical value in some other inference context,
8989
/// with fresh inference variables replacing the canonical values.
9090
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable, HashStable)]
91-
pub struct CanonicalVarInfo {
92-
pub kind: CanonicalVarKind,
91+
pub struct CanonicalVarInfo<'tcx> {
92+
pub kind: CanonicalVarKind<'tcx>,
9393
}
9494

95-
impl CanonicalVarInfo {
95+
impl<'tcx> CanonicalVarInfo<'tcx> {
9696
pub fn universe(&self) -> ty::UniverseIndex {
9797
self.kind.universe()
9898
}
@@ -113,7 +113,7 @@ impl CanonicalVarInfo {
113113
/// in the type-theory sense of the term -- i.e., a "meta" type system
114114
/// that analyzes type-like values.
115115
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable, HashStable)]
116-
pub enum CanonicalVarKind {
116+
pub enum CanonicalVarKind<'tcx> {
117117
/// Some kind of type inference variable.
118118
Ty(CanonicalTyVarKind),
119119

@@ -132,10 +132,10 @@ pub enum CanonicalVarKind {
132132
Const(ty::UniverseIndex),
133133

134134
/// A "placeholder" that represents "any const".
135-
PlaceholderConst(ty::PlaceholderConst),
135+
PlaceholderConst(ty::PlaceholderConst<'tcx>),
136136
}
137137

138-
impl CanonicalVarKind {
138+
impl<'tcx> CanonicalVarKind<'tcx> {
139139
pub fn universe(self) -> ty::UniverseIndex {
140140
match self {
141141
CanonicalVarKind::Ty(kind) => match kind {
@@ -287,9 +287,11 @@ pub type QueryOutlivesConstraint<'tcx> =
287287
ty::Binder<ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>>;
288288

289289
CloneTypeFoldableAndLiftImpls! {
290-
crate::infer::canonical::Certainty,
291-
crate::infer::canonical::CanonicalVarInfo,
292-
crate::infer::canonical::CanonicalVarKind,
290+
for <'tcx> {
291+
crate::infer::canonical::Certainty,
292+
crate::infer::canonical::CanonicalVarInfo<'tcx>,
293+
crate::infer::canonical::CanonicalVarKind<'tcx>,
294+
}
293295
}
294296

295297
CloneTypeFoldableImpls! {

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Region<'tcx> {
278278
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for CanonicalVarInfos<'tcx> {
279279
fn decode(decoder: &mut D) -> Result<Self, D::Error> {
280280
let len = decoder.read_usize()?;
281-
let interned: Result<Vec<CanonicalVarInfo>, _> =
281+
let interned: Result<Vec<CanonicalVarInfo<'tcx>>, _> =
282282
(0..len).map(|_| Decodable::decode(decoder)).collect();
283283
Ok(decoder.tcx().intern_canonical_var_infos(interned?.as_slice()))
284284
}

compiler/rustc_middle/src/ty/consts/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum ConstKind<'tcx> {
2323
Bound(ty::DebruijnIndex, ty::BoundVar),
2424

2525
/// A placeholder const - universally quantified higher-ranked const.
26-
Placeholder(ty::PlaceholderConst),
26+
Placeholder(ty::PlaceholderConst<'tcx>),
2727

2828
/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
2929
/// variants when the code is monomorphic enough for that.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub struct CtxtInterners<'tcx> {
8383
type_: InternedSet<'tcx, TyS<'tcx>>,
8484
type_list: InternedSet<'tcx, List<Ty<'tcx>>>,
8585
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
86-
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo>>,
86+
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
8787
region: InternedSet<'tcx, RegionKind>,
8888
existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
8989
predicate: InternedSet<'tcx, PredicateInner<'tcx>>,
@@ -1613,7 +1613,7 @@ nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
16131613
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
16141614
nop_list_lift! {existential_predicates; ExistentialPredicate<'a> => ExistentialPredicate<'tcx>}
16151615
nop_list_lift! {predicates; Predicate<'a> => Predicate<'tcx>}
1616-
nop_list_lift! {canonical_var_infos; CanonicalVarInfo => CanonicalVarInfo}
1616+
nop_list_lift! {canonical_var_infos; CanonicalVarInfo<'a> => CanonicalVarInfo<'tcx>}
16171617
nop_list_lift! {projs; ProjectionKind => ProjectionKind}
16181618

16191619
// This is the impl for `&'a InternalSubsts<'a>`.
@@ -2049,7 +2049,7 @@ macro_rules! slice_interners {
20492049
slice_interners!(
20502050
type_list: _intern_type_list(Ty<'tcx>),
20512051
substs: _intern_substs(GenericArg<'tcx>),
2052-
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo),
2052+
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
20532053
existential_predicates: _intern_existential_predicates(ExistentialPredicate<'tcx>),
20542054
predicates: _intern_predicates(Predicate<'tcx>),
20552055
projs: _intern_projs(ProjectionKind),
@@ -2448,7 +2448,10 @@ impl<'tcx> TyCtxt<'tcx> {
24482448
if ts.is_empty() { List::empty() } else { self._intern_place_elems(ts) }
24492449
}
24502450

2451-
pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'tcx> {
2451+
pub fn intern_canonical_var_infos(
2452+
self,
2453+
ts: &[CanonicalVarInfo<'tcx>],
2454+
) -> CanonicalVarInfos<'tcx> {
24522455
if ts.is_empty() { List::empty() } else { self._intern_canonical_var_infos(ts) }
24532456
}
24542457

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,11 +1580,9 @@ impl UniverseIndex {
15801580
}
15811581
}
15821582

1583-
/// The "placeholder index" fully defines a placeholder region.
1584-
/// Placeholder regions are identified by both a **universe** as well
1585-
/// as a "bound-region" within that universe. The `bound_region` is
1586-
/// basically a name -- distinct bound regions within the same
1587-
/// universe are just two regions with an unknown relationship to one
1583+
/// The "placeholder index" fully defines a placeholder region, type, or const. Placeholders are
1584+
/// identified by both a universe, as well as a name residing within that universe. Distinct bound
1585+
/// regions/types/consts within the same universe simply have an unknown relationship to one
15881586
/// another.
15891587
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
15901588
pub struct Placeholder<T> {
@@ -1606,7 +1604,14 @@ pub type PlaceholderRegion = Placeholder<BoundRegion>;
16061604

16071605
pub type PlaceholderType = Placeholder<BoundVar>;
16081606

1609-
pub type PlaceholderConst = Placeholder<BoundVar>;
1607+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
1608+
#[derive(TyEncodable, TyDecodable, PartialOrd, Ord)]
1609+
pub struct BoundConst<'tcx> {
1610+
pub var: BoundVar,
1611+
pub ty: Ty<'tcx>,
1612+
}
1613+
1614+
pub type PlaceholderConst<'tcx> = Placeholder<BoundConst<'tcx>>;
16101615

16111616
/// A `DefId` which is potentially bundled with its corresponding generic parameter
16121617
/// in case `did` is a const argument.

library/std/src/collections/hash/map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use crate::sys;
3434
/// attacks such as HashDoS.
3535
///
3636
/// The hashing algorithm can be replaced on a per-`HashMap` basis using the
37-
/// [`default`], [`with_hasher`], and [`with_capacity_and_hasher`] methods. Many
38-
/// alternative algorithms are available on crates.io, such as the [`fnv`] crate.
37+
/// [`default`], [`with_hasher`], and [`with_capacity_and_hasher`] methods.
38+
/// There are many alternative [hashing algorithms available on crates.io].
3939
///
4040
/// It is required that the keys implement the [`Eq`] and [`Hash`] traits, although
4141
/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`.
@@ -57,6 +57,7 @@ use crate::sys;
5757
/// The original C++ version of SwissTable can be found [here], and this
5858
/// [CppCon talk] gives an overview of how the algorithm works.
5959
///
60+
/// [hashing algorithms available on crates.io]: https://crates.io/keywords/hasher
6061
/// [SwissTable]: https://abseil.io/blog/20180927-swisstables
6162
/// [here]: https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal/raw_hash_set.h
6263
/// [CppCon talk]: https://www.youtube.com/watch?v=ncHmEUmJZf4
@@ -154,7 +155,6 @@ use crate::sys;
154155
/// [`default`]: Default::default
155156
/// [`with_hasher`]: Self::with_hasher
156157
/// [`with_capacity_and_hasher`]: Self::with_capacity_and_hasher
157-
/// [`fnv`]: https://crates.io/crates/fnv
158158
///
159159
/// ```
160160
/// use std::collections::HashMap;

src/librustdoc/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ pub struct Options {
145145
pub render_options: RenderOptions,
146146
/// Output format rendering (used only for "show-coverage" option for the moment)
147147
pub output_format: Option<OutputFormat>,
148+
/// If this option is set to `true`, rustdoc will only run checks and not generate
149+
/// documentation.
150+
pub run_check: bool,
148151
}
149152

150153
impl fmt::Debug for Options {
@@ -185,6 +188,7 @@ impl fmt::Debug for Options {
185188
.field("runtool", &self.runtool)
186189
.field("runtool_args", &self.runtool_args)
187190
.field("enable-per-target-ignores", &self.enable_per_target_ignores)
191+
.field("run_check", &self.run_check)
188192
.finish()
189193
}
190194
}
@@ -581,6 +585,7 @@ impl Options {
581585
let enable_per_target_ignores = matches.opt_present("enable-per-target-ignores");
582586
let document_private = matches.opt_present("document-private-items");
583587
let document_hidden = matches.opt_present("document-hidden-items");
588+
let run_check = matches.opt_present("check");
584589

585590
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
586591

@@ -616,6 +621,7 @@ impl Options {
616621
runtool_args,
617622
enable_per_target_ignores,
618623
test_builder,
624+
run_check,
619625
render_options: RenderOptions {
620626
output,
621627
external_html,

0 commit comments

Comments
 (0)