File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
compiler/rustc_hir_analysis/src/hir_ty_lowering
tests/ui/impl-trait/in-bindings Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -2495,6 +2495,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24952495 ty:: List :: empty ( ) ,
24962496 PredicateFilter :: All ,
24972497 ) ;
2498+ self . add_sizedness_bounds (
2499+ & mut bounds,
2500+ self_ty,
2501+ hir_bounds,
2502+ None ,
2503+ None ,
2504+ hir_ty. span ,
2505+ ) ;
24982506 self . register_trait_ascription_bounds ( bounds, hir_ty. hir_id , hir_ty. span ) ;
24992507 self_ty
25002508 }
Original file line number Diff line number Diff line change 1+ #![ feature( impl_trait_in_bindings) ]
2+
3+ trait Trait { }
4+ impl < T : ?Sized > Trait for T { }
5+
6+ fn doesnt_work ( ) {
7+ let x: & impl Trait = "hi" ;
8+ //~^ ERROR the size for values of type `str` cannot be known at compilation time
9+ }
10+
11+ fn works ( ) {
12+ let x: & ( impl Trait + ?Sized ) = "hi" ;
13+ // No implicit sized.
14+
15+ let x: & impl Trait = & ( ) ;
16+ // Is actually sized.
17+ }
18+
19+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0277]: the size for values of type `str` cannot be known at compilation time
2+ --> $DIR/implicit-sized.rs:7:13
3+ |
4+ LL | let x: &impl Trait = "hi";
5+ | ^^^^^^^^^^ doesn't have a size known at compile-time
6+ |
7+ = help: the trait `Sized` is not implemented for `str`
8+
9+ error: aborting due to 1 previous error
10+
11+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments