ParamEnv should be const when ImplItem is within a const impl.
This commit is contained in:
parent
8710a2e169
commit
87cd1ce6c1
4 changed files with 58 additions and 30 deletions
|
|
@ -1,6 +1,5 @@
|
|||
// FIXME(fee1-dead): this should have a better error message
|
||||
#![feature(const_trait_impl)]
|
||||
// check-pass
|
||||
struct NonConstAdd(i32);
|
||||
|
||||
impl std::ops::Add for NonConstAdd {
|
||||
|
|
@ -17,7 +16,7 @@ trait Foo {
|
|||
|
||||
impl const Foo for NonConstAdd {
|
||||
type Bar = NonConstAdd;
|
||||
//TODO: ~^ ERROR
|
||||
//~^ ERROR
|
||||
}
|
||||
|
||||
trait Baz {
|
||||
|
|
|
|||
20
src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr
Normal file
20
src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd`
|
||||
--> $DIR/assoc-type.rs:18:5
|
||||
|
|
||||
LL | type Bar = NonConstAdd;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
|
||||
|
|
||||
= help: the trait `Add` is not implemented for `NonConstAdd`
|
||||
note: required by a bound in `Foo::Bar`
|
||||
--> $DIR/assoc-type.rs:14:15
|
||||
|
|
||||
LL | type Bar: ~const std::ops::Add;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
|
||||
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
|
||||
|
|
||||
LL | impl const Foo for NonConstAdd where NonConstAdd: Add {
|
||||
| ++++++++++++++++++++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue