mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Rollup merge of #102194 - fee1-dead-contrib:improve-const-drop, r=oli-obk
Note the type when unable to drop values in compile time
This commit is contained in:
commit
b7d9de72ac
@ -1009,7 +1009,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
||||
|
||||
if needs_non_const_drop {
|
||||
self.check_op_spanned(
|
||||
ops::LiveDrop { dropped_at: Some(terminator.source_info.span) },
|
||||
ops::LiveDrop {
|
||||
dropped_at: Some(terminator.source_info.span),
|
||||
dropped_ty: ty_of_dropped_place,
|
||||
},
|
||||
err_span,
|
||||
);
|
||||
}
|
||||
|
@ -422,10 +422,11 @@ impl<'tcx> NonConstOp<'tcx> for InlineAsm {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LiveDrop {
|
||||
pub struct LiveDrop<'tcx> {
|
||||
pub dropped_at: Option<Span>,
|
||||
pub dropped_ty: Ty<'tcx>,
|
||||
}
|
||||
impl<'tcx> NonConstOp<'tcx> for LiveDrop {
|
||||
impl<'tcx> NonConstOp<'tcx> for LiveDrop<'tcx> {
|
||||
fn build_error(
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
@ -435,9 +436,13 @@ impl<'tcx> NonConstOp<'tcx> for LiveDrop {
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
E0493,
|
||||
"destructors cannot be evaluated at compile-time"
|
||||
"destructor of `{}` cannot be evaluated at compile-time",
|
||||
self.dropped_ty,
|
||||
);
|
||||
err.span_label(
|
||||
span,
|
||||
format!("the destructor for this type cannot be evaluated in {}s", ccx.const_kind()),
|
||||
);
|
||||
err.span_label(span, format!("{}s cannot evaluate destructors", ccx.const_kind()));
|
||||
if let Some(span) = self.dropped_at {
|
||||
err.span_label(span, "value is dropped here");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::{self, BasicBlock, Location};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_span::{symbol::sym, Span};
|
||||
|
||||
use super::check::Qualifs;
|
||||
@ -58,9 +58,9 @@ impl<'mir, 'tcx> std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckLiveDrops<'_, '_> {
|
||||
fn check_live_drop(&self, span: Span) {
|
||||
ops::LiveDrop { dropped_at: None }.build_error(self.ccx, span).emit();
|
||||
impl<'tcx> CheckLiveDrops<'_, 'tcx> {
|
||||
fn check_live_drop(&self, span: Span, dropped_ty: Ty<'tcx>) {
|
||||
ops::LiveDrop { dropped_at: None, dropped_ty }.build_error(self.ccx, span).emit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> {
|
||||
}
|
||||
|
||||
if dropped_place.is_indirect() {
|
||||
self.check_live_drop(terminator.source_info.span);
|
||||
self.check_live_drop(terminator.source_info.span, dropped_ty);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> {
|
||||
if self.qualifs.needs_non_const_drop(self.ccx, dropped_place.local, location) {
|
||||
// Use the span where the dropped local was declared for the error.
|
||||
let span = self.body.local_decls[dropped_place.local].source_info.span;
|
||||
self.check_live_drop(span);
|
||||
self.check_live_drop(span, dropped_ty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ static STATIC8: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
|
||||
// This example should fail because field1 in the base struct is not safe
|
||||
static STATIC9: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
|
||||
..SafeStruct{field1: SafeEnum::Variant3(WithDtor),
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
field2: SafeEnum::Variant1}};
|
||||
|
||||
struct UnsafeStruct;
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0493]: destructors 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
|
||||
|
|
||||
LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor),
|
||||
@ -7,7 +7,7 @@ LL | |
|
||||
LL | | field2: SafeEnum::Variant1}};
|
||||
| | ^- value is dropped here
|
||||
| |________________________________________________________________________________|
|
||||
| statics cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in statics
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:79:33
|
||||
|
@ -14,16 +14,16 @@ const X2: FakeNeedsDrop = { let x; x = FakeNeedsDrop; x };
|
||||
|
||||
// error
|
||||
const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
// error
|
||||
const Y2: FakeNeedsDrop = { let mut x; x = FakeNeedsDrop; x = FakeNeedsDrop; x };
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
// error
|
||||
const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
// error
|
||||
const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); };
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
@ -1,34 +1,34 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `FakeNeedsDrop` cannot be evaluated at compile-time
|
||||
--> $DIR/const_let.rs:16:32
|
||||
|
|
||||
LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
|
||||
| ^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `FakeNeedsDrop` cannot be evaluated at compile-time
|
||||
--> $DIR/const_let.rs:20:33
|
||||
|
|
||||
LL | const Y2: FakeNeedsDrop = { let mut x; x = FakeNeedsDrop; x = FakeNeedsDrop; x };
|
||||
| ^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<FakeNeedsDrop>` cannot be evaluated at compile-time
|
||||
--> $DIR/const_let.rs:24:21
|
||||
|
|
||||
LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
|
||||
| ^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<FakeNeedsDrop>` cannot be evaluated at compile-time
|
||||
--> $DIR/const_let.rs:28:22
|
||||
|
|
||||
LL | const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); };
|
||||
| ^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
// We will likely have to change this behavior before we allow `&mut` in a `const`.
|
||||
|
||||
const _: Vec<i32> = {
|
||||
let mut x = Vec::<i32>::new(); //~ ERROR destructors cannot be evaluated at compile-time
|
||||
let mut x = Vec::<i32>::new(); //~ ERROR destructor of
|
||||
let r = &mut x; //~ ERROR mutable references are not allowed in constants
|
||||
let y = x;
|
||||
y
|
||||
|
@ -7,11 +7,11 @@ LL | let r = &mut x;
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Vec<i32>` cannot be evaluated at compile-time
|
||||
--> $DIR/issue-65394.rs:7:9
|
||||
|
|
||||
LL | let mut x = Vec::<i32>::new();
|
||||
| ^^^^^ constants cannot evaluate destructors
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
@ -1,6 +1,6 @@
|
||||
const _: Option<Vec<i32>> = {
|
||||
let mut never_returned = Some(Vec::new());
|
||||
let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time
|
||||
let mut always_returned = None; //~ ERROR destructor of
|
||||
|
||||
let mut i = 0;
|
||||
loop {
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<Vec<i32>>` cannot be evaluated at compile-time
|
||||
--> $DIR/livedrop.rs:3:9
|
||||
|
|
||||
LL | let mut always_returned = None;
|
||||
| ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors
|
||||
| ^^^^^^^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | always_returned = never_returned;
|
||||
| --------------- value is dropped here
|
||||
|
@ -1,14 +1,14 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<Vec<i32>>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:8:9
|
||||
|
|
||||
LL | let x = Some(Vec::new());
|
||||
| ^ constants cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<Vec<i32>>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:39:9
|
||||
|
|
||||
LL | let mut tmp = None;
|
||||
| ^^^^^^^ constants cannot evaluate destructors
|
||||
| ^^^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
const _: Option<Vec<i32>> = {
|
||||
let y: Option<Vec<i32>> = None;
|
||||
let x = Some(Vec::new());
|
||||
//[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//[stock,precise]~^ ERROR destructor of
|
||||
|
||||
if true {
|
||||
x
|
||||
@ -19,7 +19,7 @@ const _: Option<Vec<i32>> = {
|
||||
// existing analysis.
|
||||
const _: Vec<i32> = {
|
||||
let vec_tuple = (Vec::new(),);
|
||||
//[stock]~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//[stock]~^ ERROR destructor of
|
||||
|
||||
vec_tuple.0
|
||||
};
|
||||
@ -27,7 +27,7 @@ const _: Vec<i32> = {
|
||||
// This applies to single-field enum variants as well.
|
||||
const _: Vec<i32> = {
|
||||
let x: Result<_, Vec<i32>> = Ok(Vec::new());
|
||||
//[stock]~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//[stock]~^ ERROR destructor of
|
||||
|
||||
match x {
|
||||
Ok(x) | Err(x) => x,
|
||||
@ -37,7 +37,7 @@ const _: Vec<i32> = {
|
||||
const _: Option<Vec<i32>> = {
|
||||
let mut some = Some(Vec::new());
|
||||
let mut tmp = None;
|
||||
//[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//[stock,precise]~^ ERROR destructor of
|
||||
|
||||
let mut i = 0;
|
||||
while i < 10 {
|
||||
|
@ -1,35 +1,35 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<Vec<i32>>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:8:9
|
||||
|
|
||||
LL | let x = Some(Vec::new());
|
||||
| ^ constants cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(Vec<i32>,)` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:21:9
|
||||
|
|
||||
LL | let vec_tuple = (Vec::new(),);
|
||||
| ^^^^^^^^^ constants cannot evaluate destructors
|
||||
| ^^^^^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Result<Vec<i32>, Vec<i32>>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:29:9
|
||||
|
|
||||
LL | let x: Result<_, Vec<i32>> = Ok(Vec::new());
|
||||
| ^ constants cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<Vec<i32>>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:39:9
|
||||
|
|
||||
LL | let mut tmp = None;
|
||||
| ^^^^^^^ constants cannot evaluate destructors
|
||||
| ^^^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
@ -1,4 +1,4 @@
|
||||
const fn f<T>(_: Box<T>) {}
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Box<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop_box.rs:1:15
|
||||
|
|
||||
LL | const fn f<T>(_: Box<T>) {}
|
||||
| ^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `S` cannot be evaluated at compile-time
|
||||
--> $DIR/drop_zst.rs:14:9
|
||||
|
|
||||
LL | let s = S;
|
||||
| ^ constant functions cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -34,7 +34,7 @@ const fn foo35(a: bool, b: bool) -> bool { a ^ b }
|
||||
struct Foo<T: ?Sized>(T);
|
||||
impl<T> Foo<T> {
|
||||
const fn new(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner(self) -> T { self.0 } //~ destructors cannot be evaluated
|
||||
const fn into_inner(self) -> T { self.0 } //~ destructor of
|
||||
const fn get(&self) -> &T { &self.0 }
|
||||
const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references
|
||||
@ -43,7 +43,7 @@ impl<T> Foo<T> {
|
||||
}
|
||||
impl<'a, T> Foo<T> {
|
||||
const fn new_lt(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner_lt(self) -> T { self.0 } //~ destructors cannot be evaluated
|
||||
const fn into_inner_lt(self) -> T { self.0 } //~ destructor of
|
||||
const fn get_lt(&'a self) -> &T { &self.0 }
|
||||
const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references
|
||||
@ -52,7 +52,7 @@ impl<'a, T> Foo<T> {
|
||||
}
|
||||
impl<T: Sized> Foo<T> {
|
||||
const fn new_s(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructors
|
||||
const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructor
|
||||
const fn get_s(&self) -> &T { &self.0 }
|
||||
const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:37:25
|
||||
|
|
||||
LL | const fn into_inner(self) -> T { self.0 }
|
||||
| ^^^^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:39:22
|
||||
@ -33,13 +33,13 @@ LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:46:28
|
||||
|
|
||||
LL | const fn into_inner_lt(self) -> T { self.0 }
|
||||
| ^^^^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:48:25
|
||||
@ -68,13 +68,13 @@ LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:55:27
|
||||
|
|
||||
LL | const fn into_inner_s(self) -> T { self.0 }
|
||||
| ^^^^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:57:24
|
||||
@ -191,21 +191,21 @@ LL | const fn inc(x: &mut i32) { *x += 1 }
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `AlanTuring<impl std::fmt::Debug>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:122:19
|
||||
|
|
||||
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
|
||||
| ^^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:124:18
|
||||
|
|
||||
LL | const fn no_apit(_x: impl std::fmt::Debug) {}
|
||||
| ^^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error: aborting due to 24 previous errors
|
||||
|
||||
|
@ -8,7 +8,7 @@ trait Foo<T> {
|
||||
}
|
||||
|
||||
trait Bar<T, U: Foo<T>> {
|
||||
const F: u32 = (U::X, 42).1; //~ ERROR destructors cannot be evaluated at compile-time
|
||||
const F: u32 = (U::X, 42).1; //~ ERROR destructor of
|
||||
}
|
||||
|
||||
impl Foo<u32> for () {
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(T, u32)` cannot be evaluated at compile-time
|
||||
--> $DIR/feature-gate-unleash_the_miri_inside_of_you.rs:11:20
|
||||
|
|
||||
LL | const F: u32 = (U::X, 42).1;
|
||||
| ^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
// Mutable borrow of a field with drop impl.
|
||||
pub const fn f() {
|
||||
let mut a: (u32, Option<String>) = (0, None); //~ ERROR destructors cannot be evaluated
|
||||
let mut a: (u32, Option<String>) = (0, None); //~ ERROR destructor of
|
||||
let _ = &mut a.1;
|
||||
}
|
||||
|
||||
// Mutable borrow of a type with drop impl.
|
||||
pub const A1: () = {
|
||||
let mut x = None; //~ ERROR destructors cannot be evaluated
|
||||
let mut x = None; //~ ERROR destructor of
|
||||
let mut y = Some(String::new());
|
||||
let a = &mut x;
|
||||
let b = &mut y;
|
||||
@ -28,12 +28,12 @@ pub const A2: () = {
|
||||
let b = &mut y;
|
||||
std::mem::swap(a, b);
|
||||
std::mem::forget(y);
|
||||
let _z = x; //~ ERROR destructors cannot be evaluated
|
||||
let _z = x; //~ ERROR destructor of
|
||||
};
|
||||
|
||||
// Shared borrow of a type that might be !Freeze and Drop.
|
||||
pub const fn g1<T>() {
|
||||
let x: Option<T> = None; //~ ERROR destructors cannot be evaluated
|
||||
let x: Option<T> = None; //~ ERROR destructor of
|
||||
let _ = x.is_some();
|
||||
}
|
||||
|
||||
@ -41,24 +41,24 @@ pub const fn g1<T>() {
|
||||
pub const fn g2<T>() {
|
||||
let x: Option<T> = None;
|
||||
let _ = x.is_some();
|
||||
let _y = x; //~ ERROR destructors cannot be evaluated
|
||||
let _y = x; //~ ERROR destructor of
|
||||
}
|
||||
|
||||
// Mutable raw reference to a Drop type.
|
||||
pub const fn address_of_mut() {
|
||||
let mut x: Option<String> = None; //~ ERROR destructors cannot be evaluated
|
||||
let mut x: Option<String> = None; //~ ERROR destructor of
|
||||
&raw mut x;
|
||||
|
||||
let mut y: Option<String> = None; //~ ERROR destructors cannot be evaluated
|
||||
let mut y: Option<String> = None; //~ ERROR destructor of
|
||||
std::ptr::addr_of_mut!(y);
|
||||
}
|
||||
|
||||
// Const raw reference to a Drop type. Conservatively assumed to allow mutation
|
||||
// until resolution of https://github.com/rust-lang/rust/issues/56604.
|
||||
pub const fn address_of_const() {
|
||||
let x: Option<String> = None; //~ ERROR destructors cannot be evaluated
|
||||
let x: Option<String> = None; //~ ERROR destructor of
|
||||
&raw const x;
|
||||
|
||||
let y: Option<String> = None; //~ ERROR destructors cannot be evaluated
|
||||
let y: Option<String> = None; //~ ERROR destructor of
|
||||
std::ptr::addr_of!(y);
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:9:9
|
||||
|
|
||||
LL | let mut a: (u32, Option<String>) = (0, None);
|
||||
| ^^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:15:9
|
||||
|
|
||||
LL | let mut x = None;
|
||||
| ^^^^^ constants cannot evaluate destructors
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:31:9
|
||||
|
|
||||
LL | let _z = x;
|
||||
| ^^ constants cannot evaluate destructors
|
||||
| ^^ the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:36:9
|
||||
|
|
||||
LL | let x: Option<T> = None;
|
||||
| ^ constant functions cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:44:9
|
||||
|
|
||||
LL | let _y = x;
|
||||
| ^^ constant functions cannot evaluate destructors
|
||||
| ^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:52:9
|
||||
|
|
||||
LL | let mut y: Option<String> = None;
|
||||
| ^^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:49:9
|
||||
|
|
||||
LL | let mut x: Option<String> = None;
|
||||
| ^^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:62:9
|
||||
|
|
||||
LL | let y: Option<String> = None;
|
||||
| ^ constant functions cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:59:9
|
||||
|
|
||||
LL | let x: Option<String> = None;
|
||||
| ^ constant functions cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
@ -11,7 +11,7 @@ impl<T> Either<T, T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "foo", since = "1.0.0")]
|
||||
pub const fn unwrap(self) -> T {
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
match self {
|
||||
Self::Left(t) => t,
|
||||
Self::Right(t) => t,
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Either<T, T>` cannot be evaluated at compile-time
|
||||
--> $DIR/stable-precise-live-drops-in-libcore.rs:13:25
|
||||
|
|
||||
LL | pub const fn unwrap(self) -> T {
|
||||
| ^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
@ -15,8 +15,8 @@ impl<T> Opt<T> {
|
||||
#[rustc_const_unstable(feature = "foo", issue = "none")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~| ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
//~| ERROR destructor of
|
||||
match self {
|
||||
Opt::Some(t) => t,
|
||||
Opt::None => f(),
|
||||
|
@ -1,17 +1,17 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `F` cannot be evaluated at compile-time
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:17:60
|
||||
|
|
||||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^ constant functions cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `Opt<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:17:54
|
||||
|
|
||||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
@ -5,7 +5,7 @@ fn borrowck_catch() {
|
||||
}
|
||||
|
||||
const _: [String; 0] = [String::new(); 0];
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time [E0493]
|
||||
//~^ ERROR destructor of `String` cannot be evaluated at compile-time [E0493]
|
||||
|
||||
fn must_be_init() {
|
||||
let x: u8;
|
||||
|
@ -8,13 +8,13 @@ LL | let _bar = foo;
|
||||
LL | let _baz = [foo; 0];
|
||||
| ^^^ value used here after move
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `String` cannot be evaluated at compile-time
|
||||
--> $DIR/repeat-drop-2.rs:7:25
|
||||
|
|
||||
LL | const _: [String; 0] = [String::new(); 0];
|
||||
| -^^^^^^^^^^^^^----
|
||||
| ||
|
||||
| |constants cannot evaluate destructors
|
||||
| |the destructor for this type cannot be evaluated in constants
|
||||
| value is dropped here
|
||||
|
||||
error[E0381]: used binding `x` isn't initialized
|
||||
|
@ -12,7 +12,7 @@ struct Bug {
|
||||
}
|
||||
let f: F = async { 1 };
|
||||
//~^ ERROR `async` blocks are not allowed in constants
|
||||
//~| ERROR destructors cannot be evaluated at compile-time
|
||||
//~| ERROR destructor of
|
||||
1
|
||||
}],
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ LL | let f: F = async { 1 };
|
||||
= note: see issue #85368 <https://github.com/rust-lang/rust/issues/85368> for more information
|
||||
= help: add `#![feature(const_async_blocks)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `F` cannot be evaluated at compile-time
|
||||
--> $DIR/issue-78722.rs:13:13
|
||||
|
|
||||
LL | let f: F = async { 1 };
|
||||
| ^ constants cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | }],
|
||||
| - value is dropped here
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
static A: () = {
|
||||
let a: [String; 1];
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
a[0] = String::new();
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
//~| ERROR binding `a` isn't initialized
|
||||
};
|
||||
|
||||
@ -14,9 +14,9 @@ struct B<T>([T; 1]);
|
||||
impl<T> B<T> {
|
||||
pub const fn f(mut self, other: T) -> Self {
|
||||
let _this = self;
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
self.0[0] = other;
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
//~| ERROR use of moved value
|
||||
self
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `String` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-elaboration-after-borrowck-error.rs:7:5
|
||||
|
|
||||
LL | a[0] = String::new();
|
||||
| ^^^^
|
||||
| |
|
||||
| statics cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in statics
|
||||
| value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `[String; 1]` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-elaboration-after-borrowck-error.rs:5:9
|
||||
|
|
||||
LL | let a: [String; 1];
|
||||
| ^ statics cannot evaluate destructors
|
||||
| ^ the destructor for this type cannot be evaluated in statics
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
@ -25,20 +25,20 @@ LL |
|
||||
LL | a[0] = String::new();
|
||||
| ^^^^ `a` used here but it isn't initialized
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-elaboration-after-borrowck-error.rs:18:9
|
||||
|
|
||||
LL | self.0[0] = other;
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
| value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `B<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/drop-elaboration-after-borrowck-error.rs:16:13
|
||||
|
|
||||
LL | let _this = self;
|
||||
| ^^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
@ -15,7 +15,7 @@ impl Drop for Bar {
|
||||
}
|
||||
|
||||
const F : Foo = (Foo { a : 0 }, Foo { a : 1 }).1;
|
||||
//~^ destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(Foo, Foo)` cannot be evaluated at compile-time
|
||||
--> $DIR/E0493.rs:17:17
|
||||
|
|
||||
LL | const F : Foo = (Foo { a : 0 }, Foo { a : 1 }).1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,33 +5,33 @@ impl Drop for WithDtor {
|
||||
}
|
||||
|
||||
static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
//~| ERROR temporary value dropped while borrowed
|
||||
|
||||
const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
//~| ERROR temporary value dropped while borrowed
|
||||
|
||||
static EARLY_DROP_S: i32 = (WithDtor, 0).1;
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
const EARLY_DROP_C: i32 = (WithDtor, 0).1;
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
const fn const_drop<T>(_: T) {}
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
const fn const_drop2<T>(x: T) {
|
||||
(x, ()).1
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
}
|
||||
|
||||
const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
const HELPER: Option<WithDtor> = Some(WithDtor);
|
||||
|
||||
const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
//~^ ERROR destructor of
|
||||
|
||||
fn main () {}
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `WithDtor` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:7:60
|
||||
|
|
||||
LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| ^^^^^^^^- value is dropped here
|
||||
| |
|
||||
| statics cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in statics
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/static-drop-scope.rs:7:60
|
||||
@ -16,13 +16,13 @@ LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| | creates a temporary which is freed while still in use
|
||||
| using this value as a static requires that borrow lasts for `'static`
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `WithDtor` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:11:59
|
||||
|
|
||||
LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| ^^^^^^^^- value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/static-drop-scope.rs:11:59
|
||||
@ -34,54 +34,54 @@ LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| | creates a temporary which is freed while still in use
|
||||
| using this value as a constant requires that borrow lasts for `'static`
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(WithDtor, i32)` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:15:28
|
||||
|
|
||||
LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
|
||||
| ^^^^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| statics cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in statics
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(WithDtor, i32)` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:18:27
|
||||
|
|
||||
LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
|
||||
| ^^^^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:21:24
|
||||
|
|
||||
LL | const fn const_drop<T>(_: T) {}
|
||||
| ^ - value is dropped here
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(T, ())` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:25:5
|
||||
|
|
||||
LL | (x, ()).1
|
||||
| ^^^^^^^ constant functions cannot evaluate destructors
|
||||
| ^^^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
LL |
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(Option<WithDtor>, i32)` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:29:34
|
||||
|
|
||||
LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
|
||||
| ^^^^^^^^^^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
error[E0493]: destructor of `(Option<WithDtor>, i32)` cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:34:43
|
||||
|
|
||||
LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
|
||||
| ^^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| constants cannot evaluate destructors
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user