This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ // check-pass
2+ // known-bug: #91009
3+
4+ #![ feature( const_mut_refs) ]
5+ #![ feature( const_trait_impl) ]
6+ struct Panic ;
7+ impl const Drop for Panic { fn drop ( & mut self ) { panic ! ( ) ; } }
8+ pub const fn id < T > ( x : T ) -> T { x }
9+ pub const C : ( ) = {
10+ let _: & ' static _ = & id ( & Panic ) ;
11+ } ;
12+
13+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // check-pass
2+ // known-bug: #91009
3+
4+ #![ feature( const_precise_live_drops) ]
5+ pub const fn id < T > ( x : T ) -> T { x }
6+ pub const C : ( ) = {
7+ let _: & ' static _ = & id ( & String :: new ( ) ) ;
8+ } ;
9+
10+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ pub const fn id < T > ( x : T ) -> T { x }
2+ pub const C : ( ) = {
3+ let _: & ' static _ = & String :: new ( ) ;
4+ //~^ ERROR: destructor of `String` cannot be evaluated at compile-time
5+ //~| ERROR: temporary value dropped while borrowed
6+
7+ let _: & ' static _ = & id ( & String :: new ( ) ) ;
8+ //~^ ERROR: destructor of `String` cannot be evaluated at compile-time
9+
10+ let _: & ' static _ = & std:: mem:: ManuallyDrop :: new ( String :: new ( ) ) ;
11+ // Promoted. bug!
12+ } ;
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0493]: destructor of `String` cannot be evaluated at compile-time
2+ --> $DIR/promoted_const_call3.rs:7:30
3+ |
4+ LL | let _: &'static _ = &id(&String::new());
5+ | ^^^^^^^^^^^^^ - value is dropped here
6+ | |
7+ | the destructor for this type cannot be evaluated in constants
8+
9+ error[E0493]: destructor of `String` cannot be evaluated at compile-time
10+ --> $DIR/promoted_const_call3.rs:3:26
11+ |
12+ LL | let _: &'static _ = &String::new();
13+ | ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
14+ ...
15+ LL | };
16+ | - value is dropped here
17+
18+ error[E0716]: temporary value dropped while borrowed
19+ --> $DIR/promoted_const_call3.rs:3:26
20+ |
21+ LL | let _: &'static _ = &String::new();
22+ | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
23+ | |
24+ | type annotation requires that borrow lasts for `'static`
25+ ...
26+ LL | };
27+ | - temporary value is freed at the end of this statement
28+
29+ error: aborting due to 3 previous errors
30+
31+ Some errors have detailed explanations: E0493, E0716.
32+ For more information about an error, try `rustc --explain E0493`.
You can’t perform that action at this time.
0 commit comments