Skip to content

Commit cd6e26d

Browse files
committed
---
yaml --- r: 211197 b: refs/heads/try c: 98f41ff h: refs/heads/master i: 211195: 889014f v: v3
1 parent 613db0f commit cd6e26d

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 666575861405712d302fe32cbe563ced8d98b8ad
5+
refs/heads/try: 98f41ff3555dba80b47ebee6f6bc8a7df697240c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc_typeck/check/mod.rs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,21 +3763,34 @@ pub fn resolve_ty_and_def_ufcs<'a, 'b, 'tcx>(fcx: &FnCtxt<'b, 'tcx>,
37633763
&'a [ast::PathSegment],
37643764
def::Def)>
37653765
{
3766+
3767+
// Associated constants can't depend on generic types.
3768+
fn have_disallowed_generic_consts<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
3769+
def: def::Def,
3770+
ty: Ty<'tcx>,
3771+
span: Span,
3772+
node_id: ast::NodeId) -> bool {
3773+
match def {
3774+
def::DefAssociatedConst(..) => {
3775+
if ty::type_has_params(ty) || ty::type_has_self(ty) {
3776+
fcx.sess().span_err(span,
3777+
"Associated consts cannot depend \
3778+
on type parameters or Self.");
3779+
fcx.write_error(node_id);
3780+
return true;
3781+
}
3782+
}
3783+
_ => {}
3784+
}
3785+
false
3786+
}
3787+
37663788
// If fully resolved already, we don't have to do anything.
37673789
if path_res.depth == 0 {
3768-
// Associated constants can't depend on generic types.
37693790
if let Some(ty) = opt_self_ty {
3770-
match path_res.full_def() {
3771-
def::DefAssociatedConst(..) => {
3772-
if ty::type_has_params(ty) || ty::type_has_self(ty) {
3773-
fcx.sess().span_err(span,
3774-
"Associated consts cannot depend \
3775-
on type parameters or Self.");
3776-
fcx.write_error(node_id);
3777-
return None;
3778-
}
3779-
}
3780-
_ => {}
3791+
if have_disallowed_generic_consts(fcx, path_res.full_def(), ty,
3792+
span, node_id) {
3793+
return None;
37813794
}
37823795
}
37833796
Some((opt_self_ty, &path.segments, path_res.base_def))
@@ -3795,18 +3808,8 @@ pub fn resolve_ty_and_def_ufcs<'a, 'b, 'tcx>(fcx: &FnCtxt<'b, 'tcx>,
37953808
let item_name = item_segment.identifier.name;
37963809
match method::resolve_ufcs(fcx, span, item_name, ty, node_id) {
37973810
Ok((def, lp)) => {
3798-
// Associated constants can't depend on generic types.
3799-
match def {
3800-
def::DefAssociatedConst(..) => {
3801-
if ty::type_has_params(ty) || ty::type_has_self(ty) {
3802-
fcx.sess().span_err(span,
3803-
"Associated consts cannot depend \
3804-
on type parameters or Self.");
3805-
fcx.write_error(node_id);
3806-
return None;
3807-
}
3808-
}
3809-
_ => {}
3811+
if have_disallowed_generic_consts(fcx, def, ty, span, node_id) {
3812+
return None;
38103813
}
38113814
// Write back the new resolution.
38123815
fcx.ccx.tcx.def_map.borrow_mut()

0 commit comments

Comments
 (0)