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

compiletest: we should not allow revision names that collide with builtin cfg names #128964

Closed
jieyouxu opened this issue Aug 11, 2024 · 2 comments · Fixed by #131930
Closed

compiletest: we should not allow revision names that collide with builtin cfg names #128964

jieyouxu opened this issue Aug 11, 2024 · 2 comments · Fixed by #131930
Labels
A-compiletest Area: The compiletest test runner C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jieyouxu
Copy link
Member

Example: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/error.3A.20unexpected.20.60--cfg.20windows.60.20flag/near/459869068

--- stderr -------------------------------
error: unexpected `--cfg windows` flag
  |
  = note: config `windows` is only supposed to be controlled by `--target`
  = note: manually setting a built-in cfg can and does create incoherent behaviors
  = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default

error: aborting due to 1 previous error

compiletest will try to set a --cfg <revision_name> that matches the revision name, but this goes poorly if the <revision_name> collides with a builtin cfg. Builtin cfgs can be found at

pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
, but we should also deny test revision name because it has special meaning cfg(test).

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-compiletest Area: The compiletest test runner labels Aug 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 11, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 11, 2024
@Urgau
Copy link
Member

Urgau commented Aug 11, 2024

This could (and should IMO) be accomplished using the (currently unstable) --print=check-cfg option, which list all the well known cfgs.

@jieyouxu jieyouxu added E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 17, 2024
@heysujal
Copy link

heysujal commented Oct 19, 2024

Hi, I would like to work on this issue and will be going through the contribution docs. I don't have prior experience using Rust so I will be a good motivation for me to learn rust.

@bors bors closed this as completed in f7f411d Oct 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 24, 2024
Rollup merge of rust-lang#131930 - clubby789:revision-cfg-collide, r=jieyouxu

Don't allow test revisions that conflict with built in cfgs

Fixes rust-lang#128964

Sorry `@heysujal` I started working on this about 1 minute before your comment by complete coincidence 😅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
Development

Successfully merging a pull request may close this issue.

4 participants