about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_typeck/src/check/check.rs14
-rw-r--r--src/test/ui/enum-discriminant/arbitrary_enum_discriminant-no-repr.stderr9
-rw-r--r--src/test/ui/enum/enum-discrim-autosizing.stderr18
-rw-r--r--src/test/ui/error-codes/E0081.stderr61
-rw-r--r--src/test/ui/error-codes/E0084.stderr2
-rw-r--r--src/test/ui/error-codes/E0658.stderr6
-rw-r--r--src/test/ui/feature-gates/feature-gate-repr128.stderr6
-rw-r--r--src/test/ui/issues/issue-15524.stderr64
-rw-r--r--src/test/ui/repr/issue-83505-repr-simd.stderr2
-rw-r--r--src/test/ui/repr/repr-transparent.stderr2
-rw-r--r--src/test/ui/tag-variant-disr-dup.stderr18
11 files changed, 83 insertions, 119 deletions
diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs
index dfcd35d2178..d4c7f3f8fa2 100644
--- a/compiler/rustc_typeck/src/check/check.rs
+++ b/compiler/rustc_typeck/src/check/check.rs
@@ -781,12 +781,13 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
         id.def_id,
         tcx.def_path_str(id.def_id.to_def_id())
     );
+    let item_span = tcx.def_span(id.def_id);
     let _indenter = indenter();
     match tcx.def_kind(id.def_id) {
         DefKind::Static(..) => {
             tcx.ensure().typeck(id.def_id);
-            maybe_check_static_with_link_section(tcx, id.def_id, tcx.def_span(id.def_id));
-            check_static_inhabited(tcx, id.def_id, tcx.def_span(id.def_id));
+            maybe_check_static_with_link_section(tcx, id.def_id, item_span);
+            check_static_inhabited(tcx, id.def_id, item_span);
         }
         DefKind::Const => {
             tcx.ensure().typeck(id.def_id);
@@ -796,7 +797,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
             let hir::ItemKind::Enum(ref enum_definition, _) = item.kind else {
                 return;
             };
-            check_enum(tcx, item.span, &enum_definition.variants, item.def_id);
+            check_enum(tcx, item_span, &enum_definition.variants, item.def_id);
         }
         DefKind::Fn => {} // entirely within check_item_body
         DefKind::Impl => {
@@ -847,10 +848,10 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
             }
         }
         DefKind::Struct => {
-            check_struct(tcx, id.def_id, tcx.def_span(id.def_id));
+            check_struct(tcx, id.def_id, item_span);
         }
         DefKind::Union => {
-            check_union(tcx, id.def_id, tcx.def_span(id.def_id));
+            check_union(tcx, id.def_id, item_span);
         }
         DefKind::OpaqueTy => {
             let item = tcx.hir().item(id);
@@ -863,7 +864,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
             // See https://github.com/rust-lang/rust/issues/75100
             if !tcx.sess.opts.actually_rustdoc {
                 let substs = InternalSubsts::identity_for_item(tcx, item.def_id.to_def_id());
-                check_opaque(tcx, item.def_id, substs, item.span, &origin);
+                check_opaque(tcx, item.def_id, substs, item_span, &origin);
             }
         }
         DefKind::TyAlias => {
@@ -1328,7 +1329,6 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, adt: ty::AdtD
     if !adt.repr().transparent() {
         return;
     }
-    let sp = tcx.sess.source_map().guess_head_span(sp);
 
     if adt.is_union() && !tcx.features().transparent_unions {
         feature_err(
diff --git a/src/test/ui/enum-discriminant/arbitrary_enum_discriminant-no-repr.stderr b/src/test/ui/enum-discriminant/arbitrary_enum_discriminant-no-repr.stderr
index 2db5372da0c..803bb06fcc2 100644
--- a/src/test/ui/enum-discriminant/arbitrary_enum_discriminant-no-repr.stderr
+++ b/src/test/ui/enum-discriminant/arbitrary_enum_discriminant-no-repr.stderr
@@ -1,13 +1,8 @@
 error[E0732]: `#[repr(inttype)]` must be specified
   --> $DIR/arbitrary_enum_discriminant-no-repr.rs:4:1
    |
-LL | / enum Enum {
-LL | |
-LL | |   Unit = 1,
-LL | |   Tuple() = 2,
-LL | |   Struct{} = 3,
-LL | | }
-   | |_^
+LL | enum Enum {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/enum/enum-discrim-autosizing.stderr b/src/test/ui/enum/enum-discrim-autosizing.stderr
index bcd362b0632..eacea86d67e 100644
--- a/src/test/ui/enum/enum-discrim-autosizing.stderr
+++ b/src/test/ui/enum/enum-discrim-autosizing.stderr
@@ -1,16 +1,14 @@
 error[E0081]: discriminant value `0` assigned more than once
   --> $DIR/enum-discrim-autosizing.rs:6:1
    |
-LL | / enum Eu64 {
-LL | |
-LL | |     Au64 = 0,
-   | |            - first assignment of `0`
-LL | |
-LL | |     Bu64 = 0x8000_0000_0000_0000
-   | |            --------------------- second assignment of `0` (overflowed from `9223372036854775808`)
-LL | |
-LL | | }
-   | |_^
+LL | enum Eu64 {
+   | ^^^^^^^^^
+LL |
+LL |     Au64 = 0,
+   |            - first assignment of `0`
+LL |
+LL |     Bu64 = 0x8000_0000_0000_0000
+   |            --------------------- second assignment of `0` (overflowed from `9223372036854775808`)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-codes/E0081.stderr b/src/test/ui/error-codes/E0081.stderr
index d7c7dbac7d6..ff6113646bb 100644
--- a/src/test/ui/error-codes/E0081.stderr
+++ b/src/test/ui/error-codes/E0081.stderr
@@ -1,48 +1,41 @@
 error[E0081]: discriminant value `3` assigned more than once
   --> $DIR/E0081.rs:1:1
    |
-LL | / enum Enum {
-LL | |
-LL | |     P = 3,
-   | |         - first assignment of `3`
-LL | |
-LL | |     X = 3,
-   | |         - second assignment of `3`
-LL | |
-LL | |     Y = 5
-LL | | }
-   | |_^
+LL | enum Enum {
+   | ^^^^^^^^^
+LL |
+LL |     P = 3,
+   |         - first assignment of `3`
+LL |
+LL |     X = 3,
+   |         - second assignment of `3`
 
 error[E0081]: discriminant value `1` assigned more than once
   --> $DIR/E0081.rs:11:1
    |
-LL | / enum EnumOverflowRepr {
-LL | |
-LL | |     P = 257,
-   | |         --- first assignment of `1` (overflowed from `257`)
-LL | |
-LL | |     X = 513,
-   | |         --- second assignment of `1` (overflowed from `513`)
-LL | |
-LL | | }
-   | |_^
+LL | enum EnumOverflowRepr {
+   | ^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL |     P = 257,
+   |         --- first assignment of `1` (overflowed from `257`)
+LL |
+LL |     X = 513,
+   |         --- second assignment of `1` (overflowed from `513`)
 
 error[E0081]: discriminant value `-1` assigned more than once
   --> $DIR/E0081.rs:20:1
    |
-LL | / enum NegDisEnum {
-LL | |
-LL | |     First = -1,
-   | |             -- first assignment of `-1`
-LL | |
-LL | |     Second = -2,
-   | |     ----------- assigned discriminant for `Last` was incremented from this discriminant
-LL | |
-LL | |     Last,
-   | |     ---- second assignment of `-1`
-LL | |
-LL | | }
-   | |_^
+LL | enum NegDisEnum {
+   | ^^^^^^^^^^^^^^^
+LL |
+LL |     First = -1,
+   |             -- first assignment of `-1`
+LL |
+LL |     Second = -2,
+   |     ----------- assigned discriminant for `Last` was incremented from this discriminant
+LL |
+LL |     Last,
+   |     ---- second assignment of `-1`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/error-codes/E0084.stderr b/src/test/ui/error-codes/E0084.stderr
index 1f818da25bb..e1bda22b8d1 100644
--- a/src/test/ui/error-codes/E0084.stderr
+++ b/src/test/ui/error-codes/E0084.stderr
@@ -4,7 +4,7 @@ error[E0084]: unsupported representation for zero-variant enum
 LL | #[repr(i32)]
    | ^^^^^^^^^^^^
 LL | enum Foo {}
-   | ----------- zero-variant enum
+   | -------- zero-variant enum
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-codes/E0658.stderr b/src/test/ui/error-codes/E0658.stderr
index 4563b0e2194..8d423484528 100644
--- a/src/test/ui/error-codes/E0658.stderr
+++ b/src/test/ui/error-codes/E0658.stderr
@@ -1,10 +1,8 @@
 error[E0658]: repr with 128-bit type is unstable
   --> $DIR/E0658.rs:2:1
    |
-LL | / enum Foo {
-LL | |     Bar(u64),
-LL | | }
-   | |_^
+LL | enum Foo {
+   | ^^^^^^^^
    |
    = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
    = help: add `#![feature(repr128)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-repr128.stderr b/src/test/ui/feature-gates/feature-gate-repr128.stderr
index 3eb005acc33..3999a6d2d2f 100644
--- a/src/test/ui/feature-gates/feature-gate-repr128.stderr
+++ b/src/test/ui/feature-gates/feature-gate-repr128.stderr
@@ -1,10 +1,8 @@
 error[E0658]: repr with 128-bit type is unstable
   --> $DIR/feature-gate-repr128.rs:2:1
    |
-LL | / enum A {
-LL | |     A(u64)
-LL | | }
-   | |_^
+LL | enum A {
+   | ^^^^^^
    |
    = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
    = help: add `#![feature(repr128)]` to the crate attributes to enable
diff --git a/src/test/ui/issues/issue-15524.stderr b/src/test/ui/issues/issue-15524.stderr
index a0ea0c2459f..1195e0a346d 100644
--- a/src/test/ui/issues/issue-15524.stderr
+++ b/src/test/ui/issues/issue-15524.stderr
@@ -1,53 +1,39 @@
 error[E0081]: discriminant value `1` assigned more than once
   --> $DIR/issue-15524.rs:3:1
    |
-LL | / enum Foo {
-LL | |
-LL | |
-LL | |
-LL | |     A = 1,
-   | |         - first assignment of `1`
-LL | |     B = 1,
-   | |         - second assignment of `1`
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | enum Foo {
+   | ^^^^^^^^
+...
+LL |     A = 1,
+   |         - first assignment of `1`
+LL |     B = 1,
+   |         - second assignment of `1`
 
 error[E0081]: discriminant value `1` assigned more than once
   --> $DIR/issue-15524.rs:3:1
    |
-LL | / enum Foo {
-LL | |
-LL | |
-LL | |
-LL | |     A = 1,
-   | |         - first assignment of `1`
-LL | |     B = 1,
-LL | |     C = 0,
-   | |     ----- assigned discriminant for `D` was incremented from this discriminant
-LL | |     D,
-   | |     - second assignment of `1`
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | enum Foo {
+   | ^^^^^^^^
+...
+LL |     A = 1,
+   |         - first assignment of `1`
+LL |     B = 1,
+LL |     C = 0,
+   |     ----- assigned discriminant for `D` was incremented from this discriminant
+LL |     D,
+   |     - second assignment of `1`
 
 error[E0081]: discriminant value `1` assigned more than once
   --> $DIR/issue-15524.rs:3:1
    |
-LL | / enum Foo {
-LL | |
-LL | |
-LL | |
-LL | |     A = 1,
-   | |         - first assignment of `1`
-...  |
-LL | |     E = N,
-   | |         - second assignment of `1`
-LL | |
-LL | | }
-   | |_^
+LL | enum Foo {
+   | ^^^^^^^^
+...
+LL |     A = 1,
+   |         - first assignment of `1`
+...
+LL |     E = N,
+   |         - second assignment of `1`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/repr/issue-83505-repr-simd.stderr b/src/test/ui/repr/issue-83505-repr-simd.stderr
index f1390a65201..df99baaf522 100644
--- a/src/test/ui/repr/issue-83505-repr-simd.stderr
+++ b/src/test/ui/repr/issue-83505-repr-simd.stderr
@@ -22,7 +22,7 @@ LL | #[repr(simd)]
    | ^^^^^^^^^^^^^
 ...
 LL | enum Es {}
-   | ---------- zero-variant enum
+   | ------- zero-variant enum
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/repr/repr-transparent.stderr b/src/test/ui/repr/repr-transparent.stderr
index d85661f6faa..f1c570b9523 100644
--- a/src/test/ui/repr/repr-transparent.stderr
+++ b/src/test/ui/repr/repr-transparent.stderr
@@ -34,7 +34,7 @@ error[E0084]: unsupported representation for zero-variant enum
 LL | #[repr(transparent)]
    | ^^^^^^^^^^^^^^^^^^^^
 LL | enum Void {}
-   | ------------ zero-variant enum
+   | --------- zero-variant enum
 
 error[E0731]: transparent enum needs exactly one variant, but has 0
   --> $DIR/repr-transparent.rs:45:1
diff --git a/src/test/ui/tag-variant-disr-dup.stderr b/src/test/ui/tag-variant-disr-dup.stderr
index 27adb6998ae..6b1ba43d2ba 100644
--- a/src/test/ui/tag-variant-disr-dup.stderr
+++ b/src/test/ui/tag-variant-disr-dup.stderr
@@ -1,17 +1,13 @@
 error[E0081]: discriminant value `0` assigned more than once
   --> $DIR/tag-variant-disr-dup.rs:3:1
    |
-LL | / enum Color {
-LL | |
-LL | |     Red = 0xff0000,
-LL | |     Green = 0x00ff00,
-LL | |     Blue = 0x0000ff,
-LL | |     Black = 0x000000,
-   | |             -------- first assignment of `0`
-LL | |     White = 0x000000,
-   | |             -------- second assignment of `0`
-LL | | }
-   | |_^
+LL | enum Color {
+   | ^^^^^^^^^^
+...
+LL |     Black = 0x000000,
+   |             -------- first assignment of `0`
+LL |     White = 0x000000,
+   |             -------- second assignment of `0`
 
 error: aborting due to previous error