Skip to content

Commit

Permalink
Update to nightly-2024-12-15 (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton authored Dec 16, 2024
1 parent e87e1b8 commit f6cb47d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
[![docs](https://img.shields.io/badge/docs-built-blue)][docs]


`rustc_plugin` is a framework for writing programs that use the Rust compiler API. We wrote `rustc_plugin` to support our research on experimental Rust tools like [Flowistry] and [Aquascope]. `rustc_plugin` is a kind of generalized version of the infrastructure in [Clippy].
`rustc_plugin` is a framework for writing programs that use the Rust compiler API. We wrote `rustc_plugin` to support our research on experimental Rust tools like [Flowistry], [Aquascope], [Paralegal], and [Argus]. `rustc_plugin` provides a kind of generalized version of the Cargo integration infrastructure in [Clippy], along with a miscellany of utilities in the `rustc_utils` crate.

## Installation

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:

```toml
rustc_plugin = "=0.11.0-nightly-2024-12-01"
rustc_plugin = "=0.12.0-nightly-2024-12-15"
```

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.
Expand Down Expand Up @@ -44,6 +44,7 @@ The `rustc_plugin` framework is responsible for marshalling arguments from the t

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:

* v0.12 (`nightly-2024-12-15`) - rustc 1.84
* v0.11 (`nightly-2024-12-01`) - rustc 1.84
* v0.10 (`nightly-2024-05-20`) - rustc 1.79
* v0.9 (`nightly-2024-01-24`) - rustc 1.76
Expand All @@ -54,9 +55,10 @@ Normally, Rust libraries have a [minimum supported Rust version][msrv] because t

[Flowistry]: https://github.com/willcrichton/flowistry/
[Aquascope]: https://github.com/cognitive-engineering-lab/aquascope
[Paralegal]: https://github.com/brownsys/paralegal
[Argus]: https://github.com/cognitive-engineering-lab/argus
[Clippy]: https://github.com/rust-lang/rust-clippy
[example]: https://github.com/cognitive-engineering-lab/rustc_plugin/tree/main/crates/rustc_plugin/examples/print-all-items
[docs]: https://cognitive-engineering-lab.github.io/rustc_plugin/v0.11.0-nightly-2024-12-01/rustc_plugin/
[docs-utils]: https://cognitive-engineering-lab.github.io/rustc_plugin/v0.11.0-nightly-2024-12-01/rustc_utils/
[msrv]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-01-24"
channel = "nightly-2024-12-15"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
7 changes: 4 additions & 3 deletions crates/rustc_plugin/examples/print-all-items/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ impl RustcPlugin for PrintAllItemsPlugin {
) -> rustc_interface::interface::Result<()> {
let mut callbacks = PrintAllItemsCallbacks { args: plugin_args };
let compiler = rustc_driver::RunCompiler::new(&compiler_args, &mut callbacks);
compiler.run()
compiler.run();
Ok(())
}
}

Expand All @@ -75,10 +76,10 @@ impl rustc_driver::Callbacks for PrintAllItemsCallbacks {
// At the top-level, the Rustc API uses an event-based interface for
// accessing the compiler at different stages of compilation. In this callback,
// all the type-checking has completed.
fn after_analysis<'tcx>(
fn after_analysis(
&mut self,
_compiler: &rustc_interface::interface::Compiler,
tcx: TyCtxt<'tcx>,
tcx: TyCtxt<'_>,
) -> rustc_driver::Compilation {
// We call our top-level function with access to the type context `tcx` and the CLI arguments.
print_all_items(tcx, &self.args);
Expand Down
3 changes: 2 additions & 1 deletion crates/rustc_plugin/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ run_on_all_crates={run_on_all_crates}, \
primary_package={primary_package}, \
is_target_crate={is_target_crate}"
);
rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run()
rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run();
Ok(())
}
}))
}
2 changes: 1 addition & 1 deletion crates/rustc_utils/src/hir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'tcx> TyExt<'tcx> for Ty<'tcx> {

fn is_copyable(self, tcx: TyCtxt<'tcx>, typing_env: TypingEnv<'tcx>) -> bool {
let ty = tcx.erase_regions(self);
ty.is_copy_modulo_regions(tcx, typing_env)
tcx.type_is_copy_modulo_regions(typing_env, ty)
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_utils/src/mir/control_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_data_structures::graph::{
DirectedGraph, Predecessors, StartNode, Successors,
};
use rustc_index::{
bit_set::{BitSet, ChunkedBitSet, SparseBitMatrix},
bit_set::{BitSet, SparseBitMatrix},
Idx,
};
use smallvec::SmallVec;
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<Node: Idx + Ord> ControlDependencies<Node> {
}

/// Returns the set of all node that are control-dependent on the given `node`.
pub fn dependent_on(&self, node: Node) -> Option<&ChunkedBitSet<Node>> {
pub fn dependent_on(&self, node: Node) -> Option<&BitSet<Node>> {
self.0.row(node)
}
}
Expand Down
13 changes: 5 additions & 8 deletions crates/rustc_utils/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ impl CompileBuilder {
rustc_driver::catch_fatal_errors(|| {
let mut compiler = rustc_driver::RunCompiler::new(&args, &mut callbacks);
compiler.set_file_loader(Some(Box::new(StringLoader(self.input.clone()))));
compiler.run()
compiler.run();
})
.unwrap()
.unwrap();
}
}
Expand Down Expand Up @@ -193,15 +192,13 @@ where
config.override_queries = Some(borrowck_facts::override_queries);
}

fn after_expansion<'tcx>(
fn after_analysis(
&mut self,
_compiler: &rustc_interface::interface::Compiler,
queries: &'tcx rustc_interface::Queries<'tcx>,
tcx: TyCtxt<'_>,
) -> rustc_driver::Compilation {
queries.global_ctxt().unwrap().enter(|tcx| {
let callback = self.callback.take().unwrap();
callback(tcx);
});
let callback = self.callback.take().unwrap();
callback(tcx);
rustc_driver::Compilation::Stop
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-12-01"
channel = "nightly-2024-12-15"
components = ["clippy", "rust-src", "rustc-dev", "llvm-tools-preview"]

0 comments on commit f6cb47d

Please sign in to comment.