-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow references to interior mutable data behind a feature gate #80418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bors
merged 13 commits into
rust-lang:master
from
oli-obk:this_could_have_been_so_simple
Jan 4, 2021
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0b84184
Allow references to interior mutable data behind a feature gate
oli-obk 3a44a20
The proper name for the rule is "enclosing scope"
oli-obk 354e510
Fix cell checks in const fn
oli-obk 4158e58
Enhance some comments
oli-obk 3ed1403
Reinstate the error-code error over the feature gate error
oli-obk aaee3f2
Don't mix feature gates and hard errors, decide on one per op and sti…
oli-obk ba3a876
Bless ui tests
oli-obk e5330a4
Apply suggestions from code review
oli-obk a137ff1
Update now-more-precise operation with a preciser message
oli-obk e5e4a85
Grammar fixes
oli-obk 8968c8a
Dangling pointers point to everything and nothing
oli-obk d3992f3
Refactor the non-transient cell borrow error diagnostic
oli-obk 90b56b9
Stylistic fixes to diagnostic messages
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,27 +1,39 @@ | ||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead | ||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability | ||
--> $DIR/const-address-of-interior-mut.rs:5:39 | ||
| | ||
LL | const A: () = { let x = Cell::new(2); &raw const x; }; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information | ||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable | ||
|
||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead | ||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability | ||
--> $DIR/const-address-of-interior-mut.rs:7:40 | ||
| | ||
LL | static B: () = { let x = Cell::new(2); &raw const x; }; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information | ||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable | ||
|
||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead | ||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability | ||
--> $DIR/const-address-of-interior-mut.rs:9:44 | ||
| | ||
LL | static mut C: () = { let x = Cell::new(2); &raw const x; }; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information | ||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable | ||
|
||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead | ||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability | ||
--> $DIR/const-address-of-interior-mut.rs:13:13 | ||
| | ||
LL | let y = &raw const x; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information | ||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0492`. | ||
For more information about this error, try `rustc --explain E0658`. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.