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#59083 - kyren:master, r=varkor
Fix rust-lang#54822 and associated faulty tests Type checking associated constants can require trait bounds, but an empty parameter environment was provided to the trait solver. Providing an appropriate parameter environment seems to fix rust-lang#54822 and also make one of the cases in src/test/ui/nll/trait-associated-constant.rs that should compile successfully do so. It also (slightly) improves the error message in src/test/ui/associated-const/associated-const-generic-obligations.rs
- Loading branch information
Showing
6 changed files
with
41 additions
and
36 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
14 changes: 9 additions & 5 deletions
14
src/test/ui/associated-const/associated-const-generic-obligations.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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
error[E0277]: the trait bound `T: Foo` is not satisfied | ||
--> $DIR/associated-const-generic-obligations.rs:14:5 | ||
error[E0326]: implemented const `FROM` has an incompatible type for trait | ||
--> $DIR/associated-const-generic-obligations.rs:14:17 | ||
| | ||
LL | const FROM: Self::Out; | ||
| --------- type in trait | ||
... | ||
LL | const FROM: &'static str = "foo"; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` | ||
| ^^^^^^^^^^^^ expected associated type, found reference | ||
| | ||
= help: consider adding a `where T: Foo` bound | ||
= note: expected type `<T as Foo>::Out` | ||
found type `&'static str` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. | ||
For more information about this error, try `rustc --explain E0326`. |
21 changes: 21 additions & 0 deletions
21
src/test/ui/associated-const/associated-const-trait-bound.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,21 @@ | ||
// compile-pass | ||
|
||
trait ConstDefault { | ||
const DEFAULT: Self; | ||
} | ||
|
||
trait Foo: Sized {} | ||
|
||
trait FooExt: Foo { | ||
type T: ConstDefault; | ||
} | ||
|
||
trait Bar<F: FooExt> { | ||
const T: F::T; | ||
} | ||
|
||
impl<F: FooExt> Bar<F> for () { | ||
const T: F::T = <F::T as ConstDefault>::DEFAULT; | ||
} | ||
|
||
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