Skip to content

Commit d74fd5e

Browse files
committed
---
yaml --- r: 225262 b: refs/heads/stable c: 98f41ff h: refs/heads/master v: v3
1 parent e135b2b commit d74fd5e

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
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 666575861405712d302fe32cbe563ced8d98b8ad
32+
refs/heads/stable: 98f41ff3555dba80b47ebee6f6bc8a7df697240c
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/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)