-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove RefCell::get and RefCell::set #13301
Merged
Merged
Conversation
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
It's surprising that `RefCell::get()` is implicitly doing a clone on a value. This patch removes it and replaces all users with either `.borrow()` when we can autoderef, or `.borrow().clone()` when we cannot.
This fixes rust-lang#13238. It avoids an infinite loop when compiling the tests with `-g`. Without this change, the debuginfo on `black_box` prevents the method from being inlined, which allows llvm to convert `silent_recurse` into a tail-call. This then loops forever instead of consuming all the stack like it is supposed to. This patch forces inlining `black_box`, which triggers the right error.
bors
added a commit
that referenced
this pull request
Apr 4, 2014
`RefCell::get` can be a bit surprising, because it actually clones the wrapped value. This removes `RefCell::get` and replaces all the users with `RefCell::borrow()` when it can, and `RefCell::borrow().clone()` when it can't. It removes `RefCell::set` for consistency. This closes #13182. It also fixes an infinite loop in a test when debugging is on.
bors-servo
pushed a commit
to servo/servo
that referenced
this pull request
Apr 16, 2014
It's going away in the next Rust upgrade (rust-lang/rust#13301). r? @larsbergstrom We'll need to do the same in rust-layers.
mbrubeck
added a commit
to mbrubeck/rust-layers
that referenced
this pull request
Apr 17, 2014
It's going away in the next Rust upgrade (rust-lang/rust#13301).
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-comments-removed
that referenced
this pull request
Sep 30, 2019
…beck:refcell-get); r=larsbergstrom It's going away in the next Rust upgrade (rust-lang/rust#13301). r? larsbergstrom We'll need to do the same in rust-layers. Source-Repo: https://github.com/servo/servo Source-Revision: aafadb65f2f5e318805a03f3bc9814eb1a8a50cc UltraBlame original commit: b14ab74b1b9813efa98ef1cb51659a7979f3aa0d
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified
that referenced
this pull request
Sep 30, 2019
…beck:refcell-get); r=larsbergstrom It's going away in the next Rust upgrade (rust-lang/rust#13301). r? larsbergstrom We'll need to do the same in rust-layers. Source-Repo: https://github.com/servo/servo Source-Revision: aafadb65f2f5e318805a03f3bc9814eb1a8a50cc UltraBlame original commit: b14ab74b1b9813efa98ef1cb51659a7979f3aa0d
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified-and-comments-removed
that referenced
this pull request
Oct 1, 2019
…beck:refcell-get); r=larsbergstrom It's going away in the next Rust upgrade (rust-lang/rust#13301). r? larsbergstrom We'll need to do the same in rust-layers. Source-Repo: https://github.com/servo/servo Source-Revision: aafadb65f2f5e318805a03f3bc9814eb1a8a50cc UltraBlame original commit: b14ab74b1b9813efa98ef1cb51659a7979f3aa0d
matthiaskrgr
pushed a commit
to matthiaskrgr/rust
that referenced
this pull request
Oct 11, 2022
…r=Veykril Make assist tests panic again on empty source changes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
RefCell::get
can be a bit surprising, because it actually clones the wrapped value. This removesRefCell::get
and replaces all the users withRefCell::borrow()
when it can, andRefCell::borrow().clone()
when it can't. It removesRefCell::set
for consistency. This closes #13182.It also fixes an infinite loop in a test when debugging is on.