ty::TyArray(_, n) => format!("array of {} elements", n),
ty::TySlice(_) => "slice".to_string(),
ty::TyRawPtr(_) => "*-ptr".to_string(),
- ty::TyRef(_, _) => "&-ptr".to_string(),
+ ty::TyRef(region, tymut) => {
+ let tymut_string = tymut.to_string();
+ if tymut_string == "_" || //unknown type name,
+ tymut_string.len() > 10 || //name longer than saying "reference",
+ region.to_string() != "" //... or a complex type
+ {
+ match tymut {
+ ty::TypeAndMut{mutbl, ..} => {
+ format!("{}reference", match mutbl {
+ hir::Mutability::MutMutable => "mutable ",
+ _ => ""
+ })
+ }
+ }
+ } else {
+ format!("&{}", tymut_string)
+ }
+ }
ty::TyFnDef(..) => format!("fn item"),
ty::TyFnPtr(_) => "fn pointer".to_string(),
ty::TyTrait(ref inner) => {
//~^ ERROR mismatched types
//~| expected type `&[i32]`
//~| found type `[{integer}; 1]`
- //~| expected &-ptr, found array of 1 elements
+ //~| expected &[i32], found array of 1 elements
}
let _y: &Trait = x; //~ ERROR mismatched types
//~| expected type `&Trait`
//~| found type `Box<Trait>`
- //~| expected &-ptr, found box
+ //~| expected &Trait, found box
}
//~^ ERROR mismatched types
//~| expected type `T`
//~| found type `&_`
- //~| expected trait T, found &-ptr
+ //~| expected trait T, found reference
let &&&x = &(&1isize as &T);
//~^ ERROR mismatched types
//~| expected type `T`
//~| found type `&_`
- //~| expected trait T, found &-ptr
+ //~| expected trait T, found reference
let box box x = box 1isize as Box<T>;
//~^ ERROR mismatched types
//~| expected type `T`
}
pub fn main() {
- // Test that we cannot convert from *-ptr to &-ptr
+ // Test that we cannot convert from *-ptr to &S and &T
let x: *const S = &S;
let y: &S = x; //~ ERROR mismatched types
let y: &T = x; //~ ERROR mismatched types
- // Test that we cannot convert from *-ptr to &-ptr (mut version)
+ // Test that we cannot convert from *-ptr to &S and &T (mut version)
let x: *mut S = &mut S;
let y: &S = x; //~ ERROR mismatched types
let y: &T = x; //~ ERROR mismatched types
//~^ ERROR mismatched types
//~| expected type `fn(&mut __test::test::Bencher)`
//~| found type `fn(isize) {bar}`
-//~| expected &-ptr, found isize
+//~| expected mutable reference, found isize
//~^ ERROR mismatched types
//~| expected type `&str`
//~| found type `Slice<_>`
- //~| expected &-ptr, found struct `Slice`
+ //~| expected &str, found struct `Slice`
}
(*p)(()) //~ ERROR mismatched types
//~| expected type `&mut ()`
//~| found type `()`
- //~| expected &-ptr, found ()
+ //~| expected &mut (), found ()
}
fn main() {}
impl<'a, T> Fn<(&'a T,)> for Foo {
extern "rust-call" fn call(&self, (_,): (T,)) {}
//~^ ERROR: has an incompatible type for trait
- //~| expected &-ptr
+ //~| expected reference
}
impl<'a, T> FnMut<(&'a T,)> for Foo {
extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
//~^ ERROR: has an incompatible type for trait
- //~| expected &-ptr
+ //~| expected reference
}
impl<'a, T> FnOnce<(&'a T,)> for Foo {
extern "rust-call" fn call_once(self, (_,): (T,)) {}
//~^ ERROR: has an incompatible type for trait
- //~| expected &-ptr
+ //~| expected reference
}
fn main() {}
fn bar(d: u8) { }
bar(&mut $d);
//~^ ERROR mismatched types
- //~| expected u8, found &-ptr
+ //~| expected u8, found &mut u8
//~| expected type `u8`
//~| found type `&mut u8`
}}
//~^ ERROR mismatched types
//~| expected type `(bool, bool)`
//~| found type `&_`
-//~| expected tuple, found &-ptr
+//~| expected tuple, found reference
}
//~^ ERROR mismatched types
//~| expected type `()`
//~| found type `&_`
- //~| expected (), found &-ptr
+ //~| expected (), found reference
}
//~^ ERROR mismatched types
//~| expected type `Box<BarStruct>`
//~| found type `&'a mut BarStruct`
- //~| expected box, found &-ptr
+ //~| expected box, found mutable reference
}
fn main() {}
//~^ ERROR mismatched types
//~| expected type `&std::option::Option<{integer}>`
//~| found type `std::option::Option<_>`
- //~| expected &-ptr, found enum `std::option::Option`
+ //~| expected reference, found enum `std::option::Option`
None => ()
//~^ ERROR mismatched types
//~| expected type `&std::option::Option<{integer}>`
//~| found type `std::option::Option<_>`
- //~| expected &-ptr, found enum `std::option::Option`
+ //~| expected reference, found enum `std::option::Option`
}
}
Foo::bar(x); //~ ERROR mismatched types
//~| expected type `&Foo`
//~| found type `Foo`
- //~| expected &-ptr, found struct `Foo`
+ //~| expected &Foo, found struct `Foo`
Foo::bar(&42); //~ ERROR mismatched types
//~| expected type `&Foo`
//~| found type `&{integer}`
y: 3,
};
let ans = s("what"); //~ ERROR mismatched types
- //~^ NOTE expected isize, found &-ptr
+ //~^ NOTE expected isize, found reference
//~| NOTE expected type
//~| NOTE found type
let ans = s();
//~^ ERROR mismatched types
//~| expected type `usize`
//~| found type `&'static str`
- //~| expected usize, found &-ptr
+ //~| expected usize, found reference
//~| ERROR expected `usize` for repeat count, found string literal [E0306]
//~| expected `usize`
let f = [0; -4_isize];