/// 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)
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));