Add track_caller to DefId::expect_local()#96747
Merged
bors merged 1 commit intorust-lang:masterfrom May 6, 2022
Merged
Conversation
Contributor
|
(rust-highfive has picked a reviewer for you, use r? to override) |
Contributor
|
@bors r+ rollup |
Collaborator
|
📌 Commit 2ed38cd has been approved by |
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
May 5, 2022
…, r=compiler-errors Add `track_caller` to `DefId::expect_local()` Suggested in rust-lang#96738 (comment). `DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
May 6, 2022
…, r=compiler-errors Add `track_caller` to `DefId::expect_local()` Suggested in rust-lang#96738 (comment). `DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 6, 2022
…piler-errors Rollup of 7 pull requests Successful merges: - rust-lang#96174 (mark ptr-int-transmute test as no_run) - rust-lang#96639 (Fix typo in `offset_from` documentation) - rust-lang#96704 (Add rotation animation on settings button when loading) - rust-lang#96730 (Add a regression test for rust-lang#64173 and rust-lang#66152) - rust-lang#96741 (Improve settings loading strategy) - rust-lang#96744 (Implement [OsStr]::join) - rust-lang#96747 (Add `track_caller` to `DefId::expect_local()`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
petrochenkov
reviewed
May 6, 2022
| #[inline] | ||
| #[track_caller] | ||
| pub fn expect_local(self) -> LocalDefId { | ||
| self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self)) |
Contributor
There was a problem hiding this comment.
This doesn't work because there's a closure in the middle which doesn't track caller.
So either #[track_caller] need to be applied to the closure too, or match need to be used instead of unwrap_or_else.
Member
Author
There was a problem hiding this comment.
Didn't know, I'll address it. Thanks!
Member
Author
There was a problem hiding this comment.
Does the same apply to expect_non_local?
rust/compiler/rustc_hir/src/def.rs
Lines 633 to 636 in 9714e13
Contributor
There was a problem hiding this comment.
Yes, fn expect_non_local should have the same issue.
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
May 6, 2022
…-take-2, r=petrochenkov Remove closures on `expect_local` to apply `#[track_caller]` Pointed out in rust-lang#96747 (comment) Didn't change `expect_non_local` as I'm not sure if it's also the case. r? `@petrochenkov`
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
May 7, 2022
…-take-2, r=petrochenkov Remove closures on `expect_local` to apply `#[track_caller]` Pointed out in rust-lang#96747 (comment) Didn't change `expect_non_local` as I'm not sure if it's also the case. r? ``@petrochenkov``
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
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.
Suggested in #96738 (comment).
DefId::expect_local()often causes ICEs (panics) and should be a good candidate to addtrack_caller.