From 538b31e9774e3c6e0561e8dbcef378deba9f3fdc Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Fri, 28 Jun 2024 09:17:04 +0200 Subject: [PATCH 01/13] Make language around `ToOwned` for `BorrowedFd` more precise --- library/std/src/os/fd/owned.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index a1f83029d2727..f11f7ef938a07 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -24,9 +24,11 @@ use crate::sys_common::{AsInner, FromInner, IntoInner}; /// passed as an argument, it is not captured or consumed, and it never has the /// value `-1`. /// -/// This type's `.to_owned()` implementation returns another `BorrowedFd` -/// rather than an `OwnedFd`. It just makes a trivial copy of the raw file -/// descriptor, which is then borrowed under the same lifetime. +/// This type does not have a [`ToOwned`][crate::borrow::ToOwned] +/// implementation. Calling `.to_owned()` on a variable of this type will call +/// it on `&BorrowedFd` and use `Clone::clone()` like `ToOwned` does for all +/// types implementing `Clone`. The result will be descriptor borrowed under +/// the same lifetime. #[derive(Copy, Clone)] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(0)] From 2162f3f34b2b4f9a7d603ab05bec4246a7b855c0 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Fri, 28 Jun 2024 09:17:39 +0200 Subject: [PATCH 02/13] Mention how you can go from `BorrowedFd` to `OwnedFd` and back --- library/std/src/os/fd/owned.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index f11f7ef938a07..5833c59725682 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -29,6 +29,9 @@ use crate::sys_common::{AsInner, FromInner, IntoInner}; /// it on `&BorrowedFd` and use `Clone::clone()` like `ToOwned` does for all /// types implementing `Clone`. The result will be descriptor borrowed under /// the same lifetime. +/// +/// To obtain an [`OwnedFd`], you can use [`BorrowedFd::try_clone_to_owned`] +/// instead, but this is not supported on all platforms. #[derive(Copy, Clone)] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(0)] @@ -52,6 +55,8 @@ pub struct BorrowedFd<'fd> { /// descriptor, so it can be used in FFI in places where a file descriptor is /// passed as a consumed argument or returned as an owned value, and it never /// has the value `-1`. +/// +/// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`]. #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(0)] // libstd/os/raw/mod.rs assures me that every libstd-supported platform has a From a6510507e784d37f52558a6ceaa8cf92d345a4e2 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 16 Jul 2024 00:03:37 -0400 Subject: [PATCH 03/13] lift_to_tcx -> lift_to_interner --- compiler/rustc_macros/src/lift.rs | 2 +- compiler/rustc_middle/src/macros.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 8 ++++---- compiler/rustc_middle/src/ty/generic_args.rs | 2 +- compiler/rustc_middle/src/ty/structural_impls.rs | 4 ++-- compiler/rustc_type_ir/src/binder.rs | 6 +++--- compiler/rustc_type_ir/src/lift.rs | 2 +- compiler/rustc_type_ir/src/predicate.rs | 4 ++-- compiler/rustc_type_ir_macros/src/lib.rs | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_macros/src/lift.rs b/compiler/rustc_macros/src/lift.rs index d41ceb29816cc..627f4088d5f5c 100644 --- a/compiler/rustc_macros/src/lift.rs +++ b/compiler/rustc_macros/src/lift.rs @@ -45,7 +45,7 @@ pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStre quote! { type Lifted = #lifted; - fn lift_to_tcx(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> { + fn lift_to_interner(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> { Some(match self { #body }) } }, diff --git a/compiler/rustc_middle/src/macros.rs b/compiler/rustc_middle/src/macros.rs index fcea1ea81a7c4..d385be007d33f 100644 --- a/compiler/rustc_middle/src/macros.rs +++ b/compiler/rustc_middle/src/macros.rs @@ -59,7 +59,7 @@ macro_rules! TrivialLiftImpls { $( impl<'tcx> $crate::ty::Lift<$crate::ty::TyCtxt<'tcx>> for $ty { type Lifted = Self; - fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, _: $crate::ty::TyCtxt<'tcx>) -> Option { Some(self) } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 25070e6b042c9..fd41668ae44c8 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1484,7 +1484,7 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn lift>>(self, value: T) -> Option { - value.lift_to_tcx(self) + value.lift_to_interner(self) } /// Creates a type context. To use the context call `fn enter` which @@ -2087,7 +2087,7 @@ macro_rules! nop_lift { ($set:ident; $ty:ty => $lifted:ty) => { impl<'a, 'tcx> Lift> for $ty { type Lifted = $lifted; - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { // Assert that the set has the right type. // Given an argument that has an interned type, the return type has the type of // the corresponding interner set. This won't actually return anything, we're @@ -2122,7 +2122,7 @@ macro_rules! nop_list_lift { ($set:ident; $ty:ty => $lifted:ty) => { impl<'a, 'tcx> Lift> for &'a List<$ty> { type Lifted = &'tcx List<$lifted>; - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { // Assert that the set has the right type. if false { let _x: &InternedSet<'tcx, List<$lifted>> = &tcx.interners.$set; @@ -2160,7 +2160,7 @@ macro_rules! nop_slice_lift { ($ty:ty => $lifted:ty) => { impl<'a, 'tcx> Lift> for &'a [$ty] { type Lifted = &'tcx [$lifted]; - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { if self.is_empty() { return Some(&[]); } diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 5ac3168196ad7..10919623de728 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -308,7 +308,7 @@ impl<'tcx> GenericArg<'tcx> { impl<'a, 'tcx> Lift> for GenericArg<'a> { type Lifted = GenericArg<'tcx>; - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { match self.unpack() { GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()), GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()), diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 00ea87690c1ab..7cdc0e32953de 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -283,7 +283,7 @@ TrivialTypeTraversalAndLiftImpls! { impl<'tcx, T: Lift>> Lift> for Option { type Lifted = Option; - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { Some(match self { Some(x) => Some(tcx.lift(x)?), None => None, @@ -293,7 +293,7 @@ impl<'tcx, T: Lift>> Lift> for Option { impl<'a, 'tcx> Lift> for Term<'a> { type Lifted = ty::Term<'tcx>; - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { + fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { match self.unpack() { TermKind::Ty(ty) => tcx.lift(ty).map(Into::into), TermKind::Const(c) => tcx.lift(c).map(Into::into), diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index 2531219baecc8..9f2af470d1cd8 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -49,10 +49,10 @@ where { type Lifted = Binder; - fn lift_to_tcx(self, tcx: U) -> Option { + fn lift_to_interner(self, tcx: U) -> Option { Some(Binder { - value: self.value.lift_to_tcx(tcx)?, - bound_vars: self.bound_vars.lift_to_tcx(tcx)?, + value: self.value.lift_to_interner(tcx)?, + bound_vars: self.bound_vars.lift_to_interner(tcx)?, }) } } diff --git a/compiler/rustc_type_ir/src/lift.rs b/compiler/rustc_type_ir/src/lift.rs index 839da10db5e56..abad155c9ae0d 100644 --- a/compiler/rustc_type_ir/src/lift.rs +++ b/compiler/rustc_type_ir/src/lift.rs @@ -17,5 +17,5 @@ /// e.g., `()` or `u8`, was interned in a different context. pub trait Lift: std::fmt::Debug { type Lifted: std::fmt::Debug; - fn lift_to_tcx(self, tcx: I) -> Option; + fn lift_to_interner(self, tcx: I) -> Option; } diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index e5bcbc67f946c..acf8817c6ac19 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -34,8 +34,8 @@ where { type Lifted = OutlivesPredicate; - fn lift_to_tcx(self, tcx: U) -> Option { - Some(OutlivesPredicate(self.0.lift_to_tcx(tcx)?, self.1.lift_to_tcx(tcx)?)) + fn lift_to_interner(self, tcx: U) -> Option { + Some(OutlivesPredicate(self.0.lift_to_interner(tcx)?, self.1.lift_to_interner(tcx)?)) } } diff --git a/compiler/rustc_type_ir_macros/src/lib.rs b/compiler/rustc_type_ir_macros/src/lib.rs index 000bcf2d3b27d..f5b90424afbc6 100644 --- a/compiler/rustc_type_ir_macros/src/lib.rs +++ b/compiler/rustc_type_ir_macros/src/lib.rs @@ -71,7 +71,7 @@ fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { wc.push(parse_quote! { #ty: ::rustc_type_ir::lift::Lift }); let bind = &bindings[index]; quote! { - #bind.lift_to_tcx(interner)? + #bind.lift_to_interner(interner)? } }) }); @@ -89,7 +89,7 @@ fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { quote! { type Lifted = #lifted_ty; - fn lift_to_tcx( + fn lift_to_interner( self, interner: J, ) -> Option { From 8d90f442ca3b71b1bbda426e5d82ef528c71f8ff Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 16 Jul 2024 00:06:30 -0400 Subject: [PATCH 04/13] tcx -> cx in rustc_type_ir --- compiler/rustc_type_ir/src/binder.rs | 36 ++++---- compiler/rustc_type_ir/src/canonical.rs | 12 +-- compiler/rustc_type_ir/src/effects.rs | 20 ++--- compiler/rustc_type_ir/src/elaborate.rs | 8 +- compiler/rustc_type_ir/src/fast_reject.rs | 6 +- compiler/rustc_type_ir/src/fold.rs | 22 ++--- compiler/rustc_type_ir/src/inherent.rs | 2 +- compiler/rustc_type_ir/src/lift.rs | 2 +- compiler/rustc_type_ir/src/opaque_ty.rs | 10 +-- compiler/rustc_type_ir/src/outlives.rs | 14 +-- compiler/rustc_type_ir/src/predicate.rs | 38 ++++---- compiler/rustc_type_ir/src/relate.rs | 89 +++++++++---------- compiler/rustc_type_ir/src/solve/mod.rs | 8 +- compiler/rustc_type_ir/src/ty_kind/closure.rs | 34 +++---- 14 files changed, 149 insertions(+), 152 deletions(-) diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index 9f2af470d1cd8..17b35a2807a2d 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -49,10 +49,10 @@ where { type Lifted = Binder; - fn lift_to_interner(self, tcx: U) -> Option { + fn lift_to_interner(self, cx: U) -> Option { Some(Binder { - value: self.value.lift_to_interner(tcx)?, - bound_vars: self.bound_vars.lift_to_interner(tcx)?, + value: self.value.lift_to_interner(cx)?, + bound_vars: self.bound_vars.lift_to_interner(cx)?, }) } } @@ -439,11 +439,11 @@ impl EarlyBinder where Iter::Item: TypeFoldable, { - pub fn iter_instantiated(self, tcx: I, args: A) -> IterInstantiated + pub fn iter_instantiated(self, cx: I, args: A) -> IterInstantiated where A: SliceLike, { - IterInstantiated { it: self.value.into_iter(), tcx, args } + IterInstantiated { it: self.value.into_iter(), cx, args } } /// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity), @@ -455,7 +455,7 @@ where pub struct IterInstantiated { it: Iter::IntoIter, - tcx: I, + cx: I, args: A, } @@ -469,7 +469,7 @@ where fn next(&mut self) -> Option { Some( EarlyBinder { value: self.it.next()?, _tcx: PhantomData } - .instantiate(self.tcx, self.args), + .instantiate(self.cx, self.args), ) } @@ -487,7 +487,7 @@ where fn next_back(&mut self) -> Option { Some( EarlyBinder { value: self.it.next_back()?, _tcx: PhantomData } - .instantiate(self.tcx, self.args), + .instantiate(self.cx, self.args), ) } } @@ -507,10 +507,10 @@ where { pub fn iter_instantiated_copied( self, - tcx: I, + cx: I, args: &'s [I::GenericArg], ) -> IterInstantiatedCopied<'s, I, Iter> { - IterInstantiatedCopied { it: self.value.into_iter(), tcx, args } + IterInstantiatedCopied { it: self.value.into_iter(), cx, args } } /// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity), @@ -522,7 +522,7 @@ where pub struct IterInstantiatedCopied<'a, I: Interner, Iter: IntoIterator> { it: Iter::IntoIter, - tcx: I, + cx: I, args: &'a [I::GenericArg], } @@ -535,7 +535,7 @@ where fn next(&mut self) -> Option { self.it.next().map(|value| { - EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.tcx, self.args) + EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.cx, self.args) }) } @@ -552,7 +552,7 @@ where { fn next_back(&mut self) -> Option { self.it.next_back().map(|value| { - EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.tcx, self.args) + EarlyBinder { value: *value, _tcx: PhantomData }.instantiate(self.cx, self.args) }) } } @@ -589,11 +589,11 @@ impl Iterator for EarlyBinderIter { } impl> ty::EarlyBinder { - pub fn instantiate(self, tcx: I, args: A) -> T + pub fn instantiate(self, cx: I, args: A) -> T where A: SliceLike, { - let mut folder = ArgFolder { tcx, args: args.as_slice(), binders_passed: 0 }; + let mut folder = ArgFolder { cx, args: args.as_slice(), binders_passed: 0 }; self.value.fold_with(&mut folder) } @@ -619,7 +619,7 @@ impl> ty::EarlyBinder { // The actual instantiation engine itself is a type folder. struct ArgFolder<'a, I: Interner> { - tcx: I, + cx: I, args: &'a [I::GenericArg], /// Number of region binders we have passed through while doing the instantiation @@ -629,7 +629,7 @@ struct ArgFolder<'a, I: Interner> { impl<'a, I: Interner> TypeFolder for ArgFolder<'a, I> { #[inline] fn cx(&self) -> I { - self.tcx + self.cx } fn fold_binder>(&mut self, t: ty::Binder) -> ty::Binder { @@ -858,6 +858,6 @@ impl<'a, I: Interner> ArgFolder<'a, I> { if self.binders_passed == 0 || !region.has_escaping_bound_vars() { return region; } - ty::fold::shift_region(self.tcx, region, self.binders_passed) + ty::fold::shift_region(self.cx, region, self.binders_passed) } } diff --git a/compiler/rustc_type_ir/src/canonical.rs b/compiler/rustc_type_ir/src/canonical.rs index 7b114f565f29e..a9252711b2b66 100644 --- a/compiler/rustc_type_ir/src/canonical.rs +++ b/compiler/rustc_type_ir/src/canonical.rs @@ -330,25 +330,25 @@ impl CanonicalVarValues { // Given a list of canonical variables, construct a set of values which are // the identity response. - pub fn make_identity(tcx: I, infos: I::CanonicalVars) -> CanonicalVarValues { + pub fn make_identity(cx: I, infos: I::CanonicalVars) -> CanonicalVarValues { CanonicalVarValues { - var_values: tcx.mk_args_from_iter(infos.iter().enumerate().map( + var_values: cx.mk_args_from_iter(infos.iter().enumerate().map( |(i, info)| -> I::GenericArg { match info.kind { CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => { - Ty::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i)) + Ty::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i)) .into() } CanonicalVarKind::Region(_) | CanonicalVarKind::PlaceholderRegion(_) => { - Region::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i)) + Region::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i)) .into() } CanonicalVarKind::Effect => { - Const::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i)) + Const::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i)) .into() } CanonicalVarKind::Const(_) | CanonicalVarKind::PlaceholderConst(_) => { - Const::new_anon_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i)) + Const::new_anon_bound(cx, ty::INNERMOST, ty::BoundVar::from_usize(i)) .into() } } diff --git a/compiler/rustc_type_ir/src/effects.rs b/compiler/rustc_type_ir/src/effects.rs index f7942f2f982f5..d1c3c8e52235c 100644 --- a/compiler/rustc_type_ir/src/effects.rs +++ b/compiler/rustc_type_ir/src/effects.rs @@ -10,38 +10,38 @@ pub enum EffectKind { } impl EffectKind { - pub fn try_from_def_id(tcx: I, def_id: I::DefId) -> Option { - if tcx.is_lang_item(def_id, EffectsMaybe) { + pub fn try_from_def_id(cx: I, def_id: I::DefId) -> Option { + if cx.is_lang_item(def_id, EffectsMaybe) { Some(EffectKind::Maybe) - } else if tcx.is_lang_item(def_id, EffectsRuntime) { + } else if cx.is_lang_item(def_id, EffectsRuntime) { Some(EffectKind::Runtime) - } else if tcx.is_lang_item(def_id, EffectsNoRuntime) { + } else if cx.is_lang_item(def_id, EffectsNoRuntime) { Some(EffectKind::NoRuntime) } else { None } } - pub fn to_def_id(self, tcx: I) -> I::DefId { + pub fn to_def_id(self, cx: I) -> I::DefId { let lang_item = match self { EffectKind::Maybe => EffectsMaybe, EffectKind::NoRuntime => EffectsNoRuntime, EffectKind::Runtime => EffectsRuntime, }; - tcx.require_lang_item(lang_item) + cx.require_lang_item(lang_item) } - pub fn try_from_ty(tcx: I, ty: I::Ty) -> Option { + pub fn try_from_ty(cx: I, ty: I::Ty) -> Option { if let crate::Adt(def, _) = ty.kind() { - Self::try_from_def_id(tcx, def.def_id()) + Self::try_from_def_id(cx, def.def_id()) } else { None } } - pub fn to_ty(self, tcx: I) -> I::Ty { - I::Ty::new_adt(tcx, tcx.adt_def(self.to_def_id(tcx)), Default::default()) + pub fn to_ty(self, cx: I) -> I::Ty { + I::Ty::new_adt(cx, cx.adt_def(self.to_def_id(cx)), Default::default()) } /// Returns an intersection between two effect kinds. If one effect kind diff --git a/compiler/rustc_type_ir/src/elaborate.rs b/compiler/rustc_type_ir/src/elaborate.rs index 0def7d12f742a..7dd2f3de3f824 100644 --- a/compiler/rustc_type_ir/src/elaborate.rs +++ b/compiler/rustc_type_ir/src/elaborate.rs @@ -258,17 +258,17 @@ pub fn supertrait_def_ids( } pub fn supertraits( - tcx: I, + cx: I, trait_ref: ty::Binder>, ) -> FilterToTraits> { - elaborate(tcx, [trait_ref.upcast(tcx)]).filter_only_self().filter_to_traits() + elaborate(cx, [trait_ref.upcast(cx)]).filter_only_self().filter_to_traits() } pub fn transitive_bounds( - tcx: I, + cx: I, trait_refs: impl Iterator>>, ) -> FilterToTraits> { - elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.upcast(tcx))) + elaborate(cx, trait_refs.map(|trait_ref| trait_ref.upcast(cx))) .filter_only_self() .filter_to_traits() } diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs index 0810fa5c55832..456accd1a1b78 100644 --- a/compiler/rustc_type_ir/src/fast_reject.rs +++ b/compiler/rustc_type_ir/src/fast_reject.rs @@ -105,7 +105,7 @@ pub enum TreatParams { /// /// ยน meaning that if the outermost layers are different, then the whole types are also different. pub fn simplify_type( - tcx: I, + cx: I, ty: I::Ty, treat_params: TreatParams, ) -> Option> { @@ -119,10 +119,10 @@ pub fn simplify_type( ty::Str => Some(SimplifiedType::Str), ty::Array(..) => Some(SimplifiedType::Array), ty::Slice(..) => Some(SimplifiedType::Slice), - ty::Pat(ty, ..) => simplify_type(tcx, ty, treat_params), + ty::Pat(ty, ..) => simplify_type(cx, ty, treat_params), ty::RawPtr(_, mutbl) => Some(SimplifiedType::Ptr(mutbl)), ty::Dynamic(trait_info, ..) => match trait_info.principal_def_id() { - Some(principal_def_id) if !tcx.trait_is_auto(principal_def_id) => { + Some(principal_def_id) if !cx.trait_is_auto(principal_def_id) => { Some(SimplifiedType::Trait(principal_def_id)) } _ => Some(SimplifiedType::MarkerTraitObject), diff --git a/compiler/rustc_type_ir/src/fold.rs b/compiler/rustc_type_ir/src/fold.rs index 09ee12d1cc391..a4d8dafb246e5 100644 --- a/compiler/rustc_type_ir/src/fold.rs +++ b/compiler/rustc_type_ir/src/fold.rs @@ -345,20 +345,20 @@ impl, Ix: Idx> TypeFoldable for IndexVec { - tcx: I, + cx: I, current_index: ty::DebruijnIndex, amount: u32, } impl Shifter { - pub fn new(tcx: I, amount: u32) -> Self { - Shifter { tcx, current_index: ty::INNERMOST, amount } + pub fn new(cx: I, amount: u32) -> Self { + Shifter { cx, current_index: ty::INNERMOST, amount } } } impl TypeFolder for Shifter { fn cx(&self) -> I { - self.tcx + self.cx } fn fold_binder>(&mut self, t: ty::Binder) -> ty::Binder { @@ -372,7 +372,7 @@ impl TypeFolder for Shifter { match r.kind() { ty::ReBound(debruijn, br) if debruijn >= self.current_index => { let debruijn = debruijn.shifted_in(self.amount); - Region::new_bound(self.tcx, debruijn, br) + Region::new_bound(self.cx, debruijn, br) } _ => r, } @@ -382,7 +382,7 @@ impl TypeFolder for Shifter { match ty.kind() { ty::Bound(debruijn, bound_ty) if debruijn >= self.current_index => { let debruijn = debruijn.shifted_in(self.amount); - Ty::new_bound(self.tcx, debruijn, bound_ty) + Ty::new_bound(self.cx, debruijn, bound_ty) } _ if ty.has_vars_bound_at_or_above(self.current_index) => ty.super_fold_with(self), @@ -394,7 +394,7 @@ impl TypeFolder for Shifter { match ct.kind() { ty::ConstKind::Bound(debruijn, bound_ct) if debruijn >= self.current_index => { let debruijn = debruijn.shifted_in(self.amount); - Const::new_bound(self.tcx, debruijn, bound_ct) + Const::new_bound(self.cx, debruijn, bound_ct) } _ => ct.super_fold_with(self), } @@ -405,16 +405,16 @@ impl TypeFolder for Shifter { } } -pub fn shift_region(tcx: I, region: I::Region, amount: u32) -> I::Region { +pub fn shift_region(cx: I, region: I::Region, amount: u32) -> I::Region { match region.kind() { ty::ReBound(debruijn, br) if amount > 0 => { - Region::new_bound(tcx, debruijn.shifted_in(amount), br) + Region::new_bound(cx, debruijn.shifted_in(amount), br) } _ => region, } } -pub fn shift_vars(tcx: I, value: T, amount: u32) -> T +pub fn shift_vars(cx: I, value: T, amount: u32) -> T where T: TypeFoldable, { @@ -424,5 +424,5 @@ where return value; } - value.fold_with(&mut Shifter::new(tcx, amount)) + value.fold_with(&mut Shifter::new(cx, amount)) } diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index f05d626b47032..63ad36efc8529 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -475,7 +475,7 @@ pub trait Clause>: /// poly-trait-ref to supertraits that must hold if that /// poly-trait-ref holds. This is slightly different from a normal /// instantiation in terms of what happens with bound regions. - fn instantiate_supertrait(self, tcx: I, trait_ref: ty::Binder>) -> Self; + fn instantiate_supertrait(self, cx: I, trait_ref: ty::Binder>) -> Self; } /// Common capabilities of placeholder kinds diff --git a/compiler/rustc_type_ir/src/lift.rs b/compiler/rustc_type_ir/src/lift.rs index abad155c9ae0d..e5a099d1f5042 100644 --- a/compiler/rustc_type_ir/src/lift.rs +++ b/compiler/rustc_type_ir/src/lift.rs @@ -17,5 +17,5 @@ /// e.g., `()` or `u8`, was interned in a different context. pub trait Lift: std::fmt::Debug { type Lifted: std::fmt::Debug; - fn lift_to_interner(self, tcx: I) -> Option; + fn lift_to_interner(self, cx: I) -> Option; } diff --git a/compiler/rustc_type_ir/src/opaque_ty.rs b/compiler/rustc_type_ir/src/opaque_ty.rs index d8ed4770e2dc1..e5d18fcb3d1e1 100644 --- a/compiler/rustc_type_ir/src/opaque_ty.rs +++ b/compiler/rustc_type_ir/src/opaque_ty.rs @@ -22,8 +22,8 @@ pub struct OpaqueTypeKey { } impl OpaqueTypeKey { - pub fn iter_captured_args(self, tcx: I) -> impl Iterator { - let variances = tcx.variances_of(self.def_id.into()); + pub fn iter_captured_args(self, cx: I) -> impl Iterator { + let variances = cx.variances_of(self.def_id.into()); std::iter::zip(self.args.iter(), variances.iter()).enumerate().filter_map( |(i, (arg, v))| match (arg.kind(), v) { (_, ty::Invariant) => Some((i, arg)), @@ -35,18 +35,18 @@ impl OpaqueTypeKey { pub fn fold_captured_lifetime_args( self, - tcx: I, + cx: I, mut f: impl FnMut(I::Region) -> I::Region, ) -> Self { let Self { def_id, args } = self; - let variances = tcx.variances_of(def_id.into()); + let variances = cx.variances_of(def_id.into()); let args = std::iter::zip(args.iter(), variances.iter()).map(|(arg, v)| match (arg.kind(), v) { (ty::GenericArgKind::Lifetime(_), ty::Bivariant) => arg, (ty::GenericArgKind::Lifetime(lt), _) => f(lt).into(), _ => arg, }); - let args = tcx.mk_args_from_iter(args); + let args = cx.mk_args_from_iter(args); Self { def_id, args } } } diff --git a/compiler/rustc_type_ir/src/outlives.rs b/compiler/rustc_type_ir/src/outlives.rs index 10b6f3355d92a..eb84f3dd58731 100644 --- a/compiler/rustc_type_ir/src/outlives.rs +++ b/compiler/rustc_type_ir/src/outlives.rs @@ -54,15 +54,15 @@ pub enum Component { /// Push onto `out` all the things that must outlive `'a` for the condition /// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**. pub fn push_outlives_components( - tcx: I, + cx: I, ty: I::Ty, out: &mut SmallVec<[Component; 4]>, ) { - ty.visit_with(&mut OutlivesCollector { tcx, out, visited: Default::default() }); + ty.visit_with(&mut OutlivesCollector { cx, out, visited: Default::default() }); } struct OutlivesCollector<'a, I: Interner> { - tcx: I, + cx: I, out: &'a mut SmallVec<[Component; 4]>, visited: SsoHashSet, } @@ -147,7 +147,7 @@ impl TypeVisitor for OutlivesCollector<'_, I> { // OutlivesProjectionComponents. Continue walking // through and constrain Pi. let mut subcomponents = smallvec![]; - compute_alias_components_recursive(self.tcx, ty, &mut subcomponents); + compute_alias_components_recursive(self.cx, ty, &mut subcomponents); self.out.push(Component::EscapingAlias(subcomponents.into_iter().collect())); } } @@ -206,7 +206,7 @@ impl TypeVisitor for OutlivesCollector<'_, I> { /// This should not be used to get the components of `parent` itself. /// Use [push_outlives_components] instead. pub fn compute_alias_components_recursive( - tcx: I, + cx: I, alias_ty: I::Ty, out: &mut SmallVec<[Component; 4]>, ) { @@ -215,9 +215,9 @@ pub fn compute_alias_components_recursive( }; let opt_variances = - if kind == ty::Opaque { Some(tcx.variances_of(alias_ty.def_id)) } else { None }; + if kind == ty::Opaque { Some(cx.variances_of(alias_ty.def_id)) } else { None }; - let mut visitor = OutlivesCollector { tcx, out, visited: Default::default() }; + let mut visitor = OutlivesCollector { cx, out, visited: Default::default() }; for (index, child) in alias_ty.args.iter().enumerate() { if opt_variances.and_then(|variances| variances.get(index)) == Some(ty::Bivariant) { diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index acf8817c6ac19..e03f521c5b105 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -34,8 +34,8 @@ where { type Lifted = OutlivesPredicate; - fn lift_to_interner(self, tcx: U) -> Option { - Some(OutlivesPredicate(self.0.lift_to_interner(tcx)?, self.1.lift_to_interner(tcx)?)) + fn lift_to_interner(self, cx: U) -> Option { + Some(OutlivesPredicate(self.0.lift_to_interner(cx)?, self.1.lift_to_interner(cx)?)) } } @@ -267,25 +267,23 @@ impl ty::Binder> { /// Given an existential predicate like `?Self: PartialEq` (e.g., derived from `dyn PartialEq`), /// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self` /// has been replaced with `self_ty` (e.g., `self_ty: PartialEq`, in our example). - pub fn with_self_ty(&self, tcx: I, self_ty: I::Ty) -> I::Clause { + pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause { match self.skip_binder() { - ExistentialPredicate::Trait(tr) => { - self.rebind(tr).with_self_ty(tcx, self_ty).upcast(tcx) - } + ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx), ExistentialPredicate::Projection(p) => { - self.rebind(p.with_self_ty(tcx, self_ty)).upcast(tcx) + self.rebind(p.with_self_ty(cx, self_ty)).upcast(cx) } ExistentialPredicate::AutoTrait(did) => { - let generics = tcx.generics_of(did); + let generics = cx.generics_of(did); let trait_ref = if generics.count() == 1 { - ty::TraitRef::new(tcx, did, [self_ty]) + ty::TraitRef::new(cx, did, [self_ty]) } else { // If this is an ill-formed auto trait, then synthesize // new error args for the missing generics. - let err_args = GenericArgs::extend_with_error(tcx, did, &[self_ty.into()]); - ty::TraitRef::new_from_args(tcx, did, err_args) + let err_args = GenericArgs::extend_with_error(cx, did, &[self_ty.into()]); + ty::TraitRef::new_from_args(cx, did, err_args) }; - self.rebind(trait_ref).upcast(tcx) + self.rebind(trait_ref).upcast(cx) } } } @@ -345,8 +343,8 @@ impl ty::Binder> { /// we convert the principal trait-ref into a normal trait-ref, /// you must give *some* self type. A common choice is `mk_err()` /// or some placeholder type. - pub fn with_self_ty(&self, tcx: I, self_ty: I::Ty) -> ty::Binder> { - self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty)) + pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder> { + self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty)) } } @@ -406,8 +404,8 @@ impl ExistentialProjection { } impl ty::Binder> { - pub fn with_self_ty(&self, tcx: I, self_ty: I::Ty) -> ty::Binder> { - self.map_bound(|p| p.with_self_ty(tcx, self_ty)) + pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder> { + self.map_bound(|p| p.with_self_ty(cx, self_ty)) } pub fn item_def_id(&self) -> I::DefId { @@ -669,21 +667,21 @@ impl ProjectionPredicate { impl ty::Binder> { /// Returns the `DefId` of the trait of the associated item being projected. #[inline] - pub fn trait_def_id(&self, tcx: I) -> I::DefId { - self.skip_binder().projection_term.trait_def_id(tcx) + pub fn trait_def_id(&self, cx: I) -> I::DefId { + self.skip_binder().projection_term.trait_def_id(cx) } /// Get the trait ref required for this projection to be well formed. /// Note that for generic associated types the predicates of the associated /// type also need to be checked. #[inline] - pub fn required_poly_trait_ref(&self, tcx: I) -> ty::Binder> { + pub fn required_poly_trait_ref(&self, cx: I) -> ty::Binder> { // Note: unlike with `TraitRef::to_poly_trait_ref()`, // `self.0.trait_ref` is permitted to have escaping regions. // This is because here `self` has a `Binder` and so does our // return value, so we are preserving the number of binding // levels. - self.map_bound(|predicate| predicate.projection_term.trait_ref(tcx)) + self.map_bound(|predicate| predicate.projection_term.trait_ref(cx)) } pub fn term(&self) -> ty::Binder { diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index 0439e7f857fe7..a8f48d14af5ce 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -56,7 +56,7 @@ impl VarianceDiagInfo { } pub trait TypeRelation: Sized { - fn tcx(&self) -> I; + fn cx(&self) -> I; /// Returns a static string we can use for printouts. fn tag(&self) -> &'static str; @@ -80,8 +80,8 @@ pub trait TypeRelation: Sized { item_def_id, a_arg, b_arg ); - let tcx = self.tcx(); - let opt_variances = tcx.variances_of(item_def_id); + let cx = self.cx(); + let opt_variances = cx.variances_of(item_def_id); relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, true) } @@ -128,7 +128,7 @@ pub fn relate_args_invariantly>( a_arg: I::GenericArgs, b_arg: I::GenericArgs, ) -> RelateResult { - relation.tcx().mk_args_from_iter(iter::zip(a_arg.iter(), b_arg.iter()).map(|(a, b)| { + relation.cx().mk_args_from_iter(iter::zip(a_arg.iter(), b_arg.iter()).map(|(a, b)| { relation.relate_with_variance(ty::Invariant, VarianceDiagInfo::default(), a, b) })) } @@ -141,14 +141,13 @@ pub fn relate_args_with_variances>( b_arg: I::GenericArgs, fetch_ty_for_diag: bool, ) -> RelateResult { - let tcx = relation.tcx(); + let cx = relation.cx(); let mut cached_ty = None; let params = iter::zip(a_arg.iter(), b_arg.iter()).enumerate().map(|(i, (a, b))| { let variance = variances.get(i).unwrap(); let variance_info = if variance == ty::Invariant && fetch_ty_for_diag { - let ty = - *cached_ty.get_or_insert_with(|| tcx.type_of(ty_def_id).instantiate(tcx, a_arg)); + let ty = *cached_ty.get_or_insert_with(|| cx.type_of(ty_def_id).instantiate(cx, a_arg)); VarianceDiagInfo::Invariant { ty, param_index: i.try_into().unwrap() } } else { VarianceDiagInfo::default() @@ -156,7 +155,7 @@ pub fn relate_args_with_variances>( relation.relate_with_variance(variance, variance_info, a, b) }); - tcx.mk_args_from_iter(params) + cx.mk_args_from_iter(params) } impl Relate for ty::FnSig { @@ -165,7 +164,7 @@ impl Relate for ty::FnSig { a: ty::FnSig, b: ty::FnSig, ) -> RelateResult> { - let tcx = relation.tcx(); + let cx = relation.cx(); if a.c_variadic != b.c_variadic { return Err(TypeError::VariadicMismatch({ @@ -210,7 +209,7 @@ impl Relate for ty::FnSig { r => r, }); Ok(ty::FnSig { - inputs_and_output: tcx.mk_type_list_from_iter(inputs_and_output)?, + inputs_and_output: cx.mk_type_list_from_iter(inputs_and_output)?, c_variadic: a.c_variadic, safety, abi, @@ -245,11 +244,11 @@ impl Relate for ty::AliasTy { ExpectedFound::new(true, a, b) })) } else { - let args = match a.kind(relation.tcx()) { + let args = match a.kind(relation.cx()) { ty::Opaque => relate_args_with_variances( relation, a.def_id, - relation.tcx().variances_of(a.def_id), + relation.cx().variances_of(a.def_id), a.args, b.args, false, // do not fetch `type_of(a_def_id)`, as it will cause a cycle @@ -258,7 +257,7 @@ impl Relate for ty::AliasTy { relate_args_invariantly(relation, a.args, b.args)? } }; - Ok(ty::AliasTy::new_from_args(relation.tcx(), a.def_id, args)) + Ok(ty::AliasTy::new_from_args(relation.cx(), a.def_id, args)) } } } @@ -276,11 +275,11 @@ impl Relate for ty::AliasTerm { ExpectedFound::new(true, a, b) })) } else { - let args = match a.kind(relation.tcx()) { + let args = match a.kind(relation.cx()) { ty::AliasTermKind::OpaqueTy => relate_args_with_variances( relation, a.def_id, - relation.tcx().variances_of(a.def_id), + relation.cx().variances_of(a.def_id), a.args, b.args, false, // do not fetch `type_of(a_def_id)`, as it will cause a cycle @@ -293,7 +292,7 @@ impl Relate for ty::AliasTerm { relate_args_invariantly(relation, a.args, b.args)? } }; - Ok(ty::AliasTerm::new_from_args(relation.tcx(), a.def_id, args)) + Ok(ty::AliasTerm::new_from_args(relation.cx(), a.def_id, args)) } } } @@ -343,7 +342,7 @@ impl Relate for ty::TraitRef { })) } else { let args = relate_args_invariantly(relation, a.args, b.args)?; - Ok(ty::TraitRef::new_from_args(relation.tcx(), a.def_id, args)) + Ok(ty::TraitRef::new_from_args(relation.cx(), a.def_id, args)) } } } @@ -377,7 +376,7 @@ pub fn structurally_relate_tys>( a: I::Ty, b: I::Ty, ) -> RelateResult { - let tcx = relation.tcx(); + let cx = relation.cx(); match (a.kind(), b.kind()) { (ty::Infer(_), _) | (_, ty::Infer(_)) => { // The caller should handle these cases! @@ -388,7 +387,7 @@ pub fn structurally_relate_tys>( panic!("bound types encountered in structurally_relate_tys") } - (ty::Error(guar), _) | (_, ty::Error(guar)) => Ok(Ty::new_error(tcx, guar)), + (ty::Error(guar), _) | (_, ty::Error(guar)) => Ok(Ty::new_error(cx, guar)), (ty::Never, _) | (ty::Char, _) @@ -412,16 +411,16 @@ pub fn structurally_relate_tys>( (ty::Adt(a_def, a_args), ty::Adt(b_def, b_args)) if a_def == b_def => { let args = relation.relate_item_args(a_def.def_id(), a_args, b_args)?; - Ok(Ty::new_adt(tcx, a_def, args)) + Ok(Ty::new_adt(cx, a_def, args)) } - (ty::Foreign(a_id), ty::Foreign(b_id)) if a_id == b_id => Ok(Ty::new_foreign(tcx, a_id)), + (ty::Foreign(a_id), ty::Foreign(b_id)) if a_id == b_id => Ok(Ty::new_foreign(cx, a_id)), (ty::Dynamic(a_obj, a_region, a_repr), ty::Dynamic(b_obj, b_region, b_repr)) if a_repr == b_repr => { Ok(Ty::new_dynamic( - tcx, + cx, relation.relate(a_obj, b_obj)?, relation.relate(a_region, b_region)?, a_repr, @@ -433,7 +432,7 @@ pub fn structurally_relate_tys>( // the (anonymous) type of the same coroutine expression. So // all of their regions should be equated. let args = relate_args_invariantly(relation, a_args, b_args)?; - Ok(Ty::new_coroutine(tcx, a_id, args)) + Ok(Ty::new_coroutine(cx, a_id, args)) } (ty::CoroutineWitness(a_id, a_args), ty::CoroutineWitness(b_id, b_args)) @@ -443,7 +442,7 @@ pub fn structurally_relate_tys>( // the (anonymous) type of the same coroutine expression. So // all of their regions should be equated. let args = relate_args_invariantly(relation, a_args, b_args)?; - Ok(Ty::new_coroutine_witness(tcx, a_id, args)) + Ok(Ty::new_coroutine_witness(cx, a_id, args)) } (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>( // the (anonymous) type of the same closure expression. So // all of their regions should be equated. let args = relate_args_invariantly(relation, a_args, b_args)?; - Ok(Ty::new_closure(tcx, a_id, args)) + Ok(Ty::new_closure(cx, a_id, args)) } (ty::CoroutineClosure(a_id, a_args), ty::CoroutineClosure(b_id, b_args)) if a_id == b_id => { let args = relate_args_invariantly(relation, a_args, b_args)?; - Ok(Ty::new_coroutine_closure(tcx, a_id, args)) + Ok(Ty::new_coroutine_closure(cx, a_id, args)) } (ty::RawPtr(a_ty, a_mutbl), ty::RawPtr(b_ty, b_mutbl)) => { @@ -475,7 +474,7 @@ pub fn structurally_relate_tys>( let ty = relation.relate_with_variance(variance, info, a_ty, b_ty)?; - Ok(Ty::new_ptr(tcx, ty, a_mutbl)) + Ok(Ty::new_ptr(cx, ty, a_mutbl)) } (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>( let r = relation.relate(a_r, b_r)?; let ty = relation.relate_with_variance(variance, info, a_ty, b_ty)?; - Ok(Ty::new_ref(tcx, r, ty, a_mutbl)) + Ok(Ty::new_ref(cx, r, ty, a_mutbl)) } (ty::Array(a_t, sz_a), ty::Array(b_t, sz_b)) => { let t = relation.relate(a_t, b_t)?; match relation.relate(sz_a, sz_b) { - Ok(sz) => Ok(Ty::new_array_with_const_len(tcx, t, sz)), + Ok(sz) => Ok(Ty::new_array_with_const_len(cx, t, sz)), Err(err) => { // Check whether the lengths are both concrete/known values, // but are unequal, for better diagnostics. - let sz_a = sz_a.try_to_target_usize(tcx); - let sz_b = sz_b.try_to_target_usize(tcx); + let sz_a = sz_a.try_to_target_usize(cx); + let sz_b = sz_b.try_to_target_usize(cx); match (sz_a, sz_b) { (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>( (ty::Slice(a_t), ty::Slice(b_t)) => { let t = relation.relate(a_t, b_t)?; - Ok(Ty::new_slice(tcx, t)) + Ok(Ty::new_slice(cx, t)) } (ty::Tuple(as_), ty::Tuple(bs)) => { if as_.len() == bs.len() { Ok(Ty::new_tup_from_iter( - tcx, + cx, iter::zip(as_.iter(), bs.iter()).map(|(a, b)| relation.relate(a, b)), )?) } else if !(as_.is_empty() || bs.is_empty()) { @@ -536,25 +535,25 @@ pub fn structurally_relate_tys>( (ty::FnDef(a_def_id, a_args), ty::FnDef(b_def_id, b_args)) if a_def_id == b_def_id => { let args = relation.relate_item_args(a_def_id, a_args, b_args)?; - Ok(Ty::new_fn_def(tcx, a_def_id, args)) + Ok(Ty::new_fn_def(cx, a_def_id, args)) } (ty::FnPtr(a_fty), ty::FnPtr(b_fty)) => { let fty = relation.relate(a_fty, b_fty)?; - Ok(Ty::new_fn_ptr(tcx, fty)) + Ok(Ty::new_fn_ptr(cx, fty)) } // Alias tend to mostly already be handled downstream due to normalization. (ty::Alias(a_kind, a_data), ty::Alias(b_kind, b_data)) => { let alias_ty = relation.relate(a_data, b_data)?; assert_eq!(a_kind, b_kind); - Ok(Ty::new_alias(tcx, a_kind, alias_ty)) + Ok(Ty::new_alias(cx, a_kind, alias_ty)) } (ty::Pat(a_ty, a_pat), ty::Pat(b_ty, b_pat)) => { let ty = relation.relate(a_ty, b_ty)?; let pat = relation.relate(a_pat, b_pat)?; - Ok(Ty::new_pat(tcx, ty, pat)) + Ok(Ty::new_pat(cx, ty, pat)) } _ => Err(TypeError::Sorts(ExpectedFound::new(true, a, b))), @@ -573,11 +572,11 @@ pub fn structurally_relate_consts>( mut b: I::Const, ) -> RelateResult { debug!("{}.structurally_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b); - let tcx = relation.tcx(); + let cx = relation.cx(); - if tcx.features().generic_const_exprs() { - a = tcx.expand_abstract_consts(a); - b = tcx.expand_abstract_consts(b); + if cx.features().generic_const_exprs() { + a = cx.expand_abstract_consts(a); + b = cx.expand_abstract_consts(b); } debug!("{}.structurally_relate_consts(normed_a = {:?}, normed_b = {:?})", relation.tag(), a, b); @@ -607,8 +606,8 @@ pub fn structurally_relate_consts>( // be stabilized. (ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => { if cfg!(debug_assertions) { - let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args); - let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args); + let a_ty = cx.type_of(au.def).instantiate(cx, au.args); + let b_ty = cx.type_of(bu.def).instantiate(cx, bu.args); assert_eq!(a_ty, b_ty); } @@ -618,11 +617,11 @@ pub fn structurally_relate_consts>( au.args, bu.args, )?; - return Ok(Const::new_unevaluated(tcx, ty::UnevaluatedConst { def: au.def, args })); + return Ok(Const::new_unevaluated(cx, ty::UnevaluatedConst { def: au.def, args })); } (ty::ConstKind::Expr(ae), ty::ConstKind::Expr(be)) => { let expr = relation.relate(ae, be)?; - return Ok(Const::new_expr(tcx, expr)); + return Ok(Const::new_expr(cx, expr)); } _ => false, }; diff --git a/compiler/rustc_type_ir/src/solve/mod.rs b/compiler/rustc_type_ir/src/solve/mod.rs index 7934f996f0bd2..2449ac47db6fa 100644 --- a/compiler/rustc_type_ir/src/solve/mod.rs +++ b/compiler/rustc_type_ir/src/solve/mod.rs @@ -106,13 +106,13 @@ pub struct Goal { } impl Goal { - pub fn new(tcx: I, param_env: I::ParamEnv, predicate: impl Upcast) -> Goal { - Goal { param_env, predicate: predicate.upcast(tcx) } + pub fn new(cx: I, param_env: I::ParamEnv, predicate: impl Upcast) -> Goal { + Goal { param_env, predicate: predicate.upcast(cx) } } /// Updates the goal to one with a different `predicate` but the same `param_env`. - pub fn with(self, tcx: I, predicate: impl Upcast) -> Goal { - Goal { param_env: self.param_env, predicate: predicate.upcast(tcx) } + pub fn with(self, cx: I, predicate: impl Upcast) -> Goal { + Goal { param_env: self.param_env, predicate: predicate.upcast(cx) } } } diff --git a/compiler/rustc_type_ir/src/ty_kind/closure.rs b/compiler/rustc_type_ir/src/ty_kind/closure.rs index 24a7c0c67e90f..6c5bbbfd59ba9 100644 --- a/compiler/rustc_type_ir/src/ty_kind/closure.rs +++ b/compiler/rustc_type_ir/src/ty_kind/closure.rs @@ -136,9 +136,9 @@ pub struct ClosureArgsParts { impl ClosureArgs { /// Construct `ClosureArgs` from `ClosureArgsParts`, containing `Args` /// for the closure parent, alongside additional closure-specific components. - pub fn new(tcx: I, parts: ClosureArgsParts) -> ClosureArgs { + pub fn new(cx: I, parts: ClosureArgsParts) -> ClosureArgs { ClosureArgs { - args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([ + args: cx.mk_args_from_iter(parts.parent_args.iter().chain([ parts.closure_kind_ty.into(), parts.closure_sig_as_fn_ptr_ty.into(), parts.tupled_upvars_ty.into(), @@ -258,9 +258,9 @@ pub struct CoroutineClosureArgsParts { } impl CoroutineClosureArgs { - pub fn new(tcx: I, parts: CoroutineClosureArgsParts) -> CoroutineClosureArgs { + pub fn new(cx: I, parts: CoroutineClosureArgsParts) -> CoroutineClosureArgs { CoroutineClosureArgs { - args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([ + args: cx.mk_args_from_iter(parts.parent_args.iter().chain([ parts.closure_kind_ty.into(), parts.signature_parts_ty.into(), parts.tupled_upvars_ty.into(), @@ -409,14 +409,14 @@ impl CoroutineClosureSignature { /// When the kind and upvars are known, use the other helper functions. pub fn to_coroutine( self, - tcx: I, + cx: I, parent_args: I::GenericArgsSlice, coroutine_kind_ty: I::Ty, coroutine_def_id: I::DefId, tupled_upvars_ty: I::Ty, ) -> I::Ty { let coroutine_args = ty::CoroutineArgs::new( - tcx, + cx, ty::CoroutineArgsParts { parent_args, kind_ty: coroutine_kind_ty, @@ -428,7 +428,7 @@ impl CoroutineClosureSignature { }, ); - Ty::new_coroutine(tcx, coroutine_def_id, coroutine_args.args) + Ty::new_coroutine(cx, coroutine_def_id, coroutine_args.args) } /// Given known upvars and a [`ClosureKind`](ty::ClosureKind), compute the coroutine @@ -438,7 +438,7 @@ impl CoroutineClosureSignature { /// that the `ClosureKind` is actually supported by the coroutine-closure. pub fn to_coroutine_given_kind_and_upvars( self, - tcx: I, + cx: I, parent_args: I::GenericArgsSlice, coroutine_def_id: I::DefId, goal_kind: ty::ClosureKind, @@ -447,7 +447,7 @@ impl CoroutineClosureSignature { coroutine_captures_by_ref_ty: I::Ty, ) -> I::Ty { let tupled_upvars_ty = Self::tupled_upvars_by_closure_kind( - tcx, + cx, goal_kind, self.tupled_inputs_ty, closure_tupled_upvars_ty, @@ -456,9 +456,9 @@ impl CoroutineClosureSignature { ); self.to_coroutine( - tcx, + cx, parent_args, - Ty::from_coroutine_closure_kind(tcx, goal_kind), + Ty::from_coroutine_closure_kind(cx, goal_kind), coroutine_def_id, tupled_upvars_ty, ) @@ -474,7 +474,7 @@ impl CoroutineClosureSignature { /// lifetimes are related to the lifetime of the borrow on the closure made for /// the call. This allows borrowck to enforce the self-borrows correctly. pub fn tupled_upvars_by_closure_kind( - tcx: I, + cx: I, kind: ty::ClosureKind, tupled_inputs_ty: I::Ty, closure_tupled_upvars_ty: I::Ty, @@ -488,12 +488,12 @@ impl CoroutineClosureSignature { }; let coroutine_captures_by_ref_ty = sig.output().skip_binder().fold_with(&mut FoldEscapingRegions { - interner: tcx, + interner: cx, region: env_region, debruijn: ty::INNERMOST, }); Ty::new_tup_from_iter( - tcx, + cx, tupled_inputs_ty .tuple_fields() .iter() @@ -501,7 +501,7 @@ impl CoroutineClosureSignature { ) } ty::ClosureKind::FnOnce => Ty::new_tup_from_iter( - tcx, + cx, tupled_inputs_ty .tuple_fields() .iter() @@ -615,9 +615,9 @@ pub struct CoroutineArgsParts { impl CoroutineArgs { /// Construct `CoroutineArgs` from `CoroutineArgsParts`, containing `Args` /// for the coroutine parent, alongside additional coroutine-specific components. - pub fn new(tcx: I, parts: CoroutineArgsParts) -> CoroutineArgs { + pub fn new(cx: I, parts: CoroutineArgsParts) -> CoroutineArgs { CoroutineArgs { - args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([ + args: cx.mk_args_from_iter(parts.parent_args.iter().chain([ parts.kind_ty.into(), parts.resume_ty.into(), parts.yield_ty.into(), From 0b5ce54bc2bd6dae4ab27fd712ee2c999491f364 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 16 Jul 2024 00:14:44 -0400 Subject: [PATCH 05/13] Fix relations --- compiler/rustc_borrowck/src/type_check/relate_tys.rs | 8 ++++---- .../rustc_infer/src/error_reporting/infer/mod.rs | 2 +- .../src/infer/outlives/test_type_match.rs | 2 +- compiler/rustc_infer/src/infer/relate/generalize.rs | 12 ++++++------ compiler/rustc_infer/src/infer/relate/glb.rs | 4 ++-- compiler/rustc_infer/src/infer/relate/lub.rs | 4 ++-- .../rustc_infer/src/infer/relate/type_relating.rs | 10 +++++----- compiler/rustc_middle/src/ty/relate.rs | 4 ++-- .../src/traits/select/_match.rs | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index 02b9c2d48b11b..ea4a94e57b3b8 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -309,7 +309,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> { } impl<'bccx, 'tcx> TypeRelation> for NllTypeRelating<'_, 'bccx, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.type_checker.infcx.tcx } @@ -370,7 +370,7 @@ impl<'bccx, 'tcx> TypeRelation> for NllTypeRelating<'_, 'bccx, 'tcx // shouldn't ever fail. Instead, it unconditionally emits an // alias-relate goal. assert!(!self.type_checker.infcx.next_trait_solver()); - self.tcx().dcx().span_delayed_bug( + self.cx().dcx().span_delayed_bug( self.span(), "failure to relate an opaque to itself should result in an error later on", ); @@ -540,7 +540,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation> for NllTypeRelating &mut self, obligations: impl IntoIterator, ty::Predicate<'tcx>>>, ) { - let tcx = self.tcx(); + let tcx = self.cx(); let param_env = self.param_env(); self.register_goals( obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)), @@ -559,7 +559,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation> for NllTypeRelating .into_iter() .map(|goal| { Obligation::new( - self.tcx(), + self.cx(), ObligationCause::dummy_with_span(self.span()), goal.param_env, goal.predicate, diff --git a/compiler/rustc_infer/src/error_reporting/infer/mod.rs b/compiler/rustc_infer/src/error_reporting/infer/mod.rs index ddd5818203cfd..a4af721cf7547 100644 --- a/compiler/rustc_infer/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_infer/src/error_reporting/infer/mod.rs @@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>); impl<'tcx> TypeRelation> for SameTypeModuloInfer<'_, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.0.tcx } diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 978b92fd8980d..d60d9113d91bf 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -137,7 +137,7 @@ impl<'tcx> TypeRelation> for MatchAgainstHigherRankedOutlives<'tcx> "MatchAgainstHigherRankedOutlives" } - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs index fe3b8d60fb91b..ace439545b84b 100644 --- a/compiler/rustc_infer/src/infer/relate/generalize.rs +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs @@ -372,7 +372,7 @@ impl<'tcx> Generalizer<'_, 'tcx> { let is_nested_alias = mem::replace(&mut self.in_alias, true); let result = match self.relate(alias, alias) { - Ok(alias) => Ok(alias.to_ty(self.tcx())), + Ok(alias) => Ok(alias.to_ty(self.cx())), Err(e) => { if is_nested_alias { return Err(e); @@ -397,7 +397,7 @@ impl<'tcx> Generalizer<'_, 'tcx> { } impl<'tcx> TypeRelation> for Generalizer<'_, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -417,7 +417,7 @@ impl<'tcx> TypeRelation> for Generalizer<'_, 'tcx> { // (e.g., #41849). relate::relate_args_invariantly(self, a_arg, b_arg) } else { - let tcx = self.tcx(); + let tcx = self.cx(); let opt_variances = tcx.variances_of(item_def_id); relate::relate_args_with_variances( self, @@ -525,7 +525,7 @@ impl<'tcx> TypeRelation> for Generalizer<'_, 'tcx> { } debug!("replacing original vid={:?} with new={:?}", vid, new_var_id); - Ok(Ty::new_var(self.tcx(), new_var_id)) + Ok(Ty::new_var(self.cx(), new_var_id)) } } } @@ -654,7 +654,7 @@ impl<'tcx> TypeRelation> for Generalizer<'_, 'tcx> { { variable_table.union(vid, new_var_id); } - Ok(ty::Const::new_var(self.tcx(), new_var_id)) + Ok(ty::Const::new_var(self.cx(), new_var_id)) } } } @@ -672,7 +672,7 @@ impl<'tcx> TypeRelation> for Generalizer<'_, 'tcx> { args, args, )?; - Ok(ty::Const::new_unevaluated(self.tcx(), ty::UnevaluatedConst { def, args })) + Ok(ty::Const::new_unevaluated(self.cx(), ty::UnevaluatedConst { def, args })) } ty::ConstKind::Placeholder(placeholder) => { if self.for_universe.can_name(placeholder.universe) { diff --git a/compiler/rustc_infer/src/infer/relate/glb.rs b/compiler/rustc_infer/src/infer/relate/glb.rs index 5bb8a113e173e..819a47fcf93fb 100644 --- a/compiler/rustc_infer/src/infer/relate/glb.rs +++ b/compiler/rustc_infer/src/infer/relate/glb.rs @@ -27,7 +27,7 @@ impl<'tcx> TypeRelation> for Glb<'_, '_, 'tcx> { "Glb" } - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } @@ -61,7 +61,7 @@ impl<'tcx> TypeRelation> for Glb<'_, '_, 'tcx> { let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone())); // GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8 Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions( - self.tcx(), + self.cx(), origin, a, b, diff --git a/compiler/rustc_infer/src/infer/relate/lub.rs b/compiler/rustc_infer/src/infer/relate/lub.rs index 94c1464817f73..56d325c5dc1fd 100644 --- a/compiler/rustc_infer/src/infer/relate/lub.rs +++ b/compiler/rustc_infer/src/infer/relate/lub.rs @@ -27,7 +27,7 @@ impl<'tcx> TypeRelation> for Lub<'_, '_, 'tcx> { "Lub" } - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } @@ -61,7 +61,7 @@ impl<'tcx> TypeRelation> for Lub<'_, '_, 'tcx> { let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone())); // LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8 Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions( - self.tcx(), + self.cx(), origin, a, b, diff --git a/compiler/rustc_infer/src/infer/relate/type_relating.rs b/compiler/rustc_infer/src/infer/relate/type_relating.rs index e206f530519b5..97bd858defbca 100644 --- a/compiler/rustc_infer/src/infer/relate/type_relating.rs +++ b/compiler/rustc_infer/src/infer/relate/type_relating.rs @@ -32,7 +32,7 @@ impl<'tcx> TypeRelation> for TypeRelating<'_, '_, 'tcx> { "TypeRelating" } - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.fields.infcx.tcx } @@ -48,7 +48,7 @@ impl<'tcx> TypeRelation> for TypeRelating<'_, '_, 'tcx> { // (e.g., #41849). relate_args_invariantly(self, a_arg, b_arg) } else { - let tcx = self.tcx(); + let tcx = self.cx(); let opt_variances = tcx.variances_of(item_def_id); relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, false) } @@ -88,7 +88,7 @@ impl<'tcx> TypeRelation> for TypeRelating<'_, '_, 'tcx> { // can't make progress on `A <: B` if both A and B are // type variables, so record an obligation. self.fields.goals.push(Goal::new( - self.tcx(), + self.cx(), self.fields.param_env, ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: true, @@ -101,7 +101,7 @@ impl<'tcx> TypeRelation> for TypeRelating<'_, '_, 'tcx> { // can't make progress on `B <: A` if both A and B are // type variables, so record an obligation. self.fields.goals.push(Goal::new( - self.tcx(), + self.cx(), self.fields.param_env, ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: false, @@ -134,7 +134,7 @@ impl<'tcx> TypeRelation> for TypeRelating<'_, '_, 'tcx> { (&ty::Error(e), _) | (_, &ty::Error(e)) => { infcx.set_tainted_by_errors(e); - return Ok(Ty::new_error(self.tcx(), e)); + return Ok(Ty::new_error(self.cx(), e)); } ( diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index ebf0d7ed737fa..61c03922ac05f 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -69,7 +69,7 @@ impl<'tcx> Relate> for ty::Pattern<'tcx> { if inc_a != inc_b { todo!() } - Ok(relation.tcx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a })) + Ok(relation.cx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a })) } } } @@ -81,7 +81,7 @@ impl<'tcx> Relate> for &'tcx ty::List RelateResult<'tcx, Self> { - let tcx = relation.tcx(); + let tcx = relation.cx(); // FIXME: this is wasteful, but want to do a perf run to see how slow it is. // We need to perform this deduplication as we sometimes generate duplicate projections diff --git a/compiler/rustc_trait_selection/src/traits/select/_match.rs b/compiler/rustc_trait_selection/src/traits/select/_match.rs index 50d8e96aaf91f..8676f30a53b6e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/_match.rs +++ b/compiler/rustc_trait_selection/src/traits/select/_match.rs @@ -36,7 +36,7 @@ impl<'tcx> TypeRelation> for MatchAgainstFreshVars<'tcx> { "MatchAgainstFreshVars" } - fn tcx(&self) -> TyCtxt<'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -77,7 +77,7 @@ impl<'tcx> TypeRelation> for MatchAgainstFreshVars<'tcx> { Err(TypeError::Sorts(ExpectedFound::new(true, a, b))) } - (&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)), + (&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.cx(), guar)), _ => structurally_relate_tys(self, a, b), } From 548394541b4bbd9ebfe031d9c3a8c57912a535be Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 9 Jul 2024 11:40:02 -0400 Subject: [PATCH 06/13] rewrite dump-ice-to-disk to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/dump-ice-to-disk/Makefile | 10 --- tests/run-make/dump-ice-to-disk/check.sh | 64 ------------------- .../dump-ice-to-disk/{src => }/lib.rs | 0 tests/run-make/dump-ice-to-disk/rmake.rs | 64 +++++++++++++++++++ 5 files changed, 64 insertions(+), 75 deletions(-) delete mode 100644 tests/run-make/dump-ice-to-disk/Makefile delete mode 100644 tests/run-make/dump-ice-to-disk/check.sh rename tests/run-make/dump-ice-to-disk/{src => }/lib.rs (100%) create mode 100644 tests/run-make/dump-ice-to-disk/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2e26f9344b899..4902656f07384 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -19,7 +19,6 @@ run-make/cross-lang-lto/Makefile run-make/dep-info-doesnt-run-much/Makefile run-make/dep-info-spaces/Makefile run-make/dep-info/Makefile -run-make/dump-ice-to-disk/Makefile run-make/emit-to-stdout/Makefile run-make/export-executable-symbols/Makefile run-make/extern-diff-internal-name/Makefile diff --git a/tests/run-make/dump-ice-to-disk/Makefile b/tests/run-make/dump-ice-to-disk/Makefile deleted file mode 100644 index 23006fc09e2f3..0000000000000 --- a/tests/run-make/dump-ice-to-disk/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -include ../tools.mk - -# ignore-windows - -export RUSTC := $(RUSTC_ORIGINAL) -export LD_LIBRARY_PATH := $(HOST_RPATH_DIR) -export TMPDIR := $(TMPDIR) - -all: - bash check.sh diff --git a/tests/run-make/dump-ice-to-disk/check.sh b/tests/run-make/dump-ice-to-disk/check.sh deleted file mode 100644 index ff6e4be35af9d..0000000000000 --- a/tests/run-make/dump-ice-to-disk/check.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh - -# Default nightly behavior (write ICE to current directory) -# FIXME(estebank): these are failing on CI, but passing locally. -# $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default.log 2>&1 -# default=$(cat ./rustc-ice-*.txt | wc -l) -# rm ./rustc-ice-*.txt - -# Explicit directory set -export RUSTC_ICE=$TMPDIR -$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1 -default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) -content=$(cat $TMPDIR/rustc-ice-*.txt) -# Ensure that the ICE dump path doesn't contain `:` because they cause problems on Windows -windows_safe=$(echo rustc-ice-*.txt | grep ':') -if [ ! -z "$windows_safe" ]; then - exit 1 -fi - -rm $TMPDIR/rustc-ice-*.txt -RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1 -short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) -rm $TMPDIR/rustc-ice-*.txt -RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-full.log 2>&1 -full=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) -rm $TMPDIR/rustc-ice-*.txt - -# Explicitly disabling ICE dump -export RUSTC_ICE=0 -$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1 -should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt 2>/dev/null | wc -l) -should_be_empty_dot=$(ls -l ./rustc-ice-*.txt 2>/dev/null | wc -l) - -echo "#### ICE Dump content:" -echo $content -echo "#### default length:" -echo $default -echo "#### short length:" -echo $short -echo "#### default_set length:" -echo $default_set -echo "#### full length:" -echo $full -echo "#### should_be_empty_dot length:" -echo $should_be_empty_dot -echo "#### should_be_empty_tmp length:" -echo $should_be_empty_tmp - -## Verify that a the ICE dump file is created in the appropriate directories, that -## their lengths are the same regardless of other backtrace configuration options, -## that the file is not created when asked to (RUSTC_ICE=0) and that the file -## contains at least part of the expected content. -if [ $short -eq $default_set ] && - #[ $default -eq $short ] && - [ $default_set -eq $full ] && - [[ $content == *"thread 'rustc' panicked at "* ]] && - [[ $content == *"stack backtrace:"* ]] && - #[ $default -gt 0 ] && - [ $should_be_empty_dot -eq 0 ] && - [ $should_be_empty_tmp -eq 0 ]; then - exit 0 -else - exit 1 -fi diff --git a/tests/run-make/dump-ice-to-disk/src/lib.rs b/tests/run-make/dump-ice-to-disk/lib.rs similarity index 100% rename from tests/run-make/dump-ice-to-disk/src/lib.rs rename to tests/run-make/dump-ice-to-disk/lib.rs diff --git a/tests/run-make/dump-ice-to-disk/rmake.rs b/tests/run-make/dump-ice-to-disk/rmake.rs new file mode 100644 index 0000000000000..95f9223452c65 --- /dev/null +++ b/tests/run-make/dump-ice-to-disk/rmake.rs @@ -0,0 +1,64 @@ +// This test checks if internal compilation error (ICE) log files work as expected. +// - Get the number of lines from the log files without any configuration options, +// then check that the line count doesn't change if the backtrace gets configured to be short +// or full. +// - Check that disabling ICE logging results in zero files created. +// - Check that the ICE files contain some of the expected strings. +// See https://github.com/rust-lang/rust/pull/108714 + +// FIXME(Oneirical): try it on Windows! + +use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files}; + +fn main() { + rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); + let ice_text = get_text_from_ice(); + let default_set = ice_text.lines().count(); + let content = ice_text; + // Ensure that the ICE files don't contain `:` in their filename because + // this causes problems on Windows. + for file in shallow_find_files(cwd(), |path| { + has_prefix(path, "rustc-ice") && has_extension(path, "txt") + }) { + assert!(!file.display().to_string().contains(":")); + } + + clear_ice_files(); + rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail(); + let short = get_text_from_ice().lines().count(); + clear_ice_files(); + rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail(); + let full = get_text_from_ice().lines().count(); + clear_ice_files(); + + // The ICE dump is explicitely disabled. Therefore, this should produce no files. + rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); + assert!(get_text_from_ice().is_empty()); + + // The line count should not change. + assert_eq!(short, default_set); + assert_eq!(full, default_set); + // Some of the expected strings in an ICE file should appear. + assert!(content.contains("thread 'rustc' panicked at")); + assert!(content.contains("stack backtrace:")); +} + +fn clear_ice_files() { + let ice_files = shallow_find_files(cwd(), |path| { + has_prefix(path, "rustc-ice") && has_extension(path, "txt") + }); + for file in ice_files { + fs_wrapper::remove_file(file); + } +} + +fn get_text_from_ice() -> String { + let ice_files = shallow_find_files(cwd(), |path| { + has_prefix(path, "rustc-ice") && has_extension(path, "txt") + }); + let mut output = String::new(); + for file in ice_files { + output.push_str(&fs_wrapper::read_to_string(file)); + } + output +} From f54fa62887b24a9a9d0cae4251b0498fae1dd725 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 9 Jul 2024 11:55:54 -0400 Subject: [PATCH 07/13] rewrite panic-abort-eh_frame to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/dump-ice-to-disk/rmake.rs | 67 ++++++++++++------- tests/run-make/panic-abort-eh_frame/Makefile | 10 --- tests/run-make/panic-abort-eh_frame/rmake.rs | 20 ++++++ 4 files changed, 62 insertions(+), 36 deletions(-) delete mode 100644 tests/run-make/panic-abort-eh_frame/Makefile create mode 100644 tests/run-make/panic-abort-eh_frame/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 4902656f07384..4313e6472603e 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -81,7 +81,6 @@ run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile run-make/no-duplicate-libs/Makefile -run-make/panic-abort-eh_frame/Makefile run-make/pass-non-c-like-enum-to-c/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile diff --git a/tests/run-make/dump-ice-to-disk/rmake.rs b/tests/run-make/dump-ice-to-disk/rmake.rs index 95f9223452c65..2fb5c825064b0 100644 --- a/tests/run-make/dump-ice-to-disk/rmake.rs +++ b/tests/run-make/dump-ice-to-disk/rmake.rs @@ -6,38 +6,56 @@ // - Check that the ICE files contain some of the expected strings. // See https://github.com/rust-lang/rust/pull/108714 -// FIXME(Oneirical): try it on Windows! - -use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files}; +use run_make_support::{cwd, has_extension, has_prefix, rfs, rustc, shallow_find_files}; fn main() { rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); - let ice_text = get_text_from_ice(); + let default = get_text_from_ice(".").lines().count(); + clear_ice_files(); + + rustc().env("RUSTC_ICE", cwd()).input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); + let ice_text = get_text_from_ice(cwd()); let default_set = ice_text.lines().count(); let content = ice_text; - // Ensure that the ICE files don't contain `:` in their filename because - // this causes problems on Windows. - for file in shallow_find_files(cwd(), |path| { + let ice_files = shallow_find_files(cwd(), |path| { has_prefix(path, "rustc-ice") && has_extension(path, "txt") - }) { - assert!(!file.display().to_string().contains(":")); - } + }); + assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file. + let ice_file_name = + ice_files.first().and_then(|f| f.file_name()).and_then(|n| n.to_str()).unwrap(); + // Ensure that the ICE dump path doesn't contain `:`, because they cause problems on Windows. + assert!(!ice_file_name.contains(":"), "{ice_file_name}"); clear_ice_files(); - rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail(); - let short = get_text_from_ice().lines().count(); + rustc() + .env("RUSTC_ICE", cwd()) + .input("lib.rs") + .env("RUST_BACKTRACE", "short") + .arg("-Ztreat-err-as-bug=1") + .run_fail(); + let short = get_text_from_ice(cwd()).lines().count(); clear_ice_files(); - rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail(); - let full = get_text_from_ice().lines().count(); + rustc() + .env("RUSTC_ICE", cwd()) + .input("lib.rs") + .env("RUST_BACKTRACE", "full") + .arg("-Ztreat-err-as-bug=1") + .run_fail(); + let full = get_text_from_ice(cwd()).lines().count(); clear_ice_files(); - // The ICE dump is explicitely disabled. Therefore, this should produce no files. + // The ICE dump is explicitly disabled. Therefore, this should produce no files. rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); - assert!(get_text_from_ice().is_empty()); + let ice_files = shallow_find_files(cwd(), |path| { + has_prefix(path, "rustc-ice") && has_extension(path, "txt") + }); + assert!(ice_files.is_empty()); // There should be 0 ICE files. // The line count should not change. assert_eq!(short, default_set); + assert_eq!(short, default); assert_eq!(full, default_set); + assert!(default > 0); // Some of the expected strings in an ICE file should appear. assert!(content.contains("thread 'rustc' panicked at")); assert!(content.contains("stack backtrace:")); @@ -48,17 +66,16 @@ fn clear_ice_files() { has_prefix(path, "rustc-ice") && has_extension(path, "txt") }); for file in ice_files { - fs_wrapper::remove_file(file); + rfs::remove_file(file); } } -fn get_text_from_ice() -> String { - let ice_files = shallow_find_files(cwd(), |path| { - has_prefix(path, "rustc-ice") && has_extension(path, "txt") - }); - let mut output = String::new(); - for file in ice_files { - output.push_str(&fs_wrapper::read_to_string(file)); - } +#[track_caller] +fn get_text_from_ice(dir: impl AsRef) -> String { + let ice_files = + shallow_find_files(dir, |path| has_prefix(path, "rustc-ice") && has_extension(path, "txt")); + assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file. + let ice_file = ice_files.get(0).unwrap(); + let output = rfs::read_to_string(ice_file); output } diff --git a/tests/run-make/panic-abort-eh_frame/Makefile b/tests/run-make/panic-abort-eh_frame/Makefile deleted file mode 100644 index 7020455b742d0..0000000000000 --- a/tests/run-make/panic-abort-eh_frame/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# only-linux -# -# This test ensures that `panic=abort` code (without `C-unwind`, that is) should not have any -# unwinding related `.eh_frame` sections emitted. - -include ../tools.mk - -all: - $(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort --edition 2021 -Z validate-mir - objdump --dwarf=frames $(TMPDIR)/foo.o | $(CGREP) -v 'DW_CFA' diff --git a/tests/run-make/panic-abort-eh_frame/rmake.rs b/tests/run-make/panic-abort-eh_frame/rmake.rs new file mode 100644 index 0000000000000..6bcf718235675 --- /dev/null +++ b/tests/run-make/panic-abort-eh_frame/rmake.rs @@ -0,0 +1,20 @@ +// An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate +// being inserted, useful for determining whether or not unwinding is necessary. +// This is useless when panics would NEVER unwind due to -C panic=abort. This section should +// therefore never appear in the emit file of a -C panic=abort compilation, and this test +// checks that this is respected. +// See https://github.com/rust-lang/rust/pull/112403 + +use run_make_support::{llvm_objdump, rustc}; + +fn main() { + rustc() + .input("foo.rs") + .crate_type("lib") + .emit("obj=foo.o") + .panic("abort") + .edition("2021") + .arg("-Zvalidate-mir") + .run(); + llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA"); +} From a9e14668d62b294d8394b7aae08cf552ba2d684e Mon Sep 17 00:00:00 2001 From: Jerry Wang Date: Mon, 15 Jul 2024 19:42:45 -0400 Subject: [PATCH 08/13] Add `llvm_components_contain` to `run-make-support` --- src/tools/run-make-support/src/lib.rs | 2 +- src/tools/run-make-support/src/targets.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index b15705e896582..e6a45f57de608 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -61,7 +61,7 @@ pub use env::{env_var, env_var_os}; pub use run::{cmd, run, run_fail, run_with_args}; /// Helpers for checking target information. -pub use targets::{is_darwin, is_msvc, is_windows, target, uname}; +pub use targets::{is_darwin, is_msvc, is_windows, llvm_components_contain, target, uname}; /// Helpers for building names of output artifacts that are potentially target-specific. pub use artifact_names::{ diff --git a/src/tools/run-make-support/src/targets.rs b/src/tools/run-make-support/src/targets.rs index 42d4a45680d16..5dcb0b83430f9 100644 --- a/src/tools/run-make-support/src/targets.rs +++ b/src/tools/run-make-support/src/targets.rs @@ -28,6 +28,13 @@ pub fn is_darwin() -> bool { target().contains("darwin") } +/// Check if `component` is within `LLVM_COMPONENTS` +#[must_use] +pub fn llvm_components_contain(component: &str) -> bool { + // `LLVM_COMPONENTS` is a space-separated list of words + env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some() +} + /// Run `uname`. This assumes that `uname` is available on the platform! #[track_caller] #[must_use] From a8b6e3f5c9a9addf320f34e33422043ac682aa91 Mon Sep 17 00:00:00 2001 From: Jerry Wang Date: Mon, 15 Jul 2024 19:43:13 -0400 Subject: [PATCH 09/13] Migrate `atomic-lock-free` to `rmake` --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/atomic-lock-free/Makefile | 48 ----------------- tests/run-make/atomic-lock-free/rmake.rs | 52 +++++++++++++++++++ 3 files changed, 52 insertions(+), 49 deletions(-) delete mode 100644 tests/run-make/atomic-lock-free/Makefile create mode 100644 tests/run-make/atomic-lock-free/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2e26f9344b899..f33cde110a5c4 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -1,5 +1,4 @@ run-make/archive-duplicate-names/Makefile -run-make/atomic-lock-free/Makefile run-make/branch-protection-check-IBT/Makefile run-make/c-dynamic-dylib/Makefile run-make/c-dynamic-rlib/Makefile diff --git a/tests/run-make/atomic-lock-free/Makefile b/tests/run-make/atomic-lock-free/Makefile deleted file mode 100644 index 37e59624a2541..0000000000000 --- a/tests/run-make/atomic-lock-free/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -include ../tools.mk - -# This tests ensure that atomic types are never lowered into runtime library calls that are not -# guaranteed to be lock-free. - -all: -ifeq ($(UNAME),Linux) -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) - $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) - $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=thumbv7neon-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64) - $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) - $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc) - $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) - $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -endif diff --git a/tests/run-make/atomic-lock-free/rmake.rs b/tests/run-make/atomic-lock-free/rmake.rs new file mode 100644 index 0000000000000..77e136e8487f3 --- /dev/null +++ b/tests/run-make/atomic-lock-free/rmake.rs @@ -0,0 +1,52 @@ +// This tests ensure that atomic types are never lowered into runtime library calls that are not +// guaranteed to be lock-free. + +//@ only-linux + +use run_make_support::{llvm_components_contain, llvm_readobj, rustc}; + +fn compile(target: &str) { + rustc().input("atomic_lock_free.rs").target(target).run(); +} + +fn check() { + llvm_readobj() + .symbols() + .input("libatomic_lock_free.rlib") + .run() + .assert_stdout_not_contains("__atomic_fetch_add"); +} + +fn compile_and_check(target: &str) { + compile(target); + check(); +} + +fn main() { + if llvm_components_contain("x86") { + compile_and_check("i686-unknown-linux-gnu"); + compile_and_check("x86_64-unknown-linux-gnu"); + } + if llvm_components_contain("arm") { + compile_and_check("arm-unknown-linux-gnueabi"); + compile_and_check("arm-unknown-linux-gnueabihf"); + compile_and_check("armv7-unknown-linux-gnueabihf"); + compile_and_check("thumbv7neon-unknown-linux-gnueabihf"); + } + if llvm_components_contain("aarch64") { + compile_and_check("aarch64-unknown-linux-gnu"); + } + if llvm_components_contain("mips") { + compile_and_check("mips-unknown-linux-gnu"); + compile_and_check("mipsel-unknown-linux-gnu"); + } + if llvm_components_contain("powerpc") { + compile_and_check("powerpc-unknown-linux-gnu"); + compile_and_check("powerpc-unknown-linux-gnuspe"); + compile_and_check("powerpc64-unknown-linux-gnu"); + compile_and_check("powerpc64le-unknown-linux-gnu"); + } + if llvm_components_contain("systemz") { + compile_and_check("s390x-unknown-linux-gnu"); + } +} From e38032fb3ad5736934ea1ff1ecc43e8af4c47a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 9 Jul 2024 22:11:20 +0000 Subject: [PATCH 10/13] Fix associated item removal suggestion We were previously telling people to write what was already there, instead of removal. ``` error[E0229]: associated item constraints are not allowed here --> $DIR/E0229.rs:13:25 | LL | fn baz(x: &>::A) {} | ^^^^^^^ associated item constraint not allowed here | help: consider removing this associated item binding | LL - fn baz(x: &>::A) {} LL + fn baz(x: &::A) {} | ``` --- .../src/hir_ty_lowering/errors.rs | 14 +++---- .../ice-unresolved-import-100241.stderr | 11 +++++ .../invalid_associated_const.stderr | 10 +++-- tests/rustdoc-ui/issue-102467.stderr | 10 +++-- .../issue-102335-const.stderr | 10 +++-- .../issue-102335-ty.stderr | 20 ++++++---- .../no-gat-position.stderr | 5 ++- .../associated-types-eq-2.stderr | 40 +++++++++++-------- .../rtn-in-impl-signature.stderr | 5 ++- tests/ui/error-codes/E0229.stderr | 15 ++++--- .../issue-102335-gat.stderr | 10 +++-- ...lid-associated-type-supertrait-hrtb.stderr | 5 ++- tests/ui/suggestions/issue-85347.stderr | 10 +++-- 13 files changed, 101 insertions(+), 64 deletions(-) create mode 100644 tests/rustdoc-ui/ice-unresolved-import-100241.stderr diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 5e595488ea7a8..cd0451b41656b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -1257,14 +1257,12 @@ pub fn prohibit_assoc_item_constraint( }; // Now emit the suggestion - if let Ok(suggestion) = tcx.sess.source_map().span_to_snippet(removal_span) { - e.span_suggestion_verbose( - removal_span, - format!("consider removing this associated item {}", constraint.kind.descr()), - suggestion, - Applicability::MaybeIncorrect, - ); - } + e.span_suggestion_verbose( + removal_span, + format!("consider removing this associated item {}", constraint.kind.descr()), + "", + Applicability::MaybeIncorrect, + ); }; // Suggest replacing the associated item binding with a generic argument. diff --git a/tests/rustdoc-ui/ice-unresolved-import-100241.stderr b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr new file mode 100644 index 0000000000000..57fbbb59c8d41 --- /dev/null +++ b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `inner` + --> $DIR/ice-unresolved-import-100241.rs:9:13 + | +LL | pub use inner::S; + | ^^^^^ maybe a missing crate `inner`? + | + = help: consider adding `extern crate inner` to use the `inner` crate + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/rustdoc-ui/invalid_associated_const.stderr b/tests/rustdoc-ui/invalid_associated_const.stderr index 6e5ddc449828c..66f8ffe6d7298 100644 --- a/tests/rustdoc-ui/invalid_associated_const.stderr +++ b/tests/rustdoc-ui/invalid_associated_const.stderr @@ -6,8 +6,9 @@ LL | type A: S = 34>; | help: consider removing this associated item binding | -LL | type A: S = 34>; - | ~~~~~~~~~~ +LL - type A: S = 34>; +LL + type A: S; + | error[E0229]: associated item constraints are not allowed here --> $DIR/invalid_associated_const.rs:4:17 @@ -18,8 +19,9 @@ LL | type A: S = 34>; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type A: S = 34>; - | ~~~~~~~~~~ +LL - type A: S = 34>; +LL + type A: S; + | error: aborting due to 2 previous errors diff --git a/tests/rustdoc-ui/issue-102467.stderr b/tests/rustdoc-ui/issue-102467.stderr index 99f911023192c..5fcdba782e7eb 100644 --- a/tests/rustdoc-ui/issue-102467.stderr +++ b/tests/rustdoc-ui/issue-102467.stderr @@ -6,8 +6,9 @@ LL | type A: S = 34>; | help: consider removing this associated item binding | -LL | type A: S = 34>; - | ~~~~~~~~~~ +LL - type A: S = 34>; +LL + type A: S; + | error[E0229]: associated item constraints are not allowed here --> $DIR/issue-102467.rs:7:17 @@ -18,8 +19,9 @@ LL | type A: S = 34>; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type A: S = 34>; - | ~~~~~~~~~~ +LL - type A: S = 34>; +LL + type A: S; + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-consts/issue-102335-const.stderr b/tests/ui/associated-consts/issue-102335-const.stderr index dc1631220e2a9..cf96c8cf8eb9d 100644 --- a/tests/ui/associated-consts/issue-102335-const.stderr +++ b/tests/ui/associated-consts/issue-102335-const.stderr @@ -6,8 +6,9 @@ LL | type A: S = 34>; | help: consider removing this associated item binding | -LL | type A: S = 34>; - | ~~~~~~~~~~ +LL - type A: S = 34>; +LL + type A: S; + | error[E0229]: associated item constraints are not allowed here --> $DIR/issue-102335-const.rs:4:17 @@ -18,8 +19,9 @@ LL | type A: S = 34>; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type A: S = 34>; - | ~~~~~~~~~~ +LL - type A: S = 34>; +LL + type A: S; + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-type-bounds/issue-102335-ty.stderr b/tests/ui/associated-type-bounds/issue-102335-ty.stderr index cd585f7f7d8f5..259b0ca00e1b3 100644 --- a/tests/ui/associated-type-bounds/issue-102335-ty.stderr +++ b/tests/ui/associated-type-bounds/issue-102335-ty.stderr @@ -6,8 +6,9 @@ LL | type A: S = ()>; // Just one erroneous equality constraint | help: consider removing this associated item binding | -LL | type A: S = ()>; // Just one erroneous equality constraint - | ~~~~~~~~~~~ +LL - type A: S = ()>; // Just one erroneous equality constraint +LL + type A: S; // Just one erroneous equality constraint + | error[E0229]: associated item constraints are not allowed here --> $DIR/issue-102335-ty.rs:2:17 @@ -18,8 +19,9 @@ LL | type A: S = ()>; // Just one erroneous equality constraint = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type A: S = ()>; // Just one erroneous equality constraint - | ~~~~~~~~~~~ +LL - type A: S = ()>; // Just one erroneous equality constraint +LL + type A: S; // Just one erroneous equality constraint + | error[E0229]: associated item constraints are not allowed here --> $DIR/issue-102335-ty.rs:8:17 @@ -29,8 +31,9 @@ LL | type A: S = ()>; // More than one erroneous equal | help: consider removing this associated item binding | -LL | type A: S = ()>; // More than one erroneous equality constraints - | ~~~~~~~~~~ +LL - type A: S = ()>; // More than one erroneous equality constraints +LL + type A: S = ()>; // More than one erroneous equality constraints + | error[E0229]: associated item constraints are not allowed here --> $DIR/issue-102335-ty.rs:8:17 @@ -41,8 +44,9 @@ LL | type A: S = ()>; // More than one erroneous equal = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type A: S = ()>; // More than one erroneous equality constraints - | ~~~~~~~~~~ +LL - type A: S = ()>; // More than one erroneous equality constraints +LL + type A: S = ()>; // More than one erroneous equality constraints + | error: aborting due to 4 previous errors diff --git a/tests/ui/associated-type-bounds/no-gat-position.stderr b/tests/ui/associated-type-bounds/no-gat-position.stderr index 39a2f89f9acf0..03dc752c5330e 100644 --- a/tests/ui/associated-type-bounds/no-gat-position.stderr +++ b/tests/ui/associated-type-bounds/no-gat-position.stderr @@ -6,8 +6,9 @@ LL | fn next<'a>(&'a mut self) -> Option>; | help: consider removing this associated item constraint | -LL | fn next<'a>(&'a mut self) -> Option>; - | ~~~~~~~~~~~ +LL - fn next<'a>(&'a mut self) -> Option>; +LL + fn next<'a>(&'a mut self) -> Option>; + | error: aborting due to 1 previous error diff --git a/tests/ui/associated-types/associated-types-eq-2.stderr b/tests/ui/associated-types/associated-types-eq-2.stderr index 69b1b533450c7..e5013a35d453b 100644 --- a/tests/ui/associated-types/associated-types-eq-2.stderr +++ b/tests/ui/associated-types/associated-types-eq-2.stderr @@ -50,8 +50,9 @@ LL | impl Tr1 for usize { | help: consider removing this associated item binding | -LL | impl Tr1 for usize { - | ~~~~~~~~~~~ +LL - impl Tr1 for usize { +LL + impl Tr1 for usize { + | error[E0046]: not all trait items implemented, missing: `A` --> $DIR/associated-types-eq-2.rs:20:1 @@ -70,8 +71,9 @@ LL | fn baz(_x: &>::A) {} | help: consider removing this associated item binding | -LL | fn baz(_x: &>::A) {} - | ~~~~~~~ +LL - fn baz(_x: &>::A) {} +LL + fn baz(_x: &::A) {} + | error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied --> $DIR/associated-types-eq-2.rs:40:6 @@ -128,8 +130,9 @@ LL | impl Tr2 for Qux { | help: consider removing this associated item binding | -LL | impl Tr2 for Qux { - | ~~~~~~~~~~ +LL - impl Tr2 for Qux { +LL + impl Tr2 for Qux { + | error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied --> $DIR/associated-types-eq-2.rs:54:6 @@ -157,8 +160,9 @@ LL | impl Tr2 for Bar { | help: consider removing this associated item binding | -LL | impl Tr2 for Bar { - | ~~~~~~~~~ +LL - impl Tr2 for Bar { +LL + impl Tr2 for Bar { + | error[E0107]: trait takes 3 generic arguments but 2 generic arguments were supplied --> $DIR/associated-types-eq-2.rs:61:6 @@ -228,8 +232,9 @@ LL | impl Tr3 for Qux { | help: consider removing this associated item binding | -LL | impl Tr3 for Qux { - | ~~~~~~~ +LL - impl Tr3 for Qux { +LL + impl Tr3 for Qux { + | error[E0229]: associated item constraints are not allowed here --> $DIR/associated-types-eq-2.rs:92:10 @@ -239,8 +244,9 @@ LL | impl Tr3 for Bar { | help: consider removing this associated item binding | -LL | impl Tr3 for Bar { - | ~~~~~~~~ +LL - impl Tr3 for Bar { +LL + impl Tr3 for Bar { + | error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied --> $DIR/associated-types-eq-2.rs:98:6 @@ -268,8 +274,9 @@ LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar { | help: consider removing this associated item binding | -LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar { - | ~~~~~~~~~ +LL - impl Tr3<42, T2 = 42, T3 = usize> for Bar { +LL + impl Tr3<42, T3 = usize> for Bar { + | error[E0107]: trait takes 3 generic arguments but 0 generic arguments were supplied --> $DIR/associated-types-eq-2.rs:106:6 @@ -295,8 +302,9 @@ LL | impl Tr3 for Bar { | help: consider removing this associated item binding | -LL | impl Tr3 for Bar { - | ~~~~~~~ +LL - impl Tr3 for Bar { +LL + impl Tr3 for Bar { + | error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied --> $DIR/associated-types-eq-2.rs:117:13 diff --git a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr index b23dbc37a55cc..e061587f49189 100644 --- a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr +++ b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr @@ -15,8 +15,9 @@ LL | impl Super1<'_, bar(..): Send> for () {} | help: consider removing this associated item constraint | -LL | impl Super1<'_, bar(..): Send> for () {} - | ~~~~~~~~~~~~~~~ +LL - impl Super1<'_, bar(..): Send> for () {} +LL + impl Super1<'_> for () {} + | error[E0046]: not all trait items implemented, missing: `bar` --> $DIR/rtn-in-impl-signature.rs:10:1 diff --git a/tests/ui/error-codes/E0229.stderr b/tests/ui/error-codes/E0229.stderr index 7d9cedc3bdc4f..038f44e8b14f0 100644 --- a/tests/ui/error-codes/E0229.stderr +++ b/tests/ui/error-codes/E0229.stderr @@ -6,8 +6,9 @@ LL | fn baz(x: &>::A) {} | help: consider removing this associated item binding | -LL | fn baz(x: &>::A) {} - | ~~~~~~~~~ +LL - fn baz(x: &>::A) {} +LL + fn baz(x: &::A) {} + | error[E0229]: associated item constraints are not allowed here --> $DIR/E0229.rs:13:25 @@ -18,8 +19,9 @@ LL | fn baz(x: &>::A) {} = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | fn baz(x: &>::A) {} - | ~~~~~~~~~ +LL - fn baz(x: &>::A) {} +LL + fn baz(x: &::A) {} + | error[E0229]: associated item constraints are not allowed here --> $DIR/E0229.rs:13:25 @@ -30,8 +32,9 @@ LL | fn baz(x: &>::A) {} = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | fn baz(x: &>::A) {} - | ~~~~~~~~~ +LL - fn baz(x: &>::A) {} +LL + fn baz(x: &::A) {} + | error[E0277]: the trait bound `I: Foo` is not satisfied --> $DIR/E0229.rs:13:15 diff --git a/tests/ui/generic-associated-types/issue-102335-gat.stderr b/tests/ui/generic-associated-types/issue-102335-gat.stderr index b4772486e6e45..bcef76290fcdc 100644 --- a/tests/ui/generic-associated-types/issue-102335-gat.stderr +++ b/tests/ui/generic-associated-types/issue-102335-gat.stderr @@ -6,8 +6,9 @@ LL | type A: S = ()>; | help: consider removing this associated item binding | -LL | type A: S = ()>; - | ~~~~~~~~~~ +LL - type A: S = ()>; +LL + type A: S = ()>; + | error[E0229]: associated item constraints are not allowed here --> $DIR/issue-102335-gat.rs:2:21 @@ -18,8 +19,9 @@ LL | type A: S = ()>; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type A: S = ()>; - | ~~~~~~~~~~ +LL - type A: S = ()>; +LL + type A: S = ()>; + | error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes/issue-83753-invalid-associated-type-supertrait-hrtb.stderr b/tests/ui/lifetimes/issue-83753-invalid-associated-type-supertrait-hrtb.stderr index f8d919fd68b68..4ea14cdf042f3 100644 --- a/tests/ui/lifetimes/issue-83753-invalid-associated-type-supertrait-hrtb.stderr +++ b/tests/ui/lifetimes/issue-83753-invalid-associated-type-supertrait-hrtb.stderr @@ -6,8 +6,9 @@ LL | fn bar(foo: Foo) {} | help: consider removing this associated item binding | -LL | fn bar(foo: Foo) {} - | ~~~~~~~~~~~~~~~~ +LL - fn bar(foo: Foo) {} +LL + fn bar(foo: Foo) {} + | error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-85347.stderr b/tests/ui/suggestions/issue-85347.stderr index b3616041c4cd9..af77ddd35e32f 100644 --- a/tests/ui/suggestions/issue-85347.stderr +++ b/tests/ui/suggestions/issue-85347.stderr @@ -22,8 +22,9 @@ LL | type Bar<'a>: Deref::Bar>; | help: consider removing this associated item binding | -LL | type Bar<'a>: Deref::Bar>; - | ~~~~~~~~~~~~~~~ +LL - type Bar<'a>: Deref::Bar>; +LL + type Bar<'a>: Deref::Bar>; + | error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied --> $DIR/issue-85347.rs:3:42 @@ -51,8 +52,9 @@ LL | type Bar<'a>: Deref::Bar>; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider removing this associated item binding | -LL | type Bar<'a>: Deref::Bar>; - | ~~~~~~~~~~~~~~~ +LL - type Bar<'a>: Deref::Bar>; +LL + type Bar<'a>: Deref::Bar>; + | error: aborting due to 4 previous errors From 8eb51852a87dd2640fbd95019ff1124b38ae8b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 10 Jul 2024 01:49:11 +0000 Subject: [PATCH 11/13] Accurate `use` rename suggestion span When suggesting to rename an import with `as`, use a smaller span to render the suggestion with a better format: ``` error[E0252]: the name `baz` is defined multiple times --> $DIR/issue-25396.rs:4:5 | LL | use foo::baz; | -------- previous import of the module `baz` here LL | use bar::baz; | ^^^^^^^^ `baz` reimported here | = note: `baz` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; | ++++++++++++ ``` --- compiler/rustc_resolve/src/diagnostics.rs | 18 ++++++++++-------- .../ice-unresolved-import-100241.stderr | 11 +++++++++++ .../blind/blind-item-block-item-shadow.stderr | 2 +- tests/ui/blind/blind-item-item-shadow.stderr | 2 +- .../duplicate-check-macro-exports.stderr | 2 +- tests/ui/error-codes/E0252.stderr | 2 +- tests/ui/error-codes/E0254.stderr | 2 +- tests/ui/error-codes/E0255.stderr | 2 +- tests/ui/imports/double-import.stderr | 2 +- tests/ui/imports/issue-19498.stderr | 6 +++--- tests/ui/imports/issue-24081.stderr | 10 +++++----- tests/ui/imports/issue-25396.stderr | 8 ++++---- .../issue-32354-suggest-import-rename.stderr | 2 +- .../ui/imports/issue-45829/import-self.stderr | 2 +- .../ui/imports/issue-45829/issue-45829.stderr | 2 +- .../issue-45829/rename-use-vs-extern.stderr | 2 +- .../issue-45829/rename-use-with-tabs.stderr | 2 +- .../issue-45829/rename-with-path.stderr | 2 +- tests/ui/imports/issue-45829/rename.stderr | 2 +- tests/ui/imports/issue-52891.stderr | 2 +- tests/ui/imports/issue-8640.stderr | 2 +- ...olve-conflict-import-vs-extern-crate.stderr | 2 +- .../resolve-conflict-item-vs-import.stderr | 2 +- .../resolve-conflict-type-vs-import.stderr | 2 +- tests/ui/variants/variant-namespacing.stderr | 12 ++++++------ 25 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 tests/rustdoc-ui/ice-unresolved-import-100241.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index e3917acce65b5..566223f98bfdb 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -371,6 +371,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }; let mut suggestion = None; + let mut span = binding_span; match import.kind { ImportKind::Single { type_ns_only: true, .. } => { suggestion = Some(format!("self as {suggested_name}")) @@ -381,12 +382,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(binding_span) { if pos <= snippet.len() { - suggestion = Some(format!( - "{} as {}{}", - &snippet[..pos], - suggested_name, - if snippet.ends_with(';') { ";" } else { "" } - )) + span = binding_span + .with_lo(binding_span.lo() + BytePos(pos as u32)) + .with_hi( + binding_span.hi() + - BytePos(if snippet.ends_with(';') { 1 } else { 0 }), + ); + suggestion = Some(format!(" as {suggested_name}")); } } } @@ -402,9 +404,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } if let Some(suggestion) = suggestion { - err.subdiagnostic(ChangeImportBindingSuggestion { span: binding_span, suggestion }); + err.subdiagnostic(ChangeImportBindingSuggestion { span, suggestion }); } else { - err.subdiagnostic(ChangeImportBinding { span: binding_span }); + err.subdiagnostic(ChangeImportBinding { span }); } } diff --git a/tests/rustdoc-ui/ice-unresolved-import-100241.stderr b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr new file mode 100644 index 0000000000000..57fbbb59c8d41 --- /dev/null +++ b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `inner` + --> $DIR/ice-unresolved-import-100241.rs:9:13 + | +LL | pub use inner::S; + | ^^^^^ maybe a missing crate `inner`? + | + = help: consider adding `extern crate inner` to use the `inner` crate + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/blind/blind-item-block-item-shadow.stderr b/tests/ui/blind/blind-item-block-item-shadow.stderr index 2e24ef453c2e4..38e3087ca3461 100644 --- a/tests/ui/blind/blind-item-block-item-shadow.stderr +++ b/tests/ui/blind/blind-item-block-item-shadow.stderr @@ -10,7 +10,7 @@ LL | use foo::Bar; help: you can use `as` to change the binding name of the import | LL | use foo::Bar as OtherBar; - | ~~~~~~~~~~~~~~~~~~~~ + | +++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/blind/blind-item-item-shadow.stderr b/tests/ui/blind/blind-item-item-shadow.stderr index 84b273c7338b1..08f5f5b47ed49 100644 --- a/tests/ui/blind/blind-item-item-shadow.stderr +++ b/tests/ui/blind/blind-item-item-shadow.stderr @@ -11,7 +11,7 @@ LL | use foo::foo; help: you can use `as` to change the binding name of the import | LL | use foo::foo as other_foo; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/duplicate/duplicate-check-macro-exports.stderr b/tests/ui/duplicate/duplicate-check-macro-exports.stderr index eff19c09062f0..470a516ecbc52 100644 --- a/tests/ui/duplicate/duplicate-check-macro-exports.stderr +++ b/tests/ui/duplicate/duplicate-check-macro-exports.stderr @@ -11,7 +11,7 @@ LL | macro_rules! panic { () => {} } help: you can use `as` to change the binding name of the import | LL | pub use std::panic as other_panic; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0252.stderr b/tests/ui/error-codes/E0252.stderr index efbb9ec96dee6..16574964eb33e 100644 --- a/tests/ui/error-codes/E0252.stderr +++ b/tests/ui/error-codes/E0252.stderr @@ -10,7 +10,7 @@ LL | use bar::baz; help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0254.stderr b/tests/ui/error-codes/E0254.stderr index d89497b2804bf..592b8766d6bd8 100644 --- a/tests/ui/error-codes/E0254.stderr +++ b/tests/ui/error-codes/E0254.stderr @@ -11,7 +11,7 @@ LL | use foo::alloc; help: you can use `as` to change the binding name of the import | LL | use foo::alloc as other_alloc; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0255.stderr b/tests/ui/error-codes/E0255.stderr index e5f908217e138..b67a334f02c4c 100644 --- a/tests/ui/error-codes/E0255.stderr +++ b/tests/ui/error-codes/E0255.stderr @@ -11,7 +11,7 @@ LL | fn foo() {} help: you can use `as` to change the binding name of the import | LL | use bar::foo as other_foo; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/double-import.stderr b/tests/ui/imports/double-import.stderr index 73bb73e349066..15b8620909f82 100644 --- a/tests/ui/imports/double-import.stderr +++ b/tests/ui/imports/double-import.stderr @@ -10,7 +10,7 @@ LL | use sub2::foo; help: you can use `as` to change the binding name of the import | LL | use sub2::foo as other_foo; - | ~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-19498.stderr b/tests/ui/imports/issue-19498.stderr index 9d26022098fdd..69bdb67d3898b 100644 --- a/tests/ui/imports/issue-19498.stderr +++ b/tests/ui/imports/issue-19498.stderr @@ -11,7 +11,7 @@ LL | mod A {} help: you can use `as` to change the binding name of the import | LL | use self::A as OtherA; - | ~~~~~~~~~~~~~~~~~ + | +++++++++ error[E0255]: the name `B` is defined multiple times --> $DIR/issue-19498.rs:5:1 @@ -26,7 +26,7 @@ LL | pub mod B {} help: you can use `as` to change the binding name of the import | LL | use self::B as OtherB; - | ~~~~~~~~~~~~~~~~~ + | +++++++++ error[E0255]: the name `D` is defined multiple times --> $DIR/issue-19498.rs:9:5 @@ -40,7 +40,7 @@ LL | mod D {} help: you can use `as` to change the binding name of the import | LL | use C::D as OtherD; - | ~~~~~~~~~~~~~~ + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/imports/issue-24081.stderr b/tests/ui/imports/issue-24081.stderr index e5ed6b10a5479..6ceba6c7013ac 100644 --- a/tests/ui/imports/issue-24081.stderr +++ b/tests/ui/imports/issue-24081.stderr @@ -11,7 +11,7 @@ LL | type Add = bool; help: you can use `as` to change the binding name of the import | LL | use std::ops::Add as OtherAdd; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++ error[E0255]: the name `Sub` is defined multiple times --> $DIR/issue-24081.rs:9:1 @@ -26,7 +26,7 @@ LL | struct Sub { x: f32 } help: you can use `as` to change the binding name of the import | LL | use std::ops::Sub as OtherSub; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++ error[E0255]: the name `Mul` is defined multiple times --> $DIR/issue-24081.rs:11:1 @@ -41,7 +41,7 @@ LL | enum Mul { A, B } help: you can use `as` to change the binding name of the import | LL | use std::ops::Mul as OtherMul; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++ error[E0255]: the name `Div` is defined multiple times --> $DIR/issue-24081.rs:13:1 @@ -56,7 +56,7 @@ LL | mod Div { } help: you can use `as` to change the binding name of the import | LL | use std::ops::Div as OtherDiv; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++ error[E0255]: the name `Rem` is defined multiple times --> $DIR/issue-24081.rs:15:1 @@ -71,7 +71,7 @@ LL | trait Rem { } help: you can use `as` to change the binding name of the import | LL | use std::ops::Rem as OtherRem; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++ error: aborting due to 5 previous errors diff --git a/tests/ui/imports/issue-25396.stderr b/tests/ui/imports/issue-25396.stderr index 518d2be784111..6f9b080f3c509 100644 --- a/tests/ui/imports/issue-25396.stderr +++ b/tests/ui/imports/issue-25396.stderr @@ -10,7 +10,7 @@ LL | use bar::baz; help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error[E0252]: the name `Quux` is defined multiple times --> $DIR/issue-25396.rs:7:5 @@ -24,7 +24,7 @@ LL | use bar::Quux; help: you can use `as` to change the binding name of the import | LL | use bar::Quux as OtherQuux; - | ~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error[E0252]: the name `blah` is defined multiple times --> $DIR/issue-25396.rs:10:5 @@ -38,7 +38,7 @@ LL | use bar::blah; help: you can use `as` to change the binding name of the import | LL | use bar::blah as other_blah; - | ~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++++ error[E0252]: the name `WOMP` is defined multiple times --> $DIR/issue-25396.rs:13:5 @@ -52,7 +52,7 @@ LL | use bar::WOMP; help: you can use `as` to change the binding name of the import | LL | use bar::WOMP as OtherWOMP; - | ~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/imports/issue-32354-suggest-import-rename.stderr b/tests/ui/imports/issue-32354-suggest-import-rename.stderr index de9bdc4f2cc85..753fa434ffba9 100644 --- a/tests/ui/imports/issue-32354-suggest-import-rename.stderr +++ b/tests/ui/imports/issue-32354-suggest-import-rename.stderr @@ -10,7 +10,7 @@ LL | use extension2::ConstructorExtension; help: you can use `as` to change the binding name of the import | LL | use extension2::ConstructorExtension as OtherConstructorExtension; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/import-self.stderr b/tests/ui/imports/issue-45829/import-self.stderr index 0c9424f308351..3c9d4fe6ba6fb 100644 --- a/tests/ui/imports/issue-45829/import-self.stderr +++ b/tests/ui/imports/issue-45829/import-self.stderr @@ -48,7 +48,7 @@ LL | use foo::self; help: you can use `as` to change the binding name of the import | LL | use foo as other_foo; - | ~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ error[E0252]: the name `A` is defined multiple times --> $DIR/import-self.rs:16:11 diff --git a/tests/ui/imports/issue-45829/issue-45829.stderr b/tests/ui/imports/issue-45829/issue-45829.stderr index 627a09a07b860..c6835c3bd7aaa 100644 --- a/tests/ui/imports/issue-45829/issue-45829.stderr +++ b/tests/ui/imports/issue-45829/issue-45829.stderr @@ -10,7 +10,7 @@ LL | use foo::{A, B as A}; help: you can use `as` to change the binding name of the import | LL | use foo::{A, B as OtherA}; - | ~~~~~~~~~~~ + | ~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr b/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr index 9b0a2534a1d1f..fd4fb9db0b6d7 100644 --- a/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr +++ b/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr @@ -10,7 +10,7 @@ LL | use std as issue_45829_b; help: you can use `as` to change the binding name of the import | LL | use std as other_issue_45829_b; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr b/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr index 5751f41ae9d12..178303bbc1d16 100644 --- a/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr +++ b/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr @@ -10,7 +10,7 @@ LL | use foo::{A, bar::B as A}; help: you can use `as` to change the binding name of the import | LL | use foo::{A, bar::B as OtherA}; - | ~~~~~~~~~~~~~~~~ + | ~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-with-path.stderr b/tests/ui/imports/issue-45829/rename-with-path.stderr index 69e084db6ffc1..a83fdb3732436 100644 --- a/tests/ui/imports/issue-45829/rename-with-path.stderr +++ b/tests/ui/imports/issue-45829/rename-with-path.stderr @@ -10,7 +10,7 @@ LL | use std::{collections::HashMap as A, sync::Arc as A}; help: you can use `as` to change the binding name of the import | LL | use std::{collections::HashMap as A, sync::Arc as OtherA}; - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename.stderr b/tests/ui/imports/issue-45829/rename.stderr index f1ee5112dc164..4977909487cfb 100644 --- a/tests/ui/imports/issue-45829/rename.stderr +++ b/tests/ui/imports/issue-45829/rename.stderr @@ -10,7 +10,7 @@ LL | use std as core; help: you can use `as` to change the binding name of the import | LL | use std as other_core; - | ~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-52891.stderr b/tests/ui/imports/issue-52891.stderr index 7bb1301edf264..730962d702a06 100644 --- a/tests/ui/imports/issue-52891.stderr +++ b/tests/ui/imports/issue-52891.stderr @@ -98,7 +98,7 @@ LL | use issue_52891::b::inner; help: you can use `as` to change the binding name of the import | LL | use issue_52891::b::inner as other_inner; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++ error[E0254]: the name `issue_52891` is defined multiple times --> $DIR/issue-52891.rs:31:19 diff --git a/tests/ui/imports/issue-8640.stderr b/tests/ui/imports/issue-8640.stderr index ea350e97e6420..d22fddb1a69e5 100644 --- a/tests/ui/imports/issue-8640.stderr +++ b/tests/ui/imports/issue-8640.stderr @@ -10,7 +10,7 @@ LL | mod bar {} help: you can use `as` to change the binding name of the import | LL | use baz::bar as other_bar; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr index e22e636adb6b5..a8d0efedb6c42 100644 --- a/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr +++ b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr @@ -8,7 +8,7 @@ LL | use std::slice as std; help: you can use `as` to change the binding name of the import | LL | use std::slice as other_std; - | ~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-conflict-item-vs-import.stderr b/tests/ui/resolve/resolve-conflict-item-vs-import.stderr index 3b1b5f1ad001e..a8b16009c5542 100644 --- a/tests/ui/resolve/resolve-conflict-item-vs-import.stderr +++ b/tests/ui/resolve/resolve-conflict-item-vs-import.stderr @@ -11,7 +11,7 @@ LL | fn transmute() {} help: you can use `as` to change the binding name of the import | LL | use std::mem::transmute as other_transmute; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-conflict-type-vs-import.stderr b/tests/ui/resolve/resolve-conflict-type-vs-import.stderr index c5cb4e078620a..241e48d0cd562 100644 --- a/tests/ui/resolve/resolve-conflict-type-vs-import.stderr +++ b/tests/ui/resolve/resolve-conflict-type-vs-import.stderr @@ -11,7 +11,7 @@ LL | struct Iter; help: you can use `as` to change the binding name of the import | LL | use std::slice::Iter as OtherIter; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/variants/variant-namespacing.stderr b/tests/ui/variants/variant-namespacing.stderr index 9e91ff7178d98..2a2491b81f940 100644 --- a/tests/ui/variants/variant-namespacing.stderr +++ b/tests/ui/variants/variant-namespacing.stderr @@ -11,7 +11,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; help: you can use `as` to change the binding name of the import | LL | pub use variant_namespacing::XE::{XStruct as OtherXStruct, XTuple, XUnit}; - | ~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++++++ error[E0255]: the name `XTuple` is defined multiple times --> $DIR/variant-namespacing.rs:24:44 @@ -26,7 +26,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; help: you can use `as` to change the binding name of the import | LL | pub use variant_namespacing::XE::{XStruct, XTuple as OtherXTuple, XUnit}; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++ error[E0255]: the name `XUnit` is defined multiple times --> $DIR/variant-namespacing.rs:24:52 @@ -41,7 +41,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; help: you can use `as` to change the binding name of the import | LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit as OtherXUnit}; - | ~~~~~~~~~~~~~~~~~~~ + | +++++++++++++ error[E0255]: the name `Struct` is defined multiple times --> $DIR/variant-namespacing.rs:28:13 @@ -56,7 +56,7 @@ LL | pub use E::{Struct, Tuple, Unit}; help: you can use `as` to change the binding name of the import | LL | pub use E::{Struct as OtherStruct, Tuple, Unit}; - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++ error[E0255]: the name `Tuple` is defined multiple times --> $DIR/variant-namespacing.rs:28:21 @@ -71,7 +71,7 @@ LL | pub use E::{Struct, Tuple, Unit}; help: you can use `as` to change the binding name of the import | LL | pub use E::{Struct, Tuple as OtherTuple, Unit}; - | ~~~~~~~~~~~~~~~~~~~ + | +++++++++++++ error[E0255]: the name `Unit` is defined multiple times --> $DIR/variant-namespacing.rs:28:28 @@ -86,7 +86,7 @@ LL | pub use E::{Struct, Tuple, Unit}; help: you can use `as` to change the binding name of the import | LL | pub use E::{Struct, Tuple, Unit as OtherUnit}; - | ~~~~~~~~~~~~~~~~~ + | ++++++++++++ error: aborting due to 6 previous errors From be9d9618845b8edbfb110927d8deab8c636c9e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 10 Jul 2024 02:28:09 +0000 Subject: [PATCH 12/13] More accurate span for type parameter suggestion After: ``` error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:3:10 | LL | impl Foo for String {} | ^^^^^^^^^^ associated item constraint not allowed here | help: declare the type parameter right after the `impl` keyword | LL - impl Foo for String {} LL + impl Foo for String {} | ``` Before: ``` error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:3:10 | LL | impl Foo for String {} | ^^^^^^^^^^ associated item constraint not allowed here | help: declare the type parameter right after the `impl` keyword | LL | impl Foo for String {} | ++++++++++++ ~ ``` --- .../src/hir_ty_lowering/errors.rs | 8 +++-- ...declared-in-wrong-spot-issue-113073.stderr | 30 +++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 5e595488ea7a8..e1c590c255184 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -1340,11 +1340,13 @@ pub fn prohibit_assoc_item_constraint( format!("<{lifetimes}{type_with_constraints}>"), ) }; - let suggestions = - vec![param_decl, (constraint.span, format!("{}", matching_param.name))]; + let suggestions = vec![ + param_decl, + (constraint.span.with_lo(constraint.ident.span.hi()), String::new()), + ]; err.multipart_suggestion_verbose( - format!("declare the type parameter right after the `impl` keyword"), + "declare the type parameter right after the `impl` keyword", suggestions, Applicability::MaybeIncorrect, ); diff --git a/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr b/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr index dfc6761e17e7f..c60c4c72a2133 100644 --- a/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr +++ b/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr @@ -14,8 +14,9 @@ LL | impl Foo for String {} | help: declare the type parameter right after the `impl` keyword | -LL | impl Foo for String {} - | ++++++++++++ ~ +LL - impl Foo for String {} +LL + impl Foo for String {} + | error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:7:10 @@ -25,8 +26,9 @@ LL | impl Foo for u8 {} | help: declare the type parameter right after the `impl` keyword | -LL | impl<'a, T: 'a + Default> Foo for u8 {} - | +++++++++++++++++++++ ~ +LL - impl Foo for u8 {} +LL + impl<'a, T: 'a + Default> Foo for u8 {} + | error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:13:13 @@ -36,8 +38,9 @@ LL | impl Foo for u16 {} | help: declare the type parameter right after the `impl` keyword | -LL | impl Foo for u16 {} - | ++++++++++++ ~ +LL - impl Foo for u16 {} +LL + impl Foo for u16 {} + | error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:17:14 @@ -47,8 +50,9 @@ LL | impl<'a> Foo for u32 {} | help: declare the type parameter right after the `impl` keyword | -LL | impl<'a, 'a, T: 'a + Default> Foo for u32 {} - | +++++++++++++++++++++ ~ +LL - impl<'a> Foo for u32 {} +LL + impl<'a, 'a, T: 'a + Default> Foo for u32 {} + | error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:23:10 @@ -58,8 +62,9 @@ LL | impl Bar for String {} | help: declare the type parameter right after the `impl` keyword | -LL | impl Bar for String {} - | ++++++++++++ ~ +LL - impl Bar for String {} +LL + impl Bar for String {} + | error[E0107]: trait takes 2 generic arguments but 1 generic argument was supplied --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:27:9 @@ -87,8 +92,9 @@ LL | impl Bar for u8 {} | help: declare the type parameter right after the `impl` keyword | -LL | impl Bar for u8 {} - | ++++++++++++ ~ +LL - impl Bar for u8 {} +LL + impl Bar for u8 {} + | error: aborting due to 8 previous errors From f6c4679547b405c0634a0d1938149ba748876d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 10 Jul 2024 22:11:51 +0000 Subject: [PATCH 13/13] More accurate span for anonymous argument suggestion Use smaller span for suggesting adding `_:` ahead of a type: ``` error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:12:47 | LL | fn foo_with_qualified_path(::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: explicitly ignore the parameter name | LL | fn foo_with_qualified_path(_: ::Baz); | ++ ``` --- compiler/rustc_parse/src/parser/diagnostics.rs | 12 ++++++------ tests/ui/anon-params/anon-params-denied-2018.stderr | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 0da7fefe6ed21..2fe3ab56146c3 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2240,11 +2240,11 @@ impl<'a> Parser<'a> { } _ => { // Otherwise, try to get a type and emit a suggestion. - if let Some(ty) = pat.to_ty() { + if let Some(_) = pat.to_ty() { err.span_suggestion_verbose( - pat.span, + pat.span.shrink_to_lo(), "explicitly ignore the parameter name", - format!("_: {}", pprust::ty_to_string(&ty)), + "_: ".to_string(), Applicability::MachineApplicable, ); err.note(rfc_note); @@ -2256,7 +2256,7 @@ impl<'a> Parser<'a> { // `fn foo(a, b) {}`, `fn foo(a, b) {}` or `fn foo(usize, usize) {}` if first_param { - err.span_suggestion( + err.span_suggestion_verbose( self_span, "if this is a `self` type, give it a parameter name", self_sugg, @@ -2266,14 +2266,14 @@ impl<'a> Parser<'a> { // Avoid suggesting that `fn foo(HashMap)` is fixed with a change to // `fn foo(HashMap: TypeName)`. if self.token != token::Lt { - err.span_suggestion( + err.span_suggestion_verbose( param_span, "if this is a parameter name, give it a type", param_sugg, Applicability::HasPlaceholders, ); } - err.span_suggestion( + err.span_suggestion_verbose( type_span, "if this is a type, explicitly ignore the parameter name", type_sugg, diff --git a/tests/ui/anon-params/anon-params-denied-2018.stderr b/tests/ui/anon-params/anon-params-denied-2018.stderr index bb60c898e8122..2d6356ffcb1c0 100644 --- a/tests/ui/anon-params/anon-params-denied-2018.stderr +++ b/tests/ui/anon-params/anon-params-denied-2018.stderr @@ -48,7 +48,7 @@ LL | fn foo_with_qualified_path(::Baz); help: explicitly ignore the parameter name | LL | fn foo_with_qualified_path(_: ::Baz); - | ~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:15:56 @@ -60,7 +60,7 @@ LL | fn foo_with_qualified_path_and_ref(&::Baz); help: explicitly ignore the parameter name | LL | fn foo_with_qualified_path_and_ref(_: &::Baz); - | ~~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `,` --> $DIR/anon-params-denied-2018.rs:18:57 @@ -72,7 +72,7 @@ LL | fn foo_with_multiple_qualified_paths(::Baz, ::Baz); help: explicitly ignore the parameter name | LL | fn foo_with_multiple_qualified_paths(_: ::Baz, ::Baz); - | ~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:18:74 @@ -84,7 +84,7 @@ LL | fn foo_with_multiple_qualified_paths(::Baz, ::Baz); help: explicitly ignore the parameter name | LL | fn foo_with_multiple_qualified_paths(::Baz, _: ::Baz); - | ~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `:`, `@`, or `|`, found `,` --> $DIR/anon-params-denied-2018.rs:22:36