Skip to content

Commit fb546ee

Browse files
committed
Auto merge of #135173 - pietroalbini:pa-fix-rvp, r=workingjubilee
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`
2 parents 6f2ca60 + 80cdaea commit fb546ee

File tree

2 files changed

+7
-7
lines changed
  • compiler/rustc_attr_data_structures/src
  • src/tools/replace-version-placeholder/src

2 files changed

+7
-7
lines changed

compiler/rustc_attr_data_structures/src/stability.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ use crate::RustcVersion;
99
/// `since` field of the `#[stable]` attribute.
1010
///
1111
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
12-
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
12+
pub const VERSION_PLACEHOLDER: &str = concat!("CURRENT_RUSTC_VERSIO", "N");
13+
// Note that the `concat!` macro above prevents `src/tools/replace-version-placeholder` from
14+
// replacing the constant with the current version. Hardcoding the tool to skip this file doesn't
15+
// work as the file can (and at some point will) be moved around.
16+
//
17+
// Turning the `concat!` macro into a string literal will make Pietro cry. That'd be sad :(
1318

1419
/// Represents the following attributes:
1520
///

src/tools/replace-version-placeholder/src/main.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ fn main() {
1111
let version_str = version_str.trim();
1212
walk::walk_many(
1313
&[&root_path.join("compiler"), &root_path.join("library")],
14-
|path, _is_dir| {
15-
walk::filter_dirs(path)
16-
// We exempt these as they require the placeholder
17-
// for their operation
18-
|| path.ends_with("compiler/rustc_attr/src/builtin.rs")
19-
},
14+
|path, _is_dir| walk::filter_dirs(path),
2015
&mut |entry, contents| {
2116
if !contents.contains(VERSION_PLACEHOLDER) {
2217
return;

0 commit comments

Comments
 (0)