From c7b6e1de661419a67a59ad59fba70a451c27cbb6 Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 8 Jun 2022 12:39:14 +0200 Subject: [PATCH 1/7] lub: don't bail out due to empty binders --- compiler/rustc_infer/src/infer/glb.rs | 20 +++++-- compiler/rustc_infer/src/infer/lub.rs | 20 +++++-- src/test/ui/lub-glb/empty-binders-err.rs | 61 ++++++++++++++++++++ src/test/ui/lub-glb/empty-binders-err.stderr | 59 +++++++++++++++++++ src/test/ui/lub-glb/empty-binders.rs | 45 +++++++++++++++ 5 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 src/test/ui/lub-glb/empty-binders-err.rs create mode 100644 src/test/ui/lub-glb/empty-binders-err.stderr create mode 100644 src/test/ui/lub-glb/empty-binders.rs diff --git a/compiler/rustc_infer/src/infer/glb.rs b/compiler/rustc_infer/src/infer/glb.rs index 0d38b94965afe..1570a08f3ca8b 100644 --- a/compiler/rustc_infer/src/infer/glb.rs +++ b/compiler/rustc_infer/src/infer/glb.rs @@ -95,12 +95,20 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> { T: Relate<'tcx>, { debug!("binders(a={:?}, b={:?})", a, b); - - // When higher-ranked types are involved, computing the LUB is - // very challenging, switch to invariance. This is obviously - // overly conservative but works ok in practice. - self.relate_with_variance(ty::Variance::Invariant, ty::VarianceDiagInfo::default(), a, b)?; - Ok(a) + if a.skip_binder().has_escaping_bound_vars() || b.skip_binder().has_escaping_bound_vars() { + // When higher-ranked types are involved, computing the GLB is + // very challenging, switch to invariance. This is obviously + // overly conservative but works ok in practice. + self.relate_with_variance( + ty::Variance::Invariant, + ty::VarianceDiagInfo::default(), + a, + b, + )?; + Ok(a) + } else { + Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?)) + } } } diff --git a/compiler/rustc_infer/src/infer/lub.rs b/compiler/rustc_infer/src/infer/lub.rs index 498c1e907c4e1..9f96d52c85034 100644 --- a/compiler/rustc_infer/src/infer/lub.rs +++ b/compiler/rustc_infer/src/infer/lub.rs @@ -95,12 +95,20 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> { T: Relate<'tcx>, { debug!("binders(a={:?}, b={:?})", a, b); - - // When higher-ranked types are involved, computing the LUB is - // very challenging, switch to invariance. This is obviously - // overly conservative but works ok in practice. - self.relate_with_variance(ty::Variance::Invariant, ty::VarianceDiagInfo::default(), a, b)?; - Ok(a) + if a.skip_binder().has_escaping_bound_vars() || b.skip_binder().has_escaping_bound_vars() { + // When higher-ranked types are involved, computing the LUB is + // very challenging, switch to invariance. This is obviously + // overly conservative but works ok in practice. + self.relate_with_variance( + ty::Variance::Invariant, + ty::VarianceDiagInfo::default(), + a, + b, + )?; + Ok(a) + } else { + Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?)) + } } } diff --git a/src/test/ui/lub-glb/empty-binders-err.rs b/src/test/ui/lub-glb/empty-binders-err.rs new file mode 100644 index 0000000000000..ee28dd7c97d61 --- /dev/null +++ b/src/test/ui/lub-glb/empty-binders-err.rs @@ -0,0 +1,61 @@ +fn lt<'a: 'a>() -> &'a () { + &() +} + +fn lt_in_fn<'a: 'a>() -> fn(&'a ()) { + |_| () +} + +struct Contra<'a>(fn(&'a ())); +fn lt_in_contra<'a: 'a>() -> Contra<'a> { + Contra(|_| ()) +} + +fn covariance<'a, 'b, 'upper, 'lower>(v: bool) +where + 'upper: 'a, + 'upper: 'b, + 'a: 'lower, + 'b: 'lower, + +{ + let _: &'upper () = match v { + //~^ ERROR lifetime may not live long enough + //~| ERROR lifetime may not live long enough + true => lt::<'a>(), + false => lt::<'b>(), + }; +} + +fn contra_fn<'a, 'b, 'upper, 'lower>(v: bool) +where + 'upper: 'a, + 'upper: 'b, + 'a: 'lower, + 'b: 'lower, + +{ + + let _: fn(&'lower ()) = match v { + //~^ ERROR lifetime may not live long enough + true => lt_in_fn::<'a>(), + false => lt_in_fn::<'b>(), + }; +} + +fn contra_struct<'a, 'b, 'upper, 'lower>(v: bool) +where + 'upper: 'a, + 'upper: 'b, + 'a: 'lower, + 'b: 'lower, + +{ + let _: Contra<'lower> = match v { + //~^ ERROR lifetime may not live long enough + true => lt_in_contra::<'a>(), + false => lt_in_contra::<'b>(), + }; +} + +fn main() {} diff --git a/src/test/ui/lub-glb/empty-binders-err.stderr b/src/test/ui/lub-glb/empty-binders-err.stderr new file mode 100644 index 0000000000000..0d5de978e4301 --- /dev/null +++ b/src/test/ui/lub-glb/empty-binders-err.stderr @@ -0,0 +1,59 @@ +error: lifetime may not live long enough + --> $DIR/empty-binders-err.rs:22:12 + | +LL | fn covariance<'a, 'b, 'upper, 'lower>(v: bool) + | -- ------ lifetime `'upper` defined here + | | + | lifetime `'a` defined here +... +LL | let _: &'upper () = match v { + | ^^^^^^^^^^ type annotation requires that `'a` must outlive `'upper` + | + = help: consider adding the following bound: `'a: 'upper` + +error: lifetime may not live long enough + --> $DIR/empty-binders-err.rs:22:12 + | +LL | fn covariance<'a, 'b, 'upper, 'lower>(v: bool) + | -- ------ lifetime `'upper` defined here + | | + | lifetime `'b` defined here +... +LL | let _: &'upper () = match v { + | ^^^^^^^^^^ type annotation requires that `'b` must outlive `'upper` + | + = help: consider adding the following bound: `'b: 'upper` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'upper` + = help: add bound `'b: 'upper` + +error: lifetime may not live long enough + --> $DIR/empty-binders-err.rs:39:12 + | +LL | fn contra_fn<'a, 'b, 'upper, 'lower>(v: bool) + | -- ------ lifetime `'lower` defined here + | | + | lifetime `'a` defined here +... +LL | let _: fn(&'lower ()) = match v { + | ^^^^^^^^^^^^^^ type annotation requires that `'lower` must outlive `'a` + | + = help: consider adding the following bound: `'lower: 'a` + +error: lifetime may not live long enough + --> $DIR/empty-binders-err.rs:54:12 + | +LL | fn contra_struct<'a, 'b, 'upper, 'lower>(v: bool) + | -- ------ lifetime `'lower` defined here + | | + | lifetime `'a` defined here +... +LL | let _: Contra<'lower> = match v { + | ^^^^^^^^^^^^^^ type annotation requires that `'lower` must outlive `'a` + | + = help: consider adding the following bound: `'lower: 'a` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/lub-glb/empty-binders.rs b/src/test/ui/lub-glb/empty-binders.rs new file mode 100644 index 0000000000000..f9d07e79fdabf --- /dev/null +++ b/src/test/ui/lub-glb/empty-binders.rs @@ -0,0 +1,45 @@ +// check-pass +// +// Check that computing the lub works even for empty binders. +fn lt<'a: 'a>() -> &'a () { + &() +} + +fn lt_in_fn<'a: 'a>() -> fn(&'a ()) { + |_| () +} + +struct Contra<'a>(fn(&'a ())); +fn lt_in_contra<'a: 'a>() -> Contra<'a> { + Contra(|_| ()) +} + +fn ok<'a, 'b, 'upper, 'lower>(v: bool) +where + 'upper: 'a, + 'upper: 'b, + 'a: 'lower, + 'b: 'lower, + +{ + let _: &'lower () = match v { + true => lt::<'a>(), + false => lt::<'b>(), + }; + + // This errored in the past because LUB and GLB always + // bailed out when encountering binders, even if they were + // empty. + let _: fn(&'upper ()) = match v { + true => lt_in_fn::<'a>(), + false => lt_in_fn::<'b>(), + }; + + // This was already accepted, as relate didn't encounter any binders. + let _: Contra<'upper> = match v { + true => lt_in_contra::<'a>(), + false => lt_in_contra::<'b>(), + }; +} + +fn main() {} From 0667b00acf939634ff1fd310ed5de2d49c65c6bb Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 8 Jun 2022 21:03:52 +0200 Subject: [PATCH 2/7] update tests + add future compat test --- .../ui/lub-glb/empty-binder-future-compat.rs | 22 +++++++++++++++++++ src/test/ui/lub-glb/empty-binders-err.rs | 12 +++------- src/test/ui/lub-glb/empty-binders-err.stderr | 20 ++++++++--------- 3 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 src/test/ui/lub-glb/empty-binder-future-compat.rs diff --git a/src/test/ui/lub-glb/empty-binder-future-compat.rs b/src/test/ui/lub-glb/empty-binder-future-compat.rs new file mode 100644 index 0000000000000..8700a88a36ea0 --- /dev/null +++ b/src/test/ui/lub-glb/empty-binder-future-compat.rs @@ -0,0 +1,22 @@ +// check-pass +fn lt_in_fn_fn<'a: 'a>() -> fn(fn(&'a ())) { + |_| () +} + + +fn foo<'a, 'b, 'lower>(v: bool) +where + 'a: 'lower, + 'b: 'lower, +{ + // if we infer `x` to be higher ranked in the future, + // this would cause a type error. + let x = match v { + true => lt_in_fn_fn::<'a>(), + false => lt_in_fn_fn::<'b>(), + }; + + let _: fn(fn(&'lower())) = x; +} + +fn main() {} diff --git a/src/test/ui/lub-glb/empty-binders-err.rs b/src/test/ui/lub-glb/empty-binders-err.rs index ee28dd7c97d61..557480173ee62 100644 --- a/src/test/ui/lub-glb/empty-binders-err.rs +++ b/src/test/ui/lub-glb/empty-binders-err.rs @@ -11,12 +11,10 @@ fn lt_in_contra<'a: 'a>() -> Contra<'a> { Contra(|_| ()) } -fn covariance<'a, 'b, 'upper, 'lower>(v: bool) +fn covariance<'a, 'b, 'upper>(v: bool) where 'upper: 'a, 'upper: 'b, - 'a: 'lower, - 'b: 'lower, { let _: &'upper () = match v { @@ -27,10 +25,8 @@ where }; } -fn contra_fn<'a, 'b, 'upper, 'lower>(v: bool) +fn contra_fn<'a, 'b, 'lower>(v: bool) where - 'upper: 'a, - 'upper: 'b, 'a: 'lower, 'b: 'lower, @@ -43,10 +39,8 @@ where }; } -fn contra_struct<'a, 'b, 'upper, 'lower>(v: bool) +fn contra_struct<'a, 'b, 'lower>(v: bool) where - 'upper: 'a, - 'upper: 'b, 'a: 'lower, 'b: 'lower, diff --git a/src/test/ui/lub-glb/empty-binders-err.stderr b/src/test/ui/lub-glb/empty-binders-err.stderr index 0d5de978e4301..f86f22d5e40bf 100644 --- a/src/test/ui/lub-glb/empty-binders-err.stderr +++ b/src/test/ui/lub-glb/empty-binders-err.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough - --> $DIR/empty-binders-err.rs:22:12 + --> $DIR/empty-binders-err.rs:20:12 | -LL | fn covariance<'a, 'b, 'upper, 'lower>(v: bool) +LL | fn covariance<'a, 'b, 'upper>(v: bool) | -- ------ lifetime `'upper` defined here | | | lifetime `'a` defined here @@ -12,9 +12,9 @@ LL | let _: &'upper () = match v { = help: consider adding the following bound: `'a: 'upper` error: lifetime may not live long enough - --> $DIR/empty-binders-err.rs:22:12 + --> $DIR/empty-binders-err.rs:20:12 | -LL | fn covariance<'a, 'b, 'upper, 'lower>(v: bool) +LL | fn covariance<'a, 'b, 'upper>(v: bool) | -- ------ lifetime `'upper` defined here | | | lifetime `'b` defined here @@ -30,10 +30,10 @@ help: the following changes may resolve your lifetime errors = help: add bound `'b: 'upper` error: lifetime may not live long enough - --> $DIR/empty-binders-err.rs:39:12 + --> $DIR/empty-binders-err.rs:35:12 | -LL | fn contra_fn<'a, 'b, 'upper, 'lower>(v: bool) - | -- ------ lifetime `'lower` defined here +LL | fn contra_fn<'a, 'b, 'lower>(v: bool) + | -- ------ lifetime `'lower` defined here | | | lifetime `'a` defined here ... @@ -43,10 +43,10 @@ LL | let _: fn(&'lower ()) = match v { = help: consider adding the following bound: `'lower: 'a` error: lifetime may not live long enough - --> $DIR/empty-binders-err.rs:54:12 + --> $DIR/empty-binders-err.rs:48:12 | -LL | fn contra_struct<'a, 'b, 'upper, 'lower>(v: bool) - | -- ------ lifetime `'lower` defined here +LL | fn contra_struct<'a, 'b, 'lower>(v: bool) + | -- ------ lifetime `'lower` defined here | | | lifetime `'a` defined here ... From 1c1a60f0a3dc36f13ba0c642e9bb4a78e2142f74 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 14 Jun 2022 09:40:15 -0700 Subject: [PATCH 3/7] interpret: convert_tag_add_extra, init_allocation_extra: allow tagger to raise errors --- .../rustc_const_eval/src/interpret/machine.rs | 8 +++++--- .../rustc_const_eval/src/interpret/memory.rs | 18 ++++++++++-------- .../src/mir/interpret/allocation.rs | 12 ++++++------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 5377535b9fa08..c18ac84171d69 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -334,12 +334,14 @@ pub trait Machine<'mir, 'tcx>: Sized { /// allocation (because a copy had to be done to add tags or metadata), machine memory will /// cache the result. (This relies on `AllocMap::get_or` being able to add the /// owned allocation to the map even when the map is shared.) + /// + /// This must only fail if `alloc` contains relocations. fn init_allocation_extra<'b>( ecx: &InterpCx<'mir, 'tcx, Self>, id: AllocId, alloc: Cow<'b, Allocation>, kind: Option>, - ) -> Cow<'b, Allocation>; + ) -> InterpResult<'tcx, Cow<'b, Allocation>>; /// Hook for performing extra checks on a memory read access. /// @@ -485,9 +487,9 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) { _id: AllocId, alloc: Cow<'b, Allocation>, _kind: Option>, - ) -> Cow<'b, Allocation> { + ) -> InterpResult<$tcx, Cow<'b, Allocation>> { // We do not use a tag so we can just cheaply forward the allocation - alloc + Ok(alloc) } fn extern_static_base_pointer( diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index f725a0591c5b6..d46f2f38d3a65 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -199,7 +199,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { kind: MemoryKind, ) -> InterpResult<'tcx, Pointer> { let alloc = Allocation::uninit(size, align, M::PANIC_ON_ALLOC_FAIL)?; - Ok(self.allocate_raw_ptr(alloc, kind)) + // We can `unwrap` since `alloc` contains no pointers. + Ok(self.allocate_raw_ptr(alloc, kind).unwrap()) } pub fn allocate_bytes_ptr( @@ -210,23 +211,25 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { mutability: Mutability, ) -> Pointer { let alloc = Allocation::from_bytes(bytes, align, mutability); - self.allocate_raw_ptr(alloc, kind) + // We can `unwrap` since `alloc` contains no pointers. + self.allocate_raw_ptr(alloc, kind).unwrap() } + /// This can fail only of `alloc` contains relocations. pub fn allocate_raw_ptr( &mut self, alloc: Allocation, kind: MemoryKind, - ) -> Pointer { + ) -> InterpResult<'tcx, Pointer> { let id = self.tcx.reserve_alloc_id(); debug_assert_ne!( Some(kind), M::GLOBAL_KIND.map(MemoryKind::Machine), "dynamically allocating global memory" ); - let alloc = M::init_allocation_extra(self, id, Cow::Owned(alloc), Some(kind)); + let alloc = M::init_allocation_extra(self, id, Cow::Owned(alloc), Some(kind))?; self.memory.alloc_map.insert(id, (kind, alloc.into_owned())); - M::tag_alloc_base_pointer(self, Pointer::from(id)) + Ok(M::tag_alloc_base_pointer(self, Pointer::from(id))) } pub fn reallocate_ptr( @@ -510,13 +513,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { }; M::before_access_global(*self.tcx, &self.machine, id, alloc, def_id, is_write)?; // We got tcx memory. Let the machine initialize its "extra" stuff. - let alloc = M::init_allocation_extra( + M::init_allocation_extra( self, id, // always use the ID we got as input, not the "hidden" one. Cow::Borrowed(alloc.inner()), M::GLOBAL_KIND.map(MemoryKind::Machine), - ); - Ok(alloc) + ) } /// Gives raw access to the `Allocation`, without bounds or alignment checks. diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index fb4e17af49498..0893dd897e612 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -201,12 +201,12 @@ impl Allocation { impl Allocation { /// Convert Tag and add Extra fields - pub fn convert_tag_add_extra( + pub fn convert_tag_add_extra( self, cx: &impl HasDataLayout, extra: Extra, - mut tagger: impl FnMut(Pointer) -> Pointer, - ) -> Allocation { + mut tagger: impl FnMut(Pointer) -> Result, Err>, + ) -> Result, Err> { // Compute new pointer tags, which also adjusts the bytes. let mut bytes = self.bytes; let mut new_relocations = Vec::with_capacity(self.relocations.0.len()); @@ -217,19 +217,19 @@ impl Allocation { let ptr_bytes = &mut bytes[idx..idx + ptr_size]; let bits = read_target_uint(endian, ptr_bytes).unwrap(); let (ptr_tag, ptr_offset) = - tagger(Pointer::new(alloc_id, Size::from_bytes(bits))).into_parts(); + tagger(Pointer::new(alloc_id, Size::from_bytes(bits)))?.into_parts(); write_target_uint(endian, ptr_bytes, ptr_offset.bytes().into()).unwrap(); new_relocations.push((offset, ptr_tag)); } // Create allocation. - Allocation { + Ok(Allocation { bytes, relocations: Relocations::from_presorted(new_relocations), init_mask: self.init_mask, align: self.align, mutability: self.mutability, extra, - } + }) } } From 31476e70969fce766519682072da37a65995ccf7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 21 Jun 2022 19:08:48 +0900 Subject: [PATCH 4/7] Add a full regression test for #73727 Signed-off-by: Yuki Okushi --- ...-static-reference-array-const-param.min.stderr} | 2 +- ...sue-73727-static-reference-array-const-param.rs | 14 ++++++++++++++ .../static-reference-array-const-param.rs | 6 ------ 3 files changed, 15 insertions(+), 7 deletions(-) rename src/test/ui/const-generics/{min_const_generics/static-reference-array-const-param.stderr => issues/issue-73727-static-reference-array-const-param.min.stderr} (84%) create mode 100644 src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs delete mode 100644 src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr similarity index 84% rename from src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr rename to src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr index f30693221a513..0a7db62472a9f 100644 --- a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr +++ b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr @@ -1,5 +1,5 @@ error: `&'static [u32]` is forbidden as the type of a const generic parameter - --> $DIR/static-reference-array-const-param.rs:1:15 + --> $DIR/issue-73727-static-reference-array-const-param.rs:9:15 | LL | fn a() {} | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs new file mode 100644 index 0000000000000..f0d604835cbb6 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs @@ -0,0 +1,14 @@ +// Regression test for #73727 + +// revisions: full min +//[full]check-pass + +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +fn a() {} +//[min]~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter + +fn main() { + a::<{&[]}>(); +} diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs deleted file mode 100644 index 7518dc59e599c..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn a() {} -//~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter - -fn main() { - a::<{&[]}>(); -} From 67508f3714296ffb0cf9820e1c1ba46b082227a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Tue, 21 Jun 2022 13:42:34 +0200 Subject: [PATCH 5/7] Remove `#[doc(hidden)]` logic from `unused_attributes` lint --- compiler/rustc_passes/src/check_attr.rs | 76 +------------------ .../lint/unused/unused-attr-doc-hidden.fixed | 55 -------------- .../ui/lint/unused/unused-attr-doc-hidden.rs | 55 -------------- .../lint/unused/unused-attr-doc-hidden.stderr | 67 ---------------- 4 files changed, 2 insertions(+), 251 deletions(-) delete mode 100644 src/test/ui/lint/unused/unused-attr-doc-hidden.fixed delete mode 100644 src/test/ui/lint/unused/unused-attr-doc-hidden.rs delete mode 100644 src/test/ui/lint/unused/unused-attr-doc-hidden.stderr diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 4ef0f590a1f3d..536d45b2399b1 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -4,8 +4,7 @@ //! conflicts between multiple such attributes attached to the same //! item. -use rustc_ast::tokenstream::DelimSpan; -use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, MacArgs, MetaItemKind, NestedMetaItem}; +use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan}; use rustc_expand::base::resolve_path; @@ -899,68 +898,6 @@ impl CheckAttrVisitor<'_> { } } - /// Checks `#[doc(hidden)]` attributes. Returns `true` if valid. - fn check_doc_hidden( - &self, - attr: &Attribute, - meta_index: usize, - meta: &NestedMetaItem, - hir_id: HirId, - target: Target, - ) -> bool { - if let Target::AssocConst - | Target::AssocTy - | Target::Method(MethodKind::Trait { body: true }) = target - { - let parent_hir_id = self.tcx.hir().get_parent_item(hir_id); - let containing_item = self.tcx.hir().expect_item(parent_hir_id); - - if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = containing_item.kind { - let meta_items = attr.meta_item_list().unwrap(); - - let (span, replacement_span) = if meta_items.len() == 1 { - (attr.span, attr.span) - } else { - let meta_span = meta.span(); - ( - meta_span, - meta_span.until(match meta_items.get(meta_index + 1) { - Some(next_item) => next_item.span(), - None => match attr.get_normal_item().args { - MacArgs::Delimited(DelimSpan { close, .. }, ..) => close, - _ => unreachable!(), - }, - }), - ) - }; - - // FIXME: #[doc(hidden)] was previously erroneously allowed on trait impl items, - // so for backward compatibility only emit a warning and do not mark it as invalid. - self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, span, |lint| { - lint.build("`#[doc(hidden)]` is ignored on trait impl items") - .warn( - "this was previously accepted by the compiler but is \ - being phased out; it will become a hard error in \ - a future release!", - ) - .note( - "whether the impl item is `doc(hidden)` or not \ - entirely depends on the corresponding trait item", - ) - .span_suggestion( - replacement_span, - "remove this attribute", - "", - Applicability::MachineApplicable, - ) - .emit(); - }); - } - } - - true - } - /// Checks that an attribute is *not* used at the crate level. Returns `true` if valid. fn check_attr_not_crate_level( &self, @@ -1079,7 +1016,7 @@ impl CheckAttrVisitor<'_> { let mut is_valid = true; if let Some(mi) = attr.meta() && let Some(list) = mi.meta_item_list() { - for (meta_index, meta) in list.into_iter().enumerate() { + for meta in list { if let Some(i_meta) = meta.meta_item() { match i_meta.name_or_empty() { sym::alias @@ -1127,15 +1064,6 @@ impl CheckAttrVisitor<'_> { is_valid = false; } - sym::hidden if !self.check_doc_hidden(attr, - meta_index, - meta, - hir_id, - target, - ) => { - is_valid = false; - } - // no_default_passes: deprecated // passes: deprecated // plugins: removed, but rustdoc warns about it itself diff --git a/src/test/ui/lint/unused/unused-attr-doc-hidden.fixed b/src/test/ui/lint/unused/unused-attr-doc-hidden.fixed deleted file mode 100644 index 362ad55707a4a..0000000000000 --- a/src/test/ui/lint/unused/unused-attr-doc-hidden.fixed +++ /dev/null @@ -1,55 +0,0 @@ -#![feature(inherent_associated_types)] -#![allow(dead_code, incomplete_features)] -#![crate_type = "lib"] -#![deny(unused_attributes)] -// run-rustfix - -pub trait Trait { - type It; - const IT: (); - fn it0(); - fn it1(); - fn it2(); -} - -pub struct Implementor; - -impl Implementor { - #[doc(hidden)] // no error - type Inh = (); - - #[doc(hidden)] // no error - const INH: () = (); - - #[doc(hidden)] // no error - fn inh() {} -} - -impl Trait for Implementor { - - type It = (); - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - - const IT: () = (); - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc(alias = "aka")] - fn it0() {} - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc(alias = "this", )] - fn it1() {} - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc()] - fn it2() {} - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - //~| ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted -} diff --git a/src/test/ui/lint/unused/unused-attr-doc-hidden.rs b/src/test/ui/lint/unused/unused-attr-doc-hidden.rs deleted file mode 100644 index d493ed6dae206..0000000000000 --- a/src/test/ui/lint/unused/unused-attr-doc-hidden.rs +++ /dev/null @@ -1,55 +0,0 @@ -#![feature(inherent_associated_types)] -#![allow(dead_code, incomplete_features)] -#![crate_type = "lib"] -#![deny(unused_attributes)] -// run-rustfix - -pub trait Trait { - type It; - const IT: (); - fn it0(); - fn it1(); - fn it2(); -} - -pub struct Implementor; - -impl Implementor { - #[doc(hidden)] // no error - type Inh = (); - - #[doc(hidden)] // no error - const INH: () = (); - - #[doc(hidden)] // no error - fn inh() {} -} - -impl Trait for Implementor { - #[doc(hidden)] - type It = (); - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc(hidden)] - const IT: () = (); - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc(hidden, alias = "aka")] - fn it0() {} - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc(alias = "this", hidden,)] - fn it1() {} - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - - #[doc(hidden, hidden)] - fn it2() {} - //~^^ ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted - //~| ERROR `#[doc(hidden)]` is ignored - //~| WARNING this was previously accepted -} diff --git a/src/test/ui/lint/unused/unused-attr-doc-hidden.stderr b/src/test/ui/lint/unused/unused-attr-doc-hidden.stderr deleted file mode 100644 index f167bd460db3e..0000000000000 --- a/src/test/ui/lint/unused/unused-attr-doc-hidden.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error: `#[doc(hidden)]` is ignored on trait impl items - --> $DIR/unused-attr-doc-hidden.rs:29:5 - | -LL | #[doc(hidden)] - | ^^^^^^^^^^^^^^ help: remove this attribute - | -note: the lint level is defined here - --> $DIR/unused-attr-doc-hidden.rs:4:9 - | -LL | #![deny(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item - -error: `#[doc(hidden)]` is ignored on trait impl items - --> $DIR/unused-attr-doc-hidden.rs:34:5 - | -LL | #[doc(hidden)] - | ^^^^^^^^^^^^^^ help: remove this attribute - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item - -error: `#[doc(hidden)]` is ignored on trait impl items - --> $DIR/unused-attr-doc-hidden.rs:39:11 - | -LL | #[doc(hidden, alias = "aka")] - | ^^^^^^-- - | | - | help: remove this attribute - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item - -error: `#[doc(hidden)]` is ignored on trait impl items - --> $DIR/unused-attr-doc-hidden.rs:44:27 - | -LL | #[doc(alias = "this", hidden,)] - | ^^^^^^- - | | - | help: remove this attribute - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item - -error: `#[doc(hidden)]` is ignored on trait impl items - --> $DIR/unused-attr-doc-hidden.rs:49:11 - | -LL | #[doc(hidden, hidden)] - | ^^^^^^-- - | | - | help: remove this attribute - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item - -error: `#[doc(hidden)]` is ignored on trait impl items - --> $DIR/unused-attr-doc-hidden.rs:49:19 - | -LL | #[doc(hidden, hidden)] - | ^^^^^^ help: remove this attribute - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item - -error: aborting due to 6 previous errors - From b6290debedf28aef1af2b8408b49431ccd9c3328 Mon Sep 17 00:00:00 2001 From: Caio Date: Tue, 21 Jun 2022 09:33:14 -0300 Subject: [PATCH 6/7] Move some tests to more reasonable directories --- src/test/ui/{issues => associated-types}/issue-47139-2.rs | 0 src/test/ui/{issues => cast}/issue-10991.rs | 0 src/test/ui/{issues => cast}/issue-10991.stderr | 0 src/test/ui/{issues => codegen}/issue-28950.rs | 0 src/test/ui/{issues => codegen}/issue-63787.rs | 0 src/test/ui/{issues => deriving}/issue-6341.rs | 0 src/test/ui/{issues => imports}/issue-24883.rs | 0 src/test/ui/{issues => imports}/issue-68103.rs | 0 src/test/ui/{issues => inference}/issue-72690.rs | 0 src/test/ui/{issues => inference}/issue-72690.stderr | 0 src/test/ui/{issues => lint}/issue-35075.rs | 0 src/test/ui/{issues => lint}/issue-35075.stderr | 0 src/test/ui/{issues => macros}/issue-8851.rs | 0 .../ui/{issues => match}/issue-46920-byte-array-patterns.rs | 0 .../issue-27282-move-match-input-into-guard.rs | 0 .../issue-27282-move-match-input-into-guard.stderr | 0 .../ui/{issues => nll}/issue-27282-move-ref-mut-into-guard.rs | 0 .../{issues => nll}/issue-27282-move-ref-mut-into-guard.stderr | 0 .../issue-27282-mutate-before-diverging-arm-1.rs | 0 .../issue-27282-mutate-before-diverging-arm-1.stderr | 0 .../issue-27282-mutate-before-diverging-arm-2.rs | 0 .../issue-27282-mutate-before-diverging-arm-2.stderr | 0 .../issue-27282-mutate-before-diverging-arm-3.rs | 0 .../issue-27282-mutate-before-diverging-arm-3.stderr | 0 src/test/ui/{borrowck => nll}/issue-27282-mutation-in-guard.rs | 0 .../ui/{borrowck => nll}/issue-27282-mutation-in-guard.stderr | 0 .../{borrowck => nll}/issue-27282-reborrow-ref-mut-in-guard.rs | 0 .../issue-27282-reborrow-ref-mut-in-guard.stderr | 0 src/test/ui/{issues => nll}/issue-52057.rs | 0 src/test/ui/{issues => test-attrs}/issue-16597-empty.rs | 0 src/test/ui/{issues => test-attrs}/issue-16597.rs | 0 src/test/ui/{issues => traits}/issue-38033.rs | 0 src/test/ui/{issues => typeck}/issue-10401.rs | 0 src/test/ui/{issues => typeck}/issue-10401.stderr | 0 src/test/ui/{issues => unsafe}/issue-3080.mir.stderr | 0 src/test/ui/{issues => unsafe}/issue-3080.rs | 0 src/test/ui/{issues => unsafe}/issue-3080.thir.stderr | 0 src/test/ui/{issues => unsafe}/issue-47412.mir.stderr | 0 src/test/ui/{issues => unsafe}/issue-47412.rs | 0 src/test/ui/{issues => unsafe}/issue-47412.thir.stderr | 0 src/tools/tidy/src/ui_tests.rs | 2 +- 41 files changed, 1 insertion(+), 1 deletion(-) rename src/test/ui/{issues => associated-types}/issue-47139-2.rs (100%) rename src/test/ui/{issues => cast}/issue-10991.rs (100%) rename src/test/ui/{issues => cast}/issue-10991.stderr (100%) rename src/test/ui/{issues => codegen}/issue-28950.rs (100%) rename src/test/ui/{issues => codegen}/issue-63787.rs (100%) rename src/test/ui/{issues => deriving}/issue-6341.rs (100%) rename src/test/ui/{issues => imports}/issue-24883.rs (100%) rename src/test/ui/{issues => imports}/issue-68103.rs (100%) rename src/test/ui/{issues => inference}/issue-72690.rs (100%) rename src/test/ui/{issues => inference}/issue-72690.stderr (100%) rename src/test/ui/{issues => lint}/issue-35075.rs (100%) rename src/test/ui/{issues => lint}/issue-35075.stderr (100%) rename src/test/ui/{issues => macros}/issue-8851.rs (100%) rename src/test/ui/{issues => match}/issue-46920-byte-array-patterns.rs (100%) rename src/test/ui/{borrowck => nll}/issue-27282-move-match-input-into-guard.rs (100%) rename src/test/ui/{borrowck => nll}/issue-27282-move-match-input-into-guard.stderr (100%) rename src/test/ui/{issues => nll}/issue-27282-move-ref-mut-into-guard.rs (100%) rename src/test/ui/{issues => nll}/issue-27282-move-ref-mut-into-guard.stderr (100%) rename src/test/ui/{issues => nll}/issue-27282-mutate-before-diverging-arm-1.rs (100%) rename src/test/ui/{issues => nll}/issue-27282-mutate-before-diverging-arm-1.stderr (100%) rename src/test/ui/{borrowck => nll}/issue-27282-mutate-before-diverging-arm-2.rs (100%) rename src/test/ui/{borrowck => nll}/issue-27282-mutate-before-diverging-arm-2.stderr (100%) rename src/test/ui/{issues => nll}/issue-27282-mutate-before-diverging-arm-3.rs (100%) rename src/test/ui/{issues => nll}/issue-27282-mutate-before-diverging-arm-3.stderr (100%) rename src/test/ui/{borrowck => nll}/issue-27282-mutation-in-guard.rs (100%) rename src/test/ui/{borrowck => nll}/issue-27282-mutation-in-guard.stderr (100%) rename src/test/ui/{borrowck => nll}/issue-27282-reborrow-ref-mut-in-guard.rs (100%) rename src/test/ui/{borrowck => nll}/issue-27282-reborrow-ref-mut-in-guard.stderr (100%) rename src/test/ui/{issues => nll}/issue-52057.rs (100%) rename src/test/ui/{issues => test-attrs}/issue-16597-empty.rs (100%) rename src/test/ui/{issues => test-attrs}/issue-16597.rs (100%) rename src/test/ui/{issues => traits}/issue-38033.rs (100%) rename src/test/ui/{issues => typeck}/issue-10401.rs (100%) rename src/test/ui/{issues => typeck}/issue-10401.stderr (100%) rename src/test/ui/{issues => unsafe}/issue-3080.mir.stderr (100%) rename src/test/ui/{issues => unsafe}/issue-3080.rs (100%) rename src/test/ui/{issues => unsafe}/issue-3080.thir.stderr (100%) rename src/test/ui/{issues => unsafe}/issue-47412.mir.stderr (100%) rename src/test/ui/{issues => unsafe}/issue-47412.rs (100%) rename src/test/ui/{issues => unsafe}/issue-47412.thir.stderr (100%) diff --git a/src/test/ui/issues/issue-47139-2.rs b/src/test/ui/associated-types/issue-47139-2.rs similarity index 100% rename from src/test/ui/issues/issue-47139-2.rs rename to src/test/ui/associated-types/issue-47139-2.rs diff --git a/src/test/ui/issues/issue-10991.rs b/src/test/ui/cast/issue-10991.rs similarity index 100% rename from src/test/ui/issues/issue-10991.rs rename to src/test/ui/cast/issue-10991.rs diff --git a/src/test/ui/issues/issue-10991.stderr b/src/test/ui/cast/issue-10991.stderr similarity index 100% rename from src/test/ui/issues/issue-10991.stderr rename to src/test/ui/cast/issue-10991.stderr diff --git a/src/test/ui/issues/issue-28950.rs b/src/test/ui/codegen/issue-28950.rs similarity index 100% rename from src/test/ui/issues/issue-28950.rs rename to src/test/ui/codegen/issue-28950.rs diff --git a/src/test/ui/issues/issue-63787.rs b/src/test/ui/codegen/issue-63787.rs similarity index 100% rename from src/test/ui/issues/issue-63787.rs rename to src/test/ui/codegen/issue-63787.rs diff --git a/src/test/ui/issues/issue-6341.rs b/src/test/ui/deriving/issue-6341.rs similarity index 100% rename from src/test/ui/issues/issue-6341.rs rename to src/test/ui/deriving/issue-6341.rs diff --git a/src/test/ui/issues/issue-24883.rs b/src/test/ui/imports/issue-24883.rs similarity index 100% rename from src/test/ui/issues/issue-24883.rs rename to src/test/ui/imports/issue-24883.rs diff --git a/src/test/ui/issues/issue-68103.rs b/src/test/ui/imports/issue-68103.rs similarity index 100% rename from src/test/ui/issues/issue-68103.rs rename to src/test/ui/imports/issue-68103.rs diff --git a/src/test/ui/issues/issue-72690.rs b/src/test/ui/inference/issue-72690.rs similarity index 100% rename from src/test/ui/issues/issue-72690.rs rename to src/test/ui/inference/issue-72690.rs diff --git a/src/test/ui/issues/issue-72690.stderr b/src/test/ui/inference/issue-72690.stderr similarity index 100% rename from src/test/ui/issues/issue-72690.stderr rename to src/test/ui/inference/issue-72690.stderr diff --git a/src/test/ui/issues/issue-35075.rs b/src/test/ui/lint/issue-35075.rs similarity index 100% rename from src/test/ui/issues/issue-35075.rs rename to src/test/ui/lint/issue-35075.rs diff --git a/src/test/ui/issues/issue-35075.stderr b/src/test/ui/lint/issue-35075.stderr similarity index 100% rename from src/test/ui/issues/issue-35075.stderr rename to src/test/ui/lint/issue-35075.stderr diff --git a/src/test/ui/issues/issue-8851.rs b/src/test/ui/macros/issue-8851.rs similarity index 100% rename from src/test/ui/issues/issue-8851.rs rename to src/test/ui/macros/issue-8851.rs diff --git a/src/test/ui/issues/issue-46920-byte-array-patterns.rs b/src/test/ui/match/issue-46920-byte-array-patterns.rs similarity index 100% rename from src/test/ui/issues/issue-46920-byte-array-patterns.rs rename to src/test/ui/match/issue-46920-byte-array-patterns.rs diff --git a/src/test/ui/borrowck/issue-27282-move-match-input-into-guard.rs b/src/test/ui/nll/issue-27282-move-match-input-into-guard.rs similarity index 100% rename from src/test/ui/borrowck/issue-27282-move-match-input-into-guard.rs rename to src/test/ui/nll/issue-27282-move-match-input-into-guard.rs diff --git a/src/test/ui/borrowck/issue-27282-move-match-input-into-guard.stderr b/src/test/ui/nll/issue-27282-move-match-input-into-guard.stderr similarity index 100% rename from src/test/ui/borrowck/issue-27282-move-match-input-into-guard.stderr rename to src/test/ui/nll/issue-27282-move-match-input-into-guard.stderr diff --git a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs b/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs similarity index 100% rename from src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs rename to src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs diff --git a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr b/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.stderr similarity index 100% rename from src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr rename to src/test/ui/nll/issue-27282-move-ref-mut-into-guard.stderr diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs b/src/test/ui/nll/issue-27282-mutate-before-diverging-arm-1.rs similarity index 100% rename from src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs rename to src/test/ui/nll/issue-27282-mutate-before-diverging-arm-1.rs diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr b/src/test/ui/nll/issue-27282-mutate-before-diverging-arm-1.stderr similarity index 100% rename from src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr rename to src/test/ui/nll/issue-27282-mutate-before-diverging-arm-1.stderr diff --git a/src/test/ui/borrowck/issue-27282-mutate-before-diverging-arm-2.rs b/src/test/ui/nll/issue-27282-mutate-before-diverging-arm-2.rs similarity index 100% rename from src/test/ui/borrowck/issue-27282-mutate-before-diverging-arm-2.rs rename to src/test/ui/nll/issue-27282-mutate-before-diverging-arm-2.rs diff --git a/src/test/ui/borrowck/issue-27282-mutate-before-diverging-arm-2.stderr b/src/test/ui/nll/issue-27282-mutate-before-diverging-arm-2.stderr similarity index 100% rename from src/test/ui/borrowck/issue-27282-mutate-before-diverging-arm-2.stderr rename to src/test/ui/nll/issue-27282-mutate-before-diverging-arm-2.stderr diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs b/src/test/ui/nll/issue-27282-mutate-before-diverging-arm-3.rs similarity index 100% rename from src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs rename to src/test/ui/nll/issue-27282-mutate-before-diverging-arm-3.rs diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.stderr b/src/test/ui/nll/issue-27282-mutate-before-diverging-arm-3.stderr similarity index 100% rename from src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.stderr rename to src/test/ui/nll/issue-27282-mutate-before-diverging-arm-3.stderr diff --git a/src/test/ui/borrowck/issue-27282-mutation-in-guard.rs b/src/test/ui/nll/issue-27282-mutation-in-guard.rs similarity index 100% rename from src/test/ui/borrowck/issue-27282-mutation-in-guard.rs rename to src/test/ui/nll/issue-27282-mutation-in-guard.rs diff --git a/src/test/ui/borrowck/issue-27282-mutation-in-guard.stderr b/src/test/ui/nll/issue-27282-mutation-in-guard.stderr similarity index 100% rename from src/test/ui/borrowck/issue-27282-mutation-in-guard.stderr rename to src/test/ui/nll/issue-27282-mutation-in-guard.stderr diff --git a/src/test/ui/borrowck/issue-27282-reborrow-ref-mut-in-guard.rs b/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs similarity index 100% rename from src/test/ui/borrowck/issue-27282-reborrow-ref-mut-in-guard.rs rename to src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs diff --git a/src/test/ui/borrowck/issue-27282-reborrow-ref-mut-in-guard.stderr b/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr similarity index 100% rename from src/test/ui/borrowck/issue-27282-reborrow-ref-mut-in-guard.stderr rename to src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr diff --git a/src/test/ui/issues/issue-52057.rs b/src/test/ui/nll/issue-52057.rs similarity index 100% rename from src/test/ui/issues/issue-52057.rs rename to src/test/ui/nll/issue-52057.rs diff --git a/src/test/ui/issues/issue-16597-empty.rs b/src/test/ui/test-attrs/issue-16597-empty.rs similarity index 100% rename from src/test/ui/issues/issue-16597-empty.rs rename to src/test/ui/test-attrs/issue-16597-empty.rs diff --git a/src/test/ui/issues/issue-16597.rs b/src/test/ui/test-attrs/issue-16597.rs similarity index 100% rename from src/test/ui/issues/issue-16597.rs rename to src/test/ui/test-attrs/issue-16597.rs diff --git a/src/test/ui/issues/issue-38033.rs b/src/test/ui/traits/issue-38033.rs similarity index 100% rename from src/test/ui/issues/issue-38033.rs rename to src/test/ui/traits/issue-38033.rs diff --git a/src/test/ui/issues/issue-10401.rs b/src/test/ui/typeck/issue-10401.rs similarity index 100% rename from src/test/ui/issues/issue-10401.rs rename to src/test/ui/typeck/issue-10401.rs diff --git a/src/test/ui/issues/issue-10401.stderr b/src/test/ui/typeck/issue-10401.stderr similarity index 100% rename from src/test/ui/issues/issue-10401.stderr rename to src/test/ui/typeck/issue-10401.stderr diff --git a/src/test/ui/issues/issue-3080.mir.stderr b/src/test/ui/unsafe/issue-3080.mir.stderr similarity index 100% rename from src/test/ui/issues/issue-3080.mir.stderr rename to src/test/ui/unsafe/issue-3080.mir.stderr diff --git a/src/test/ui/issues/issue-3080.rs b/src/test/ui/unsafe/issue-3080.rs similarity index 100% rename from src/test/ui/issues/issue-3080.rs rename to src/test/ui/unsafe/issue-3080.rs diff --git a/src/test/ui/issues/issue-3080.thir.stderr b/src/test/ui/unsafe/issue-3080.thir.stderr similarity index 100% rename from src/test/ui/issues/issue-3080.thir.stderr rename to src/test/ui/unsafe/issue-3080.thir.stderr diff --git a/src/test/ui/issues/issue-47412.mir.stderr b/src/test/ui/unsafe/issue-47412.mir.stderr similarity index 100% rename from src/test/ui/issues/issue-47412.mir.stderr rename to src/test/ui/unsafe/issue-47412.mir.stderr diff --git a/src/test/ui/issues/issue-47412.rs b/src/test/ui/unsafe/issue-47412.rs similarity index 100% rename from src/test/ui/issues/issue-47412.rs rename to src/test/ui/unsafe/issue-47412.rs diff --git a/src/test/ui/issues/issue-47412.thir.stderr b/src/test/ui/unsafe/issue-47412.thir.stderr similarity index 100% rename from src/test/ui/issues/issue-47412.thir.stderr rename to src/test/ui/unsafe/issue-47412.thir.stderr diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index f59121181d29b..8ec5c33249333 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -8,7 +8,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. const ROOT_ENTRY_LIMIT: usize = 968; -const ISSUES_ENTRY_LIMIT: usize = 2179; +const ISSUES_ENTRY_LIMIT: usize = 2147; fn check_entries(path: &Path, bad: &mut bool) { let dirs = walkdir::WalkDir::new(&path.join("test/ui")) From 5ed149504180e04ba81e308b07c2d33af1b7af49 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 21 Jun 2022 12:40:32 -0300 Subject: [PATCH 7/7] This comment is out dated and misleading Arms are about TAIT and RPIT, as the variants clearly show. --- compiler/rustc_resolve/src/late/lifetimes.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index 447f4174c10d5..55574b8360739 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -846,8 +846,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // the opaque_ty generics let opaque_ty = self.tcx.hir().item(item_id); let (generics, bounds) = match opaque_ty.kind { - // Named opaque `impl Trait` types are reached via `TyKind::Path`. - // This arm is for `impl Trait` in the types of statics, constants and locals. hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::TyAlias, .. @@ -866,7 +864,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { return; } - // RPIT (return position impl trait) hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..), ref generics,