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

Confusing/incorrect error messages with respect to visibility and traits #8592

Closed
SiegeLord opened this issue Aug 18, 2013 · 0 comments · Fixed by #9432
Closed

Confusing/incorrect error messages with respect to visibility and traits #8592

SiegeLord opened this issue Aug 18, 2013 · 0 comments · Fixed by #9432

Comments

@SiegeLord
Copy link
Contributor

There are two sets of problematic messages here. First, take this code:

struct S;

trait A
{
    priv fn foo(); // Error 1
}

priv impl S // Error 2
{

}

priv impl A for S // Error 3
{
    priv fn foo() {} // Error 4
}

All of the marked lines give this error:

error: obsolete syntax: `priv` not necessary
note: an item without a visibility qualifier is private by default

This is wrong in all those cases, as the said items are not private by default. In case of Error 1, the visibility is set by the visibility of the trait. In case of Error 2, there's no such thing as a private implementation, you're meant to put visibility on individual functions. In case of Error 3 there's no such thing as a private implementation of a trait, but unlike Error 2 you're not allowed to put visibility on individual functions as the visibility is inherited from the implemented trait. Error 4, thus, is also wrong. Obviously if the priv keyword goes (#8122) then these are invalidated.

The other problematic error comes from this code:

struct S;
trait A
{
    fn foo();
}

pub impl A for S // Error 5
{

}

The error text:

error: obsolete syntax: visibility-qualified implementation
note: `pub` or `priv` goes on individual functions; remove the `pub` or `priv`

This is not correct, as you're not allowed to put it on the individual functions either.

bors added a commit that referenced this issue Sep 25, 2013
…walton

This fixes private statics and functions from being usable cross-crates, along
with some bad privacy error messages. This is a reopening of #8365 with all the
privacy checks in privacy.rs instead of resolve.rs (where they should be
anyway).

These maps of exported items will hopefully get used for generating
documentation by rustdoc

Closes #8592
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 7, 2022
Do not fire `panic` in a constant environment

Let rustc handle panics in constant environments.

Since rust-lang/rust-clippy#8348 I thought that such modification would require a lot of work but thanks to rust-lang/rust-clippy#8588 I now know that it is not the case.

changelog: [`panic`]: No longer lint in constant context. `rustc` already handles this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant