Fix associated const resolution on structs
This commit is contained in:
parent
ceaaa1bc33
commit
d6c9aa8901
@ -2752,7 +2752,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
};
|
||||
if let Some(path_res) = resolution {
|
||||
match path_res.base_def {
|
||||
DefVariant(..) | DefStruct(..) | DefConst(..) => {
|
||||
DefStruct(..) if path_res.depth == 0 => {
|
||||
self.record_def(pattern.id, path_res);
|
||||
}
|
||||
DefVariant(..) | DefConst(..) => {
|
||||
self.record_def(pattern.id, path_res);
|
||||
}
|
||||
DefStatic(..) => {
|
||||
|
@ -8,10 +8,14 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:empty-struct.rs
|
||||
|
||||
#![feature(associated_consts)]
|
||||
|
||||
extern crate empty_struct;
|
||||
use empty_struct::XEmpty2 as XFoo;
|
||||
|
||||
struct Foo;
|
||||
type FooWorkaround = Foo;
|
||||
|
||||
enum Bar {
|
||||
Var1,
|
||||
@ -31,6 +35,10 @@ impl HasBar for Foo {
|
||||
const THEBAR: Bar = Bar::Var1;
|
||||
}
|
||||
|
||||
impl HasBar for XFoo {
|
||||
const THEBAR: Bar = Bar::Var1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Inherent impl
|
||||
assert!(match Bar::Var2 {
|
||||
@ -43,7 +51,7 @@ fn main() {
|
||||
});
|
||||
// Trait impl
|
||||
assert!(match Bar::Var1 {
|
||||
FooWorkaround::THEBAR => true,
|
||||
Foo::THEBAR => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(match Bar::Var1 {
|
||||
@ -54,4 +62,16 @@ fn main() {
|
||||
<Foo as HasBar>::THEBAR => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(match Bar::Var1 {
|
||||
XFoo::THEBAR => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(match Bar::Var1 {
|
||||
<XFoo>::THEBAR => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(match Bar::Var1 {
|
||||
<XFoo as HasBar>::THEBAR => true,
|
||||
_ => false,
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user