Auto merge of #135947 - matthiaskrgr:rollup-k9jpfls, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #135073 (Implement `ByteStr` and `ByteString` types)
 - #135492 (Add missing check for async body when suggesting await on futures.)
 - #135766 (handle global trait bounds defining assoc types)
 - #135880 (Get rid of RunCompiler)
 - #135908 (rustc_codegen_llvm: remove outdated asm-to-obj codegen note)
 - #135911 (Allow `arena_cache` queries to return `Option<&'tcx T>`)
 - #135920 (simplify parse_format::Parser::ws by using next_if)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-24 01:59:34 +00:00
commit aa3bd1abcb
3 changed files with 16 additions and 18 deletions

View File

@ -18,8 +18,8 @@ use std::path::Path;
use rustc_ast_pretty::pprust::item_to_string; use rustc_ast_pretty::pprust::item_to_string;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_driver::{Compilation, RunCompiler}; use rustc_driver::{Compilation, run_compiler};
use rustc_interface::interface::Compiler; use rustc_interface::interface::{Compiler, Config};
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
struct MyFileLoader; struct MyFileLoader;
@ -51,6 +51,10 @@ fn main() {
struct MyCallbacks; struct MyCallbacks;
impl rustc_driver::Callbacks for MyCallbacks { impl rustc_driver::Callbacks for MyCallbacks {
fn config(&mut self, config: &mut Config) {
config.file_loader = Some(Box::new(MyFileLoader));
}
fn after_crate_root_parsing( fn after_crate_root_parsing(
&mut self, &mut self,
_compiler: &Compiler, _compiler: &Compiler,
@ -83,10 +87,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
} }
fn main() { fn main() {
match RunCompiler::new(&["main.rs".to_string()], &mut MyCallbacks) { run_compiler(&["main.rs".to_string()], &mut MyCallbacks);
mut compiler => {
compiler.set_file_loader(Some(Box::new(MyFileLoader)));
compiler.run();
}
}
} }

View File

@ -18,8 +18,8 @@ use std::path::Path;
use rustc_ast_pretty::pprust::item_to_string; use rustc_ast_pretty::pprust::item_to_string;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_driver::{Compilation, RunCompiler}; use rustc_driver::{Compilation, run_compiler};
use rustc_interface::interface::Compiler; use rustc_interface::interface::{Compiler, Config};
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
struct MyFileLoader; struct MyFileLoader;
@ -51,6 +51,10 @@ fn main() {
struct MyCallbacks; struct MyCallbacks;
impl rustc_driver::Callbacks for MyCallbacks { impl rustc_driver::Callbacks for MyCallbacks {
fn config(&mut self, config: &mut Config) {
config.file_loader = Some(Box::new(MyFileLoader));
}
fn after_crate_root_parsing( fn after_crate_root_parsing(
&mut self, &mut self,
_compiler: &Compiler, _compiler: &Compiler,
@ -90,10 +94,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
} }
fn main() { fn main() {
match RunCompiler::new(&["main.rs".to_string()], &mut MyCallbacks) { run_compiler(&["main.rs".to_string()], &mut MyCallbacks);
mut compiler => {
compiler.set_file_loader(Some(Box::new(MyFileLoader)));
compiler.run();
}
}
} }

View File

@ -6,7 +6,7 @@ The [`rustc_driver`] is essentially `rustc`'s `main` function.
It acts as the glue for running the various phases of the compiler in the correct order, It acts as the glue for running the various phases of the compiler in the correct order,
using the interface defined in the [`rustc_interface`] crate. Where possible, using [`rustc_driver`] rather than [`rustc_interface`] is recommended. using the interface defined in the [`rustc_interface`] crate. Where possible, using [`rustc_driver`] rather than [`rustc_interface`] is recommended.
The main entry point of [`rustc_driver`] is [`rustc_driver::RunCompiler`][rd_rc]. The main entry point of [`rustc_driver`] is [`rustc_driver::run_compiler`][rd_rc].
This builder accepts the same command-line args as rustc as well as an implementation of [`Callbacks`][cb] and a couple of other optional options. This builder accepts the same command-line args as rustc as well as an implementation of [`Callbacks`][cb] and a couple of other optional options.
[`Callbacks`][cb] is a `trait` that allows for custom compiler configuration, [`Callbacks`][cb] is a `trait` that allows for custom compiler configuration,
as well as allowing custom code to run after different phases of the compilation. as well as allowing custom code to run after different phases of the compilation.
@ -40,7 +40,7 @@ specifically [`rustc_driver_impl::run_compiler`][rdi_rc]
[cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html [cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-interface-example.rs [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-interface-example.rs
[i_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/fn.run_compiler.html [i_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/fn.run_compiler.html
[rd_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/struct.RunCompiler.html [rd_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.run_compiler.html
[rdi_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver_impl/fn.run_compiler.html [rdi_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver_impl/fn.run_compiler.html
[stupid-stats]: https://github.com/nrc/stupid-stats [stupid-stats]: https://github.com/nrc/stupid-stats
[`nightly-rustc`]: https://doc.rust-lang.org/nightly/nightly-rustc/ [`nightly-rustc`]: https://doc.rust-lang.org/nightly/nightly-rustc/