-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #119896 - oli-obk:variance_ice, r=compiler-errors
Taint `_` placeholder types in trait impl method signatures We report an error right below for them, but that kind of broken type can cause subsequent ICEs. fixes #119867
- Loading branch information
Showing
3 changed files
with
43 additions
and
2 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
13 changes: 13 additions & 0 deletions
13
tests/ui/traits/method-argument-mismatch-variance-ice-119867.rs
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,13 @@ | ||
trait Deserialize { | ||
fn deserialize(&self); | ||
} | ||
|
||
struct ArchivedVec<T>(T); | ||
|
||
impl<T> Deserialize for ArchivedVec<T> { | ||
fn deserialize(s: _) {} | ||
//~^ ERROR: `_` is not allowed within types on item signatures | ||
//~| ERROR: has a `&self` declaration in the trait, but not in the impl | ||
} | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr
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,24 @@ | ||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions | ||
--> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:23 | ||
| | ||
LL | fn deserialize(s: _) {} | ||
| ^ not allowed in type signatures | ||
| | ||
help: try replacing `_` with the type in the corresponding trait method signature | ||
| | ||
LL | fn deserialize(s: &ArchivedVec<T>) {} | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error[E0186]: method `deserialize` has a `&self` declaration in the trait, but not in the impl | ||
--> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:5 | ||
| | ||
LL | fn deserialize(&self); | ||
| ---------------------- `&self` used in trait | ||
... | ||
LL | fn deserialize(s: _) {} | ||
| ^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0121, E0186. | ||
For more information about an error, try `rustc --explain E0121`. |