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

private no-mangle lints: only suggest pub if it doesn't already exist #47479

Merged

Conversation

zackmdavis
Copy link
Member

Fixes #47383 (function or static can be pub but unreachable because it's in a private module; adding another pub is nonsensical).

r? @estebank

@zackmdavis zackmdavis force-pushed the and_the_case_of_the_suggested_double-pub branch from 56520b3 to 1f2a1c2 Compare January 16, 2018 04:44
@estebank
Copy link
Contributor

r=me once the test is fixed.

@kennytm kennytm added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 16, 2018
The incompetent fool who added these suggestions in 38e5a96 apparently
thought it was safe to assume that, because the offending function or
static was unreachable, it would therefore have not have any existing
visibility modifiers, making it safe for us to unconditionally suggest
inserting `pub`. This isn't true.

This resolves rust-lang#47383.
@zackmdavis zackmdavis force-pushed the and_the_case_of_the_suggested_double-pub branch from 1f2a1c2 to 661e033 Compare January 16, 2018 08:31
@petrochenkov
Copy link
Contributor

I don't think this is a correct fix.
Until #47384 is changed this lint should be based on reachability as well.
Otherwise you'll get no_mangle items to which you can't link, but no lint is reported.

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 16, 2018
@zackmdavis
Copy link
Member Author

@petrochenkov

Until #47384 is changed this lint should be based on reachability as well. Otherwise you'll get no_mangle items to which you can't link, but no lint is reported.

I'm confused: as I understand, the lint is based on reachability (if !cx.access_levels.is_reachable( ...). This PR doesn't change that; this PR just makes it so that the lint warning doesn't additionally have a "try making it pub" suggestion span when there's already a pub. But the lint is still triggered: notice that the two #[no-mangle] pub items added to the UI test result in two more lint warnings appearing in the output.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 17, 2018

📌 Commit 661e033 has been approved by estebank

@petrochenkov
Copy link
Contributor

Ah, I see, only the help note is disabled, then it's ok.

kennytm added a commit to kennytm/rust that referenced this pull request Jan 17, 2018
…ested_double-pub, r=estebank

private no-mangle lints: only suggest `pub` if it doesn't already exist

Fixes rust-lang#47383 (function or static can be `pub` but unreachable because it's in a private module; adding another `pub` is nonsensical).

r? @estebank
kennytm added a commit to kennytm/rust that referenced this pull request Jan 17, 2018
…ested_double-pub, r=estebank

private no-mangle lints: only suggest `pub` if it doesn't already exist

Fixes rust-lang#47383 (function or static can be `pub` but unreachable because it's in a private module; adding another `pub` is nonsensical).

r? @estebank
bors added a commit that referenced this pull request Jan 17, 2018
@bors bors merged commit 661e033 into rust-lang:master Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants