Skip to content

path attribute is silently accepted and ignored for inline mod items. #13156

Closed

Description

@pnkfelix

Consider the following program p.rs:

#[path="q.rs"] mod q {
    pub fn q_main() { println!("Hello World"); }
}

fn main() { q::q_main() }

I don't know if this is considered a bug or a feature, but we should probably emit a warning when we encounter that useless path attribute attached to q above.

Activity

  1. gkoz commented on Feb 2, 2016

    @gkoz
    Contributor

    Doesn't seem useless to me. The reference gives this seemingly reasonable example:

    The directories and files used for loading external file modules can be influenced with the path attribute.

    #[path = "thread_files"]
    mod thread {
        // Load the `local_data` module from `thread_files/tls.rs`
        #[path = "tls.rs"]
        mod local_data;
    }

    Now suppose you're in a build script and want to include src/tls.rs. Is there a better way than

    // This module hides some optional stuff
    #[cfg(foo_bar)]
    #[path = ""]
    mod thread {
        #[path = "src/tls.rs"]
        mod local_data;
    }
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 9, 2017
  3. Mark-Simulacrum commented on May 30, 2017

    @Mark-Simulacrum
    Member

    Yeah, to my knowledge this is expected and intentional behavior; closing.

  4. added a commit that references this issue on Sep 6, 2022
  5. added a commit that references this issue on Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions