forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#24422 - pnkfelix:typeck-highlevel-before-bodi…
…es, r=nikomatsakis typeck: Do high-level structural/signature checks before function body checks. This avoids various ICEs, e.g. premature calls to cat_expr that yield the dreaded "cat_expr Errd" ICE. However, it also means that some early error feedback is now not provided. This may be for the best, because the error feedback were were providing in some of those cases were false positives -- it was spurious feedback and a distraction from the real problem. So it is not 100% clear whether we actually want to put this change in or not. I think its a net win, but others might disagree. (Kudos to @arielb1 for suggesting this modification.)
- Loading branch information
Showing
19 changed files
with
417 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Check that we get an error when you use `<Self as Get>::Value` in | ||
// the trait definition but `Self` does not, in fact, implement `Get`. | ||
// | ||
// See also associated-types-no-suitable-supertrait.rs, which checks | ||
// that we see the same error when making this mistake on an impl | ||
// rather than the default method impl. | ||
// | ||
// See also run-pass/associated-types-projection-to-unrelated-trait.rs, | ||
// which checks that the trait interface itself is not considered an | ||
// error as long as all impls satisfy the constraint. | ||
|
||
trait Get : ::std::marker::MarkerTrait { | ||
type Value; | ||
} | ||
|
||
trait Other { | ||
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {} | ||
//~^ ERROR the trait `Get` is not implemented for the type `Self` | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Tests that enum-to-float casts are disallowed. | ||
|
||
enum E { | ||
L0 = -1, | ||
H0 = 1 | ||
} | ||
|
||
enum F { | ||
L1 = 1, | ||
H1 = 0xFFFFFFFFFFFFFFFF | ||
} | ||
|
||
pub fn main() { | ||
let a = E::L0 as f32; //~ ERROR illegal cast | ||
let c = F::H1 as f32; //~ ERROR illegal cast | ||
assert_eq!(a, -1.0f32); | ||
assert_eq!(c, -1.0f32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Regression test for #23729 | ||
|
||
fn main() { | ||
let fib = { | ||
struct Recurrence { | ||
mem: [u64; 2], | ||
pos: usize, | ||
} | ||
|
||
impl Iterator for Recurrence { | ||
//~^ ERROR not all trait items implemented, missing: `Item` [E0046] | ||
#[inline] | ||
fn next(&mut self) -> Option<u64> { | ||
if self.pos < 2 { | ||
let next_val = self.mem[self.pos]; | ||
self.pos += 1; | ||
Some(next_val) | ||
} else { | ||
let next_val = (self.mem[0] + self.mem[1]); | ||
self.mem[0] = self.mem[1]; | ||
self.mem[1] = next_val; | ||
Some(next_val) | ||
} | ||
} | ||
} | ||
|
||
Recurrence { mem: [0, 1], pos: 0 } | ||
}; | ||
|
||
for e in fib.take(10) { | ||
println!("{}", e) | ||
} | ||
} |
Oops, something went wrong.