Skip to content

Commit 92154f7

Browse files
authored
Update to nightly-2025-08-20 (#40)
* Update to nightly-2025-04-01 * Update to nightly-2025-05-01 * Fix clippy * Update to 2025-06-01 * Fix handling of field_tys * Update to nightly-2025-07-01 * Update to nightly-2025-08-01 * Fix doc link * Upgrade to 2025-08-20
1 parent da8896e commit 92154f7

File tree

21 files changed

+91
-84
lines changed

21 files changed

+91
-84
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
The Rust compiler's interface is not stable, so the only sensible way to develop a Rust compiler plugin is by pinning to a specific nightly. Each version of `rustc_plugin` is pinned to one nightly, and you *have* to use the same nightly version that we do. Therefore each release of `rustc_plugin` has a semantic version number (e.g. `0.1.0`) and the nightly version is added as a prerelease label (e.g. `-nightly-2023-08-25`). You can add a dependency to your `Cargo.toml` like this:
1212

1313
```toml
14-
rustc_plugin = "=0.13.0-nightly-2025-03-03"
14+
rustc_plugin = "=0.14.0-nightly-2025-08-20"
1515
```
1616

1717
We will treat a change to the nightly version as a breaking change, so the semantic version will be correspondingly updated as a breaking update.
@@ -44,6 +44,7 @@ The `rustc_plugin` framework is responsible for marshalling arguments from the t
4444

4545
Normally, Rust libraries have a [minimum supported Rust version][msrv] because they promise to not use any breaking features implemented after that version. Rust compiler plugins are the opposite — they have a **maximum** supported Rust version (MaxSRV). A compiler plugin cannot analyze programs that use features implemented after the release date of the plugin's toolchain. The MaxSRV for every version of `rustc_plugin` is listed below:
4646

47+
* v0.14 (`nightly-2025-08-20`) - rustc 1.87
4748
* v0.13 (`nightly-2025-03-03`) - rustc 1.86
4849
* v0.12 (`nightly-2024-12-15`) - rustc 1.84
4950
* v0.11 (`nightly-2024-12-01`) - rustc 1.84
@@ -60,6 +61,6 @@ Normally, Rust libraries have a [minimum supported Rust version][msrv] because t
6061
[Argus]: https://github.com/cognitive-engineering-lab/argus
6162
[Clippy]: https://github.com/rust-lang/rust-clippy
6263
[example]: https://github.com/cognitive-engineering-lab/rustc_plugin/tree/main/crates/rustc_plugin/examples/print-all-items
63-
[docs]: https://cognitive-engineering-lab.github.io/rustc_plugin/v0.13.0-nightly-2025-03-03/rustc_plugin/
64-
[docs-utils]: https://cognitive-engineering-lab.github.io/rustc_plugin/v0.13.0-nightly-2025-03-03/rustc_utils/
64+
[docs]: https://cognitive-engineering-lab.github.io/rustc_plugin/v0.14.0-nightly-2025-08-20/rustc_plugin/
65+
[docs-utils]: https://cognitive-engineering-lab.github.io/rustc_plugin/v0.14.0-nightly-2025-08-20/rustc_utils/
6566
[msrv]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field

crates/rustc_plugin/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_plugin"
3-
version = "0.13.0-nightly-2025-03-03"
4-
edition = "2021"
3+
version = "0.14.0-nightly-2025-08-20"
4+
edition = "2024"
55
authors = ["Will Crichton <crichton.will@gmail.com>"]
66
description = "A framework for writing plugins that integrate with the Rust compiler"
77
repository = "https://github.com/cognitive-engineering-lab/rustc_plugin"
@@ -18,7 +18,7 @@ serde = "1"
1818
serde_json = "1"
1919

2020
[dev-dependencies]
21-
anyhow = {version = "1", features = ["backtrace"]}
21+
anyhow = { version = "1", features = ["backtrace"] }
2222

2323
[build-dependencies]
2424
toml = "0.7"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "print-all-items"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[package.metadata.rust-analyzer]
77
rustc_private = true
88

99
[dependencies]
1010
rustc_plugin = { path = "../.." }
11-
env_logger = {version = "0.10", default-features = false}
12-
clap = {version = "4.4", features = ["derive"]}
13-
serde = {version = "1", features = ["derive"]}
11+
env_logger = { version = "0.10", default-features = false }
12+
clap = { version = "4.4", features = ["derive"] }
13+
serde = { version = "1", features = ["derive"] }

crates/rustc_plugin/examples/print-all-items/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cargo print-all-items
1515
You should see the output:
1616

1717
```text
18-
There is an item "" of type "`use` import"
1918
There is an item "std" of type "extern crate"
19+
There is an item of type "import"
2020
There is an item "add" of type "function"
21-
```
21+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-03-02"
2+
channel = "nightly-2025-08-20"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

crates/rustc_plugin/examples/print-all-items/src/lib.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::{borrow::Cow, env, process::Command};
1212

1313
use clap::Parser;
1414
use rustc_hir::{
15-
intravisit::{self, Visitor},
1615
Item,
16+
intravisit::{self, Visitor},
1717
};
1818
use rustc_middle::ty::TyCtxt;
1919
use rustc_plugin::{CrateFilter, RustcPlugin, RustcPluginArgs, Utf8Path};
@@ -25,7 +25,7 @@ pub struct PrintAllItemsPlugin;
2525

2626
// To parse CLI arguments, we use Clap for this example. But that
2727
// detail is up to you.
28-
#[derive(Parser, Serialize, Deserialize)]
28+
#[derive(Parser, Serialize, Deserialize, Clone)]
2929
pub struct PrintAllItemsPluginArgs {
3030
#[arg(short, long)]
3131
allcaps: bool,
@@ -102,20 +102,28 @@ impl rustc_driver::Callbacks for PrintAllItemsCallbacks {
102102
// I recommend reading the Rustc Development Guide to better understand which compiler APIs
103103
// are relevant to whatever task you have.
104104
fn print_all_items(tcx: TyCtxt, args: PrintAllItemsPluginArgs) {
105-
tcx.hir_visit_all_item_likes_in_crate(&mut PrintVisitor { args });
105+
tcx.hir_visit_all_item_likes_in_crate(&mut PrintVisitor { args, tcx });
106106
}
107107

108-
struct PrintVisitor {
108+
struct PrintVisitor<'tcx> {
109109
args: PrintAllItemsPluginArgs,
110+
tcx: TyCtxt<'tcx>,
110111
}
111112

112-
impl Visitor<'_> for PrintVisitor {
113-
fn visit_item(&mut self, item: &Item) -> Self::Result {
114-
let mut msg = format!(
115-
"There is an item \"{}\" of type \"{}\"",
116-
item.ident,
117-
item.kind.descr()
118-
);
113+
impl<'tcx> Visitor<'tcx> for PrintVisitor<'tcx> {
114+
fn visit_item(&mut self, item: &'tcx Item<'tcx>) -> Self::Result {
115+
let mut msg = if let Some(ident) = item.kind.ident() {
116+
format!(
117+
"There is an item \"{}\" of type \"{}\"",
118+
ident,
119+
self.tcx.def_descr(item.owner_id.to_def_id())
120+
)
121+
} else {
122+
format!(
123+
"There is an item of type \"{}\"",
124+
self.tcx.def_descr(item.owner_id.to_def_id())
125+
)
126+
};
119127
if self.args.allcaps {
120128
msg = msg.to_uppercase();
121129
}

crates/rustc_plugin/examples/print-all-items/test-crate/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "test-crate"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

crates/rustc_plugin/src/cli.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::{
22
env, fs,
33
path::PathBuf,
4-
process::{exit, Command, Stdio},
4+
process::{Command, Stdio, exit},
55
};
66

77
use cargo_metadata::camino::Utf8Path;
88

9-
use super::plugin::{RustcPlugin, PLUGIN_ARGS};
9+
use super::plugin::{PLUGIN_ARGS, RustcPlugin};
1010
use crate::CrateFilter;
1111

1212
pub const RUN_ON_ALL_CRATES: &str = "RUSTC_PLUGIN_ALL_TARGETS";
@@ -193,10 +193,10 @@ fn only_run_on_file(
193193
let prefix = format!("lib{}", pkg.name.replace('-', "_"));
194194
for entry in entries {
195195
let path = entry.unwrap().path();
196-
if let Some(file_name) = path.file_name() {
197-
if file_name.to_string_lossy().starts_with(&prefix) {
198-
fs::remove_file(path).unwrap();
199-
}
196+
if let Some(file_name) = path.file_name()
197+
&& file_name.to_string_lossy().starts_with(&prefix)
198+
{
199+
fs::remove_file(path).unwrap();
200200
}
201201
}
202202
}

crates/rustc_plugin/tests/workspaces/basic/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "basic"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

crates/rustc_plugin/tests/workspaces/multi/a/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "a"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

0 commit comments

Comments
 (0)