Skip to content
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

where_clauses_object_safety regression on a trait where it shouldn't trigger #106247

Closed
dtolnay opened this issue Dec 29, 2022 · 8 comments · Fixed by #106253
Closed

where_clauses_object_safety regression on a trait where it shouldn't trigger #106247

dtolnay opened this issue Dec 29, 2022 · 8 comments · Fixed by #106253
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 29, 2022

#![deny(where_clauses_object_safety)]

pub trait Trait {
    fn method(&self) where Self: Sync;
}

I bisected #51443 (comment). According to cargo-bisect-rustc --start 2022-12-28 --end 2022-12-29 -- check it bisects to 6a20f7d. This is concerning because nothing in #106209 looks remotely related to where_clause_object_safety so I am inferring that this is an unintentional regression.

Here are the 9 PRs in the rollup:

Definitely not it:

Highly unlikely:

I guess that leaves:

which only adds a brand new lint pass unrelated to where_clauses_object_safety, independent of any existing code. The PR is +167 -0. It seems like the only possible effect should be adding new occurrences of multiple_supertrait_upcastable, not affecting anything else.

In any case cc @nbdd0121 @compiler-errors in case you can tell what's going on.

@dtolnay dtolnay added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. labels Dec 29, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 29, 2022
@dtolnay
Copy link
Member Author

dtolnay commented Dec 29, 2022

I confirmed that the regression no longer reproduces after reverting #105484.

I have put up a revert PR in #106248 since it really seems like @nbdd0121's PR did not intentionally have anything to do with where_clauses_object_safety.

@nbdd0121
Copy link
Contributor

I think the way where_clause_object_safety currently being implemented is problematic. It currently fires when the compiler is checking whether a trait is object-safe or not, which doesn't make sense. It should be checked at actual use site (i.e. having is_object_safe return yes/no/no-but-we-accidentally-allowed-it.

Is the issue serious enough for a revert? I think a forward fix is better.

@dtolnay
Copy link
Member Author

dtolnay commented Dec 29, 2022

Yes I think it's serious enough for a revert. If I understand your explanation correctly, the multiple_supertrait_upcastable check gets run on every trait, which means we're now reporting scary object safety breakage warnings on literally every trait with a where-clause that mentions Self, for traits that no one ever though of using with dyn. That is a quite disruptive false positive.

(Of course you're free to race to put up a forward fix before the revert gets approved.)

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-critical

@rustbot rustbot added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 29, 2022
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 29, 2022
tarcieri added a commit to RustCrypto/actions that referenced this issue Dec 30, 2022
Recent nightlies broke pretty much anything that uses object safety:

rust-lang/rust#106247

This (temporarily) pins to a nightly before this regression occurred
so we don't have to pin nightly everywhere object safety is used.
tarcieri added a commit to RustCrypto/actions that referenced this issue Dec 30, 2022
Recent nightlies broke pretty much anything that uses object safety:

rust-lang/rust#106247

This (temporarily) pins to a nightly before this regression occurred
so we don't have to pin nightly everywhere object safety is used.
compiler-errors added a commit to compiler-errors/rust that referenced this issue Dec 31, 2022
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint"

This is a clean revert of rust-lang#105484.

I confirmed that reverting that PR fixes the regression reported in rust-lang#106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** rust-lang#106247 (comment) has an explanation of why rust-lang#105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe.

FYI `@nbdd0121` `@compiler-errors`
@Noratrieb Noratrieb removed the P-critical Critical priority label Dec 31, 2022
@Noratrieb
Copy link
Member

Removing P-critical as the revert has landed in #106248. Should we reprioritize this?

@apiraino
Copy link
Contributor

apiraino commented Dec 31, 2022

@Nilstrieb I think P- labels can stay attached to an issue. In fact they're just signaling the priority, not their open/solved status; therefore a closed issue can stay P-critical for good (and sometimes it's also useful to have a reference or a "previous case" to refer to in case similar issues are filed).

In addition, it's also useful in case critical regressions are fixed on the stable channel so T-infra can decide for a stable backport (i.e. a point release).

@rustbot label P-critical

@rustbot rustbot added the P-critical Critical priority label Dec 31, 2022
@pnkfelix
Copy link
Member

pnkfelix commented Jan 5, 2023

Discussed in triage meeting. Downgrading (we do not need to revisit every week)

@rustbot label: +P-high -P-critical

@rustbot rustbot added P-high High priority and removed P-critical Critical priority labels Jan 5, 2023
@pnkfelix
Copy link
Member

pnkfelix commented Jan 5, 2023

further discussion led us to realize that this should just be closed due to the revert

(a test landed, so we should not reinject the bug when the lint re-lands)

@pnkfelix pnkfelix closed this as completed Jan 5, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 29, 2023
Skip possible where_clause_object_safety lints when checking `multiple_supertrait_upcastable`

Fix rust-lang#106247

To achieve this, I lifted the `WhereClauseReferencesSelf` out from `object_safety_violations` and move it into `is_object_safe` (which is changed to a new query).

cc `@dtolnay`
r? `@compiler-errors`
thomcc pushed a commit to tcdi/postgrestd that referenced this issue May 31, 2023
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint"

This is a clean revert of #105484.

I confirmed that reverting that PR fixes the regression reported in #106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** rust-lang/rust#106247 (comment) has an explanation of why #105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe.

FYI `@nbdd0121` `@compiler-errors`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants