Do not use unsized_fn_params in patterns

This commit is contained in:
Santiago Pastorino 2020-10-20 13:30:47 -03:00
parent 58018d438b
commit ca41681bf0
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
4 changed files with 37 additions and 1 deletions

View File

@ -129,7 +129,9 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
var_ty
);
}
let old_within_fn_param = mem::replace(&mut self.within_fn_param, false);
intravisit::walk_pat(self, p);
self.within_fn_param = old_within_fn_param;
}
// Don't descend into the bodies of nested closures.

View File

@ -0,0 +1,11 @@
#![feature(box_patterns)]
#![feature(unsized_fn_params)]
#[allow(dead_code)]
fn f1(box box _b: Box<Box<[u8]>>) {}
//~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time [E0277]
fn f2((_x, _y): (i32, [i32])) {}
//~^ ERROR: the size for values of type `[i32]` cannot be known at compilation time [E0277]
fn main() {}

View File

@ -0,0 +1,23 @@
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/unsized-local-pat.rs:5:15
|
LL | fn f1(box box _b: Box<Box<[u8]>>) {}
| ^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/unsized-local-pat.rs:8:12
|
LL | fn f2((_x, _y): (i32, [i32])) {}
| ^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[i32]`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -5,7 +5,7 @@
pub fn f0(_f: dyn FnOnce()) {}
pub fn f1(_s: str) {}
pub fn f2((_x, _y): (i32, [i32])) {}
pub fn f2(_x: i32, _y: [i32]) {}
fn main() {
let foo = "foo".to_string().into_boxed_str();