Open
Description
Code
// Compile with edition 2018 or later
mod foo {
pub(in parent) fn bar() {
println!("hello from bar");
}
}
fn main() {
bar();
}
Current output
error: relative paths are not supported in visibilities in 2018 edition or later
--> src/lib.rs:2:12
|
2 | pub(in parent) fn bar() {
| ^^^^^^ help: try: `crate::parent`
Desired output
error: relative paths are not supported in visibilities in 2018 edition or later
--> src/lib.rs:2:12
|
2 | pub(in parent) fn bar() {
| ^^^^^^ help: try: `crate::parent`
| ^^^^^^^^ help: did you mean? `super`
Rationale and extra context
If the programmer wrote pub(in parent)
and there is no module named parent
in the crate (at the location where edition 2015 would have resolved the path), it is likely that what they were actually trying to do is make the item visible to "the parent module", which is properly spelled super
.
It would also probably be helpful to refer the programmer to https://doc.rust-lang.org/reference/visibility-and-privacy.html#pubin-path-pubcrate-pubsuper-and-pubself either directly or via --explain
.
Note also that this error is missing an E-code (and therefore there is nothing to use --explain
on).