Skip to content

Commit

Permalink
Merge #1241
Browse files Browse the repository at this point in the history
1241: Print a proper compiler warning when no edition is selected r=JonasAlaif a=JonasAlaif



Co-authored-by: Jonas <[email protected]>
  • Loading branch information
bors[bot] and JonasAlaif authored Nov 21, 2022
2 parents 81f5ba8 + d8ecade commit e6e40f4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
5 changes: 4 additions & 1 deletion prusti-tests/tests/cargotest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ fn simple_assert_false() {
.with_stderr(
"\
[CHECKING] foo v0.0.1 ([..])
[WARNING] Prusti specifications are supported only from 2018 edition. Please specify the edition with adding a command line argument `--edition=2018` or `--edition=2021`.
[ERROR] [Prusti: verification error] the asserted expression might not hold
--> src/main.rs:1:13
|
Expand All @@ -76,7 +78,8 @@ fn simple_assert_false() {
|
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `foo` due to previous error
warning: `foo` (bin \"foo\") generated 1 warning
error: could not compile `foo` due to previous error; 1 warning emitted
",
)
.run();
Expand Down
10 changes: 10 additions & 0 deletions prusti/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ impl prusti_rustc_interface::driver::Callbacks for PrustiCompilerCalls {
compiler: &Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
if compiler.session().rust_2015() {
compiler
.session()
.struct_warn(
"Prusti specifications are supported only from 2018 edition. Please \
specify the edition with adding a command line argument `--edition=2018` or \
`--edition=2021`.",
)
.emit();
}
compiler.session().abort_if_errors();
let (krate, _resolver, _lint_store) = &mut *queries.expansion().unwrap().peek_mut();
if config::print_desugared_specs() {
Expand Down
17 changes: 1 addition & 16 deletions prusti/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod verifier;
use arg_value::arg_value;
use callbacks::PrustiCompilerCalls;
use lazy_static::lazy_static;
use log::{info, warn};
use log::info;
use prusti_common::{config, report::user, Stopwatch};
use prusti_rustc_interface::interface::interface::try_print_query_stack;
use std::{borrow::Cow, env, panic};
Expand Down Expand Up @@ -147,8 +147,6 @@ fn main() {
// be called.
let mut rustc_args = Vec::new();
let mut is_codegen = false;
let mut contains_edition = false;
let mut only_print = false;
for arg in original_rustc_args {
if arg == "--codegen" || arg == "-C" {
is_codegen = true;
Expand All @@ -160,22 +158,9 @@ fn main() {
rustc_args.push("-C".to_owned());
is_codegen = false;
}
if arg == "--edition=2018" || arg == "--edition=2021" {
contains_edition = true;
}
if arg.starts_with("--print=") {
only_print = true;
}
rustc_args.push(arg);
}
}
if !contains_edition && !only_print {
warn!(
"Specifications are supported only from 2018 edition. Please specify \
the edition with adding a command line argument `--edition=2018` or \
`--edition=2021`."
);
}

let exit_code = prusti_rustc_interface::driver::catch_with_exit_code(move || {
user::message(format!(
Expand Down

0 comments on commit e6e40f4

Please sign in to comment.