Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jul 2, 2023
1 parent 79bc4c8 commit f1de5c8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cargo-dylint/tests/boundary_toolchains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use tempfile::tempdir;
// smoelius: Put recent boundaries first, since they're more likely to cause problems.
// smoelius: The relevant PRs and merge commits appear before each boundary.
const BOUNDARIES: &[(&str, &str)] = &[
// https://github.com/rust-lang/rust/pull/112692
// https://github.com/rust-lang/rust/commit/b6144cd843d6eb6acc086797ea37e0c69c892b90
("2023-06-28", "2023-06-29"),
// https://github.com/rust-lang/rust/pull/111748
// https://github.com/rust-lang/rust/commit/70e04bd88d85cab8ed110ace5a278fab106d0ef5
("2023-05-29", "2023-05-30"),
Expand Down
23 changes: 19 additions & 4 deletions driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ impl Callbacks {
path.to_string_lossy(),
err
);
rustc_session::early_error(
rustc_session::config::ErrorOutputType::default(),
Box::leak(msg.into_boxed_str()) as &str,
);
early_error(msg);
});

loaded_libs.push(LoadedLibrary { path, lib });
Expand All @@ -140,6 +137,24 @@ impl Callbacks {
}
}

#[rustversion::before(2023-06-28)]
fn early_error(msg: String) -> ! {
rustc_session::early_error(
rustc_session::config::ErrorOutputType::default(),
Box::leak(msg.into_boxed_str()) as &str,
)
}

#[rustversion::since(2023-06-28)]
extern crate rustc_errors;

#[rustversion::since(2023-06-28)]
fn early_error(msg: impl Into<rustc_errors::DiagnosticMessage>) -> ! {
let handler =
rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default());
handler.early_error(msg)
}

#[rustversion::before(2022-07-14)]
fn zero_mir_opt_level(config: &mut rustc_interface::Config) {
trait Zeroable {
Expand Down
23 changes: 19 additions & 4 deletions utils/linting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,7 @@ pub fn config_toml(name: &str) -> ConfigResult<Option<toml::Value>> {
pub fn init_config(sess: &rustc_session::Session) {
try_init_config(sess).unwrap_or_else(|err| {
let msg = format!("could not read configuration file: {err}");
rustc_session::early_error(
rustc_session::config::ErrorOutputType::default(),
Box::leak(msg.into_boxed_str()) as &str,
);
early_error(msg);
});
}

Expand Down Expand Up @@ -565,3 +562,21 @@ fn local_crate_source_file(sess: &rustc_session::Session) -> Option<PathBuf> {
fn local_crate_source_file(sess: &rustc_session::Session) -> Option<PathBuf> {
sess.local_crate_source_file()
}

#[rustversion::before(2023-06-28)]
fn early_error(msg: String) -> ! {
rustc_session::early_error(
rustc_session::config::ErrorOutputType::default(),
Box::leak(msg.into_boxed_str()) as &str,
)
}

#[rustversion::since(2023-06-28)]
extern crate rustc_errors;

#[rustversion::since(2023-06-28)]
fn early_error(msg: impl Into<rustc_errors::DiagnosticMessage>) -> ! {
let handler =
rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default());
handler.early_error(msg)
}

0 comments on commit f1de5c8

Please sign in to comment.