Skip to content

Commit 7cde639

Browse files
committed
Remove proc-macro back-compat hack for rental
This leaves the hack in place for allsorts-rental - it still relies on this backc-ompat hack to compile, and some crates on crates.io are still using it. We've been emitting future-incompat report warnings for rental for a while now, and fixing a broken build only requires bumping rental to the latest point release.
1 parent 52372f9 commit 7cde639

File tree

3 files changed

+16
-118
lines changed

3 files changed

+16
-118
lines changed

compiler/rustc_expand/src/base.rs

+14-27
Original file line numberDiff line numberDiff line change
@@ -1424,38 +1424,25 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool {
14241424
if variant.ident.name == sym::Input {
14251425
let filename = sess.source_map().span_to_filename(item.ident.span);
14261426
if let FileName::Real(real) = filename {
1427-
if let Some(c) = real
1427+
if let real
14281428
.local_path()
14291429
.unwrap_or(Path::new(""))
14301430
.components()
14311431
.flat_map(|c| c.as_os_str().to_str())
1432-
.find(|c| c.starts_with("rental") || c.starts_with("allsorts-rental"))
1432+
.find(|c| c.starts_with("allsorts-rental"))
1433+
.is_some()
14331434
{
1434-
let crate_matches = if c.starts_with("allsorts-rental") {
1435-
true
1436-
} else {
1437-
let mut version = c.trim_start_matches("rental-").split('.');
1438-
version.next() == Some("0")
1439-
&& version.next() == Some("5")
1440-
&& version
1441-
.next()
1442-
.and_then(|c| c.parse::<u32>().ok())
1443-
.map_or(false, |v| v < 6)
1444-
};
1445-
1446-
if crate_matches {
1447-
sess.buffer_lint_with_diagnostic(
1448-
&PROC_MACRO_BACK_COMPAT,
1449-
item.ident.span,
1450-
ast::CRATE_NODE_ID,
1451-
"using an old version of `rental`",
1452-
BuiltinLintDiagnostics::ProcMacroBackCompat(
1453-
"older versions of the `rental` crate will stop compiling in future versions of Rust; \
1454-
please update to `rental` v0.5.6, or switch to one of the `rental` alternatives".to_string()
1455-
)
1456-
);
1457-
return true;
1458-
}
1435+
sess.buffer_lint_with_diagnostic(
1436+
&PROC_MACRO_BACK_COMPAT,
1437+
item.ident.span,
1438+
ast::CRATE_NODE_ID,
1439+
"using an old version of `rental`",
1440+
BuiltinLintDiagnostics::ProcMacroBackCompat(
1441+
"older versions of the `rental` crate will stop compiling in future versions of Rust; \
1442+
please update to `rental` v0.5.6, or switch to one of the `rental` alternatives".to_string()
1443+
)
1444+
);
1445+
return true;
14591446
}
14601447
}
14611448
}

tests/ui/proc-macro/pretty-print-hack-show.local.stderr

+1-89
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,7 @@ LL | enum ProceduralMasqueradeDummyType {
3939
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
4040
= 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
4141

42-
error: using an old version of `rental`
43-
--> $DIR/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-
--> $DIR/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-
--> $DIR/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-
--> $DIR/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
42+
error: aborting due to 4 previous errors
8343

8444
Future incompatibility report: Future breakage diagnostic:
8545
error: using an old version of `rental`
@@ -129,51 +89,3 @@ LL | enum ProceduralMasqueradeDummyType {
12989
= 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
13090
= note: `#[deny(proc_macro_back_compat)]` on by default
13191

132-
Future breakage diagnostic:
133-
error: using an old version of `rental`
134-
--> $DIR/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-
--> $DIR/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-
--> $DIR/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-
--> $DIR/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-

tests/ui/proc-macro/pretty-print-hack-show.local.stdout

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
2020
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:36: 14:2 (#0),
2121
},
2222
]
23-
PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input, }
24-
PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input }
23+
PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input }
2524
PRINT-DERIVE INPUT (DEBUG): TokenStream [
2625
Ident {
2726
ident: "enum",

0 commit comments

Comments
 (0)