Skip to content

Commit bb49eea

Browse files
authored
Rollup merge of #76898 - Aaron1011:fix/item-def-span, r=oli-obk
Record `tcx.def_span` instead of `item.span` in crate metadata This was missed in PR #75465. As a result, a few places have been using the full body span of functions, instead of just the header span.
2 parents 34f9501 + 0d0a3e1 commit bb49eea

File tree

7 files changed

+20
-42
lines changed

7 files changed

+20
-42
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ impl EncodeContext<'a, 'tcx> {
13001300
});
13011301
record!(self.tables.visibility[def_id] <-
13021302
ty::Visibility::from_hir(&item.vis, item.hir_id, tcx));
1303-
record!(self.tables.span[def_id] <- item.span);
1303+
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
13041304
record!(self.tables.attributes[def_id] <- item.attrs);
13051305
// FIXME(eddyb) there should be a nicer way to do this.
13061306
match item.kind {

src/test/ui/consts/miri_unleashed/drop.stderr

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
error[E0080]: could not evaluate static initializer
22
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
33
|
4-
LL | / pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
5-
LL | | // Code here does not matter - this is replaced by the
6-
LL | | // real drop glue by the compiler.
7-
LL | |
8-
LL | | // SAFETY: see comment above
9-
LL | | unsafe { drop_in_place(to_drop) }
10-
LL | | }
11-
| | ^
12-
| | |
13-
| |_calling non-const function `<Vec<i32> as Drop>::drop`
14-
| inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
4+
LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| calling non-const function `<Vec<i32> as Drop>::drop`
8+
| inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
159
|
1610
::: $DIR/drop.rs:18:1
1711
|
18-
LL | };
19-
| - inside `TEST_BAD` at $DIR/drop.rs:18:1
12+
LL | };
13+
| - inside `TEST_BAD` at $DIR/drop.rs:18:1
2014

2115
warning: skipping const checks
2216
|

src/test/ui/macros/same-sequence-span.stderr

+4-8
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@ LL | $(= $z:tt)*
1717
error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments
1818
--> $DIR/same-sequence-span.rs:19:1
1919
|
20-
LL | proc_macro_sequence::make_foo!();
21-
| ^--------------------------------
22-
| |
23-
| _in this macro invocation
20+
LL | proc_macro_sequence::make_foo!();
21+
| ---------------------------------^^^^^^^^^^^^^
2422
| |
25-
LL | |
26-
LL | |
27-
LL | | fn main() {}
28-
... |
23+
| not allowed after `expr` fragments
24+
| in this macro invocation
2925
|
3026
= note: allowed there are: `=>`, `,` or `;`
3127
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

src/test/ui/proc-macro/meta-macro-hygiene.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Def site: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5)
1+
Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5)
22
Input: TokenStream [Ident { ident: "$crate", span: $DIR/meta-macro-hygiene.rs:24:37: 24:43 (#4) }, Punct { ch: ':', spacing: Joint, span: $DIR/meta-macro-hygiene.rs:24:43: 24:45 (#4) }, Punct { ch: ':', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:24:43: 24:45 (#4) }, Ident { ident: "dummy", span: $DIR/meta-macro-hygiene.rs:24:45: 24:50 (#4) }, Punct { ch: '!', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:24:50: 24:51 (#4) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/meta-macro-hygiene.rs:24:51: 24:53 (#4) }]
3-
Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5) }, Punct { ch: ':', spacing: Joint, span: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5) }, Punct { ch: ':', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5) }, Ident { ident: "dummy", span: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5) }, Punct { ch: '!', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#5) }]
3+
Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Punct { ch: ':', spacing: Joint, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Punct { ch: ':', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Ident { ident: "dummy", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Punct { ch: '!', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }]
44
#![feature /* 0#0 */(prelude_import)]
55
// ignore-tidy-linelength
66
// aux-build:make-macro.rs
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Def site: $DIR/auxiliary/make-macro.rs:7:9: 16:10 (#4)
1+
Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4)
22
Input: TokenStream []
33
Respanned: TokenStream []
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
error: reached the recursion limit while instantiating `drop_in_place::<S<fn(fn(fn(fn(fn...)))))))))))))))))))))))))))))>))`
22
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
33
|
4-
LL | / pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
5-
LL | | // Code here does not matter - this is replaced by the
6-
LL | | // real drop glue by the compiler.
7-
LL | |
8-
LL | | // SAFETY: see comment above
9-
LL | | unsafe { drop_in_place(to_drop) }
10-
LL | | }
11-
| |_^
4+
LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126
|
137
note: `drop_in_place` defined here
148
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
159
|
16-
LL | / pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
17-
LL | | // Code here does not matter - this is replaced by the
18-
LL | | // real drop glue by the compiler.
19-
LL | |
20-
LL | | // SAFETY: see comment above
21-
LL | | unsafe { drop_in_place(to_drop) }
22-
LL | | }
23-
| |_^
10+
LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2412

2513
error: aborting due to previous error
2614

src/test/ui/type_length_limit.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: reached the type-length limit while instantiating `std::mem::drop::<Optio
22
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
33
|
44
LL | pub fn drop<T>(_x: T) {}
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: consider adding a `#![type_length_limit="8"]` attribute to your crate
88

0 commit comments

Comments
 (0)