forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#56850 - alexreg:fix-self-in-typedefs, r=pet…
…rochenkov Fixed issue with using `Self` ctor in typedefs Added two regression tests. This is definitely suitable for a beta backport. CC @Centril
- Loading branch information
Showing
7 changed files
with
176 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
enum Foo {} | ||
struct Bar {} | ||
|
||
impl Foo { | ||
fn foo() { | ||
let _ = Self; | ||
//~^ ERROR the `Self` constructor can only be used with tuple or unit structs | ||
let _ = Self(); | ||
//~^ ERROR the `Self` constructor can only be used with tuple or unit structs | ||
} | ||
} | ||
|
||
impl Bar { | ||
fn bar() { | ||
let _ = Self; | ||
//~^ ERROR the `Self` constructor can only be used with tuple or unit structs | ||
let _ = Self(); | ||
//~^ ERROR the `Self` constructor can only be used with tuple or unit structs | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
error: the `Self` constructor can only be used with tuple or unit structs | ||
--> $DIR/issue-56199.rs:7:17 | ||
| | ||
LL | let _ = Self; | ||
| ^^^^ | ||
| | ||
= note: did you mean to use one of the enum's variants? | ||
|
||
error: the `Self` constructor can only be used with tuple or unit structs | ||
--> $DIR/issue-56199.rs:9:17 | ||
| | ||
LL | let _ = Self(); | ||
| ^^^^ | ||
| | ||
= note: did you mean to use one of the enum's variants? | ||
|
||
error: the `Self` constructor can only be used with tuple or unit structs | ||
--> $DIR/issue-56199.rs:16:17 | ||
| | ||
LL | let _ = Self; | ||
| ^^^^ did you mean `Self { /* fields */ }`? | ||
|
||
error: the `Self` constructor can only be used with tuple or unit structs | ||
--> $DIR/issue-56199.rs:18:17 | ||
| | ||
LL | let _ = Self(); | ||
| ^^^^ did you mean `Self { /* fields */ }`? | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
pub struct Foo {} | ||
|
||
impl Foo { | ||
fn bar(Self(foo): Self) {} | ||
//~^ ERROR the `Self` constructor can only be used with tuple or unit structs | ||
//~^^ ERROR expected tuple struct/variant, found self constructor `Self` [E0164] | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: the `Self` constructor can only be used with tuple or unit structs | ||
--> $DIR/issue-56835.rs:5:12 | ||
| | ||
LL | fn bar(Self(foo): Self) {} | ||
| ^^^^^^^^^ did you mean `Self { /* fields */ }`? | ||
|
||
error[E0164]: expected tuple struct/variant, found self constructor `Self` | ||
--> $DIR/issue-56835.rs:5:12 | ||
| | ||
LL | fn bar(Self(foo): Self) {} | ||
| ^^^^^^^^^ not a tuple variant or struct | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0164`. |