Skip to content

Commit e10614a

Browse files
committed
adjust range tests
Since the desugaring removed special handling for ranges, the error message changed and so I had to adjust `range-1`. Turns out there was a bug where borrowck was too restrictive in some rare cases of constructing ranges from literals. The `range-2` test enshrined this bug -- now it's adjusted to test a case that's actually wrong.
1 parent 69719df commit e10614a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/test/compile-fail/range-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
pub fn main() {
1414
// Mixed types.
1515
let _ = 0u32..10i32;
16-
//~^ ERROR start and end of range have incompatible types
16+
//~^ ERROR mismatched types
1717

1818
// Bool => does not implement iterator.
1919
for i in false..true {}

src/test/compile-fail/range-2.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -12,8 +12,10 @@
1212

1313
pub fn main() {
1414
let r = {
15-
&42..&42
16-
//~^ ERROR borrowed value does not live long enough
17-
//~^^ ERROR borrowed value does not live long enough
15+
let a = 42;
16+
let b = 42;
17+
&a..&b
18+
//~^ ERROR `a` does not live long enough
19+
//~^^ ERROR `b` does not live long enough
1820
};
1921
}

src/test/run-pass/range.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -44,6 +44,7 @@ pub fn main() {
4444
let _ = 0_usize..4+4-3;
4545
let _ = 0..foo();
4646

47+
let _ = { &42..&100 }; // references to literals are OK
4748
let _ = ..42_usize;
4849

4950
// Test we can use two different types with a common supertype.

0 commit comments

Comments
 (0)