diff options
| -rw-r--r-- | src/librustc_resolve/lib.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/associated-const-match-patterns.rs | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 447230ada22..38ab0a8c5ed 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2528,8 +2528,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // If anything ends up here entirely resolved, // it's an error. If anything ends up here // partially resolved, that's OK, because it may - // be a `T::CONST` that typeck will resolve to - // an inherent impl. + // be a `T::CONST` that typeck will resolve. if path_res.depth == 0 { self.resolve_error( path.span, @@ -2537,6 +2536,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { token::get_ident( path.segments.last().unwrap().identifier))); } else { + let const_name = path.segments.last().unwrap() + .identifier.name; + let traits = self.get_traits_containing_item(const_name); + self.trait_map.insert(pattern.id, traits); self.record_def(pattern.id, path_res); } } diff --git a/src/test/run-pass/associated-const-match-patterns.rs b/src/test/run-pass/associated-const-match-patterns.rs index eeaacbf9dcc..62e90d7a6e2 100644 --- a/src/test/run-pass/associated-const-match-patterns.rs +++ b/src/test/run-pass/associated-const-match-patterns.rs @@ -42,6 +42,10 @@ fn main() { }); // Trait impl assert!(match Bar::Var1 { + Foo::THEBAR => true, + _ => false, + }); + assert!(match Bar::Var1 { <Foo>::THEBAR => true, _ => false, }); |
