Skip to content

Commit d82f912

Browse files
committed
Fallout from this change.
1 parent 58dc3bb commit d82f912

15 files changed

+220
-54
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that we get an error when you use `<Self as Get>::Value` in
12+
// the trait definition but `Self` does not, in fact, implement `Get`.
13+
//
14+
// See also associated-types-no-suitable-supertrait.rs, which checks
15+
// that we see the same error when making this mistake on an impl
16+
// rather than the default method impl.
17+
//
18+
// See also run-pass/associated-types-projection-to-unrelated-trait.rs,
19+
// which checks that the trait interface itself is not considered an
20+
// error as long as all impls satisfy the constraint.
21+
22+
trait Get : ::std::marker::MarkerTrait {
23+
type Value;
24+
}
25+
26+
trait Other {
27+
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
28+
//~^ ERROR the trait `Get` is not implemented for the type `Self`
29+
}
30+
31+
fn main() { }

src/test/compile-fail/associated-types-no-suitable-supertrait.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,30 @@
1010

1111
// Check that we get an error when you use `<Self as Get>::Value` in
1212
// the trait definition but `Self` does not, in fact, implement `Get`.
13+
//
14+
// See also associated-types-no-suitable-supertrait-2.rs, which checks
15+
// that we see the same error if we get around to checking the default
16+
// method body.
17+
//
18+
// See also run-pass/associated-types-projection-to-unrelated-trait.rs,
19+
// which checks that the trait interface itself is not considered an
20+
// error as long as all impls satisfy the constraint.
1321

1422
trait Get : ::std::marker::MarkerTrait {
1523
type Value;
1624
}
1725

1826
trait Other {
1927
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
20-
//~^ ERROR the trait `Get` is not implemented for the type `Self`
28+
// (note that we no longer catch the error here, since the
29+
// error below aborts compilation.
30+
// See also associated-types-no-suitable-supertrait-2.rs
31+
// which checks that this error would be caught eventually.)
2132
}
2233

2334
impl<T:Get> Other for T {
2435
fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
2536
//~^ ERROR the trait `Get` is not implemented for the type `(T, U)`
26-
//~| ERROR the trait `Get` is not implemented for the type `(T, U)`
2737
}
2838

2939
fn main() { }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests that enum-to-float casts are disallowed.
12+
13+
enum E {
14+
L0 = -1,
15+
H0 = 1
16+
}
17+
18+
enum F {
19+
L1 = 1,
20+
H1 = 0xFFFFFFFFFFFFFFFF
21+
}
22+
23+
pub fn main() {
24+
let a = E::L0 as f32; //~ ERROR illegal cast
25+
let c = F::H1 as f32; //~ ERROR illegal cast
26+
assert_eq!(a, -1.0f32);
27+
assert_eq!(c, -1.0f32);
28+
}

src/test/compile-fail/enum-to-float-cast.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ static C0: f32 = E::L0 as f32; //~ ERROR illegal cast
2424
static C1: f32 = F::H1 as f32; //~ ERROR illegal cast
2525

2626
pub fn main() {
27-
let a = E::L0 as f32; //~ ERROR illegal cast
2827
let b = C0;
29-
let c = F::H1 as f32; //~ ERROR illegal cast
3028
let d = C1;
31-
assert_eq!(a, -1.0f32);
3229
assert_eq!(b, -1.0f32);
33-
assert_eq!(c, -1.0f32);
3430
assert_eq!(d, -1.0f32);
3531
}

src/test/compile-fail/issue-16048.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'a> Test<'a> for Foo<'a> {
2929
impl<'a> NoLifetime for Foo<'a> {
3030
fn get<'p, T : Test<'a>>(&self) -> T {
3131
//~^ ERROR lifetime parameters or bounds on method `get` do not match the trait declaration
32-
return *self as T; //~ ERROR non-scalar cast: `Foo<'a>` as `T`
32+
return *self as T;
3333
}
3434
}
3535

src/test/compile-fail/issue-19244-1.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ const TUP: (usize,) = (42,);
1212

1313
fn main() {
1414
let a: [isize; TUP.1];
15-
//~^ ERROR array length constant evaluation error: tuple index out of bounds
16-
//~| ERROR attempted out-of-bounds tuple index
17-
//~| ERROR attempted out-of-bounds tuple index
15+
//~^ ERROR attempted out-of-bounds tuple index
1816
}

src/test/compile-fail/issue-19244-2.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ const STRUCT: MyStruct = MyStruct { field: 42 };
1313

1414
fn main() {
1515
let a: [isize; STRUCT.nonexistent_field];
16-
//~^ ERROR array length constant evaluation error: nonexistent struct field
17-
//~| ERROR attempted access of field `nonexistent_field`
18-
//~| ERROR attempted access of field `nonexistent_field`
16+
//~^ ERROR attempted access of field `nonexistent_field`
1917
}

src/test/compile-fail/issue-2063.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ impl to_str_2 for t {
2828
}
2929

3030
fn new_t(x: t) {
31-
x.my_to_string(); //~ ERROR does not implement
31+
x.my_to_string();
32+
// (there used to be an error emitted right here as well. It was
33+
// spurious, at best; if `t` did exist as a type, it clearly would
34+
// have an impl of the `to_str_2` trait.)
3235
}
3336

3437
fn main() {

src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs

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

1313
fn main() {
1414
fn bar(n: isize) {
15+
// FIXME (#24414): This error message needs improvement.
1516
let _x: [isize; n];
1617
//~^ ERROR no type for local variable
17-
//~| ERROR array length constant evaluation error: non-constant path in constant expr
1818
}
1919
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that `base` in `Fru { field: expr, ..base }` must have right type.
12+
//
13+
// See also struct-base-wrong-type.rs, which tests same condition
14+
// within a const expression.
15+
16+
struct Foo { a: isize, b: isize }
17+
struct Bar { x: isize }
18+
19+
fn main() {
20+
let b = Bar { x: 5 };
21+
let f = Foo { a: 2, ..b }; //~ ERROR mismatched types
22+
//~| expected `Foo`
23+
//~| found `Bar`
24+
//~| expected struct `Foo`
25+
//~| found struct `Bar`
26+
let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types
27+
//~| expected `Foo`
28+
//~| found `_`
29+
//~| expected struct `Foo`
30+
//~| found integral variable
31+
}

0 commit comments

Comments
 (0)