authorbors <bors@rust-lang.org> 2024-07-18 06:11:35 UTC
committerbors <bors@rust-lang.org> 2024-07-18 06:11:35 UTC
log52f3c71c8dc4aaed71e3035995fcbdd6d78c98c6
tree29470eed894270e4f81716b839c190806fdf0099
parent4bb2f278617e5498ac9a4776d3e1268154c500c5
parent77e5bbf3412a6e5d4defb3445c729dc457cd1fc0

Auto merge of #127898 - matthiaskrgr:rollup-lkkpoui, r=matthiaskrgr

Rollup of 8 pull requests Successful merges: - #127077 (Make language around `ToOwned` for `BorrowedFd` more precise) - #127783 (Put the dots back in RTN pretty printing) - #127787 (Migrate `atomic-lock-free` to `rmake`) - #127810 (Rename `tcx` to `cx` in `rustc_type_ir`) - #127878 (Fix associated item removal suggestion) - #127886 (Accurate `use` rename suggestion span) - #127888 (More accurate span for type parameter suggestion) - #127889 (More accurate span for anonymous argument suggestion) r? `@ghost` `@rustbot` modify labels: rollup

80 files changed, 550 insertions(+), 383 deletions(-)

compiler/rustc_borrowck/src/type_check/relate_tys.rs+4-4
......@@ -309,7 +309,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
309309}
310310
311311impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx> {
312 fn tcx(&self) -> TyCtxt<'tcx> {
312 fn cx(&self) -> TyCtxt<'tcx> {
313313 self.type_checker.infcx.tcx
314314 }
315315
......@@ -370,7 +370,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
370370 // shouldn't ever fail. Instead, it unconditionally emits an
371371 // alias-relate goal.
372372 assert!(!self.type_checker.infcx.next_trait_solver());
373 self.tcx().dcx().span_delayed_bug(
373 self.cx().dcx().span_delayed_bug(
374374 self.span(),
375375 "failure to relate an opaque to itself should result in an error later on",
376376 );
......@@ -540,7 +540,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
540540 &mut self,
541541 obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
542542 ) {
543 let tcx = self.tcx();
543 let tcx = self.cx();
544544 let param_env = self.param_env();
545545 self.register_goals(
546546 obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)),
......@@ -559,7 +559,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
559559 .into_iter()
560560 .map(|goal| {
561561 Obligation::new(
562 self.tcx(),
562 self.cx(),
563563 ObligationCause::dummy_with_span(self.span()),
564564 goal.param_env,
565565 goal.predicate,
compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs+11-11
......@@ -1257,14 +1257,12 @@ pub fn prohibit_assoc_item_constraint(
12571257 };
12581258
12591259 // Now emit the suggestion
1260 if let Ok(suggestion) = tcx.sess.source_map().span_to_snippet(removal_span) {
1261 e.span_suggestion_verbose(
1262 removal_span,
1263 format!("consider removing this associated item {}", constraint.kind.descr()),
1264 suggestion,
1265 Applicability::MaybeIncorrect,
1266 );
1267 }
1260 e.span_suggestion_verbose(
1261 removal_span,
1262 format!("consider removing this associated item {}", constraint.kind.descr()),
1263 "",
1264 Applicability::MaybeIncorrect,
1265 );
12681266 };
12691267
12701268 // Suggest replacing the associated item binding with a generic argument.
......@@ -1340,11 +1338,13 @@ pub fn prohibit_assoc_item_constraint(
13401338 format!("<{lifetimes}{type_with_constraints}>"),
13411339 )
13421340 };
1343 let suggestions =
1344 vec![param_decl, (constraint.span, format!("{}", matching_param.name))];
1341 let suggestions = vec![
1342 param_decl,
1343 (constraint.span.with_lo(constraint.ident.span.hi()), String::new()),
1344 ];
13451345
13461346 err.multipart_suggestion_verbose(
1347 format!("declare the type parameter right after the `impl` keyword"),
1347 "declare the type parameter right after the `impl` keyword",
13481348 suggestions,
13491349 Applicability::MaybeIncorrect,
13501350 );
compiler/rustc_infer/src/error_reporting/infer/mod.rs+1-1
......@@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19301930struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>);
19311931
19321932impl<'tcx> TypeRelation<TyCtxt<'tcx>> for SameTypeModuloInfer<'_, 'tcx> {
1933 fn tcx(&self) -> TyCtxt<'tcx> {
1933 fn cx(&self) -> TyCtxt<'tcx> {
19341934 self.0.tcx
19351935 }
19361936
compiler/rustc_infer/src/infer/outlives/test_type_match.rs+1-1
......@@ -137,7 +137,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx>
137137 "MatchAgainstHigherRankedOutlives"
138138 }
139139
140 fn tcx(&self) -> TyCtxt<'tcx> {
140 fn cx(&self) -> TyCtxt<'tcx> {
141141 self.tcx
142142 }
143143
compiler/rustc_infer/src/infer/relate/generalize.rs+6-6
......@@ -372,7 +372,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
372372
373373 let is_nested_alias = mem::replace(&mut self.in_alias, true);
374374 let result = match self.relate(alias, alias) {
375 Ok(alias) => Ok(alias.to_ty(self.tcx())),
375 Ok(alias) => Ok(alias.to_ty(self.cx())),
376376 Err(e) => {
377377 if is_nested_alias {
378378 return Err(e);
......@@ -397,7 +397,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
397397}
398398
399399impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
400 fn tcx(&self) -> TyCtxt<'tcx> {
400 fn cx(&self) -> TyCtxt<'tcx> {
401401 self.infcx.tcx
402402 }
403403
......@@ -417,7 +417,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
417417 // (e.g., #41849).
418418 relate::relate_args_invariantly(self, a_arg, b_arg)
419419 } else {
420 let tcx = self.tcx();
420 let tcx = self.cx();
421421 let opt_variances = tcx.variances_of(item_def_id);
422422 relate::relate_args_with_variances(
423423 self,
......@@ -525,7 +525,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
525525 }
526526
527527 debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
528 Ok(Ty::new_var(self.tcx(), new_var_id))
528 Ok(Ty::new_var(self.cx(), new_var_id))
529529 }
530530 }
531531 }
......@@ -654,7 +654,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
654654 {
655655 variable_table.union(vid, new_var_id);
656656 }
657 Ok(ty::Const::new_var(self.tcx(), new_var_id))
657 Ok(ty::Const::new_var(self.cx(), new_var_id))
658658 }
659659 }
660660 }
......@@ -672,7 +672,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
672672 args,
673673 args,
674674 )?;
675 Ok(ty::Const::new_unevaluated(self.tcx(), ty::UnevaluatedConst { def, args }))
675 Ok(ty::Const::new_unevaluated(self.cx(), ty::UnevaluatedConst { def, args }))
676676 }
677677 ty::ConstKind::Placeholder(placeholder) => {
678678 if self.for_universe.can_name(placeholder.universe) {
compiler/rustc_infer/src/infer/relate/glb.rs+2-2
......@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
2727 "Glb"
2828 }
2929
30 fn tcx(&self) -> TyCtxt<'tcx> {
30 fn cx(&self) -> TyCtxt<'tcx> {
3131 self.fields.tcx()
3232 }
3333
......@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
6161 let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262 // GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8
6363 Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
64 self.tcx(),
64 self.cx(),
6565 origin,
6666 a,
6767 b,
compiler/rustc_infer/src/infer/relate/lub.rs+2-2
......@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
2727 "Lub"
2828 }
2929
30 fn tcx(&self) -> TyCtxt<'tcx> {
30 fn cx(&self) -> TyCtxt<'tcx> {
3131 self.fields.tcx()
3232 }
3333
......@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
6161 let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262 // LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8
6363 Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
64 self.tcx(),
64 self.cx(),
6565 origin,
6666 a,
6767 b,
compiler/rustc_infer/src/infer/relate/type_relating.rs+5-5
......@@ -32,7 +32,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
3232 "TypeRelating"
3333 }
3434
35 fn tcx(&self) -> TyCtxt<'tcx> {
35 fn cx(&self) -> TyCtxt<'tcx> {
3636 self.fields.infcx.tcx
3737 }
3838
......@@ -48,7 +48,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
4848 // (e.g., #41849).
4949 relate_args_invariantly(self, a_arg, b_arg)
5050 } else {
51 let tcx = self.tcx();
51 let tcx = self.cx();
5252 let opt_variances = tcx.variances_of(item_def_id);
5353 relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, false)
5454 }
......@@ -88,7 +88,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
8888 // can't make progress on `A <: B` if both A and B are
8989 // type variables, so record an obligation.
9090 self.fields.goals.push(Goal::new(
91 self.tcx(),
91 self.cx(),
9292 self.fields.param_env,
9393 ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
9494 a_is_expected: true,
......@@ -101,7 +101,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
101101 // can't make progress on `B <: A` if both A and B are
102102 // type variables, so record an obligation.
103103 self.fields.goals.push(Goal::new(
104 self.tcx(),
104 self.cx(),
105105 self.fields.param_env,
106106 ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
107107 a_is_expected: false,
......@@ -134,7 +134,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
134134
135135 (&ty::Error(e), _) | (_, &ty::Error(e)) => {
136136 infcx.set_tainted_by_errors(e);
137 return Ok(Ty::new_error(self.tcx(), e));
137 return Ok(Ty::new_error(self.cx(), e));
138138 }
139139
140140 (
compiler/rustc_macros/src/lift.rs+1-1
......@@ -45,7 +45,7 @@ pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStre
4545 quote! {
4646 type Lifted = #lifted;
4747
48 fn lift_to_tcx(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
48 fn lift_to_interner(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
4949 Some(match self { #body })
5050 }
5151 },
compiler/rustc_middle/src/macros.rs+1-1
......@@ -59,7 +59,7 @@ macro_rules! TrivialLiftImpls {
5959 $(
6060 impl<'tcx> $crate::ty::Lift<$crate::ty::TyCtxt<'tcx>> for $ty {
6161 type Lifted = Self;
62 fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
62 fn lift_to_interner(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
6363 Some(self)
6464 }
6565 }
compiler/rustc_middle/src/ty/context.rs+4-4
......@@ -1484,7 +1484,7 @@ impl<'tcx> TyCtxt<'tcx> {
14841484 }
14851485
14861486 pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
1487 value.lift_to_tcx(self)
1487 value.lift_to_interner(self)
14881488 }
14891489
14901490 /// Creates a type context. To use the context call `fn enter` which
......@@ -2087,7 +2087,7 @@ macro_rules! nop_lift {
20872087 ($set:ident; $ty:ty => $lifted:ty) => {
20882088 impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for $ty {
20892089 type Lifted = $lifted;
2090 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
2090 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
20912091 // Assert that the set has the right type.
20922092 // Given an argument that has an interned type, the return type has the type of
20932093 // the corresponding interner set. This won't actually return anything, we're
......@@ -2122,7 +2122,7 @@ macro_rules! nop_list_lift {
21222122 ($set:ident; $ty:ty => $lifted:ty) => {
21232123 impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a List<$ty> {
21242124 type Lifted = &'tcx List<$lifted>;
2125 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
2125 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
21262126 // Assert that the set has the right type.
21272127 if false {
21282128 let _x: &InternedSet<'tcx, List<$lifted>> = &tcx.interners.$set;
......@@ -2160,7 +2160,7 @@ macro_rules! nop_slice_lift {
21602160 ($ty:ty => $lifted:ty) => {
21612161 impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a [$ty] {
21622162 type Lifted = &'tcx [$lifted];
2163 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
2163 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
21642164 if self.is_empty() {
21652165 return Some(&[]);
21662166 }
compiler/rustc_middle/src/ty/generic_args.rs+1-1
......@@ -308,7 +308,7 @@ impl<'tcx> GenericArg<'tcx> {
308308impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
309309 type Lifted = GenericArg<'tcx>;
310310
311 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
311 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
312312 match self.unpack() {
313313 GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
314314 GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),
compiler/rustc_middle/src/ty/print/pretty.rs+5-2
......@@ -1214,11 +1214,14 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
12141214 && let ty::Alias(_, alias_ty) =
12151215 self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind()
12161216 && alias_ty.def_id == def_id
1217 && let generics = self.tcx().generics_of(fn_def_id)
1218 // FIXME(return_type_notation): We only support lifetime params for now.
1219 && generics.own_params.iter().all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime))
12171220 {
1218 let num_args = self.tcx().generics_of(fn_def_id).count();
1221 let num_args = generics.count();
12191222 write!(self, " {{ ")?;
12201223 self.print_def_path(fn_def_id, &args[..num_args])?;
1221 write!(self, "() }}")?;
1224 write!(self, "(..) }}")?;
12221225 }
12231226
12241227 Ok(())
compiler/rustc_middle/src/ty/relate.rs+2-2
......@@ -69,7 +69,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Pattern<'tcx> {
6969 if inc_a != inc_b {
7070 todo!()
7171 }
72 Ok(relation.tcx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
72 Ok(relation.cx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
7373 }
7474 }
7575 }
......@@ -81,7 +81,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate<
8181 a: Self,
8282 b: Self,
8383 ) -> RelateResult<'tcx, Self> {
84 let tcx = relation.tcx();
84 let tcx = relation.cx();
8585
8686 // FIXME: this is wasteful, but want to do a perf run to see how slow it is.
8787 // We need to perform this deduplication as we sometimes generate duplicate projections
compiler/rustc_middle/src/ty/structural_impls.rs+2-2
......@@ -283,7 +283,7 @@ TrivialTypeTraversalAndLiftImpls! {
283283
284284impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
285285 type Lifted = Option<T::Lifted>;
286 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
286 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
287287 Some(match self {
288288 Some(x) => Some(tcx.lift(x)?),
289289 None => None,
......@@ -293,7 +293,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
293293
294294impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
295295 type Lifted = ty::Term<'tcx>;
296 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
296 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
297297 match self.unpack() {
298298 TermKind::Ty(ty) => tcx.lift(ty).map(Into::into),
299299 TermKind::Const(c) => tcx.lift(c).map(Into::into),
compiler/rustc_parse/src/parser/diagnostics.rs+6-6
......@@ -2240,11 +2240,11 @@ impl<'a> Parser<'a> {
22402240 }
22412241 _ => {
22422242 // Otherwise, try to get a type and emit a suggestion.
2243 if let Some(ty) = pat.to_ty() {
2243 if let Some(_) = pat.to_ty() {
22442244 err.span_suggestion_verbose(
2245 pat.span,
2245 pat.span.shrink_to_lo(),
22462246 "explicitly ignore the parameter name",
2247 format!("_: {}", pprust::ty_to_string(&ty)),
2247 "_: ".to_string(),
22482248 Applicability::MachineApplicable,
22492249 );
22502250 err.note(rfc_note);
......@@ -2256,7 +2256,7 @@ impl<'a> Parser<'a> {
22562256
22572257 // `fn foo(a, b) {}`, `fn foo(a<x>, b<y>) {}` or `fn foo(usize, usize) {}`
22582258 if first_param {
2259 err.span_suggestion(
2259 err.span_suggestion_verbose(
22602260 self_span,
22612261 "if this is a `self` type, give it a parameter name",
22622262 self_sugg,
......@@ -2266,14 +2266,14 @@ impl<'a> Parser<'a> {
22662266 // Avoid suggesting that `fn foo(HashMap<u32>)` is fixed with a change to
22672267 // `fn foo(HashMap: TypeName<u32>)`.
22682268 if self.token != token::Lt {
2269 err.span_suggestion(
2269 err.span_suggestion_verbose(
22702270 param_span,
22712271 "if this is a parameter name, give it a type",
22722272 param_sugg,
22732273 Applicability::HasPlaceholders,
22742274 );
22752275 }
2276 err.span_suggestion(
2276 err.span_suggestion_verbose(
22772277 type_span,
22782278 "if this is a type, explicitly ignore the parameter name",
22792279 type_sugg,
compiler/rustc_resolve/src/diagnostics.rs+10-8
......@@ -371,6 +371,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
371371 };
372372
373373 let mut suggestion = None;
374 let mut span = binding_span;
374375 match import.kind {
375376 ImportKind::Single { type_ns_only: true, .. } => {
376377 suggestion = Some(format!("self as {suggested_name}"))
......@@ -381,12 +382,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
381382 {
382383 if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(binding_span) {
383384 if pos <= snippet.len() {
384 suggestion = Some(format!(
385 "{} as {}{}",
386 &snippet[..pos],
387 suggested_name,
388 if snippet.ends_with(';') { ";" } else { "" }
389 ))
385 span = binding_span
386 .with_lo(binding_span.lo() + BytePos(pos as u32))
387 .with_hi(
388 binding_span.hi()
389 - BytePos(if snippet.ends_with(';') { 1 } else { 0 }),
390 );
391 suggestion = Some(format!(" as {suggested_name}"));
390392 }
391393 }
392394 }
......@@ -402,9 +404,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
402404 }
403405
404406 if let Some(suggestion) = suggestion {
405 err.subdiagnostic(ChangeImportBindingSuggestion { span: binding_span, suggestion });
407 err.subdiagnostic(ChangeImportBindingSuggestion { span, suggestion });
406408 } else {
407 err.subdiagnostic(ChangeImportBinding { span: binding_span });
409 err.subdiagnostic(ChangeImportBinding { span });
408410 }
409411 }
410412
compiler/rustc_trait_selection/src/traits/select/_match.rs+2-2
......@@ -36,7 +36,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
3636 "MatchAgainstFreshVars"
3737 }
3838
39 fn tcx(&self) -> TyCtxt<'tcx> {
39 fn cx(&self) -> TyCtxt<'tcx> {
4040 self.tcx
4141 }
4242
......@@ -77,7 +77,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
7777 Err(TypeError::Sorts(ExpectedFound::new(true, a, b)))
7878 }
7979
80 (&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)),
80 (&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.cx(), guar)),
8181
8282 _ => structurally_relate_tys(self, a, b),
8383 }
compiler/rustc_type_ir/src/binder.rs+18-18
......@@ -49,10 +49,10 @@ where
4949{
5050 type Lifted = Binder<U, T::Lifted>;
5151
52 fn lift_to_tcx(self, tcx: U) -> Option<Self::Lifted> {
52 fn lift_to_interner(self, cx: U) -> Option<Self::Lifted> {
5353 Some(Binder {
54 value: self.value.lift_to_tcx(tcx)?,
55 bound_vars: self.bound_vars.lift_to_tcx(tcx)?,
54 value: self.value.lift_to_interner(cx)?,
55 bound_vars: self.bound_vars.lift_to_interner(cx)?,
5656 })
5757 }
5858}
......@@ -439,11 +439,11 @@ impl<I: Interner, Iter: IntoIterator> EarlyBinder<I, Iter>
439439where
440440 Iter::Item: TypeFoldable<I>,
441441{
442 pub fn iter_instantiated<A>(self, tcx: I, args: A) -> IterInstantiated<I, Iter, A>
442 pub fn iter_instantiated<A>(self, cx: I, args: A) -> IterInstantiated<I, Iter, A>
443443 where
444444 A: SliceLike<Item = I::GenericArg>,
445445 {
446 IterInstantiated { it: self.value.into_iter(), tcx, args }
446 IterInstantiated { it: self.value.into_iter(), cx, args }
447447 }
448448
449449 /// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity),
......@@ -455,7 +455,7 @@ where
455455
456456pub struct IterInstantiated<I: Interner, Iter: IntoIterator, A> {
457457 it: Iter::IntoIter,
458 tcx: I,
458 cx: I,
459459 args: A,
460460}
461461
......@@ -469,7 +469,7 @@ where
469469 fn next(&mut self) -> Option<Self::Item> {
470470 Some(
471471 EarlyBinder { value: self.it.next()?, _tcx: PhantomData }
472 .instantiate(self.tcx, self.args),
472 .instantiate(self.cx, self.args),
473473 )
474474 }
475475
......@@ -487,7 +487,7 @@ where
487487 fn next_back(&mut self) -> Option<Self::Item> {
488488 Some(
489489 EarlyBinder { value: self.it.next_back()?, _tcx: PhantomData }
490 .instantiate(self.tcx, self.args),
490 .instantiate(self.cx, self.args),
491491 )
492492 }
493493}
......@@ -507,10 +507,10 @@ where
507507{
508508 pub fn iter_instantiated_copied(
509509 self,
510 tcx: I,
510 cx: I,
511511 args: &'s [I::GenericArg],
512512 ) -> IterInstantiatedCopied<'s, I, Iter> {
513 IterInstantiatedCopied { it: self.value.into_iter(), tcx, args }
513 IterInstantiatedCopied { it: self.value.into_iter(), cx, args }
514514 }
515515
516516 /// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity),
......@@ -522,7 +522,7 @@ where
522522
523523pub struct IterInstantiatedCopied<'a, I: Interner, Iter: IntoIterator> {
524524 it: Iter::IntoIter,
525 tcx: I,
525 cx: I,
526526 args: &'a [I::GenericArg],
527527}
528528
......@@ -535,7 +535,7 @@ where
535535
536536 fn next(&mut self) -> Option<Self::Item> {
537537 self.it.next().map(|value| {
538 EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.tcx, self.args)
538 EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.cx, self.args)
539539 })
540540 }
541541
......@@ -552,7 +552,7 @@ where
552552{
553553 fn next_back(&mut self) -> Option<Self::Item> {
554554 self.it.next_back().map(|value| {
555 EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.tcx, self.args)
555 EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.cx, self.args)
556556 })
557557 }
558558}
......@@ -589,11 +589,11 @@ impl<I: Interner, T: Iterator> Iterator for EarlyBinderIter<I, T> {
589589}
590590
591591impl<I: Interner, T: TypeFoldable<I>> ty::EarlyBinder<I, T> {
592 pub fn instantiate<A>(self, tcx: I, args: A) -> T
592 pub fn instantiate<A>(self, cx: I, args: A) -> T
593593 where
594594 A: SliceLike<Item = I::GenericArg>,
595595 {
596 let mut folder = ArgFolder { tcx, args: args.as_slice(), binders_passed: 0 };
596 let mut folder = ArgFolder { cx, args: args.as_slice(), binders_passed: 0 };
597597 self.value.fold_with(&mut folder)
598598 }
599599
......@@ -619,7 +619,7 @@ impl<I: Interner, T: TypeFoldable<I>> ty::EarlyBinder<I, T> {
619619// The actual instantiation engine itself is a type folder.
620620
621621struct ArgFolder<'a, I: Interner> {
622 tcx: I,
622 cx: I,
623623 args: &'a [I::GenericArg],
624624
625625 /// Number of region binders we have passed through while doing the instantiation
......@@ -629,7 +629,7 @@ struct ArgFolder<'a, I: Interner> {
629629impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> {
630630 #[inline]
631631 fn cx(&self) -> I {
632 self.tcx
632 self.cx
633633 }
634634
635635 fn fold_binder<T: TypeFoldable<I>>(&mut self, t: ty::Binder<I, T>) -> ty::Binder<I, T> {
......@@ -858,6 +858,6 @@ impl<'a, I: Interner> ArgFolder<'a, I> {
858858 if self.binders_passed == 0 || !region.has_escaping_bound_vars() {
859859 return region;
860860 }
861 ty::fold::shift_region(self.tcx, region, self.binders_passed)
861 ty::fold::shift_region(self.cx, region, self.binders_passed)
862862 }
863863}
compiler/rustc_type_ir/src/canonical.rs+6-6
......@@ -330,25 +330,25 @@ impl<I: Interner> CanonicalVarValues<I> {
330330
331331 // Given a list of canonical variables, construct a set of values which are
332332 // the identity response.
333 pub fn make_identity(tcx: I, infos: I::CanonicalVars) -> CanonicalVarValues<I> {
333 pub fn make_identity(cx: I, infos: I::CanonicalVars) -> CanonicalVarValues<I> {
334334 CanonicalVarValues {
335 var_values: tcx.mk_args_from_iter(infos.iter().enumerate().map(
335 var_values: cx.mk_args_from_iter(infos.iter().enumerate().map(
336336 |(i, info)| -> I::GenericArg {
337337 match info.kind {
338338 CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => {
339 Ty::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i))
339 Ty::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i))
340340 .into()
341341 }
342342 CanonicalVarKind::Region(_) | CanonicalVarKind::PlaceholderRegion(_) => {
343 Region::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i))
343 Region::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i))
344344 .into()
345345 }
346346 CanonicalVarKind::Effect => {
347 Const::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i))
347 Const::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i))
348348 .into()
349349 }
350350 CanonicalVarKind::Const(_) | CanonicalVarKind::PlaceholderConst(_) => {
351 Const::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i))
351 Const::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i))
352352 .into()
353353 }
354354 }
compiler/rustc_type_ir/src/effects.rs+10-10
......@@ -10,38 +10,38 @@ pub enum EffectKind {
1010}
1111
1212impl EffectKind {
13 pub fn try_from_def_id<I: Interner>(tcx: I, def_id: I::DefId) -> Option<EffectKind> {
14 if tcx.is_lang_item(def_id, EffectsMaybe) {
13 pub fn try_from_def_id<I: Interner>(cx: I, def_id: I::DefId) -> Option<EffectKind> {
14 if cx.is_lang_item(def_id, EffectsMaybe) {
1515 Some(EffectKind::Maybe)
16 } else if tcx.is_lang_item(def_id, EffectsRuntime) {
16 } else if cx.is_lang_item(def_id, EffectsRuntime) {
1717 Some(EffectKind::Runtime)
18 } else if tcx.is_lang_item(def_id, EffectsNoRuntime) {
18 } else if cx.is_lang_item(def_id, EffectsNoRuntime) {
1919 Some(EffectKind::NoRuntime)
2020 } else {
2121 None
2222 }
2323 }
2424
25 pub fn to_def_id<I: Interner>(self, tcx: I) -> I::DefId {
25 pub fn to_def_id<I: Interner>(self, cx: I) -> I::DefId {
2626 let lang_item = match self {
2727 EffectKind::Maybe => EffectsMaybe,
2828 EffectKind::NoRuntime => EffectsNoRuntime,
2929 EffectKind::Runtime => EffectsRuntime,
3030 };
3131
32 tcx.require_lang_item(lang_item)
32 cx.require_lang_item(lang_item)
3333 }
3434
35 pub fn try_from_ty<I: Interner>(tcx: I, ty: I::Ty) -> Option<EffectKind> {
35 pub fn try_from_ty<I: Interner>(cx: I, ty: I::Ty) -> Option<EffectKind> {
3636 if let crate::Adt(def, _) = ty.kind() {
37 Self::try_from_def_id(tcx, def.def_id())
37 Self::try_from_def_id(cx, def.def_id())
3838 } else {
3939 None
4040 }
4141 }
4242
43 pub fn to_ty<I: Interner>(self, tcx: I) -> I::Ty {
44 I::Ty::new_adt(tcx, tcx.adt_def(self.to_def_id(tcx)), Default::default())
43 pub fn to_ty<I: Interner>(self, cx: I) -> I::Ty {
44 I::Ty::new_adt(cx, cx.adt_def(self.to_def_id(cx)), Default::default())
4545 }
4646
4747 /// Returns an intersection between two effect kinds. If one effect kind
compiler/rustc_type_ir/src/elaborate.rs+4-4
......@@ -258,17 +258,17 @@ pub fn supertrait_def_ids<I: Interner>(
258258}
259259
260260pub fn supertraits<I: Interner>(
261 tcx: I,
261 cx: I,
262262 trait_ref: ty::Binder<I, ty::TraitRef<I>>,
263263) -> FilterToTraits<I, Elaborator<I, I::Clause>> {
264 elaborate(tcx, [trait_ref.upcast(tcx)]).filter_only_self().filter_to_traits()
264 elaborate(cx, [trait_ref.upcast(cx)]).filter_only_self().filter_to_traits()
265265}
266266
267267pub fn transitive_bounds<I: Interner>(
268 tcx: I,
268 cx: I,
269269 trait_refs: impl Iterator<Item = ty::Binder<I, ty::TraitRef<I>>>,
270270) -> FilterToTraits<I, Elaborator<I, I::Clause>> {
271 elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.upcast(tcx)))
271 elaborate(cx, trait_refs.map(|trait_ref| trait_ref.upcast(cx)))
272272 .filter_only_self()
273273 .filter_to_traits()
274274}
compiler/rustc_type_ir/src/fast_reject.rs+3-3
......@@ -105,7 +105,7 @@ pub enum TreatParams {
105105///
106106/// ¹ meaning that if the outermost layers are different, then the whole types are also different.
107107pub fn simplify_type<I: Interner>(
108 tcx: I,
108 cx: I,
109109 ty: I::Ty,
110110 treat_params: TreatParams,
111111) -> Option<SimplifiedType<I::DefId>> {
......@@ -119,10 +119,10 @@ pub fn simplify_type<I: Interner>(
119119 ty::Str => Some(SimplifiedType::Str),
120120 ty::Array(..) => Some(SimplifiedType::Array),
121121 ty::Slice(..) => Some(SimplifiedType::Slice),
122 ty::Pat(ty, ..) => simplify_type(tcx, ty, treat_params),
122 ty::Pat(ty, ..) => simplify_type(cx, ty, treat_params),
123123 ty::RawPtr(_, mutbl) => Some(SimplifiedType::Ptr(mutbl)),
124124 ty::Dynamic(trait_info, ..) => match trait_info.principal_def_id() {
125 Some(principal_def_id) if !tcx.trait_is_auto(principal_def_id) => {
125 Some(principal_def_id) if !cx.trait_is_auto(principal_def_id) => {
126126 Some(SimplifiedType::Trait(principal_def_id))
127127 }
128128 _ => Some(SimplifiedType::MarkerTraitObject),
compiler/rustc_type_ir/src/fold.rs+11-11
......@@ -345,20 +345,20 @@ impl<I: Interner, T: TypeFoldable<I>, Ix: Idx> TypeFoldable<I> for IndexVec<Ix,
345345// `rustc_middle/src/ty/generic_args.rs` for more details.
346346
347347struct Shifter<I: Interner> {
348 tcx: I,
348 cx: I,
349349 current_index: ty::DebruijnIndex,
350350 amount: u32,
351351}
352352
353353impl<I: Interner> Shifter<I> {
354 pub fn new(tcx: I, amount: u32) -> Self {
355 Shifter { tcx, current_index: ty::INNERMOST, amount }
354 pub fn new(cx: I, amount: u32) -> Self {
355 Shifter { cx, current_index: ty::INNERMOST, amount }
356356 }
357357}
358358
359359impl<I: Interner> TypeFolder<I> for Shifter<I> {
360360 fn cx(&self) -> I {
361 self.tcx
361 self.cx
362362 }
363363
364364 fn fold_binder<T: TypeFoldable<I>>(&mut self, t: ty::Binder<I, T>) -> ty::Binder<I, T> {
......@@ -372,7 +372,7 @@ impl<I: Interner> TypeFolder<I> for Shifter<I> {
372372 match r.kind() {
373373 ty::ReBound(debruijn, br) if debruijn >= self.current_index => {
374374 let debruijn = debruijn.shifted_in(self.amount);
375 Region::new_bound(self.tcx, debruijn, br)
375 Region::new_bound(self.cx, debruijn, br)
376376 }
377377 _ => r,
378378 }
......@@ -382,7 +382,7 @@ impl<I: Interner> TypeFolder<I> for Shifter<I> {
382382 match ty.kind() {
383383 ty::Bound(debruijn, bound_ty) if debruijn >= self.current_index => {
384384 let debruijn = debruijn.shifted_in(self.amount);
385 Ty::new_bound(self.tcx, debruijn, bound_ty)
385 Ty::new_bound(self.cx, debruijn, bound_ty)
386386 }
387387
388388 _ if ty.has_vars_bound_at_or_above(self.current_index) => ty.super_fold_with(self),
......@@ -394,7 +394,7 @@ impl<I: Interner> TypeFolder<I> for Shifter<I> {
394394 match ct.kind() {
395395 ty::ConstKind::Bound(debruijn, bound_ct) if debruijn >= self.current_index => {
396396 let debruijn = debruijn.shifted_in(self.amount);
397 Const::new_bound(self.tcx, debruijn, bound_ct)
397 Const::new_bound(self.cx, debruijn, bound_ct)
398398 }
399399 _ => ct.super_fold_with(self),
400400 }
......@@ -405,16 +405,16 @@ impl<I: Interner> TypeFolder<I> for Shifter<I> {
405405 }
406406}
407407
408pub fn shift_region<I: Interner>(tcx: I, region: I::Region, amount: u32) -> I::Region {
408pub fn shift_region<I: Interner>(cx: I, region: I::Region, amount: u32) -> I::Region {
409409 match region.kind() {
410410 ty::ReBound(debruijn, br) if amount > 0 => {
411 Region::new_bound(tcx, debruijn.shifted_in(amount), br)
411 Region::new_bound(cx, debruijn.shifted_in(amount), br)
412412 }
413413 _ => region,
414414 }
415415}
416416
417pub fn shift_vars<I: Interner, T>(tcx: I, value: T, amount: u32) -> T
417pub fn shift_vars<I: Interner, T>(cx: I, value: T, amount: u32) -> T
418418where
419419 T: TypeFoldable<I>,
420420{
......@@ -424,5 +424,5 @@ where
424424 return value;
425425 }
426426
427 value.fold_with(&mut Shifter::new(tcx, amount))
427 value.fold_with(&mut Shifter::new(cx, amount))
428428}
compiler/rustc_type_ir/src/inherent.rs+1-1
......@@ -475,7 +475,7 @@ pub trait Clause<I: Interner<Clause = Self>>:
475475 /// poly-trait-ref to supertraits that must hold if that
476476 /// poly-trait-ref holds. This is slightly different from a normal
477477 /// instantiation in terms of what happens with bound regions.
478 fn instantiate_supertrait(self, tcx: I, trait_ref: ty::Binder<I, ty::TraitRef<I>>) -> Self;
478 fn instantiate_supertrait(self, cx: I, trait_ref: ty::Binder<I, ty::TraitRef<I>>) -> Self;
479479}
480480
481481/// Common capabilities of placeholder kinds
compiler/rustc_type_ir/src/lift.rs+1-1
......@@ -17,5 +17,5 @@
1717/// e.g., `()` or `u8`, was interned in a different context.
1818pub trait Lift<I>: std::fmt::Debug {
1919 type Lifted: std::fmt::Debug;
20 fn lift_to_tcx(self, tcx: I) -> Option<Self::Lifted>;
20 fn lift_to_interner(self, cx: I) -> Option<Self::Lifted>;
2121}
compiler/rustc_type_ir/src/opaque_ty.rs+5-5
......@@ -22,8 +22,8 @@ pub struct OpaqueTypeKey<I: Interner> {
2222}
2323
2424impl<I: Interner> OpaqueTypeKey<I> {
25 pub fn iter_captured_args(self, tcx: I) -> impl Iterator<Item = (usize, I::GenericArg)> {
26 let variances = tcx.variances_of(self.def_id.into());
25 pub fn iter_captured_args(self, cx: I) -> impl Iterator<Item = (usize, I::GenericArg)> {
26 let variances = cx.variances_of(self.def_id.into());
2727 std::iter::zip(self.args.iter(), variances.iter()).enumerate().filter_map(
2828 |(i, (arg, v))| match (arg.kind(), v) {
2929 (_, ty::Invariant) => Some((i, arg)),
......@@ -35,18 +35,18 @@ impl<I: Interner> OpaqueTypeKey<I> {
3535
3636 pub fn fold_captured_lifetime_args(
3737 self,
38 tcx: I,
38 cx: I,
3939 mut f: impl FnMut(I::Region) -> I::Region,
4040 ) -> Self {
4141 let Self { def_id, args } = self;
42 let variances = tcx.variances_of(def_id.into());
42 let variances = cx.variances_of(def_id.into());
4343 let args =
4444 std::iter::zip(args.iter(), variances.iter()).map(|(arg, v)| match (arg.kind(), v) {
4545 (ty::GenericArgKind::Lifetime(_), ty::Bivariant) => arg,
4646 (ty::GenericArgKind::Lifetime(lt), _) => f(lt).into(),
4747 _ => arg,
4848 });
49 let args = tcx.mk_args_from_iter(args);
49 let args = cx.mk_args_from_iter(args);
5050 Self { def_id, args }
5151 }
5252}
compiler/rustc_type_ir/src/outlives.rs+7-7
......@@ -54,15 +54,15 @@ pub enum Component<I: Interner> {
5454/// Push onto `out` all the things that must outlive `'a` for the condition
5555/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
5656pub fn push_outlives_components<I: Interner>(
57 tcx: I,
57 cx: I,
5858 ty: I::Ty,
5959 out: &mut SmallVec<[Component<I>; 4]>,
6060) {
61 ty.visit_with(&mut OutlivesCollector { tcx, out, visited: Default::default() });
61 ty.visit_with(&mut OutlivesCollector { cx, out, visited: Default::default() });
6262}
6363
6464struct OutlivesCollector<'a, I: Interner> {
65 tcx: I,
65 cx: I,
6666 out: &'a mut SmallVec<[Component<I>; 4]>,
6767 visited: SsoHashSet<I::Ty>,
6868}
......@@ -147,7 +147,7 @@ impl<I: Interner> TypeVisitor<I> for OutlivesCollector<'_, I> {
147147 // OutlivesProjectionComponents. Continue walking
148148 // through and constrain Pi.
149149 let mut subcomponents = smallvec![];
150 compute_alias_components_recursive(self.tcx, ty, &mut subcomponents);
150 compute_alias_components_recursive(self.cx, ty, &mut subcomponents);
151151 self.out.push(Component::EscapingAlias(subcomponents.into_iter().collect()));
152152 }
153153 }
......@@ -206,7 +206,7 @@ impl<I: Interner> TypeVisitor<I> for OutlivesCollector<'_, I> {
206206/// This should not be used to get the components of `parent` itself.
207207/// Use [push_outlives_components] instead.
208208pub fn compute_alias_components_recursive<I: Interner>(
209 tcx: I,
209 cx: I,
210210 alias_ty: I::Ty,
211211 out: &mut SmallVec<[Component<I>; 4]>,
212212) {
......@@ -215,9 +215,9 @@ pub fn compute_alias_components_recursive<I: Interner>(
215215 };
216216
217217 let opt_variances =
218 if kind == ty::Opaque { Some(tcx.variances_of(alias_ty.def_id)) } else { None };
218 if kind == ty::Opaque { Some(cx.variances_of(alias_ty.def_id)) } else { None };
219219
220 let mut visitor = OutlivesCollector { tcx, out, visited: Default::default() };
220 let mut visitor = OutlivesCollector { cx, out, visited: Default::default() };
221221
222222 for (index, child) in alias_ty.args.iter().enumerate() {
223223 if opt_variances.and_then(|variances| variances.get(index)) == Some(ty::Bivariant) {
compiler/rustc_type_ir/src/predicate.rs+18-20
......@@ -34,8 +34,8 @@ where
3434{
3535 type Lifted = OutlivesPredicate<U, A::Lifted>;
3636
37 fn lift_to_tcx(self, tcx: U) -> Option<Self::Lifted> {
38 Some(OutlivesPredicate(self.0.lift_to_tcx(tcx)?, self.1.lift_to_tcx(tcx)?))
37 fn lift_to_interner(self, cx: U) -> Option<Self::Lifted> {
38 Some(OutlivesPredicate(self.0.lift_to_interner(cx)?, self.1.lift_to_interner(cx)?))
3939 }
4040}
4141
......@@ -267,25 +267,23 @@ impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
267267 /// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`),
268268 /// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self`
269269 /// has been replaced with `self_ty` (e.g., `self_ty: PartialEq<u32>`, in our example).
270 pub fn with_self_ty(&self, tcx: I, self_ty: I::Ty) -> I::Clause {
270 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause {
271271 match self.skip_binder() {
272 ExistentialPredicate::Trait(tr) => {
273 self.rebind(tr).with_self_ty(tcx, self_ty).upcast(tcx)
274 }
272 ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx),
275273 ExistentialPredicate::Projection(p) => {
276 self.rebind(p.with_self_ty(tcx, self_ty)).upcast(tcx)
274 self.rebind(p.with_self_ty(cx, self_ty)).upcast(cx)
277275 }
278276 ExistentialPredicate::AutoTrait(did) => {
279 let generics = tcx.generics_of(did);
277 let generics = cx.generics_of(did);
280278 let trait_ref = if generics.count() == 1 {
281 ty::TraitRef::new(tcx, did, [self_ty])
279 ty::TraitRef::new(cx, did, [self_ty])
282280 } else {
283281 // If this is an ill-formed auto trait, then synthesize
284282 // new error args for the missing generics.
285 let err_args = GenericArgs::extend_with_error(tcx, did, &[self_ty.into()]);
286 ty::TraitRef::new_from_args(tcx, did, err_args)
283 let err_args = GenericArgs::extend_with_error(cx, did, &[self_ty.into()]);
284 ty::TraitRef::new_from_args(cx, did, err_args)
287285 };
288 self.rebind(trait_ref).upcast(tcx)
286 self.rebind(trait_ref).upcast(cx)
289287 }
290288 }
291289 }
......@@ -345,8 +343,8 @@ impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> {
345343 /// we convert the principal trait-ref into a normal trait-ref,
346344 /// you must give *some* self type. A common choice is `mk_err()`
347345 /// or some placeholder type.
348 pub fn with_self_ty(&self, tcx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
349 self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty))
346 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
347 self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty))
350348 }
351349}
352350
......@@ -406,8 +404,8 @@ impl<I: Interner> ExistentialProjection<I> {
406404}
407405
408406impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
409 pub fn with_self_ty(&self, tcx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionPredicate<I>> {
410 self.map_bound(|p| p.with_self_ty(tcx, self_ty))
407 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionPredicate<I>> {
408 self.map_bound(|p| p.with_self_ty(cx, self_ty))
411409 }
412410
413411 pub fn item_def_id(&self) -> I::DefId {
......@@ -669,21 +667,21 @@ impl<I: Interner> ProjectionPredicate<I> {
669667impl<I: Interner> ty::Binder<I, ProjectionPredicate<I>> {
670668 /// Returns the `DefId` of the trait of the associated item being projected.
671669 #[inline]
672 pub fn trait_def_id(&self, tcx: I) -> I::DefId {
673 self.skip_binder().projection_term.trait_def_id(tcx)
670 pub fn trait_def_id(&self, cx: I) -> I::DefId {
671 self.skip_binder().projection_term.trait_def_id(cx)
674672 }
675673
676674 /// Get the trait ref required for this projection to be well formed.
677675 /// Note that for generic associated types the predicates of the associated
678676 /// type also need to be checked.
679677 #[inline]
680 pub fn required_poly_trait_ref(&self, tcx: I) -> ty::Binder<I, TraitRef<I>> {
678 pub fn required_poly_trait_ref(&self, cx: I) -> ty::Binder<I, TraitRef<I>> {
681679 // Note: unlike with `TraitRef::to_poly_trait_ref()`,
682680 // `self.0.trait_ref` is permitted to have escaping regions.
683681 // This is because here `self` has a `Binder` and so does our
684682 // return value, so we are preserving the number of binding
685683 // levels.
686 self.map_bound(|predicate| predicate.projection_term.trait_ref(tcx))
684 self.map_bound(|predicate| predicate.projection_term.trait_ref(cx))
687685 }
688686
689687 pub fn term(&self) -> ty::Binder<I, I::Term> {
compiler/rustc_type_ir/src/relate.rs+44-45
......@@ -56,7 +56,7 @@ impl<I: Interner> VarianceDiagInfo<I> {
5656}
5757
5858pub trait TypeRelation<I: Interner>: Sized {
59 fn tcx(&self) -> I;
59 fn cx(&self) -> I;
6060
6161 /// Returns a static string we can use for printouts.
6262 fn tag(&self) -> &'static str;
......@@ -80,8 +80,8 @@ pub trait TypeRelation<I: Interner>: Sized {
8080 item_def_id, a_arg, b_arg
8181 );
8282
83 let tcx = self.tcx();
84 let opt_variances = tcx.variances_of(item_def_id);
83 let cx = self.cx();
84 let opt_variances = cx.variances_of(item_def_id);
8585 relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, true)
8686 }
8787
......@@ -128,7 +128,7 @@ pub fn relate_args_invariantly<I: Interner, R: TypeRelation<I>>(
128128 a_arg: I::GenericArgs,
129129 b_arg: I::GenericArgs,
130130) -> RelateResult<I, I::GenericArgs> {
131 relation.tcx().mk_args_from_iter(iter::zip(a_arg.iter(), b_arg.iter()).map(|(a, b)| {
131 relation.cx().mk_args_from_iter(iter::zip(a_arg.iter(), b_arg.iter()).map(|(a, b)| {
132132 relation.relate_with_variance(ty::Invariant, VarianceDiagInfo::default(), a, b)
133133 }))
134134}
......@@ -141,14 +141,13 @@ pub fn relate_args_with_variances<I: Interner, R: TypeRelation<I>>(
141141 b_arg: I::GenericArgs,
142142 fetch_ty_for_diag: bool,
143143) -> RelateResult<I, I::GenericArgs> {
144 let tcx = relation.tcx();
144 let cx = relation.cx();
145145
146146 let mut cached_ty = None;
147147 let params = iter::zip(a_arg.iter(), b_arg.iter()).enumerate().map(|(i, (a, b))| {
148148 let variance = variances.get(i).unwrap();
149149 let variance_info = if variance == ty::Invariant && fetch_ty_for_diag {
150 let ty =
151 *cached_ty.get_or_insert_with(|| tcx.type_of(ty_def_id).instantiate(tcx, a_arg));
150 let ty = *cached_ty.get_or_insert_with(|| cx.type_of(ty_def_id).instantiate(cx, a_arg));
152151 VarianceDiagInfo::Invariant { ty, param_index: i.try_into().unwrap() }
153152 } else {
154153 VarianceDiagInfo::default()
......@@ -156,7 +155,7 @@ pub fn relate_args_with_variances<I: Interner, R: TypeRelation<I>>(
156155 relation.relate_with_variance(variance, variance_info, a, b)
157156 });
158157
159 tcx.mk_args_from_iter(params)
158 cx.mk_args_from_iter(params)
160159}
161160
162161impl<I: Interner> Relate<I> for ty::FnSig<I> {
......@@ -165,7 +164,7 @@ impl<I: Interner> Relate<I> for ty::FnSig<I> {
165164 a: ty::FnSig<I>,
166165 b: ty::FnSig<I>,
167166 ) -> RelateResult<I, ty::FnSig<I>> {
168 let tcx = relation.tcx();
167 let cx = relation.cx();
169168
170169 if a.c_variadic != b.c_variadic {
171170 return Err(TypeError::VariadicMismatch({
......@@ -210,7 +209,7 @@ impl<I: Interner> Relate<I> for ty::FnSig<I> {
210209 r => r,
211210 });
212211 Ok(ty::FnSig {
213 inputs_and_output: tcx.mk_type_list_from_iter(inputs_and_output)?,
212 inputs_and_output: cx.mk_type_list_from_iter(inputs_and_output)?,
214213 c_variadic: a.c_variadic,
215214 safety,
216215 abi,
......@@ -245,11 +244,11 @@ impl<I: Interner> Relate<I> for ty::AliasTy<I> {
245244 ExpectedFound::new(true, a, b)
246245 }))
247246 } else {
248 let args = match a.kind(relation.tcx()) {
247 let args = match a.kind(relation.cx()) {
249248 ty::Opaque => relate_args_with_variances(
250249 relation,
251250 a.def_id,
252 relation.tcx().variances_of(a.def_id),
251 relation.cx().variances_of(a.def_id),
253252 a.args,
254253 b.args,
255254 false, // do not fetch `type_of(a_def_id)`, as it will cause a cycle
......@@ -258,7 +257,7 @@ impl<I: Interner> Relate<I> for ty::AliasTy<I> {
258257 relate_args_invariantly(relation, a.args, b.args)?
259258 }
260259 };
261 Ok(ty::AliasTy::new_from_args(relation.tcx(), a.def_id, args))
260 Ok(ty::AliasTy::new_from_args(relation.cx(), a.def_id, args))
262261 }
263262 }
264263}
......@@ -276,11 +275,11 @@ impl<I: Interner> Relate<I> for ty::AliasTerm<I> {
276275 ExpectedFound::new(true, a, b)
277276 }))
278277 } else {
279 let args = match a.kind(relation.tcx()) {
278 let args = match a.kind(relation.cx()) {
280279 ty::AliasTermKind::OpaqueTy => relate_args_with_variances(
281280 relation,
282281 a.def_id,
283 relation.tcx().variances_of(a.def_id),
282 relation.cx().variances_of(a.def_id),
284283 a.args,
285284 b.args,
286285 false, // do not fetch `type_of(a_def_id)`, as it will cause a cycle
......@@ -293,7 +292,7 @@ impl<I: Interner> Relate<I> for ty::AliasTerm<I> {
293292 relate_args_invariantly(relation, a.args, b.args)?
294293 }
295294 };
296 Ok(ty::AliasTerm::new_from_args(relation.tcx(), a.def_id, args))
295 Ok(ty::AliasTerm::new_from_args(relation.cx(), a.def_id, args))
297296 }
298297 }
299298}
......@@ -343,7 +342,7 @@ impl<I: Interner> Relate<I> for ty::TraitRef<I> {
343342 }))
344343 } else {
345344 let args = relate_args_invariantly(relation, a.args, b.args)?;
346 Ok(ty::TraitRef::new_from_args(relation.tcx(), a.def_id, args))
345 Ok(ty::TraitRef::new_from_args(relation.cx(), a.def_id, args))
347346 }
348347 }
349348}
......@@ -377,7 +376,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
377376 a: I::Ty,
378377 b: I::Ty,
379378) -> RelateResult<I, I::Ty> {
380 let tcx = relation.tcx();
379 let cx = relation.cx();
381380 match (a.kind(), b.kind()) {
382381 (ty::Infer(_), _) | (_, ty::Infer(_)) => {
383382 // The caller should handle these cases!
......@@ -388,7 +387,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
388387 panic!("bound types encountered in structurally_relate_tys")
389388 }
390389
391 (ty::Error(guar), _) | (_, ty::Error(guar)) => Ok(Ty::new_error(tcx, guar)),
390 (ty::Error(guar), _) | (_, ty::Error(guar)) => Ok(Ty::new_error(cx, guar)),
392391
393392 (ty::Never, _)
394393 | (ty::Char, _)
......@@ -412,16 +411,16 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
412411
413412 (ty::Adt(a_def, a_args), ty::Adt(b_def, b_args)) if a_def == b_def => {
414413 let args = relation.relate_item_args(a_def.def_id(), a_args, b_args)?;
415 Ok(Ty::new_adt(tcx, a_def, args))
414 Ok(Ty::new_adt(cx, a_def, args))
416415 }
417416
418 (ty::Foreign(a_id), ty::Foreign(b_id)) if a_id == b_id => Ok(Ty::new_foreign(tcx, a_id)),
417 (ty::Foreign(a_id), ty::Foreign(b_id)) if a_id == b_id => Ok(Ty::new_foreign(cx, a_id)),
419418
420419 (ty::Dynamic(a_obj, a_region, a_repr), ty::Dynamic(b_obj, b_region, b_repr))
421420 if a_repr == b_repr =>
422421 {
423422 Ok(Ty::new_dynamic(
424 tcx,
423 cx,
425424 relation.relate(a_obj, b_obj)?,
426425 relation.relate(a_region, b_region)?,
427426 a_repr,
......@@ -433,7 +432,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
433432 // the (anonymous) type of the same coroutine expression. So
434433 // all of their regions should be equated.
435434 let args = relate_args_invariantly(relation, a_args, b_args)?;
436 Ok(Ty::new_coroutine(tcx, a_id, args))
435 Ok(Ty::new_coroutine(cx, a_id, args))
437436 }
438437
439438 (ty::CoroutineWitness(a_id, a_args), ty::CoroutineWitness(b_id, b_args))
......@@ -443,7 +442,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
443442 // the (anonymous) type of the same coroutine expression. So
444443 // all of their regions should be equated.
445444 let args = relate_args_invariantly(relation, a_args, b_args)?;
446 Ok(Ty::new_coroutine_witness(tcx, a_id, args))
445 Ok(Ty::new_coroutine_witness(cx, a_id, args))
447446 }
448447
449448 (ty::Closure(a_id, a_args), ty::Closure(b_id, b_args)) if a_id == b_id => {
......@@ -451,14 +450,14 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
451450 // the (anonymous) type of the same closure expression. So
452451 // all of their regions should be equated.
453452 let args = relate_args_invariantly(relation, a_args, b_args)?;
454 Ok(Ty::new_closure(tcx, a_id, args))
453 Ok(Ty::new_closure(cx, a_id, args))
455454 }
456455
457456 (ty::CoroutineClosure(a_id, a_args), ty::CoroutineClosure(b_id, b_args))
458457 if a_id == b_id =>
459458 {
460459 let args = relate_args_invariantly(relation, a_args, b_args)?;
461 Ok(Ty::new_coroutine_closure(tcx, a_id, args))
460 Ok(Ty::new_coroutine_closure(cx, a_id, args))
462461 }
463462
464463 (ty::RawPtr(a_ty, a_mutbl), ty::RawPtr(b_ty, b_mutbl)) => {
......@@ -475,7 +474,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
475474
476475 let ty = relation.relate_with_variance(variance, info, a_ty, b_ty)?;
477476
478 Ok(Ty::new_ptr(tcx, ty, a_mutbl))
477 Ok(Ty::new_ptr(cx, ty, a_mutbl))
479478 }
480479
481480 (ty::Ref(a_r, a_ty, a_mutbl), ty::Ref(b_r, b_ty, b_mutbl)) => {
......@@ -493,18 +492,18 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
493492 let r = relation.relate(a_r, b_r)?;
494493 let ty = relation.relate_with_variance(variance, info, a_ty, b_ty)?;
495494
496 Ok(Ty::new_ref(tcx, r, ty, a_mutbl))
495 Ok(Ty::new_ref(cx, r, ty, a_mutbl))
497496 }
498497
499498 (ty::Array(a_t, sz_a), ty::Array(b_t, sz_b)) => {
500499 let t = relation.relate(a_t, b_t)?;
501500 match relation.relate(sz_a, sz_b) {
502 Ok(sz) => Ok(Ty::new_array_with_const_len(tcx, t, sz)),
501 Ok(sz) => Ok(Ty::new_array_with_const_len(cx, t, sz)),
503502 Err(err) => {
504503 // Check whether the lengths are both concrete/known values,
505504 // but are unequal, for better diagnostics.
506 let sz_a = sz_a.try_to_target_usize(tcx);
507 let sz_b = sz_b.try_to_target_usize(tcx);
505 let sz_a = sz_a.try_to_target_usize(cx);
506 let sz_b = sz_b.try_to_target_usize(cx);
508507
509508 match (sz_a, sz_b) {
510509 (Some(sz_a_val), Some(sz_b_val)) if sz_a_val != sz_b_val => Err(
......@@ -518,13 +517,13 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
518517
519518 (ty::Slice(a_t), ty::Slice(b_t)) => {
520519 let t = relation.relate(a_t, b_t)?;
521 Ok(Ty::new_slice(tcx, t))
520 Ok(Ty::new_slice(cx, t))
522521 }
523522
524523 (ty::Tuple(as_), ty::Tuple(bs)) => {
525524 if as_.len() == bs.len() {
526525 Ok(Ty::new_tup_from_iter(
527 tcx,
526 cx,
528527 iter::zip(as_.iter(), bs.iter()).map(|(a, b)| relation.relate(a, b)),
529528 )?)
530529 } else if !(as_.is_empty() || bs.is_empty()) {
......@@ -536,25 +535,25 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
536535
537536 (ty::FnDef(a_def_id, a_args), ty::FnDef(b_def_id, b_args)) if a_def_id == b_def_id => {
538537 let args = relation.relate_item_args(a_def_id, a_args, b_args)?;
539 Ok(Ty::new_fn_def(tcx, a_def_id, args))
538 Ok(Ty::new_fn_def(cx, a_def_id, args))
540539 }
541540
542541 (ty::FnPtr(a_fty), ty::FnPtr(b_fty)) => {
543542 let fty = relation.relate(a_fty, b_fty)?;
544 Ok(Ty::new_fn_ptr(tcx, fty))
543 Ok(Ty::new_fn_ptr(cx, fty))
545544 }
546545
547546 // Alias tend to mostly already be handled downstream due to normalization.
548547 (ty::Alias(a_kind, a_data), ty::Alias(b_kind, b_data)) => {
549548 let alias_ty = relation.relate(a_data, b_data)?;
550549 assert_eq!(a_kind, b_kind);
551 Ok(Ty::new_alias(tcx, a_kind, alias_ty))
550 Ok(Ty::new_alias(cx, a_kind, alias_ty))
552551 }
553552
554553 (ty::Pat(a_ty, a_pat), ty::Pat(b_ty, b_pat)) => {
555554 let ty = relation.relate(a_ty, b_ty)?;
556555 let pat = relation.relate(a_pat, b_pat)?;
557 Ok(Ty::new_pat(tcx, ty, pat))
556 Ok(Ty::new_pat(cx, ty, pat))
558557 }
559558
560559 _ => Err(TypeError::Sorts(ExpectedFound::new(true, a, b))),
......@@ -573,11 +572,11 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>(
573572 mut b: I::Const,
574573) -> RelateResult<I, I::Const> {
575574 debug!("{}.structurally_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
576 let tcx = relation.tcx();
575 let cx = relation.cx();
577576
578 if tcx.features().generic_const_exprs() {
579 a = tcx.expand_abstract_consts(a);
580 b = tcx.expand_abstract_consts(b);
577 if cx.features().generic_const_exprs() {
578 a = cx.expand_abstract_consts(a);
579 b = cx.expand_abstract_consts(b);
581580 }
582581
583582 debug!("{}.structurally_relate_consts(normed_a = {:?}, normed_b = {:?})", relation.tag(), a, b);
......@@ -607,8 +606,8 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>(
607606 // be stabilized.
608607 (ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => {
609608 if cfg!(debug_assertions) {
610 let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args);
611 let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args);
609 let a_ty = cx.type_of(au.def).instantiate(cx, au.args);
610 let b_ty = cx.type_of(bu.def).instantiate(cx, bu.args);
612611 assert_eq!(a_ty, b_ty);
613612 }
614613
......@@ -618,11 +617,11 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>(
618617 au.args,
619618 bu.args,
620619 )?;
621 return Ok(Const::new_unevaluated(tcx, ty::UnevaluatedConst { def: au.def, args }));
620 return Ok(Const::new_unevaluated(cx, ty::UnevaluatedConst { def: au.def, args }));
622621 }
623622 (ty::ConstKind::Expr(ae), ty::ConstKind::Expr(be)) => {
624623 let expr = relation.relate(ae, be)?;
625 return Ok(Const::new_expr(tcx, expr));
624 return Ok(Const::new_expr(cx, expr));
626625 }
627626 _ => false,
628627 };
compiler/rustc_type_ir/src/solve/mod.rs+4-4
......@@ -106,13 +106,13 @@ pub struct Goal<I: Interner, P> {
106106}
107107
108108impl<I: Interner, P> Goal<I, P> {
109 pub fn new(tcx: I, param_env: I::ParamEnv, predicate: impl Upcast<I, P>) -> Goal<I, P> {
110 Goal { param_env, predicate: predicate.upcast(tcx) }
109 pub fn new(cx: I, param_env: I::ParamEnv, predicate: impl Upcast<I, P>) -> Goal<I, P> {
110 Goal { param_env, predicate: predicate.upcast(cx) }
111111 }
112112
113113 /// Updates the goal to one with a different `predicate` but the same `param_env`.
114 pub fn with<Q>(self, tcx: I, predicate: impl Upcast<I, Q>) -> Goal<I, Q> {
115 Goal { param_env: self.param_env, predicate: predicate.upcast(tcx) }
114 pub fn with<Q>(self, cx: I, predicate: impl Upcast<I, Q>) -> Goal<I, Q> {
115 Goal { param_env: self.param_env, predicate: predicate.upcast(cx) }
116116 }
117117}
118118
compiler/rustc_type_ir/src/ty_kind/closure.rs+17-17
......@@ -136,9 +136,9 @@ pub struct ClosureArgsParts<I: Interner> {
136136impl<I: Interner> ClosureArgs<I> {
137137 /// Construct `ClosureArgs` from `ClosureArgsParts`, containing `Args`
138138 /// for the closure parent, alongside additional closure-specific components.
139 pub fn new(tcx: I, parts: ClosureArgsParts<I>) -> ClosureArgs<I> {
139 pub fn new(cx: I, parts: ClosureArgsParts<I>) -> ClosureArgs<I> {
140140 ClosureArgs {
141 args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([
141 args: cx.mk_args_from_iter(parts.parent_args.iter().chain([
142142 parts.closure_kind_ty.into(),
143143 parts.closure_sig_as_fn_ptr_ty.into(),
144144 parts.tupled_upvars_ty.into(),
......@@ -258,9 +258,9 @@ pub struct CoroutineClosureArgsParts<I: Interner> {
258258}
259259
260260impl<I: Interner> CoroutineClosureArgs<I> {
261 pub fn new(tcx: I, parts: CoroutineClosureArgsParts<I>) -> CoroutineClosureArgs<I> {
261 pub fn new(cx: I, parts: CoroutineClosureArgsParts<I>) -> CoroutineClosureArgs<I> {
262262 CoroutineClosureArgs {
263 args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([
263 args: cx.mk_args_from_iter(parts.parent_args.iter().chain([
264264 parts.closure_kind_ty.into(),
265265 parts.signature_parts_ty.into(),
266266 parts.tupled_upvars_ty.into(),
......@@ -409,14 +409,14 @@ impl<I: Interner> CoroutineClosureSignature<I> {
409409 /// When the kind and upvars are known, use the other helper functions.
410410 pub fn to_coroutine(
411411 self,
412 tcx: I,
412 cx: I,
413413 parent_args: I::GenericArgsSlice,
414414 coroutine_kind_ty: I::Ty,
415415 coroutine_def_id: I::DefId,
416416 tupled_upvars_ty: I::Ty,
417417 ) -> I::Ty {
418418 let coroutine_args = ty::CoroutineArgs::new(
419 tcx,
419 cx,
420420 ty::CoroutineArgsParts {
421421 parent_args,
422422 kind_ty: coroutine_kind_ty,
......@@ -428,7 +428,7 @@ impl<I: Interner> CoroutineClosureSignature<I> {
428428 },
429429 );
430430
431 Ty::new_coroutine(tcx, coroutine_def_id, coroutine_args.args)
431 Ty::new_coroutine(cx, coroutine_def_id, coroutine_args.args)
432432 }
433433
434434 /// Given known upvars and a [`ClosureKind`](ty::ClosureKind), compute the coroutine
......@@ -438,7 +438,7 @@ impl<I: Interner> CoroutineClosureSignature<I> {
438438 /// that the `ClosureKind` is actually supported by the coroutine-closure.
439439 pub fn to_coroutine_given_kind_and_upvars(
440440 self,
441 tcx: I,
441 cx: I,
442442 parent_args: I::GenericArgsSlice,
443443 coroutine_def_id: I::DefId,
444444 goal_kind: ty::ClosureKind,
......@@ -447,7 +447,7 @@ impl<I: Interner> CoroutineClosureSignature<I> {
447447 coroutine_captures_by_ref_ty: I::Ty,
448448 ) -> I::Ty {
449449 let tupled_upvars_ty = Self::tupled_upvars_by_closure_kind(
450 tcx,
450 cx,
451451 goal_kind,
452452 self.tupled_inputs_ty,
453453 closure_tupled_upvars_ty,
......@@ -456,9 +456,9 @@ impl<I: Interner> CoroutineClosureSignature<I> {
456456 );
457457
458458 self.to_coroutine(
459 tcx,
459 cx,
460460 parent_args,
461 Ty::from_coroutine_closure_kind(tcx, goal_kind),
461 Ty::from_coroutine_closure_kind(cx, goal_kind),
462462 coroutine_def_id,
463463 tupled_upvars_ty,
464464 )
......@@ -474,7 +474,7 @@ impl<I: Interner> CoroutineClosureSignature<I> {
474474 /// lifetimes are related to the lifetime of the borrow on the closure made for
475475 /// the call. This allows borrowck to enforce the self-borrows correctly.
476476 pub fn tupled_upvars_by_closure_kind(
477 tcx: I,
477 cx: I,
478478 kind: ty::ClosureKind,
479479 tupled_inputs_ty: I::Ty,
480480 closure_tupled_upvars_ty: I::Ty,
......@@ -488,12 +488,12 @@ impl<I: Interner> CoroutineClosureSignature<I> {
488488 };
489489 let coroutine_captures_by_ref_ty =
490490 sig.output().skip_binder().fold_with(&mut FoldEscapingRegions {
491 interner: tcx,
491 interner: cx,
492492 region: env_region,
493493 debruijn: ty::INNERMOST,
494494 });
495495 Ty::new_tup_from_iter(
496 tcx,
496 cx,
497497 tupled_inputs_ty
498498 .tuple_fields()
499499 .iter()
......@@ -501,7 +501,7 @@ impl<I: Interner> CoroutineClosureSignature<I> {
501501 )
502502 }
503503 ty::ClosureKind::FnOnce => Ty::new_tup_from_iter(
504 tcx,
504 cx,
505505 tupled_inputs_ty
506506 .tuple_fields()
507507 .iter()
......@@ -615,9 +615,9 @@ pub struct CoroutineArgsParts<I: Interner> {
615615impl<I: Interner> CoroutineArgs<I> {
616616 /// Construct `CoroutineArgs` from `CoroutineArgsParts`, containing `Args`
617617 /// for the coroutine parent, alongside additional coroutine-specific components.
618 pub fn new(tcx: I, parts: CoroutineArgsParts<I>) -> CoroutineArgs<I> {
618 pub fn new(cx: I, parts: CoroutineArgsParts<I>) -> CoroutineArgs<I> {
619619 CoroutineArgs {
620 args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([
620 args: cx.mk_args_from_iter(parts.parent_args.iter().chain([
621621 parts.kind_ty.into(),
622622 parts.resume_ty.into(),
623623 parts.yield_ty.into(),
compiler/rustc_type_ir_macros/src/lib.rs+2-2
......@@ -71,7 +71,7 @@ fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
7171 wc.push(parse_quote! { #ty: ::rustc_type_ir::lift::Lift<J, Lifted = #lifted_ty> });
7272 let bind = &bindings[index];
7373 quote! {
74 #bind.lift_to_tcx(interner)?
74 #bind.lift_to_interner(interner)?
7575 }
7676 })
7777 });
......@@ -89,7 +89,7 @@ fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
8989 quote! {
9090 type Lifted = #lifted_ty;
9191
92 fn lift_to_tcx(
92 fn lift_to_interner(
9393 self,
9494 interner: J,
9595 ) -> Option<Self::Lifted> {
library/std/src/os/fd/owned.rs+10-3
......@@ -24,9 +24,14 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
2424/// passed as an argument, it is not captured or consumed, and it never has the
2525/// value `-1`.
2626///
27/// This type's `.to_owned()` implementation returns another `BorrowedFd`
28/// rather than an `OwnedFd`. It just makes a trivial copy of the raw file
29/// descriptor, which is then borrowed under the same lifetime.
27/// This type does not have a [`ToOwned`][crate::borrow::ToOwned]
28/// implementation. Calling `.to_owned()` on a variable of this type will call
29/// it on `&BorrowedFd` and use `Clone::clone()` like `ToOwned` does for all
30/// types implementing `Clone`. The result will be descriptor borrowed under
31/// the same lifetime.
32///
33/// To obtain an [`OwnedFd`], you can use [`BorrowedFd::try_clone_to_owned`]
34/// instead, but this is not supported on all platforms.
3035#[derive(Copy, Clone)]
3136#[repr(transparent)]
3237#[rustc_layout_scalar_valid_range_start(0)]
......@@ -50,6 +55,8 @@ pub struct BorrowedFd<'fd> {
5055/// descriptor, so it can be used in FFI in places where a file descriptor is
5156/// passed as a consumed argument or returned as an owned value, and it never
5257/// has the value `-1`.
58///
59/// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`].
5360#[repr(transparent)]
5461#[rustc_layout_scalar_valid_range_start(0)]
5562// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a
src/tools/run-make-support/src/lib.rs+1-1
......@@ -61,7 +61,7 @@ pub use env::{env_var, env_var_os};
6161pub use run::{cmd, run, run_fail, run_with_args};
6262
6363/// Helpers for checking target information.
64pub use targets::{is_darwin, is_msvc, is_windows, target, uname};
64pub use targets::{is_darwin, is_msvc, is_windows, llvm_components_contain, target, uname};
6565
6666/// Helpers for building names of output artifacts that are potentially target-specific.
6767pub use artifact_names::{
src/tools/run-make-support/src/targets.rs+7
......@@ -28,6 +28,13 @@ pub fn is_darwin() -> bool {
2828 target().contains("darwin")
2929}
3030
31/// Check if `component` is within `LLVM_COMPONENTS`
32#[must_use]
33pub fn llvm_components_contain(component: &str) -> bool {
34 // `LLVM_COMPONENTS` is a space-separated list of words
35 env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some()
36}
37
3138/// Run `uname`. This assumes that `uname` is available on the platform!
3239#[track_caller]
3340#[must_use]
src/tools/tidy/src/allowed_run_make_makefiles.txt-1
......@@ -1,5 +1,4 @@
11run-make/archive-duplicate-names/Makefile
2run-make/atomic-lock-free/Makefile
32run-make/branch-protection-check-IBT/Makefile
43run-make/c-dynamic-dylib/Makefile
54run-make/c-dynamic-rlib/Makefile
tests/run-make/atomic-lock-free/Makefile deleted-48
......@@ -1,48 +0,0 @@
1include ../tools.mk
2
3# This tests ensure that atomic types are never lowered into runtime library calls that are not
4# guaranteed to be lock-free.
5
6all:
7ifeq ($(UNAME),Linux)
8ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
9 $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs
10 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
11 $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
12 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
13endif
14ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
15 $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs
16 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
17 $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs
18 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
19 $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs
20 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
21 $(RUSTC) --target=thumbv7neon-unknown-linux-gnueabihf atomic_lock_free.rs
22 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
23endif
24ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64)
25 $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs
26 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
27endif
28ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
29 $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs
30 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
31 $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs
32 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
33endif
34ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc)
35 $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs
36 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
37 $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs
38 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
39 $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs
40 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
41 $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs
42 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
43endif
44ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz)
45 $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs
46 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
47endif
48endif
tests/run-make/atomic-lock-free/rmake.rs created+52
......@@ -0,0 +1,52 @@
1// This tests ensure that atomic types are never lowered into runtime library calls that are not
2// guaranteed to be lock-free.
3
4//@ only-linux
5
6use run_make_support::{llvm_components_contain, llvm_readobj, rustc};
7
8fn compile(target: &str) {
9 rustc().input("atomic_lock_free.rs").target(target).run();
10}
11
12fn check() {
13 llvm_readobj()
14 .symbols()
15 .input("libatomic_lock_free.rlib")
16 .run()
17 .assert_stdout_not_contains("__atomic_fetch_add");
18}
19
20fn compile_and_check(target: &str) {
21 compile(target);
22 check();
23}
24
25fn main() {
26 if llvm_components_contain("x86") {
27 compile_and_check("i686-unknown-linux-gnu");
28 compile_and_check("x86_64-unknown-linux-gnu");
29 }
30 if llvm_components_contain("arm") {
31 compile_and_check("arm-unknown-linux-gnueabi");
32 compile_and_check("arm-unknown-linux-gnueabihf");
33 compile_and_check("armv7-unknown-linux-gnueabihf");
34 compile_and_check("thumbv7neon-unknown-linux-gnueabihf");
35 }
36 if llvm_components_contain("aarch64") {
37 compile_and_check("aarch64-unknown-linux-gnu");
38 }
39 if llvm_components_contain("mips") {
40 compile_and_check("mips-unknown-linux-gnu");
41 compile_and_check("mipsel-unknown-linux-gnu");
42 }
43 if llvm_components_contain("powerpc") {
44 compile_and_check("powerpc-unknown-linux-gnu");
45 compile_and_check("powerpc-unknown-linux-gnuspe");
46 compile_and_check("powerpc64-unknown-linux-gnu");
47 compile_and_check("powerpc64le-unknown-linux-gnu");
48 }
49 if llvm_components_contain("systemz") {
50 compile_and_check("s390x-unknown-linux-gnu");
51 }
52}
tests/rustdoc-ui/ice-unresolved-import-100241.stderr created+11
......@@ -0,0 +1,11 @@
1error[E0432]: unresolved import `inner`
2 --> $DIR/ice-unresolved-import-100241.rs:9:13
3 |
4LL | pub use inner::S;
5 | ^^^^^ maybe a missing crate `inner`?
6 |
7 = help: consider adding `extern crate inner` to use the `inner` crate
8
9error: aborting due to 1 previous error
10
11For more information about this error, try `rustc --explain E0432`.
tests/rustdoc-ui/invalid_associated_const.stderr+6-4
......@@ -6,8 +6,9 @@ LL | type A: S<C<X = 0i32> = 34>;
66 |
77help: consider removing this associated item binding
88 |
9LL | type A: S<C<X = 0i32> = 34>;
10 | ~~~~~~~~~~
9LL - type A: S<C<X = 0i32> = 34>;
10LL + type A: S<C = 34>;
11 |
1112
1213error[E0229]: associated item constraints are not allowed here
1314 --> $DIR/invalid_associated_const.rs:4:17
......@@ -18,8 +19,9 @@ LL | type A: S<C<X = 0i32> = 34>;
1819 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1920help: consider removing this associated item binding
2021 |
21LL | type A: S<C<X = 0i32> = 34>;
22 | ~~~~~~~~~~
22LL - type A: S<C<X = 0i32> = 34>;
23LL + type A: S<C = 34>;
24 |
2325
2426error: aborting due to 2 previous errors
2527
tests/rustdoc-ui/issue-102467.stderr+6-4
......@@ -6,8 +6,9 @@ LL | type A: S<C<X = 0i32> = 34>;
66 |
77help: consider removing this associated item binding
88 |
9LL | type A: S<C<X = 0i32> = 34>;
10 | ~~~~~~~~~~
9LL - type A: S<C<X = 0i32> = 34>;
10LL + type A: S<C = 34>;
11 |
1112
1213error[E0229]: associated item constraints are not allowed here
1314 --> $DIR/issue-102467.rs:7:17
......@@ -18,8 +19,9 @@ LL | type A: S<C<X = 0i32> = 34>;
1819 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1920help: consider removing this associated item binding
2021 |
21LL | type A: S<C<X = 0i32> = 34>;
22 | ~~~~~~~~~~
22LL - type A: S<C<X = 0i32> = 34>;
23LL + type A: S<C = 34>;
24 |
2325
2426error: aborting due to 2 previous errors
2527
tests/ui/anon-params/anon-params-denied-2018.stderr+4-4
......@@ -48,7 +48,7 @@ LL | fn foo_with_qualified_path(<Bar as T>::Baz);
4848help: explicitly ignore the parameter name
4949 |
5050LL | fn foo_with_qualified_path(_: <Bar as T>::Baz);
51 | ~~~~~~~~~~~~~~~~~~
51 | ++
5252
5353error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
5454 --> $DIR/anon-params-denied-2018.rs:15:56
......@@ -60,7 +60,7 @@ LL | fn foo_with_qualified_path_and_ref(&<Bar as T>::Baz);
6060help: explicitly ignore the parameter name
6161 |
6262LL | fn foo_with_qualified_path_and_ref(_: &<Bar as T>::Baz);
63 | ~~~~~~~~~~~~~~~~~~~
63 | ++
6464
6565error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `,`
6666 --> $DIR/anon-params-denied-2018.rs:18:57
......@@ -72,7 +72,7 @@ LL | fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, <Bar as T>::Baz);
7272help: explicitly ignore the parameter name
7373 |
7474LL | fn foo_with_multiple_qualified_paths(_: <Bar as T>::Baz, <Bar as T>::Baz);
75 | ~~~~~~~~~~~~~~~~~~
75 | ++
7676
7777error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
7878 --> $DIR/anon-params-denied-2018.rs:18:74
......@@ -84,7 +84,7 @@ LL | fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, <Bar as T>::Baz);
8484help: explicitly ignore the parameter name
8585 |
8686LL | fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, _: <Bar as T>::Baz);
87 | ~~~~~~~~~~~~~~~~~~
87 | ++
8888
8989error: expected one of `:`, `@`, or `|`, found `,`
9090 --> $DIR/anon-params-denied-2018.rs:22:36
tests/ui/associated-consts/issue-102335-const.stderr+6-4
......@@ -6,8 +6,9 @@ LL | type A: S<C<X = 0i32> = 34>;
66 |
77help: consider removing this associated item binding
88 |
9LL | type A: S<C<X = 0i32> = 34>;
10 | ~~~~~~~~~~
9LL - type A: S<C<X = 0i32> = 34>;
10LL + type A: S<C = 34>;
11 |
1112
1213error[E0229]: associated item constraints are not allowed here
1314 --> $DIR/issue-102335-const.rs:4:17
......@@ -18,8 +19,9 @@ LL | type A: S<C<X = 0i32> = 34>;
1819 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1920help: consider removing this associated item binding
2021 |
21LL | type A: S<C<X = 0i32> = 34>;
22 | ~~~~~~~~~~
22LL - type A: S<C<X = 0i32> = 34>;
23LL + type A: S<C = 34>;
24 |
2325
2426error: aborting due to 2 previous errors
2527
tests/ui/associated-type-bounds/issue-102335-ty.stderr+12-8
......@@ -6,8 +6,9 @@ LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint
66 |
77help: consider removing this associated item binding
88 |
9LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint
10 | ~~~~~~~~~~~
9LL - type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint
10LL + type A: S<C = ()>; // Just one erroneous equality constraint
11 |
1112
1213error[E0229]: associated item constraints are not allowed here
1314 --> $DIR/issue-102335-ty.rs:2:17
......@@ -18,8 +19,9 @@ LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint
1819 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1920help: consider removing this associated item binding
2021 |
21LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint
22 | ~~~~~~~~~~~
22LL - type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint
23LL + type A: S<C = ()>; // Just one erroneous equality constraint
24 |
2325
2426error[E0229]: associated item constraints are not allowed here
2527 --> $DIR/issue-102335-ty.rs:8:17
......@@ -29,8 +31,9 @@ LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equal
2931 |
3032help: consider removing this associated item binding
3133 |
32LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints
33 | ~~~~~~~~~~
34LL - type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints
35LL + type A: S<C<X = i32> = ()>; // More than one erroneous equality constraints
36 |
3437
3538error[E0229]: associated item constraints are not allowed here
3639 --> $DIR/issue-102335-ty.rs:8:17
......@@ -41,8 +44,9 @@ LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equal
4144 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4245help: consider removing this associated item binding
4346 |
44LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints
45 | ~~~~~~~~~~
47LL - type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints
48LL + type A: S<C<X = i32> = ()>; // More than one erroneous equality constraints
49 |
4650
4751error: aborting due to 4 previous errors
4852
tests/ui/associated-type-bounds/no-gat-position.stderr+3-2
......@@ -6,8 +6,9 @@ LL | fn next<'a>(&'a mut self) -> Option<Self::Item<'a, As1: Copy>>;
66 |
77help: consider removing this associated item constraint
88 |
9LL | fn next<'a>(&'a mut self) -> Option<Self::Item<'a, As1: Copy>>;
10 | ~~~~~~~~~~~
9LL - fn next<'a>(&'a mut self) -> Option<Self::Item<'a, As1: Copy>>;
10LL + fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;
11 |
1112
1213error: aborting due to 1 previous error
1314
tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr+2-2
......@@ -13,12 +13,12 @@ error: future cannot be sent between threads safely
1313LL | is_send(foo::<T>());
1414 | ^^^^^^^^^^ future returned by `foo` is not `Send`
1515 |
16 = help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method() }`, which is required by `impl Future<Output = Result<(), ()>>: Send`
16 = help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method(..) }`, which is required by `impl Future<Output = Result<(), ()>>: Send`
1717note: future is not `Send` as it awaits another future which is not `Send`
1818 --> $DIR/basic.rs:13:5
1919 |
2020LL | T::method().await?;
21 | ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>> { <T as Foo>::method() }`, which is not `Send`
21 | ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>> { <T as Foo>::method(..) }`, which is not `Send`
2222note: required by a bound in `is_send`
2323 --> $DIR/basic.rs:17:20
2424 |
tests/ui/associated-type-bounds/return-type-notation/display.rs created+25
......@@ -0,0 +1,25 @@
1#![feature(return_type_notation)]
2//~^ WARN the feature `return_type_notation` is incomplete
3
4trait Trait {}
5fn needs_trait(_: impl Trait) {}
6
7trait Assoc {
8 fn method() -> impl Sized;
9 fn method_with_lt() -> impl Sized;
10 fn method_with_ty<T>() -> impl Sized;
11 fn method_with_ct<const N: usize>() -> impl Sized;
12}
13
14fn foo<T: Assoc>(t: T) {
15 needs_trait(T::method());
16 //~^ ERROR the trait bound
17 needs_trait(T::method_with_lt());
18 //~^ ERROR the trait bound
19 needs_trait(T::method_with_ty());
20 //~^ ERROR the trait bound
21 needs_trait(T::method_with_ct());
22 //~^ ERROR the trait bound
23}
24
25fn main() {}
tests/ui/associated-type-bounds/return-type-notation/display.stderr created+78
......@@ -0,0 +1,78 @@
1warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2 --> $DIR/display.rs:1:12
3 |
4LL | #![feature(return_type_notation)]
5 | ^^^^^^^^^^^^^^^^^^^^
6 |
7 = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
8 = note: `#[warn(incomplete_features)]` on by default
9
10error[E0277]: the trait bound `impl Sized { <T as Assoc>::method(..) }: Trait` is not satisfied
11 --> $DIR/display.rs:15:17
12 |
13LL | needs_trait(T::method());
14 | ----------- ^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized { <T as Assoc>::method(..) }`
15 | |
16 | required by a bound introduced by this call
17 |
18note: required by a bound in `needs_trait`
19 --> $DIR/display.rs:5:24
20 |
21LL | fn needs_trait(_: impl Trait) {}
22 | ^^^^^ required by this bound in `needs_trait`
23
24error[E0277]: the trait bound `impl Sized { <T as Assoc>::method_with_lt(..) }: Trait` is not satisfied
25 --> $DIR/display.rs:17:17
26 |
27LL | needs_trait(T::method_with_lt());
28 | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized { <T as Assoc>::method_with_lt(..) }`
29 | |
30 | required by a bound introduced by this call
31 |
32note: required by a bound in `needs_trait`
33 --> $DIR/display.rs:5:24
34 |
35LL | fn needs_trait(_: impl Trait) {}
36 | ^^^^^ required by this bound in `needs_trait`
37
38error[E0277]: the trait bound `impl Sized: Trait` is not satisfied
39 --> $DIR/display.rs:19:17
40 |
41LL | needs_trait(T::method_with_ty());
42 | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized`
43 | |
44 | required by a bound introduced by this call
45 |
46help: this trait has no implementations, consider adding one
47 --> $DIR/display.rs:4:1
48 |
49LL | trait Trait {}
50 | ^^^^^^^^^^^
51note: required by a bound in `needs_trait`
52 --> $DIR/display.rs:5:24
53 |
54LL | fn needs_trait(_: impl Trait) {}
55 | ^^^^^ required by this bound in `needs_trait`
56
57error[E0277]: the trait bound `impl Sized: Trait` is not satisfied
58 --> $DIR/display.rs:21:17
59 |
60LL | needs_trait(T::method_with_ct());
61 | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized`
62 | |
63 | required by a bound introduced by this call
64 |
65help: this trait has no implementations, consider adding one
66 --> $DIR/display.rs:4:1
67 |
68LL | trait Trait {}
69 | ^^^^^^^^^^^
70note: required by a bound in `needs_trait`
71 --> $DIR/display.rs:5:24
72 |
73LL | fn needs_trait(_: impl Trait) {}
74 | ^^^^^ required by this bound in `needs_trait`
75
76error: aborting due to 4 previous errors; 1 warning emitted
77
78For more information about this error, try `rustc --explain E0277`.
tests/ui/associated-types/associated-types-eq-2.stderr+24-16
......@@ -50,8 +50,9 @@ LL | impl Tr1<A = usize> for usize {
5050 |
5151help: consider removing this associated item binding
5252 |
53LL | impl Tr1<A = usize> for usize {
54 | ~~~~~~~~~~~
53LL - impl Tr1<A = usize> for usize {
54LL + impl Tr1 for usize {
55 |
5556
5657error[E0046]: not all trait items implemented, missing: `A`
5758 --> $DIR/associated-types-eq-2.rs:20:1
......@@ -70,8 +71,9 @@ LL | fn baz<I: Tr1>(_x: &<I as Tr1<A=Bar>>::A) {}
7071 |
7172help: consider removing this associated item binding
7273 |
73LL | fn baz<I: Tr1>(_x: &<I as Tr1<A=Bar>>::A) {}
74 | ~~~~~~~
74LL - fn baz<I: Tr1>(_x: &<I as Tr1<A=Bar>>::A) {}
75LL + fn baz<I: Tr1>(_x: &<I as Tr1>::A) {}
76 |
7577
7678error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied
7779 --> $DIR/associated-types-eq-2.rs:40:6
......@@ -128,8 +130,9 @@ LL | impl Tr2<i32, t2 = Qux, T3 = usize> for Qux {
128130 |
129131help: consider removing this associated item binding
130132 |
131LL | impl Tr2<i32, t2 = Qux, T3 = usize> for Qux {
132 | ~~~~~~~~~~
133LL - impl Tr2<i32, t2 = Qux, T3 = usize> for Qux {
134LL + impl Tr2<i32, T3 = usize> for Qux {
135 |
133136
134137error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied
135138 --> $DIR/associated-types-eq-2.rs:54:6
......@@ -157,8 +160,9 @@ LL | impl Tr2<i32, X = Qux, Y = usize> for Bar {
157160 |
158161help: consider removing this associated item binding
159162 |
160LL | impl Tr2<i32, X = Qux, Y = usize> for Bar {
161 | ~~~~~~~~~
163LL - impl Tr2<i32, X = Qux, Y = usize> for Bar {
164LL + impl Tr2<i32, Y = usize> for Bar {
165 |
162166
163167error[E0107]: trait takes 3 generic arguments but 2 generic arguments were supplied
164168 --> $DIR/associated-types-eq-2.rs:61:6
......@@ -228,8 +232,9 @@ LL | impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux {
228232 |
229233help: consider removing this associated item binding
230234 |
231LL | impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux {
232 | ~~~~~~~
235LL - impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux {
236LL + impl Tr3<T2 = Qux, T3 = usize> for Qux {
237 |
233238
234239error[E0229]: associated item constraints are not allowed here
235240 --> $DIR/associated-types-eq-2.rs:92:10
......@@ -239,8 +244,9 @@ LL | impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar {
239244 |
240245help: consider removing this associated item binding
241246 |
242LL | impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar {
243 | ~~~~~~~~
247LL - impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar {
248LL + impl Tr3<T2 = Qux, T3 = usize> for Bar {
249 |
244250
245251error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied
246252 --> $DIR/associated-types-eq-2.rs:98:6
......@@ -268,8 +274,9 @@ LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar {
268274 |
269275help: consider removing this associated item binding
270276 |
271LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar {
272 | ~~~~~~~~~
277LL - impl Tr3<42, T2 = 42, T3 = usize> for Bar {
278LL + impl Tr3<42, T3 = usize> for Bar {
279 |
273280
274281error[E0107]: trait takes 3 generic arguments but 0 generic arguments were supplied
275282 --> $DIR/associated-types-eq-2.rs:106:6
......@@ -295,8 +302,9 @@ LL | impl Tr3<X = 42, Y = Qux, Z = usize> for Bar {
295302 |
296303help: consider removing this associated item binding
297304 |
298LL | impl Tr3<X = 42, Y = Qux, Z = usize> for Bar {
299 | ~~~~~~~
305LL - impl Tr3<X = 42, Y = Qux, Z = usize> for Bar {
306LL + impl Tr3<Y = Qux, Z = usize> for Bar {
307 |
300308
301309error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied
302310 --> $DIR/associated-types-eq-2.rs:117:13
tests/ui/async-await/return-type-notation/issue-110963-early.stderr+4-4
......@@ -18,8 +18,8 @@ LL | | }
1818LL | | });
1919 | |______^ implementation of `Send` is not general enough
2020 |
21 = note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>() }`, for any two lifetimes `'0` and `'1`...
22 = note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>() }`, for some specific lifetime `'2`
21 = note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>(..) }`, for any two lifetimes `'0` and `'1`...
22 = note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>(..) }`, for some specific lifetime `'2`
2323
2424error: implementation of `Send` is not general enough
2525 --> $DIR/issue-110963-early.rs:14:5
......@@ -32,8 +32,8 @@ LL | | }
3232LL | | });
3333 | |______^ implementation of `Send` is not general enough
3434 |
35 = note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>() }`, for any two lifetimes `'0` and `'1`...
36 = note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>() }`, for some specific lifetime `'2`
35 = note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>(..) }`, for any two lifetimes `'0` and `'1`...
36 = note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>(..) }`, for some specific lifetime `'2`
3737 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3838
3939error: aborting due to 2 previous errors; 1 warning emitted
tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr+3-2
......@@ -15,8 +15,9 @@ LL | impl Super1<'_, bar(..): Send> for () {}
1515 |
1616help: consider removing this associated item constraint
1717 |
18LL | impl Super1<'_, bar(..): Send> for () {}
19 | ~~~~~~~~~~~~~~~
18LL - impl Super1<'_, bar(..): Send> for () {}
19LL + impl Super1<'_> for () {}
20 |
2021
2122error[E0046]: not all trait items implemented, missing: `bar`
2223 --> $DIR/rtn-in-impl-signature.rs:10:1
tests/ui/blind/blind-item-block-item-shadow.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use foo::Bar;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use foo::Bar as OtherBar;
13 | ~~~~~~~~~~~~~~~~~~~~
13 | +++++++++++
1414
1515error: aborting due to 1 previous error
1616
tests/ui/blind/blind-item-item-shadow.stderr+1-1
......@@ -11,7 +11,7 @@ LL | use foo::foo;
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use foo::foo as other_foo;
14 | ~~~~~~~~~~~~~~~~~~~~~
14 | ++++++++++++
1515
1616error: aborting due to 1 previous error
1717
tests/ui/duplicate/duplicate-check-macro-exports.stderr+1-1
......@@ -11,7 +11,7 @@ LL | macro_rules! panic { () => {} }
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | pub use std::panic as other_panic;
14 | ~~~~~~~~~~~~~~~~~~~~~~~~~
14 | ++++++++++++++
1515
1616error: aborting due to 1 previous error
1717
tests/ui/error-codes/E0229.stderr+9-6
......@@ -6,8 +6,9 @@ LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
66 |
77help: consider removing this associated item binding
88 |
9LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
10 | ~~~~~~~~~
9LL - fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
10LL + fn baz<I>(x: &<I as Foo>::A) {}
11 |
1112
1213error[E0229]: associated item constraints are not allowed here
1314 --> $DIR/E0229.rs:13:25
......@@ -18,8 +19,9 @@ LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
1819 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1920help: consider removing this associated item binding
2021 |
21LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
22 | ~~~~~~~~~
22LL - fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
23LL + fn baz<I>(x: &<I as Foo>::A) {}
24 |
2325
2426error[E0229]: associated item constraints are not allowed here
2527 --> $DIR/E0229.rs:13:25
......@@ -30,8 +32,9 @@ LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
3032 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3133help: consider removing this associated item binding
3234 |
33LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
34 | ~~~~~~~~~
35LL - fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
36LL + fn baz<I>(x: &<I as Foo>::A) {}
37 |
3538
3639error[E0277]: the trait bound `I: Foo` is not satisfied
3740 --> $DIR/E0229.rs:13:15
tests/ui/error-codes/E0252.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use bar::baz;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use bar::baz as other_baz;
13 | ~~~~~~~~~~~~~~~~~~~~~
13 | ++++++++++++
1414
1515error: aborting due to 1 previous error
1616
tests/ui/error-codes/E0254.stderr+1-1
......@@ -11,7 +11,7 @@ LL | use foo::alloc;
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use foo::alloc as other_alloc;
14 | ~~~~~~~~~~~~~~~~~~~~~~~~~
14 | ++++++++++++++
1515
1616error: aborting due to 1 previous error
1717
tests/ui/error-codes/E0255.stderr+1-1
......@@ -11,7 +11,7 @@ LL | fn foo() {}
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use bar::foo as other_foo;
14 | ~~~~~~~~~~~~~~~~~~~~~
14 | ++++++++++++
1515
1616error: aborting due to 1 previous error
1717
tests/ui/generic-associated-types/issue-102335-gat.stderr+6-4
......@@ -6,8 +6,9 @@ LL | type A: S<C<(), i32 = ()> = ()>;
66 |
77help: consider removing this associated item binding
88 |
9LL | type A: S<C<(), i32 = ()> = ()>;
10 | ~~~~~~~~~~
9LL - type A: S<C<(), i32 = ()> = ()>;
10LL + type A: S<C<()> = ()>;
11 |
1112
1213error[E0229]: associated item constraints are not allowed here
1314 --> $DIR/issue-102335-gat.rs:2:21
......@@ -18,8 +19,9 @@ LL | type A: S<C<(), i32 = ()> = ()>;
1819 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1920help: consider removing this associated item binding
2021 |
21LL | type A: S<C<(), i32 = ()> = ()>;
22 | ~~~~~~~~~~
22LL - type A: S<C<(), i32 = ()> = ()>;
23LL + type A: S<C<()> = ()>;
24 |
2325
2426error: aborting due to 2 previous errors
2527
tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr+18-12
......@@ -14,8 +14,9 @@ LL | impl Foo<T: Default> for String {}
1414 |
1515help: declare the type parameter right after the `impl` keyword
1616 |
17LL | impl<T: Default> Foo<T> for String {}
18 | ++++++++++++ ~
17LL - impl Foo<T: Default> for String {}
18LL + impl<T: Default> Foo<T> for String {}
19 |
1920
2021error[E0229]: associated item constraints are not allowed here
2122 --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:7:10
......@@ -25,8 +26,9 @@ LL | impl Foo<T: 'a + Default> for u8 {}
2526 |
2627help: declare the type parameter right after the `impl` keyword
2728 |
28LL | impl<'a, T: 'a + Default> Foo<T> for u8 {}
29 | +++++++++++++++++++++ ~
29LL - impl Foo<T: 'a + Default> for u8 {}
30LL + impl<'a, T: 'a + Default> Foo<T> for u8 {}
31 |
3032
3133error[E0229]: associated item constraints are not allowed here
3234 --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:13:13
......@@ -36,8 +38,9 @@ LL | impl<T> Foo<T: Default> for u16 {}
3638 |
3739help: declare the type parameter right after the `impl` keyword
3840 |
39LL | impl<T, T: Default> Foo<T> for u16 {}
40 | ++++++++++++ ~
41LL - impl<T> Foo<T: Default> for u16 {}
42LL + impl<T, T: Default> Foo<T> for u16 {}
43 |
4144
4245error[E0229]: associated item constraints are not allowed here
4346 --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:17:14
......@@ -47,8 +50,9 @@ LL | impl<'a> Foo<T: 'a + Default> for u32 {}
4750 |
4851help: declare the type parameter right after the `impl` keyword
4952 |
50LL | impl<'a, 'a, T: 'a + Default> Foo<T> for u32 {}
51 | +++++++++++++++++++++ ~
53LL - impl<'a> Foo<T: 'a + Default> for u32 {}
54LL + impl<'a, 'a, T: 'a + Default> Foo<T> for u32 {}
55 |
5256
5357error[E0229]: associated item constraints are not allowed here
5458 --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:23:10
......@@ -58,8 +62,9 @@ LL | impl Bar<T: Default, K: Default> for String {}
5862 |
5963help: declare the type parameter right after the `impl` keyword
6064 |
61LL | impl<T: Default> Bar<T, K: Default> for String {}
62 | ++++++++++++ ~
65LL - impl Bar<T: Default, K: Default> for String {}
66LL + impl<T: Default> Bar<T, K: Default> for String {}
67 |
6368
6469error[E0107]: trait takes 2 generic arguments but 1 generic argument was supplied
6570 --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:27:9
......@@ -87,8 +92,9 @@ LL | impl<T> Bar<T, K: Default> for u8 {}
8792 |
8893help: declare the type parameter right after the `impl` keyword
8994 |
90LL | impl<T, K: Default> Bar<T, K> for u8 {}
91 | ++++++++++++ ~
95LL - impl<T> Bar<T, K: Default> for u8 {}
96LL + impl<T, K: Default> Bar<T, K> for u8 {}
97 |
9298
9399error: aborting due to 8 previous errors
94100
tests/ui/imports/double-import.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use sub2::foo;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use sub2::foo as other_foo;
13 | ~~~~~~~~~~~~~~~~~~~~~~
13 | ++++++++++++
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-19498.stderr+3-3
......@@ -11,7 +11,7 @@ LL | mod A {}
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use self::A as OtherA;
14 | ~~~~~~~~~~~~~~~~~
14 | +++++++++
1515
1616error[E0255]: the name `B` is defined multiple times
1717 --> $DIR/issue-19498.rs:5:1
......@@ -26,7 +26,7 @@ LL | pub mod B {}
2626help: you can use `as` to change the binding name of the import
2727 |
2828LL | use self::B as OtherB;
29 | ~~~~~~~~~~~~~~~~~
29 | +++++++++
3030
3131error[E0255]: the name `D` is defined multiple times
3232 --> $DIR/issue-19498.rs:9:5
......@@ -40,7 +40,7 @@ LL | mod D {}
4040help: you can use `as` to change the binding name of the import
4141 |
4242LL | use C::D as OtherD;
43 | ~~~~~~~~~~~~~~
43 | +++++++++
4444
4545error: aborting due to 3 previous errors
4646
tests/ui/imports/issue-24081.stderr+5-5
......@@ -11,7 +11,7 @@ LL | type Add = bool;
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use std::ops::Add as OtherAdd;
14 | ~~~~~~~~~~~~~~~~~~~~~~~~~
14 | +++++++++++
1515
1616error[E0255]: the name `Sub` is defined multiple times
1717 --> $DIR/issue-24081.rs:9:1
......@@ -26,7 +26,7 @@ LL | struct Sub { x: f32 }
2626help: you can use `as` to change the binding name of the import
2727 |
2828LL | use std::ops::Sub as OtherSub;
29 | ~~~~~~~~~~~~~~~~~~~~~~~~~
29 | +++++++++++
3030
3131error[E0255]: the name `Mul` is defined multiple times
3232 --> $DIR/issue-24081.rs:11:1
......@@ -41,7 +41,7 @@ LL | enum Mul { A, B }
4141help: you can use `as` to change the binding name of the import
4242 |
4343LL | use std::ops::Mul as OtherMul;
44 | ~~~~~~~~~~~~~~~~~~~~~~~~~
44 | +++++++++++
4545
4646error[E0255]: the name `Div` is defined multiple times
4747 --> $DIR/issue-24081.rs:13:1
......@@ -56,7 +56,7 @@ LL | mod Div { }
5656help: you can use `as` to change the binding name of the import
5757 |
5858LL | use std::ops::Div as OtherDiv;
59 | ~~~~~~~~~~~~~~~~~~~~~~~~~
59 | +++++++++++
6060
6161error[E0255]: the name `Rem` is defined multiple times
6262 --> $DIR/issue-24081.rs:15:1
......@@ -71,7 +71,7 @@ LL | trait Rem { }
7171help: you can use `as` to change the binding name of the import
7272 |
7373LL | use std::ops::Rem as OtherRem;
74 | ~~~~~~~~~~~~~~~~~~~~~~~~~
74 | +++++++++++
7575
7676error: aborting due to 5 previous errors
7777
tests/ui/imports/issue-25396.stderr+4-4
......@@ -10,7 +10,7 @@ LL | use bar::baz;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use bar::baz as other_baz;
13 | ~~~~~~~~~~~~~~~~~~~~~
13 | ++++++++++++
1414
1515error[E0252]: the name `Quux` is defined multiple times
1616 --> $DIR/issue-25396.rs:7:5
......@@ -24,7 +24,7 @@ LL | use bar::Quux;
2424help: you can use `as` to change the binding name of the import
2525 |
2626LL | use bar::Quux as OtherQuux;
27 | ~~~~~~~~~~~~~~~~~~~~~~
27 | ++++++++++++
2828
2929error[E0252]: the name `blah` is defined multiple times
3030 --> $DIR/issue-25396.rs:10:5
......@@ -38,7 +38,7 @@ LL | use bar::blah;
3838help: you can use `as` to change the binding name of the import
3939 |
4040LL | use bar::blah as other_blah;
41 | ~~~~~~~~~~~~~~~~~~~~~~~
41 | +++++++++++++
4242
4343error[E0252]: the name `WOMP` is defined multiple times
4444 --> $DIR/issue-25396.rs:13:5
......@@ -52,7 +52,7 @@ LL | use bar::WOMP;
5252help: you can use `as` to change the binding name of the import
5353 |
5454LL | use bar::WOMP as OtherWOMP;
55 | ~~~~~~~~~~~~~~~~~~~~~~
55 | ++++++++++++
5656
5757error: aborting due to 4 previous errors
5858
tests/ui/imports/issue-32354-suggest-import-rename.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use extension2::ConstructorExtension;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use extension2::ConstructorExtension as OtherConstructorExtension;
13 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 | ++++++++++++++++++++++++++++
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-45829/import-self.stderr+1-1
......@@ -48,7 +48,7 @@ LL | use foo::self;
4848help: you can use `as` to change the binding name of the import
4949 |
5050LL | use foo as other_foo;
51 | ~~~~~~~~~~~~~~~~
51 | ~~~~~~~~~~~~
5252
5353error[E0252]: the name `A` is defined multiple times
5454 --> $DIR/import-self.rs:16:11
tests/ui/imports/issue-45829/issue-45829.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use foo::{A, B as A};
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use foo::{A, B as OtherA};
13 | ~~~~~~~~~~~
13 | ~~~~~~~~~
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-45829/rename-use-vs-extern.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use std as issue_45829_b;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use std as other_issue_45829_b;
13 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
13 | ~~~~~~~~~~~~~~~~~~~~~~
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-45829/rename-use-with-tabs.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use foo::{A, bar::B as A};
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use foo::{A, bar::B as OtherA};
13 | ~~~~~~~~~~~~~~~~
13 | ~~~~~~~~~
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-45829/rename-with-path.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use std::{collections::HashMap as A, sync::Arc as A};
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use std::{collections::HashMap as A, sync::Arc as OtherA};
13 | ~~~~~~~~~~~~~~~~~~~
13 | ~~~~~~~~~
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-45829/rename.stderr+1-1
......@@ -10,7 +10,7 @@ LL | use std as core;
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use std as other_core;
13 | ~~~~~~~~~~~~~~~~~
13 | ~~~~~~~~~~~~~
1414
1515error: aborting due to 1 previous error
1616
tests/ui/imports/issue-52891.stderr+1-1
......@@ -98,7 +98,7 @@ LL | use issue_52891::b::inner;
9898help: you can use `as` to change the binding name of the import
9999 |
100100LL | use issue_52891::b::inner as other_inner;
101 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101 | ++++++++++++++
102102
103103error[E0254]: the name `issue_52891` is defined multiple times
104104 --> $DIR/issue-52891.rs:31:19
tests/ui/imports/issue-8640.stderr+1-1
......@@ -10,7 +10,7 @@ LL | mod bar {}
1010help: you can use `as` to change the binding name of the import
1111 |
1212LL | use baz::bar as other_bar;
13 | ~~~~~~~~~~~~~~~~~~~~~
13 | ++++++++++++
1414
1515error: aborting due to 1 previous error
1616
tests/ui/lifetimes/issue-83753-invalid-associated-type-supertrait-hrtb.stderr+3-2
......@@ -6,8 +6,9 @@ LL | fn bar(foo: Foo<Target = usize>) {}
66 |
77help: consider removing this associated item binding
88 |
9LL | fn bar(foo: Foo<Target = usize>) {}
10 | ~~~~~~~~~~~~~~~~
9LL - fn bar(foo: Foo<Target = usize>) {}
10LL + fn bar(foo: Foo) {}
11 |
1112
1213error: aborting due to 1 previous error
1314
tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr+1-1
......@@ -8,7 +8,7 @@ LL | use std::slice as std;
88help: you can use `as` to change the binding name of the import
99 |
1010LL | use std::slice as other_std;
11 | ~~~~~~~~~~~~~~~~~~~~~~~
11 | ~~~~~~~~~~~~
1212
1313error: aborting due to 1 previous error
1414
tests/ui/resolve/resolve-conflict-item-vs-import.stderr+1-1
......@@ -11,7 +11,7 @@ LL | fn transmute() {}
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use std::mem::transmute as other_transmute;
14 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 | ++++++++++++++++++
1515
1616error: aborting due to 1 previous error
1717
tests/ui/resolve/resolve-conflict-type-vs-import.stderr+1-1
......@@ -11,7 +11,7 @@ LL | struct Iter;
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | use std::slice::Iter as OtherIter;
14 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 | ++++++++++++
1515
1616error: aborting due to 1 previous error
1717
tests/ui/suggestions/issue-85347.stderr+6-4
......@@ -22,8 +22,9 @@ LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
2222 |
2323help: consider removing this associated item binding
2424 |
25LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
26 | ~~~~~~~~~~~~~~~
25LL - type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
26LL + type Bar<'a>: Deref<Target = <Self>::Bar>;
27 |
2728
2829error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
2930 --> $DIR/issue-85347.rs:3:42
......@@ -51,8 +52,9 @@ LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
5152 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5253help: consider removing this associated item binding
5354 |
54LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
55 | ~~~~~~~~~~~~~~~
55LL - type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
56LL + type Bar<'a>: Deref<Target = <Self>::Bar>;
57 |
5658
5759error: aborting due to 4 previous errors
5860
tests/ui/variants/variant-namespacing.stderr+6-6
......@@ -11,7 +11,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
1111help: you can use `as` to change the binding name of the import
1212 |
1313LL | pub use variant_namespacing::XE::{XStruct as OtherXStruct, XTuple, XUnit};
14 | ~~~~~~~~~~~~~~~~~~~~~~~
14 | +++++++++++++++
1515
1616error[E0255]: the name `XTuple` is defined multiple times
1717 --> $DIR/variant-namespacing.rs:24:44
......@@ -26,7 +26,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
2626help: you can use `as` to change the binding name of the import
2727 |
2828LL | pub use variant_namespacing::XE::{XStruct, XTuple as OtherXTuple, XUnit};
29 | ~~~~~~~~~~~~~~~~~~~~~
29 | ++++++++++++++
3030
3131error[E0255]: the name `XUnit` is defined multiple times
3232 --> $DIR/variant-namespacing.rs:24:52
......@@ -41,7 +41,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
4141help: you can use `as` to change the binding name of the import
4242 |
4343LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit as OtherXUnit};
44 | ~~~~~~~~~~~~~~~~~~~
44 | +++++++++++++
4545
4646error[E0255]: the name `Struct` is defined multiple times
4747 --> $DIR/variant-namespacing.rs:28:13
......@@ -56,7 +56,7 @@ LL | pub use E::{Struct, Tuple, Unit};
5656help: you can use `as` to change the binding name of the import
5757 |
5858LL | pub use E::{Struct as OtherStruct, Tuple, Unit};
59 | ~~~~~~~~~~~~~~~~~~~~~
59 | ++++++++++++++
6060
6161error[E0255]: the name `Tuple` is defined multiple times
6262 --> $DIR/variant-namespacing.rs:28:21
......@@ -71,7 +71,7 @@ LL | pub use E::{Struct, Tuple, Unit};
7171help: you can use `as` to change the binding name of the import
7272 |
7373LL | pub use E::{Struct, Tuple as OtherTuple, Unit};
74 | ~~~~~~~~~~~~~~~~~~~
74 | +++++++++++++
7575
7676error[E0255]: the name `Unit` is defined multiple times
7777 --> $DIR/variant-namespacing.rs:28:28
......@@ -86,7 +86,7 @@ LL | pub use E::{Struct, Tuple, Unit};
8686help: you can use `as` to change the binding name of the import
8787 |
8888LL | pub use E::{Struct, Tuple, Unit as OtherUnit};
89 | ~~~~~~~~~~~~~~~~~
89 | ++++++++++++
9090
9191error: aborting due to 6 previous errors
9292