Skip to content

Commit f502ebe

Browse files
committed
---
yaml --- r: 150892 b: refs/heads/try2 c: 14e1fd4 h: refs/heads/master v: v3
1 parent 02e6191 commit f502ebe

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
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: 3b9ade0f81d519733940ec28b796c11fdb0fd17b
8+
refs/heads/try2: 14e1fd46290e175692b495d1e024a3975568f417
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/ty.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,13 +2416,13 @@ pub enum Representability {
24162416

24172417
/// Check whether a type is representable. This means it cannot contain unboxed
24182418
/// structural recursion. This check is needed for structs and enums.
2419-
pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
2419+
pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
24202420

24212421
// Iterate until something non-representable is found
2422-
fn find_nonrepresentable<It: Iterator<t>>(cx: &ctxt, seen: &mut Vec<DefId>,
2422+
fn find_nonrepresentable<It: Iterator<t>>(cx: &ctxt, sp: Span, seen: &mut Vec<DefId>,
24232423
mut iter: It) -> Representability {
24242424
for ty in iter {
2425-
let r = type_structurally_recursive(cx, seen, ty);
2425+
let r = type_structurally_recursive(cx, sp, seen, ty);
24262426
if r != Representable {
24272427
return r
24282428
}
@@ -2432,7 +2432,7 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24322432

24332433
// Does the type `ty` directly (without indirection through a pointer)
24342434
// contain any types on stack `seen`?
2435-
fn type_structurally_recursive(cx: &ctxt, seen: &mut Vec<DefId>,
2435+
fn type_structurally_recursive(cx: &ctxt, sp: Span, seen: &mut Vec<DefId>,
24362436
ty: t) -> Representability {
24372437
debug!("type_structurally_recursive: {}",
24382438
::util::ppaux::ty_to_str(cx, ty));
@@ -2455,19 +2455,19 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24552455
match get(ty).sty {
24562456
// Tuples
24572457
ty_tup(ref ts) => {
2458-
find_nonrepresentable(cx, seen, ts.iter().map(|t| *t))
2458+
find_nonrepresentable(cx, sp, seen, ts.iter().map(|t| *t))
24592459
}
24602460
// Fixed-length vectors.
24612461
// FIXME(#11924) Behavior undecided for zero-length vectors.
24622462
ty_vec(ty, VstoreFixed(_)) => {
2463-
type_structurally_recursive(cx, seen, ty)
2463+
type_structurally_recursive(cx, sp, seen, ty)
24642464
}
24652465

24662466
// Push struct and enum def-ids onto `seen` before recursing.
24672467
ty_struct(did, ref substs) => {
24682468
seen.push(did);
24692469
let fields = struct_fields(cx, did, substs);
2470-
let r = find_nonrepresentable(cx, seen,
2470+
let r = find_nonrepresentable(cx, sp, seen,
24712471
fields.iter().map(|f| f.mt.ty));
24722472
seen.pop();
24732473
r
@@ -2478,8 +2478,10 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24782478

24792479
let mut r = Representable;
24802480
for variant in vs.iter() {
2481-
let iter = variant.args.iter().map(|aty| subst(cx, substs, *aty));
2482-
r = find_nonrepresentable(cx, seen, iter);
2481+
let iter = variant.args.iter().map(|aty| {
2482+
aty.subst_spanned(cx, substs, Some(sp))
2483+
});
2484+
r = find_nonrepresentable(cx, sp, seen, iter);
24832485

24842486
if r != Representable { break }
24852487
}
@@ -2499,7 +2501,7 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24992501
// contains a different, structurally recursive type, maintain a stack
25002502
// of seen types and check recursion for each of them (issues #3008, #3779).
25012503
let mut seen: Vec<DefId> = Vec::new();
2502-
type_structurally_recursive(cx, &mut seen, ty)
2504+
type_structurally_recursive(cx, sp, &mut seen, ty)
25032505
}
25042506

25052507
pub fn type_is_trait(ty: t) -> bool {

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3356,7 +3356,7 @@ pub fn check_representable(tcx: &ty::ctxt,
33563356
// recursive type. It is only necessary to throw an error on those that
33573357
// contain themselves. For case 2, there must be an inner type that will be
33583358
// caught by case 1.
3359-
match ty::is_type_representable(tcx, rty) {
3359+
match ty::is_type_representable(tcx, sp, rty) {
33603360
ty::SelfRecursive => {
33613361
tcx.sess.span_err(
33623362
sp, format!("illegal recursive {} type; \

branches/try2/src/test/compile-fail/issue-5997-enum.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: missing type param `Z` in the substitution of `Z`
12-
1311
fn f<Z>() -> bool {
1412
enum E { V(Z) }
13+
//~^ ERROR missing type param `Z` in the substitution of `Z`
1514

1615
true
1716
}

0 commit comments

Comments
 (0)