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

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

Closed
pnkfelix opened this Issue Mar 26, 2014 · 2 comments

Comments

Projects
None yet
4 participants
@pnkfelix
Member

pnkfelix commented Mar 26, 2014

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.

@gkoz

This comment has been minimized.

Show comment
Hide comment
@gkoz

gkoz Feb 2, 2016

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;
}
Contributor

gkoz commented Feb 2, 2016

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;
}
@Mark-Simulacrum

This comment has been minimized.

Show comment
Hide comment
@Mark-Simulacrum

Mark-Simulacrum May 30, 2017

Member

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

Member

Mark-Simulacrum commented May 30, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment