Skip to content

Commit 496edf9

Browse files
committed
Update rental hack to work with remapped paths.
1 parent 5ca6f7d commit 496edf9

6 files changed

+235
-4
lines changed

compiler/rustc_expand/src/base.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ use rustc_span::edition::Edition;
3131
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId};
3232
use rustc_span::source_map::SourceMap;
3333
use rustc_span::symbol::{kw, sym, Ident, Symbol};
34-
use rustc_span::{BytePos, FileName, RealFileName, Span, DUMMY_SP};
34+
use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
3535
use smallvec::{smallvec, SmallVec};
3636

3737
use std::iter;
38-
use std::path::PathBuf;
38+
use std::path::{Path, PathBuf};
3939
use std::rc::Rc;
4040

4141
pub(crate) use rustc_span::hygiene::MacroKind;
@@ -1423,8 +1423,10 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool {
14231423
if let [variant] = &*enum_def.variants {
14241424
if variant.ident.name == sym::Input {
14251425
let filename = sess.source_map().span_to_filename(item.ident.span);
1426-
if let FileName::Real(RealFileName::LocalPath(path)) = filename {
1427-
if let Some(c) = path
1426+
if let FileName::Real(real) = filename {
1427+
if let Some(c) = real
1428+
.local_path()
1429+
.unwrap_or(Path::new(""))
14281430
.components()
14291431
.flat_map(|c| c.as_os_str().to_str())
14301432
.find(|c| c.starts_with("rental") || c.starts_with("allsorts-rental"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
error: using an old version of `rental`
2+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
3+
|
4+
LL | enum ProceduralMasqueradeDummyType {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
9+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
10+
= note: `#[deny(proc_macro_back_compat)]` on by default
11+
12+
error: using an old version of `rental`
13+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
14+
|
15+
LL | enum ProceduralMasqueradeDummyType {
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
20+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
21+
22+
error: using an old version of `rental`
23+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
24+
|
25+
LL | enum ProceduralMasqueradeDummyType {
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
|
28+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
29+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
30+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
31+
32+
error: using an old version of `rental`
33+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
34+
|
35+
LL | enum ProceduralMasqueradeDummyType {
36+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37+
|
38+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
39+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
40+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
41+
42+
error: using an old version of `rental`
43+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
44+
|
45+
LL | enum ProceduralMasqueradeDummyType {
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
|
48+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
49+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
50+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
51+
52+
error: using an old version of `rental`
53+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
54+
|
55+
LL | enum ProceduralMasqueradeDummyType {
56+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
|
58+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
59+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
60+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
61+
62+
error: using an old version of `rental`
63+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
64+
|
65+
LL | enum ProceduralMasqueradeDummyType {
66+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67+
|
68+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
69+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
70+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
71+
72+
error: using an old version of `rental`
73+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
74+
|
75+
LL | enum ProceduralMasqueradeDummyType {
76+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77+
|
78+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
79+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
80+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
81+
82+
error: aborting due to 8 previous errors
83+
84+
Future incompatibility report: Future breakage diagnostic:
85+
error: using an old version of `rental`
86+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
87+
|
88+
LL | enum ProceduralMasqueradeDummyType {
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
90+
|
91+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
92+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
93+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
94+
= note: `#[deny(proc_macro_back_compat)]` on by default
95+
96+
Future breakage diagnostic:
97+
error: using an old version of `rental`
98+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
99+
|
100+
LL | enum ProceduralMasqueradeDummyType {
101+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102+
|
103+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
104+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
105+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
106+
= note: `#[deny(proc_macro_back_compat)]` on by default
107+
108+
Future breakage diagnostic:
109+
error: using an old version of `rental`
110+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
111+
|
112+
LL | enum ProceduralMasqueradeDummyType {
113+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114+
|
115+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
116+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
117+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
118+
= note: `#[deny(proc_macro_back_compat)]` on by default
119+
120+
Future breakage diagnostic:
121+
error: using an old version of `rental`
122+
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
123+
|
124+
LL | enum ProceduralMasqueradeDummyType {
125+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126+
|
127+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
128+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
129+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
130+
= note: `#[deny(proc_macro_back_compat)]` on by default
131+
132+
Future breakage diagnostic:
133+
error: using an old version of `rental`
134+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
135+
|
136+
LL | enum ProceduralMasqueradeDummyType {
137+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138+
|
139+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
140+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
141+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
142+
= note: `#[deny(proc_macro_back_compat)]` on by default
143+
144+
Future breakage diagnostic:
145+
error: using an old version of `rental`
146+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
147+
|
148+
LL | enum ProceduralMasqueradeDummyType {
149+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150+
|
151+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
152+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
153+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
154+
= note: `#[deny(proc_macro_back_compat)]` on by default
155+
156+
Future breakage diagnostic:
157+
error: using an old version of `rental`
158+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
159+
|
160+
LL | enum ProceduralMasqueradeDummyType {
161+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162+
|
163+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
164+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
165+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
166+
= note: `#[deny(proc_macro_back_compat)]` on by default
167+
168+
Future breakage diagnostic:
169+
error: using an old version of `rental`
170+
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
171+
|
172+
LL | enum ProceduralMasqueradeDummyType {
173+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174+
|
175+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
176+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
177+
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
178+
= note: `#[deny(proc_macro_back_compat)]` on by default
179+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input, }
2+
PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input }
3+
PRINT-DERIVE INPUT (DEBUG): TokenStream [
4+
Ident {
5+
ident: "enum",
6+
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:1: 4:5 (#0),
7+
},
8+
Ident {
9+
ident: "ProceduralMasqueradeDummyType",
10+
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6: 4:35 (#0),
11+
},
12+
Group {
13+
delimiter: Brace,
14+
stream: TokenStream [
15+
Ident {
16+
ident: "Input",
17+
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:13:5: 13:10 (#0),
18+
},
19+
],
20+
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:36: 14:2 (#0),
21+
},
22+
]
23+
PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input, }
24+
PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input }
25+
PRINT-DERIVE INPUT (DEBUG): TokenStream [
26+
Ident {
27+
ident: "enum",
28+
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:1: 4:5 (#0),
29+
},
30+
Ident {
31+
ident: "ProceduralMasqueradeDummyType",
32+
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6: 4:35 (#0),
33+
},
34+
Group {
35+
delimiter: Brace,
36+
stream: TokenStream [
37+
Ident {
38+
ident: "Input",
39+
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:13:5: 13:10 (#0),
40+
},
41+
],
42+
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:36: 14:2 (#0),
43+
},
44+
]

tests/ui/proc-macro/pretty-print-hack-show.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// aux-build:test-macros.rs
22
// compile-flags: -Z span-debug
3+
// revisions: local remapped
4+
// [remapped]compile-flags: --remap-path-prefix={{src-base}}=remapped
5+
6+
// The remapped paths are not normalized by compiletest.
7+
// normalize-stdout-test: "\\(proc-macro|pretty-print-hack)" -> "/$1"
8+
// normalize-stderr-test: "\\(proc-macro|pretty-print-hack)" -> "/$1"
39

410
#![no_std] // Don't load unnecessary hygiene information from std
511
extern crate std;

0 commit comments

Comments
 (0)