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] #![no_std]
extern crate alloc; extern crate alloc;
@ -29,7 +29,7 @@ fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
#[start] #[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize { 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 { unsafe {
puts(*world as *const str as *const u8); 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] #![no_core]
#![allow(dead_code, non_camel_case_types)] #![allow(dead_code, non_camel_case_types)]
@ -178,7 +178,7 @@ fn main() {
let ptr: *const i8 = hello as *const [u8] as *const i8; let ptr: *const i8 = hello as *const [u8] as *const i8;
puts(ptr); 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); puts(*world as *const str as *const i8);
world as Box<dyn SomeTrait>; world as Box<dyn SomeTrait>;
@ -238,10 +238,10 @@ fn main() {
} }
} }
let _ = box NoisyDrop { let _ = Box::new(NoisyDrop {
text: "Boxed outer got dropped!\0", text: "Boxed outer got dropped!\0",
inner: NoisyDropInner, inner: NoisyDropInner,
} as Box<dyn SomeTrait>; }) as Box<dyn SomeTrait>;
const FUNC_REF: Option<fn()> = Some(main); const FUNC_REF: Option<fn()> = Some(main);
match FUNC_REF { 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] #![no_std]
extern crate alloc; extern crate alloc;
@ -38,7 +38,7 @@ unsafe extern "C" fn _Unwind_Resume() {
#[start] #[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize { 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 { unsafe {
puts(*world as *const str as *const u8); 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 // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs
#![feature( #![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 extern_types, thread_local
)] )]
#![no_core] #![no_core]
@ -163,7 +163,7 @@ fn main() {
let ptr: *const u8 = hello as *const [u8] as *const u8; let ptr: *const u8 = hello as *const [u8] as *const u8;
puts(ptr); 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); puts(*world as *const str as *const u8);
world as Box<dyn SomeTrait>; world as Box<dyn SomeTrait>;
@ -223,10 +223,10 @@ fn main() {
} }
} }
let _ = box NoisyDrop { let _ = Box::new(NoisyDrop {
text: "Boxed outer got dropped!\0", text: "Boxed outer got dropped!\0",
inner: NoisyDropInner, inner: NoisyDropInner,
} as Box<dyn SomeTrait>; }) as Box<dyn SomeTrait>;
const FUNC_REF: Option<fn()> = Some(main); const FUNC_REF: Option<fn()> = Some(main);
#[allow(unreachable_code)] #[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] #![no_std]
#[link(name = "c")] #[link(name = "c")]

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
#![allow(rustc::potential_query_instability)] #![allow(rustc::potential_query_instability)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(drain_filter)] #![feature(drain_filter)]
#![feature(box_syntax)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(map_try_insert)] #![feature(map_try_insert)]
#![feature(min_specialization)] #![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: feature of Rust, you must use a flag, like this:
```rust ```rust
#![feature(box_syntax)] #![feature(generators, generator_trait)]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;
fn main() { 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 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 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)] #![feature(lint_reasons)]
#![allow( #![allow(
clippy::borrowed_box, clippy::borrowed_box,
@ -34,7 +33,7 @@ fn ok_box_trait(boxed_trait: &Box<dyn Z>) {
} }
fn warn_call() { fn warn_call() {
let x = box A; let x = Box::new(A);
x.foo(); x.foo();
} }
@ -43,41 +42,41 @@ fn warn_arg(x: Box<A>) {
} }
fn nowarn_closure_arg() { fn nowarn_closure_arg() {
let x = Some(box A); let x = Some(Box::new(A));
x.map_or((), |x| take_ref(&x)); x.map_or((), |x| take_ref(&x));
} }
fn warn_rename_call() { fn warn_rename_call() {
let x = box A; let x = Box::new(A);
let y = x; let y = x;
y.foo(); // via autoderef y.foo(); // via autoderef
} }
fn warn_notuse() { fn warn_notuse() {
let bz = box A; let bz = Box::new(A);
} }
fn warn_pass() { fn warn_pass() {
let bz = box A; let bz = Box::new(A);
take_ref(&bz); // via deref coercion take_ref(&bz); // via deref coercion
} }
fn nowarn_return() -> Box<A> { fn nowarn_return() -> Box<A> {
box A // moved out, "escapes" Box::new(A) // moved out, "escapes"
} }
fn nowarn_move() { fn nowarn_move() {
let bx = box A; let bx = Box::new(A);
drop(bx) // moved in, "escapes" drop(bx) // moved in, "escapes"
} }
fn nowarn_call() { fn nowarn_call() {
let bx = box A; let bx = Box::new(A);
bx.clone(); // method only available to Box, not via autoderef bx.clone(); // method only available to Box, not via autoderef
} }
fn nowarn_pass() { fn nowarn_pass() {
let bx = box A; let bx = Box::new(A);
take_box(&bx); // fn needs &Box take_box(&bx); // fn needs &Box
} }
@ -86,30 +85,20 @@ fn take_ref(x: &A) {}
fn nowarn_ref_take() { fn nowarn_ref_take() {
// false positive, should actually warn // false positive, should actually warn
let x = box A; let x = Box::new(A);
let y = &x; let y = &x;
take_box(y); take_box(y);
} }
fn nowarn_match() { fn nowarn_match() {
let x = box A; // moved into a match let x = Box::new(A); // moved into a match
match x { match x {
y => drop(y), y => drop(y),
} }
} }
fn warn_match() { fn warn_match() {
let x = box A; let x = Box::new(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];
match &x { match &x {
// not moved // not moved
y => (), y => (),

View File

@ -1,5 +1,5 @@
error: local variable doesn't need to be boxed here 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>) { 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` = note: `-D clippy::boxed-local` implied by `-D warnings`
error: local variable doesn't need to be boxed here 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<&()>>) -> () {} LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: local variable doesn't need to be boxed here 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 { LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
| ^ | ^
error: local variable doesn't need to be boxed here 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>) {} 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)] #![warn(clippy::no_effect_underscore_binding)]
#![allow(dead_code, path_statements)] #![allow(dead_code, path_statements)]
#![allow(clippy::deref_addrof, clippy::redundant_field_names, clippy::uninlined_format_args)] #![allow(clippy::deref_addrof, clippy::redundant_field_names, clippy::uninlined_format_args)]
@ -102,7 +102,6 @@ fn main() {
*&42; *&42;
&6; &6;
(5, 6, 7); (5, 6, 7);
box 42;
..; ..;
5..; 5..;
..5; ..5;

View File

@ -81,83 +81,77 @@ LL | (5, 6, 7);
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:105:5 --> $DIR/no_effect.rs:105:5
| |
LL | box 42;
| ^^^^^^^
error: statement with no effect
--> $DIR/no_effect.rs:106:5
|
LL | ..; LL | ..;
| ^^^ | ^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:107:5 --> $DIR/no_effect.rs:106:5
| |
LL | 5..; LL | 5..;
| ^^^^ | ^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:108:5 --> $DIR/no_effect.rs:107:5
| |
LL | ..5; LL | ..5;
| ^^^^ | ^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:109:5 --> $DIR/no_effect.rs:108:5
| |
LL | 5..6; LL | 5..6;
| ^^^^^ | ^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:110:5 --> $DIR/no_effect.rs:109:5
| |
LL | 5..=6; LL | 5..=6;
| ^^^^^^ | ^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:111:5 --> $DIR/no_effect.rs:110:5
| |
LL | [42, 55]; LL | [42, 55];
| ^^^^^^^^^ | ^^^^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:112:5 --> $DIR/no_effect.rs:111:5
| |
LL | [42, 55][1]; LL | [42, 55][1];
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:113:5 --> $DIR/no_effect.rs:112:5
| |
LL | (42, 55).1; LL | (42, 55).1;
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:114:5 --> $DIR/no_effect.rs:113:5
| |
LL | [42; 55]; LL | [42; 55];
| ^^^^^^^^^ | ^^^^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:115:5 --> $DIR/no_effect.rs:114:5
| |
LL | [42; 55][13]; LL | [42; 55][13];
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:117:5 --> $DIR/no_effect.rs:116:5
| |
LL | || x += 5; LL | || x += 5;
| ^^^^^^^^^^ | ^^^^^^^^^^
error: statement with no effect error: statement with no effect
--> $DIR/no_effect.rs:119:5 --> $DIR/no_effect.rs:118:5
| |
LL | FooString { s: s }; LL | FooString { s: s };
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect 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; LL | let _unused = 1;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
@ -165,22 +159,22 @@ LL | let _unused = 1;
= note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings` = note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings`
error: binding to `_` prefixed variable with no side-effect 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"); LL | let _penguin = || println!("Some helpful closure");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect 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 }; LL | let _duck = Struct { field: 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect 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]; 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 // run-rustfix
#![feature(box_syntax)]
#![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)] #![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)]
#![warn(clippy::unnecessary_operation)] #![warn(clippy::unnecessary_operation)]
@ -59,7 +58,6 @@ fn main() {
5;6;get_number(); 5;6;get_number();
get_number(); get_number();
get_number(); get_number();
get_number();
5;get_number(); 5;get_number();
42;get_number(); 42;get_number();
assert!([42, 55].len() > get_usize()); assert!([42, 55].len() > get_usize());

View File

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

View File

@ -1,5 +1,5 @@
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:51:5 --> $DIR/unnecessary_operation.rs:50:5
| |
LL | Tuple(get_number()); LL | Tuple(get_number());
| ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `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` = note: `-D clippy::unnecessary-operation` implied by `-D warnings`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:52:5 --> $DIR/unnecessary_operation.rs:51:5
| |
LL | Struct { field: get_number() }; LL | Struct { field: get_number() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:53:5 --> $DIR/unnecessary_operation.rs:52:5
| |
LL | Struct { ..get_struct() }; LL | Struct { ..get_struct() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:54:5 --> $DIR/unnecessary_operation.rs:53:5
| |
LL | Enum::Tuple(get_number()); LL | Enum::Tuple(get_number());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:55:5 --> $DIR/unnecessary_operation.rs:54:5
| |
LL | Enum::Struct { field: get_number() }; LL | Enum::Struct { field: get_number() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:56:5 --> $DIR/unnecessary_operation.rs:55:5
| |
LL | 5 + get_number(); LL | 5 + get_number();
| ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` | ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:57:5 --> $DIR/unnecessary_operation.rs:56:5
| |
LL | *&get_number(); LL | *&get_number();
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:58:5 --> $DIR/unnecessary_operation.rs:57:5
| |
LL | &get_number(); LL | &get_number();
| ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:59:5 --> $DIR/unnecessary_operation.rs:58:5
| |
LL | (5, 6, get_number()); LL | (5, 6, get_number());
| ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();` | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:60:5 --> $DIR/unnecessary_operation.rs:59:5
|
LL | box get_number();
| ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation
--> $DIR/unnecessary_operation.rs:61:5
| |
LL | get_number()..; LL | get_number()..;
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:62:5 --> $DIR/unnecessary_operation.rs:60:5
| |
LL | ..get_number(); LL | ..get_number();
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:63:5 --> $DIR/unnecessary_operation.rs:61:5
| |
LL | 5..get_number(); LL | 5..get_number();
| ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:64:5 --> $DIR/unnecessary_operation.rs:62:5
| |
LL | [42, get_number()]; LL | [42, get_number()];
| ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:65:5 --> $DIR/unnecessary_operation.rs:63:5
| |
LL | [42, 55][get_usize()]; LL | [42, 55][get_usize()];
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());` | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:66:5 --> $DIR/unnecessary_operation.rs:64:5
| |
LL | (42, get_number()).1; LL | (42, get_number()).1;
| ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:67:5 --> $DIR/unnecessary_operation.rs:65:5
| |
LL | [get_number(); 55]; LL | [get_number(); 55];
| ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:68:5 --> $DIR/unnecessary_operation.rs:66:5
| |
LL | [42; 55][get_usize()]; LL | [42; 55][get_usize()];
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());` | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:69:5 --> $DIR/unnecessary_operation.rs:67:5
| |
LL | / { LL | / {
LL | | get_number() LL | | get_number()
@ -117,12 +111,12 @@ LL | | };
| |______^ help: statement can be reduced to: `get_number();` | |______^ help: statement can be reduced to: `get_number();`
error: unnecessary operation error: unnecessary operation
--> $DIR/unnecessary_operation.rs:72:5 --> $DIR/unnecessary_operation.rs:70:5
| |
LL | / FooString { LL | / FooString {
LL | | s: String::from("blah"), LL | | s: String::from("blah"),
LL | | }; LL | | };
| |______^ help: statement can be reduced to: `String::from("blah");` | |______^ 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 // Validation makes this fail in the wrong place
//@compile-flags: -Zmiri-disable-validation //@compile-flags: -Zmiri-disable-validation
#![feature(box_syntax)]
fn main() { fn main() {
let x = box 42; let x = Box::new(42);
unsafe { unsafe {
let f = std::mem::transmute::<Box<i32>, fn()>(x); let f = std::mem::transmute::<Box<i32>, fn()>(x);
f() //~ ERROR: function pointer but it does not point to a function f() //~ ERROR: function pointer but it does not point to a function

View File

@ -1,7 +1,5 @@
#![feature(box_syntax)]
fn main() { fn main() {
// With the nested Vec, this is calling Offset(Unique::empty(), 0) on drop. // With the nested Vec, this is calling Offset(Unique::empty(), 0) on drop.
let args: Vec<Vec<i32>> = Vec::new(); 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> { struct Fat<T: ?Sized> {
f1: isize, f1: isize,
f2: &'static str, f2: &'static str,
@ -109,7 +107,7 @@ pub fn main() {
assert_eq!((*f2)[1], 2); assert_eq!((*f2)[1], 2);
// Nested Box. // 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); foo(&*f1);
let f2: Box<Fat<[isize]>> = f1; let f2: Box<Fat<[isize]>> = f1;
foo(&*f2); foo(&*f2);
@ -117,6 +115,6 @@ pub fn main() {
let f3: Box<Fat<[isize]>> = let f3: Box<Fat<[isize]>> =
Box::<Fat<[_; 3]>>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }); Box::<Fat<[_; 3]>>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
foo(&*f3); 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); foo(&*f4);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -1,15 +1,13 @@
#![feature(box_syntax)]
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
pub fn main() { pub fn main() {
let (tx, rx) = channel::<Box<_>>(); let (tx, rx) = channel::<Box<_>>();
tx.send(box 100).unwrap(); tx.send(Box::new(100)).unwrap();
let v = rx.recv().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::new(101)).unwrap();
tx.send(box 102).unwrap(); tx.send(Box::new(102)).unwrap();
assert_eq!(rx.recv().unwrap(), box 101); assert_eq!(rx.recv().unwrap(), Box::new(101));
assert_eq!(rx.recv().unwrap(), box 102); 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 // doing region-folding, when really all clients of the region-folding
// case only want to see *free* lifetime variables, not bound ones. // case only want to see *free* lifetime variables, not bound ones.
#![feature(box_syntax)]
pub fn main() { pub fn main() {
fn explicit() { fn explicit() {
fn test<F>(_x: Option<Box<F>>) fn test<F>(_x: Option<Box<F>>)
@ -21,7 +19,7 @@ pub fn main() {
F: FnMut(Box<dyn for<'a> FnMut(&'a isize)>), 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 // 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)>), F: FnMut(Box<dyn FnMut(&isize)>),
{ {
} }
test(Some(box |_f: Box<dyn FnMut(&isize)>| {})); test(Some(Box::new(|_f: Box<dyn FnMut(&isize)>| {})));
} }
explicit(); explicit();

View File

@ -857,9 +857,9 @@ mod lint {
#[test] #[test]
fn lint_feature() { fn lint_feature() {
check_edit( check_edit(
"box_syntax", "box_patterns",
r#"#[feature(box_$0)] struct Test;"#, 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 // Test expressions
fn foo() -> bool { fn foo() -> bool {
let boxed: Box<i32> = box 5;
let referenced = &5 ; let referenced = &5 ;
let very_long_variable_name = ( a + first + simple + test ); 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) { fn issue184(source: &str) {
for c in source.chars() { for c in source.chars() {
if index < 'a' { if index < 'a' {
@ -413,10 +406,6 @@ fn issue2704() {
.concat(&requires1) .concat(&requires1)
.concat(&requires2) .concat(&requires2)
.distinct_total()); .distinct_total());
let requires = requires.set(box requires0
.concat(&requires1)
.concat(&requires2)
.distinct_total());
let requires = requires.set(requires0 let requires = requires.set(requires0
.concat(&requires1) .concat(&requires1)
.concat(&requires2) .concat(&requires2)

View File

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

View File

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

View File

@ -3,7 +3,6 @@
// Test expressions // Test expressions
fn foo() -> bool { fn foo() -> bool {
let boxed: Box<i32> = box 5;
let referenced = &5; let referenced = &5;
let very_long_variable_name = (a + first + simple + test); 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) { fn issue184(source: &str) {
for c in source.chars() { for c in source.chars() {
if index < 'a' { if index < 'a' {
@ -454,12 +446,6 @@ fn issue2704() {
.concat(&requires2) .concat(&requires2)
.distinct_total(), .distinct_total(),
); );
let requires = requires.set(
box requires0
.concat(&requires1)
.concat(&requires2)
.distinct_total(),
);
let requires = requires.set( let requires = requires.set(
requires0 requires0
.concat(&requires1) .concat(&requires1)

View File

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

View File

@ -3,21 +3,21 @@
fn move_out_by_subslice() -> () { 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 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 _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 _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:+1:14: +1:19 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:+1:14: +1:19 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:+1:14: +1:19 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:+1:14: +1:19 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:+1:21: +1:26 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:+1:21: +1:26 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:+1:21: +1:26 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:+1:21: +1:26 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:+1:21: +1:26 let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
scope 1 { scope 1 {
debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 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 { 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 { scope 2 {
@ -27,86 +27,86 @@ fn move_out_by_subslice() -> () {
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 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 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:+1:14: +1:19 _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:+1:14: +1:19 _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:+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:+3:9: +3:20
// mir::Constant // 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>) } // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +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:+1:14: +1:19 _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:+1:18: +1:19 (*_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:+1:14: +1: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:+1:18: +1:19 drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20
} }
bb2: { bb2: {
StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 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:+1:21: +1:26 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:+1:21: +1:26 _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:+1:21: +1:26 _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:+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:+5:9: +5:20
// mir::Constant // 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>) } // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
} }
bb3: { bb3: {
StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +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:+1:21: +1:26 _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:+1:25: +1:26 (*_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:+1:21: +1:26 _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:+1:25: +1:26 drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20
} }
bb4: { bb4: {
StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 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: +1:27 _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:+1:26: +1:27 drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
} }
bb5: { bb5: {
StorageDead(_7); // 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:+1:26: +1:27 drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
} }
bb6: { 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 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 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:+2:10: +2:12 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:+2:10: +2: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: +3:2 _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:+3:1: +3:2 drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
} }
bb7: { bb7: {
StorageDead(_12); // scope 1 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:+3:1: +3:2 drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
} }
bb8: { bb8: {
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +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:+3:2: +3:2 return; // scope 0 at $DIR/uniform_array_move_out.rs:+8:2: +8:2
} }
bb9 (cleanup): { 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): { 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): { 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): { 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() -> () { 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 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 _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 _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:+1:14: +1:19 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:+1:14: +1:19 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:+1:14: +1:19 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:+1:14: +1:19 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:+1:21: +1:26 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:+1:21: +1:26 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:+1:21: +1:26 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:+1:21: +1:26 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:+1:21: +1:26 let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20
scope 1 { scope 1 {
debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 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 { 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 { scope 2 {
@ -27,86 +27,86 @@ fn move_out_from_end() -> () {
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 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 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:+1:14: +1:19 _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:+1:14: +1:19 _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:+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:+3:9: +3:20
// mir::Constant // 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>) } // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +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:+1:14: +1:19 _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:+1:18: +1:19 (*_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:+1:14: +1: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:+1:18: +1:19 drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20
} }
bb2: { bb2: {
StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 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:+1:21: +1:26 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:+1:21: +1:26 _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:+1:21: +1:26 _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:+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:+5:9: +5:20
// mir::Constant // 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>) } // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
} }
bb3: { bb3: {
StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +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:+1:21: +1:26 _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:+1:25: +1:26 (*_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:+1:21: +1:26 _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:+1:25: +1:26 drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20
} }
bb4: { bb4: {
StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 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: +1:27 _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:+1:26: +1:27 drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
} }
bb5: { bb5: {
StorageDead(_7); // 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:+1:26: +1:27 drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6
} }
bb6: { 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 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 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:+2:14: +2:16 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:+2:14: +2: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: +3:2 _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:+3:1: +3:2 drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
} }
bb7: { bb7: {
StorageDead(_12); // scope 1 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:+3:1: +3:2 drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2
} }
bb8: { bb8: {
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +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:+3:2: +3:2 return; // scope 0 at $DIR/uniform_array_move_out.rs:+8:2: +8:2
} }
bb9 (cleanup): { 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): { 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): { 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): { 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 // EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir
fn move_out_from_end() { 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; let [.., _y] = a;
} }
// EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir // EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir
fn move_out_by_subslice() { 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; let [_y @ ..] = a;
} }

View File

@ -4,14 +4,14 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:+0:11: +0:11 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 _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 _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: +1:22 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: +1:22 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: +1:22 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: +1:22 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: +1:22 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: +1:22 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: +1:22 let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18
scope 1 { scope 1 {
debug x => _1; // in scope 1 at $DIR/boxes.rs:+1:9: +1:10 debug x => _1; // in scope 1 at $DIR/boxes.rs:+1:9: +1:10
} }
@ -20,41 +20,41 @@
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/boxes.rs:+1:9: +1:10 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(_2); // scope 0 at $DIR/boxes.rs:+1:13: +2:18
StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +2:18
- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22 - _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18
- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22 - _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: +1:22 + _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: +1:22 + _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: +1:22 _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +2:18
// mir::Constant // 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>) } // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageLive(_7); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 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: +1:22 _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:+1:19: +1:21 _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:+1:19: +1:21 (*_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: +1:22 _3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +2:18
StorageDead(_7); // scope 0 at $DIR/boxes.rs:+1:21: +1:22 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: +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: +2:18
_2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 _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: +1:26 _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:+1:25: +1:26 StorageDead(_2); // scope 0 at $DIR/boxes.rs:+3:11: +3:12
drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+1:26: +1:27 drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+3:12: +3:13
} }
bb2: { bb2: {
StorageDead(_3); // scope 0 at $DIR/boxes.rs:+1:26: +1:27 StorageDead(_3); // scope 0 at $DIR/boxes.rs:+3:12: +3:13
_0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +2:2 _0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +4:2
StorageDead(_1); // scope 0 at $DIR/boxes.rs:+2:1: +2:2 StorageDead(_1); // scope 0 at $DIR/boxes.rs:+4:1: +4:2
return; // scope 0 at $DIR/boxes.rs:+2:2: +2:2 return; // scope 0 at $DIR/boxes.rs:+4:2: +4:2
} }
bb3 (cleanup): { 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-wasm32
// ignore-wasm64 // 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 // EMIT_MIR boxes.main.ConstProp.diff
fn main() { fn main() {
let x = *(box 42) + 0; let x = *(#[rustc_box]
Box::new(42))
+ 0;
} }

View File

@ -3,58 +3,42 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/derefer_inline_test.rs:+0:11: +0:11 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 _1: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18
let mut _2: usize; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 let mut _2: std::boxed::Box<u32>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17
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 {
}
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18
_2 = SizeOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12 StorageLive(_2); // scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17
_3 = AlignOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12 _2 = f() -> bb1; // scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12
// mir::Constant // mir::Constant
// + span: $DIR/derefer_inline_test.rs:11:5: 11:12 // + span: $DIR/derefer_inline_test.rs:10:14: 10:15
// + 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
// + literal: Const { ty: fn() -> Box<u32> {f}, val: Value(<ZST>) } // + 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: { bb2: {
_1 = move _5; // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 StorageDead(_2); // scope 0 at $DIR/derefer_inline_test.rs:+1:17: +1:18
drop(_5) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12 drop(_1) -> bb3; // scope 0 at $DIR/derefer_inline_test.rs:+1:18: +1:19
} }
bb3: { bb3: {
StorageDead(_5); // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12 StorageDead(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:18: +1:19
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
_0 = const (); // scope 0 at $DIR/derefer_inline_test.rs:+0:11: +2:2 _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 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): { 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 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 // EMIT_MIR derefer_inline_test.main.Derefer.diff
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
#![feature(box_syntax)]
#[inline] #[inline]
fn f() -> Box<u32> { fn f() -> Box<u32> {
box 0 Box::new(0)
} }
fn main() { fn main() {
box f(); Box::new(f());
} }

View File

@ -4,81 +4,78 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline_into_box_place.rs:+0:11: +0:11 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 _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 _2: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48
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
scope 1 { scope 1 {
debug _x => _1; // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11 debug _x => _1; // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11
} }
scope 2 { + 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 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 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: { bb0: {
StorageLive(_1); // scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 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 StorageLive(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48
_3 = AlignOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _2 = Vec::<u32>::new() -> bb1; // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + 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 // mir::Constant
// + span: $DIR/inline_into_box_place.rs:8:29: 8:43 - // + span: $DIR/inline_into_box_place.rs:7:38: 7:46
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } - // + user_ty: UserType(2)
}
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)
- // + literal: Const { ty: fn() -> Vec<u32> {Vec::<u32>::new}, val: Value(<ZST>) } - // + literal: Const { ty: fn() -> Vec<u32> {Vec::<u32>::new}, val: Value(<ZST>) }
- }
-
- bb2: {
+ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ // + user_ty: UserType(0) + // + user_ty: UserType(0)
+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Unevaluated(alloc::raw_vec::RawVec::<T>::NEW, [u32], None) } + // + 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 + _2 = Vec::<u32> { buf: move _3, len: const 0_usize }; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + StorageDead(_3); // scope 2 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 + _4 = SizeOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ StorageDead(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + _5 = AlignOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ StorageDead(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb3, unwind: bb4]; // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
_1 = move _5; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + // mir::Constant
StorageDead(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 + // + span: $SRC_DIR/alloc/src/boxed.rs:LL:COL
_0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 + // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
- 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
} }
- bb3: { bb1: {
+ bb2: { - _1 = Box::<Vec<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:49
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
- // mir::Constant - // mir::Constant
- // + span: $DIR/inline_into_box_place.rs:8:42: 8:43 - // + span: $DIR/inline_into_box_place.rs:7:29: 7:37
- // + literal: Const { ty: unsafe fn(Unique<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}, val: Value(<ZST>) } - // + 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 // ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -Z mir-opt-level=4 // compile-flags: -Z mir-opt-level=4
#![feature(box_syntax)]
// EMIT_MIR inline_into_box_place.main.Inline.diff // EMIT_MIR inline_into_box_place.main.Inline.diff
fn main() { 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 // initializing it
// ignore-wasm32-bare compiled with panic=abort by default // ignore-wasm32-bare compiled with panic=abort by default
#![feature(box_syntax)] #![feature(rustc_attrs)]
// EMIT_MIR issue_62289.test.ElaborateDrops.before.mir // EMIT_MIR issue_62289.test.ElaborateDrops.before.mir
fn test() -> Option<Box<u32>> { fn test() -> Option<Box<u32>> {
Some(box (None?)) Some(
#[rustc_box]
Box::new(None?),
)
} }
fn main() { fn main() {

View File

@ -2,121 +2,121 @@
fn test() -> Option<Box<u32>> { 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 _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 _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:+1:10: +1:21 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:+1:10: +1:21 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:+1:10: +1:21 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:+1:10: +1:21 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:+1:15: +1:20 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:+1:15: +1:19 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:+1:19: +1:20 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:+1:19: +1:20 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:+1:19: +1:20 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:+1:19: +1:20 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:+1:15: +1:20 let _12: u32; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
scope 1 { scope 1 {
} }
scope 2 { 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 3 {
} }
} }
scope 4 { 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 { scope 5 {
} }
} }
bb0: { bb0: {
StorageLive(_1); // scope 0 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:+1:10: +1:21 _2 = SizeOf(u32); // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24
_3 = AlignOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 _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:+1:10: +1:21 _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24
// mir::Constant // 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>) } // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageLive(_5); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 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:+1:10: +1:21 _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:+1:15: +1:20 StorageLive(_6); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:22
_7 = Option::<u32>::None; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 _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:+1:15: +1:20 _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 // 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>) } // + 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: { bb2: {
StorageDead(_7); // scope 0 at $DIR/issue_62289.rs:+1:19: +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:+1:15: +1:20 _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:+1:15: +1:20 switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23
} }
bb3: { bb3: {
StorageLive(_12); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 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:+1:15: +1:20 _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:+1:15: +1:20 (*_5) = _12; // scope 5 at $DIR/issue_62289.rs:+3:18: +3:23
StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
_1 = move _5; // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 _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:+1:20: +1:21 drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
} }
bb4: { 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: { bb5: {
StorageLive(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +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:+1:19: +1:20 _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:+1:19: +1:20 StorageLive(_11); // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23
_11 = _9; // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 _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:+1:15: +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:+3:18: +3:23
// mir::Constant // 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>) } // + literal: Const { ty: fn(Option<Infallible>) -> Option<Box<u32>> {<Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual}, val: Value(<ZST>) }
} }
bb6: { bb6: {
StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23
StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23
drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
} }
bb7: { bb7: {
StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 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: +1:22 _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:+1:21: +1:22 drop(_1) -> bb8; // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
} }
bb8: { bb8: {
StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2 StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+5:1: +5:2
goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2
} }
bb9: { bb9: {
StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24
StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6
StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2 StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+5:1: +5:2
goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2
} }
bb10: { 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): { 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): { 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): { 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)] #[cfg(FALSE)]
fn syntax() { fn syntax() {
let _ = #[attr] box 0;
let _ = #[attr] []; let _ = #[attr] [];
let _ = #[attr] [0]; let _ = #[attr] [0];
let _ = #[attr] [0; 0]; let _ = #[attr] [0; 0];

View File

@ -1,6 +1,5 @@
// pp-exact // pp-exact
#![feature(box_syntax)]
#![feature(inline_const)] #![feature(inline_const)]
#![feature(inline_const_pat)] #![feature(inline_const_pat)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
@ -140,7 +139,6 @@ fn _10() {
} }
fn _11() { fn _11() {
let _ = #[rustc_dummy] box 0;
let _: [(); 0] = #[rustc_dummy] []; let _: [(); 0] = #[rustc_dummy] [];
let _ = #[rustc_dummy] [0, 0]; let _ = #[rustc_dummy] [0, 0];
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)); let mut g = |e| f(expr(e));
for kind in 0..=19 { for kind in 0..=18 {
match kind { match kind {
0 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Box(e))), 0 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Call(e, thin_vec![]))),
1 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Call(e, thin_vec![]))), 1 => {
2 => {
let seg = PathSegment::from_ident(Ident::from_str("x")); let seg = PathSegment::from_ident(Ident::from_str("x"));
iter_exprs(depth - 1, &mut |e| { iter_exprs(depth - 1, &mut |e| {
g(ExprKind::MethodCall(Box::new(MethodCall { 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 { let op = Spanned {
span: DUMMY_SP, span: DUMMY_SP,
node: match kind { node: match kind {
3 => BinOpKind::Add, 2 => BinOpKind::Add,
4 => BinOpKind::Mul, 3 => BinOpKind::Mul,
5 => BinOpKind::Shl, 4 => BinOpKind::Shl,
6 => BinOpKind::And, 5 => BinOpKind::And,
7 => BinOpKind::Or, 6 => BinOpKind::Or,
8 => BinOpKind::Lt, 7 => BinOpKind::Lt,
_ => unreachable!(), _ => unreachable!(),
}, },
}; };
iter_exprs(depth - 1, &mut |e| g(ExprKind::Binary(op, e, make_x()))); 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))); 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))); iter_exprs(depth - 1, &mut |e| g(ExprKind::Unary(UnOp::Deref, e)));
} }
10 => { 9 => {
let block = P(Block { let block = P(Block {
stmts: ThinVec::new(), stmts: ThinVec::new(),
id: DUMMY_NODE_ID, 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))); 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) }); let decl = P(FnDecl { inputs: thin_vec![], output: FnRetTy::Default(DUMMY_SP) });
iter_exprs(depth - 1, &mut |e| { iter_exprs(depth - 1, &mut |e| {
g(ExprKind::Closure(Box::new(Closure { 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(e, make_x(), DUMMY_SP)));
iter_exprs(depth - 1, &mut |e| g(ExprKind::Assign(make_x(), e, 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")))); iter_exprs(depth - 1, &mut |e| g(ExprKind::Field(e, Ident::from_str("f"))));
} }
14 => { 13 => {
iter_exprs(depth - 1, &mut |e| { iter_exprs(depth - 1, &mut |e| {
g(ExprKind::Range(Some(e), Some(make_x()), RangeLimits::HalfOpen)) 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)) g(ExprKind::Range(Some(make_x()), Some(e), RangeLimits::HalfOpen))
}); });
} }
15 => { 14 => {
iter_exprs(depth - 1, &mut |e| { iter_exprs(depth - 1, &mut |e| {
g(ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, e)) g(ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, e))
}); });
} }
16 => { 15 => {
g(ExprKind::Ret(None)); g(ExprKind::Ret(None));
iter_exprs(depth - 1, &mut |e| g(ExprKind::Ret(Some(e)))); iter_exprs(depth - 1, &mut |e| g(ExprKind::Ret(Some(e))));
} }
17 => { 16 => {
let path = Path::from_ident(Ident::from_str("S")); let path = Path::from_ident(Ident::from_str("S"));
g(ExprKind::Struct(P(StructExpr { g(ExprKind::Struct(P(StructExpr {
qself: None, qself: None,
@ -169,10 +168,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
rest: StructRest::Base(make_x()), rest: StructRest::Base(make_x()),
}))); })));
} }
18 => { 17 => {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Try(e))); iter_exprs(depth - 1, &mut |e| g(ExprKind::Try(e)));
} }
19 => { 18 => {
let pat = let pat =
P(Pat { id: DUMMY_NODE_ID, kind: PatKind::Wild, span: DUMMY_SP, tokens: None }); 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))) 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. // Verifies all possible restrictions for statics values.
#![allow(warnings)] #![allow(warnings)]
#![feature(box_syntax)]
use std::marker; use std::marker;
@ -19,7 +18,7 @@ enum SafeEnum {
Variant1, Variant1,
Variant2(isize), Variant2(isize),
Variant3(WithDtor), Variant3(WithDtor),
Variant4(String) Variant4(String),
} }
// These should be ok // These should be ok
@ -29,42 +28,45 @@ static STATIC3: SafeEnum = SafeEnum::Variant3(WithDtor);
enum UnsafeEnum { enum UnsafeEnum {
Variant5, Variant5,
Variant6(isize) Variant6(isize),
} }
impl Drop for UnsafeEnum { impl Drop for UnsafeEnum {
fn drop(&mut self) {} fn drop(&mut self) {}
} }
static STATIC4: UnsafeEnum = UnsafeEnum::Variant5; static STATIC4: UnsafeEnum = UnsafeEnum::Variant5;
static STATIC5: UnsafeEnum = UnsafeEnum::Variant6(0); static STATIC5: UnsafeEnum = UnsafeEnum::Variant6(0);
struct SafeStruct { struct SafeStruct {
field1: SafeEnum, field1: SafeEnum,
field2: SafeEnum, field2: SafeEnum,
} }
// Struct fields are safe, hence this static should be safe // 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, static STATIC7: SafeStruct =
field2: SafeEnum::Variant3(WithDtor)}; SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant3(WithDtor) };
// Test variadic constructor for structs. The base struct should be examined // Test variadic constructor for structs. The base struct should be examined
// as well as every field present in the constructor. // as well as every field present in the constructor.
// This example shouldn't fail because all the fields are safe. // This example shouldn't fail because all the fields are safe.
static STATIC8: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, static STATIC8: SafeStruct = SafeStruct {
..SafeStruct{field1: SafeEnum::Variant1, field1: SafeEnum::Variant1,
field2: SafeEnum::Variant1}}; ..SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant1 }
};
// This example should fail because field1 in the base struct is not safe // This example should fail because field1 in the base struct is not safe
static STATIC9: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, static STATIC9: SafeStruct = SafeStruct {
..SafeStruct{field1: SafeEnum::Variant3(WithDtor), field1: SafeEnum::Variant1,
//~^ ERROR destructor of ..SafeStruct {
field2: SafeEnum::Variant1}}; //~^ ERROR destructor of
field1: SafeEnum::Variant3(WithDtor),
field2: SafeEnum::Variant1,
}
};
struct UnsafeStruct; struct UnsafeStruct;
@ -76,38 +78,45 @@ static STATIC10: UnsafeStruct = UnsafeStruct;
struct MyOwned; struct MyOwned;
static STATIC11: Box<MyOwned> = box MyOwned; static STATIC11: Vec<MyOwned> = vec![MyOwned];
//~^ ERROR allocations are not allowed in statics //~^ ERROR allocations are not allowed in statics
//~^^ ERROR cannot call non-const
static mut STATIC12: UnsafeStruct = UnsafeStruct; static mut STATIC12: UnsafeStruct = UnsafeStruct;
static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, static mut STATIC13: SafeStruct =
field2: SafeEnum::Variant3(WithDtor)}; SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant3(WithDtor) };
static mut STATIC14: SafeStruct = SafeStruct { static mut STATIC14: SafeStruct = SafeStruct {
field1: SafeEnum::Variant1, field1: SafeEnum::Variant1,
field2: SafeEnum::Variant4("str".to_string()) field2: SafeEnum::Variant4("str".to_string()), //~ ERROR cannot call non-const fn
//~^ ERROR cannot call non-const fn
}; };
static STATIC15: &'static [Box<MyOwned>] = &[ static STATIC15: &'static [Vec<MyOwned>] = &[
box MyOwned, //~ ERROR allocations are not allowed in statics vec![MyOwned], //~ ERROR allocations are not allowed in statics
box 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>) = ( static STATIC16: (&'static Vec<MyOwned>, &'static Vec<MyOwned>) = (
&box MyOwned, //~ ERROR allocations are not allowed in statics &vec![MyOwned], //~ ERROR allocations are not allowed in statics
&box 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 mut STATIC17: SafeEnum = SafeEnum::Variant1;
static STATIC19: Box<isize> = static STATIC19: Vec<isize> = vec![3];
box 3;
//~^ ERROR allocations are not allowed in statics //~^ ERROR allocations are not allowed in statics
//~^^ ERROR cannot call non-const
pub fn main() { pub fn main() {
let y = { static x: Box<isize> = box 3; x }; let y = {
//~^ ERROR allocations are not allowed in statics static x: Vec<isize> = vec![3]; //~ ERROR allocations are not allowed in statics
//~| ERROR cannot move out of static item //~^ 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 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 | |
LL | | field2: SafeEnum::Variant1}}; LL | | field1: SafeEnum::Variant3(WithDtor),
| | ^- value is dropped here LL | | field2: SafeEnum::Variant1,
| |________________________________________________________________________________| LL | | }
| the destructor for this type cannot be evaluated in statics | |_____^ the destructor for this type cannot be evaluated in statics
LL | };
| - value is dropped here
error[E0010]: allocations are not allowed in statics 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; LL | static STATIC11: Vec<MyOwned> = vec![MyOwned];
| ^^^^^^^^^^^ allocation not allowed in statics | ^^^^^^^^^^^^^ 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 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 = 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 = 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 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, LL | vec![MyOwned],
| ^^^^^^^^^^^ allocation not allowed in statics | ^^^^^^^^^^^^^ 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 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, LL | vec![MyOwned],
| ^^^^^^^^^^^ allocation not allowed in statics | ^^^^^^^^^^^^^ 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 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, LL | &vec![MyOwned],
| ^^^^^^^^^^^ allocation not allowed in statics | ^^^^^^^^^^^^^ 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 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, LL | &vec![MyOwned],
| ^^^^^^^^^^^ allocation not allowed in statics | ^^^^^^^^^^^^^ 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 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; LL | static STATIC19: Vec<isize> = vec![3];
| ^^^^^ allocation not allowed in statics | ^^^^^^^ 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` 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 }; LL | x
| ^ move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait | ^ move occurs because `x` has type `Vec<isize>`, which does not implement the `Copy` trait
| |
help: consider borrowing here help: consider borrowing here
| |
LL | let y = { static x: Box<isize> = box 3; &x }; LL | &x
| + | +
error[E0010]: allocations are not allowed in statics 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 }; LL | static x: Vec<isize> = vec![3];
| ^^^^^ allocation not allowed in statics | ^^^^^^^ 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. Some errors have detailed explanations: E0010, E0015, E0493, E0507.
For more information about an error, try `rustc --explain E0010`. 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. // A version of coerce-expect-unsized that uses type ascription.
// Doesn't work so far, but supposed to work eventually // Doesn't work so far, but supposed to work eventually
#![feature(box_syntax, type_ascription)] #![feature(type_ascription)]
use std::fmt::Debug; use std::fmt::Debug;
pub fn main() { pub fn main() {
let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); //~ ERROR mismatched types let _ = type_ascribe!(Box::new({ [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::new( 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( match true { true => [1, 2, 3], false => [1, 3, 4] }), Box<[i32]>);
//~^ ERROR mismatched types //~^ ERROR mismatched types
let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types let _ = type_ascribe!(Box::new( { |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::new( 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( 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!(&{ [1, 2, 3] }, &[i32]); //~ ERROR mismatched types
let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[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![ let _ = type_ascribe!(vec![
Box::new(|x| (x as u8)), 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) -> _>>); ], Vec<Box<dyn Fn(i32) -> _>>);
} }

View File

@ -1,8 +1,8 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:9:27 --> $DIR/coerce-expect-unsized-ascribed.rs:9:27
| |
LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); LL | let _ = type_ascribe!(Box::new({ [1, 2, 3] }), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
| |
= note: expected struct `Box<[i32]>` = note: expected struct `Box<[i32]>`
found struct `Box<[i32; 3]>` found struct `Box<[i32; 3]>`
@ -10,50 +10,50 @@ LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>);
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:10:27 --> $DIR/coerce-expect-unsized-ascribed.rs:10:27
| |
LL | let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>); LL | let _ = type_ascribe!(Box::new( if true { [1, 2, 3] } else { [1, 3, 4] }), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
| |
= note: expected struct `Box<[i32]>` = note: expected struct `Box<[i32]>`
found struct `Box<[i32; 3]>` found struct `Box<[i32; 3]>`
error[E0308]: mismatched types 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]>); LL | Box::new( match true { true => [1, 2, 3], false => [1, 3, 4] }), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>`
| |
= note: expected struct `Box<[i32]>` = note: expected struct `Box<[i32]>`
found struct `Box<[i32; 3]>` 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 error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:14:27 --> $DIR/coerce-expect-unsized-ascribed.rs:14:27
| |
LL | let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>); LL | let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box<dyn Fn(i32) -> _>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<bool>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>` = note: expected struct `Box<dyn Debug>`
found struct `Box<bool>` found struct `Box<bool>`
error[E0308]: mismatched types 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>); LL | let _ = type_ascribe!(Box::new( match true { true => 'a', false => 'b' }), Box<dyn Debug>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<char>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<char>`
| |
= note: expected struct `Box<dyn Debug>` = note: expected struct `Box<dyn Debug>`
found struct `Box<char>` found struct `Box<char>`
error[E0308]: mismatched types 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]); LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]);
| ^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]` | ^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]`
@ -62,7 +62,7 @@ LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]);
found reference `&[i32; 3]` found reference `&[i32; 3]`
error[E0308]: mismatched types 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]); LL | let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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]` found reference `&[i32; 3]`
error[E0308]: mismatched types 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]); LL | let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3, 4] }, &[i32]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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]` found reference `&[i32; 3]`
error[E0308]: mismatched types 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) -> _); 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` = 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 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); LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&bool` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&bool`
@ -98,7 +98,7 @@ LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug);
found reference `&bool` found reference `&bool`
error[E0308]: mismatched types 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); LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn Debug);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&char` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&char`
@ -107,7 +107,7 @@ LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn D
found reference `&char` found reference `&char`
error[E0308]: mismatched types 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]>); LL | let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>);
| ^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | ^^^^^^^^^^^^^^^^^^^ 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]>` found struct `Box<[i32; 3]>`
error[E0308]: mismatched types 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) -> _>); 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>` = 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 error: aborting due to 14 previous errors

View File

@ -1,12 +1,11 @@
// compile-flags: -Zunleash-the-miri-inside-of-you // compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(box_syntax)]
use std::mem::ManuallyDrop; use std::mem::ManuallyDrop;
fn main() {} fn main() {}
static TEST_BAD: &mut i32 = { static TEST_BAD: &mut i32 = {
&mut *(box 0) &mut *(Box::new(0))
//~^ ERROR could not evaluate static initializer //~^ 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 error[E0080]: could not evaluate static initializer
--> $DIR/box.rs:9:11 --> $DIR/box.rs:8:11
| |
LL | &mut *(box 0) LL | &mut *(Box::new(0))
| ^^^^^^^ calling non-const function `alloc::alloc::exchange_malloc` | ^^^^^^^^^^^^^ calling non-const function `Box::<i32>::new`
warning: skipping const checks warning: skipping const checks
| |
help: skipping check that does not even have a feature gate 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) LL | &mut *(Box::new(0))
| ^^^^^^^ | ^^^^^^^^^^^^^
help: skipping check for `const_mut_refs` feature help: skipping check for `const_mut_refs` feature
--> $DIR/box.rs:9:16 --> $DIR/box.rs:8:5
| |
LL | &mut *(box 0) LL | &mut *(Box::new(0))
| ^ | ^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_mut_refs` feature
--> $DIR/box.rs:9:5
|
LL | &mut *(box 0)
| ^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate 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 error: aborting due to previous error; 1 warning emitted

View File

@ -1,8 +1,7 @@
// compile-flags: -Z teach // compile-flags: -Z teach
#![feature(box_syntax)]
#![allow(warnings)] #![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() {} fn main() {}

View File

@ -1,11 +1,22 @@
error[E0010]: allocations are not allowed in constants 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; LL | const CON: Vec<i32> = vec![1, 2, 3];
| ^^^^^ allocation not allowed in constants | ^^^^^^^^^^^^^ 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: 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)] #![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() {} fn main() {}

View File

@ -1,9 +1,21 @@
error[E0010]: allocations are not allowed in constants 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; LL | const CON: Vec<i32> = vec![1, 2, 3];
| ^^^^^ allocation not allowed in constants | ^^^^^^^^^^^^^ 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` error[E0382]: borrow of moved value: `g`
--> $DIR/issue-105084.rs:44:14 --> $DIR/issue-105084.rs:45:14
| |
LL | let mut g = || { 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 | ----- 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]` 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 = || { LL | let mut g = || {
| -- within this `[generator@$DIR/issue-105084.rs:22:17: 22:19]` | -- within this `[generator@$DIR/issue-105084.rs:22:17: 22:19]`
@ -32,13 +32,13 @@ 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, ())>` | ^^^^ 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 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` | has type `Box<(i32, ())>` which does not implement `Copy`
note: required by a bound in `copy` note: required by a bound in `copy`
--> $DIR/issue-105084.rs:17:12 --> $DIR/issue-105084.rs:17:12
| |

View File

@ -9,7 +9,7 @@
#![feature(generators)] #![feature(generators)]
#![feature(generator_clone)] #![feature(generator_clone)]
#![feature(generator_trait)] #![feature(generator_trait)]
#![feature(box_syntax)] #![feature(rustc_attrs, stmt_expr_attributes)]
use std::ops::Generator; use std::ops::Generator;
use std::pin::Pin; use std::pin::Pin;
@ -25,7 +25,8 @@ fn main() {
// - create a Box that is ignored for trait computations; // - create a Box that is ignored for trait computations;
// - compute fields (and yields); // - compute fields (and yields);
// - assign to `t`. // - assign to `t`.
let t = box (5, yield); let t = #[rustc_box]
Box::new((5, yield));
drop(t); 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 // needs-unwind Asserting on contents of error message
#![allow(path_statements, unused_allocation)] #![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 { macro_rules! test {
( (
@ -127,9 +127,6 @@ fn main() {
// block // block
[ { elem } == 3 ] => "Assertion failed: { elem } == 3" [ { elem } == 3 ] => "Assertion failed: { elem } == 3"
// box
[ box elem == box 3 ] => "Assertion failed: box elem == box 3"
// break // break
[ loop { break elem; } == 3 ] => "Assertion failed: loop { break elem; } == 3" [ loop { break elem; } == 3 ] => "Assertion failed: loop { break elem; } == 3"

View File

@ -4,7 +4,6 @@
#![feature(async_closure)] #![feature(async_closure)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(generators)] #![feature(generators)]
@ -91,9 +90,6 @@ fn test_block() {
#[test] #[test]
fn test_expr() { fn test_expr() {
// ExprKind::Box
assert_eq!(stringify_expr!(box expr), "box expr");
// ExprKind::Array // ExprKind::Array
assert_eq!(stringify_expr!([]), "[]"); assert_eq!(stringify_expr!([]), "[]");
assert_eq!(stringify_expr!([true]), "[true]"); 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() {} 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]]; } #[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
//~^ ERROR expected expression, found `]` //~^ ERROR expected expression, found `]`
#[cfg(FALSE)] fn e() { let _ = foo#[attr](); } #[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 `]` 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]]; } LL | #[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
| ^ expected expression | ^ expected expression
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#` 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](); } LL | #[cfg(FALSE)] fn e() { let _ = foo#[attr](); }
| ^ expected one of 8 possible tokens | ^ expected one of 8 possible tokens
error: an inner attribute is not permitted in this context 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]); } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `)` 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]); } LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
| ^ expected expression | ^ expected expression
error: an inner attribute is not permitted in this context 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]); } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `)` 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]); } LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
| ^ expected expression | ^ expected expression
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#` 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; } LL | #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; }
| ^ expected one of 8 possible tokens | ^ expected one of 8 possible tokens
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context 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}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context 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}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: expected expression, found `..` 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; } LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; }
| ^^ expected expression | ^^ expected expression
error: expected expression, found `..` 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] ..; } LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..; }
| ^^ expected expression | ^^ expected expression
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted in this context 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; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches 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] {}; } LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch | -- ^^^^^^^ -- 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` | the branch belongs to this `if`
error: an inner attribute is not permitted in this context 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]}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` 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 {}; } LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator | ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: outer attributes are not allowed on `if` and `else` branches 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] {}; } LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; }
| ---- ^^^^^^^ -- the attributes are attached to this branch | ---- ^^^^^^^ -- 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` | the branch belongs to this `else`
error: an inner attribute is not permitted in this context 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]}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches 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 {}; } LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; }
| ---- ^^^^^^^ ------- the attributes are attached to this branch | ---- ^^^^^^^ ------- 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` | the branch belongs to this `else`
error: outer attributes are not allowed on `if` and `else` branches 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] {}; } LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch | -- ^^^^^^^ -- 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` | the branch belongs to this `if`
error: an inner attribute is not permitted in this context 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]}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches 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] {}; } LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch | -- ^^^^^^^ -- 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` | the branch belongs to this `if`
error: an inner attribute is not permitted in this context 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]}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` 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 {}; } LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator | ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: outer attributes are not allowed on `if` and `else` branches 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] {}; } LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; }
| ---- ^^^^^^^ -- the attributes are attached to this branch | ---- ^^^^^^^ -- 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` | the branch belongs to this `else`
error: an inner attribute is not permitted in this context 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]}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: outer attributes are not allowed on `if` and `else` branches 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 {}; } LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; }
| ---- ^^^^^^^ --------------- the attributes are attached to this branch | ---- ^^^^^^^ --------------- 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` | the branch belongs to this `else`
error: outer attributes are not allowed on `if` and `else` branches 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] {}; } LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; }
| -- ^^^^^^^ -- the attributes are attached to this branch | -- ^^^^^^^ -- 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` | the branch belongs to this `if`
error: an inner attribute is not permitted in this context 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]}; } 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted following an outer attribute 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; } LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; }
| ------- ^^^^^^^^ not permitted following an outer attribute | ------- ^^^^^^^^ 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted following an outer attribute 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; } LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; }
| ------- ^^^^^^^^ not permitted following an outer attribute | ------- ^^^^^^^^ 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 = note: outer attributes, like `#[test]`, annotate the item following them
error: an inner attribute is not permitted following an outer attribute 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!(); } LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
| ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation | ------- ^^^^^^^^ ------- 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 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![]; } LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
| ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation | ------- ^^^^^^^^ ------- 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 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!{}; } LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
| ------- ^^^^^^^^ ------ the inner attribute doesn't annotate this item macro invocation | ------- ^^^^^^^^ ------ 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 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
| ^^^ help: use `..` instead | ^^^ 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`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#` 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
| ^ expected one of `=>`, `if`, or `|` | ^ expected one of `=>`, `if`, or `|`
error[E0586]: inclusive range with no end 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
| ^^^ help: use `..` instead | ^^^ 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`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#` 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
| ^ expected one of `=>`, `if`, or `|` | ^ expected one of `=>`, `if`, or `|`
error: unexpected token: `#` 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } }
| ^ | ^
error[E0586]: inclusive range with no end 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
| ^^^ help: use `..` instead | ^^^ 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`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#` 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 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
| ^ expected one of `=>`, `if`, or `|` | ^ expected one of `=>`, `if`, or `|`
error: unexpected token: `#` 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(); } LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
| ^ | ^
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` 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(); } LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator | ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: unexpected token: `#` 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(); } LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
| ^ | ^
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` 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(); } LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator | ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: expected statement after outer attribute 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]; } } } LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
| ^^^^^^^ | ^^^^^^^
error: expected statement after outer attribute 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] } } } 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`. For more information about this error, try `rustc --explain E0586`.

View File

@ -5,11 +5,17 @@
#[allow(unused_macro_rules)] #[allow(unused_macro_rules)]
macro_rules! m { macro_rules! m {
($e:expr) => { 0 }; // This fails on the input below due to `, foo`. ($e:expr) => {
($e:expr,) => { 1 }; // This also fails to match due to `foo`. 0
(box $e:expr, foo) => { 2 }; // Successful matcher, we should get `2`. }; // 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() { 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::new(3);
//~^ ERROR cannot call non-const fn
static mut a: Box<isize> = box 3;
//~^ ERROR allocations are not allowed in statics
fn main() {} fn main() {}

View File

@ -1,9 +1,12 @@
error[E0010]: allocations are not allowed in statics error[E0015]: cannot call non-const fn `Box::<isize>::new` in statics
--> $DIR/static-mut-not-constant.rs:3:28 --> $DIR/static-mut-not-constant.rs:1:28
| |
LL | static mut a: Box<isize> = box 3; LL | static mut a: Box<isize> = Box::new(3);
| ^^^^^ allocation not allowed in statics | ^^^^^^^^^^^
|
= 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 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

@ -1,12 +1,10 @@
fn digit() -> str { fn digit() -> str {
return {}; return {};
//~^ ERROR: mismatched types [E0308] //~^ ERROR: mismatched types [E0308]
} }
fn main() { 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: cannot find value `_y` in this scope [E0425]
//~| ERROR: `X..` patterns in slices are experimental [E0658] //~| 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] //~| ERROR: pattern requires 1 element but array has 2 [E0527]
} }

View File

@ -1,49 +1,31 @@
error[E0425]: cannot find value `_y` in this scope error[E0425]: cannot find value `_y` in this scope
--> $DIR/issue-105946.rs:6:10 --> $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 | ^^ not found in this scope
error[E0658]: `X..` patterns in slices are experimental error[E0658]: `X..` patterns in slices are experimental
--> $DIR/issue-105946.rs:6:10 --> $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 = 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 = 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 error[E0308]: mismatched types
--> $DIR/issue-105946.rs:2:10 --> $DIR/issue-105946.rs:2:12
| |
LL | return {}; LL | return {};
| ^^ expected `str`, found `()` | ^^ expected `str`, found `()`
error[E0527]: pattern requires 1 element but array has 2 error[E0527]: pattern requires 1 element but array has 2
--> $DIR/issue-105946.rs:6:9 --> $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 | ^^^^^^ 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. Some errors have detailed explanations: E0308, E0425, E0527, E0658.
For more information about an error, try `rustc --explain E0308`. 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);
}