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

Check that trait is exported or public before adding hint #62696

Merged
merged 2 commits into from
Jul 18, 2019
Merged

Check that trait is exported or public before adding hint #62696

merged 2 commits into from
Jul 18, 2019

Conversation

fmckeogh
Copy link
Member

Closes #62194.

This PR checks the AccessLevels of a trait to check whether adding the intercrate ambiguity hint is valid or not.

I am unsure of both the use of .unwrap() as well as removing hints for [downstream and upstream.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 15, 2019
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you verify that there's at least one test with the note being emitted? (A quick search in my local repo showed that there might be 16 others, but I'd like confirmation.)

for cause in &overlap.intercrate_ambiguity_causes {
cause.add_intercrate_ambiguity_hint(&mut err);
let access_levels = tcx.privacy_access_levels(impl_def_id.krate);
let id = tcx.hir().as_local_hir_id(impl_def_id).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use if let Some(id) = instead of unwrap(). Every unwrap is a potential ICE.

Copy link
Member Author

@fmckeogh fmckeogh Jul 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, should I also fix the other two .unwrap()s in the specialization_graph_provider function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave them for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are both fine to leave as-is (they can never fail, if they do, an ICE is appropriate). They could be turned into .expect with an explanation, but that's not that important (finding the source of the would-be ICEs would be easy even without).

@fmckeogh
Copy link
Member Author

Can you verify that there's at least one test with the note being emitted? (A quick search in my local repo showed that there might be 16 others, but I'd like confirmation.)

coherence-projection-conflict-orphan is correctly emitting the note (pub trait Foo<P>), as well as coherence-overlap-upstream-inherent for use of pub trait Remote.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 16, 2019

📌 Commit 3c11944 has been approved by estebank

@bors 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 16, 2019
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 18, 2019
Check that trait is exported or public before adding hint

Closes rust-lang#62194.

This PR checks the `AccessLevels` of a trait to check whether adding the intercrate ambiguity hint is valid or not.

I am unsure of both the use of `.unwrap()` as well as removing hints for [downstream *and* [upstream](https://github.com/rust-lang/rust/blob/92b0f52584c9375505ecdefdd7855b93a5919d51/src/librustc/traits/select.rs#L112-L142).
bors added a commit that referenced this pull request Jul 18, 2019
Rollup of 15 pull requests

Successful merges:

 - #61926 (Fix hyperlinks in From impls between Vec and VecDeque)
 - #62615 ( Only error about MSVC + PGO + unwind if we're generating code)
 - #62696 (Check that trait is exported or public before adding hint)
 - #62712 (Update the help message on error for self type)
 - #62728 (Fix repeated wording in slice documentation)
 - #62730 (Consolidate hygiene tests)
 - #62732 (Remove last use of mem::uninitialized from std::io::util)
 - #62740 (Add missing link to Infallible in TryFrom doc)
 - #62745 (update data_layout and features for armv7-wrs-vxworks)
 - #62749 (Document link_section arbitrary bytes)
 - #62752 (Disable Z3 in LLVM build)
 - #62764 (normalize use of backticks in compiler messages for librustc/lint)
 - #62774 (Disable simd_select_bitmask test on big endian)
 - #62777 (Self-referencial type now called a recursive type)
 - #62778 (Emit artifact notifications for dependency files)

Failed merges:

 - #62746 ( do not use mem::uninitialized in std::io)

r? @ghost
@bors bors merged commit 3c11944 into rust-lang:master Jul 18, 2019
@fmckeogh fmckeogh deleted the fix_#62194 branch July 19, 2019 05:33
arielb1 added a commit to arielb1/rust that referenced this pull request Aug 3, 2019
I think that PR is a problem (rust-lang#63145), but this makes the tests green for now.
arielb1 added a commit to arielb1/rust that referenced this pull request Aug 4, 2019
…ebank"

This reverts commit df21a6f, reversing
changes made to cc16d04.
Centril added a commit to Centril/rust that referenced this pull request Aug 5, 2019
…rors, r=estebank

Revert "Rollup merge of rust-lang#62696 - chocol4te:fix_#62194, r=estebank"

This reverts commit df21a6f (rust-lang#62696), reversing
changes made to cc16d04.

That PR makes error messages worse than before, and we couldn't come up with a way of actually making them better, so revert it for now. Any idea for making this error message better is welcome!

Fixes rust-lang#63145.

r? @estebank
Centril added a commit to Centril/rust that referenced this pull request Aug 6, 2019
…rors, r=estebank

Revert "Rollup merge of rust-lang#62696 - chocol4te:fix_#62194, r=estebank"

This reverts commit df21a6f (rust-lang#62696), reversing
changes made to cc16d04.

That PR makes error messages worse than before, and we couldn't come up with a way of actually making them better, so revert it for now. Any idea for making this error message better is welcome!

Fixes rust-lang#63145.

r? @estebank
Centril added a commit to Centril/rust that referenced this pull request Aug 6, 2019
…rors, r=estebank

Revert "Rollup merge of rust-lang#62696 - chocol4te:fix_#62194, r=estebank"

This reverts commit df21a6f (rust-lang#62696), reversing
changes made to cc16d04.

That PR makes error messages worse than before, and we couldn't come up with a way of actually making them better, so revert it for now. Any idea for making this error message better is welcome!

Fixes rust-lang#63145.

r? @estebank
Centril added a commit to Centril/rust that referenced this pull request Aug 6, 2019
…rors, r=estebank

Revert "Rollup merge of rust-lang#62696 - chocol4te:fix_#62194, r=estebank"

This reverts commit df21a6f (rust-lang#62696), reversing
changes made to cc16d04.

That PR makes error messages worse than before, and we couldn't come up with a way of actually making them better, so revert it for now. Any idea for making this error message better is welcome!

Fixes rust-lang#63145.

r? @estebank
bors added a commit that referenced this pull request Aug 6, 2019
Rollup of 14 pull requests

Successful merges:

 - #61457 (Implement DoubleEndedIterator for iter::{StepBy, Peekable, Take})
 - #63017 (Remove special code-path for handing unknown tokens)
 - #63184 (Explaining the reason why validation is performed in to_str of path.rs)
 - #63230 (Make use of possibly uninitialized data [E0381] a hard error)
 - #63260 (fix UB in a test)
 - #63264 (Revert "Rollup merge of #62696 - chocol4te:fix_#62194, r=estebank")
 - #63272 (Some more libsyntax::attr cleanup)
 - #63285 (Remove leftover AwaitOrigin)
 - #63287 (Don't store &Span)
 - #63293 (Clarify align_to's requirements and obligations)
 - #63295 (improve align_offset docs)
 - #63299 (Make qualify consts in_projection use PlaceRef)
 - #63312 (doc: fix broken sentence)
 - #63315 (Fix #63313)

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coherence hint wrong for a blanked implementation bounded by a private trait
5 participants