about summary refs log tree commit diff
path: root/tests/ui/parser
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-25 17:05:33 +0100
committerGitHub <noreply@github.com>2024-03-25 17:05:33 +0100
commite9ec44251c32dfe2a8e0b82a72b402df615bbd8b (patch)
treec405692cef9241f9742b3889bcc00d2c6f48c78c /tests/ui/parser
parentccc5310922807e168d3be5c22b77cf3d76ce4f09 (diff)
parent08235b1603f77f39468e7b2e552945501c0cc048 (diff)
downloadrust-e9ec44251c32dfe2a8e0b82a72b402df615bbd8b.tar.gz
rust-e9ec44251c32dfe2a8e0b82a72b402df615bbd8b.zip
Rollup merge of #122910 - compiler-errors:unit-struct-in-path-pat-only, r=petrochenkov
Validate that we're only matching on unit struct for path pattern

Resolution doesn't validate that we only really take `CtorKind::Unit` in path patterns, since all it sees is `Res::SelfCtor(def_id)`. Check this instead during pattern typeck.

r? petrochenkov

Fixes #122809
Diffstat (limited to 'tests/ui/parser')
-rw-r--r--tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs4
-rw-r--r--tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr9
2 files changed, 7 insertions, 6 deletions
diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs
index aeccd0d9f76..ada10fcda27 100644
--- a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs
+++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs
@@ -4,12 +4,12 @@ impl S {
     fn foo(&mur Self) {}
     //~^ ERROR expected identifier, found keyword `Self`
     //~| ERROR expected one of `:`, `@`
-    //~| ERROR the `Self` constructor can only be used with
+    //~| ERROR expected unit struct, found self constructor `Self`
     fn bar(&'static mur Self) {}
     //~^ ERROR unexpected lifetime
     //~| ERROR expected identifier, found keyword `Self`
     //~| ERROR expected one of `:`, `@`
-    //~| ERROR the `Self` constructor can only be used with
+    //~| ERROR expected unit struct, found self constructor `Self`
 
     fn baz(&mur Self @ _) {}
     //~^ ERROR expected one of `:`, `@`
diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr
index 421f1454036..ec0af9a6caf 100644
--- a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr
+++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr
@@ -40,17 +40,18 @@ error: expected one of `:`, `@`, or `|`, found keyword `Self`
 LL |     fn baz(&mur Self @ _) {}
    |                 ^^^^ expected one of `:`, `@`, or `|`
 
-error: the `Self` constructor can only be used with tuple or unit structs
+error[E0533]: expected unit struct, found self constructor `Self`
   --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
    |
 LL |     fn foo(&mur Self) {}
-   |                 ^^^^ help: use curly brackets: `Self { /* fields */ }`
+   |                 ^^^^ not a unit struct
 
-error: the `Self` constructor can only be used with tuple or unit structs
+error[E0533]: expected unit struct, found self constructor `Self`
   --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
    |
 LL |     fn bar(&'static mur Self) {}
-   |                         ^^^^ help: use curly brackets: `Self { /* fields */ }`
+   |                         ^^^^ not a unit struct
 
 error: aborting due to 8 previous errors
 
+For more information about this error, try `rustc --explain E0533`.