Skip to content

Commit

Permalink
Add unsized_locals to INCOMPLETE_FEATURES list
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Apr 22, 2020
1 parent 4bfd62a commit 5d3b331
Show file tree
Hide file tree
Showing 27 changed files with 143 additions and 63 deletions.
1 change: 1 addition & 0 deletions src/librustc_feature/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,5 @@ pub const INCOMPLETE_FEATURES: &[Symbol] = &[
sym::raw_dylib,
sym::const_trait_impl,
sym::const_trait_bound_opt_out,
sym::unsized_locals,
];
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0161.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
//[zflagsul]compile-flags: -Z borrowck=migrate
//[editionul]edition:2018

#![allow(incomplete_features)]
#![cfg_attr(nll, feature(nll))]
#![cfg_attr(nllul, feature(nll))]
#![cfg_attr(migrateul, feature(unsized_locals))]
#![cfg_attr(zflagsul, feature(unsized_locals))]
#![cfg_attr(nllul, feature(unsized_locals))]
#![cfg_attr(editionul, feature(unsized_locals))]

#![feature(box_syntax)]

fn foo(x: Box<[i32]>) {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/fn/dyn-fn-alignment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-pass

#![allow(incomplete_features)]
#![feature(unsized_locals)]
#![allow(dead_code)]
#[repr(align(256))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize, unsized_locals)]
//~^ WARN the feature `unsized_locals` is incomplete and may cause the compiler to crash

// This tests a few edge-cases around `arbitrary_self_types`. Most specifically,
// it checks that the `ObjectCandidate` you get from method matching can't
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
warning: the feature `unsized_locals` is incomplete and may cause the compiler to crash
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:1:77
|
LL | #![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize, unsized_locals)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:85:24
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:86:24
|
LL | let _seetype: () = z;
| -- ^ expected `()`, found `u32`
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:102:24
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:103:24
|
LL | let _seetype: () = z;
| -- ^ expected `()`, found `u64`
| |
| expected due to this

error[E0034]: multiple applicable items in scope
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:120:15
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:121:15
|
LL | let z = x.foo();
| ^^^ multiple `foo` found
|
note: candidate #1 is defined in an impl of the trait `internal::X` for the type `T`
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:43:9
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:44:9
|
LL | fn foo(self: Smaht<Self, u64>) -> u64 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `T`
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:70:9
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:71:9
|
LL | fn foo(self) {}
| ^^^^^^^^^^^^
note: candidate #3 is defined in the trait `FinalFoo`
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:57:5
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:58:5
|
LL | fn foo(&self) -> u8;
| ^^^^^^^^^^^^^^^^^^^^
Expand All @@ -49,30 +57,30 @@ LL | let z = FinalFoo::foo(x);
| ^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:137:24
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:138:24
|
LL | let _seetype: () = z;
| -- ^ expected `()`, found `u8`
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:155:24
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:156:24
|
LL | let _seetype: () = z;
| -- ^ expected `()`, found `u32`
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:172:24
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:173:24
|
LL | let _seetype: () = z;
| -- ^ expected `()`, found `u32`
| |
| expected due to this

error: aborting due to 6 previous errors
error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0034, E0308.
For more information about an error, try `rustc --explain E0034`.
9 changes: 5 additions & 4 deletions src/test/ui/moves/move-out-of-slice-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(unsized_locals)]
//~^ WARN the feature `unsized_locals` is incomplete and may cause the compiler to crash

struct A;
#[derive(Clone, Copy)]
Expand All @@ -8,27 +9,27 @@ fn main() {
let a: Box<[A]> = Box::new([A]);
match *a {
//~^ ERROR cannot move out of type `[A]`, a non-copy slice
[a @ ..] => {},
[a @ ..] => {}
_ => {}
}
let b: Box<[A]> = Box::new([A, A, A]);
match *b {
//~^ ERROR cannot move out of type `[A]`, a non-copy slice
[_, _, b @ .., _] => {},
[_, _, b @ .., _] => {}
_ => {}
}

// `[C]` isn't `Copy`, even if `C` is.
let c: Box<[C]> = Box::new([C]);
match *c {
//~^ ERROR cannot move out of type `[C]`, a non-copy slice
[c @ ..] => {},
[c @ ..] => {}
_ => {}
}
let d: Box<[C]> = Box::new([C, C, C]);
match *d {
//~^ ERROR cannot move out of type `[C]`, a non-copy slice
[_, _, d @ .., _] => {},
[_, _, d @ .., _] => {}
_ => {}
}
}
26 changes: 17 additions & 9 deletions src/test/ui/moves/move-out-of-slice-2.stderr
Original file line number Diff line number Diff line change
@@ -1,51 +1,59 @@
warning: the feature `unsized_locals` is incomplete and may cause the compiler to crash
--> $DIR/move-out-of-slice-2.rs:1:12
|
LL | #![feature(unsized_locals)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

error[E0508]: cannot move out of type `[A]`, a non-copy slice
--> $DIR/move-out-of-slice-2.rs:9:11
--> $DIR/move-out-of-slice-2.rs:10:11
|
LL | match *a {
| ^^ cannot move out of here
LL |
LL | [a @ ..] => {},
LL | [a @ ..] => {}
| ------
| |
| data moved here
| move occurs because `a` has type `[A]`, which does not implement the `Copy` trait

error[E0508]: cannot move out of type `[A]`, a non-copy slice
--> $DIR/move-out-of-slice-2.rs:15:11
--> $DIR/move-out-of-slice-2.rs:16:11
|
LL | match *b {
| ^^ cannot move out of here
LL |
LL | [_, _, b @ .., _] => {},
LL | [_, _, b @ .., _] => {}
| ------
| |
| data moved here
| move occurs because `b` has type `[A]`, which does not implement the `Copy` trait

error[E0508]: cannot move out of type `[C]`, a non-copy slice
--> $DIR/move-out-of-slice-2.rs:23:11
--> $DIR/move-out-of-slice-2.rs:24:11
|
LL | match *c {
| ^^ cannot move out of here
LL |
LL | [c @ ..] => {},
LL | [c @ ..] => {}
| ------
| |
| data moved here
| move occurs because `c` has type `[C]`, which does not implement the `Copy` trait

error[E0508]: cannot move out of type `[C]`, a non-copy slice
--> $DIR/move-out-of-slice-2.rs:29:11
--> $DIR/move-out-of-slice-2.rs:30:11
|
LL | match *d {
| ^^ cannot move out of here
LL |
LL | [_, _, d @ .., _] => {},
LL | [_, _, d @ .., _] => {}
| ------
| |
| data moved here
| move occurs because `d` has type `[C]`, which does not implement the `Copy` trait

error: aborting due to 4 previous errors
error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0508`.
2 changes: 1 addition & 1 deletion src/test/ui/unsized-locals/autoderef.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-pass

#![allow(incomplete_features)]
#![feature(unsized_locals)]

pub trait Foo {
Expand All @@ -24,7 +25,6 @@ impl Foo for dyn FnMut() -> String {
}
}


fn main() {
let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>);
assert_eq!(&x.foo() as &str, "hello");
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/unsized-locals/borrow-after-move.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(unsized_locals)]
//~^ WARN the feature `unsized_locals` is incomplete and may cause the compiler to crash

pub trait Foo {
fn foo(self) -> String;
Expand Down
20 changes: 14 additions & 6 deletions src/test/ui/unsized-locals/borrow-after-move.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
warning: the feature `unsized_locals` is incomplete and may cause the compiler to crash
--> $DIR/borrow-after-move.rs:1:12
|
LL | #![feature(unsized_locals)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:20:24
--> $DIR/borrow-after-move.rs:21:24
|
LL | let y = *x;
| -- value moved here
Expand All @@ -10,7 +18,7 @@ LL | println!("{}", &x);
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait

error[E0382]: borrow of moved value: `y`
--> $DIR/borrow-after-move.rs:22:24
--> $DIR/borrow-after-move.rs:23:24
|
LL | let y = *x;
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
Expand All @@ -21,7 +29,7 @@ LL | println!("{}", &y);
| ^^ value borrowed here after move

error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:30:24
--> $DIR/borrow-after-move.rs:31:24
|
LL | let y = *x;
| -- value moved here
Expand All @@ -32,7 +40,7 @@ LL | println!("{}", &x);
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait

error[E0382]: borrow of moved value: `y`
--> $DIR/borrow-after-move.rs:32:24
--> $DIR/borrow-after-move.rs:33:24
|
LL | let y = *x;
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
Expand All @@ -43,7 +51,7 @@ LL | println!("{}", &y);
| ^^ value borrowed here after move

error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:39:24
--> $DIR/borrow-after-move.rs:40:24
|
LL | let x = "hello".to_owned().into_boxed_str();
| - move occurs because `x` has type `std::boxed::Box<str>`, which does not implement the `Copy` trait
Expand All @@ -52,6 +60,6 @@ LL | x.foo();
LL | println!("{}", &x);
| ^^ value borrowed here after move

error: aborting due to 5 previous errors
error: aborting due to 5 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-pass

#![allow(incomplete_features)]
#![feature(unsized_locals)]

pub trait Foo {
Expand All @@ -14,7 +15,6 @@ impl Foo for A {
}
}


fn main() {
let x = *(Box::new(A) as Box<dyn Foo>);
assert_eq!(x.foo(), format!("hello"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-pass

#![allow(incomplete_features)]
#![feature(unsized_locals)]

pub trait Foo {
Expand All @@ -12,7 +13,6 @@ struct A;

impl Foo for A {}


fn main() {
let x = *(Box::new(A) as Box<dyn Foo>);
assert_eq!(x.foo(), format!("hello"));
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/unsized-locals/by-value-trait-object-safety.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#![feature(unsized_locals)]
//~^ WARN the feature `unsized_locals` is incomplete and may cause the compiler to crash

pub trait Foo {
fn foo(self) -> String where Self: Sized;
fn foo(self) -> String
where
Self: Sized;
}

struct A;
Expand All @@ -12,7 +15,6 @@ impl Foo for A {
}
}


fn main() {
let x = *(Box::new(A) as Box<dyn Foo>);
x.foo();
Expand Down
16 changes: 12 additions & 4 deletions src/test/ui/unsized-locals/by-value-trait-object-safety.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
warning: the feature `unsized_locals` is incomplete and may cause the compiler to crash
--> $DIR/by-value-trait-object-safety.rs:1:12
|
LL | #![feature(unsized_locals)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

error: the `foo` method cannot be invoked on a trait object
--> $DIR/by-value-trait-object-safety.rs:18:7
--> $DIR/by-value-trait-object-safety.rs:20:7
|
LL | fn foo(self) -> String where Self: Sized;
| ----- this has a `Sized` requirement
LL | Self: Sized;
| ----- this has a `Sized` requirement
...
LL | x.foo();
| ^^^

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

1 change: 1 addition & 0 deletions src/test/ui/unsized-locals/double-move.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(unsized_locals)]
//~^ WARN the feature `unsized_locals` is incomplete and may cause the compiler to crash

pub trait Foo {
fn foo(self) -> String;
Expand Down
Loading

0 comments on commit 5d3b331

Please sign in to comment.