-
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 #100247 - cjgillot:verify-dyn-trait-alias-defaults, r…
…=lcnr Generalize trait object generic param check to aliases. The current algorithm only checks that `Self` does not appear in defaults for traits. This is not sufficient for trait aliases. This PR moves the check to trait object elaboration, which sees through trait aliases. Fixes #82927. Fixes #84789.
- Loading branch information
Showing
11 changed files
with
178 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
trait Foo<X = Box<dyn Foo>> { | ||
//~^ ERROR cycle detected | ||
//~| ERROR cycle detected | ||
} | ||
|
||
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
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,10 @@ | ||
trait SendEqAlias<T> = PartialEq; | ||
//~^ ERROR trait aliases are experimental | ||
|
||
struct Foo<T>(dyn SendEqAlias<T>); | ||
//~^ ERROR the type parameter `Rhs` must be explicitly specified [E0393] | ||
|
||
struct Bar<T>(dyn SendEqAlias<T>, T); | ||
//~^ ERROR the type parameter `Rhs` must be explicitly specified [E0393] | ||
|
||
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,39 @@ | ||
error[E0658]: trait aliases are experimental | ||
--> $DIR/generic-default-in-dyn.rs:1:1 | ||
| | ||
LL | trait SendEqAlias<T> = PartialEq; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information | ||
= help: add `#![feature(trait_alias)]` to the crate attributes to enable | ||
|
||
error[E0393]: the type parameter `Rhs` must be explicitly specified | ||
--> $DIR/generic-default-in-dyn.rs:4:19 | ||
| | ||
LL | struct Foo<T>(dyn SendEqAlias<T>); | ||
| ^^^^^^^^^^^^^^ missing reference to `Rhs` | ||
| | ||
::: $SRC_DIR/core/src/cmp.rs:LL:COL | ||
| | ||
LL | pub trait PartialEq<Rhs: ?Sized = Self> { | ||
| --------------------------------------- type parameter `Rhs` must be specified for this | ||
| | ||
= note: because of the default `Self` reference, type parameters must be specified on object types | ||
|
||
error[E0393]: the type parameter `Rhs` must be explicitly specified | ||
--> $DIR/generic-default-in-dyn.rs:7:19 | ||
| | ||
LL | struct Bar<T>(dyn SendEqAlias<T>, T); | ||
| ^^^^^^^^^^^^^^ missing reference to `Rhs` | ||
| | ||
::: $SRC_DIR/core/src/cmp.rs:LL:COL | ||
| | ||
LL | pub trait PartialEq<Rhs: ?Sized = Self> { | ||
| --------------------------------------- type parameter `Rhs` must be specified for this | ||
| | ||
= note: because of the default `Self` reference, type parameters must be specified on object types | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0393, E0658. | ||
For more information about an error, try `rustc --explain E0393`. |
Oops, something went wrong.