Fix call-generic-method-nonconst test
This commit is contained in:
parent
7106f8d8ee
commit
6b6ad781f8
3 changed files with 20 additions and 4 deletions
|
@ -3261,7 +3261,7 @@ impl<'hir> Node<'hir> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `Constness::Const` when this node is a const fn/impl.
|
/// Returns `Constness::Const` when this node is a const fn/impl/item.
|
||||||
pub fn constness(&self) -> Constness {
|
pub fn constness(&self) -> Constness {
|
||||||
match self {
|
match self {
|
||||||
Node::Item(Item {
|
Node::Item(Item {
|
||||||
|
@ -3278,6 +3278,10 @@ impl<'hir> Node<'hir> {
|
||||||
})
|
})
|
||||||
| Node::Item(Item { kind: ItemKind::Impl(Impl { constness, .. }), .. }) => *constness,
|
| Node::Item(Item { kind: ItemKind::Impl(Impl { constness, .. }), .. }) => *constness,
|
||||||
|
|
||||||
|
Node::Item(Item { kind: ItemKind::Const(..), .. })
|
||||||
|
| Node::TraitItem(TraitItem { kind: TraitItemKind::Const(..), .. })
|
||||||
|
| Node::ImplItem(ImplItem { kind: ImplItemKind::Const(..), .. }) => Constness::Const,
|
||||||
|
|
||||||
_ => Constness::NotConst,
|
_ => Constness::NotConst,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// FIXME(jschievink): this is not rejected correctly (only when the non-const impl is actually used)
|
|
||||||
// ignore-test
|
|
||||||
|
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
|
#![feature(const_fn_trait_bound)]
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
error[E0277]: can't compare `S` with `S`
|
||||||
|
--> $DIR/call-generic-method-nonconst.rs:19:34
|
||||||
|
|
|
||||||
|
LL | const fn equals_self<T: PartialEq>(t: &T) -> bool {
|
||||||
|
| --------- required by this bound in `equals_self`
|
||||||
|
...
|
||||||
|
LL | pub const EQ: bool = equals_self(&S);
|
||||||
|
| ^^ no implementation for `S == S`
|
||||||
|
|
|
||||||
|
= help: the trait `PartialEq` is not implemented for `S`
|
||||||
|
|
||||||
|
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