Skip to content

"could not find inline in the crate root" should say "visibilities can only be restricted to ancestor modules" #118011

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

Closed
jyn514 opened this issue Nov 17, 2023 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Nov 17, 2023

Code

; tree src
src
├── foo
│   └── b.rs
├── foo.rs
└── main.rs

; for f in src/**/*.rs; do echo "// $f"; cat $f; done
// src/foo.rs
mod b;
// src/foo/b.rs
pub (in crate::inline) fn c() {}
// src/main.rs
mod foo;

mod inline {}

fn main() {}

Current output

error[E0433]: failed to resolve: maybe a missing crate `inline`?
 --> src/foo/b.rs:1:16
  |
1 | pub (in crate::inline) fn c() {}
  |                ^^^^^^ maybe a missing crate `inline`?
  |
  = help: consider adding `extern crate inline` to use the `inline` crate

Desired output

error[E0742]: visibilities can only be restricted to ancestor modules
 --> src/foo/b.rs:1:16
  |
1 | pub (in crate::inline) fn c() {}
  |                ^^^^^^

Rationale and extra context

inline does exist, it's just not allowed to be used in pub in this context.

Other cases

Reordering mod inline {} above the mod foo declaration produces the correct suggestion:

diff --git a/src/main.rs b/src/correct.rs
index 68c1aa9..f17245f 100644
--- a/src/main.rs
+++ b/src/correct.rs
@@ -1,4 +1,4 @@
-mod foo;
 mod inline {}
+mod foo;
 
 fn main() {}

Anything else?

version: rustc 1.75.0-nightly (75b064d 2023-11-01)

@rustbot label A-resolve

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 17, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-resolve Area: Name/path resolution done by `rustc_resolve` specifically labels Nov 17, 2023
@jyn514
Copy link
Member Author

jyn514 commented Nov 17, 2023

duplicate of #40066

@jyn514 jyn514 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants