Do not expect blocks to have type str.

This commit is contained in:
Eduard Burtescu 2016-02-14 15:38:48 +02:00
parent 083dc5b12d
commit 5d0a68d1d3
2 changed files with 8 additions and 1 deletions

View File

@ -3828,7 +3828,7 @@ impl<'tcx> Expectation<'tcx> {
/// for examples of where this comes up,.
fn rvalue_hint(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
match tcx.struct_tail(ty).sty {
ty::TySlice(_) | ty::TyTrait(..) => {
ty::TySlice(_) | ty::TyStr | ty::TyTrait(..) => {
ExpectRvalueLikeUnsized(ty)
}
_ => ExpectHasType(ty)

View File

@ -44,6 +44,13 @@ pub fn main() {
let _: &Debug = &if true { false } else { true };
let _: &Debug = &match true { true => 'a', false => 'b' };
let _: &str = &{ String::new() };
let _: &str = &if true { String::from("...") } else { 5.to_string() };
let _: &str = &match true {
true => format!("{}", false),
false => ["x", "y"].join("+")
};
let _: Box<[isize]> = Box::new([1, 2, 3]);
let _: Box<Fn(isize) -> _> = Box::new(|x| (x as u8));