Skip to content

Commit 93d70a8

Browse files
committed
Tweaks to associated const related code.
1 parent 4eeab6a commit 93d70a8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/librustc_lint/builtin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,6 @@ impl LintPass for NonUpperCaseGlobals {
10781078
fn check_pat(&mut self, cx: &Context, p: &ast::Pat) {
10791079
// Lint for constants that look like binding identifiers (#7526)
10801080
match (&p.node, cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def())) {
1081-
(&ast::PatIdent(_, ref path1, _), Some(def::DefAssociatedConst(..))) |
10821081
(&ast::PatIdent(_, ref path1, _), Some(def::DefConst(..))) => {
10831082
NonUpperCaseGlobals::check_upper_case(cx, "constant in pattern",
10841083
path1.node, p.span);

src/librustc_typeck/check/_match.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
188188
let path_res = if let Some(&d) = tcx.def_map.borrow().get(&pat.id) {
189189
d
190190
} else if qself.position == 0 {
191-
// This is just a sentinel for finish_resolving_def_to_ty.
192191
def::PathResolution {
192+
// This is just a sentinel for finish_resolving_def_to_ty.
193193
base_def: def::DefMod(ast_util::local_def(ast::CRATE_NODE_ID)),
194194
last_private: LastMod(AllPublic),
195195
depth: path.segments.len()
@@ -616,13 +616,18 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
616616
path_scheme, &ctor_predicates,
617617
opt_ty, def, pat.span, pat.id);
618618

619-
let pat_ty = fcx.node_ty(pat.id);
620-
demand::eqtype(fcx, pat.span, expected, pat_ty);
621-
622619
// If we didn't have a fully resolved path to start with, we had an
623620
// associated const, and we should quit now, since the rest of this
624621
// function uses checks specific to structs and enums.
625-
if path_res.depth != 0 { return; }
622+
if path_res.depth != 0 {
623+
let pat_ty = fcx.node_ty(pat.id);
624+
demand::suptype(fcx, pat.span, expected, pat_ty);
625+
return;
626+
}
627+
628+
let pat_ty = fcx.node_ty(pat.id);
629+
demand::eqtype(fcx, pat.span, expected, pat_ty);
630+
626631

627632
let real_path_ty = fcx.node_ty(pat.id);
628633
let (arg_tys, kind_name): (Vec<_>, &'static str) = match real_path_ty.sty {

0 commit comments

Comments
 (0)