-
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
Avoid ICEs in trait names without dyn
#119752
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
dyn
Res::Def(DefKind::Trait, id) => { | ||
// When we're dealing with a recursive trait, we don't want to downgrade | ||
// the error, so we consider them to be object safe always. (#119652) | ||
tcx.check_is_object_safe(id) || Some(id) == owner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be swapped to avoid executing the query if not necessary or would that change the meaning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean something like the following?
Res::Def(DefKind::Trait, id) if Some(id) == owner => {
// When we're dealing with a recursive trait, we don't want to downgrade
// the error, so we consider them to be object safe always. (#119652)
true
}
Res::Def(DefKind::Trait, id) => {
tcx.check_is_object_safe(id)
}
I only left it unconditionally because it doesn't cause any additional problems (it's ok, if incorrect, to check if Self
is object safe, surprisingly enough), but don't mind making this split more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be causing some issues for me generating accurate lint suggestions, because types that are not actually object safe are now being marked as object safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trevyn We can also entirely remove the downgrade, given how many head aches this is giving us, but your PR looks correct.
@bors reroll since its been a week I have been hitting a ton of these while fuzzing which is quite annoying 🙈 |
bors-reroll isn't a thing. |
Looks okay, thanks for fixing this! trait B { fn f(a: A) -> A; }
trait A { fn g(b: B) -> B; } Then the If we don't ICE r=me |
@bors r=fmease |
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#103730 (Added NonZeroXxx::from_mut(_unchecked)?) - rust-lang#113142 (optimize EscapeAscii's Display and CStr's Debug) - rust-lang#118799 (Stabilize single-field offset_of) - rust-lang#119613 (Expose Obligations created during type inference.) - rust-lang#119752 (Avoid ICEs in trait names without `dyn`) - rust-lang#120132 (Teach tidy about line/col information for malformed features) - rust-lang#120135 (SMIR: Make the remaining "private" fields actually private) - rust-lang#120148 (`single_use_lifetimes`: Don't suggest deleting lifetimes with bounds) - rust-lang#120150 (Stabilize `round_ties_even`) - rust-lang#120155 (Don't use `ReErased` to detect type test promotion failed) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#103730 (Added NonZeroXxx::from_mut(_unchecked)?) - rust-lang#113142 (optimize EscapeAscii's Display and CStr's Debug) - rust-lang#118799 (Stabilize single-field offset_of) - rust-lang#119613 (Expose Obligations created during type inference.) - rust-lang#119752 (Avoid ICEs in trait names without `dyn`) - rust-lang#120132 (Teach tidy about line/col information for malformed features) - rust-lang#120135 (SMIR: Make the remaining "private" fields actually private) - rust-lang#120148 (`single_use_lifetimes`: Don't suggest deleting lifetimes with bounds) - rust-lang#120150 (Stabilize `round_ties_even`) - rust-lang#120155 (Don't use `ReErased` to detect type test promotion failed) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119752 - estebank:ice-ice, r=fmease Avoid ICEs in trait names without `dyn` Check diagnostic is error before downgrading. Fix rust-lang#119633. Account for traits using self-trait by name without `dyn`. Fix rust-lang#119652.
…-errors `maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe` rust-lang#119752 leveraged and overloaded `is_object_safe` to prevent an ICE, but accurate object safety information is needed for precise suggestions. This separates out `is_downgradable`, used for the ICE prevention, and `is_object_safe`, which returns to its original meaning.
…-errors `maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe` rust-lang#119752 leveraged and overloaded `is_object_safe` to prevent an ICE, but accurate object safety information is needed for precise suggestions. This separates out `is_downgradable`, used for the ICE prevention, and `is_object_safe`, which returns to its original meaning.
…-errors `maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe` rust-lang#119752 leveraged and overloaded `is_object_safe` to prevent an ICE, but accurate object safety information is needed for precise suggestions. This separates out `is_downgradable`, used for the ICE prevention, and `is_object_safe`, which returns to its original meaning.
Rollup merge of rust-lang#120164 - trevyn:is_downgradable, r=compiler-errors `maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe` rust-lang#119752 leveraged and overloaded `is_object_safe` to prevent an ICE, but accurate object safety information is needed for precise suggestions. This separates out `is_downgradable`, used for the ICE prevention, and `is_object_safe`, which returns to its original meaning.
Check diagnostic is error before downgrading. Fix #119633.
Account for traits using self-trait by name without
dyn
. Fix #119652.