Make item spans more consistent
This commit is contained in:
parent
1ba1fec234
commit
aad2334ecb
11 changed files with 83 additions and 119 deletions
|
@ -781,12 +781,13 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||||
id.def_id,
|
id.def_id,
|
||||||
tcx.def_path_str(id.def_id.to_def_id())
|
tcx.def_path_str(id.def_id.to_def_id())
|
||||||
);
|
);
|
||||||
|
let item_span = tcx.def_span(id.def_id);
|
||||||
let _indenter = indenter();
|
let _indenter = indenter();
|
||||||
match tcx.def_kind(id.def_id) {
|
match tcx.def_kind(id.def_id) {
|
||||||
DefKind::Static(..) => {
|
DefKind::Static(..) => {
|
||||||
tcx.ensure().typeck(id.def_id);
|
tcx.ensure().typeck(id.def_id);
|
||||||
maybe_check_static_with_link_section(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, tcx.def_span(id.def_id));
|
check_static_inhabited(tcx, id.def_id, item_span);
|
||||||
}
|
}
|
||||||
DefKind::Const => {
|
DefKind::Const => {
|
||||||
tcx.ensure().typeck(id.def_id);
|
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 {
|
let hir::ItemKind::Enum(ref enum_definition, _) = item.kind else {
|
||||||
return;
|
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::Fn => {} // entirely within check_item_body
|
||||||
DefKind::Impl => {
|
DefKind::Impl => {
|
||||||
|
@ -847,10 +848,10 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefKind::Struct => {
|
DefKind::Struct => {
|
||||||
check_struct(tcx, id.def_id, tcx.def_span(id.def_id));
|
check_struct(tcx, id.def_id, item_span);
|
||||||
}
|
}
|
||||||
DefKind::Union => {
|
DefKind::Union => {
|
||||||
check_union(tcx, id.def_id, tcx.def_span(id.def_id));
|
check_union(tcx, id.def_id, item_span);
|
||||||
}
|
}
|
||||||
DefKind::OpaqueTy => {
|
DefKind::OpaqueTy => {
|
||||||
let item = tcx.hir().item(id);
|
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
|
// See https://github.com/rust-lang/rust/issues/75100
|
||||||
if !tcx.sess.opts.actually_rustdoc {
|
if !tcx.sess.opts.actually_rustdoc {
|
||||||
let substs = InternalSubsts::identity_for_item(tcx, item.def_id.to_def_id());
|
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 => {
|
DefKind::TyAlias => {
|
||||||
|
@ -1328,7 +1329,6 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, adt: ty::AdtD
|
||||||
if !adt.repr().transparent() {
|
if !adt.repr().transparent() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let sp = tcx.sess.source_map().guess_head_span(sp);
|
|
||||||
|
|
||||||
if adt.is_union() && !tcx.features().transparent_unions {
|
if adt.is_union() && !tcx.features().transparent_unions {
|
||||||
feature_err(
|
feature_err(
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
error[E0732]: `#[repr(inttype)]` must be specified
|
error[E0732]: `#[repr(inttype)]` must be specified
|
||||||
--> $DIR/arbitrary_enum_discriminant-no-repr.rs:4:1
|
--> $DIR/arbitrary_enum_discriminant-no-repr.rs:4:1
|
||||||
|
|
|
|
||||||
LL | / enum Enum {
|
LL | enum Enum {
|
||||||
LL | |
|
| ^^^^^^^^^
|
||||||
LL | | Unit = 1,
|
|
||||||
LL | | Tuple() = 2,
|
|
||||||
LL | | Struct{} = 3,
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
error[E0081]: discriminant value `0` assigned more than once
|
error[E0081]: discriminant value `0` assigned more than once
|
||||||
--> $DIR/enum-discrim-autosizing.rs:6:1
|
--> $DIR/enum-discrim-autosizing.rs:6:1
|
||||||
|
|
|
|
||||||
LL | / enum Eu64 {
|
LL | enum Eu64 {
|
||||||
LL | |
|
| ^^^^^^^^^
|
||||||
LL | | Au64 = 0,
|
LL |
|
||||||
| | - first assignment of `0`
|
LL | Au64 = 0,
|
||||||
LL | |
|
| - first assignment of `0`
|
||||||
LL | | Bu64 = 0x8000_0000_0000_0000
|
LL |
|
||||||
| | --------------------- second assignment of `0` (overflowed from `9223372036854775808`)
|
LL | Bu64 = 0x8000_0000_0000_0000
|
||||||
LL | |
|
| --------------------- second assignment of `0` (overflowed from `9223372036854775808`)
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,48 +1,41 @@
|
||||||
error[E0081]: discriminant value `3` assigned more than once
|
error[E0081]: discriminant value `3` assigned more than once
|
||||||
--> $DIR/E0081.rs:1:1
|
--> $DIR/E0081.rs:1:1
|
||||||
|
|
|
|
||||||
LL | / enum Enum {
|
LL | enum Enum {
|
||||||
LL | |
|
| ^^^^^^^^^
|
||||||
LL | | P = 3,
|
LL |
|
||||||
| | - first assignment of `3`
|
LL | P = 3,
|
||||||
LL | |
|
| - first assignment of `3`
|
||||||
LL | | X = 3,
|
LL |
|
||||||
| | - second assignment of `3`
|
LL | X = 3,
|
||||||
LL | |
|
| - second assignment of `3`
|
||||||
LL | | Y = 5
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error[E0081]: discriminant value `1` assigned more than once
|
error[E0081]: discriminant value `1` assigned more than once
|
||||||
--> $DIR/E0081.rs:11:1
|
--> $DIR/E0081.rs:11:1
|
||||||
|
|
|
|
||||||
LL | / enum EnumOverflowRepr {
|
LL | enum EnumOverflowRepr {
|
||||||
LL | |
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
LL | | P = 257,
|
LL |
|
||||||
| | --- first assignment of `1` (overflowed from `257`)
|
LL | P = 257,
|
||||||
LL | |
|
| --- first assignment of `1` (overflowed from `257`)
|
||||||
LL | | X = 513,
|
LL |
|
||||||
| | --- second assignment of `1` (overflowed from `513`)
|
LL | X = 513,
|
||||||
LL | |
|
| --- second assignment of `1` (overflowed from `513`)
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error[E0081]: discriminant value `-1` assigned more than once
|
error[E0081]: discriminant value `-1` assigned more than once
|
||||||
--> $DIR/E0081.rs:20:1
|
--> $DIR/E0081.rs:20:1
|
||||||
|
|
|
|
||||||
LL | / enum NegDisEnum {
|
LL | enum NegDisEnum {
|
||||||
LL | |
|
| ^^^^^^^^^^^^^^^
|
||||||
LL | | First = -1,
|
LL |
|
||||||
| | -- first assignment of `-1`
|
LL | First = -1,
|
||||||
LL | |
|
| -- first assignment of `-1`
|
||||||
LL | | Second = -2,
|
LL |
|
||||||
| | ----------- assigned discriminant for `Last` was incremented from this discriminant
|
LL | Second = -2,
|
||||||
LL | |
|
| ----------- assigned discriminant for `Last` was incremented from this discriminant
|
||||||
LL | | Last,
|
LL |
|
||||||
| | ---- second assignment of `-1`
|
LL | Last,
|
||||||
LL | |
|
| ---- second assignment of `-1`
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0084]: unsupported representation for zero-variant enum
|
||||||
LL | #[repr(i32)]
|
LL | #[repr(i32)]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
LL | enum Foo {}
|
LL | enum Foo {}
|
||||||
| ----------- zero-variant enum
|
| -------- zero-variant enum
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
error[E0658]: repr with 128-bit type is unstable
|
error[E0658]: repr with 128-bit type is unstable
|
||||||
--> $DIR/E0658.rs:2:1
|
--> $DIR/E0658.rs:2:1
|
||||||
|
|
|
|
||||||
LL | / enum Foo {
|
LL | enum Foo {
|
||||||
LL | | Bar(u64),
|
| ^^^^^^^^
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
|
|
||||||
= note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
|
= 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
|
= help: add `#![feature(repr128)]` to the crate attributes to enable
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
error[E0658]: repr with 128-bit type is unstable
|
error[E0658]: repr with 128-bit type is unstable
|
||||||
--> $DIR/feature-gate-repr128.rs:2:1
|
--> $DIR/feature-gate-repr128.rs:2:1
|
||||||
|
|
|
|
||||||
LL | / enum A {
|
LL | enum A {
|
||||||
LL | | A(u64)
|
| ^^^^^^
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
|
|
||||||
= note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
|
= 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
|
= help: add `#![feature(repr128)]` to the crate attributes to enable
|
||||||
|
|
|
@ -1,53 +1,39 @@
|
||||||
error[E0081]: discriminant value `1` assigned more than once
|
error[E0081]: discriminant value `1` assigned more than once
|
||||||
--> $DIR/issue-15524.rs:3:1
|
--> $DIR/issue-15524.rs:3:1
|
||||||
|
|
|
|
||||||
LL | / enum Foo {
|
LL | enum Foo {
|
||||||
LL | |
|
| ^^^^^^^^
|
||||||
LL | |
|
...
|
||||||
LL | |
|
LL | A = 1,
|
||||||
LL | | A = 1,
|
| - first assignment of `1`
|
||||||
| | - first assignment of `1`
|
LL | B = 1,
|
||||||
LL | | B = 1,
|
| - second assignment of `1`
|
||||||
| | - second assignment of `1`
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error[E0081]: discriminant value `1` assigned more than once
|
error[E0081]: discriminant value `1` assigned more than once
|
||||||
--> $DIR/issue-15524.rs:3:1
|
--> $DIR/issue-15524.rs:3:1
|
||||||
|
|
|
|
||||||
LL | / enum Foo {
|
LL | enum Foo {
|
||||||
LL | |
|
| ^^^^^^^^
|
||||||
LL | |
|
...
|
||||||
LL | |
|
LL | A = 1,
|
||||||
LL | | A = 1,
|
| - first assignment of `1`
|
||||||
| | - first assignment of `1`
|
LL | B = 1,
|
||||||
LL | | B = 1,
|
LL | C = 0,
|
||||||
LL | | C = 0,
|
| ----- assigned discriminant for `D` was incremented from this discriminant
|
||||||
| | ----- assigned discriminant for `D` was incremented from this discriminant
|
LL | D,
|
||||||
LL | | D,
|
| - second assignment of `1`
|
||||||
| | - second assignment of `1`
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error[E0081]: discriminant value `1` assigned more than once
|
error[E0081]: discriminant value `1` assigned more than once
|
||||||
--> $DIR/issue-15524.rs:3:1
|
--> $DIR/issue-15524.rs:3:1
|
||||||
|
|
|
|
||||||
LL | / enum Foo {
|
LL | enum Foo {
|
||||||
LL | |
|
| ^^^^^^^^
|
||||||
LL | |
|
...
|
||||||
LL | |
|
LL | A = 1,
|
||||||
LL | | A = 1,
|
| - first assignment of `1`
|
||||||
| | - first assignment of `1`
|
...
|
||||||
... |
|
LL | E = N,
|
||||||
LL | | E = N,
|
| - second assignment of `1`
|
||||||
| | - second assignment of `1`
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ LL | #[repr(simd)]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
...
|
...
|
||||||
LL | enum Es {}
|
LL | enum Es {}
|
||||||
| ---------- zero-variant enum
|
| ------- zero-variant enum
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ error[E0084]: unsupported representation for zero-variant enum
|
||||||
LL | #[repr(transparent)]
|
LL | #[repr(transparent)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
LL | enum Void {}
|
LL | enum Void {}
|
||||||
| ------------ zero-variant enum
|
| --------- zero-variant enum
|
||||||
|
|
||||||
error[E0731]: transparent enum needs exactly one variant, but has 0
|
error[E0731]: transparent enum needs exactly one variant, but has 0
|
||||||
--> $DIR/repr-transparent.rs:45:1
|
--> $DIR/repr-transparent.rs:45:1
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
error[E0081]: discriminant value `0` assigned more than once
|
error[E0081]: discriminant value `0` assigned more than once
|
||||||
--> $DIR/tag-variant-disr-dup.rs:3:1
|
--> $DIR/tag-variant-disr-dup.rs:3:1
|
||||||
|
|
|
|
||||||
LL | / enum Color {
|
LL | enum Color {
|
||||||
LL | |
|
| ^^^^^^^^^^
|
||||||
LL | | Red = 0xff0000,
|
...
|
||||||
LL | | Green = 0x00ff00,
|
LL | Black = 0x000000,
|
||||||
LL | | Blue = 0x0000ff,
|
| -------- first assignment of `0`
|
||||||
LL | | Black = 0x000000,
|
LL | White = 0x000000,
|
||||||
| | -------- first assignment of `0`
|
| -------- second assignment of `0`
|
||||||
LL | | White = 0x000000,
|
|
||||||
| | -------- second assignment of `0`
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue