Skip to content

Commit 37f21b9

Browse files
committed
Update to nightly-2025-03-02
1 parent 2305d91 commit 37f21b9

File tree

17 files changed

+90
-90
lines changed

17 files changed

+90
-90
lines changed

crates/rustc_plugin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc_plugin"
3-
version = "0.12.0-nightly-2024-12-15"
3+
version = "0.13.0-nightly-2025-03-02"
44
edition = "2021"
55
authors = ["Will Crichton <crichton.will@gmail.com>"]
66
description = "A framework for writing plugins that integrate with the Rust compiler"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ rustc_private = true
88

99
[dependencies]
1010
rustc_plugin = { path = "../.." }
11-
env_logger = "0.10"
11+
env_logger = {version = "0.10", default-features = false}
1212
clap = {version = "4.4", features = ["derive"]}
1313
serde = {version = "1", features = ["derive"]}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-12-15"
2+
channel = "nightly-2025-03-02"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
#![feature(rustc_private)]
44

55
extern crate rustc_driver;
6+
extern crate rustc_hir;
67
extern crate rustc_interface;
78
extern crate rustc_middle;
89
extern crate rustc_session;
910

1011
use std::{borrow::Cow, env, process::Command};
1112

1213
use clap::Parser;
14+
use rustc_hir::{
15+
intravisit::{self, Visitor},
16+
Item,
17+
};
1318
use rustc_middle::ty::TyCtxt;
1419
use rustc_plugin::{CrateFilter, RustcPlugin, RustcPluginArgs, Utf8Path};
1520
use serde::{Deserialize, Serialize};
@@ -61,15 +66,16 @@ impl RustcPlugin for PrintAllItemsPlugin {
6166
compiler_args: Vec<String>,
6267
plugin_args: Self::Args,
6368
) -> rustc_interface::interface::Result<()> {
64-
let mut callbacks = PrintAllItemsCallbacks { args: plugin_args };
65-
let compiler = rustc_driver::RunCompiler::new(&compiler_args, &mut callbacks);
66-
compiler.run();
69+
let mut callbacks = PrintAllItemsCallbacks {
70+
args: Some(plugin_args),
71+
};
72+
rustc_driver::run_compiler(&compiler_args, &mut callbacks);
6773
Ok(())
6874
}
6975
}
7076

7177
struct PrintAllItemsCallbacks {
72-
args: PrintAllItemsPluginArgs,
78+
args: Option<PrintAllItemsPluginArgs>,
7379
}
7480

7581
impl rustc_driver::Callbacks for PrintAllItemsCallbacks {
@@ -82,7 +88,7 @@ impl rustc_driver::Callbacks for PrintAllItemsCallbacks {
8288
tcx: TyCtxt<'_>,
8389
) -> rustc_driver::Compilation {
8490
// We call our top-level function with access to the type context `tcx` and the CLI arguments.
85-
print_all_items(tcx, &self.args);
91+
print_all_items(tcx, self.args.take().unwrap());
8692

8793
// Note that you should generally allow compilation to continue. If
8894
// your plugin is being invoked on a dependency, then you need to ensure
@@ -92,21 +98,29 @@ impl rustc_driver::Callbacks for PrintAllItemsCallbacks {
9298
}
9399
}
94100

95-
// The core of our analysis. It doesn't do much, just access some methods on the `TyCtxt`.
101+
// The core of our analysis. Right now it just prints out a description of each item.
96102
// I recommend reading the Rustc Development Guide to better understand which compiler APIs
97103
// are relevant to whatever task you have.
98-
fn print_all_items(tcx: TyCtxt, args: &PrintAllItemsPluginArgs) {
99-
let hir = tcx.hir();
100-
for item_id in hir.items() {
101-
let item = hir.item(item_id);
104+
fn print_all_items(tcx: TyCtxt, args: PrintAllItemsPluginArgs) {
105+
tcx.hir_visit_all_item_likes_in_crate(&mut PrintVisitor { args });
106+
}
107+
108+
struct PrintVisitor {
109+
args: PrintAllItemsPluginArgs,
110+
}
111+
112+
impl Visitor<'_> for PrintVisitor {
113+
fn visit_item(&mut self, item: &Item) -> Self::Result {
102114
let mut msg = format!(
103115
"There is an item \"{}\" of type \"{}\"",
104116
item.ident,
105117
item.kind.descr()
106118
);
107-
if args.allcaps {
119+
if self.args.allcaps {
108120
msg = msg.to_uppercase();
109121
}
110122
println!("{msg}");
123+
124+
intravisit::walk_item(self, item)
111125
}
112126
}

crates/rustc_plugin/src/driver.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn driver_main<T: RustcPlugin>(plugin: T) {
152152
log::debug!("Running plugin...");
153153
let plugin_args: T::Args =
154154
serde_json::from_str(&env::var(PLUGIN_ARGS).unwrap()).unwrap();
155-
plugin.run(args, plugin_args)
155+
plugin.run(args, plugin_args).unwrap();
156156
} else {
157157
log::debug!(
158158
"Running normal Rust. Relevant variables:\
@@ -161,8 +161,7 @@ run_on_all_crates={run_on_all_crates}, \
161161
primary_package={primary_package}, \
162162
is_target_crate={is_target_crate}"
163163
);
164-
rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run();
165-
Ok(())
164+
rustc_driver::run_compiler(&args, &mut DefaultCallbacks);
166165
}
167166
}))
168167
}

crates/rustc_utils/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc_utils"
3-
version = "0.12.0-nightly-2024-12-15"
3+
version = "0.13.0-nightly-2025-03-02"
44
edition = "2021"
55
authors = ["Will Crichton <crichton.will@gmail.com>"]
66
description = "Utilities for working with the Rust compiler"
@@ -27,7 +27,7 @@ serde = {version = "1", features = ["derive"], optional = true}
2727
textwrap = {version = "0.16", optional = true}
2828
regex = {version = "1", optional = true}
2929
ts-rs = {version = "7", optional = true}
30-
indexical = {version = "0.3.1", default-features = false, features = ["rustc"], optional = true}
30+
indexical = {version = "0.7.0", default-features = false, features = ["rustc"], optional = true}
3131

3232
[dev-dependencies]
3333
rustc_utils = {path = ".", features = ["test"]}

crates/rustc_utils/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
)]
4242

4343
extern crate either;
44+
extern crate rustc_abi;
4445
extern crate rustc_borrowck;
4546
extern crate rustc_data_structures;
4647
extern crate rustc_driver;
@@ -50,6 +51,7 @@ extern crate rustc_hir;
5051
extern crate rustc_index;
5152
extern crate rustc_infer;
5253
extern crate rustc_interface;
54+
extern crate rustc_lint_defs;
5355
extern crate rustc_macros;
5456
extern crate rustc_middle;
5557
extern crate rustc_mir_dataflow;

crates/rustc_utils/src/mir/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> BodyExt<'tcx> for Body<'tcx> {
137137

138138
fn source_info_to_hir_id(&self, info: &SourceInfo) -> HirId {
139139
let scope = &self.source_scopes[info.scope];
140-
let local_data = scope.local_data.as_ref().assert_crate_local();
140+
let local_data = scope.local_data.as_ref().unwrap_crate_local();
141141
local_data.lint_root
142142
}
143143

crates/rustc_utils/src/mir/control_dependencies.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use rustc_data_structures::graph::{
1313
DirectedGraph, Predecessors, StartNode, Successors,
1414
};
1515
use rustc_index::{
16-
bit_set::{BitSet, SparseBitMatrix},
16+
bit_set::{DenseBitSet, MixedBitSet, SparseBitMatrix},
1717
Idx,
1818
};
1919
use smallvec::SmallVec;
2020

2121
struct ReversedGraph<'a, G: ControlFlowGraph> {
2222
graph: &'a G,
2323
exit: G::Node,
24-
unreachable: BitSet<G::Node>,
24+
unreachable: MixedBitSet<G::Node>,
2525
}
2626

2727
impl<G: ControlFlowGraph> DirectedGraph for ReversedGraph<'_, G> {
@@ -76,7 +76,7 @@ impl<Node: Idx> PostDominators<Node> {
7676
let mut reversed = ReversedGraph {
7777
graph,
7878
exit,
79-
unreachable: BitSet::new_empty(num_nodes),
79+
unreachable: MixedBitSet::new_empty(num_nodes),
8080
};
8181

8282
let reachable = iterate::post_order_from(&reversed, exit);
@@ -194,7 +194,7 @@ impl<Node: Idx + Ord> ControlDependencies<Node> {
194194
}
195195

196196
/// Returns the set of all node that are control-dependent on the given `node`.
197-
pub fn dependent_on(&self, node: Node) -> Option<&BitSet<Node>> {
197+
pub fn dependent_on(&self, node: Node) -> Option<&DenseBitSet<Node>> {
198198
self.0.row(node)
199199
}
200200
}

crates/rustc_utils/src/mir/location_or_arg.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,15 @@ impl From<Local> for LocationOrArg {
4242

4343
#[cfg(feature = "indexical")]
4444
pub mod index {
45-
use indexical::{
46-
impls::RustcIndexSet, index_vec::define_index_type, IndexedDomain, IndexedValue,
47-
ToIndex,
48-
};
45+
use indexical::{bitset::rustc::IndexSet, define_index_type, IndexedDomain, ToIndex};
4946

5047
use super::*;
5148

5249
define_index_type! {
53-
pub struct LocationOrArgIndex = u32;
50+
pub struct LocationOrArgIndex for LocationOrArg = u32;
5451
}
5552

56-
impl IndexedValue for LocationOrArg {
57-
type Index = LocationOrArgIndex;
58-
}
59-
60-
pub type LocationOrArgSet = RustcIndexSet<LocationOrArg>;
53+
pub type LocationOrArgSet = IndexSet<LocationOrArg>;
6154
pub type LocationOrArgDomain = IndexedDomain<LocationOrArg>;
6255

6356
pub struct CustomMarker;

0 commit comments

Comments
 (0)