Skip to content

Commit 1a733d0

Browse files
committed
---
yaml --- r: 150894 b: refs/heads/try2 c: f829d20 h: refs/heads/master v: v3
1 parent cd33181 commit 1a733d0

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 52a53e8ae78d77b3c3735fbaf00e53152402295e
8+
refs/heads/try2: f829d208a30a4a8880ffb07ce4582e30c8f8d57f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/typeck/collect.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,24 @@ pub fn ty_generics(ccx: &CrateCtxt,
945945
let param_ty = ty::param_ty {idx: base_index + offset,
946946
def_id: local_def(param.id)};
947947
let bounds = @compute_bounds(ccx, param_ty, &param.bounds);
948-
let default = param.default.map(|x| ast_ty_to_ty(ccx, &ExplicitRscope, x));
948+
let default = param.default.map(|path| {
949+
let ty = ast_ty_to_ty(ccx, &ExplicitRscope, path);
950+
let cur_idx = param_ty.idx;
951+
952+
ty::walk_ty(ty, |t| {
953+
match ty::get(t).sty {
954+
ty::ty_param(p) => if p.idx > cur_idx {
955+
ccx.tcx.sess.span_err(path.span,
956+
"type parameters with a default cannot use \
957+
forward declared identifiers")
958+
},
959+
_ => {}
960+
}
961+
});
962+
963+
ty
964+
});
965+
949966
let def = ty::TypeParameterDef {
950967
ident: param.ident,
951968
def_id: local_def(param.id),

branches/try2/src/test/compile-fail/generic-type-params-forward-mention.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
// Ensure that we get an error and not an ICE for this problematic case.
1414
struct Foo<T = Option<U>, U = bool>;
15-
15+
//~^ ERROR type parameters with a default cannot use forward declared identifiers
1616
fn main() {
1717
let x: Foo;
18-
//~^ ERROR missing type param `U` in the substitution of `std::option::Option<U>`
1918
}

0 commit comments

Comments
 (0)