You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8e5e2cc
Browse filesBrowse the repository at this point in the historyBrowse files
Rollup merge of #162340 - fmease:fix-for-dyn-recovery, r=davidtwco
When trying to recover from `for<…> dyn …` don't unconditionally treat `dyn` as a keyword
`dyn` is only a keyword in Rust 2015 if it's followed by a token in the following set: {*PathIdentSegment*, *LIFETIME_TOKEN*, `for`, `(`, `?`}. However, the `for<…> dyn …` → `dyn for<…> …` recovery code treated it as a keyword unconditionally meaning we were **incorrectly rejecting Rust 2015 code** like `trait dyn {} type X = for<> dyn;` (regressed in PR #117891).
This is very similar to issue #157565.
<sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
Copy file name to clipboardExpand all lines: tests/ui/parser/dyn-2015-identifier.fail.stderr
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,12 @@ error[E0405]: cannot find trait `dyn` in this scope
52
52
LL | type A4 = dyn + dyn;
53
53
| ^^^ not found in this scope
54
54
55
+
error[E0405]: cannot find trait `dyn` in this scope
56
+
--> $DIR/dyn-2015-identifier.rs:33:17
57
+
|
58
+
LL | type A5 = for<> dyn;
59
+
| ^^^ not found in this scope
60
+
55
61
warning: trait objects without an explicit `dyn` are deprecated
56
62
--> $DIR/dyn-2015-identifier.rs:24:11
57
63
|
@@ -66,6 +72,19 @@ help: if this is a dyn-compatible trait, use `dyn`
66
72
LL | type A4 = dyn dyn + dyn;
67
73
| +++
68
74
75
+
warning: trait objects without an explicit `dyn` are deprecated
76
+
--> $DIR/dyn-2015-identifier.rs:33:11
77
+
|
78
+
LL | type A5 = for<> dyn;
79
+
| ^^^^^^^^^
80
+
|
81
+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
82
+
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
83
+
help: if this is a dyn-compatible trait, use `dyn`
84
+
|
85
+
LL | type A5 = dyn for<> dyn;
86
+
| +++
87
+
69
88
error[E0433]: cannot find module or crate `dyn` in this scope
70
89
--> $DIR/dyn-2015-identifier.rs:10:11
71
90
|
@@ -74,7 +93,7 @@ LL | type A1 = dyn::dyn;
74
93
|
75
94
= help: you might be missing a crate named `dyn`
76
95
77
-
error: aborting due to 10 previous errors; 1 warning emitted
96
+
error: aborting due to 11 previous errors; 2 warnings emitted
78
97
79
98
Some errors have detailed explanations: E0405, E0425, E0433.
80
99
For more information about an error, try `rustc --explain E0405`.
0 commit comments