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

'extern mod foo(name = "bar")' is not equivalent to 'extern mod foo = "bar"' #10265

Closed
tautologico opened this issue Nov 4, 2013 · 1 comment · Fixed by #10368
Closed

'extern mod foo(name = "bar")' is not equivalent to 'extern mod foo = "bar"' #10265

tautologico opened this issue Nov 4, 2013 · 1 comment · Fixed by #10368

Comments

@tautologico
Copy link
Contributor

I'm trying to tackle #9543 but under the impression that 'extern mod foo(name = "bar")' should be equivalent to 'extern mod foo = "bar"'. After trying to change occurrences of the first form, I noticed rustc does not treat them equally. A minimal test shows this easily:

// world.rs
#[link(name = "world", vers="1.0")];
pub fn explore() -> &str { "world" }

This is used by

// main.rs
extern mod w(name = "world");
fn main() {
    println("hello " + w::explore());
}

And it all works if I compile world.rs as a lib and then compile main.rs passing -L . to rustc. If I change the first line in main.rs to extern mod w = "world", it does not work ("can't find crate for 'w')".

While trying to find out if the two forms should be equivalent I looked at view items in the manual; by the specification there maybe the two forms are not meant to be equivalent, but I was informed on IRC that this is probably a rustc bug, so I'm filing it.

@tautologico
Copy link
Contributor Author

After some investigation, I found out that the 'extern mod foo(name="bar")' form creates a view item with attached metaitem having key "name" and value "bar". The 'extern mod foo = "bar"' form creates a view item with two metaitems, one with key "name" and value "bar", and other with key "package_id" and also value "bar". This happens in rustc::metadata::creader, function visit_view_item, and it appends the whole path as package_id and only the filestem as name, but in this case both are equal. So in rustc::metadata::loader, find_library_crate_aux finds the crate to load but metadata_matches requires the "package_id" metaitem to be present in the "bar" crate.

I confirmed this with my above example by adding 'package_id="world"' item in the link attribute above (world.rs), and it worked even with 'extern mod w = "world"' in main.rs.

So this amounts to the "package_id" being mandatory in external crates.

@bors bors closed this as completed in 4f68d13 Nov 9, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 10, 2023
…=Alexendoo

Mark uninlined_format_args as pedantic

Fixes rust-lang/rust-clippy#10087

We should restore this when rust-analyzer support gets better. Worth filing an issue to track.

changelog: Mark [`uninlined_format_args`] as `pedantic`
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