Skip to content

Conversation

@chenyukang
Copy link
Member

@chenyukang chenyukang commented Nov 6, 2025

Fixes #148439

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 6, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-148439-env branch 2 times, most recently from 48c2fbb to 1f8b6da Compare November 6, 2025 04:14
Comment on lines +187 to +189
const KNOWN_CARGO_VARS: &[&str] = &[
// List of known Cargo environment variables that are set for crates (not build scripts, OUT_DIR etc).
// See: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion (non-blocking): I have two reservations about making this suggestion:

  1. Wouldn't this depend on the specific cargo version?
  2. Basically, what I was trying to get at, is that in principle I feel like rustc should not make assumptions about cargo (that is, rustc should not "know" about cargo's existence), because cargo isn't the only way to invoke rustc.

I guess I could be convinced by "well, most users do build with cargo", so don't consider this a hard-blocking concern.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm not sure, there is a similar list for this in rust-analyzer: https://github.com/chenyukang/rust/blob/702bf000a0b5062d8b5ced717a26d70919df6ba0/src/tools/rust-analyzer/crates/project-model/src/env.rs#L9-L49 , I guess there is a better and general way to keep it synced.
  2. I agree rustc should not knowing details about cargo, I think it's ok since we need to check the prefix with CARGO_ of env:
    https://github.com/rust-lang/rust/pull/148559/files#diff-0eaa1095d59f2f3d9c015005d15fd8f7cda13121a8404d77b2955fc5fcd40449R213, and it's a note but not code suggestions, it's maybe incorrect for rare scenarios.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems alright, was just curious to hear what you think.

@chenyukang chenyukang force-pushed the yukang-fix-148439-env branch from 1f8b6da to ad471f4 Compare November 6, 2025 09:44
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@Kivooeo Kivooeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenyukang chenyukang force-pushed the yukang-fix-148439-env branch from ad471f4 to 760e803 Compare November 6, 2025 12:13
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-148439-env branch from 760e803 to 553d580 Compare November 6, 2025 12:24
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-148439-env branch from 553d580 to 3edd25f Compare November 6, 2025 15:11
@Kivooeo
Copy link
Member

Kivooeo commented Nov 6, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 6, 2025

📌 Commit 3edd25f has been approved by Kivooeo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading suggestion when using env!() on a misspelt Cargo environment variable

8 participants