6

discard default auto trait impls if explicit ones exist (rebase of #85048) by Dd...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/113312
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

discard default auto trait impls if explicit ones exist (rebase of #85048) #113312

Conversation

Contributor

Rebase of #85048

Collaborator

r? @b-naber

(rustbot has picked a reviewer for you, use r? to override)

rustbot

added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Jul 4, 2023

Contributor

Author

r? @lcnr

Ddystopia

changed the title auto trait candidate selection is unsound (rebase of #84857)

auto trait candidate selection is unsound (rebase of #85048)

Jul 4, 2023

Ddystopia

changed the title auto trait candidate selection is unsound (rebase of #85048)

discard default auto trait impls if explicit ones exist (rebase of #85048)

Jul 4, 2023

Contributor

thanks for looking into this heart lets start with crater

@bors try

Contributor

hourglass Trying commit cb2716b with merge 262225c...

This comment has been minimized.

Contributor

💔 Test failed - checks-actions

bors

added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Jul 4, 2023

Contributor

oh, this PR is now breaking tokio-util sweat that is unexpected and feels wrong thinking

Contributor

error[E0277]: `impl Future<Output = Result<(), tokio::sync::mpsc::error::SendError<_>>>` cannot be sent between threads safely
Error:   --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-util-0.6.9/src/sync/mpsc.rs:43:43
   |
43 |             inner: ReusableBoxFuture::new(make_future(None)),
   |                    ---------------------- ^^^^^^^^^^^^^^^^^ `impl Future<Output = Result<(), tokio::sync::mpsc::error::SendError<_>>>` cannot be sent between threads safely
   |                    |
   |                    required by a bound introduced by this call
   |
   = help: the trait `Send` is not implemented for `impl Future<Output = Result<(), tokio::sync::mpsc::error::SendError<_>>>`
note: required by a bound in `ReusableBoxFuture::<T>::new`
  --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-util-0.6.9/src/sync/reusable_box.rs:21:33
   |
19 |     pub fn new<F>(future: F) -> Self
   |            --- required by a bound in this associated function
20 |     where
21 |         F: Future<Output = T> + Send + 'static,
   |                                 ^^^^ required by this bound in `ReusableBoxFuture::<T>::new`

if !has_impl {

candidates.vec.push(AutoImplCandidate)

}

}

Contributor

ah, this is wrong for opaque types sweat_smile we need to always emit consider AutoImplCandidates for them if they don't also have a ProjectionCandidate. This is a bit of a mess in the old solver.

The issue is that we consider all impls to potentially apply for opaque types, but we should instead actually leak their underlying type and check whether it implements the auto trait

cc @compiler-errors given that we've recently talked about auto traits and opaques :>

Ddystopia reacted with heart emoji

Contributor

@bors try

Contributor

hourglass Trying commit 2cc873f with merge d48499c...

Contributor

sunny Try build successful - checks-actions
Build commit: d48499c (d48499c087dc9ccf49e58dd584b2df4a2c08657c)

1 similar comment

Contributor

@craterbot check

Collaborator

ok_hand Experiment pr-113312 created and queued.
robot Automatically detected try build d48499c
mag You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

craterbot

added S-waiting-on-crater Status: Waiting on a crater run to be completed.

and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jul 4, 2023

rfcbot

added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised.

and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.

labels

Jul 18, 2023

bellThis is now entering its final comment period, as per the review above. 🔔

rfcbot

added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting

and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised.

labels

Jul 28, 2023

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

Contributor

can you change the description of SUSPICIOUS_AUTO_TRAIT_IMPLS to "the rules governing auto traits have recently changed resulting in potential breakage". I think we then want to remove this lint after 1 or 2 more versions. Also change the description to talk about "previously unsound" and "have been recently modified". "This change caused".

r=me after that

@bors rollup=never
@bors delegate+

Contributor

v@Ddystopia, you can now approve this pull request!

If @lcnr told you to "r=me" after making some further change, please make that change, then do @bors r=@lcnr

Contributor

Author

lcnr reacted with thumbs up emoji

Contributor

📌 Commit 3715934 has been approved by lcnr

It is now in the queue for this repository.

bors

added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Jul 28, 2023

Contributor

hourglass Testing commit 3715934 with merge e4c98ca...

Contributor

sunny Test successful - checks-actions
Approved by: lcnr
Pushing e4c98ca to master...

bors

added the merged-by-bors This PR was explicitly merged by bors label

Jul 28, 2023

bors

merged commit e4c98ca into

rust-lang:master

Jul 28, 2023

12 checks passed

Member

There's an empty file, impl-trait/auto-trait-leak. That looks like an accident?

lcnr and Ddystopia reacted with thumbs up emoji

struct Foo<T, U>(Always<T, U>);

trait False {}

unsafe impl<U: False> Send for Foo<u32, U> {}

This would be worth a comment explaining what is being tested: that the manual impl Send for Foo should "block" the implicit impl

Contributor

Not sure how much explanation makes sense here, though a "Tests that we don't incorrectly allow overlap between a builtin auto trait impl and a user written one. See #83857 for more details." would be good here.

Contributor

@Ddystopia are you up to open a PR here? otherwise I can do it next week

Contributor

Author

@Ddystopia are you up to open a PR here? otherwise I can do it next week

Yes, sure

Collaborator

Finished benchmarking commit (e4c98ca): comparison URL.

Overall result: x regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions x
(primary)
- - 0
Regressions x
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements white_check_mark
(primary)
- - 0
Improvements white_check_mark
(secondary)
- - 0
All xwhite_check_mark (primary) - - 0

Max RSS (memory usage)

Results

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 651.183s -> 651.8s (0.09%)

This comment was marked as spam.

apiraino

removed the to-announce Announce this issue on triage meeting label

Aug 4, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

RalfJung

RalfJung left review comments

lcnr

lcnr left review comments
Assignees

lcnr

Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects

None yet

Milestone

1.73.0

Development

Successfully merging this pull request may close these issues.

None yet

12 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK