diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 0a9fe24e0c71b1478b21457b6fe293ea826d8f3a..6a570d53beb5a952aa951b7e849e38d508aa323d 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -1012,12 +1012,7 @@ fn named_span(item_span: Span, ident: Ident, generics: Option<&Generics<'_>>) -> ItemKind::Use(path, _) => path.span, _ => named_span(item.span, item.ident, item.kind.generics()), }, - Node::Variant(variant) => match variant.data { - VariantData::Struct(..) | VariantData::Unit(..) => { - named_span(variant.span, variant.ident, None) - } - VariantData::Tuple(..) => variant.span, - }, + Node::Variant(variant) => named_span(variant.span, variant.ident, None), Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)), Node::ForeignItem(item) => match item.kind { ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()), diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index ff24ea63c0b72b07d9f739eeabde46039f377e12..0617a0a54cfba58bc9837429f6786928791593f7 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -341,7 +341,7 @@ fn report_negative_positive_conflict( positive_impl_def_id: DefId, sg: &mut specialization_graph::Graph, ) { - let impl_span = tcx.span_of_impl(local_impl_def_id.to_def_id()).unwrap(); + let impl_span = tcx.def_span(local_impl_def_id); let mut err = struct_span_err!( tcx.sess, diff --git a/src/test/ui/empty/empty-struct-braces-pat-3.stderr b/src/test/ui/empty/empty-struct-braces-pat-3.stderr index 60266bb35807df7314c527bbdabba1766b89a5e7..615e7fb4aae2982252922221b983f3468272cd65 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-3.stderr +++ b/src/test/ui/empty/empty-struct-braces-pat-3.stderr @@ -19,7 +19,7 @@ LL | XEmpty3 {}, | ------- `XE::XEmpty3` defined here LL | XEmpty4, LL | XEmpty5(), - | --------- similarly named tuple variant `XEmpty5` defined here + | ------- similarly named tuple variant `XEmpty5` defined here | help: use struct pattern syntax instead | @@ -51,7 +51,7 @@ LL | XEmpty3 {}, | ------- `XE::XEmpty3` defined here LL | XEmpty4, LL | XEmpty5(), - | --------- similarly named tuple variant `XEmpty5` defined here + | ------- similarly named tuple variant `XEmpty5` defined here | help: use struct pattern syntax instead | diff --git a/src/test/ui/empty/empty-struct-tuple-pat.stderr b/src/test/ui/empty/empty-struct-tuple-pat.stderr index e696b85c6cc8164273480aa7f3a917119d03b676..9f44747381a9a4fc71464bca93493f96160cc39b 100644 --- a/src/test/ui/empty/empty-struct-tuple-pat.stderr +++ b/src/test/ui/empty/empty-struct-tuple-pat.stderr @@ -36,7 +36,7 @@ LL | XE::XEmpty5 => (), LL | XEmpty4, | ------- similarly named unit variant `XEmpty4` defined here LL | XEmpty5(), - | --------- `XE::XEmpty5` defined here + | ------- `XE::XEmpty5` defined here | help: use the tuple variant pattern syntax instead | diff --git a/src/test/ui/empty/empty-struct-unit-pat.stderr b/src/test/ui/empty/empty-struct-unit-pat.stderr index acd1070d5d6f2665560afba81b0b0e0738fc42e5..5c0b4cffa9469787ffbb9f58e8c899ac8bbb6d69 100644 --- a/src/test/ui/empty/empty-struct-unit-pat.stderr +++ b/src/test/ui/empty/empty-struct-unit-pat.stderr @@ -108,7 +108,7 @@ LL | XE::XEmpty4() => (), LL | XEmpty4, | ------- `XE::XEmpty4` defined here LL | XEmpty5(), - | --------- similarly named tuple variant `XEmpty5` defined here + | ------- similarly named tuple variant `XEmpty5` defined here | help: use this syntax instead | @@ -139,7 +139,7 @@ LL | XE::XEmpty4(..) => (), LL | XEmpty4, | ------- `XE::XEmpty4` defined here LL | XEmpty5(), - | --------- similarly named tuple variant `XEmpty5` defined here + | ------- similarly named tuple variant `XEmpty5` defined here | help: use this syntax instead | diff --git a/src/test/ui/mismatched_types/issue-47706.stderr b/src/test/ui/mismatched_types/issue-47706.stderr index 0b4f84a330a548f3b2b371ca18f8d5f46c49e0b2..8b8563684014dbf633909ab7825dcf7c52cffac8 100644 --- a/src/test/ui/mismatched_types/issue-47706.stderr +++ b/src/test/ui/mismatched_types/issue-47706.stderr @@ -19,7 +19,7 @@ error[E0593]: function is expected to take 0 arguments, but it takes 1 argument --> $DIR/issue-47706.rs:27:9 | LL | Bar(i32), - | -------- takes 1 argument + | --- takes 1 argument ... LL | foo(Qux::Bar); | --- ^^^^^^^^ expected function that takes 0 arguments diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index fbd86bdb661f207f8b1115c01edd516d7b1e799d..b04ea14d1a58095238293d750d6b9d93936ccaa7 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -94,7 +94,7 @@ LL | check(xm7::V); LL | V {}, | - `xm7::V` defined here LL | TV(), - | ---- similarly named tuple variant `TV` defined here + | -- similarly named tuple variant `TV` defined here | help: use struct literal syntax instead | diff --git a/src/test/ui/pattern/pat-tuple-field-count-cross.stderr b/src/test/ui/pattern/pat-tuple-field-count-cross.stderr index 019cd414d2e99e856874742635f0ad634d04a3e4..c0cc56aa86e2651127d3a3ca3f338a3be3d4053a 100644 --- a/src/test/ui/pattern/pat-tuple-field-count-cross.stderr +++ b/src/test/ui/pattern/pat-tuple-field-count-cross.stderr @@ -60,7 +60,7 @@ LL | E1::Z0() => {} ::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:15 | LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) } - | -- ---- similarly named tuple variant `Z1` defined here + | -- -- similarly named tuple variant `Z1` defined here | | | `E1::Z0` defined here | @@ -82,7 +82,7 @@ LL | E1::Z0(x) => {} ::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:15 | LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) } - | -- ---- similarly named tuple variant `Z1` defined here + | -- -- similarly named tuple variant `Z1` defined here | | | `E1::Z0` defined here | @@ -104,7 +104,7 @@ LL | E1::Z1 => {} ::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:19 | LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) } - | -- ---- `E1::Z1` defined here + | -- -- `E1::Z1` defined here | | | similarly named unit variant `Z0` defined here | @@ -295,7 +295,7 @@ LL | E1::Z1(x) => {} ::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:19 | LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) } - | ---- tuple variant has 0 fields + | -- tuple variant has 0 fields error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 3 fields --> $DIR/pat-tuple-field-count-cross.rs:39:9 diff --git a/src/test/ui/pattern/pat-tuple-overfield.stderr b/src/test/ui/pattern/pat-tuple-overfield.stderr index 9e13a2dc9fbfe209162e3df5ff5064c13e2b85e7..856e7918cb75c4c2bf3c7942804321715f3bede7 100644 --- a/src/test/ui/pattern/pat-tuple-overfield.stderr +++ b/src/test/ui/pattern/pat-tuple-overfield.stderr @@ -289,7 +289,7 @@ error[E0023]: this pattern has 1 field, but the corresponding tuple variant has --> $DIR/pat-tuple-overfield.rs:71:16 | LL | Z1(), - | ---- tuple variant has 0 fields + | -- tuple variant has 0 fields ... LL | E1::Z1(_) => {} | ^ expected 0 fields, found 1 @@ -298,7 +298,7 @@ error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has --> $DIR/pat-tuple-overfield.rs:72:16 | LL | Z1(), - | ---- tuple variant has 0 fields + | -- tuple variant has 0 fields ... LL | E1::Z1(_, _) => {} | ^ ^ expected 0 fields, found 2 diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr index 4548269b507930fb1bd407fbca12afc4f5e9f9a8..3c46b95cbc6858da3d759895a379f90ea43441af 100644 --- a/src/test/ui/proc-macro/parent-source-spans.stderr +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -148,7 +148,7 @@ LL | one!("hello", "world"); ::: $SRC_DIR/core/src/result.rs:LL:COL | LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T), - | --------------------------------------------------- similarly named tuple variant `Ok` defined here + | -- similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -164,7 +164,7 @@ LL | two!("yay", "rust"); ::: $SRC_DIR/core/src/result.rs:LL:COL | LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T), - | --------------------------------------------------- similarly named tuple variant `Ok` defined here + | -- similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -180,7 +180,7 @@ LL | three!("hip", "hop"); ::: $SRC_DIR/core/src/result.rs:LL:COL | LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T), - | --------------------------------------------------- similarly named tuple variant `Ok` defined here + | -- similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/repr/repr-transparent.stderr b/src/test/ui/repr/repr-transparent.stderr index 6ff3641bc15d0008c5bcd1d1a30cb6c7a76a6a1f..d85661f6faa847c46b5db19b5e0886de59c1ab04 100644 --- a/src/test/ui/repr/repr-transparent.stderr +++ b/src/test/ui/repr/repr-transparent.stderr @@ -58,7 +58,7 @@ error[E0731]: transparent enum needs exactly one variant, but has 2 LL | enum MultipleVariants { | ^^^^^^^^^^^^^^^^^^^^^ needs exactly one variant, but has 2 LL | Foo(String), - | ----------- + | --- LL | Bar, | --- too many variants in `MultipleVariants` diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 81d8a34881c0cbf1bb48cdaad29655aa0eef9b4a..e546d9f64ecad27d2b0a46f92e8643fc9639d37d 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -318,7 +318,7 @@ error[E0308]: mismatched types --> $DIR/privacy-enum-ctor.rs:27:20 | LL | Fn(u8), - | ------ fn(u8) -> Z {Z::Fn} defined here + | -- fn(u8) -> Z {Z::Fn} defined here ... LL | let _: Z = Z::Fn; | - ^^^^^ expected enum `Z`, found fn item @@ -353,7 +353,7 @@ error[E0308]: mismatched types --> $DIR/privacy-enum-ctor.rs:43:16 | LL | Fn(u8), - | ------ fn(u8) -> E {E::Fn} defined here + | -- fn(u8) -> E {E::Fn} defined here ... LL | let _: E = m::E::Fn; | - ^^^^^^^^ expected enum `E`, found fn item @@ -388,7 +388,7 @@ error[E0308]: mismatched types --> $DIR/privacy-enum-ctor.rs:51:16 | LL | Fn(u8), - | ------ fn(u8) -> E {E::Fn} defined here + | -- fn(u8) -> E {E::Fn} defined here ... LL | let _: E = E::Fn; | - ^^^^^ expected enum `E`, found fn item diff --git a/src/test/ui/rfc-2008-non-exhaustive/variant.stderr b/src/test/ui/rfc-2008-non-exhaustive/variant.stderr index 64cae3748c91e9ed38f7aad23e2af8ae96a763dd..720b7b119cec96e861d1d69ddb6d2a0085109a4e 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/variant.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/variant.stderr @@ -8,7 +8,7 @@ note: the tuple variant `Tuple` is defined here --> $DIR/auxiliary/variants.rs:5:23 | LL | #[non_exhaustive] Tuple(u32), - | ^^^^^^^^^^ + | ^^^^^ error[E0603]: unit variant `Unit` is private --> $DIR/variant.rs:14:47 @@ -44,7 +44,7 @@ note: the tuple variant `Tuple` is defined here --> $DIR/auxiliary/variants.rs:5:23 | LL | #[non_exhaustive] Tuple(u32), - | ^^^^^^^^^^ + | ^^^^^ error[E0603]: tuple variant `Tuple` is private --> $DIR/variant.rs:26:35 @@ -56,7 +56,7 @@ note: the tuple variant `Tuple` is defined here --> $DIR/auxiliary/variants.rs:5:23 | LL | #[non_exhaustive] Tuple(u32), - | ^^^^^^^^^^ + | ^^^^^ error[E0639]: cannot create non-exhaustive variant using struct expression --> $DIR/variant.rs:8:26 diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 505ed2ad7b37ad0d5a88d750f0ad96fe01c60a78..9aeb99ee2fa8f28f47e547d49f12ba7f1c628d70 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -130,7 +130,7 @@ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:35:16 | LL | A(usize), - | -------- fn(usize) -> E {E::A} defined here + | - fn(usize) -> E {E::A} defined here ... LL | let _: E = E::A; | - ^^^^ expected enum `E`, found fn item