diff --git a/compiler/rustc_const_eval/src/const_eval/type_info.rs b/compiler/rustc_const_eval/src/const_eval/type_info.rs index 5d37db06d76ac..3c6064d3f87d3 100644 --- a/compiler/rustc_const_eval/src/const_eval/type_info.rs +++ b/compiler/rustc_const_eval/src/const_eval/type_info.rs @@ -1,4 +1,5 @@ use rustc_abi::FieldIdx; +use rustc_ast::Mutability; use rustc_hir::LangItem; use rustc_middle::mir::interpret::{CtfeProvenance, Scalar}; use rustc_middle::span_bug; @@ -103,12 +104,19 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> { let (variant, _variant_place) = downcast(sym::Str)?; variant } + ty::Ref(_, ty, mutability) => { + let (variant, variant_place) = downcast(sym::Reference)?; + let reference_place = + self.project_field(&variant_place, FieldIdx::ZERO)?; + self.write_reference_type_info(reference_place, *ty, *mutability)?; + + variant + } ty::Adt(_, _) | ty::Foreign(_) | ty::Pat(_, _) | ty::Slice(_) | ty::RawPtr(..) - | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(..) | ty::UnsafeBinder(..) @@ -279,4 +287,29 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> { } interp_ok(()) } + + pub(crate) fn write_reference_type_info( + &mut self, + place: impl Writeable<'tcx, CtfeProvenance>, + ty: Ty<'tcx>, + mutability: Mutability, + ) -> InterpResult<'tcx> { + // Iterate over all fields of `type_info::Reference`. + for (field_idx, field) in + place.layout().ty.ty_adt_def().unwrap().non_enum_variant().fields.iter_enumerated() + { + let field_place = self.project_field(&place, field_idx)?; + + match field.name { + // Write the `TypeId` of the reference's inner type to the `ty` field. + sym::pointee => self.write_type_id(ty, &field_place)?, + // Write the boolean representing the reference's mutability to the `mutable` field. + sym::mutable => { + self.write_scalar(Scalar::from_bool(mutability.is_mut()), &field_place)? + } + other => span_bug!(self.tcx.def_span(field.did), "unimplemented field {other}"), + } + } + interp_ok(()) + } } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 51920db8cd79e..f0576002354dc 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -343,6 +343,7 @@ symbols! { RefCell, RefCellRef, RefCellRefMut, + Reference, Relaxed, Release, Result, @@ -1521,6 +1522,7 @@ symbols! { must_use, mut_preserve_binding_mode_2024, mut_ref, + mutable, naked, naked_asm, naked_functions, diff --git a/library/core/src/mem/type_info.rs b/library/core/src/mem/type_info.rs index 2e3bdb45ce052..ee647ef55840a 100644 --- a/library/core/src/mem/type_info.rs +++ b/library/core/src/mem/type_info.rs @@ -55,6 +55,8 @@ pub enum TypeKind { Float(Float), /// String slice type. Str(Str), + /// References. + Reference(Reference), /// FIXME(#146922): add all the common types Other, } @@ -133,3 +135,14 @@ pub struct Float { pub struct Str { // No additional information to provide for now. } + +/// Compile-time type information about references. +#[derive(Debug)] +#[non_exhaustive] +#[unstable(feature = "type_info", issue = "146922")] +pub struct Reference { + /// The type of the value being referred to. + pub pointee: TypeId, + /// Whether this reference is mutable or not. + pub mutable: bool, +} diff --git a/library/coretests/tests/mem/type_info.rs b/library/coretests/tests/mem/type_info.rs index fc13637a5574c..7df632981ce1b 100644 --- a/library/coretests/tests/mem/type_info.rs +++ b/library/coretests/tests/mem/type_info.rs @@ -1,4 +1,4 @@ -use std::any::TypeId; +use std::any::{Any, TypeId}; use std::mem::type_info::{Type, TypeKind}; #[test] @@ -95,3 +95,33 @@ fn test_primitives() { let Type { kind: Str(_ty), size, .. } = (const { Type::of::() }) else { panic!() }; assert_eq!(size, None); } + +#[test] +fn test_references() { + // Immutable reference. + match const { Type::of::<&u8>() }.kind { + TypeKind::Reference(reference) => { + assert_eq!(reference.pointee, TypeId::of::()); + assert!(!reference.mutable); + } + _ => unreachable!(), + } + + // Mutable pointer. + match const { Type::of::<&mut u64>() }.kind { + TypeKind::Reference(reference) => { + assert_eq!(reference.pointee, TypeId::of::()); + assert!(reference.mutable); + } + _ => unreachable!(), + } + + // Wide pointer. + match const { Type::of::<&dyn Any>() }.kind { + TypeKind::Reference(reference) => { + assert_eq!(reference.pointee, TypeId::of::()); + assert!(!reference.mutable); + } + _ => unreachable!(), + } +} diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index b86582807f722..d8e8f65caa98b 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -932,6 +932,13 @@ impl Step for Rustc { // see https://github.com/rust-lang/rust/pull/122066#issuecomment-1983049222 // If there is any bug, please comment out the next line. cargo.rustdocflag("--generate-link-to-definition"); + // FIXME: Currently, `--generate-macro-expansion` option is buggy in `beta` rustdoc. To + // allow CI to pass, we only enable the option in stage 2 and higher. + // cfg(bootstrap) + // ^ Adding this so it's not forgotten when the new release is done. + if builder.top_stage > 1 { + cargo.rustdocflag("--generate-macro-expansion"); + } compile::rustc_cargo(builder, &mut cargo, target, &build_compiler, &self.crates); cargo.arg("-Zskip-rustdoc-fingerprint"); diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index debea4fc0cec6..018e20b76dc83 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -7,7 +7,6 @@ use std::fmt::Display; use std::mem; use std::ops::Range; -use rustc_ast::attr::AttributeExt; use rustc_ast::util::comments::may_have_doc_links; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; @@ -1062,10 +1061,11 @@ fn preprocessed_markdown_links(s: &str) -> Vec { impl LinkCollector<'_, '_> { #[instrument(level = "debug", skip_all)] fn resolve_links(&mut self, item: &Item) { + let tcx = self.cx.tcx; if !self.cx.document_private() && let Some(def_id) = item.item_id.as_def_id() && let Some(def_id) = def_id.as_local() - && !self.cx.tcx.effective_visibilities(()).is_exported(def_id) + && !tcx.effective_visibilities(()).is_exported(def_id) && !has_primitive_or_keyword_or_attribute_docs(&item.attrs.other_attrs) { // Skip link resolution for non-exported items. @@ -1073,9 +1073,9 @@ impl LinkCollector<'_, '_> { } let mut insert_links = |item_id, doc: &str| { - let module_id = match self.cx.tcx.def_kind(item_id) { - DefKind::Mod if item.inner_docs(self.cx.tcx) => item_id, - _ => find_nearest_parent_module(self.cx.tcx, item_id).unwrap(), + let module_id = match tcx.def_kind(item_id) { + DefKind::Mod if item.inner_docs(tcx) => item_id, + _ => find_nearest_parent_module(tcx, item_id).unwrap(), }; for md_link in preprocessed_markdown_links(&doc) { let link = self.resolve_link(&doc, item, item_id, module_id, &md_link); @@ -1108,7 +1108,14 @@ impl LinkCollector<'_, '_> { // Also resolve links in the note text of `#[deprecated]`. for attr in &item.attrs.other_attrs { - let Some(note_sym) = attr.deprecation_note() else { continue }; + let rustc_hir::Attribute::Parsed(rustc_hir::attrs::AttributeKind::Deprecation { + span, + deprecation, + }) = attr + else { + continue; + }; + let Some(note_sym) = deprecation.note else { continue }; let note = note_sym.as_str(); if !may_have_doc_links(note) { @@ -1116,7 +1123,18 @@ impl LinkCollector<'_, '_> { } debug!("deprecated_note={note}"); - insert_links(item.item_id.expect_def_id(), note) + // When resolving an intra-doc link inside a deprecation note that is on an inlined + // `use` statement, we need to use the `def_id` of the `use` statement, not the + // inlined item. + // + let item_id = if let Some(inline_stmt_id) = item.inline_stmt_id + && item.span(tcx).is_none_or(|item_span| !item_span.inner().contains(*span)) + { + inline_stmt_id.to_def_id() + } else { + item.item_id.expect_def_id() + }; + insert_links(item_id, note) } } diff --git a/tests/mir-opt/unreachable.rs b/tests/mir-opt/unreachable.rs index f7f4815ae7ce1..afab1291fc3df 100644 --- a/tests/mir-opt/unreachable.rs +++ b/tests/mir-opt/unreachable.rs @@ -47,10 +47,11 @@ fn as_match() { // CHECK: bb1: { // CHECK: [[eq:_.*]] = Ne({{.*}}, const 1_isize); // CHECK-NEXT: assume(move [[eq]]); - // CHECK-NEXT: goto -> bb2; - // CHECK: bb2: { + // CHECK-NEXT: goto -> [[return:bb.*]]; + // CHECK: [[return]]: { + // CHECK-NOT: {{bb.*}}: { // CHECK: return; - // CHECK: bb3: { + // CHECK: {{bb.*}}: { // CHECK-NEXT: unreachable; match empty() { Some(_x) => match _x {}, diff --git a/tests/mir-opt/unreachable_enum_branching.rs b/tests/mir-opt/unreachable_enum_branching.rs index 7647f9bf0779a..0f6656f4168ec 100644 --- a/tests/mir-opt/unreachable_enum_branching.rs +++ b/tests/mir-opt/unreachable_enum_branching.rs @@ -49,7 +49,7 @@ struct Plop { fn simple() { // CHECK-LABEL: fn simple( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb1, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: {{bb.*}}, otherwise: [[unreachable]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test1::C { @@ -63,7 +63,7 @@ fn simple() { fn custom_discriminant() { // CHECK-LABEL: fn custom_discriminant( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [4: bb3, 5: bb2, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [4: {{bb.*}}, 5: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test2::D { @@ -76,7 +76,7 @@ fn custom_discriminant() { fn otherwise_t1() { // CHECK-LABEL: fn otherwise_t1( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: bb5, 1: bb5, 2: bb1, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, 2: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test1::C { @@ -90,7 +90,7 @@ fn otherwise_t1() { fn otherwise_t2() { // CHECK-LABEL: fn otherwise_t2( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [4: bb2, 5: bb1, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [4: {{bb.*}}, 5: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test2::D { diff --git a/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs b/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs new file mode 100644 index 0000000000000..99415a9a2fd4a --- /dev/null +++ b/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs @@ -0,0 +1,11 @@ +// This test ensures that the intra-doc link in `deprecated` note is resolved at the correct +// location (ie in the current crate and not in the reexported item's location/crate) and +// therefore doesn't crash. +// +// This is a regression test for . + +#![crate_name = "foo"] + +#[deprecated(note = "use [`std::mem::forget`]")] +#[doc(inline)] +pub use std::mem::drop; diff --git a/tests/ui/closures/2229_closure_analysis/capture-enums.rs b/tests/ui/closures/2229_closure_analysis/capture-enums.rs index 4c600ccdaa438..36b98351854bf 100644 --- a/tests/ui/closures/2229_closure_analysis/capture-enums.rs +++ b/tests/ui/closures/2229_closure_analysis/capture-enums.rs @@ -1,6 +1,7 @@ //@ edition:2021 #![feature(rustc_attrs)] +#![feature(stmt_expr_attributes)] enum Info { Point(i32, i32, String), @@ -14,9 +15,6 @@ fn multi_variant_enum() { let meta = Info::Meta("meta".into(), vec); let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 - //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date || { //~^ ERROR First Pass analysis includes: //~| ERROR Min Capture analysis includes: @@ -48,9 +46,6 @@ fn single_variant_enum() { let point = SingleVariant::Point(10, -10, "1".into()); let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 - //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date || { //~^ ERROR First Pass analysis includes: //~| ERROR Min Capture analysis includes: diff --git a/tests/ui/closures/2229_closure_analysis/capture-enums.stderr b/tests/ui/closures/2229_closure_analysis/capture-enums.stderr index b62384ffe12e0..2f49c8668f85c 100644 --- a/tests/ui/closures/2229_closure_analysis/capture-enums.stderr +++ b/tests/ui/closures/2229_closure_analysis/capture-enums.stderr @@ -1,25 +1,5 @@ -error[E0658]: attributes on expressions are experimental - --> $DIR/capture-enums.rs:16:13 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: attributes on expressions are experimental - --> $DIR/capture-enums.rs:50:13 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - error: First Pass analysis includes: - --> $DIR/capture-enums.rs:20:5 + --> $DIR/capture-enums.rs:18:5 | LL | / || { LL | | @@ -30,38 +10,38 @@ LL | | }; | |_____^ | note: Capturing point[] -> Immutable - --> $DIR/capture-enums.rs:23:41 + --> $DIR/capture-enums.rs:21:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ note: Capturing point[] -> Immutable - --> $DIR/capture-enums.rs:23:41 + --> $DIR/capture-enums.rs:21:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ note: Capturing point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:23:41 + --> $DIR/capture-enums.rs:21:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ note: Capturing meta[] -> Immutable - --> $DIR/capture-enums.rs:31:35 + --> $DIR/capture-enums.rs:29:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ note: Capturing meta[] -> Immutable - --> $DIR/capture-enums.rs:31:35 + --> $DIR/capture-enums.rs:29:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ note: Capturing meta[(1, 1)] -> ByValue - --> $DIR/capture-enums.rs:31:35 + --> $DIR/capture-enums.rs:29:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ error: Min Capture analysis includes: - --> $DIR/capture-enums.rs:20:5 + --> $DIR/capture-enums.rs:18:5 | LL | / || { LL | | @@ -72,18 +52,18 @@ LL | | }; | |_____^ | note: Min Capture point[] -> ByValue - --> $DIR/capture-enums.rs:23:41 + --> $DIR/capture-enums.rs:21:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ note: Min Capture meta[] -> ByValue - --> $DIR/capture-enums.rs:31:35 + --> $DIR/capture-enums.rs:29:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ error: First Pass analysis includes: - --> $DIR/capture-enums.rs:54:5 + --> $DIR/capture-enums.rs:49:5 | LL | / || { LL | | @@ -95,13 +75,13 @@ LL | | }; | |_____^ | note: Capturing point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:57:47 + --> $DIR/capture-enums.rs:52:47 | LL | let SingleVariant::Point(_, _, str) = point; | ^^^^^ error: Min Capture analysis includes: - --> $DIR/capture-enums.rs:54:5 + --> $DIR/capture-enums.rs:49:5 | LL | / || { LL | | @@ -113,11 +93,10 @@ LL | | }; | |_____^ | note: Min Capture point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:57:47 + --> $DIR/capture-enums.rs:52:47 | LL | let SingleVariant::Point(_, _, str) = point; | ^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs b/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs index a3b19708899a0..81013e5b2cd16 100644 --- a/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs +++ b/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs @@ -34,4 +34,82 @@ fn edge_case_if() { _b(); } +struct Unit; + +enum TSingle { + A(u32, u32), +} + +enum SSingle { + A { a: u32, b: u32 }, +} + +struct TStruct(u32, u32); +struct SStruct { a: u32, b: u32 } + + +// Destructuring a unit struct should not capture it +fn match_unit_struct(mut x: (Unit, u32)) { + let r = &mut x.0; + let _ = || { + let (Unit, a) = x; + a + }; + + let _ = *r; +} + +// The same is true for an equivalent enum +fn match_unit_enum(mut x: (SingleVariant, u32)) { + let r = &mut x.0; + let _ = || { + let (SingleVariant::A, a) = x; + a + }; + + let _ = *r; +} + +// More generally, destructuring a struct should only capture the fields being touched +fn match_struct(mut x: SStruct) { + let r = &mut x.a; + let _ = || { + let SStruct { b, .. } = x; + b + }; + + let _ = *r; +} + +fn match_tuple_struct(mut x: TStruct) { + let r = &mut x.0; + let _ = || { + let TStruct(_, a) = x; + a + }; + + let _ = *r; +} + +// The same is true for an equivalent enum as well +fn match_singleton(mut x: SSingle) { + let SSingle::A { a: ref mut r, .. } = x; + let _ = || { + let SSingle::A { b, .. } = x; + b + }; + + let _ = *r; +} + +fn match_tuple_singleton(mut x: TSingle) { + let TSingle::A(ref mut r, _) = x; + let _ = || { + let TSingle::A(_, a) = x; + a + }; + + let _ = *r; +} + fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs index 3225558271812..5b7259c6c2cc6 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs @@ -10,6 +10,8 @@ // Ignore non_exhaustive in the same crate #[non_exhaustive] enum L1 { A, B } + +#[non_exhaustive] enum L2 { C } extern crate match_non_exhaustive_lib; diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index 85426dd9a5ea6..99d33b05429e8 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `L1::B` not covered - --> $DIR/non-exhaustive-match.rs:26:25 + --> $DIR/non-exhaustive-match.rs:28:25 | LL | let _b = || { match l1 { L1::A => () } }; | ^^ pattern `L1::B` not covered @@ -16,7 +16,7 @@ LL | let _b = || { match l1 { L1::A => (), L1::B => todo!() } }; | ++++++++++++++++++ error[E0004]: non-exhaustive patterns: type `E1` is non-empty - --> $DIR/non-exhaustive-match.rs:37:25 + --> $DIR/non-exhaustive-match.rs:39:25 | LL | let _d = || { match e1 {} }; | ^^ @@ -35,7 +35,7 @@ LL ~ } }; | error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/non-exhaustive-match.rs:39:25 + --> $DIR/non-exhaustive-match.rs:41:25 | LL | let _e = || { match e2 { E2::A => (), E2::B => () } }; | ^^ pattern `_` not covered @@ -53,7 +53,7 @@ LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; | ++++++++++++++ error[E0505]: cannot move out of `e3` because it is borrowed - --> $DIR/non-exhaustive-match.rs:46:22 + --> $DIR/non-exhaustive-match.rs:48:22 | LL | let _g = || { match e3 { E3::C => (), _ => () } }; | -- -- borrow occurs due to use in closure diff --git a/tests/ui/closures/or-patterns-issue-137467.rs b/tests/ui/closures/or-patterns-issue-137467.rs index 5a1e84e1c9a0d..de2a4beeaf9d1 100644 --- a/tests/ui/closures/or-patterns-issue-137467.rs +++ b/tests/ui/closures/or-patterns-issue-137467.rs @@ -40,30 +40,6 @@ fn match_unit_variant(x: (Choice, u32, u32)) { }; } -struct Unit; - -fn match_unit_struct(mut x: (Unit, u32)) { - let r = &mut x.0; - let _ = || { - let (Unit, a) = x; - a - }; - - let _ = *r; -} - -enum Also { Unit } - -fn match_unit_enum(mut x: (Also, u32)) { - let r = &mut x.0; - let _ = || { - let (Also::Unit, a) = x; - a - }; - - let _ = *r; -} - enum TEnum { A(u32), B(u32), @@ -99,46 +75,6 @@ enum SSingle { struct TStruct(u32, u32); struct SStruct { a: u32, b: u32 } -fn match_struct(mut x: SStruct) { - let r = &mut x.a; - let _ = || { - let SStruct { b, .. } = x; - b - }; - - let _ = *r; -} - -fn match_tuple_struct(mut x: TStruct) { - let r = &mut x.0; - let _ = || { - let TStruct(_, a) = x; - a - }; - - let _ = *r; -} - -fn match_singleton(mut x: SSingle) { - let SSingle::A { a: ref mut r, .. } = x; - let _ = || { - let SSingle::A { b, .. } = x; - b - }; - - let _ = *r; -} - -fn match_tuple_singleton(mut x: TSingle) { - let TSingle::A(ref mut r, _) = x; - let _ = || { - let TSingle::A(_, a) = x; - a - }; - - let _ = *r; -} - fn match_slice(x: (&[u32], u32, u32)) { let _ = || { let (([], a, _) | ([_, ..], _, a)) = x; diff --git a/tests/ui/issues/issue-16683.rs b/tests/ui/lifetimes/elided-self-lifetime-in-trait-fn.rs similarity index 68% rename from tests/ui/issues/issue-16683.rs rename to tests/ui/lifetimes/elided-self-lifetime-in-trait-fn.rs index 72fa21bddd186..5ac39c6f5d9bf 100644 --- a/tests/ui/issues/issue-16683.rs +++ b/tests/ui/lifetimes/elided-self-lifetime-in-trait-fn.rs @@ -1,3 +1,4 @@ +//! regression test for trait T<'a> { fn a(&'a self) -> &'a bool; fn b(&self) { diff --git a/tests/ui/issues/issue-16683.stderr b/tests/ui/lifetimes/elided-self-lifetime-in-trait-fn.stderr similarity index 87% rename from tests/ui/issues/issue-16683.stderr rename to tests/ui/lifetimes/elided-self-lifetime-in-trait-fn.stderr index 39b22ed1f1568..383afaf782f9a 100644 --- a/tests/ui/issues/issue-16683.stderr +++ b/tests/ui/lifetimes/elided-self-lifetime-in-trait-fn.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-16683.rs:4:9 + --> $DIR/elided-self-lifetime-in-trait-fn.rs:5:9 | LL | trait T<'a> { | -- lifetime `'a` defined here diff --git a/tests/ui/issues/issue-17405.rs b/tests/ui/pattern/struct_pattern_on_tuple_enum.rs similarity index 69% rename from tests/ui/issues/issue-17405.rs rename to tests/ui/pattern/struct_pattern_on_tuple_enum.rs index 14781a7d3f7ea..a827788419394 100644 --- a/tests/ui/issues/issue-17405.rs +++ b/tests/ui/pattern/struct_pattern_on_tuple_enum.rs @@ -1,3 +1,4 @@ +//! regression test for enum Foo { Bar(isize) } diff --git a/tests/ui/issues/issue-17405.stderr b/tests/ui/pattern/struct_pattern_on_tuple_enum.stderr similarity index 85% rename from tests/ui/issues/issue-17405.stderr rename to tests/ui/pattern/struct_pattern_on_tuple_enum.stderr index 47f5bf4dc330a..a322b363aa9c4 100644 --- a/tests/ui/issues/issue-17405.stderr +++ b/tests/ui/pattern/struct_pattern_on_tuple_enum.stderr @@ -1,5 +1,5 @@ error[E0574]: expected struct, variant or union type, found enum `Foo` - --> $DIR/issue-17405.rs:7:9 + --> $DIR/struct_pattern_on_tuple_enum.rs:8:9 | LL | Foo { i } => () | ^^^ not a struct, variant or union type diff --git a/tests/ui/issues/issue-18389.rs b/tests/ui/privacy/trait_more_private_than_item.rs similarity index 83% rename from tests/ui/issues/issue-18389.rs rename to tests/ui/privacy/trait_more_private_than_item.rs index 0ab3f14545727..f55a494abd212 100644 --- a/tests/ui/issues/issue-18389.rs +++ b/tests/ui/privacy/trait_more_private_than_item.rs @@ -1,3 +1,4 @@ +//! regression test for //@ check-pass use std::any::Any; diff --git a/tests/ui/issues/issue-18389.stderr b/tests/ui/privacy/trait_more_private_than_item.stderr similarity index 84% rename from tests/ui/issues/issue-18389.stderr rename to tests/ui/privacy/trait_more_private_than_item.stderr index 4706d1ba1779e..03bffcd390c55 100644 --- a/tests/ui/issues/issue-18389.stderr +++ b/tests/ui/privacy/trait_more_private_than_item.stderr @@ -1,5 +1,5 @@ warning: trait `Private<::P, ::R>` is more private than the item `Public` - --> $DIR/issue-18389.rs:9:1 + --> $DIR/trait_more_private_than_item.rs:10:1 | LL | / pub trait Public: Private< LL | | @@ -9,7 +9,7 @@ LL | | > { | |_^ trait `Public` is reachable at visibility `pub` | note: but trait `Private<::P, ::R>` is only usable at visibility `pub(crate)` - --> $DIR/issue-18389.rs:6:1 + --> $DIR/trait_more_private_than_item.rs:7:1 | LL | trait Private { | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/reflection/dump.bit32.run.stdout b/tests/ui/reflection/dump.bit32.run.stdout index 483efdbbd12ab..8d0398bdd53ae 100644 --- a/tests/ui/reflection/dump.bit32.run.stdout +++ b/tests/ui/reflection/dump.bit32.run.stdout @@ -155,19 +155,34 @@ Type { ), } Type { - kind: Other, + kind: Reference( + Reference { + pointee: TypeId(0xda1b6da9bd297bb2900de9303aadea79), + mutable: false, + }, + ), size: Some( 8, ), } Type { - kind: Other, + kind: Reference( + Reference { + pointee: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c), + mutable: false, + }, + ), size: Some( 8, ), } Type { - kind: Other, + kind: Reference( + Reference { + pointee: TypeId(0x641e3def269c37acc6dcb92bf8c5f196), + mutable: false, + }, + ), size: Some( 8, ), @@ -182,3 +197,25 @@ Type { kind: Other, size: None, } +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: false, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: true, + }, + ), + size: Some( + 4, + ), +} diff --git a/tests/ui/reflection/dump.bit64.run.stdout b/tests/ui/reflection/dump.bit64.run.stdout index 681e81b71d56b..3564922fc1714 100644 --- a/tests/ui/reflection/dump.bit64.run.stdout +++ b/tests/ui/reflection/dump.bit64.run.stdout @@ -155,19 +155,34 @@ Type { ), } Type { - kind: Other, + kind: Reference( + Reference { + pointee: TypeId(0xda1b6da9bd297bb2900de9303aadea79), + mutable: false, + }, + ), size: Some( 16, ), } Type { - kind: Other, + kind: Reference( + Reference { + pointee: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c), + mutable: false, + }, + ), size: Some( 16, ), } Type { - kind: Other, + kind: Reference( + Reference { + pointee: TypeId(0x641e3def269c37acc6dcb92bf8c5f196), + mutable: false, + }, + ), size: Some( 16, ), @@ -182,3 +197,25 @@ Type { kind: Other, size: None, } +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: true, + }, + ), + size: Some( + 8, + ), +} diff --git a/tests/ui/reflection/dump.rs b/tests/ui/reflection/dump.rs index 584b7c8ed4ae8..d42216a62fdc8 100644 --- a/tests/ui/reflection/dump.rs +++ b/tests/ui/reflection/dump.rs @@ -40,5 +40,6 @@ fn main() { Foo, Bar, &Unsized, &str, &[u8], str, [u8], + &u8, &mut u8, } } diff --git a/tests/ui/issues/issue-18119.rs b/tests/ui/resolve/impl-on-non-type.rs similarity index 75% rename from tests/ui/issues/issue-18119.rs rename to tests/ui/resolve/impl-on-non-type.rs index e48dc51a2c644..3db13d520f9fe 100644 --- a/tests/ui/issues/issue-18119.rs +++ b/tests/ui/resolve/impl-on-non-type.rs @@ -1,3 +1,4 @@ +//! regression test for const X: u8 = 1; static Y: u8 = 1; fn foo() {} diff --git a/tests/ui/issues/issue-18119.stderr b/tests/ui/resolve/impl-on-non-type.stderr similarity index 78% rename from tests/ui/issues/issue-18119.stderr rename to tests/ui/resolve/impl-on-non-type.stderr index ddee5a9da7a42..99cc405015b58 100644 --- a/tests/ui/issues/issue-18119.stderr +++ b/tests/ui/resolve/impl-on-non-type.stderr @@ -1,17 +1,17 @@ error[E0573]: expected type, found constant `X` - --> $DIR/issue-18119.rs:5:6 + --> $DIR/impl-on-non-type.rs:6:6 | LL | impl X {} | ^ not a type error[E0573]: expected type, found static `Y` - --> $DIR/issue-18119.rs:7:6 + --> $DIR/impl-on-non-type.rs:8:6 | LL | impl Y {} | ^ not a type error[E0573]: expected type, found function `foo` - --> $DIR/issue-18119.rs:9:6 + --> $DIR/impl-on-non-type.rs:10:6 | LL | impl foo {} | ^^^ not a type diff --git a/tests/ui/issues/issue-17994.rs b/tests/ui/type-alias/unused_type_parameter.rs similarity index 58% rename from tests/ui/issues/issue-17994.rs rename to tests/ui/type-alias/unused_type_parameter.rs index ab37a172eaa74..64fb98be1bf74 100644 --- a/tests/ui/issues/issue-17994.rs +++ b/tests/ui/type-alias/unused_type_parameter.rs @@ -1,3 +1,4 @@ +//! regression test for trait Tr {} type Huh where T: Tr = isize; //~ ERROR type parameter `T` is never used fn main() {} diff --git a/tests/ui/issues/issue-17994.stderr b/tests/ui/type-alias/unused_type_parameter.stderr similarity index 88% rename from tests/ui/issues/issue-17994.stderr rename to tests/ui/type-alias/unused_type_parameter.stderr index f149e5d08faac..a9ddbc8c5001d 100644 --- a/tests/ui/issues/issue-17994.stderr +++ b/tests/ui/type-alias/unused_type_parameter.stderr @@ -1,5 +1,5 @@ error[E0091]: type parameter `T` is never used - --> $DIR/issue-17994.rs:2:10 + --> $DIR/unused_type_parameter.rs:3:10 | LL | type Huh where T: Tr = isize; | ^ unused type parameter