//! This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
-#![feature(nll)]
#![feature(let_else)]
#![feature(once_cell)]
#![recursion_limit = "256"]
use rustc_metadata::locator;
use rustc_save_analysis as save;
use rustc_save_analysis::DumpHandler;
-use rustc_serialize::json::ToJson;
use rustc_session::config::{nightly_options, CG_OPTIONS, DB_OPTIONS};
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
use rustc_session::cstore::MetadataLoader;
use rustc_session::{early_error, early_error_no_abort, early_warn};
use rustc_span::source_map::{FileLoader, FileName};
use rustc_span::symbol::sym;
+use rustc_target::json::ToJson;
use std::borrow::Cow;
use std::cmp::max;
use std::ffi::OsString;
use std::fs;
use std::io::{self, Read, Write};
-use std::lazy::SyncLazy;
use std::panic::{self, catch_unwind};
use std::path::PathBuf;
use std::process::{self, Command, Stdio};
use std::str;
+use std::sync::LazyLock;
use std::time::Instant;
pub mod args;
return early_exit();
}
- if sess.opts.debugging_opts.parse_only
- || sess.opts.debugging_opts.show_span.is_some()
- || sess.opts.debugging_opts.ast_json_noexpand
- {
+ if sess.opts.debugging_opts.parse_only || sess.opts.debugging_opts.show_span.is_some() {
return early_exit();
}
queries.global_ctxt()?;
- if sess.opts.debugging_opts.no_analysis || sess.opts.debugging_opts.ast_json {
+ if sess.opts.debugging_opts.no_analysis {
return early_exit();
}
}
Sysroot => println!("{}", sess.sysroot.display()),
TargetLibdir => println!("{}", sess.target_tlib_path.dir.display()),
- TargetSpec => println!("{}", sess.target.to_json().pretty()),
+ TargetSpec => {
+ println!("{}", serde_json::to_string_pretty(&sess.target.to_json()).unwrap());
+ }
FileNames | CrateName => {
let input = input.unwrap_or_else(|| {
early_error(ErrorOutputType::default(), "no input file provided")
}
if cg_flags.iter().any(|x| *x == "passes=list") {
- let backend_name = debug_flags.iter().find_map(|x| {
- if x.starts_with("codegen-backend=") {
- Some(&x["codegen-backends=".len()..])
- } else {
- None
- }
- });
+ let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
get_codegen_backend(&None, backend_name).print_passes();
return None;
}
}
}
-static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
- SyncLazy::new(|| {
+static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
+ LazyLock::new(|| {
let hook = panic::take_hook();
panic::set_hook(Box::new(|info| {
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
if std::env::var("RUST_BACKTRACE").is_err() {
std::env::set_var("RUST_BACKTRACE", "full");
}
- SyncLazy::force(&DEFAULT_HOOK);
+ LazyLock::force(&DEFAULT_HOOK);
}
/// This allows tools to enable rust logging without having to magically match rustc's