Auto merge of #21523 - nikomatsakis:issue-21245-japaric-ti-failure, r=eddyb
This also includes some miscellaneous cleanup. This is kind of a band-aid but it fixes the problems @japaric was encountering. r? @eddyb
This commit is contained in:
commit
92ff8ea528
19 changed files with 326 additions and 125 deletions
|
|
@ -40,8 +40,8 @@ impl Car for ModelU { }
|
|||
|
||||
fn dent<C:Car>(c: C, color: C::Color) { c.chip_paint(color) }
|
||||
fn a() { dent(ModelT, Black); }
|
||||
fn b() { dent(ModelT, Blue); } //~ ERROR type mismatch
|
||||
fn c() { dent(ModelU, Black); } //~ ERROR type mismatch
|
||||
fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types
|
||||
fn c() { dent(ModelU, Black); } //~ ERROR mismatched types
|
||||
fn d() { dent(ModelU, Blue); }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub fn f2<T: Foo>(a: T) -> T::A {
|
|||
|
||||
pub fn f1_int_int() {
|
||||
f1(2is, 4is);
|
||||
//~^ ERROR type mismatch resolving
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize
|
||||
//~| found isize
|
||||
}
|
||||
|
|
@ -51,8 +51,6 @@ pub fn f2_int() {
|
|||
//~^ ERROR mismatched types
|
||||
//~| expected `isize`
|
||||
//~| found `usize`
|
||||
//~| expected isize
|
||||
//~| found usize
|
||||
}
|
||||
|
||||
pub fn main() { }
|
||||
|
|
|
|||
|
|
@ -32,5 +32,8 @@ fn main() {
|
|||
let bits: &[_] = &[0, 1];
|
||||
|
||||
0.contains(bits);
|
||||
//~^ ERROR the trait `Set<_>` is not implemented for the type `_`
|
||||
//~^ ERROR overflow
|
||||
//~| ERROR overflow
|
||||
//~| ERROR overflow
|
||||
//~| ERROR mismatched types
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ impl Bar {
|
|||
|
||||
#[derive(Hash)]
|
||||
struct Foo(Bar);
|
||||
//~^ error: the trait `core::hash::Hash<__S>` is not implemented for the type `Bar`
|
||||
//~^ error: the trait `core::hash::Hash<_>` is not implemented for the type `Bar`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn foo(p: &Panolpy) {
|
|||
// known to be an integer, but meh.
|
||||
let x;
|
||||
22 >> x;
|
||||
//~^ ERROR right-hand-side of a shift operation must have integral type
|
||||
//~^ ERROR the type of this value must be known in this context
|
||||
|
||||
22 >> 1;
|
||||
// Integer literal types are OK
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@
|
|||
fn main() {
|
||||
let x: &[isize] = &[1, 2, 3, 4, 5];
|
||||
// Immutable slices are not mutable.
|
||||
|
||||
let y: &mut[_] = &x[2..4];
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected `&mut [_]`
|
||||
//~| found `&_`
|
||||
//~| found `&[isize]`
|
||||
//~| values differ in mutability
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ where T : Convert<U>
|
|||
}
|
||||
|
||||
fn a() {
|
||||
test(22is, 44is); //~ ERROR not implemented
|
||||
test(22is, 44is); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
41
src/test/run-pass/into-iterator-type-inference-shift.rs
Normal file
41
src/test/run-pass/into-iterator-type-inference-shift.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// 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 type inference failure around shifting. In this
|
||||
// case, the iteration yields an int, but we hadn't run the full type
|
||||
// propagation yet, and so we just saw a type variable, yielding an
|
||||
// error.
|
||||
|
||||
use std::u8;
|
||||
|
||||
trait IntoIterator {
|
||||
type Iter: Iterator;
|
||||
|
||||
fn into_iter(self) -> Self::Iter;
|
||||
}
|
||||
|
||||
impl<I> IntoIterator for I where I: Iterator {
|
||||
type Iter = I;
|
||||
|
||||
fn into_iter(self) -> I {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn desugared_for_loop_bad(byte: u8) -> u8 {
|
||||
let mut result = 0;
|
||||
let mut x = IntoIterator::into_iter(range(0, u8::BITS));
|
||||
let mut y = Iterator::next(&mut x);
|
||||
let mut z = y.unwrap();
|
||||
byte >> z;
|
||||
1
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
20
src/test/run-pass/issue-19499.rs
Normal file
20
src/test/run-pass/issue-19499.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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 issue #19499. Due to incorrect caching of trait
|
||||
// results for closures with upvars whose types were not fully
|
||||
// computed, this rather bizarre little program (along with many more
|
||||
// reasonable examples) let to ambiguity errors about not being able
|
||||
// to infer sufficient type information.
|
||||
|
||||
fn main() {
|
||||
let n = 0;
|
||||
let it = Some(1_us).into_iter().inspect(|_| {n;});
|
||||
}
|
||||
62
src/test/run-pass/issue-21245.rs
Normal file
62
src/test/run-pass/issue-21245.rs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// 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 issue #21245. Check that we are able to infer
|
||||
// the types in these examples correctly. It used to be that
|
||||
// insufficient type propagation caused the type of the iterator to be
|
||||
// incorrectly unified with the `*const` type to which it is coerced.
|
||||
|
||||
use std::ptr;
|
||||
|
||||
trait IntoIterator {
|
||||
type Iter: Iterator;
|
||||
|
||||
fn into_iter(self) -> Self::Iter;
|
||||
}
|
||||
|
||||
impl<I> IntoIterator for I where I: Iterator {
|
||||
type Iter = I;
|
||||
|
||||
fn into_iter(self) -> I {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn desugared_for_loop_bad<T>(v: Vec<T>) {
|
||||
match IntoIterator::into_iter(v.iter()) {
|
||||
mut iter => {
|
||||
loop {
|
||||
match ::std::iter::Iterator::next(&mut iter) {
|
||||
::std::option::Option::Some(x) => {
|
||||
unsafe { ptr::read(x); }
|
||||
},
|
||||
::std::option::Option::None => break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn desugared_for_loop_good<T>(v: Vec<T>) {
|
||||
match v.iter().into_iter() {
|
||||
mut iter => {
|
||||
loop {
|
||||
match ::std::iter::Iterator::next(&mut iter) {
|
||||
::std::option::Option::Some(x) => {
|
||||
unsafe { ptr::read(x); }
|
||||
},
|
||||
::std::option::Option::None => break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue