Skip to content

Commit 5195423

Browse files
authored
Upgrade toolchain to nightly-2023-01-23 (#2149)
Upgrade our toolchain to `nightly-2023-01-23`. The changes here are related to the following changes: - rust-lang/rust#104986 - rust-lang/rust#105657 - rust-lang/rust#105603 - rust-lang/rust#105613 - rust-lang/rust#105977 - rust-lang/rust#104645
1 parent bf5e697 commit 5195423

File tree

23 files changed

+73
-51
lines changed

23 files changed

+73
-51
lines changed

.github/workflows/cbmc-latest.yml

+5
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ jobs:
8989
- name: Execute Kani performance tests
9090
working-directory: ./kani
9191
run: ./scripts/kani-perf.sh
92+
93+
- name: Execute Kani performance ignored tests
94+
working-directory: ./kani
95+
continue-on-error: true
96+
run: cargo run -p compiletest -- --suite perf --mode cargo-kani-test ignore --ignored --no-fail-fast

kani-compiler/kani_queries/src/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,22 @@ mod unsound_experiments;
1010
#[cfg(feature = "unsound_experiments")]
1111
use crate::unsound_experiments::UnsoundExperiments;
1212

13-
#[derive(Debug, Clone, Copy, AsRefStr, EnumString, EnumVariantNames, PartialEq, Eq)]
13+
#[derive(Debug, Default, Clone, Copy, AsRefStr, EnumString, EnumVariantNames, PartialEq, Eq)]
1414
#[strum(serialize_all = "snake_case")]
1515
pub enum ReachabilityType {
1616
/// Start the cross-crate reachability analysis from all harnesses in the local crate.
1717
Harnesses,
1818
/// Use standard rustc monomorphizer algorithm.
1919
Legacy,
2020
/// Don't perform any reachability analysis. This will skip codegen for this crate.
21+
#[default]
2122
None,
2223
/// Start the cross-crate reachability analysis from all public functions in the local crate.
2324
PubFns,
2425
/// Start the cross-crate reachability analysis from all *test* (i.e. `#[test]`) harnesses in the local crate.
2526
Tests,
2627
}
2728

28-
impl Default for ReachabilityType {
29-
fn default() -> Self {
30-
ReachabilityType::None
31-
}
32-
}
33-
3429
pub trait UserInput {
3530
fn set_emit_vtable_restrictions(&mut self, restrictions: bool);
3631
fn get_emit_vtable_restrictions(&self) -> bool;

kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ impl<'tcx> GotocCtx<'tcx> {
365365
"add_with_overflow" => codegen_op_with_overflow!(add_overflow_result),
366366
"arith_offset" => self.codegen_offset(intrinsic, instance, fargs, p, loc),
367367
"assert_inhabited" => self.codegen_assert_intrinsic(instance, intrinsic, span),
368-
"assert_uninit_valid" => self.codegen_assert_intrinsic(instance, intrinsic, span),
368+
"assert_mem_uninitialized_valid" => {
369+
self.codegen_assert_intrinsic(instance, intrinsic, span)
370+
}
369371
"assert_zero_valid" => self.codegen_assert_intrinsic(instance, intrinsic, span),
370372
// https://doc.rust-lang.org/core/intrinsics/fn.assume.html
371373
// Informs the optimizer that a condition is always true.

kani-compiler/src/codegen_cprover_gotoc/codegen/place.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ impl<'tcx> GotocCtx<'tcx> {
243243
match t {
244244
TypeOrVariant::Type(t) => {
245245
match t.kind() {
246-
ty::Bool
246+
ty::Alias(..)
247+
| ty::Bool
247248
| ty::Char
248249
| ty::Int(_)
249250
| ty::Uint(_)
@@ -254,10 +255,8 @@ impl<'tcx> GotocCtx<'tcx> {
254255
| ty::GeneratorWitness(..)
255256
| ty::Foreign(..)
256257
| ty::Dynamic(..)
257-
| ty::Projection(_)
258258
| ty::Bound(..)
259259
| ty::Placeholder(..)
260-
| ty::Opaque(..)
261260
| ty::Param(_)
262261
| ty::Infer(_)
263262
| ty::Error(_) => unreachable!("type {:?} does not have a field", t),

kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs

+34-13
Original file line numberDiff line numberDiff line change
@@ -358,20 +358,41 @@ impl<'tcx> GotocCtx<'tcx> {
358358
// `Generator::resume(...) -> GeneratorState` function in case we
359359
// have an ordinary generator, or the `Future::poll(...) -> Poll`
360360
// function in case this is a special generator backing an async construct.
361-
let ret_ty = if self.tcx.generator_is_async(*did) {
362-
let state_did = self.tcx.require_lang_item(LangItem::Poll, None);
363-
let state_adt_ref = self.tcx.adt_def(state_did);
364-
let state_substs = self.tcx.intern_substs(&[sig.return_ty.into()]);
365-
self.tcx.mk_adt(state_adt_ref, state_substs)
361+
let tcx = self.tcx;
362+
let (resume_ty, ret_ty) = if tcx.generator_is_async(*did) {
363+
// The signature should be `Future::poll(_, &mut Context<'_>) -> Poll<Output>`
364+
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
365+
let poll_adt_ref = tcx.adt_def(poll_did);
366+
let poll_substs = tcx.intern_substs(&[sig.return_ty.into()]);
367+
let ret_ty = tcx.mk_adt(poll_adt_ref, poll_substs);
368+
369+
// We have to replace the `ResumeTy` that is used for type and borrow checking
370+
// with `&mut Context<'_>` which is used in codegen.
371+
#[cfg(debug_assertions)]
372+
{
373+
if let ty::Adt(resume_ty_adt, _) = sig.resume_ty.kind() {
374+
let expected_adt = tcx.adt_def(tcx.require_lang_item(LangItem::ResumeTy, None));
375+
assert_eq!(*resume_ty_adt, expected_adt);
376+
} else {
377+
panic!("expected `ResumeTy`, found `{:?}`", sig.resume_ty);
378+
};
379+
}
380+
let context_mut_ref = tcx.mk_task_context();
381+
382+
(context_mut_ref, ret_ty)
366383
} else {
367-
let state_did = self.tcx.require_lang_item(LangItem::GeneratorState, None);
368-
let state_adt_ref = self.tcx.adt_def(state_did);
369-
let state_substs = self.tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]);
370-
self.tcx.mk_adt(state_adt_ref, state_substs)
384+
// The signature should be `Generator::resume(_, Resume) -> GeneratorState<Yield, Return>`
385+
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
386+
let state_adt_ref = tcx.adt_def(state_did);
387+
let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]);
388+
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
389+
390+
(sig.resume_ty, ret_ty)
371391
};
392+
372393
ty::Binder::bind_with_vars(
373-
self.tcx.mk_fn_sig(
374-
[env_ty, sig.resume_ty].iter(),
394+
tcx.mk_fn_sig(
395+
[env_ty, resume_ty].iter(),
375396
&ret_ty,
376397
false,
377398
Unsafety::Normal,
@@ -813,7 +834,7 @@ impl<'tcx> GotocCtx<'tcx> {
813834
)
814835
}
815836
}
816-
ty::Projection(_) | ty::Opaque(_, _) => {
837+
ty::Alias(..) => {
817838
unreachable!("Type should've been normalized already")
818839
}
819840

@@ -1226,7 +1247,7 @@ impl<'tcx> GotocCtx<'tcx> {
12261247
ty::Dynamic(..) | ty::Slice(_) | ty::Str => {
12271248
unreachable!("Should have generated a fat pointer")
12281249
}
1229-
ty::Projection(_) | ty::Opaque(..) => {
1250+
ty::Alias(..) => {
12301251
unreachable!("Should have been removed by normalization")
12311252
}
12321253

kani-compiler/src/kani_compiler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Callbacks for KaniCompiler {
169169
rustc_queries: &'tcx rustc_interface::Queries<'tcx>,
170170
) -> Compilation {
171171
if self.stubs.is_none() && self.queries.lock().unwrap().get_stubbing_enabled() {
172-
rustc_queries.global_ctxt().unwrap().peek_mut().enter(|tcx| {
172+
rustc_queries.global_ctxt().unwrap().enter(|tcx| {
173173
let stubs = self.stubs.insert(self.collect_stubs(tcx));
174174
debug!(?stubs, "after_analysis");
175175
if stubs.is_empty() { Compilation::Continue } else { Compilation::Stop }

kani-compiler/src/kani_middle/attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fn parse_solver(tcx: TyCtxt, attr: &Attribute) -> Option<CbmcSolver> {
276276
}
277277
}
278278
MetaItemKind::NameValue(lit) if ident_str == "bin" && lit.kind.is_str() => {
279-
Some(CbmcSolver::Binary(lit.token_lit.symbol.to_string()))
279+
Some(CbmcSolver::Binary(lit.symbol.to_string()))
280280
}
281281
_ => {
282282
invalid_arg_err(attr);

kani-compiler/src/kani_middle/coercion.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir::lang_items::LangItem;
1717
use rustc_middle::traits::{ImplSource, ImplSourceUserDefinedData};
1818
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
1919
use rustc_middle::ty::TypeAndMut;
20-
use rustc_middle::ty::{self, ParamEnv, TraitRef, Ty, TyCtxt};
20+
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
2121
use rustc_span::symbol::Symbol;
2222
use tracing::trace;
2323

@@ -213,10 +213,9 @@ fn custom_coerce_unsize_info<'tcx>(
213213
) -> CustomCoerceUnsized {
214214
let def_id = tcx.require_lang_item(LangItem::CoerceUnsized, None);
215215

216-
let trait_ref = ty::Binder::dummy(TraitRef {
217-
def_id,
218-
substs: tcx.mk_substs_trait(source_ty, [target_ty.into()]),
219-
});
216+
let trait_ref = ty::Binder::dummy(
217+
tcx.mk_trait_ref(def_id, tcx.mk_substs_trait(source_ty, [target_ty.into()])),
218+
);
220219

221220
match tcx.codegen_select_candidate((ParamEnv::reveal_all(), trait_ref)) {
222221
Ok(ImplSource::UserDefined(ImplSourceUserDefinedData { impl_def_id, .. })) => {

kani-compiler/src/session.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ pub fn init_session(args: &ArgMatches, json_hook: bool) {
7070
// Initialize the rustc logger using value from RUSTC_LOG. We keep the log control separate
7171
// because we cannot control the RUSTC log format unless if we match the exact tracing
7272
// version used by RUSTC.
73-
rustc_driver::init_rustc_env_logger();
73+
// TODO: Enable rustc log when we upgrade the toolchain.
74+
// <https://github.com/model-checking/kani/issues/2283>
75+
//
76+
// rustc_driver::init_rustc_env_logger();
7477

7578
// Install Kani panic hook.
7679
if json_hook {

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
[toolchain]
5-
channel = "nightly-2022-12-11"
5+
channel = "nightly-2023-01-23"
66
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

scripts/kani-perf.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ done
2727
suite="perf"
2828
mode="cargo-kani-test"
2929
echo "Check compiletest suite=$suite mode=$mode"
30-
cargo run -p compiletest -- --suite $suite --mode $mode
30+
cargo run -p compiletest -- --suite $suite --mode $mode --no-fail-fast
3131
exit_code=$?
3232

3333
echo "Cleaning up..."

tests/cargo-kani/vecdeque-cve/src/abstract_vecdeque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ impl AbstractRawVec {
275275

276276
fn handle_reserve(result: Result<(), TryReserveError>) {
277277
match result.map_err(|e| e.kind()) {
278-
Err(CapacityOverflow) => capacity_overflow(),
279-
Err(AllocError) => handle_alloc_error(),
278+
Err(TryReserveErrorKind::CapacityOverflow) => capacity_overflow(),
279+
Err(TryReserveErrorKind::AllocError) => handle_alloc_error(),
280280
Ok(()) => { /* yay */ }
281281
}
282282
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/ui/code-location/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module/mod.rs:10:5 in function module::not_empty
22
main.rs:13:5 in function same_file
33
/toolchains/
4-
alloc/src/vec/mod.rs:3054:81 in function <std::vec::Vec<i32> as std::ops::Drop>::drop
4+
alloc/src/vec/mod.rs:3059:81 in function <std::vec::Vec<i32> as std::ops::Drop>::drop
55

66
VERIFICATION:- SUCCESSFUL

tools/compiletest/src/header.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,17 @@ pub fn make_test_description<R: Read>(
180180
path: &Path,
181181
src: R,
182182
) -> test::TestDesc {
183-
let mut ignore = false;
184183
let mut should_fail = false;
185-
let mut ignore_message = None;
186184

187-
if config.mode == Mode::Kani || config.mode == Mode::Stub {
188-
// If the path to the test contains "fixme" or "ignore", skip it.
189-
let file_path = path.to_str().unwrap();
190-
(ignore, ignore_message) = if file_path.contains("fixme") {
191-
(true, Some("fixme test"))
192-
} else if file_path.contains("ignore") {
193-
(true, Some("ignore test"))
194-
} else {
195-
(false, None)
196-
};
197-
}
185+
// If the path to the test contains "fixme" or "ignore", skip it.
186+
let file_path = path.to_str().unwrap();
187+
let (mut ignore, mut ignore_message) = if file_path.contains("fixme") {
188+
(true, Some("fixme test"))
189+
} else if file_path.contains("ignore") {
190+
(true, Some("ignore test"))
191+
} else {
192+
(false, None)
193+
};
198194

199195
// The `KaniFixme` mode runs tests that are ignored in the `kani` suite
200196
if config.mode == Mode::KaniFixme {
@@ -207,8 +203,10 @@ pub fn make_test_description<R: Read>(
207203

208204
// If the base name does NOT contain "fixme" or "ignore", we skip it.
209205
// All "fixme" tests are expected to fail
210-
(ignore, ignore_message) = if base_name.contains("fixme") || base_name.contains("ignore") {
206+
(ignore, ignore_message) = if base_name.contains("fixme") {
211207
(false, None)
208+
} else if base_name.contains("ignore") {
209+
(true, Some("ignore test"))
212210
} else {
213211
(true, Some("regular test"))
214212
};

0 commit comments

Comments
 (0)