about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-12-21 03:02:07 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-12-21 03:02:07 +0000
commit1549af29c3fea4c9afde42712b5092d8cc98e140 (patch)
treeeef347149220a58f709cded0a39f0c6c2f6acf57
parentcbbc7becc820e05f64d8a23d1a63a27e51b8ff7a (diff)
downloadrust-1549af29c3fea4c9afde42712b5092d8cc98e140.tar.gz
rust-1549af29c3fea4c9afde42712b5092d8cc98e140.zip
Do not suggest `foo.Bar`
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs7
-rw-r--r--tests/ui/parser/raw/raw-literal-keywords.stderr10
2 files changed, 6 insertions, 11 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 30a150db728..1ddb5fc0a11 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -746,7 +746,12 @@ impl<'a> Parser<'a> {
     }
 
     fn recover_missing_dot(&mut self, err: &mut Diag<'_>) {
-        if !self.token.is_ident() {
+        let Some((ident, _)) = self.token.ident() else {
+            return;
+        };
+        if let Some(c) = ident.name.as_str().chars().next()
+            && c.is_uppercase()
+        {
             return;
         }
         if self.token.is_reserved_ident() && !self.token.is_ident_named(kw::Await) {
diff --git a/tests/ui/parser/raw/raw-literal-keywords.stderr b/tests/ui/parser/raw/raw-literal-keywords.stderr
index c7d63672661..f7b6c894a90 100644
--- a/tests/ui/parser/raw/raw-literal-keywords.stderr
+++ b/tests/ui/parser/raw/raw-literal-keywords.stderr
@@ -9,22 +9,12 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
    |
 LL |     r#struct Test;
    |              ^^^^ expected one of 8 possible tokens
-   |
-help: you might have meant to write a field access
-   |
-LL |     r#struct.Test;
-   |             +
 
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test`
   --> $DIR/raw-literal-keywords.rs:10:13
    |
 LL |     r#union Test;
    |             ^^^^ expected one of 8 possible tokens
-   |
-help: you might have meant to write a field access
-   |
-LL |     r#union.Test;
-   |            +
 
 error[E0425]: cannot find value `r#if` in this scope
   --> $DIR/raw-literal-keywords.rs:14:13