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

Non-ASCII Crate IDs do not work #13412

Closed
lilyball opened this issue Apr 8, 2014 · 4 comments
Closed

Non-ASCII Crate IDs do not work #13412

lilyball opened this issue Apr 8, 2014 · 4 comments

Comments

@lilyball
Copy link
Contributor

lilyball commented Apr 8, 2014

Right now we can create crates with non-ASCII names, and they compile just fine, but we can't seem to link against them. I've reproduced this problem on both OS X and Linux, so I'm pretty sure it's not a filename issue. It also doesn't seem to matter if the crate ID is using decomposed or composed characters (or characters that only have one form).

We already have a feature gate for non_ascii_idents, it seems reasonable that we should feature-gate having non-ascii crate IDs as well (both implicit IDs taken from the filename, and explicit ones specified with the attribute). I don't believe we need to test any clients of such crates (using the extern crate foo = "fℇℇ#0.0" syntax, as extern crate fℇℇ already hits non_ascii_idents) because using the crate is already broken, and fixing it will not have any compatibility issues.

Example:

foo.rs:

#![crate_id="fℇℇ#0.0"]
#![crate_type="rlib"]

pub fn foo() { println!("foo"); }

main.rs:

extern crate foo = "fℇℇ#0.0";

fn main() {
    foo::foo();
}

Compiling foo.rs works just fine, but compiling main.rs errors:

main.rs:1:1: 1:30 error: can't find crate for `foo`
main.rs:1 extern crate foo = "fℇℇ#0.0";
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@lilyball
Copy link
Contributor Author

lilyball commented Apr 8, 2014

Related to #2253.

@alexcrichton
Copy link
Member

Hm, something funny with the encoding might be happening. I copy-and-pasted the code from this page and it worked on both OSX and linux. What's the output you get with RUST_LOG=rustc::metadata::loader?

@lilyball
Copy link
Contributor Author

lilyball commented Apr 9, 2014

@alexcrichton My rustc is only 2 days old. I can try updating, but I didn't think there were any relevant changes recently.

That log provides nothing interesting. The very first reference to either "foo" or "fℇℇ" is the error

main.rs:1:1: 1:30 error: can't find crate for `foo`
main.rs:1 extern crate foo = "fℇℇ#0.0";
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

This is emitted immediately after it successfully reads libnative-83574243-0.11-pre.dylib.

@lilyball
Copy link
Contributor Author

lilyball commented Apr 9, 2014

Aaand now I feel like a fool. I forgot -L .. Sigh.

Maybe rustc should suggest adding -L . if it can't find a crate, but the current directory contains a viable candidate?

@lilyball lilyball closed this as completed Apr 9, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 18, 2024
Implement lint for regex::Regex compilation inside a loop

Closes rust-lang#598.

Seems like a pretty simple one, I'm not sure if I sorted out all the lint plumbing correctly because I was adding it to the existing regex pass, but seems to work. The name is a bit jank and I'm super open to suggestions for changing it.

changelog: [`regex_creation_in_loops`]: Added lint for Regex compilation inside loops.
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

No branches or pull requests

2 participants