From 0d780b108b007c6232ab3cbba8c47822edbbbddd Mon Sep 17 00:00:00 2001 From: GoodDaisy <90915921+GoodDaisy@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:29:24 +0800 Subject: [PATCH 1/6] fix typos in comments --- compiler/rustc_const_eval/src/interpret/eval_context.rs | 2 +- library/core/src/num/mod.rs | 2 +- src/doc/unstable-book/src/compiler-flags/check-cfg.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 791370660fe94..3e764daa66269 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -1010,7 +1010,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // Just make this an efficient immediate. // Note that not calling `layout_of` here does have one real consequence: // if the type is too big, we'll only notice this when the local is actually initialized, - // which is a bit too late -- we should ideally notice this alreayd here, when the memory + // which is a bit too late -- we should ideally notice this already here, when the memory // is conceptually allocated. But given how rare that error is and that this is a hot function, // we accept this downside for now. Operand::Immediate(Immediate::Uninit) diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 8b127132c1ca2..a6c1adfac6551 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -114,7 +114,7 @@ macro_rules! midpoint_impl { without modifying the original"] #[inline] pub const fn midpoint(self, rhs: $SelfT) -> $SelfT { - // Use the well known branchless algorthim from Hacker's Delight to compute + // Use the well known branchless algorithm from Hacker's Delight to compute // `(a + b) / 2` without overflowing: `((a ^ b) >> 1) + (a & b)`. ((self ^ rhs) >> 1) + (self & rhs) } diff --git a/src/doc/unstable-book/src/compiler-flags/check-cfg.md b/src/doc/unstable-book/src/compiler-flags/check-cfg.md index ca18ec567a4fc..7a3ef5e9e2be6 100644 --- a/src/doc/unstable-book/src/compiler-flags/check-cfg.md +++ b/src/doc/unstable-book/src/compiler-flags/check-cfg.md @@ -123,7 +123,7 @@ rustc --check-cfg 'cfg(is_embedded, has_feathers, values(any()))' \ fn do_embedded() {} // and because names exhaustiveness was not disabled #[cfg(has_feathers)] // This is expected as "has_feathers" was provided in cfg() -fn do_features() {} // and because names exhaustiveness was not disbaled +fn do_features() {} // and because names exhaustiveness was not disabled #[cfg(has_feathers = "zapping")] // This is expected as "has_feathers" was provided in cfg() // and because no value checking was enable for "has_feathers" From c1fb05cdf2442da42a1f28ba9fb5bc4adfac3875 Mon Sep 17 00:00:00 2001 From: rustbot <47979223+rustbot@users.noreply.github.com> Date: Mon, 23 Oct 2023 13:00:51 -0400 Subject: [PATCH 2/6] Update books --- src/doc/book | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/book b/src/doc/book index 72187f5cd0bea..3dca2fc50b922 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 72187f5cd0beaaa9c6f584156bcd88f921871e83 +Subproject commit 3dca2fc50b922a8efb94903b9fee8bb42ab48f38 diff --git a/src/doc/embedded-book b/src/doc/embedded-book index eac173690b8cc..22bca3d0f6e9b 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit eac173690b8cc99094e1d88bd49dd61127fbd285 +Subproject commit 22bca3d0f6e9b9b556689b54ce96f25b46ecd1b3 diff --git a/src/doc/nomicon b/src/doc/nomicon index ddfa421448768..1842257814919 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit ddfa4214487686e91b21aa29afb972c08a8f0d5b +Subproject commit 1842257814919fa62e81bdecd5e8f95be2839dbb diff --git a/src/doc/reference b/src/doc/reference index 142b2ed77d33f..16fd3c06d9e55 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 142b2ed77d33f37a9973772bd95e6144ed9dce43 +Subproject commit 16fd3c06d9e558dae2d52000818274ae70c9e90a diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 8eb3a01ab74c5..6709beeb7d0fb 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 8eb3a01ab74c567b7174784892fb807f2c632d6b +Subproject commit 6709beeb7d0fbc5ffc91ac4893a24434123b9bfa diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index b98af7d661e47..b0ee9ec8fa59a 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit b98af7d661e4744baab81fb8dc7a049e44a4a998 +Subproject commit b0ee9ec8fa59a6c7620165e061f4747202377a62 From 895134291192ca28d156131baa6340fbf48a16f2 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 20 Oct 2023 21:30:52 -0700 Subject: [PATCH 3/6] Naming nits --- compiler/rustc_middle/src/ty/list.rs | 4 +- .../rustc_middle/src/ty/structural_impls.rs | 44 +++++++++---------- compiler/rustc_middle/src/ty/sty.rs | 4 +- compiler/rustc_type_ir/src/const_kind.rs | 6 +-- compiler/rustc_type_ir/src/debug.rs | 36 +++++++-------- compiler/rustc_type_ir/src/region_kind.rs | 6 +-- compiler/rustc_type_ir/src/ty_kind.rs | 10 ++--- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 7a32cfb10857d..66463efd287d1 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -121,8 +121,8 @@ impl fmt::Debug for List { } } impl<'tcx, T: super::DebugWithInfcx>> super::DebugWithInfcx> for List { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { fmt::Debug::fmt(&this.map(|this| this.as_slice()), f) diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 012bb74941286..0fedc0e3cf8d3 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -93,8 +93,8 @@ impl<'tcx> fmt::Debug for ty::FnSig<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::FnSig<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { let sig = this.data; @@ -149,8 +149,8 @@ impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> { } impl<'tcx> ty::DebugWithInfcx> for Ty<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { this.data.fmt(f) @@ -242,8 +242,8 @@ impl<'tcx> fmt::Debug for AliasTy<'tcx> { } } impl<'tcx> DebugWithInfcx> for AliasTy<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_struct("AliasTy") @@ -263,8 +263,8 @@ impl<'tcx> fmt::Debug for ty::InferConst<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::InferConst<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { use ty::InferConst::*; @@ -287,8 +287,8 @@ impl<'tcx> fmt::Debug for ty::consts::Expr<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::consts::Expr<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data { @@ -320,8 +320,8 @@ impl<'tcx> fmt::Debug for ty::UnevaluatedConst<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::UnevaluatedConst<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_struct("UnevaluatedConst") @@ -337,8 +337,8 @@ impl<'tcx> fmt::Debug for ty::Const<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::Const<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { // If this is a value, we spend some effort to make it look nice. @@ -395,8 +395,8 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> { } } impl<'tcx> DebugWithInfcx> for GenericArg<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data.unpack() { @@ -413,8 +413,8 @@ impl<'tcx> fmt::Debug for Region<'tcx> { } } impl<'tcx> DebugWithInfcx> for Region<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { write!(f, "{:?}", &this.map(|data| data.kind())) @@ -422,8 +422,8 @@ impl<'tcx> DebugWithInfcx> for Region<'tcx> { } impl<'tcx> DebugWithInfcx> for ty::RegionVid { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.infcx.and_then(|infcx| infcx.universe_of_lt(*this.data)) { @@ -434,8 +434,8 @@ impl<'tcx> DebugWithInfcx> for ty::RegionVid { } impl<'tcx, T: DebugWithInfcx>> DebugWithInfcx> for ty::Binder<'tcx, T> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_tuple("Binder") diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 46aa5d950cb18..e76f256fdaacd 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -683,8 +683,8 @@ pub enum ExistentialPredicate<'tcx> { } impl<'tcx> DebugWithInfcx> for ExistentialPredicate<'tcx> { - fn fmt>>( - this: rustc_type_ir::OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: rustc_type_ir::OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { fmt::Debug::fmt(&this.data, f) diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index f84841c9f6455..8139aacd86589 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -231,13 +231,13 @@ impl Clone for ConstKind { impl fmt::Debug for ConstKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + OptWithInfcx::with_no_infcx(self).fmt(f) } } impl DebugWithInfcx for ConstKind { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { use ConstKind::*; diff --git a/compiler/rustc_type_ir/src/debug.rs b/compiler/rustc_type_ir/src/debug.rs index 7c6a784690073..556576eef00c7 100644 --- a/compiler/rustc_type_ir/src/debug.rs +++ b/compiler/rustc_type_ir/src/debug.rs @@ -26,15 +26,15 @@ impl InferCtxtLike for core::convert::Infallible { } pub trait DebugWithInfcx: fmt::Debug { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result; } impl + ?Sized> DebugWithInfcx for &'_ T { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { >::fmt(this.map(|&data| data), f) @@ -42,8 +42,8 @@ impl + ?Sized> DebugWithInfcx for &'_ T { } impl> DebugWithInfcx for [T] { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { match f.alternate() { @@ -70,46 +70,46 @@ impl> DebugWithInfcx for [T] { } } -pub struct OptWithInfcx<'a, I: Interner, InfCtx: InferCtxtLike, T> { +pub struct OptWithInfcx<'a, I: Interner, Infcx: InferCtxtLike, T> { pub data: T, - pub infcx: Option<&'a InfCtx>, + pub infcx: Option<&'a Infcx>, _interner: PhantomData, } -impl, T: Copy> Copy for OptWithInfcx<'_, I, InfCtx, T> {} +impl, T: Copy> Copy for OptWithInfcx<'_, I, Infcx, T> {} -impl, T: Clone> Clone for OptWithInfcx<'_, I, InfCtx, T> { +impl, T: Clone> Clone for OptWithInfcx<'_, I, Infcx, T> { fn clone(&self) -> Self { Self { data: self.data.clone(), infcx: self.infcx, _interner: self._interner } } } impl<'a, I: Interner, T> OptWithInfcx<'a, I, core::convert::Infallible, T> { - pub fn new_no_ctx(data: T) -> Self { + pub fn with_no_infcx(data: T) -> Self { Self { data, infcx: None, _interner: PhantomData } } } -impl<'a, I: Interner, InfCtx: InferCtxtLike, T> OptWithInfcx<'a, I, InfCtx, T> { - pub fn new(data: T, infcx: &'a InfCtx) -> Self { +impl<'a, I: Interner, Infcx: InferCtxtLike, T> OptWithInfcx<'a, I, Infcx, T> { + pub fn new(data: T, infcx: &'a Infcx) -> Self { Self { data, infcx: Some(infcx), _interner: PhantomData } } - pub fn wrap(self, u: U) -> OptWithInfcx<'a, I, InfCtx, U> { + pub fn wrap(self, u: U) -> OptWithInfcx<'a, I, Infcx, U> { OptWithInfcx { data: u, infcx: self.infcx, _interner: PhantomData } } - pub fn map(self, f: impl FnOnce(T) -> U) -> OptWithInfcx<'a, I, InfCtx, U> { + pub fn map(self, f: impl FnOnce(T) -> U) -> OptWithInfcx<'a, I, Infcx, U> { OptWithInfcx { data: f(self.data), infcx: self.infcx, _interner: PhantomData } } - pub fn as_ref(&self) -> OptWithInfcx<'a, I, InfCtx, &T> { + pub fn as_ref(&self) -> OptWithInfcx<'a, I, Infcx, &T> { OptWithInfcx { data: &self.data, infcx: self.infcx, _interner: PhantomData } } } -impl, T: DebugWithInfcx> fmt::Debug - for OptWithInfcx<'_, I, InfCtx, T> +impl, T: DebugWithInfcx> fmt::Debug + for OptWithInfcx<'_, I, Infcx, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { DebugWithInfcx::fmt(self.as_ref(), f) diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index 0006eec4d3007..18b31949285d9 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -274,8 +274,8 @@ impl hash::Hash for RegionKind { } impl DebugWithInfcx for RegionKind { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data { @@ -301,7 +301,7 @@ impl DebugWithInfcx for RegionKind { } impl fmt::Debug for RegionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + OptWithInfcx::with_no_infcx(self).fmt(f) } } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 91bfce9a142f9..3f7171a816b0b 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -534,8 +534,8 @@ impl hash::Hash for TyKind { } impl DebugWithInfcx for TyKind { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> fmt::Result { match this.data { @@ -617,7 +617,7 @@ impl DebugWithInfcx for TyKind { // This is manually implemented because a derive would require `I: Debug` impl fmt::Debug for TyKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + OptWithInfcx::with_no_infcx(self).fmt(f) } } @@ -1239,8 +1239,8 @@ impl fmt::Debug for InferTy { } impl> DebugWithInfcx for InferTy { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { use InferTy::*; From 269d5a322e35490513612ba1ed1afd80a982cfe7 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 20 Oct 2023 22:10:58 -0700 Subject: [PATCH 4/6] Remove redundant type parameter --- compiler/rustc_infer/src/infer/mod.rs | 4 +- compiler/rustc_middle/src/ty/list.rs | 6 +- compiler/rustc_middle/src/ty/mod.rs | 2 +- .../rustc_middle/src/ty/structural_impls.rs | 60 +++++++-------- compiler/rustc_middle/src/ty/sty.rs | 4 +- compiler/rustc_type_ir/src/const_kind.rs | 10 +-- compiler/rustc_type_ir/src/debug.rs | 73 +++++++++++-------- compiler/rustc_type_ir/src/lib.rs | 2 +- compiler/rustc_type_ir/src/region_kind.rs | 10 +-- compiler/rustc_type_ir/src/ty_kind.rs | 14 ++-- 10 files changed, 98 insertions(+), 87 deletions(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 8ffcf1fce9cfb..2198a15d99d4c 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -341,7 +341,9 @@ pub struct InferCtxt<'tcx> { next_trait_solver: bool, } -impl<'tcx> ty::InferCtxtLike> for InferCtxt<'tcx> { +impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> { + type Interner = TyCtxt<'tcx>; + fn universe_of_ty(&self, ty: ty::InferTy) -> Option { use InferTy::*; match ty { diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 66463efd287d1..4f9c9d85763a2 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -1,7 +1,7 @@ use crate::arena::Arena; use rustc_data_structures::aligned::{align_of, Aligned}; use rustc_serialize::{Encodable, Encoder}; -use rustc_type_ir::{InferCtxtLike, OptWithInfcx}; +use rustc_type_ir::{InferCtxtLike, WithInfcx}; use std::alloc::Layout; use std::cmp::Ordering; use std::fmt; @@ -121,8 +121,8 @@ impl fmt::Debug for List { } } impl<'tcx, T: super::DebugWithInfcx>> super::DebugWithInfcx> for List { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { fmt::Debug::fmt(&this.map(|this| this.as_slice()), f) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 9b0ceb23e3eab..91211a048a00e 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -54,7 +54,7 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{ExpnId, ExpnKind, Span}; use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx}; pub use rustc_target::abi::{ReprFlags, ReprOptions}; -pub use rustc_type_ir::{DebugWithInfcx, InferCtxtLike, OptWithInfcx}; +pub use rustc_type_ir::{DebugWithInfcx, InferCtxtLike, WithInfcx}; pub use vtable::*; use std::fmt::Debug; diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 0fedc0e3cf8d3..101c6dd4f9a20 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -10,7 +10,7 @@ use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; use crate::ty::{self, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; use rustc_hir::def::Namespace; use rustc_target::abi::TyAndLayout; -use rustc_type_ir::{ConstKind, DebugWithInfcx, InferCtxtLike, OptWithInfcx}; +use rustc_type_ir::{ConstKind, DebugWithInfcx, InferCtxtLike, WithInfcx}; use std::fmt::{self, Debug}; use std::ops::ControlFlow; @@ -89,12 +89,12 @@ impl fmt::Debug for ty::FreeRegion { impl<'tcx> fmt::Debug for ty::FnSig<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } impl<'tcx> DebugWithInfcx> for ty::FnSig<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { let sig = this.data; @@ -149,8 +149,8 @@ impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> { } impl<'tcx> ty::DebugWithInfcx> for Ty<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { this.data.fmt(f) @@ -238,12 +238,12 @@ impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> { impl<'tcx> fmt::Debug for AliasTy<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } impl<'tcx> DebugWithInfcx> for AliasTy<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_struct("AliasTy") @@ -263,12 +263,12 @@ impl<'tcx> fmt::Debug for ty::InferConst<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::InferConst<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { use ty::InferConst::*; - match this.infcx.and_then(|infcx| infcx.universe_of_ct(*this.data)) { + match this.infcx.universe_of_ct(*this.data) { None => write!(f, "{:?}", this.data), Some(universe) => match *this.data { Var(vid) => write!(f, "?{}_{}c", vid.index, universe.index()), @@ -283,12 +283,12 @@ impl<'tcx> DebugWithInfcx> for ty::InferConst<'tcx> { impl<'tcx> fmt::Debug for ty::consts::Expr<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } impl<'tcx> DebugWithInfcx> for ty::consts::Expr<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data { @@ -316,12 +316,12 @@ impl<'tcx> DebugWithInfcx> for ty::consts::Expr<'tcx> { impl<'tcx> fmt::Debug for ty::UnevaluatedConst<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } impl<'tcx> DebugWithInfcx> for ty::UnevaluatedConst<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_struct("UnevaluatedConst") @@ -333,12 +333,12 @@ impl<'tcx> DebugWithInfcx> for ty::UnevaluatedConst<'tcx> { impl<'tcx> fmt::Debug for ty::Const<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } impl<'tcx> DebugWithInfcx> for ty::Const<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { // If this is a value, we spend some effort to make it look nice. @@ -395,8 +395,8 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> { } } impl<'tcx> DebugWithInfcx> for GenericArg<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data.unpack() { @@ -413,8 +413,8 @@ impl<'tcx> fmt::Debug for Region<'tcx> { } } impl<'tcx> DebugWithInfcx> for Region<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { write!(f, "{:?}", &this.map(|data| data.kind())) @@ -422,11 +422,11 @@ impl<'tcx> DebugWithInfcx> for Region<'tcx> { } impl<'tcx> DebugWithInfcx> for ty::RegionVid { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { - match this.infcx.and_then(|infcx| infcx.universe_of_lt(*this.data)) { + match this.infcx.universe_of_lt(*this.data) { Some(universe) => write!(f, "'?{}_{}", this.data.index(), universe.index()), None => write!(f, "{:?}", this.data), } @@ -434,8 +434,8 @@ impl<'tcx> DebugWithInfcx> for ty::RegionVid { } impl<'tcx, T: DebugWithInfcx>> DebugWithInfcx> for ty::Binder<'tcx, T> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_tuple("Binder") diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index e76f256fdaacd..f93a23158fb0f 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -683,8 +683,8 @@ pub enum ExistentialPredicate<'tcx> { } impl<'tcx> DebugWithInfcx> for ExistentialPredicate<'tcx> { - fn fmt>>( - this: rustc_type_ir::OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, + fn fmt>>( + this: rustc_type_ir::WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { fmt::Debug::fmt(&this.data, f) diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index 8139aacd86589..fbd403c82c6f8 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -5,8 +5,8 @@ use std::fmt; use std::hash; use crate::{ - DebruijnIndex, DebugWithInfcx, HashStableContext, InferCtxtLike, Interner, OptWithInfcx, - TyDecoder, TyEncoder, + DebruijnIndex, DebugWithInfcx, HashStableContext, InferCtxtLike, Interner, TyDecoder, + TyEncoder, WithInfcx, }; use self::ConstKind::*; @@ -231,13 +231,13 @@ impl Clone for ConstKind { impl fmt::Debug for ConstKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - OptWithInfcx::with_no_infcx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } impl DebugWithInfcx for ConstKind { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { use ConstKind::*; diff --git a/compiler/rustc_type_ir/src/debug.rs b/compiler/rustc_type_ir/src/debug.rs index 556576eef00c7..4ea3eb3e84f43 100644 --- a/compiler/rustc_type_ir/src/debug.rs +++ b/compiler/rustc_type_ir/src/debug.rs @@ -3,38 +3,48 @@ use crate::{Interner, UniverseIndex}; use core::fmt; use std::marker::PhantomData; -pub trait InferCtxtLike { - fn universe_of_ty(&self, ty: I::InferTy) -> Option; +pub trait InferCtxtLike { + type Interner: Interner; - fn universe_of_lt(&self, lt: I::InferRegion) -> Option; + fn universe_of_ty(&self, ty: ::InferTy) -> Option; - fn universe_of_ct(&self, ct: I::InferConst) -> Option; + fn universe_of_lt( + &self, + lt: ::InferRegion, + ) -> Option; + + fn universe_of_ct(&self, ct: ::InferConst) + -> Option; } -impl InferCtxtLike for core::convert::Infallible { +pub struct NoInfcx(PhantomData); + +impl InferCtxtLike for NoInfcx { + type Interner = I; + fn universe_of_ty(&self, _ty: ::InferTy) -> Option { - match *self {} + None } fn universe_of_ct(&self, _ct: ::InferConst) -> Option { - match *self {} + None } fn universe_of_lt(&self, _lt: ::InferRegion) -> Option { - match *self {} + None } } pub trait DebugWithInfcx: fmt::Debug { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result; } impl + ?Sized> DebugWithInfcx for &'_ T { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { >::fmt(this.map(|&data| data), f) @@ -42,8 +52,8 @@ impl + ?Sized> DebugWithInfcx for &'_ T { } impl> DebugWithInfcx for [T] { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { match f.alternate() { @@ -70,46 +80,45 @@ impl> DebugWithInfcx for [T] { } } -pub struct OptWithInfcx<'a, I: Interner, Infcx: InferCtxtLike, T> { +pub struct WithInfcx<'a, Infcx: InferCtxtLike, T> { pub data: T, - pub infcx: Option<&'a Infcx>, - _interner: PhantomData, + pub infcx: &'a Infcx, } -impl, T: Copy> Copy for OptWithInfcx<'_, I, Infcx, T> {} +impl Copy for WithInfcx<'_, Infcx, T> {} -impl, T: Clone> Clone for OptWithInfcx<'_, I, Infcx, T> { +impl Clone for WithInfcx<'_, Infcx, T> { fn clone(&self) -> Self { - Self { data: self.data.clone(), infcx: self.infcx, _interner: self._interner } + Self { data: self.data.clone(), infcx: self.infcx } } } -impl<'a, I: Interner, T> OptWithInfcx<'a, I, core::convert::Infallible, T> { +impl<'a, I: Interner, T> WithInfcx<'a, NoInfcx, T> { pub fn with_no_infcx(data: T) -> Self { - Self { data, infcx: None, _interner: PhantomData } + Self { data, infcx: &NoInfcx(PhantomData) } } } -impl<'a, I: Interner, Infcx: InferCtxtLike, T> OptWithInfcx<'a, I, Infcx, T> { +impl<'a, Infcx: InferCtxtLike, T> WithInfcx<'a, Infcx, T> { pub fn new(data: T, infcx: &'a Infcx) -> Self { - Self { data, infcx: Some(infcx), _interner: PhantomData } + Self { data, infcx } } - pub fn wrap(self, u: U) -> OptWithInfcx<'a, I, Infcx, U> { - OptWithInfcx { data: u, infcx: self.infcx, _interner: PhantomData } + pub fn wrap(self, u: U) -> WithInfcx<'a, Infcx, U> { + WithInfcx { data: u, infcx: self.infcx } } - pub fn map(self, f: impl FnOnce(T) -> U) -> OptWithInfcx<'a, I, Infcx, U> { - OptWithInfcx { data: f(self.data), infcx: self.infcx, _interner: PhantomData } + pub fn map(self, f: impl FnOnce(T) -> U) -> WithInfcx<'a, Infcx, U> { + WithInfcx { data: f(self.data), infcx: self.infcx } } - pub fn as_ref(&self) -> OptWithInfcx<'a, I, Infcx, &T> { - OptWithInfcx { data: &self.data, infcx: self.infcx, _interner: PhantomData } + pub fn as_ref(&self) -> WithInfcx<'a, Infcx, &T> { + WithInfcx { data: &self.data, infcx: self.infcx } } } -impl, T: DebugWithInfcx> fmt::Debug - for OptWithInfcx<'_, I, Infcx, T> +impl> fmt::Debug + for WithInfcx<'_, Infcx, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { DebugWithInfcx::fmt(self.as_ref(), f) diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index d4ca9da96e4ed..1ff220f3ed6b2 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -34,7 +34,7 @@ mod region_kind; pub use codec::*; pub use const_kind::*; -pub use debug::{DebugWithInfcx, InferCtxtLike, OptWithInfcx}; +pub use debug::{DebugWithInfcx, InferCtxtLike, WithInfcx}; pub use flags::*; pub use interner::*; pub use region_kind::*; diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index 18b31949285d9..23e575cbc3751 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -5,8 +5,8 @@ use std::fmt; use std::hash; use crate::{ - DebruijnIndex, DebugWithInfcx, HashStableContext, InferCtxtLike, Interner, OptWithInfcx, - TyDecoder, TyEncoder, + DebruijnIndex, DebugWithInfcx, HashStableContext, InferCtxtLike, Interner, TyDecoder, + TyEncoder, WithInfcx, }; use self::RegionKind::*; @@ -274,8 +274,8 @@ impl hash::Hash for RegionKind { } impl DebugWithInfcx for RegionKind { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data { @@ -301,7 +301,7 @@ impl DebugWithInfcx for RegionKind { } impl fmt::Debug for RegionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::with_no_infcx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 3f7171a816b0b..9c719d2d9784b 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -11,7 +11,7 @@ use crate::HashStableContext; use crate::Interner; use crate::TyDecoder; use crate::TyEncoder; -use crate::{DebruijnIndex, DebugWithInfcx, InferCtxtLike, OptWithInfcx}; +use crate::{DebruijnIndex, DebugWithInfcx, InferCtxtLike, WithInfcx}; use self::TyKind::*; @@ -534,8 +534,8 @@ impl hash::Hash for TyKind { } impl DebugWithInfcx for TyKind { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> fmt::Result { match this.data { @@ -617,7 +617,7 @@ impl DebugWithInfcx for TyKind { // This is manually implemented because a derive would require `I: Debug` impl fmt::Debug for TyKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::with_no_infcx(self).fmt(f) + WithInfcx::with_no_infcx(self).fmt(f) } } @@ -1239,12 +1239,12 @@ impl fmt::Debug for InferTy { } impl> DebugWithInfcx for InferTy { - fn fmt>( - this: OptWithInfcx<'_, I, Infcx, &Self>, + fn fmt>( + this: WithInfcx<'_, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { use InferTy::*; - match this.infcx.and_then(|infcx| infcx.universe_of_ty(*this.data)) { + match this.infcx.universe_of_ty(*this.data) { None => write!(f, "{:?}", this.data), Some(universe) => match *this.data { TyVar(ty_vid) => write!(f, "?{}_{}t", ty_vid.index(), universe.index()), From b99b93586fe949f87f20cc65b9f0f1ac738c529d Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Tue, 24 Oct 2023 09:46:34 +0300 Subject: [PATCH 5/6] remove change-id assertion in bootstrap test In the bootstrap test, the assertion of the change-id fails whenever we update the change-id next to a breaking change in build configurations. This commit removes the assertion, as it's not critical or useful to have. Signed-off-by: onur-ozkan --- src/bootstrap/bootstrap_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py index 7f16cac78901c..e6caabec4f640 100644 --- a/src/bootstrap/bootstrap_test.py +++ b/src/bootstrap/bootstrap_test.py @@ -103,7 +103,6 @@ class GenerateAndParseConfig(unittest.TestCase): """Test that we can serialize and deserialize a config.toml file""" def test_no_args(self): build = serialize_and_parse([]) - self.assertEqual(build.get_toml("change-id"), '116998') self.assertEqual(build.get_toml("profile"), 'dist') self.assertIsNone(build.get_toml("llvm.download-ci-llvm")) From 712106b1229f48e71a6365f5e5bf171403105750 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 23 Oct 2023 16:34:33 +0000 Subject: [PATCH 6/6] Add regression test for #117058 --- .../statement-attribute-validation.rs | 39 +++++++++++++ .../statement-attribute-validation.stderr | 56 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/ui/attributes/statement-attribute-validation.rs create mode 100644 tests/ui/attributes/statement-attribute-validation.stderr diff --git a/tests/ui/attributes/statement-attribute-validation.rs b/tests/ui/attributes/statement-attribute-validation.rs new file mode 100644 index 0000000000000..31407364acfea --- /dev/null +++ b/tests/ui/attributes/statement-attribute-validation.rs @@ -0,0 +1,39 @@ +// test for #117058 - check that attributes are validated on various kinds of statements. + +struct A; + +fn func() {} + +fn main() { + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + if true { + } else { + } + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + (1); + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + match 1 { + _ => {} + } + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + while false {} + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + {} + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + A {}; + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + func(); + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + A; + #[allow(two-words)] + //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` + loop {} +} diff --git a/tests/ui/attributes/statement-attribute-validation.stderr b/tests/ui/attributes/statement-attribute-validation.stderr new file mode 100644 index 0000000000000..06f447be5626a --- /dev/null +++ b/tests/ui/attributes/statement-attribute-validation.stderr @@ -0,0 +1,56 @@ +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:8:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:13:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:16:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:21:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:24:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:27:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:30:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:33:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/statement-attribute-validation.rs:36:16 + | +LL | #[allow(two-words)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: aborting due to 9 previous errors +