mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Do not use unsized_fn_params in patterns
This commit is contained in:
parent
58018d438b
commit
ca41681bf0
@ -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.
|
||||
|
11
src/test/ui/unsized-locals/unsized-local-pat.rs
Normal file
11
src/test/ui/unsized-locals/unsized-local-pat.rs
Normal 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() {}
|
23
src/test/ui/unsized-locals/unsized-local-pat.stderr
Normal file
23
src/test/ui/unsized-locals/unsized-local-pat.stderr
Normal 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`.
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user