-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #55150 - pnkfelix:issues-47215-54797-fix-ice-from-movin…
…g-out-of-thread-local-under-ast-borrowck, r=nikomatsakis Do not allow moving out of thread local under ast borrowck AST borrowck failed to prevent moving out of a thread-local static. This was broken. And it also (sometimes?) caused an ICE during drop elaboration. Fix #47215 Fix #54797
- Loading branch information
Showing
16 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0507]: cannot move out of static item | ||
--> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 | ||
| | ||
LL | let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] | ||
| ^ | ||
| | | ||
| cannot move out of static item | ||
| help: consider borrowing here: `&X` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// rust-lang/rust#47215: at one time, the compiler categorized | ||
// thread-local statics as a temporary rvalue, as a way to enforce | ||
// that they are only valid for a given lifetime. | ||
// | ||
// The problem with this is that you cannot move out of static items, | ||
// but you *can* move temporary rvalues. I.e., the categorization | ||
// above only solves half of the problem presented by thread-local | ||
// statics. | ||
|
||
#![feature(thread_local)] | ||
|
||
#[thread_local] | ||
static mut X: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT; | ||
|
||
fn main() { | ||
unsafe { | ||
let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] | ||
let _y = x.get_mut(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0507]: cannot move out of thread-local static item | ||
--> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 | ||
| | ||
LL | let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] | ||
| ^ | ||
| | | ||
| cannot move out of thread-local static item | ||
| help: consider using a reference instead: `&X` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters