Fix call-generic-method-nonconst test
This commit is contained in:
parent
7106f8d8ee
commit
6b6ad781f8
@ -3261,7 +3261,7 @@ pub fn hir_id(&self) -> Option<HirId> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
match self {
|
||||
Node::Item(Item {
|
||||
@ -3278,6 +3278,10 @@ pub fn constness(&self) -> 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,
|
||||
}
|
||||
}
|
||||
|
@ -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_fn_trait_bound)]
|
||||
|
||||
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…
Reference in New Issue
Block a user