-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
compiletest: Make aux-crate directive explicitly handle --extern modifiers
#151353
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
base: main
Are you sure you want to change the base?
Conversation
|
Some changes occurred in src/tools/compiletest cc @jieyouxu |
|
Ah, so we're talking about these?
“Options” seems like a needlessly confusing term to have been used on that unstable-book page; calling them “modifiers” (as the tracking issue does) is a lot clearer. |
| /// With `aux-crate: noprelude:foo=bar.rs` this will be `noprelude`. | ||
| pub extern_opts: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we should ignore the unstable book and the compiler source, and call these “extern modifiers” instead.
- This field comment really needs to give a brief explanation of what extern modifiers actually are, perhaps with a link to the tracking issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree "extern modifiers" is a better name than "extern options". I added some more info and linked to the tracking issue. I don't think we should give too many details though since we don't want that comment to become outdated soon.
I also added references this functionality in the rustc-dev-guide.
| let opts_and_name = parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(); | ||
| let path = parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(); | ||
| let (opts, name) = match opts_and_name.split_once(':') { | ||
| None => (None, opts_and_name), | ||
| Some((opts, name)) => (Some(opts.to_string()), name.to_string()), | ||
| }; | ||
| AuxCrate { extern_opts: opts, name, path } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parsing step is getting complex enough that a regex might be an improvement. Seems worth a try at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried porting it to a regex but didn't think it ended up being easier to understand, so I kept it as is. I hope that's OK. The diff is small at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent some more time on it and found a way to use a regex that I like. Hopefully you'll like it too.
|
We should also mention |
|
The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. |
5028acf to
41c6301
Compare
aux-crate directive explicitly handle --extern optionsaux-crate directive explicitly handle --extern modifiers
…modifiers To make it clearer what happens. In other words, do not silently keep modifiers as part of `AuxCrate::name`.
41c6301 to
8d3e25a
Compare
With
-Zunstable-optionsit is possible to pass options to--extern. See here for an exhaustive list of possible options:rust/compiler/rustc_session/src/config.rs
Lines 2356 to 2367 in b5dd72d
Using these options works with the
aux-cratedirective, but only because the options pretend to be part of the name. Make it clearer whataux-cratesupports by explicitly handling--externoptions.This PR is step one of splitting up #151258 into smaller pieces.
r? @Zalathar