-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Avoid replacing the definition of CURRENT_RUSTC_VERSION
#135173
Conversation
Before this commit, replace-version-placeholder hardcoded the path defining CURRENT_RUSTC_VERSION (to avoid replacing it). After a refactor moved the file defining it without changing the hardcoded path, the tool started replacing the constant itself with the version number. To avoid this from happening in the future, this changes the definition of the constant to avoid the tool from ever matching it.
Could not assign reviewer from: |
@@ -9,7 +9,12 @@ use crate::RustcVersion; | |||
/// `since` field of the `#[stable]` attribute. | |||
/// | |||
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591). | |||
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION"; | |||
pub const VERSION_PLACEHOLDER: &str = concat!("CURRENT_RUSTC_VERSIO", "N"); |
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.
lmao
// Note that the `concat!` macro above prevents `src/tools/replace-version-placeholder` from | ||
// replacing the constant with the current version. Hardcoding the tool to skip this file doesn't | ||
// work as the file can (and at some point will) be moved around. |
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.
lmaoooo
// replacing the constant with the current version. Hardcoding the tool to skip this file doesn't | ||
// work as the file can (and at some point will) be moved around. | ||
// | ||
// Turning the `concat!` macro into a string literal will make Pietro cry. That'd be sad :( |
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.
don't cry Pietro :(
// for their operation | ||
|| path.ends_with("compiler/rustc_attr/src/builtin.rs") | ||
}, | ||
|path, _is_dir| walk::filter_dirs(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.
oh nice, it even makes the actual code simpler.
@bors r+ p=1 |
Why not ignore the lines that contain the "VERSION_PLACEHOLDER" definition itself 🤔 |
that seems way more context-sensitive therefore fragile than just having a slightly cursed string constant |
I kinda don't want someone refactoring that variable name from accidentally regressing this, which could happen without reading the comment if someone uses the rename assist in rust-analyzer. This was a fairly painful failure to track down tbh, I don't want it to happen again. |
I was thinking of implementing something like |
I like the gross |
…bilee Avoid replacing the definition of `CURRENT_RUSTC_VERSION` Before this PR, replace-version-placeholder hardcoded the path defining CURRENT_RUSTC_VERSION (to avoid replacing it). After a refactor moved the file defining it without changing the hardcoded path, the tool started replacing the constant itself with the version number. To avoid this from happening in the future, this changes the definition of the constant to avoid the tool from ever matching it. r? `@workingjubilee`
@bors retry Yield priority to the stable release. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (fb546ee): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 3.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -3.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 764.114s -> 764.15s (0.00%) |
Before this PR, replace-version-placeholder hardcoded the path defining CURRENT_RUSTC_VERSION (to avoid replacing it). After a refactor moved the file defining it without changing the hardcoded path, the tool started replacing the constant itself with the version number.
To avoid this from happening in the future, this changes the definition of the constant to avoid the tool from ever matching it.
r? @workingjubilee