Do not expect blocks to have type str.
This commit is contained in:
parent
083dc5b12d
commit
5d0a68d1d3
@ -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)
|
||||
|
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user