prusti-dev
prusti-dev copied to clipboard
ICE: expected a type, but found another kind
The following Rust program:
use prusti_contracts::*;
use core::ops::Deref;
fn main() {}
struct A;
struct B {
a: A,
}
impl Deref for B {
type Target = A;
fn deref<'a>(&'a self) -> &'a Self::Target {
&self.a
}
}
#[extern_spec]
impl Deref for B {
#[pure]
fn deref<'a>(&'a self) -> &'a A;
}
results in an ICE due to the explicit lifetime 'a (without the explicit lifetime 'a in the second impl block, Prusti verifies okay):
[2022-03-22T21:33:45Z INFO prusti_driver] Prusti version: commit 795c70cfa1 2022-03-22 20:26:09 UTC, built on 2022-03-22 20:33:14 UTC
warning: unused return value of `std::ops::Deref::deref` that must be used
--> src/lib.rs:57:5
|
57 | / #[pure]
58 | | fn deref<'a>(&'a self) -> &'a A;
| |____________________________________^
|
= note: `#[warn(unused_must_use)]` on by default
[2022-03-22T21:33:45Z INFO prusti_viper::verifier] Received 2 functions to be verified:
[2022-03-22T21:33:45Z INFO prusti_common::stopwatch::log_level] [prusti-viper] Starting: encoding to Viper
[2022-03-22T21:33:45Z INFO prusti_viper::verifier] - main (prusti_example::main)
[2022-03-22T21:33:45Z INFO prusti_viper::verifier] Source: src/lib.rs:17:1: 17:14 (#0)
[2022-03-22T21:33:45Z INFO prusti_viper::verifier] - <B as std::ops::Deref>::deref (prusti_example::{impl#0}::deref)
[2022-03-22T21:33:45Z INFO prusti_viper::verifier] Source: src/lib.rs:50:5: 50:47 (#0)
[2022-03-22T21:33:45Z INFO prusti_viper::encoder::encoder] Encoding: prusti_example::main (prusti_example::main)
[2022-03-22T21:33:45Z INFO prusti_viper::encoder::encoder] Encoding: prusti_example::<B as std::ops::Deref>::deref (prusti_example::{impl#0}::deref)
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:173:18: expected a type, but found another kind
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1236:9
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: std::panic::panic_any::<rustc_errors::ExplicitBug>
2: <rustc_errors::HandlerInner>::bug
3: <rustc_errors::Handler>::bug
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>
5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
6: rustc_middle::util::bug::bug_fmt
7: <rustc_middle::ty::subst::GenericArg>::expect_ty
8: prusti_viper::encoder::mir::pure::pure_functions::encoder::PureFunctionEncoder::new
9: <prusti_viper::encoder::encoder::Encoder as prusti_viper::encoder::mir::pure::pure_functions::interface::PureFunctionEncoderInterface>::encode_pure_function_def
10: prusti_viper::encoder::encoder::Encoder::process_encoding_queue
11: prusti_viper::verifier::Verifier::verify
12: prusti_driver::verifier::verify
13: rustc_interface::passes::QueryContext::enter
14: <prusti_driver::callbacks::PrustiCompilerCalls as rustc_driver::Callbacks>::after_analysis
15: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
16: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
17: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
18: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: Prusti or the compiler unexpectedly panicked. This is a bug.
note: We would appreciate a bug report: https://github.com/viperproject/prusti-dev/issues/new
note: Prusti version: commit 795c70cfa1 2022-03-22 20:26:09 UTC, built on 2022-03-22 20:33:14 UTC
query stack during panic:
end of query stack
[2022-03-22T21:33:45Z INFO prusti_common::stopwatch::log_level] [prusti-viper] Completed: encoding to Viper (0.036 seconds)
[2022-03-22T21:33:45Z INFO prusti_common::stopwatch::log_level] [prusti] Completed: main (0.075 seconds)
warning: `prusti-example` (lib) generated 1 warning
This seems to be a regression since the latest rustc update, it is after this update that I noticed it for the first time. This was working okay before the last update. Additionally, there is a warning generated by the contents of the #[extern_spec] impl block which could be marked as "allowed", because it arises from within the auto-generated Prusti code.