Make default error reporting deterministic
This commit is contained in:
parent
d732f7323b
commit
9da04b2bd1
4 changed files with 35 additions and 10 deletions
|
|
@ -12,12 +12,19 @@ use std::fmt::Debug;
|
|||
|
||||
// Example from the RFC
|
||||
fn foo<F:Default=usize>() -> F { F::default() }
|
||||
//~^ NOTE: a default was defined here...
|
||||
|
||||
fn bar<B:Debug=isize>(b: B) { println!("{:?}", b); }
|
||||
//~^ NOTE: a second default was defined here...
|
||||
|
||||
fn main() {
|
||||
// Here, F is instantiated with $0=uint
|
||||
let x = foo();
|
||||
//~^ ERROR: mismatched types
|
||||
//~| NOTE: conflicting type parameter defaults `usize` and `isize`
|
||||
//~| NOTE: ...that was applied to an unconstrained type variable here
|
||||
|
||||
// Here, B is instantiated with $1=uint, and constraint $0 <: $1 is added.
|
||||
bar(x);
|
||||
//~^ NOTE: ...that also applies to the same type variable here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,20 @@
|
|||
// <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.
|
||||
//
|
||||
//aux-build:default_ty_param_cross_crate_crate.rs
|
||||
extern crate default_param_test;
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::collections::HashMap;
|
||||
use default_param_test::{Foo, bleh};
|
||||
|
||||
fn foo<R=()>(x: HashMap<i32, i32, R>) -> HashMap<i32, i32, R> { x }
|
||||
fn bar<R=char>(x: HashMap<i32, i32, R>) {}
|
||||
fn meh<X, B=bool>(x: Foo<X, B>) {}
|
||||
//~^ NOTE: a default was defined here...
|
||||
|
||||
fn main() {
|
||||
let x: HashMap<i32, i32, _> = foo(panic!());
|
||||
bar(x);
|
||||
let foo = bleh();
|
||||
//~^ NOTE: ...that also applies to the same type variable here
|
||||
|
||||
meh(foo);
|
||||
//~^ ERROR: mismatched types:
|
||||
//~| NOTE: conflicting type parameter defaults `bool` and `char`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue