Closed
Description
I think this is a small diagnostic problem. This code compiles (with two warnings):
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
trait HasBar {
fn bar(&self);
}
impl const HasBar for usize {
fn bar(&self) {}
}
struct Foo<T>(T)
where T: HasBar;
impl<T> Foo<T> where T: HasBar {
const fn foo(&self)
where T: ~const HasBar {
self.0.bar();
}
}
fn main() {}
(There in the impl foo I've used both HasBar and ~const HasBar, I'm not sure if this is necessary).
If you miss the 'const' from the impl foo:
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
trait HasBar {
fn bar(&self);
}
impl const HasBar for usize {
fn bar(&self) {}
}
struct Foo<T>(T)
where T: HasBar;
impl<T> Foo<T> where T: HasBar {
fn foo(&self)
where T: ~const HasBar {
self.0.bar();
}
}
fn main() {}
It gives an error that doesn't suggest that a 'const' is missing in foo:
error: `~const` is not allowed here
--> ...\test.rs:16:14
|
16 | where T: ~const HasBar {
| ^^^^^^^^^^^^^
|
= note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions