Remove uses of box_syntax in rustc and tools

This commit is contained in:
clubby789 2023-02-27 13:07:44 +00:00
parent 24c0b81c1f
commit dd7df04e16
80 changed files with 862 additions and 955 deletions

View File

@ -1,4 +1,4 @@
#![feature(start, core_intrinsics, alloc_error_handler, box_syntax)]
#![feature(start, core_intrinsics, alloc_error_handler)]
#![no_std]
extern crate alloc;
@ -29,7 +29,7 @@ fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
let world: Box<&str> = box "Hello World!\0";
let world: Box<&str> = Box::new("Hello World!\0");
unsafe {
puts(*world as *const str as *const u8);
}

View File

@ -1,4 +1,4 @@
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, box_syntax)]
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local)]
#![no_core]
#![allow(dead_code, non_camel_case_types)]
@ -178,7 +178,7 @@ fn main() {
let ptr: *const i8 = hello as *const [u8] as *const i8;
puts(ptr);
let world: Box<&str> = box "World!\0";
let world: Box<&str> = Box::new("World!\0");
puts(*world as *const str as *const i8);
world as Box<dyn SomeTrait>;
@ -238,10 +238,10 @@ fn main() {
}
}
let _ = box NoisyDrop {
let _ = Box::new(NoisyDrop {
text: "Boxed outer got dropped!\0",
inner: NoisyDropInner,
} as Box<dyn SomeTrait>;
}) as Box<dyn SomeTrait>;
const FUNC_REF: Option<fn()> = Some(main);
match FUNC_REF {

View File

@ -1,4 +1,4 @@
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler, lang_items)]
#![feature(start, core_intrinsics, alloc_error_handler, lang_items)]
#![no_std]
extern crate alloc;
@ -38,7 +38,7 @@ unsafe extern "C" fn _Unwind_Resume() {
#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
let world: Box<&str> = box "Hello World!\0";
let world: Box<&str> = Box::new("Hello World!\0");
unsafe {
puts(*world as *const str as *const u8);
}

View File

@ -1,7 +1,7 @@
// Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs
#![feature(
no_core, unboxed_closures, start, lang_items, box_syntax, never_type, linkage,
no_core, unboxed_closures, start, lang_items, never_type, linkage,
extern_types, thread_local
)]
#![no_core]
@ -163,7 +163,7 @@ fn main() {
let ptr: *const u8 = hello as *const [u8] as *const u8;
puts(ptr);
let world: Box<&str> = box "World!\0";
let world: Box<&str> = Box::new("World!\0");
puts(*world as *const str as *const u8);
world as Box<dyn SomeTrait>;
@ -223,10 +223,10 @@ fn main() {
}
}
let _ = box NoisyDrop {
let _ = Box::new(NoisyDrop {
text: "Boxed outer got dropped!\0",
inner: NoisyDropInner,
} as Box<dyn SomeTrait>;
}) as Box<dyn SomeTrait>;
const FUNC_REF: Option<fn()> = Some(main);
#[allow(unreachable_code)]

View File

@ -1,4 +1,4 @@
#![feature(start, box_syntax, core_intrinsics, lang_items)]
#![feature(start, core_intrinsics, lang_items)]
#![no_std]
#[link(name = "c")]

View File

@ -5,7 +5,5 @@ the heap at runtime, and therefore cannot be done at compile time.
Erroneous code example:
```compile_fail,E0010
#![feature(box_syntax)]
const CON : Box<i32> = box 0;
const CON : Vec<i32> = vec![1, 2, 3];
```

View File

@ -1367,8 +1367,8 @@ impl<'a> State<'a> {
self.ann.pre(self, AnnNode::Expr(expr));
match expr.kind {
hir::ExprKind::Box(expr) => {
self.word_space("box");
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
self.word_space("Box::new");
self.print_call_post(std::slice::from_ref(expr));
}
hir::ExprKind::Array(exprs) => {
self.print_expr_vec(exprs);

View File

@ -1371,7 +1371,6 @@ declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]);
impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
match e.kind {
hir::ExprKind::Box(_) => {}
hir::ExprKind::Call(path_expr, [_])
if let hir::ExprKind::Path(qpath) = &path_expr.kind
&& let Some(did) = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id()

View File

@ -158,10 +158,12 @@ impl EnumSizeOpt {
tmp_ty,
),
};
let rval = Rvalue::Use(Operand::Constant(box (constant_vals)));
let rval = Rvalue::Use(Operand::Constant(Box::new(constant_vals)));
let const_assign =
Statement { source_info, kind: StatementKind::Assign(box (place, rval)) };
let const_assign = Statement {
source_info,
kind: StatementKind::Assign(Box::new((place, rval))),
};
let discr_place = Place::from(
local_decls
@ -170,7 +172,10 @@ impl EnumSizeOpt {
let store_discr = Statement {
source_info,
kind: StatementKind::Assign(box (discr_place, Rvalue::Discriminant(*rhs))),
kind: StatementKind::Assign(Box::new((
discr_place,
Rvalue::Discriminant(*rhs),
))),
};
let discr_cast_place =
@ -178,14 +183,14 @@ impl EnumSizeOpt {
let cast_discr = Statement {
source_info,
kind: StatementKind::Assign(box (
kind: StatementKind::Assign(Box::new((
discr_cast_place,
Rvalue::Cast(
CastKind::IntToInt,
Operand::Copy(discr_place),
tcx.types.usize,
),
)),
))),
};
let size_place =
@ -193,14 +198,14 @@ impl EnumSizeOpt {
let store_size = Statement {
source_info,
kind: StatementKind::Assign(box (
kind: StatementKind::Assign(Box::new((
size_place,
Rvalue::Use(Operand::Copy(Place {
local: size_array_local,
projection: tcx
.mk_place_elems(&[PlaceElem::Index(discr_cast_place.local)]),
})),
)),
))),
};
let dst =
@ -208,10 +213,10 @@ impl EnumSizeOpt {
let dst_ptr = Statement {
source_info,
kind: StatementKind::Assign(box (
kind: StatementKind::Assign(Box::new((
dst,
Rvalue::AddressOf(Mutability::Mut, *lhs),
)),
))),
};
let dst_cast_ty = tcx.mk_mut_ptr(tcx.types.u8);
@ -220,10 +225,10 @@ impl EnumSizeOpt {
let dst_cast = Statement {
source_info,
kind: StatementKind::Assign(box (
kind: StatementKind::Assign(Box::new((
dst_cast_place,
Rvalue::Cast(CastKind::PtrToPtr, Operand::Copy(dst), dst_cast_ty),
)),
))),
};
let src =
@ -231,10 +236,10 @@ impl EnumSizeOpt {
let src_ptr = Statement {
source_info,
kind: StatementKind::Assign(box (
kind: StatementKind::Assign(Box::new((
src,
Rvalue::AddressOf(Mutability::Not, *rhs),
)),
))),
};
let src_cast_ty = tcx.mk_imm_ptr(tcx.types.u8);
@ -243,24 +248,24 @@ impl EnumSizeOpt {
let src_cast = Statement {
source_info,
kind: StatementKind::Assign(box (
kind: StatementKind::Assign(Box::new((
src_cast_place,
Rvalue::Cast(CastKind::PtrToPtr, Operand::Copy(src), src_cast_ty),
)),
))),
};
let deinit_old =
Statement { source_info, kind: StatementKind::Deinit(box dst) };
Statement { source_info, kind: StatementKind::Deinit(Box::new(dst)) };
let copy_bytes = Statement {
source_info,
kind: StatementKind::Intrinsic(
box NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
kind: StatementKind::Intrinsic(Box::new(
NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
src: Operand::Copy(src_cast_place),
dst: Operand::Copy(dst_cast_place),
count: Operand::Copy(size_place),
}),
),
)),
};
let store_dead = Statement {

View File

@ -1,7 +1,6 @@
#![allow(rustc::potential_query_instability)]
#![feature(box_patterns)]
#![feature(drain_filter)]
#![feature(box_syntax)]
#![feature(let_chains)]
#![feature(map_try_insert)]
#![feature(min_specialization)]

View File

@ -5,16 +5,31 @@ each one organized by a "feature flag." That is, when using an unstable
feature of Rust, you must use a flag, like this:
```rust
#![feature(box_syntax)]
#![feature(generators, generator_trait)]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;
fn main() {
let five = box 5;
let mut generator = || {
yield 1;
return "foo"
};
match Pin::new(&mut generator).resume(()) {
GeneratorState::Yielded(1) => {}
_ => panic!("unexpected value from resume"),
}
match Pin::new(&mut generator).resume(()) {
GeneratorState::Complete("foo") => {}
_ => panic!("unexpected value from resume"),
}
}
```
The `box_syntax` feature [has a chapter][box] describing how to use it.
The `generators` feature [has a chapter][generators] describing how to use it.
[box]: language-features/box-syntax.md
[generators]: language-features/generators.md
Because this documentation relates to unstable features, we make no guarantees
that what is contained here is accurate or up to date. It's developed on a

View File

@ -1,4 +1,3 @@
#![feature(box_syntax)]
#![feature(lint_reasons)]
#![allow(
clippy::borrowed_box,
@ -34,7 +33,7 @@ fn ok_box_trait(boxed_trait: &Box<dyn Z>) {
}
fn warn_call() {
let x = box A;
let x = Box::new(A);
x.foo();
}
@ -43,41 +42,41 @@ fn warn_arg(x: Box<A>) {
}
fn nowarn_closure_arg() {
let x = Some(box A);
let x = Some(Box::new(A));
x.map_or((), |x| take_ref(&x));
}
fn warn_rename_call() {
let x = box A;
let x = Box::new(A);
let y = x;
y.foo(); // via autoderef
}
fn warn_notuse() {
let bz = box A;
let bz = Box::new(A);
}
fn warn_pass() {
let bz = box A;
let bz = Box::new(A);
take_ref(&bz); // via deref coercion
}
fn nowarn_return() -> Box<A> {
box A // moved out, "escapes"
Box::new(A) // moved out, "escapes"
}
fn nowarn_move() {
let bx = box A;
let bx = Box::new(A);
drop(bx) // moved in, "escapes"
}
fn nowarn_call() {
let bx = box A;
let bx = Box::new(A);
bx.clone(); // method only available to Box, not via autoderef
}
fn nowarn_pass() {
let bx = box A;
let bx = Box::new(A);
take_box(&bx); // fn needs &Box
}
@ -86,30 +85,20 @@ fn take_ref(x: &A) {}
fn nowarn_ref_take() {
// false positive, should actually warn
let x = box A;
let x = Box::new(A);
let y = &x;
take_box(y);
}
fn nowarn_match() {
let x = box A; // moved into a match
let x = Box::new(A); // moved into a match
match x {
y => drop(y),
}
}
fn warn_match() {
let x = box A;
match &x {
// not moved
y => (),
}
}
fn nowarn_large_array() {
// should not warn, is large array
// and should not be on stack
let x = box [1; 10000];
let x = Box::new(A);
match &x {
// not moved
y => (),

View File

@ -1,5 +1,5 @@
error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:41:13
--> $DIR/boxed_local.rs:40:13
|
LL | fn warn_arg(x: Box<A>) {
| ^
@ -7,19 +7,19 @@ LL | fn warn_arg(x: Box<A>) {
= note: `-D clippy::boxed-local` implied by `-D warnings`
error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:132:12
--> $DIR/boxed_local.rs:121:12
|
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^
error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:196:44
--> $DIR/boxed_local.rs:185:44
|
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
| ^
error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:203:16
--> $DIR/boxed_local.rs:192:16
|
LL | fn foo(x: Box<u32>) {}
| ^

View File

@ -1,4 +1,4 @@
#![feature(box_syntax, fn_traits, unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
#![warn(clippy::no_effect_underscore_binding)]
#![allow(dead_code, path_statements)]
#![allow(clippy::deref_addrof, clippy::redundant_field_names, clippy::uninlined_format_args)]
@ -102,7 +102,6 @@ fn main() {
*&42;
&6;
(5, 6, 7);
box 42;
..;
5..;
..5;

View File

@ -81,83 +81,77 @@ LL | (5, 6, 7);
error: statement with no effect
--> $DIR/no_effect.rs:105:5
|
LL | box 42;
| ^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:106:5
|
LL | ..;
| ^^^
error: statement with no effect
--> $DIR/no_effect.rs:107:5
--> $DIR/no_effect.rs:106:5
|
LL | 5..;
| ^^^^
error: statement with no effect
--> $DIR/no_effect.rs:108:5
--> $DIR/no_effect.rs:107:5
|
LL | ..5;
| ^^^^
error: statement with no effect
--> $DIR/no_effect.rs:109:5
--> $DIR/no_effect.rs:108:5
|
LL | 5..6;
| ^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:110:5
--> $DIR/no_effect.rs:109:5
|
LL | 5..=6;
| ^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:111:5
--> $DIR/no_effect.rs:110:5
|
LL | [42, 55];
| ^^^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:112:5
--> $DIR/no_effect.rs:111:5
|
LL | [42, 55][1];
| ^^^^^^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:113:5
--> $DIR/no_effect.rs:112:5
|
LL | (42, 55).1;
| ^^^^^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:114:5
--> $DIR/no_effect.rs:113:5
|
LL | [42; 55];
| ^^^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:115:5
--> $DIR/no_effect.rs:114:5
|
LL | [42; 55][13];
| ^^^^^^^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:117:5
--> $DIR/no_effect.rs:116:5
|
LL | || x += 5;
| ^^^^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:119:5
--> $DIR/no_effect.rs:118:5
|
LL | FooString { s: s };
| ^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:120:5
--> $DIR/no_effect.rs:119:5
|
LL | let _unused = 1;
| ^^^^^^^^^^^^^^^^
@ -165,22 +159,22 @@ LL | let _unused = 1;
= note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings`
error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:121:5
--> $DIR/no_effect.rs:120:5
|
LL | let _penguin = || println!("Some helpful closure");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:122:5
--> $DIR/no_effect.rs:121:5
|
LL | let _duck = Struct { field: 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:123:5
--> $DIR/no_effect.rs:122:5
|
LL | let _cat = [2, 4, 6, 8][2];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 30 previous errors
error: aborting due to 29 previous errors

View File

@ -1,6 +1,5 @@
// run-rustfix
#![feature(box_syntax)]
#![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)]
#![warn(clippy::unnecessary_operation)]
@ -59,7 +58,6 @@ fn main() {
5;6;get_number();
get_number();
get_number();
get_number();
5;get_number();
42;get_number();
assert!([42, 55].len() > get_usize());

View File

@ -1,6 +1,5 @@
// run-rustfix
#![feature(box_syntax)]
#![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)]
#![warn(clippy::unnecessary_operation)]
@ -57,7 +56,6 @@ fn main() {
*&get_number();
&get_number();
(5, 6, get_number());
box get_number();
get_number()..;
..get_number();
5..get_number();

View File

@ -1,5 +1,5 @@
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:51:5
--> $DIR/unnecessary_operation.rs:50:5
|
LL | Tuple(get_number());
| ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
@ -7,109 +7,103 @@ LL | Tuple(get_number());
= note: `-D clippy::unnecessary-operation` implied by `-D warnings`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:52:5
--> $DIR/unnecessary_operation.rs:51:5
|
LL | Struct { field: get_number() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:53:5
--> $DIR/unnecessary_operation.rs:52:5
|
LL | Struct { ..get_struct() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:54:5
--> $DIR/unnecessary_operation.rs:53:5
|
LL | Enum::Tuple(get_number());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:55:5
--> $DIR/unnecessary_operation.rs:54:5
|
LL | Enum::Struct { field: get_number() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:56:5
--> $DIR/unnecessary_operation.rs:55:5
|
LL | 5 + get_number();
| ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:57:5
--> $DIR/unnecessary_operation.rs:56:5
|
LL | *&get_number();
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:58:5
--> $DIR/unnecessary_operation.rs:57:5
|
LL | &get_number();
| ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:59:5
--> $DIR/unnecessary_operation.rs:58:5
|
LL | (5, 6, get_number());
| ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:60:5
|
LL | box get_number();
| ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:61:5
--> $DIR/unnecessary_operation.rs:59:5
|
LL | get_number()..;
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:62:5
--> $DIR/unnecessary_operation.rs:60:5
|
LL | ..get_number();
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:63:5
--> $DIR/unnecessary_operation.rs:61:5
|
LL | 5..get_number();
| ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:64:5
--> $DIR/unnecessary_operation.rs:62:5
|
LL | [42, get_number()];
| ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:65:5
--> $DIR/unnecessary_operation.rs:63:5
|
LL | [42, 55][get_usize()];
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:66:5
--> $DIR/unnecessary_operation.rs:64:5
|
LL | (42, get_number()).1;
| ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:67:5
--> $DIR/unnecessary_operation.rs:65:5
|
LL | [get_number(); 55];
| ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:68:5
--> $DIR/unnecessary_operation.rs:66:5
|
LL | [42; 55][get_usize()];
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:69:5
--> $DIR/unnecessary_operation.rs:67:5
|
LL | / {
LL | | get_number()
@ -117,12 +111,12 @@ LL | | };
| |______^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:72:5
--> $DIR/unnecessary_operation.rs:70:5
|
LL | / FooString {
LL | | s: String::from("blah"),
LL | | };
| |______^ help: statement can be reduced to: `String::from("blah");`
error: aborting due to 20 previous errors
error: aborting due to 19 previous errors

View File

@ -1,10 +1,8 @@
// Validation makes this fail in the wrong place
//@compile-flags: -Zmiri-disable-validation
#![feature(box_syntax)]
fn main() {
let x = box 42;
let x = Box::new(42);
unsafe {
let f = std::mem::transmute::<Box<i32>, fn()>(x);
f() //~ ERROR: function pointer but it does not point to a function

View File

@ -1,7 +1,5 @@
#![feature(box_syntax)]
fn main() {
// With the nested Vec, this is calling Offset(Unique::empty(), 0) on drop.
let args: Vec<Vec<i32>> = Vec::new();
let _val = box args;
let _val = Box::new(args);
}

View File

@ -1,5 +1,3 @@
#![feature(box_syntax)]
struct Fat<T: ?Sized> {
f1: isize,
f2: &'static str,
@ -109,7 +107,7 @@ pub fn main() {
assert_eq!((*f2)[1], 2);
// Nested Box.
let f1: Box<Fat<[isize; 3]>> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
let f1: Box<Fat<[isize; 3]>> = Box::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
foo(&*f1);
let f2: Box<Fat<[isize]>> = f1;
foo(&*f2);
@ -117,6 +115,6 @@ pub fn main() {
let f3: Box<Fat<[isize]>> =
Box::<Fat<[_; 3]>>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
foo(&*f3);
let f4: Box<Fat<[isize]>> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
let f4: Box<Fat<[isize]>> = Box::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
foo(&*f4);
}

View File

@ -1,13 +1,7 @@
#![feature(box_syntax)]
fn make_box() -> Box<(i16, i16)> {
Box::new((1, 2))
}
fn make_box_syntax() -> Box<(i16, i16)> {
box (1, 2)
}
fn allocate_reallocate() {
let mut s = String::new();
@ -29,6 +23,5 @@ fn allocate_reallocate() {
fn main() {
assert_eq!(*make_box(), (1, 2));
assert_eq!(*make_box_syntax(), (1, 2));
allocate_reallocate();
}

View File

@ -1,5 +1,3 @@
#![feature(box_syntax)]
trait T {
fn print(&self);
}
@ -25,7 +23,7 @@ fn print_s(s: &S) {
}
pub fn main() {
let s: Box<S> = box S { s: 5 };
let s: Box<S> = Box::new(S { s: 5 });
print_s(&*s);
let t: Box<dyn T> = s as Box<dyn T>;
print_t(&*t);

View File

@ -1,11 +1,9 @@
#![feature(box_syntax)]
fn test(foo: Box<Vec<isize>>) {
assert_eq!((*foo)[0], 10);
}
pub fn main() {
let x = box vec![10];
let x = Box::new(vec![10]);
// Test forgetting a local by move-in
test(x);
}

View File

@ -1,7 +1,5 @@
#![feature(box_syntax)]
pub fn main() {
let x = box 10;
let x = Box::new(10);
let y = x;
assert_eq!(*y, 10);
}

View File

@ -1,15 +1,13 @@
#![feature(box_syntax)]
use std::sync::mpsc::channel;
pub fn main() {
let (tx, rx) = channel::<Box<_>>();
tx.send(box 100).unwrap();
tx.send(Box::new(100)).unwrap();
let v = rx.recv().unwrap();
assert_eq!(v, box 100);
assert_eq!(v, Box::new(100));
tx.send(box 101).unwrap();
tx.send(box 102).unwrap();
assert_eq!(rx.recv().unwrap(), box 101);
assert_eq!(rx.recv().unwrap(), box 102);
tx.send(Box::new(101)).unwrap();
tx.send(Box::new(102)).unwrap();
assert_eq!(rx.recv().unwrap(), Box::new(101));
assert_eq!(rx.recv().unwrap(), Box::new(102));
}

View File

@ -12,8 +12,6 @@
// doing region-folding, when really all clients of the region-folding
// case only want to see *free* lifetime variables, not bound ones.
#![feature(box_syntax)]
pub fn main() {
fn explicit() {
fn test<F>(_x: Option<Box<F>>)
@ -21,7 +19,7 @@ pub fn main() {
F: FnMut(Box<dyn for<'a> FnMut(&'a isize)>),
{
}
test(Some(box |_f: Box<dyn for<'a> FnMut(&'a isize)>| {}));
test(Some(Box::new(|_f: Box<dyn for<'a> FnMut(&'a isize)>| {})));
}
// The code below is shorthand for the code above (and more likely
@ -32,7 +30,7 @@ pub fn main() {
F: FnMut(Box<dyn FnMut(&isize)>),
{
}
test(Some(box |_f: Box<dyn FnMut(&isize)>| {}));
test(Some(Box::new(|_f: Box<dyn FnMut(&isize)>| {})));
}
explicit();

View File

@ -857,9 +857,9 @@ mod lint {
#[test]
fn lint_feature() {
check_edit(
"box_syntax",
"box_patterns",
r#"#[feature(box_$0)] struct Test;"#,
r#"#[feature(box_syntax)] struct Test;"#,
r#"#[feature(box_patterns)] struct Test;"#,
)
}

View File

@ -3,7 +3,6 @@
// Test expressions
fn foo() -> bool {
let boxed: Box<i32> = box 5;
let referenced = &5 ;
let very_long_variable_name = ( a + first + simple + test );
@ -132,12 +131,6 @@ fn qux() {
}
}
fn issue227() {
{
let handler = box DocumentProgressHandler::new(addr, DocumentProgressTask::DOMContentLoaded);
}
}
fn issue184(source: &str) {
for c in source.chars() {
if index < 'a' {
@ -413,10 +406,6 @@ fn issue2704() {
.concat(&requires1)
.concat(&requires2)
.distinct_total());
let requires = requires.set(box requires0
.concat(&requires1)
.concat(&requires2)
.distinct_total());
let requires = requires.set(requires0
.concat(&requires1)
.concat(&requires2)

View File

@ -108,12 +108,6 @@ fn main() {
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
));
// Box
foo(box Bar {
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
});
// Unary
foo(!bar(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,

View File

@ -96,12 +96,6 @@ fn main() {
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
));
// Box
foo(box Bar {
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
});
// Unary
foo(!bar(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,

View File

@ -3,7 +3,6 @@
// Test expressions
fn foo() -> bool {
let boxed: Box<i32> = box 5;
let referenced = &5;
let very_long_variable_name = (a + first + simple + test);
@ -179,13 +178,6 @@ fn qux() {
}
}
fn issue227() {
{
let handler =
box DocumentProgressHandler::new(addr, DocumentProgressTask::DOMContentLoaded);
}
}
fn issue184(source: &str) {
for c in source.chars() {
if index < 'a' {
@ -454,12 +446,6 @@ fn issue2704() {
.concat(&requires2)
.distinct_total(),
);
let requires = requires.set(
box requires0
.concat(&requires1)
.concat(&requires2)
.distinct_total(),
);
let requires = requires.set(
requires0
.concat(&requires1)

View File

@ -3,12 +3,12 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/box_expr.rs:+0:11: +0:11
let _1: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+1:9: +1:10
let mut _2: usize; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25
let mut _3: usize; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25
let mut _4: *mut u8; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25
let mut _5: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25
let _6: (); // in scope 0 at $DIR/box_expr.rs:+2:5: +2:12
let mut _7: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+2:10: +2:11
let mut _2: usize; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23
let mut _3: usize; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23
let mut _4: *mut u8; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23
let mut _5: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23
let _6: (); // in scope 0 at $DIR/box_expr.rs:+3:5: +3:12
let mut _7: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+3:10: +3:11
scope 1 {
debug x => _1; // in scope 1 at $DIR/box_expr.rs:+1:9: +1:10
}
@ -17,64 +17,64 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/box_expr.rs:+1:9: +1:10
_2 = SizeOf(S); // scope 2 at $DIR/box_expr.rs:+1:13: +1:25
_3 = AlignOf(S); // scope 2 at $DIR/box_expr.rs:+1:13: +1:25
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/box_expr.rs:+1:13: +1:25
_2 = SizeOf(S); // scope 2 at $DIR/box_expr.rs:+2:5: +2:23
_3 = AlignOf(S); // scope 2 at $DIR/box_expr.rs:+2:5: +2:23
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/box_expr.rs:+2:5: +2:23
// mir::Constant
// + span: $DIR/box_expr.rs:7:13: 7:25
// + span: $DIR/box_expr.rs:8:5: 8:23
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_5); // scope 0 at $DIR/box_expr.rs:+1:13: +1:25
_5 = ShallowInitBox(move _4, S); // scope 0 at $DIR/box_expr.rs:+1:13: +1:25
(*_5) = S::new() -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/box_expr.rs:+1:17: +1:25
StorageLive(_5); // scope 0 at $DIR/box_expr.rs:+2:5: +2:23
_5 = ShallowInitBox(move _4, S); // scope 0 at $DIR/box_expr.rs:+2:5: +2:23
(*_5) = S::new() -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/box_expr.rs:+2:14: +2:22
// mir::Constant
// + span: $DIR/box_expr.rs:7:17: 7:23
// + span: $DIR/box_expr.rs:8:14: 8:20
// + literal: Const { ty: fn() -> S {S::new}, val: Value(<ZST>) }
}
bb2: {
_1 = move _5; // scope 0 at $DIR/box_expr.rs:+1:13: +1:25
drop(_5) -> bb3; // scope 0 at $DIR/box_expr.rs:+1:24: +1:25
_1 = move _5; // scope 0 at $DIR/box_expr.rs:+2:5: +2:23
drop(_5) -> bb3; // scope 0 at $DIR/box_expr.rs:+2:22: +2:23
}
bb3: {
StorageDead(_5); // scope 0 at $DIR/box_expr.rs:+1:24: +1:25
StorageLive(_6); // scope 1 at $DIR/box_expr.rs:+2:5: +2:12
StorageLive(_7); // scope 1 at $DIR/box_expr.rs:+2:10: +2:11
_7 = move _1; // scope 1 at $DIR/box_expr.rs:+2:10: +2:11
_6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; // scope 1 at $DIR/box_expr.rs:+2:5: +2:12
StorageDead(_5); // scope 0 at $DIR/box_expr.rs:+2:22: +2:23
StorageLive(_6); // scope 1 at $DIR/box_expr.rs:+3:5: +3:12
StorageLive(_7); // scope 1 at $DIR/box_expr.rs:+3:10: +3:11
_7 = move _1; // scope 1 at $DIR/box_expr.rs:+3:10: +3:11
_6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; // scope 1 at $DIR/box_expr.rs:+3:5: +3:12
// mir::Constant
// + span: $DIR/box_expr.rs:8:5: 8:9
// + span: $DIR/box_expr.rs:9:5: 9:9
// + literal: Const { ty: fn(Box<S>) {std::mem::drop::<Box<S>>}, val: Value(<ZST>) }
}
bb4: {
StorageDead(_7); // scope 1 at $DIR/box_expr.rs:+2:11: +2:12
StorageDead(_6); // scope 1 at $DIR/box_expr.rs:+2:12: +2:13
_0 = const (); // scope 0 at $DIR/box_expr.rs:+0:11: +3:2
drop(_1) -> bb5; // scope 0 at $DIR/box_expr.rs:+3:1: +3:2
StorageDead(_7); // scope 1 at $DIR/box_expr.rs:+3:11: +3:12
StorageDead(_6); // scope 1 at $DIR/box_expr.rs:+3:12: +3:13
_0 = const (); // scope 0 at $DIR/box_expr.rs:+0:11: +4:2
drop(_1) -> bb5; // scope 0 at $DIR/box_expr.rs:+4:1: +4:2
}
bb5: {
StorageDead(_1); // scope 0 at $DIR/box_expr.rs:+3:1: +3:2
return; // scope 0 at $DIR/box_expr.rs:+3:2: +3:2
StorageDead(_1); // scope 0 at $DIR/box_expr.rs:+4:1: +4:2
return; // scope 0 at $DIR/box_expr.rs:+4:2: +4:2
}
bb6 (cleanup): {
drop(_7) -> bb7; // scope 1 at $DIR/box_expr.rs:+2:11: +2:12
drop(_7) -> bb7; // scope 1 at $DIR/box_expr.rs:+3:11: +3:12
}
bb7 (cleanup): {
drop(_1) -> bb9; // scope 0 at $DIR/box_expr.rs:+3:1: +3:2
drop(_1) -> bb9; // scope 0 at $DIR/box_expr.rs:+4:1: +4:2
}
bb8 (cleanup): {
drop(_5) -> bb9; // scope 0 at $DIR/box_expr.rs:+1:24: +1:25
drop(_5) -> bb9; // scope 0 at $DIR/box_expr.rs:+2:22: +2:23
}
bb9 (cleanup): {
resume; // scope 0 at $DIR/box_expr.rs:+0:1: +3:2
resume; // scope 0 at $DIR/box_expr.rs:+0:1: +4:2
}
}

View File

@ -1,17 +1,20 @@
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(box_syntax)]
#![feature(rustc_attrs, stmt_expr_attributes)]
// EMIT_MIR box_expr.main.ElaborateDrops.before.mir
fn main() {
let x = box S::new();
let x = #[rustc_box]
Box::new(S::new());
drop(x);
}
struct S;
impl S {
fn new() -> Self { S }
fn new() -> Self {
S
}
}
impl Drop for S {

View File

@ -3,21 +3,21 @@
fn move_out_by_subslice() -> () {
let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +0:27
let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
scope 1 {
debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
let _12: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
let _12: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+7:10: +7:12
scope 4 {
debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+7:10: +7:12
}
}
scope 2 {
@ -27,86 +27,86 @@ fn move_out_by_subslice() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
// mir::Constant
// + span: $DIR/uniform_array_move_out.rs:11:14: 11:19
// + span: $DIR/uniform_array_move_out.rs:18:9: 18:20
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
(*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
_2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
(*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+3:18: +3:19
_2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20
}
bb2: {
StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20
StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
// mir::Constant
// + span: $DIR/uniform_array_move_out.rs:11:21: 11:26
// + span: $DIR/uniform_array_move_out.rs:20:9: 20:20
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb3: {
StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
(*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
_7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
(*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+5:18: +5:19
_7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20
}
bb4: {
StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
_1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27
drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20
_1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +6:6
drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb5: {
StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb6: {
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+2:21: +2:22
StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
_12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2
drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+7:21: +7:22
StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+7:10: +7:12
_12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+7:10: +7:12
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +8:2
drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
}
bb7: {
StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
}
bb8: {
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
return; // scope 0 at $DIR/uniform_array_move_out.rs:+8:2: +8:2
}
bb9 (cleanup): {
drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
}
bb10 (cleanup): {
drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb11 (cleanup): {
drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb12 (cleanup): {
resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2
resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +8:2
}
}

View File

@ -3,21 +3,21 @@
fn move_out_from_end() -> () {
let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +0:24
let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
scope 1 {
debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
let _12: std::boxed::Box<i32>; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
let _12: std::boxed::Box<i32>; // in scope 1 at $DIR/uniform_array_move_out.rs:+7:14: +7:16
scope 4 {
debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+7:14: +7:16
}
}
scope 2 {
@ -27,86 +27,86 @@ fn move_out_from_end() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
// mir::Constant
// + span: $DIR/uniform_array_move_out.rs:5:14: 5:19
// + span: $DIR/uniform_array_move_out.rs:7:9: 7:20
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
_6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
(*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
_2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
_6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
(*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+3:18: +3:19
_2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20
drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20
}
bb2: {
StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20
StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
// mir::Constant
// + span: $DIR/uniform_array_move_out.rs:5:21: 5:26
// + span: $DIR/uniform_array_move_out.rs:9:9: 9:20
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb3: {
StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
_11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
(*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
_7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
_11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
(*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+5:18: +5:19
_7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20
}
bb4: {
StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
_1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27
drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20
_1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +6:6
drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb5: {
StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb6: {
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+2:20: +2:21
StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
_12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2
drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+7:20: +7:21
StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+7:14: +7:16
_12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+7:14: +7:16
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +8:2
drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
}
bb7: {
StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
}
bb8: {
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
return; // scope 0 at $DIR/uniform_array_move_out.rs:+8:2: +8:2
}
bb9 (cleanup): {
drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
}
bb10 (cleanup): {
drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb11 (cleanup): {
drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
}
bb12 (cleanup): {
resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2
resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +8:2
}
}

View File

@ -1,14 +1,24 @@
#![feature(box_syntax)]
#![feature(stmt_expr_attributes, rustc_attrs)]
// EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir
fn move_out_from_end() {
let a = [box 1, box 2];
let a = [
#[rustc_box]
Box::new(1),
#[rustc_box]
Box::new(2),
];
let [.., _y] = a;
}
// EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir
fn move_out_by_subslice() {
let a = [box 1, box 2];
let a = [
#[rustc_box]
Box::new(1),
#[rustc_box]
Box::new(2),
];
let [_y @ ..] = a;
}

View File

@ -4,14 +4,14 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/boxes.rs:+1:9: +1:10
let mut _2: i32; // in scope 0 at $DIR/boxes.rs:+1:13: +1:22
let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _4: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _5: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _6: *mut u8; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _8: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22
let mut _2: i32; // in scope 0 at $DIR/boxes.rs:+1:13: +2:18
let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
let mut _4: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
let mut _5: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
let mut _6: *mut u8; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
let mut _8: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
scope 1 {
debug x => _1; // in scope 1 at $DIR/boxes.rs:+1:9: +1:10
}
@ -20,41 +20,41 @@
bb0: {
StorageLive(_1); // scope 0 at $DIR/boxes.rs:+1:9: +1:10
StorageLive(_2); // scope 0 at $DIR/boxes.rs:+1:13: +1:22
StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +1:22
- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22
- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22
+ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
+ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
_6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
StorageLive(_2); // scope 0 at $DIR/boxes.rs:+1:13: +2:18
StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +2:18
- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18
- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18
+ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +2:18
+ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +2:18
_6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +2:18
// mir::Constant
// + span: $DIR/boxes.rs:13:14: 13:22
// + span: $DIR/boxes.rs:13:14: 14:18
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_7); // scope 0 at $DIR/boxes.rs:+1:14: +1:22
_7 = ShallowInitBox(move _6, i32); // scope 0 at $DIR/boxes.rs:+1:14: +1:22
_8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:19: +1:21
(*_8) = const 42_i32; // scope 0 at $DIR/boxes.rs:+1:19: +1:21
_3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +1:22
StorageDead(_7); // scope 0 at $DIR/boxes.rs:+1:21: +1:22
_9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:13: +1:22
_2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +1:22
_1 = Add(move _2, const 0_i32); // scope 0 at $DIR/boxes.rs:+1:13: +1:26
StorageDead(_2); // scope 0 at $DIR/boxes.rs:+1:25: +1:26
drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+1:26: +1:27
StorageLive(_7); // scope 0 at $DIR/boxes.rs:+1:14: +2:18
_7 = ShallowInitBox(move _6, i32); // scope 0 at $DIR/boxes.rs:+1:14: +2:18
_8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+2:14: +2:16
(*_8) = const 42_i32; // scope 0 at $DIR/boxes.rs:+2:14: +2:16
_3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +2:18
StorageDead(_7); // scope 0 at $DIR/boxes.rs:+2:17: +2:18
_9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:13: +2:18
_2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +2:18
_1 = Add(move _2, const 0_i32); // scope 0 at $DIR/boxes.rs:+1:13: +3:12
StorageDead(_2); // scope 0 at $DIR/boxes.rs:+3:11: +3:12
drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+3:12: +3:13
}
bb2: {
StorageDead(_3); // scope 0 at $DIR/boxes.rs:+1:26: +1:27
_0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +2:2
StorageDead(_1); // scope 0 at $DIR/boxes.rs:+2:1: +2:2
return; // scope 0 at $DIR/boxes.rs:+2:2: +2:2
StorageDead(_3); // scope 0 at $DIR/boxes.rs:+3:12: +3:13
_0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +4:2
StorageDead(_1); // scope 0 at $DIR/boxes.rs:+4:1: +4:2
return; // scope 0 at $DIR/boxes.rs:+4:2: +4:2
}
bb3 (cleanup): {
resume; // scope 0 at $DIR/boxes.rs:+0:1: +2:2
resume; // scope 0 at $DIR/boxes.rs:+0:1: +4:2
}
}

View File

@ -4,11 +4,13 @@
// ignore-wasm32
// ignore-wasm64
#![feature(box_syntax)]
#![feature(rustc_attrs, stmt_expr_attributes)]
// Note: this test verifies that we, in fact, do not const prop `box`
// Note: this test verifies that we, in fact, do not const prop `#[rustc_box]`
// EMIT_MIR boxes.main.ConstProp.diff
fn main() {
let x = *(box 42) + 0;
let x = *(#[rustc_box]
Box::new(42))
+ 0;
}

View File

@ -3,58 +3,42 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/derefer_inline_test.rs:+0:11: +0:11
let _1: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
let mut _2: usize; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
let mut _3: usize; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
let mut _4: *mut u8; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
let mut _5: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
scope 1 {
}
let _1: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18
let mut _2: std::boxed::Box<u32>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17
bb0: {
StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
_2 = SizeOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12
_3 = AlignOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12
StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18
StorageLive(_2); // scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17
_2 = f() -> bb1; // scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17
// mir::Constant
// + span: $DIR/derefer_inline_test.rs:11:5: 11:12
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_5); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
_5 = ShallowInitBox(move _4, std::boxed::Box<u32>); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
(*_5) = f() -> [return: bb2, unwind: bb6]; // scope 0 at $DIR/derefer_inline_test.rs:+1:9: +1:12
// mir::Constant
// + span: $DIR/derefer_inline_test.rs:11:9: 11:10
// + span: $DIR/derefer_inline_test.rs:10:14: 10:15
// + literal: Const { ty: fn() -> Box<u32> {f}, val: Value(<ZST>) }
}
bb1: {
_1 = Box::<Box<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18
// mir::Constant
// + span: $DIR/derefer_inline_test.rs:10:5: 10:13
// + user_ty: UserType(0)
// + literal: Const { ty: fn(Box<u32>) -> Box<Box<u32>> {Box::<Box<u32>>::new}, val: Value(<ZST>) }
}
bb2: {
_1 = move _5; // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
drop(_5) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12
StorageDead(_2); // scope 0 at $DIR/derefer_inline_test.rs:+1:17: +1:18
drop(_1) -> bb3; // scope 0 at $DIR/derefer_inline_test.rs:+1:18: +1:19
}
bb3: {
StorageDead(_5); // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12
drop(_1) -> bb4; // scope 0 at $DIR/derefer_inline_test.rs:+1:12: +1:13
}
bb4: {
StorageDead(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:12: +1:13
StorageDead(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:18: +1:19
_0 = const (); // scope 0 at $DIR/derefer_inline_test.rs:+0:11: +2:2
return; // scope 0 at $DIR/derefer_inline_test.rs:+2:2: +2:2
}
bb4 (cleanup): {
drop(_2) -> bb5; // scope 0 at $DIR/derefer_inline_test.rs:+1:17: +1:18
}
bb5 (cleanup): {
drop(_1) -> bb7; // scope 0 at $DIR/derefer_inline_test.rs:+1:12: +1:13
}
bb6 (cleanup): {
drop(_5) -> bb7; // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12
}
bb7 (cleanup): {
resume; // scope 0 at $DIR/derefer_inline_test.rs:+0:1: +2:2
}
}

View File

@ -2,11 +2,10 @@
// EMIT_MIR derefer_inline_test.main.Derefer.diff
// ignore-wasm32 compiled with panic=abort by default
#![feature(box_syntax)]
#[inline]
fn f() -> Box<u32> {
box 0
Box::new(0)
}
fn main() {
box f();
Box::new(f());
}

View File

@ -4,81 +4,78 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline_into_box_place.rs:+0:11: +0:11
let _1: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11
let mut _2: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
let mut _3: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
let mut _4: *mut u8; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
let mut _5: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
let mut _6: (); // in scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43
let mut _7: *const std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+ let mut _8: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ let mut _9: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
let mut _2: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48
scope 1 {
debug _x => _1; // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11
}
scope 2 {
}
+ scope 3 (inlined Vec::<u32>::new) { // at $DIR/inline_into_box_place.rs:8:33: 8:43
+ let mut _10: alloc::raw_vec::RawVec<u32>; // in scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ scope 2 (inlined Vec::<u32>::new) { // at $DIR/inline_into_box_place.rs:7:38: 7:48
+ let mut _3: alloc::raw_vec::RawVec<u32>; // in scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ }
+ scope 3 (inlined Box::<Vec<u32>>::new) { // at $DIR/inline_into_box_place.rs:7:29: 7:49
+ debug x => _2; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ let mut _4: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ let mut _5: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ let mut _6: *mut u8; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ let mut _7: *const std::vec::Vec<u32>; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ scope 4 {
+ }
+ }
bb0: {
StorageLive(_1); // scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11
_2 = SizeOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43
_3 = AlignOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43
StorageLive(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48
- _2 = Vec::<u32>::new() -> bb1; // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48
+ StorageLive(_3); // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ _3 = const _; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
// mir::Constant
// + span: $DIR/inline_into_box_place.rs:8:29: 8:43
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
_5 = ShallowInitBox(move _4, std::vec::Vec<u32>); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
_7 = (((_5.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
- (*_7) = Vec::<u32>::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ StorageLive(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ _8 = &mut (*_7); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ StorageLive(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ StorageLive(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ _10 = const _; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
// mir::Constant
- // + span: $DIR/inline_into_box_place.rs:8:33: 8:41
- // + user_ty: UserType(1)
- // + span: $DIR/inline_into_box_place.rs:7:38: 7:46
- // + user_ty: UserType(2)
- // + literal: Const { ty: fn() -> Vec<u32> {Vec::<u32>::new}, val: Value(<ZST>) }
- }
-
- bb2: {
+ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ // + user_ty: UserType(0)
+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Unevaluated(alloc::raw_vec::RawVec::<T>::NEW, [u32], None) }
+ _9 = Vec::<u32> { buf: move _10, len: const 0_usize }; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ (*_8) = move _9; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ StorageDead(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+ StorageDead(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
_1 = move _5; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
StorageDead(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43
_0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2
- drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
+ drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
+ _2 = Vec::<u32> { buf: move _3, len: const 0_usize }; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ StorageDead(_3); // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ _4 = SizeOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ _5 = AlignOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb3, unwind: bb4]; // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ // mir::Constant
+ // + span: $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
- bb3: {
+ bb2: {
StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2
}
- bb4 (cleanup): {
+ bb3 (cleanup): {
resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2
- }
-
- bb5 (cleanup): {
- _6 = alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>(move (_5.0: std::ptr::Unique<std::vec::Vec<u32>>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43
bb1: {
- _1 = Box::<Vec<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:49
- // mir::Constant
- // + span: $DIR/inline_into_box_place.rs:8:42: 8:43
- // + literal: Const { ty: unsafe fn(Unique<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}, val: Value(<ZST>) }
- // + span: $DIR/inline_into_box_place.rs:7:29: 7:37
- // + user_ty: UserType(1)
- // + literal: Const { ty: fn(Vec<u32>) -> Box<Vec<u32>> {Box::<Vec<u32>>::new}, val: Value(<ZST>) }
+ StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
+ return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2
}
- bb2: {
- StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49
- _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2
- drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2
}
bb3: {
- StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
- return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2
+ _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ (*_7) = move _2; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49
+ _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2
+ drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
}
bb4 (cleanup): {
- resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2
+ drop(_2) -> bb2; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
}
}

View File

@ -2,8 +2,7 @@
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -Z mir-opt-level=4
#![feature(box_syntax)]
// EMIT_MIR inline_into_box_place.main.Inline.diff
fn main() {
let _x: Box<Vec<u32>> = box Vec::new();
let _x: Box<Vec<u32>> = Box::new(Vec::new());
}

View File

@ -2,11 +2,14 @@
// initializing it
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(box_syntax)]
#![feature(rustc_attrs)]
// EMIT_MIR issue_62289.test.ElaborateDrops.before.mir
fn test() -> Option<Box<u32>> {
Some(box (None?))
Some(
#[rustc_box]
Box::new(None?),
)
}
fn main() {

View File

@ -2,121 +2,121 @@
fn test() -> Option<Box<u32>> {
let mut _0: std::option::Option<std::boxed::Box<u32>>; // return place in scope 0 at $DIR/issue_62289.rs:+0:14: +0:30
let mut _1: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
let mut _2: usize; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
let mut _3: usize; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
let mut _4: *mut u8; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
let mut _5: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
let mut _6: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:19
let mut _8: isize; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
let _9: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
let mut _10: !; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
let mut _11: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
let _12: u32; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
let mut _1: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
let mut _2: usize; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
let mut _3: usize; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
let mut _4: *mut u8; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
let mut _5: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
let mut _6: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:22
let mut _8: isize; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
let _9: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
let mut _10: !; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
let mut _11: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
let _12: u32; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
scope 1 {
}
scope 2 {
debug residual => _9; // in scope 2 at $DIR/issue_62289.rs:+1:19: +1:20
debug residual => _9; // in scope 2 at $DIR/issue_62289.rs:+3:22: +3:23
scope 3 {
}
}
scope 4 {
debug val => _12; // in scope 4 at $DIR/issue_62289.rs:+1:15: +1:20
debug val => _12; // in scope 4 at $DIR/issue_62289.rs:+3:18: +3:23
scope 5 {
}
}
bb0: {
StorageLive(_1); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
_2 = SizeOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21
_3 = AlignOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21
StorageLive(_1); // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
_2 = SizeOf(u32); // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24
_3 = AlignOf(u32); // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24
// mir::Constant
// + span: $DIR/issue_62289.rs:9:10: 9:21
// + span: $DIR/issue_62289.rs:11:9: 11:24
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
bb1: {
StorageLive(_5); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
_5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
StorageLive(_6); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19
_7 = Option::<u32>::None; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19
_6 = <Option<u32> as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
StorageLive(_5); // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
_5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
StorageLive(_6); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:22
_7 = Option::<u32>::None; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:22
_6 = <Option<u32> as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
// mir::Constant
// + span: $DIR/issue_62289.rs:9:15: 9:20
// + span: $DIR/issue_62289.rs:11:18: 11:23
// + literal: Const { ty: fn(Option<u32>) -> ControlFlow<<Option<u32> as Try>::Residual, <Option<u32> as Try>::Output> {<Option<u32> as Try>::branch}, val: Value(<ZST>) }
}
bb2: {
StorageDead(_7); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
_8 = discriminant(_6); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
StorageDead(_7); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
_8 = discriminant(_6); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
}
bb3: {
StorageLive(_12); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
_12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
(*_5) = _12; // scope 5 at $DIR/issue_62289.rs:+1:15: +1:20
StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
_1 = move _5; // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
StorageLive(_12); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
_12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
(*_5) = _12; // scope 5 at $DIR/issue_62289.rs:+3:18: +3:23
StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
_1 = move _5; // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24
drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
}
bb4: {
unreachable; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
unreachable; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
}
bb5: {
StorageLive(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
_9 = ((_6 as Break).0: std::option::Option<std::convert::Infallible>); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
StorageLive(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20
_11 = _9; // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20
_0 = <Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue_62289.rs:+1:15: +1:20
StorageLive(_9); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
_9 = ((_6 as Break).0: std::option::Option<std::convert::Infallible>); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
StorageLive(_11); // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23
_11 = _9; // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23
_0 = <Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue_62289.rs:+3:18: +3:23
// mir::Constant
// + span: $DIR/issue_62289.rs:9:19: 9:20
// + span: $DIR/issue_62289.rs:11:22: 11:23
// + literal: Const { ty: fn(Option<Infallible>) -> Option<Box<u32>> {<Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual}, val: Value(<ZST>) }
}
bb6: {
StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20
StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23
StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
}
bb7: {
StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
_0 = Option::<Box<u32>>::Some(move _1); // scope 0 at $DIR/issue_62289.rs:+1:5: +1:22
drop(_1) -> bb8; // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
_0 = Option::<Box<u32>>::Some(move _1); // scope 0 at $DIR/issue_62289.rs:+1:5: +4:6
drop(_1) -> bb8; // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
}
bb8: {
StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2
goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2
StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+5:1: +5:2
goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2
}
bb9: {
StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2
goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2
StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+5:1: +5:2
goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2
}
bb10: {
return; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2
return; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2
}
bb11 (cleanup): {
drop(_1) -> bb13; // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
drop(_1) -> bb13; // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
}
bb12 (cleanup): {
drop(_5) -> bb13; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
drop(_5) -> bb13; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
}
bb13 (cleanup): {
resume; // scope 0 at $DIR/issue_62289.rs:+0:1: +2:2
resume; // scope 0 at $DIR/issue_62289.rs:+0:1: +5:2
}
}

View File

@ -4,7 +4,6 @@ fn main() {}
#[cfg(FALSE)]
fn syntax() {
let _ = #[attr] box 0;
let _ = #[attr] [];
let _ = #[attr] [0];
let _ = #[attr] [0; 0];

View File

@ -1,6 +1,5 @@
// pp-exact
#![feature(box_syntax)]
#![feature(inline_const)]
#![feature(inline_const_pat)]
#![feature(rustc_attrs)]
@ -140,7 +139,6 @@ fn _10() {
}
fn _11() {
let _ = #[rustc_dummy] box 0;
let _: [(); 0] = #[rustc_dummy] [];
let _ = #[rustc_dummy] [0, 0];
let _ = #[rustc_dummy] [0; 0];

View File

@ -73,11 +73,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
let mut g = |e| f(expr(e));
for kind in 0..=19 {
for kind in 0..=18 {
match kind {
0 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Box(e))),
1 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Call(e, thin_vec![]))),
2 => {
0 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Call(e, thin_vec![]))),
1 => {
let seg = PathSegment::from_ident(Ident::from_str("x"));
iter_exprs(depth - 1, &mut |e| {
g(ExprKind::MethodCall(Box::new(MethodCall {
@ -90,26 +89,26 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
}))
)});
}
3..=8 => {
2..=7 => {
let op = Spanned {
span: DUMMY_SP,
node: match kind {
3 => BinOpKind::Add,
4 => BinOpKind::Mul,
5 => BinOpKind::Shl,
6 => BinOpKind::And,
7 => BinOpKind::Or,
8 => BinOpKind::Lt,
2 => BinOpKind::Add,
3 => BinOpKind::Mul,
4 => BinOpKind::Shl,
5 => BinOpKind::And,
6 => BinOpKind::Or,
7 => BinOpKind::Lt,
_ => unreachable!(),
},
};
iter_exprs(depth - 1, &mut |e| g(ExprKind::Binary(op, e, make_x())));
iter_exprs(depth - 1, &mut |e| g(ExprKind::Binary(op, make_x(), e)));
}
9 => {
8 => {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Unary(UnOp::Deref, e)));
}
10 => {
9 => {
let block = P(Block {
stmts: ThinVec::new(),
id: DUMMY_NODE_ID,
@ -120,7 +119,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
});
iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None)));
}
11 => {
10 => {
let decl = P(FnDecl { inputs: thin_vec![], output: FnRetTy::Default(DUMMY_SP) });
iter_exprs(depth - 1, &mut |e| {
g(ExprKind::Closure(Box::new(Closure {
@ -136,14 +135,14 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
})))
});
}
12 => {
11 => {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Assign(e, make_x(), DUMMY_SP)));
iter_exprs(depth - 1, &mut |e| g(ExprKind::Assign(make_x(), e, DUMMY_SP)));
}
13 => {
12 => {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Field(e, Ident::from_str("f"))));
}
14 => {
13 => {
iter_exprs(depth - 1, &mut |e| {
g(ExprKind::Range(Some(e), Some(make_x()), RangeLimits::HalfOpen))
});
@ -151,16 +150,16 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
g(ExprKind::Range(Some(make_x()), Some(e), RangeLimits::HalfOpen))
});
}
15 => {
14 => {
iter_exprs(depth - 1, &mut |e| {
g(ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, e))
});
}
16 => {
15 => {
g(ExprKind::Ret(None));
iter_exprs(depth - 1, &mut |e| g(ExprKind::Ret(Some(e))));
}
17 => {
16 => {
let path = Path::from_ident(Ident::from_str("S"));
g(ExprKind::Struct(P(StructExpr {
qself: None,
@ -169,10 +168,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
rest: StructRest::Base(make_x()),
})));
}
18 => {
17 => {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Try(e)));
}
19 => {
18 => {
let pat =
P(Pat { id: DUMMY_NODE_ID, kind: PatKind::Wild, span: DUMMY_SP, tokens: None });
iter_exprs(depth - 1, &mut |e| g(ExprKind::Let(pat.clone(), e, DUMMY_SP)))

View File

@ -1,7 +1,6 @@
// Verifies all possible restrictions for statics values.
#![allow(warnings)]
#![feature(box_syntax)]
use std::marker;
@ -19,7 +18,7 @@ enum SafeEnum {
Variant1,
Variant2(isize),
Variant3(WithDtor),
Variant4(String)
Variant4(String),
}
// These should be ok
@ -29,42 +28,45 @@ static STATIC3: SafeEnum = SafeEnum::Variant3(WithDtor);
enum UnsafeEnum {
Variant5,
Variant6(isize)
Variant6(isize),
}
impl Drop for UnsafeEnum {
fn drop(&mut self) {}
}
static STATIC4: UnsafeEnum = UnsafeEnum::Variant5;
static STATIC5: UnsafeEnum = UnsafeEnum::Variant6(0);
struct SafeStruct {
field1: SafeEnum,
field2: SafeEnum,
}
// Struct fields are safe, hence this static should be safe
static STATIC6: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, field2: SafeEnum::Variant2(0)};
static STATIC6: SafeStruct =
SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant2(0) };
static STATIC7: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
field2: SafeEnum::Variant3(WithDtor)};
static STATIC7: SafeStruct =
SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant3(WithDtor) };
// Test variadic constructor for structs. The base struct should be examined
// as well as every field present in the constructor.
// This example shouldn't fail because all the fields are safe.
static STATIC8: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
..SafeStruct{field1: SafeEnum::Variant1,
field2: SafeEnum::Variant1}};
static STATIC8: SafeStruct = SafeStruct {
field1: SafeEnum::Variant1,
..SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant1 }
};
// This example should fail because field1 in the base struct is not safe
static STATIC9: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
..SafeStruct{field1: SafeEnum::Variant3(WithDtor),
//~^ ERROR destructor of
field2: SafeEnum::Variant1}};
static STATIC9: SafeStruct = SafeStruct {
field1: SafeEnum::Variant1,
..SafeStruct {
//~^ ERROR destructor of
field1: SafeEnum::Variant3(WithDtor),
field2: SafeEnum::Variant1,
}
};
struct UnsafeStruct;
@ -76,38 +78,45 @@ static STATIC10: UnsafeStruct = UnsafeStruct;
struct MyOwned;
static STATIC11: Box<MyOwned> = box MyOwned;
static STATIC11: Vec<MyOwned> = vec![MyOwned];
//~^ ERROR allocations are not allowed in statics
//~^^ ERROR cannot call non-const
static mut STATIC12: UnsafeStruct = UnsafeStruct;
static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
field2: SafeEnum::Variant3(WithDtor)};
static mut STATIC13: SafeStruct =
SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant3(WithDtor) };
static mut STATIC14: SafeStruct = SafeStruct {
field1: SafeEnum::Variant1,
field2: SafeEnum::Variant4("str".to_string())
//~^ ERROR cannot call non-const fn
field2: SafeEnum::Variant4("str".to_string()), //~ ERROR cannot call non-const fn
};
static STATIC15: &'static [Box<MyOwned>] = &[
box MyOwned, //~ ERROR allocations are not allowed in statics
box MyOwned, //~ ERROR allocations are not allowed in statics
static STATIC15: &'static [Vec<MyOwned>] = &[
vec![MyOwned], //~ ERROR allocations are not allowed in statics
//~^ ERROR cannot call non-const
vec![MyOwned], //~ ERROR allocations are not allowed in statics
//~^ ERROR cannot call non-const
];
static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = (
&box MyOwned, //~ ERROR allocations are not allowed in statics
&box MyOwned, //~ ERROR allocations are not allowed in statics
static STATIC16: (&'static Vec<MyOwned>, &'static Vec<MyOwned>) = (
&vec![MyOwned], //~ ERROR allocations are not allowed in statics
//~^ ERROR cannot call non-const
&vec![MyOwned], //~ ERROR allocations are not allowed in statics
//~^ ERROR cannot call non-const
);
static mut STATIC17: SafeEnum = SafeEnum::Variant1;
static STATIC19: Box<isize> =
box 3;
static STATIC19: Vec<isize> = vec![3];
//~^ ERROR allocations are not allowed in statics
//~^^ ERROR cannot call non-const
pub fn main() {
let y = { static x: Box<isize> = box 3; x };
//~^ ERROR allocations are not allowed in statics
//~| ERROR cannot move out of static item
let y = {
static x: Vec<isize> = vec![3]; //~ ERROR allocations are not allowed in statics
//~^ ERROR cannot call non-const
x
//~^ ERROR cannot move out of static
};
}

View File

@ -1,24 +1,38 @@
error[E0493]: destructor of `SafeStruct` cannot be evaluated at compile-time
--> $DIR/check-static-values-constraints.rs:65:43
--> $DIR/check-static-values-constraints.rs:64:7
|
LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor),
| ___________________________________________^
LL | ..SafeStruct {
| _______^
LL | |
LL | | field2: SafeEnum::Variant1}};
| | ^- value is dropped here
| |________________________________________________________________________________|
| the destructor for this type cannot be evaluated in statics
LL | | field1: SafeEnum::Variant3(WithDtor),
LL | | field2: SafeEnum::Variant1,
LL | | }
| |_____^ the destructor for this type cannot be evaluated in statics
LL | };
| - value is dropped here
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:79:33
--> $DIR/check-static-values-constraints.rs:81:33
|
LL | static STATIC11: Box<MyOwned> = box MyOwned;
| ^^^^^^^^^^^ allocation not allowed in statics
LL | static STATIC11: Vec<MyOwned> = vec![MyOwned];
| ^^^^^^^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:81:33
|
LL | static STATIC11: Vec<MyOwned> = vec![MyOwned];
| ^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `<str as ToString>::to_string` in statics
--> $DIR/check-static-values-constraints.rs:89:38
--> $DIR/check-static-values-constraints.rs:92:38
|
LL | field2: SafeEnum::Variant4("str".to_string())
LL | field2: SafeEnum::Variant4("str".to_string()),
| ^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
@ -26,53 +40,125 @@ LL | field2: SafeEnum::Variant4("str".to_string())
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:94:5
--> $DIR/check-static-values-constraints.rs:96:5
|
LL | box MyOwned,
| ^^^^^^^^^^^ allocation not allowed in statics
LL | vec![MyOwned],
| ^^^^^^^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:96:5
|
LL | vec![MyOwned],
| ^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:95:5
--> $DIR/check-static-values-constraints.rs:98:5
|
LL | box MyOwned,
| ^^^^^^^^^^^ allocation not allowed in statics
LL | vec![MyOwned],
| ^^^^^^^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:98:5
|
LL | vec![MyOwned],
| ^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:99:6
--> $DIR/check-static-values-constraints.rs:103:6
|
LL | &box MyOwned,
| ^^^^^^^^^^^ allocation not allowed in statics
LL | &vec![MyOwned],
| ^^^^^^^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:103:6
|
LL | &vec![MyOwned],
| ^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:100:6
--> $DIR/check-static-values-constraints.rs:105:6
|
LL | &box MyOwned,
| ^^^^^^^^^^^ allocation not allowed in statics
LL | &vec![MyOwned],
| ^^^^^^^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:105:6
|
LL | &vec![MyOwned],
| ^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:106:5
--> $DIR/check-static-values-constraints.rs:111:31
|
LL | box 3;
| ^^^^^ allocation not allowed in statics
LL | static STATIC19: Vec<isize> = vec![3];
| ^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const fn `slice::<impl [isize]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:111:31
|
LL | static STATIC19: Vec<isize> = vec![3];
| ^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0507]: cannot move out of static item `x`
--> $DIR/check-static-values-constraints.rs:110:45
--> $DIR/check-static-values-constraints.rs:119:9
|
LL | let y = { static x: Box<isize> = box 3; x };
| ^ move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait
LL | x
| ^ move occurs because `x` has type `Vec<isize>`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let y = { static x: Box<isize> = box 3; &x };
LL | &x
| +
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:110:38
--> $DIR/check-static-values-constraints.rs:117:32
|
LL | let y = { static x: Box<isize> = box 3; x };
| ^^^^^ allocation not allowed in statics
LL | static x: Vec<isize> = vec![3];
| ^^^^^^^ allocation not allowed in statics
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 10 previous errors
error[E0015]: cannot call non-const fn `slice::<impl [isize]>::into_vec::<std::alloc::Global>` in statics
--> $DIR/check-static-values-constraints.rs:117:32
|
LL | static x: Vec<isize> = vec![3];
| ^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 17 previous errors
Some errors have detailed explanations: E0010, E0015, E0493, E0507.
For more information about an error, try `rustc --explain E0010`.

View File

@ -1,18 +1,19 @@
// A version of coerce-expect-unsized that uses type ascription.
// Doesn't work so far, but supposed to work eventually
#![feature(box_syntax, type_ascription)]
#![feature(type_ascription)]
use std::fmt::Debug;
pub fn main() {
let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); //~ ERROR mismatched types
let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>); //~ ERROR mismatched types
let _ = type_ascribe!(box match true { true => [1, 2, 3], false => [1, 3, 4] }, Box<[i32]>);
let _ = type_ascribe!(Box::new({ [1, 2, 3] }), Box<[i32]>); //~ ERROR mismatched types
let _ = type_ascribe!(Box::new( if true { [1, 2, 3] } else { [1, 3, 4] }), Box<[i32]>); //~ ERROR mismatched types
let _ = type_ascribe!(
Box::new( match true { true => [1, 2, 3], false => [1, 3, 4] }), Box<[i32]>);
//~^ ERROR mismatched types
let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types
let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>); //~ ERROR mismatched types
let _ = type_ascribe!(box match true { true => 'a', false => 'b' }, Box<dyn Debug>); //~ ERROR mismatched types
let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types
let _ = type_ascribe!(Box::new( if true { false } else { true }), Box<dyn Debug>); //~ ERROR mismatched types
let _ = type_ascribe!(Box::new( match true { true => 'a', false => 'b' }), Box<dyn Debug>); //~ ERROR mismatched types
let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]); //~ ERROR mismatched types
let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]); //~ ERROR mismatched types
@ -27,6 +28,6 @@ pub fn main() {
let _ = type_ascribe!(vec![
Box::new(|x| (x as u8)),
box |x| (x as i16 as u8),
Box::new(|x| (x as i16 as u8)),
], Vec<Box<dyn Fn(i32) -> _>>);
}

View File

@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:9:27
|
LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>);
| ^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
LL | let _ = type_ascribe!(Box::new({ [1, 2, 3] }), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
|
= note: expected struct `Box<[i32]>`
found struct `Box<[i32; 3]>`
@ -10,50 +10,50 @@ LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>);
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:10:27
|
LL | let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
LL | let _ = type_ascribe!(Box::new( if true { [1, 2, 3] } else { [1, 3, 4] }), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
|
= note: expected struct `Box<[i32]>`
found struct `Box<[i32; 3]>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:11:27
--> $DIR/coerce-expect-unsized-ascribed.rs:12:9
|
LL | let _ = type_ascribe!(box match true { true => [1, 2, 3], false => [1, 3, 4] }, Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
LL | Box::new( match true { true => [1, 2, 3], false => [1, 3, 4] }), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
|
= note: expected struct `Box<[i32]>`
found struct `Box<[i32; 3]>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:13:27
|
LL | let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>);
| ^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:13:33]>`
|
= note: expected struct `Box<dyn Fn(i32) -> u8>`
found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:33: 13:36]>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:14:27
|
LL | let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<bool>`
LL | let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box<dyn Fn(i32) -> _>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:14:39]>`
|
= note: expected struct `Box<dyn Fn(i32) -> u8>`
found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:14:39: 14:42]>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:15:27
|
LL | let _ = type_ascribe!(Box::new( if true { false } else { true }), Box<dyn Debug>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<bool>`
|
= note: expected struct `Box<dyn Debug>`
found struct `Box<bool>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:15:27
--> $DIR/coerce-expect-unsized-ascribed.rs:16:27
|
LL | let _ = type_ascribe!(box match true { true => 'a', false => 'b' }, Box<dyn Debug>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<char>`
LL | let _ = type_ascribe!(Box::new( match true { true => 'a', false => 'b' }), Box<dyn Debug>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<char>`
|
= note: expected struct `Box<dyn Debug>`
found struct `Box<char>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:17:27
--> $DIR/coerce-expect-unsized-ascribed.rs:18:27
|
LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]);
| ^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]`
@ -62,7 +62,7 @@ LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]);
found reference `&[i32; 3]`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:18:27
--> $DIR/coerce-expect-unsized-ascribed.rs:19:27
|
LL | let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]`
@ -71,7 +71,7 @@ LL | let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]
found reference `&[i32; 3]`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:19:27
--> $DIR/coerce-expect-unsized-ascribed.rs:20:27
|
LL | let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3, 4] }, &[i32]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]`
@ -80,16 +80,16 @@ LL | let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3,
found reference `&[i32; 3]`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:21:27
--> $DIR/coerce-expect-unsized-ascribed.rs:22:27
|
LL | let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _);
| ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&[closure@coerce-expect-unsized-ascribed.rs:21:30]`
| ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&[closure@coerce-expect-unsized-ascribed.rs:22:30]`
|
= note: expected reference `&dyn Fn(i32) -> u8`
found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:30: 21:33]`
found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:22:30: 22:33]`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:22:27
--> $DIR/coerce-expect-unsized-ascribed.rs:23:27
|
LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&bool`
@ -98,7 +98,7 @@ LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug);
found reference `&bool`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:23:27
--> $DIR/coerce-expect-unsized-ascribed.rs:24:27
|
LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn Debug);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&char`
@ -107,7 +107,7 @@ LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn D
found reference `&char`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:25:27
--> $DIR/coerce-expect-unsized-ascribed.rs:26:27
|
LL | let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
@ -116,13 +116,13 @@ LL | let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>);
found struct `Box<[i32; 3]>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:26:27
--> $DIR/coerce-expect-unsized-ascribed.rs:27:27
|
LL | let _ = type_ascribe!(Box::new(|x| (x as u8)), Box<dyn Fn(i32) -> _>);
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:26:36]>`
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:27:36]>`
|
= note: expected struct `Box<dyn Fn(i32) -> u8>`
found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:36: 26:39]>`
found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:27:36: 27:39]>`
error: aborting due to 14 previous errors

View File

@ -1,12 +1,11 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(box_syntax)]
use std::mem::ManuallyDrop;
fn main() {}
static TEST_BAD: &mut i32 = {
&mut *(box 0)
&mut *(Box::new(0))
//~^ ERROR could not evaluate static initializer
//~| NOTE calling non-const function `alloc::alloc::exchange_malloc`
//~| NOTE calling non-const function `Box::<i32>::new`
};

View File

@ -1,31 +1,26 @@
error[E0080]: could not evaluate static initializer
--> $DIR/box.rs:9:11
--> $DIR/box.rs:8:11
|
LL | &mut *(box 0)
| ^^^^^^^ calling non-const function `alloc::alloc::exchange_malloc`
LL | &mut *(Box::new(0))
| ^^^^^^^^^^^^^ calling non-const function `Box::<i32>::new`
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/box.rs:9:11
--> $DIR/box.rs:8:11
|
LL | &mut *(box 0)
| ^^^^^^^
help: skipping check for `const_mut_refs` feature
--> $DIR/box.rs:9:16
|
LL | &mut *(box 0)
| ^
help: skipping check for `const_mut_refs` feature
--> $DIR/box.rs:9:5
|
LL | &mut *(box 0)
LL | &mut *(Box::new(0))
| ^^^^^^^^^^^^^
help: skipping check for `const_mut_refs` feature
--> $DIR/box.rs:8:5
|
LL | &mut *(Box::new(0))
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/box.rs:9:5
--> $DIR/box.rs:8:5
|
LL | &mut *(box 0)
| ^^^^^^^^^^^^^
LL | &mut *(Box::new(0))
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted

View File

@ -1,8 +1,7 @@
// compile-flags: -Z teach
#![feature(box_syntax)]
#![allow(warnings)]
const CON : Box<i32> = box 0; //~ ERROR E0010
const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010
//~| ERROR cannot call non-const fn
fn main() {}

View File

@ -1,11 +1,22 @@
error[E0010]: allocations are not allowed in constants
--> $DIR/E0010-teach.rs:6:24
--> $DIR/E0010-teach.rs:5:23
|
LL | const CON : Box<i32> = box 0;
| ^^^^^ allocation not allowed in constants
LL | const CON: Vec<i32> = vec![1, 2, 3];
| ^^^^^^^^^^^^^ allocation not allowed in constants
|
= note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time.
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
error[E0015]: cannot call non-const fn `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constants
--> $DIR/E0010-teach.rs:5:23
|
LL | const CON: Vec<i32> = vec![1, 2, 3];
| ^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0010`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0010, E0015.
For more information about an error, try `rustc --explain E0010`.

View File

@ -1,6 +1,5 @@
#![feature(box_syntax)]
#![allow(warnings)]
const CON : Box<i32> = box 0; //~ ERROR E0010
const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010
//~| ERROR cannot call non-const fn
fn main() {}

View File

@ -1,9 +1,21 @@
error[E0010]: allocations are not allowed in constants
--> $DIR/E0010.rs:4:24
--> $DIR/E0010.rs:3:23
|
LL | const CON : Box<i32> = box 0;
| ^^^^^ allocation not allowed in constants
LL | const CON: Vec<i32> = vec![1, 2, 3];
| ^^^^^^^^^^^^^ allocation not allowed in constants
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
error[E0015]: cannot call non-const fn `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constants
--> $DIR/E0010.rs:3:23
|
LL | const CON: Vec<i32> = vec![1, 2, 3];
| ^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0010`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0010, E0015.
For more information about an error, try `rustc --explain E0010`.

View File

@ -1,5 +1,5 @@
error[E0382]: borrow of moved value: `g`
--> $DIR/issue-105084.rs:44:14
--> $DIR/issue-105084.rs:45:14
|
LL | let mut g = || {
| ----- move occurs because `g` has type `[generator@$DIR/issue-105084.rs:22:17: 22:19]`, which does not implement the `Copy` trait
@ -23,7 +23,7 @@ LL | let mut h = copy(g.clone());
| ++++++++
error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `[generator@$DIR/issue-105084.rs:22:17: 22:19]`
--> $DIR/issue-105084.rs:38:17
--> $DIR/issue-105084.rs:39:17
|
LL | let mut g = || {
| -- within this `[generator@$DIR/issue-105084.rs:22:17: 22:19]`
@ -32,12 +32,12 @@ LL | let mut h = copy(g);
| ^^^^ within `[generator@$DIR/issue-105084.rs:22:17: 22:19]`, the trait `Copy` is not implemented for `Box<(i32, ())>`
|
note: generator does not implement `Copy` as this value is used across a yield
--> $DIR/issue-105084.rs:28:25
--> $DIR/issue-105084.rs:29:22
|
LL | let t = box (5, yield);
| --------^^^^^-
LL | Box::new((5, yield));
| -------------^^^^^--
| | |
| | yield occurs here, with `box (5, yield)` maybe used later
| | yield occurs here, with `Box::new((5, yield))` maybe used later
| has type `Box<(i32, ())>` which does not implement `Copy`
note: required by a bound in `copy`
--> $DIR/issue-105084.rs:17:12

View File

@ -9,7 +9,7 @@
#![feature(generators)]
#![feature(generator_clone)]
#![feature(generator_trait)]
#![feature(box_syntax)]
#![feature(rustc_attrs, stmt_expr_attributes)]
use std::ops::Generator;
use std::pin::Pin;
@ -25,7 +25,8 @@ fn main() {
// - create a Box that is ignored for trait computations;
// - compute fields (and yields);
// - assign to `t`.
let t = box (5, yield);
let t = #[rustc_box]
Box::new((5, yield));
drop(t);
};

View File

@ -1,24 +0,0 @@
// run-pass
// Test that box-statements with yields in them work.
#![feature(generators, box_syntax, generator_trait)]
use std::pin::Pin;
use std::ops::Generator;
use std::ops::GeneratorState;
fn main() {
let x = 0i32;
|| { //~ WARN unused generator that must be used
let y = 2u32;
{
let _t = box (&x, yield 0, &y);
}
match box (&x, yield 0, &y) {
_t => {}
}
};
let mut g = |_| box yield;
assert_eq!(Pin::new(&mut g).resume(1), GeneratorState::Yielded(()));
assert_eq!(Pin::new(&mut g).resume(2), GeneratorState::Complete(box 2));
}

View File

@ -1,17 +0,0 @@
warning: unused generator that must be used
--> $DIR/yield-in-box.rs:11:5
|
LL | / || {
LL | | let y = 2u32;
LL | | {
LL | | let _t = box (&x, yield 0, &y);
... |
LL | | }
LL | | };
| |_____^
|
= note: generators are lazy and do nothing unless resumed
= note: `#[warn(unused_must_use)]` on by default
warning: 1 warning emitted

View File

@ -1,16 +0,0 @@
// Test that we don't ICE when we are missing the owned_box lang item.
// error-pattern: requires `owned_box` lang_item
#![feature(lang_items, box_syntax)]
#![no_std]
use core::panic::PanicInfo;
fn main() {
let x = box 1i32;
}
#[lang = "eh_personality"] extern "C" fn eh_personality() {}
#[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0;
#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} }

View File

@ -1,4 +0,0 @@
error: requires `owned_box` lang_item
error: aborting due to previous error

View File

@ -5,7 +5,7 @@
// needs-unwind Asserting on contents of error message
#![allow(path_statements, unused_allocation)]
#![feature(box_syntax, core_intrinsics, generic_assert, generic_assert_internals)]
#![feature(core_intrinsics, generic_assert, generic_assert_internals)]
macro_rules! test {
(
@ -127,9 +127,6 @@ fn main() {
// block
[ { elem } == 3 ] => "Assertion failed: { elem } == 3"
// box
[ box elem == box 3 ] => "Assertion failed: box elem == box 3"
// break
[ loop { break elem; } == 3 ] => "Assertion failed: loop { break elem; } == 3"

View File

@ -4,7 +4,6 @@
#![feature(async_closure)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(generators)]
@ -91,9 +90,6 @@ fn test_block() {
#[test]
fn test_expr() {
// ExprKind::Box
assert_eq!(stringify_expr!(box expr), "box expr");
// ExprKind::Array
assert_eq!(stringify_expr!([]), "[]");
assert_eq!(stringify_expr!([true]), "[true]");

View File

@ -1,10 +0,0 @@
// run-pass
#![feature(box_syntax)]
fn test() -> Box<i32> {
box 42
}
fn main() {
assert_eq!(*test(), 42);
}

View File

@ -1,7 +1,5 @@
fn main() {}
#[cfg(FALSE)] fn e() { let _ = box #![attr] 0; }
//~^ ERROR an inner attribute is not permitted in this context
#[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
//~^ ERROR expected expression, found `]`
#[cfg(FALSE)] fn e() { let _ = foo#[attr](); }

View File

@ -1,26 +1,17 @@
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:3:36
|
LL | #[cfg(FALSE)] fn e() { let _ = box #![attr] 0; }
| ^^^^^^^^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `]`
--> $DIR/attr-stmt-expr-attr-bad.rs:5:40
--> $DIR/attr-stmt-expr-attr-bad.rs:3:40
|
LL | #[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
| ^ expected expression
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:7:35
--> $DIR/attr-stmt-expr-attr-bad.rs:5:35
|
LL | #[cfg(FALSE)] fn e() { let _ = foo#[attr](); }
| ^ expected one of 8 possible tokens
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:9:36
--> $DIR/attr-stmt-expr-attr-bad.rs:7:36
|
LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
| ^^^^^^^^
@ -29,13 +20,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `)`
--> $DIR/attr-stmt-expr-attr-bad.rs:9:44
--> $DIR/attr-stmt-expr-attr-bad.rs:7:44
|
LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
| ^ expected expression
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:12:38
--> $DIR/attr-stmt-expr-attr-bad.rs:10:38
|
LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
| ^^^^^^^^
@ -44,13 +35,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `)`
--> $DIR/attr-stmt-expr-attr-bad.rs:12:46
--> $DIR/attr-stmt-expr-attr-bad.rs:10:46
|
LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
| ^ expected expression
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:15:36
--> $DIR/attr-stmt-expr-attr-bad.rs:13:36
|
LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; }
| ^^^^^^^^
@ -59,7 +50,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:17:33
--> $DIR/attr-stmt-expr-attr-bad.rs:15:33
|
LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; }
| ^^^^^^^^
@ -68,7 +59,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:19:33
--> $DIR/attr-stmt-expr-attr-bad.rs:17:33
|
LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; }
| ^^^^^^^^
@ -77,13 +68,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:21:34
--> $DIR/attr-stmt-expr-attr-bad.rs:19:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; }
| ^ expected one of 8 possible tokens
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:23:35
--> $DIR/attr-stmt-expr-attr-bad.rs:21:35
|
LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; }
| ^^^^^^^^
@ -92,7 +83,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:25:40
--> $DIR/attr-stmt-expr-attr-bad.rs:23:40
|
LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; }
| ^^^^^^^^
@ -101,7 +92,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:27:35
--> $DIR/attr-stmt-expr-attr-bad.rs:25:35
|
LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; }
| ^^^^^^^^
@ -110,7 +101,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:29:40
--> $DIR/attr-stmt-expr-attr-bad.rs:27:40
|
LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; }
| ^^^^^^^^
@ -119,19 +110,19 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `..`
--> $DIR/attr-stmt-expr-attr-bad.rs:31:40
--> $DIR/attr-stmt-expr-attr-bad.rs:29:40
|
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; }
| ^^ expected expression
error: expected expression, found `..`
--> $DIR/attr-stmt-expr-attr-bad.rs:33:40
--> $DIR/attr-stmt-expr-attr-bad.rs:31:40
|
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..; }
| ^^ expected expression
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:35:41
--> $DIR/attr-stmt-expr-attr-bad.rs:33:41
|
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; }
| ^^^^^^^^
@ -140,7 +131,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:37:45
--> $DIR/attr-stmt-expr-attr-bad.rs:35:45
|
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }
| ^^^^^^^^
@ -149,7 +140,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:39:37
--> $DIR/attr-stmt-expr-attr-bad.rs:37:37
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch
@ -158,7 +149,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; }
| the branch belongs to this `if`
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:41:38
--> $DIR/attr-stmt-expr-attr-bad.rs:39:38
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; }
| ^^^^^^^^
@ -167,13 +158,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:43:40
--> $DIR/attr-stmt-expr-attr-bad.rs:41:40
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:45:45
--> $DIR/attr-stmt-expr-attr-bad.rs:43:45
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; }
| ---- ^^^^^^^ -- the attributes are attached to this branch
@ -182,7 +173,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; }
| the branch belongs to this `else`
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:47:46
--> $DIR/attr-stmt-expr-attr-bad.rs:45:46
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }
| ^^^^^^^^
@ -191,7 +182,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:49:45
--> $DIR/attr-stmt-expr-attr-bad.rs:47:45
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; }
| ---- ^^^^^^^ ------- the attributes are attached to this branch
@ -200,7 +191,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; }
| the branch belongs to this `else`
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:51:50
--> $DIR/attr-stmt-expr-attr-bad.rs:49:50
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch
@ -209,7 +200,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; }
| the branch belongs to this `if`
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:53:51
--> $DIR/attr-stmt-expr-attr-bad.rs:51:51
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }
| ^^^^^^^^
@ -218,7 +209,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:55:45
--> $DIR/attr-stmt-expr-attr-bad.rs:53:45
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch
@ -227,7 +218,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; }
| the branch belongs to this `if`
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:57:46
--> $DIR/attr-stmt-expr-attr-bad.rs:55:46
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; }
| ^^^^^^^^
@ -236,13 +227,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:59:48
--> $DIR/attr-stmt-expr-attr-bad.rs:57:48
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:61:53
--> $DIR/attr-stmt-expr-attr-bad.rs:59:53
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; }
| ---- ^^^^^^^ -- the attributes are attached to this branch
@ -251,7 +242,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; }
| the branch belongs to this `else`
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:63:54
--> $DIR/attr-stmt-expr-attr-bad.rs:61:54
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }
| ^^^^^^^^
@ -260,7 +251,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:65:53
--> $DIR/attr-stmt-expr-attr-bad.rs:63:53
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; }
| ---- ^^^^^^^ --------------- the attributes are attached to this branch
@ -269,7 +260,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}
| the branch belongs to this `else`
error: outer attributes are not allowed on `if` and `else` branches
--> $DIR/attr-stmt-expr-attr-bad.rs:67:66
--> $DIR/attr-stmt-expr-attr-bad.rs:65:66
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch
@ -278,7 +269,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}
| the branch belongs to this `if`
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:69:67
--> $DIR/attr-stmt-expr-attr-bad.rs:67:67
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; }
| ^^^^^^^^
@ -287,7 +278,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted following an outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:72:32
--> $DIR/attr-stmt-expr-attr-bad.rs:70:32
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; }
| ------- ^^^^^^^^ not permitted following an outer attribute
@ -298,7 +289,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted following an outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:74:32
--> $DIR/attr-stmt-expr-attr-bad.rs:72:32
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; }
| ------- ^^^^^^^^ not permitted following an outer attribute
@ -309,7 +300,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; }
= note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted following an outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:76:32
--> $DIR/attr-stmt-expr-attr-bad.rs:74:32
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
| ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation
@ -325,7 +316,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!(); }
|
error: an inner attribute is not permitted following an outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:78:32
--> $DIR/attr-stmt-expr-attr-bad.rs:76:32
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
| ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation
@ -341,7 +332,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo![]; }
|
error: an inner attribute is not permitted following an outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:80:32
--> $DIR/attr-stmt-expr-attr-bad.rs:78:32
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
| ------- ^^^^^^^^ ------ the inner attribute doesn't annotate this item macro invocation
@ -357,7 +348,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!{}; }
|
error[E0586]: inclusive range with no end
--> $DIR/attr-stmt-expr-attr-bad.rs:86:35
--> $DIR/attr-stmt-expr-attr-bad.rs:84:35
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
| ^^^ help: use `..` instead
@ -365,13 +356,13 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:86:38
--> $DIR/attr-stmt-expr-attr-bad.rs:84:38
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
| ^ expected one of `=>`, `if`, or `|`
error[E0586]: inclusive range with no end
--> $DIR/attr-stmt-expr-attr-bad.rs:89:35
--> $DIR/attr-stmt-expr-attr-bad.rs:87:35
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
| ^^^ help: use `..` instead
@ -379,19 +370,19 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:89:38
--> $DIR/attr-stmt-expr-attr-bad.rs:87:38
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
| ^ expected one of `=>`, `if`, or `|`
error: unexpected token: `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:92:39
--> $DIR/attr-stmt-expr-attr-bad.rs:90:39
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } }
| ^
error[E0586]: inclusive range with no end
--> $DIR/attr-stmt-expr-attr-bad.rs:94:35
--> $DIR/attr-stmt-expr-attr-bad.rs:92:35
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
| ^^^ help: use `..` instead
@ -399,47 +390,47 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:94:38
--> $DIR/attr-stmt-expr-attr-bad.rs:92:38
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
| ^ expected one of `=>`, `if`, or `|`
error: unexpected token: `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:98:34
--> $DIR/attr-stmt-expr-attr-bad.rs:96:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
| ^
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:98:34
--> $DIR/attr-stmt-expr-attr-bad.rs:96:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: unexpected token: `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:101:34
--> $DIR/attr-stmt-expr-attr-bad.rs:99:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
| ^
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:101:34
--> $DIR/attr-stmt-expr-attr-bad.rs:99:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: expected statement after outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:106:37
--> $DIR/attr-stmt-expr-attr-bad.rs:104:37
|
LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
| ^^^^^^^
error: expected statement after outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:108:37
--> $DIR/attr-stmt-expr-attr-bad.rs:106:37
|
LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr] } } }
| ^^^^^^^
error: aborting due to 53 previous errors
error: aborting due to 52 previous errors
For more information about this error, try `rustc --explain E0586`.

View File

@ -5,11 +5,17 @@
#[allow(unused_macro_rules)]
macro_rules! m {
($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
($e:expr,) => { 1 }; // This also fails to match due to `foo`.
(box $e:expr, foo) => { 2 }; // Successful matcher, we should get `2`.
($e:expr) => {
0
}; // This fails on the input below due to `, foo`.
($e:expr,) => {
1
}; // This also fails to match due to `foo`.
(do yeet $e:expr, foo) => {
2
}; // Successful matcher, we should get `2`.
}
fn main() {
assert_eq!(2, m!(box 42, foo));
assert_eq!(2, m!(do yeet 42, foo));
}

View File

@ -1,8 +0,0 @@
#![feature(box_syntax)]
#![allow(unused_variables)]
#![deny(unreachable_code)]
fn main() {
let x = box return; //~ ERROR unreachable
println!("hi");
}

View File

@ -1,17 +0,0 @@
error: unreachable expression
--> $DIR/expr_box.rs:6:13
|
LL | let x = box return;
| ^^^^------
| | |
| | any code following this expression is unreachable
| unreachable expression
|
note: the lint level is defined here
--> $DIR/expr_box.rs:3:9
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -1,6 +1,4 @@
#![feature(box_syntax)]
static mut a: Box<isize> = box 3;
//~^ ERROR allocations are not allowed in statics
static mut a: Box<isize> = Box::new(3);
//~^ ERROR cannot call non-const fn
fn main() {}

View File

@ -1,9 +1,12 @@
error[E0010]: allocations are not allowed in statics
--> $DIR/static-mut-not-constant.rs:3:28
error[E0015]: cannot call non-const fn `Box::<isize>::new` in statics
--> $DIR/static-mut-not-constant.rs:1:28
|
LL | static mut a: Box<isize> = box 3;
| ^^^^^ allocation not allowed in statics
LL | static mut a: Box<isize> = Box::new(3);
| ^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
error: aborting due to previous error
For more information about this error, try `rustc --explain E0010`.
For more information about this error, try `rustc --explain E0015`.

View File

@ -3,10 +3,8 @@ fn digit() -> str {
//~^ ERROR: mismatched types [E0308]
}
fn main() {
let [_y..] = [box 1, box 2];
let [_y..] = [Box::new(1), Box::new(2)];
//~^ ERROR: cannot find value `_y` in this scope [E0425]
//~| ERROR: `X..` patterns in slices are experimental [E0658]
//~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658]
//~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658]
//~| ERROR: pattern requires 1 element but array has 2 [E0527]
}

View File

@ -1,38 +1,20 @@
error[E0425]: cannot find value `_y` in this scope
--> $DIR/issue-105946.rs:6:10
|
LL | let [_y..] = [box 1, box 2];
LL | let [_y..] = [Box::new(1), Box::new(2)];
| ^^ not found in this scope
error[E0658]: `X..` patterns in slices are experimental
--> $DIR/issue-105946.rs:6:10
|
LL | let [_y..] = [box 1, box 2];
LL | let [_y..] = [Box::new(1), Box::new(2)];
| ^^^^
|
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
= help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable
error[E0658]: box expression syntax is experimental; you can call `Box::new` instead
--> $DIR/issue-105946.rs:6:19
|
LL | let [_y..] = [box 1, box 2];
| ^^^^^
|
= note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information
= help: add `#![feature(box_syntax)]` to the crate attributes to enable
error[E0658]: box expression syntax is experimental; you can call `Box::new` instead
--> $DIR/issue-105946.rs:6:26
|
LL | let [_y..] = [box 1, box 2];
| ^^^^^
|
= note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information
= help: add `#![feature(box_syntax)]` to the crate attributes to enable
error[E0308]: mismatched types
--> $DIR/issue-105946.rs:2:10
--> $DIR/issue-105946.rs:2:12
|
LL | return {};
| ^^ expected `str`, found `()`
@ -40,10 +22,10 @@ LL | return {};
error[E0527]: pattern requires 1 element but array has 2
--> $DIR/issue-105946.rs:6:9
|
LL | let [_y..] = [box 1, box 2];
LL | let [_y..] = [Box::new(1), Box::new(2)];
| ^^^^^^ expected 2 elements
error: aborting due to 6 previous errors
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0308, E0425, E0527, E0658.
For more information about an error, try `rustc --explain E0308`.

View File

@ -1,10 +0,0 @@
#![feature(box_syntax)]
// Box expression needs to be movable, and hence has to be of a Sized type.
fn main() {
let _x: Box<[u32]> = box { loop {} };
//~^ ERROR: the size for values of type `[u32]` cannot be known at compilation time
// Check that a deduced size does not cause issues.
let _y: Box<[u32]> = box [];
let _z: Box<[u32; 0]> = box { loop {} };
}

View File

@ -1,12 +0,0 @@
error[E0277]: the size for values of type `[u32]` cannot be known at compilation time
--> $DIR/issue-87935-unsized-box-expr.rs:4:30
|
LL | let _x: Box<[u32]> = box { loop {} };
| ^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u32]`
= note: the type of a box expression must have a statically known size
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

9
tests/ui/unpretty/box.rs Normal file
View File

@ -0,0 +1,9 @@
// compile-flags: -Zunpretty=hir
// check-pass
#![feature(stmt_expr_attributes, rustc_attrs)]
fn main() {
let _ = #[rustc_box]
Box::new(1);
}

View File

@ -0,0 +1,14 @@
// compile-flags: -Zunpretty=hir
// check-pass
#![feature(stmt_expr_attributes, rustc_attrs)]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
fn main() {
let _ =
#[rustc_box]
Box::new (1);
}