Skip to content

Commit b73e9a4

Browse files
committedJul 27, 2023
Auto merge of #114130 - GuillaumeGomez:rollup-69ihuaj, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #114032 (typos) - #114059 (rustdoc: fix cross-crate `impl Sized` & `impl ?Sized`) - #114088 (Bump syn dependency) - #114091 (docs: fmt::Debug*: Fix comments for finish method.) - #114109 (Docs: Fix URL for `rmatches`) - #114117 (Restore region uniquification in the new solver 🎉 ) - #114123 (Turns out opaque types can have hidden types registered during mir validation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 49a16b6 + 218e88e commit b73e9a4

File tree

22 files changed

+420
-272
lines changed

22 files changed

+420
-272
lines changed
 

‎Cargo.lock

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ dependencies = [
220220
"proc-macro2",
221221
"quote",
222222
"serde",
223-
"syn 2.0.8",
223+
"syn 2.0.27",
224224
]
225225

226226
[[package]]
@@ -502,7 +502,7 @@ dependencies = [
502502
"heck",
503503
"proc-macro2",
504504
"quote",
505-
"syn 2.0.8",
505+
"syn 2.0.27",
506506
]
507507

508508
[[package]]
@@ -527,7 +527,7 @@ dependencies = [
527527
"regex",
528528
"rustc_tools_util",
529529
"serde",
530-
"syn 2.0.8",
530+
"syn 2.0.27",
531531
"tempfile",
532532
"termize",
533533
"tester",
@@ -842,7 +842,7 @@ version = "0.1.73"
842842
dependencies = [
843843
"itertools",
844844
"quote",
845-
"syn 2.0.8",
845+
"syn 2.0.27",
846846
]
847847

848848
[[package]]
@@ -943,7 +943,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
943943
dependencies = [
944944
"proc-macro2",
945945
"quote",
946-
"syn 2.0.8",
946+
"syn 2.0.27",
947947
]
948948

949949
[[package]]
@@ -1309,7 +1309,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
13091309
dependencies = [
13101310
"proc-macro2",
13111311
"quote",
1312-
"syn 2.0.8",
1312+
"syn 2.0.27",
13131313
]
13141314

13151315
[[package]]
@@ -2456,7 +2456,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
24562456
dependencies = [
24572457
"proc-macro2",
24582458
"quote",
2459-
"syn 2.0.8",
2459+
"syn 2.0.27",
24602460
]
24612461

24622462
[[package]]
@@ -2643,7 +2643,7 @@ dependencies = [
26432643
"pest_meta",
26442644
"proc-macro2",
26452645
"quote",
2646-
"syn 2.0.8",
2646+
"syn 2.0.27",
26472647
]
26482648

26492649
[[package]]
@@ -3586,7 +3586,7 @@ dependencies = [
35863586
"fluent-syntax",
35873587
"proc-macro2",
35883588
"quote",
3589-
"syn 2.0.8",
3589+
"syn 2.0.27",
35903590
"unic-langid",
35913591
]
35923592

@@ -3855,7 +3855,7 @@ version = "0.1.0"
38553855
dependencies = [
38563856
"proc-macro2",
38573857
"quote",
3858-
"syn 2.0.8",
3858+
"syn 2.0.27",
38593859
"synstructure 0.13.0",
38603860
]
38613861

@@ -4462,7 +4462,7 @@ dependencies = [
44624462
"proc-macro2",
44634463
"quote",
44644464
"serde",
4465-
"syn 2.0.8",
4465+
"syn 2.0.27",
44664466
]
44674467

44684468
[[package]]
@@ -4629,7 +4629,7 @@ checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68"
46294629
dependencies = [
46304630
"proc-macro2",
46314631
"quote",
4632-
"syn 2.0.8",
4632+
"syn 2.0.27",
46334633
]
46344634

46354635
[[package]]
@@ -4910,9 +4910,9 @@ dependencies = [
49104910

49114911
[[package]]
49124912
name = "syn"
4913-
version = "2.0.8"
4913+
version = "2.0.27"
49144914
source = "registry+https://github.com/rust-lang/crates.io-index"
4915-
checksum = "bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9"
4915+
checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0"
49164916
dependencies = [
49174917
"proc-macro2",
49184918
"quote",
@@ -4939,7 +4939,7 @@ checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06"
49394939
dependencies = [
49404940
"proc-macro2",
49414941
"quote",
4942-
"syn 2.0.8",
4942+
"syn 2.0.27",
49434943
"unicode-xid",
49444944
]
49454945

@@ -5089,7 +5089,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
50895089
dependencies = [
50905090
"proc-macro2",
50915091
"quote",
5092-
"syn 2.0.8",
5092+
"syn 2.0.27",
50935093
]
50945094

50955095
[[package]]
@@ -5310,7 +5310,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
53105310
dependencies = [
53115311
"proc-macro2",
53125312
"quote",
5313-
"syn 2.0.8",
5313+
"syn 2.0.27",
53145314
]
53155315

53165316
[[package]]
@@ -5740,7 +5740,7 @@ dependencies = [
57405740
"once_cell",
57415741
"proc-macro2",
57425742
"quote",
5743-
"syn 2.0.8",
5743+
"syn 2.0.27",
57445744
"wasm-bindgen-shared",
57455745
]
57465746

@@ -5774,7 +5774,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
57745774
dependencies = [
57755775
"proc-macro2",
57765776
"quote",
5777-
"syn 2.0.8",
5777+
"syn 2.0.27",
57785778
"wasm-bindgen-backend",
57795779
"wasm-bindgen-shared",
57805780
]

‎compiler/rustc_const_eval/src/util/compare_types.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ pub fn is_subtype<'tcx>(
5757
// we would get unification errors because we're unable to look into opaque types,
5858
// even if they're constrained in our current function.
5959
for (key, ty) in infcx.take_opaque_types() {
60-
span_bug!(
61-
ty.hidden_type.span,
62-
"{}, {}",
63-
tcx.type_of(key.def_id).instantiate(tcx, key.args),
64-
ty.hidden_type.ty
65-
);
60+
let hidden_ty = tcx.type_of(key.def_id).instantiate(tcx, key.args);
61+
if hidden_ty != ty.hidden_type.ty {
62+
span_bug!(
63+
ty.hidden_type.span,
64+
"{}, {}",
65+
tcx.type_of(key.def_id).instantiate(tcx, key.args),
66+
ty.hidden_type.ty
67+
);
68+
}
6669
}
6770
errors.is_empty()
6871
}

‎compiler/rustc_macros/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ proc-macro = true
88

99
[dependencies]
1010
synstructure = "0.13.0"
11-
# FIXME(Nilstrieb): Updating this causes changes in the diagnostics output.
12-
syn = { version = "=2.0.8", features = ["full"] }
11+
syn = { version = "2.0.9", features = ["full"] }
1312
proc-macro2 = "1"
1413
quote = "1"

‎compiler/rustc_trait_selection/src/solve/canonicalize.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ impl<'a, 'tcx> Canonicalizer<'a, 'tcx> {
125125
// - var_infos: [E0, U1, E1, U1, E1, E6, U6], curr_compressed_uv: 1, next_orig_uv: 6
126126
// - var_infos: [E0, U1, E1, U1, E1, E2, U2], curr_compressed_uv: 2, next_orig_uv: -
127127
//
128-
// This algorithm runs in `O(nm)` where `n` is the number of different universe
129-
// indices in the input and `m` is the number of canonical variables.
130-
// This should be fine as both `n` and `m` are expected to be small.
128+
// This algorithm runs in `O(n²)` where `n` is the number of different universe
129+
// indices in the input. This should be fine as `n` is expected to be small.
131130
let mut curr_compressed_uv = ty::UniverseIndex::ROOT;
132131
let mut existential_in_new_uv = false;
133132
let mut next_orig_uv = Some(ty::UniverseIndex::ROOT);
@@ -263,14 +262,18 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
263262
ty::ReError(_) => return r,
264263
};
265264

266-
let var = ty::BoundVar::from(
267-
self.variables.iter().position(|&v| v == r.into()).unwrap_or_else(|| {
268-
let var = self.variables.len();
269-
self.variables.push(r.into());
270-
self.primitive_var_infos.push(CanonicalVarInfo { kind });
271-
var
272-
}),
273-
);
265+
let existing_bound_var = match self.canonicalize_mode {
266+
CanonicalizeMode::Input => None,
267+
CanonicalizeMode::Response { .. } => {
268+
self.variables.iter().position(|&v| v == r.into()).map(ty::BoundVar::from)
269+
}
270+
};
271+
let var = existing_bound_var.unwrap_or_else(|| {
272+
let var = ty::BoundVar::from(self.variables.len());
273+
self.variables.push(r.into());
274+
self.primitive_var_infos.push(CanonicalVarInfo { kind });
275+
var
276+
});
274277
let br = ty::BoundRegion { var, kind: BrAnon(None) };
275278
ty::Region::new_late_bound(self.interner(), self.binder_index, br)
276279
}

‎compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
344344
Ok(response) => response,
345345
};
346346

347-
let has_changed = !canonical_response.value.var_values.is_identity()
347+
let has_changed = !canonical_response.value.var_values.is_identity_modulo_regions()
348348
|| !canonical_response.value.external_constraints.opaque_types.is_empty();
349349
let (certainty, nested_goals) = match self.instantiate_and_apply_query_response(
350350
goal.param_env,

‎library/core/src/fmt/builders.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
518518
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
519519
/// fmt.debug_set()
520520
/// .entries(self.0.iter())
521-
/// .finish() // Ends the struct formatting.
521+
/// .finish() // Ends the set formatting.
522522
/// }
523523
/// }
524524
///
@@ -648,7 +648,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
648648
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
649649
/// fmt.debug_list()
650650
/// .entries(self.0.iter())
651-
/// .finish() // Ends the struct formatting.
651+
/// .finish() // Ends the list formatting.
652652
/// }
653653
/// }
654654
///
@@ -905,7 +905,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
905905
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
906906
/// fmt.debug_map()
907907
/// .entries(self.0.iter().map(|&(ref k, ref v)| (k, v)))
908-
/// .finish() // Ends the struct formatting.
908+
/// .finish() // Ends the map formatting.
909909
/// }
910910
/// }
911911
///

‎library/core/src/str/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ impl str {
16661666
/// If the pattern allows a reverse search but its results might differ
16671667
/// from a forward search, the [`rmatches`] method can be used.
16681668
///
1669-
/// [`rmatches`]: str::matches
1669+
/// [`rmatches`]: str::rmatches
16701670
///
16711671
/// # Examples
16721672
///

‎src/librustdoc/clean/mod.rs

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,10 @@ fn clean_ty_generics<'tcx>(
804804
let where_predicates = preds
805805
.predicates
806806
.iter()
807-
.flat_map(|(p, _)| {
807+
.flat_map(|(pred, _)| {
808808
let mut projection = None;
809809
let param_idx = (|| {
810-
let bound_p = p.kind();
810+
let bound_p = pred.kind();
811811
match bound_p.skip_binder() {
812812
ty::ClauseKind::Trait(pred) => {
813813
if let ty::Param(param) = pred.self_ty().kind() {
@@ -832,33 +832,26 @@ fn clean_ty_generics<'tcx>(
832832
})();
833833

834834
if let Some(param_idx) = param_idx
835-
&& let Some(b) = impl_trait.get_mut(&param_idx.into())
835+
&& let Some(bounds) = impl_trait.get_mut(&param_idx.into())
836836
{
837-
let p: WherePredicate = clean_predicate(*p, cx)?;
837+
let pred = clean_predicate(*pred, cx)?;
838838

839-
b.extend(
840-
p.get_bounds()
839+
bounds.extend(
840+
pred.get_bounds()
841841
.into_iter()
842842
.flatten()
843843
.cloned()
844-
.filter(|b| !b.is_sized_bound(cx)),
845844
);
846845

847-
let proj = projection.map(|p| {
848-
(
849-
clean_projection(p.map_bound(|p| p.projection_ty), cx, None),
850-
p.map_bound(|p| p.term),
851-
)
852-
});
853-
if let Some(((_, trait_did, name), rhs)) = proj
854-
.as_ref()
855-
.and_then(|(lhs, rhs): &(Type, _)| Some((lhs.projection()?, rhs)))
846+
if let Some(proj) = projection
847+
&& let lhs = clean_projection(proj.map_bound(|p| p.projection_ty), cx, None)
848+
&& let Some((_, trait_did, name)) = lhs.projection()
856849
{
857850
impl_trait_proj.entry(param_idx).or_default().push((
858851
trait_did,
859852
name,
860-
*rhs,
861-
p.get_bound_params()
853+
proj.map_bound(|p| p.term),
854+
pred.get_bound_params()
862855
.into_iter()
863856
.flatten()
864857
.cloned()
@@ -869,13 +862,32 @@ fn clean_ty_generics<'tcx>(
869862
return None;
870863
}
871864

872-
Some(p)
865+
Some(pred)
873866
})
874867
.collect::<Vec<_>>();
875868

876869
for (param, mut bounds) in impl_trait {
870+
let mut has_sized = false;
871+
bounds.retain(|b| {
872+
if b.is_sized_bound(cx) {
873+
has_sized = true;
874+
false
875+
} else {
876+
true
877+
}
878+
});
879+
if !has_sized {
880+
bounds.push(GenericBound::maybe_sized(cx));
881+
}
882+
877883
// Move trait bounds to the front.
878-
bounds.sort_by_key(|b| !matches!(b, GenericBound::TraitBound(..)));
884+
bounds.sort_by_key(|b| !b.is_trait_bound());
885+
886+
// Add back a `Sized` bound if there are no *trait* bounds remaining (incl. `?Sized`).
887+
// Since all potential trait bounds are at the front we can just check the first bound.
888+
if bounds.first().map_or(true, |b| !b.is_trait_bound()) {
889+
bounds.insert(0, GenericBound::sized(cx));
890+
}
879891

880892
let crate::core::ImplTraitParam::ParamIndex(idx) = param else { unreachable!() };
881893
if let Some(proj) = impl_trait_proj.remove(&idx) {
@@ -897,7 +909,7 @@ fn clean_ty_generics<'tcx>(
897909
// implicit `Sized` bound unless removed with `?Sized`.
898910
// However, in the list of where-predicates below, `Sized` appears like a
899911
// normal bound: It's either present (the type is sized) or
900-
// absent (the type is unsized) but never *maybe* (i.e. `?Sized`).
912+
// absent (the type might be unsized) but never *maybe* (i.e. `?Sized`).
901913
//
902914
// This is unsuitable for rendering.
903915
// Thus, as a first step remove all `Sized` bounds that should be implicit.
@@ -908,8 +920,8 @@ fn clean_ty_generics<'tcx>(
908920
let mut sized_params = FxHashSet::default();
909921
where_predicates.retain(|pred| {
910922
if let WherePredicate::BoundPredicate { ty: Generic(g), bounds, .. } = pred
911-
&& *g != kw::SelfUpper
912-
&& bounds.iter().any(|b| b.is_sized_bound(cx))
923+
&& *g != kw::SelfUpper
924+
&& bounds.iter().any(|b| b.is_sized_bound(cx))
913925
{
914926
sized_params.insert(*g);
915927
false
@@ -2119,7 +2131,6 @@ fn clean_middle_opaque_bounds<'tcx>(
21192131
cx: &mut DocContext<'tcx>,
21202132
bounds: Vec<ty::Clause<'tcx>>,
21212133
) -> Type {
2122-
let mut regions = vec![];
21232134
let mut has_sized = false;
21242135
let mut bounds = bounds
21252136
.iter()
@@ -2128,10 +2139,7 @@ fn clean_middle_opaque_bounds<'tcx>(
21282139
let trait_ref = match bound_predicate.skip_binder() {
21292140
ty::ClauseKind::Trait(tr) => bound_predicate.rebind(tr.trait_ref),
21302141
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
2131-
if let Some(r) = clean_middle_region(reg) {
2132-
regions.push(GenericBound::Outlives(r));
2133-
}
2134-
return None;
2142+
return clean_middle_region(reg).map(GenericBound::Outlives);
21352143
}
21362144
_ => return None,
21372145
};
@@ -2167,10 +2175,20 @@ fn clean_middle_opaque_bounds<'tcx>(
21672175
Some(clean_poly_trait_ref_with_bindings(cx, trait_ref, bindings))
21682176
})
21692177
.collect::<Vec<_>>();
2170-
bounds.extend(regions);
2171-
if !has_sized && !bounds.is_empty() {
2172-
bounds.insert(0, GenericBound::maybe_sized(cx));
2178+
2179+
if !has_sized {
2180+
bounds.push(GenericBound::maybe_sized(cx));
21732181
}
2182+
2183+
// Move trait bounds to the front.
2184+
bounds.sort_by_key(|b| !b.is_trait_bound());
2185+
2186+
// Add back a `Sized` bound if there are no *trait* bounds remaining (incl. `?Sized`).
2187+
// Since all potential trait bounds are at the front we can just check the first bound.
2188+
if bounds.first().map_or(true, |b| !b.is_trait_bound()) {
2189+
bounds.insert(0, GenericBound::sized(cx));
2190+
}
2191+
21742192
ImplTrait(bounds)
21752193
}
21762194

‎src/librustdoc/clean/types.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,15 +1219,24 @@ pub(crate) enum GenericBound {
12191219
}
12201220

12211221
impl GenericBound {
1222+
pub(crate) fn sized(cx: &mut DocContext<'_>) -> GenericBound {
1223+
Self::sized_with(cx, hir::TraitBoundModifier::None)
1224+
}
1225+
12221226
pub(crate) fn maybe_sized(cx: &mut DocContext<'_>) -> GenericBound {
1227+
Self::sized_with(cx, hir::TraitBoundModifier::Maybe)
1228+
}
1229+
1230+
fn sized_with(cx: &mut DocContext<'_>, modifier: hir::TraitBoundModifier) -> GenericBound {
12231231
let did = cx.tcx.require_lang_item(LangItem::Sized, None);
12241232
let empty = ty::Binder::dummy(ty::GenericArgs::empty());
12251233
let path = external_path(cx, did, false, ThinVec::new(), empty);
12261234
inline::record_extern_fqn(cx, did, ItemType::Trait);
1227-
GenericBound::TraitBound(
1228-
PolyTrait { trait_: path, generic_params: Vec::new() },
1229-
hir::TraitBoundModifier::Maybe,
1230-
)
1235+
GenericBound::TraitBound(PolyTrait { trait_: path, generic_params: Vec::new() }, modifier)
1236+
}
1237+
1238+
pub(crate) fn is_trait_bound(&self) -> bool {
1239+
matches!(self, Self::TraitBound(..))
12311240
}
12321241

12331242
pub(crate) fn is_sized_bound(&self, cx: &DocContext<'_>) -> bool {

‎src/librustdoc/html/format.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,22 +1102,35 @@ fn fmt_type<'cx>(
11021102
};
11031103
let m = mutability.print_with_space();
11041104
let amp = if f.alternate() { "&" } else { "&amp;" };
1105-
match **ty {
1105+
1106+
if let clean::Generic(name) = **ty {
1107+
return primitive_link(
1108+
f,
1109+
PrimitiveType::Reference,
1110+
&format!("{amp}{lt}{m}{name}"),
1111+
cx,
1112+
);
1113+
}
1114+
1115+
write!(f, "{amp}{lt}{m}")?;
1116+
1117+
let needs_parens = match **ty {
11061118
clean::DynTrait(ref bounds, ref trait_lt)
11071119
if bounds.len() > 1 || trait_lt.is_some() =>
11081120
{
1109-
write!(f, "{}{}{}(", amp, lt, m)?;
1110-
fmt_type(ty, f, use_absolute, cx)?;
1111-
write!(f, ")")
1112-
}
1113-
clean::Generic(name) => {
1114-
primitive_link(f, PrimitiveType::Reference, &format!("{amp}{lt}{m}{name}"), cx)
1115-
}
1116-
_ => {
1117-
write!(f, "{}{}{}", amp, lt, m)?;
1118-
fmt_type(ty, f, use_absolute, cx)
1121+
true
11191122
}
1123+
clean::ImplTrait(ref bounds) if bounds.len() > 1 => true,
1124+
_ => false,
1125+
};
1126+
if needs_parens {
1127+
f.write_str("(")?;
11201128
}
1129+
fmt_type(ty, f, use_absolute, cx)?;
1130+
if needs_parens {
1131+
f.write_str(")")?;
1132+
}
1133+
Ok(())
11211134
}
11221135
clean::ImplTrait(ref bounds) => {
11231136
if f.alternate() {

‎src/tools/compiletest/src/header/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub(super) fn parse_cfg_name_directive<'a>(
112112
(config.target == "wasm32-unknown-unknown").then_some("emscripten"),
113113
],
114114
allowed_names: &target_cfgs.all_oses,
115-
message: "when the operative system is {name}"
115+
message: "when the operating system is {name}"
116116
}
117117
condition! {
118118
name: &target_cfg.env,
@@ -122,7 +122,7 @@ pub(super) fn parse_cfg_name_directive<'a>(
122122
condition! {
123123
name: &target_cfg.os_and_env(),
124124
allowed_names: &target_cfgs.all_oses_and_envs,
125-
message: "when the operative system and target environment are {name}"
125+
message: "when the operating system and target environment are {name}"
126126
}
127127
condition! {
128128
name: &target_cfg.abi,

‎tests/rustdoc/extern-impl-trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ extern crate extern_impl_trait;
77
// @has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo<Associated = ()> + 'a"
88
pub use extern_impl_trait::X;
99

10-
// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl ?Sized + Foo<Associated = ()> + 'a"
10+
// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo<Associated = ()> + ?Sized + 'a"
1111
pub use extern_impl_trait::Y;

‎tests/rustdoc/impl-everywhere.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ pub fn foo_foo() -> impl Foo + Foo2 {
2525
Bar
2626
}
2727

28-
// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo + Foo2"
28+
// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)"
2929
pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) {
3030
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use std::fmt::Debug;
2+
3+
pub fn sized(x: impl Sized) -> impl Sized {
4+
x
5+
}
6+
7+
pub fn sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a {
8+
x
9+
}
10+
11+
pub fn maybe_sized(x: &impl ?Sized) -> &impl ?Sized {
12+
x
13+
}
14+
15+
pub fn debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized) {
16+
x
17+
}
18+
19+
pub fn maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't) {
20+
x
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![crate_name = "user"]
2+
3+
// aux-crate:impl_sized=impl-sized.rs
4+
// edition:2021
5+
6+
// @has user/fn.sized.html
7+
// @has - '//pre[@class="rust item-decl"]' "sized(x: impl Sized) -> impl Sized"
8+
pub use impl_sized::sized;
9+
10+
// @has user/fn.sized_outlives.html
11+
// @has - '//pre[@class="rust item-decl"]' \
12+
// "sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a"
13+
pub use impl_sized::sized_outlives;
14+
15+
// @has user/fn.maybe_sized.html
16+
// @has - '//pre[@class="rust item-decl"]' "maybe_sized(x: &impl ?Sized) -> &impl ?Sized"
17+
pub use impl_sized::maybe_sized;
18+
19+
// @has user/fn.debug_maybe_sized.html
20+
// @has - '//pre[@class="rust item-decl"]' \
21+
// "debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized)"
22+
pub use impl_sized::debug_maybe_sized;
23+
24+
// @has user/fn.maybe_sized_outlives.html
25+
// @has - '//pre[@class="rust item-decl"]' \
26+
// "maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't)"
27+
pub use impl_sized::maybe_sized_outlives;

‎tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ enum DiagnosticOnEnum {
5353
#[derive(Diagnostic)]
5454
#[diag(no_crate_example, code = "E0123")]
5555
#[diag = "E0123"]
56-
//~^ ERROR expected parentheses: #[diag(...)]
56+
//~^ ERROR failed to resolve: maybe a missing crate `core`
5757
struct WrongStructAttrStyle {}
5858

5959
#[derive(Diagnostic)]
@@ -644,7 +644,7 @@ struct MissingCodeInSuggestion {
644644
//~| ERROR cannot find attribute `multipart_suggestion` in this scope
645645
#[multipart_suggestion()]
646646
//~^ ERROR cannot find attribute `multipart_suggestion` in this scope
647-
//~| ERROR unexpected end of input, unexpected token in nested attribute, expected ident
647+
//~| ERROR `#[multipart_suggestion(...)]` is not a valid attribute
648648
struct MultipartSuggestion {
649649
#[multipart_suggestion(no_crate_suggestion)]
650650
//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute
@@ -797,15 +797,15 @@ struct SuggestionsNoItem {
797797
struct SuggestionsInvalidItem {
798798
#[suggestion(code(foo))]
799799
//~^ ERROR `code(...)` must contain only string literals
800-
//~| ERROR unexpected token
800+
//~| ERROR failed to resolve: maybe a missing crate `core`
801801
sub: Span,
802802
}
803803

804804
#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` in this scope
805805
#[diag(no_crate_example)]
806806
struct SuggestionsInvalidLiteral {
807807
#[suggestion(code = 3)]
808-
//~^ ERROR expected string literal
808+
//~^ ERROR failed to resolve: maybe a missing crate `core`
809809
sub: Span,
810810
}
811811

‎tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ LL | Bar,
2020
|
2121
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
2222

23-
error: expected parentheses: #[diag(...)]
24-
--> $DIR/diagnostic-derive.rs:55:8
25-
|
26-
LL | #[diag = "E0123"]
27-
| ^
28-
2923
error: `#[nonsense(...)]` is not a valid attribute
3024
--> $DIR/diagnostic-derive.rs:60:1
3125
|
@@ -476,6 +470,14 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
476470
|
477471
= help: consider creating a `Subdiagnostic` instead
478472

473+
error: `#[multipart_suggestion(...)]` is not a valid attribute
474+
--> $DIR/diagnostic-derive.rs:645:1
475+
|
476+
LL | #[multipart_suggestion()]
477+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
478+
|
479+
= help: consider creating a `Subdiagnostic` instead
480+
479481
error: `#[multipart_suggestion(...)]` is not a valid attribute
480482
--> $DIR/diagnostic-derive.rs:649:5
481483
|
@@ -484,12 +486,6 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
484486
|
485487
= help: consider creating a `Subdiagnostic` instead
486488

487-
error: unexpected end of input, unexpected token in nested attribute, expected ident
488-
--> $DIR/diagnostic-derive.rs:645:24
489-
|
490-
LL | #[multipart_suggestion()]
491-
| ^
492-
493489
error: `#[suggestion(...)]` is not a valid attribute
494490
--> $DIR/diagnostic-derive.rs:657:1
495491
|
@@ -550,18 +546,6 @@ error: `code(...)` must contain only string literals
550546
LL | #[suggestion(code(foo))]
551547
| ^^^
552548

553-
error: unexpected token
554-
--> $DIR/diagnostic-derive.rs:798:23
555-
|
556-
LL | #[suggestion(code(foo))]
557-
| ^^^
558-
559-
error: expected string literal
560-
--> $DIR/diagnostic-derive.rs:807:25
561-
|
562-
LL | #[suggestion(code = 3)]
563-
| ^
564-
565549
error: `#[suggestion(...)]` is not a valid attribute
566550
--> $DIR/diagnostic-derive.rs:822:5
567551
|
@@ -572,6 +556,24 @@ LL | #[suggestion(no_crate_suggestion, code = "")]
572556
= help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]`
573557
= help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]`
574558

559+
error[E0433]: failed to resolve: maybe a missing crate `core`?
560+
--> $DIR/diagnostic-derive.rs:55:8
561+
|
562+
LL | #[diag = "E0123"]
563+
| ^ maybe a missing crate `core`?
564+
565+
error[E0433]: failed to resolve: maybe a missing crate `core`?
566+
--> $DIR/diagnostic-derive.rs:798:23
567+
|
568+
LL | #[suggestion(code(foo))]
569+
| ^^^ maybe a missing crate `core`?
570+
571+
error[E0433]: failed to resolve: maybe a missing crate `core`?
572+
--> $DIR/diagnostic-derive.rs:807:25
573+
|
574+
LL | #[suggestion(code = 3)]
575+
| ^ maybe a missing crate `core`?
576+
575577
error: cannot find attribute `nonsense` in this scope
576578
--> $DIR/diagnostic-derive.rs:60:3
577579
|
@@ -656,5 +658,5 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg`
656658

657659
error: aborting due to 84 previous errors
658660

659-
Some errors have detailed explanations: E0277, E0425.
661+
Some errors have detailed explanations: E0277, E0425, E0433.
660662
For more information about an error, try `rustc --explain E0277`.

‎tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ struct G {
9595

9696
#[derive(Subdiagnostic)]
9797
#[label("...")]
98-
//~^ ERROR unexpected literal in nested attribute, expected ident
98+
//~^ ERROR failed to resolve: maybe a missing crate `core`?
99+
//~| NOTE maybe a missing crate `core`?
99100
struct H {
100101
#[primary_span]
101102
span: Span,
@@ -134,7 +135,7 @@ struct L {
134135

135136
#[derive(Subdiagnostic)]
136137
#[label()]
137-
//~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident
138+
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
138139
struct M {
139140
#[primary_span]
140141
span: Span,
@@ -310,7 +311,8 @@ struct AB {
310311

311312
#[derive(Subdiagnostic)]
312313
union AC {
313-
//~^ ERROR unexpected unsupported untagged union
314+
//~^ ERROR failed to resolve: maybe a missing crate `core`?
315+
//~| NOTE maybe a missing crate `core`?
314316
span: u32,
315317
b: u64,
316318
}
@@ -556,7 +558,7 @@ struct BBb {
556558
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
557559
struct BBc {
558560
#[suggestion_part()]
559-
//~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident
561+
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
560562
span1: Span,
561563
}
562564

@@ -576,11 +578,12 @@ struct BD {
576578
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
577579
span1: Span,
578580
#[suggestion_part()]
579-
//~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident
581+
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
580582
span2: Span,
581583
#[suggestion_part(foo = "bar")]
582584
//~^ ERROR `code` is the only valid nested attribute
583-
//~| ERROR expected `,`
585+
//~| ERROR failed to resolve: maybe a missing crate `core`?
586+
//~| NOTE maybe a missing crate `core`?
584587
span4: Span,
585588
#[suggestion_part(code = "...")]
586589
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
@@ -672,7 +675,8 @@ enum BL {
672675
struct BM {
673676
#[suggestion_part(code("foo"))]
674677
//~^ ERROR expected exactly one string literal for `code = ...`
675-
//~| ERROR unexpected token
678+
//~| ERROR failed to resolve: maybe a missing crate `core`?
679+
//~| NOTE maybe a missing crate `core`?
676680
span: Span,
677681
r#type: String,
678682
}
@@ -682,7 +686,8 @@ struct BM {
682686
struct BN {
683687
#[suggestion_part(code("foo", "bar"))]
684688
//~^ ERROR expected exactly one string literal for `code = ...`
685-
//~| ERROR unexpected token
689+
//~| ERROR failed to resolve: maybe a missing crate `core`?
690+
//~| NOTE maybe a missing crate `core`?
686691
span: Span,
687692
r#type: String,
688693
}
@@ -692,7 +697,8 @@ struct BN {
692697
struct BO {
693698
#[suggestion_part(code(3))]
694699
//~^ ERROR expected exactly one string literal for `code = ...`
695-
//~| ERROR unexpected token
700+
//~| ERROR failed to resolve: maybe a missing crate `core`?
701+
//~| NOTE maybe a missing crate `core`?
696702
span: Span,
697703
r#type: String,
698704
}
@@ -713,7 +719,8 @@ struct BP {
713719
#[multipart_suggestion(no_crate_example)]
714720
struct BQ {
715721
#[suggestion_part(code = 3)]
716-
//~^ ERROR expected string literal
722+
//~^ ERROR failed to resolve: maybe a missing crate `core`?
723+
//~| NOTE maybe a missing crate `core`?
717724
span: Span,
718725
r#type: String,
719726
}
@@ -805,7 +812,8 @@ struct SuggestionStyleInvalid3 {
805812
#[derive(Subdiagnostic)]
806813
#[suggestion(no_crate_example, code = "", style("foo"))]
807814
//~^ ERROR expected `= "xxx"`
808-
//~| ERROr expected `,`
815+
//~| ERROR failed to resolve: maybe a missing crate `core`?
816+
//~| NOTE maybe a missing crate `core`?
809817
struct SuggestionStyleInvalid4 {
810818
#[primary_span]
811819
sub: Span,

‎tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr

Lines changed: 135 additions & 138 deletions
Large diffs are not rendered by default.

‎tests/ui/impl-trait/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// revisions: current next
2-
//[next] compile-flag: -Ztrait-solver=next
2+
//[next] compile-flags: -Ztrait-solver=next
33
// check-pass
44

55
use std::path::Path;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// compile-flags: -Ztrait-solver=next
2+
// check-pass
3+
4+
trait Eq<'a, 'b, T> {}
5+
6+
trait Ambig {}
7+
impl Ambig for () {}
8+
9+
impl<'a, T> Eq<'a, 'a, T> for () where T: Ambig {}
10+
11+
fn eq<'a, 'b, T>(t: T)
12+
where
13+
(): Eq<'a, 'b, T>,
14+
{
15+
}
16+
17+
fn test<'r>() {
18+
let mut x = Default::default();
19+
20+
// When we evaluate `(): Eq<'r, 'r, ?0>` we uniquify the regions.
21+
// That leads us to evaluate `(): Eq<'?0, '?1, ?0>`. The response of this
22+
// will be ambiguous (because `?0: Ambig` is ambig) and also not an "identity"
23+
// response, since the region constraints will contain `'?0 == '?1` (so
24+
// `is_changed` will return true). Since it's both ambig and changed,
25+
// fulfillment will both re-register the goal AND loop again. This hits the
26+
// overflow limit. This should neither be considered overflow, nor ICE.
27+
eq::<'r, 'r, _>(x);
28+
29+
x = ();
30+
}
31+
32+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! ICE: https://github.com/rust-lang/rust/issues/114121
2+
//! This test checks that MIR validation never constrains
3+
//! new hidden types that *differ* from the actual hidden types.
4+
//! This test used to ICE because oli-obk assumed mir validation
5+
//! was only ever run after opaque types were revealed in MIR.
6+
7+
// compile-flags: -Zvalidate-mir
8+
// check-pass
9+
10+
fn main() {
11+
let _ = Some(()).into_iter().flat_map(|_| Some(()).into_iter().flat_map(func));
12+
}
13+
14+
fn func(_: ()) -> impl Iterator<Item = ()> {
15+
Some(()).into_iter().flat_map(|_| vec![])
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.