Skip to content

Commit cc53ca4

Browse files
committed
Allow raw path-segment kw but not suggest escaping them
1 parent c8bc460 commit cc53ca4

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ impl Ident {
30823082
/// We see this identifier in a normal identifier position, like variable name or a type.
30833083
/// How was it written originally? Did it use the raw form? Let's try to guess.
30843084
pub fn is_raw_guess(self) -> bool {
3085-
self.name.can_be_raw() && self.is_reserved()
3085+
self.name.can_be_raw() && !self.is_path_segment_keyword() && self.is_reserved()
30863086
}
30873087

30883088
/// Given the name of a lifetime without the first quote (`'`),

tests/ui/cfg/path-kw-as-pred.stderr

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,24 @@ error: expected identifier, found keyword `crate`
2727
|
2828
LL | #[cfg_attr(crate, path = "foo")]
2929
| ^^^^^ expected identifier, found keyword
30-
|
31-
help: escape `crate` to use it as an identifier
32-
|
33-
LL | #[cfg_attr(r#crate, path = "foo")]
34-
| ++
3530

3631
error: expected identifier, found keyword `super`
3732
--> $DIR/path-kw-as-pred.rs:28:12
3833
|
3934
LL | #[cfg_attr(super, path = "foo")]
4035
| ^^^^^ expected identifier, found keyword
41-
|
42-
help: escape `super` to use it as an identifier
43-
|
44-
LL | #[cfg_attr(r#super, path = "foo")]
45-
| ++
4636

4737
error: expected identifier, found keyword `self`
4838
--> $DIR/path-kw-as-pred.rs:30:12
4939
|
5040
LL | #[cfg_attr(self, path = "foo")]
5141
| ^^^^ expected identifier, found keyword
52-
|
53-
help: escape `self` to use it as an identifier
54-
|
55-
LL | #[cfg_attr(r#self, path = "foo")]
56-
| ++
5742

5843
error: expected identifier, found keyword `Self`
5944
--> $DIR/path-kw-as-pred.rs:32:12
6045
|
6146
LL | #[cfg_attr(Self, path = "foo")]
6247
| ^^^^ expected identifier, found keyword
63-
|
64-
help: escape `Self` to use it as an identifier
65-
|
66-
LL | #[cfg_attr(r#Self, path = "foo")]
67-
| ++
6848

6949
error: expected identifier, found keyword `crate`
7050
--> $DIR/path-kw-as-pred.rs:34:22

0 commit comments

Comments
 (0)