Skip to content

Commit 88204c2

Browse files
authored
Update Rust toolchain to 2023-10-05 (rust-lang#2802)
Source changes required by the following upstream commits: * rust-lang/rust@44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR. * rust-lang/rust@4ed4913e67 Merge ExternProviders into the general Providers struct * rust-lang/rust@3c52a3e280 subst -> instantiate * rust-lang/rust@6a02baaa3d Partially outline code inside the panic! macro * rust-lang/rust@3148e6a993 subtyping_projections Resolves: rust-lang#2811
1 parent 534b050 commit 88204c2

File tree

8 files changed

+23
-42
lines changed

8 files changed

+23
-42
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ impl<'tcx> GotocCtx<'tcx> {
260260
| ty::Never
261261
| ty::FnDef(..)
262262
| ty::GeneratorWitness(..)
263-
| ty::GeneratorWitnessMIR(..)
264263
| ty::Foreign(..)
265264
| ty::Dynamic(..)
266265
| ty::Bound(..)
@@ -605,13 +604,15 @@ impl<'tcx> GotocCtx<'tcx> {
605604
self,
606605
)
607606
}
608-
ProjectionElem::OpaqueCast(ty) => ProjectedPlace::try_new(
609-
before.goto_expr.cast_to(self.codegen_ty(ty)),
610-
TypeOrVariant::Type(ty),
611-
before.fat_ptr_goto_expr,
612-
before.fat_ptr_mir_typ,
613-
self,
614-
),
607+
ProjectionElem::OpaqueCast(ty) | ProjectionElem::Subtype(ty) => {
608+
ProjectedPlace::try_new(
609+
before.goto_expr.cast_to(self.codegen_ty(self.monomorphize(ty))),
610+
TypeOrVariant::Type(ty),
611+
before.fat_ptr_goto_expr,
612+
before.fat_ptr_mir_typ,
613+
self,
614+
)
615+
}
615616
}
616617
}
617618

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'tcx> GotocCtx<'tcx> {
424424
{
425425
// Instance is Some(..) only when current codegen unit is a function.
426426
if let Some(current_fn) = &self.current_fn {
427-
current_fn.instance().subst_mir_and_normalize_erasing_regions(
427+
current_fn.instance().instantiate_mir_and_normalize_erasing_regions(
428428
self.tcx,
429429
ty::ParamEnv::reveal_all(),
430430
ty::EarlyBinder::bind(value),
@@ -813,11 +813,7 @@ impl<'tcx> GotocCtx<'tcx> {
813813
ty::Bound(_, _) | ty::Param(_) => unreachable!("monomorphization bug"),
814814

815815
// type checking remnants which shouldn't be reachable
816-
ty::GeneratorWitness(_)
817-
| ty::GeneratorWitnessMIR(_, _)
818-
| ty::Infer(_)
819-
| ty::Placeholder(_)
820-
| ty::Error(_) => {
816+
ty::GeneratorWitness(_, _) | ty::Infer(_) | ty::Placeholder(_) | ty::Error(_) => {
821817
unreachable!("remnants of type checking")
822818
}
823819
}
@@ -1254,8 +1250,7 @@ impl<'tcx> GotocCtx<'tcx> {
12541250
// For soundness, hold off on generating them till we have test-cases.
12551251
ty::Bound(_, _) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
12561252
ty::Error(_) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
1257-
ty::GeneratorWitness(_) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
1258-
ty::GeneratorWitnessMIR(_, _) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
1253+
ty::GeneratorWitness(_, _) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
12591254
ty::Infer(_) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
12601255
ty::Param(_) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),
12611256
ty::Placeholder(_) => todo!("{:?} {:?}", pointee_type, pointee_type.kind()),

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ use rustc_metadata::fs::{emit_wrapper_file, METADATA_FILENAME};
3737
use rustc_metadata::EncodedMetadata;
3838
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
3939
use rustc_middle::mir::mono::MonoItem;
40-
use rustc_middle::query::{ExternProviders, Providers};
4140
use rustc_middle::ty::TyCtxt;
41+
use rustc_middle::util::Providers;
4242
use rustc_session::config::{CrateType, OutputFilenames, OutputType};
4343
use rustc_session::cstore::MetadataLoaderDyn;
4444
use rustc_session::output::out_filename;
@@ -193,10 +193,6 @@ impl CodegenBackend for GotocCodegenBackend {
193193
provide::provide(providers, &self.queries.lock().unwrap());
194194
}
195195

196-
fn provide_extern(&self, providers: &mut ExternProviders) {
197-
provide::provide_extern(providers, &self.queries.lock().unwrap());
198-
}
199-
200196
fn print_version(&self) {
201197
println!("Kani-goto version: {}", env!("CARGO_PKG_VERSION"));
202198
}

kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'tcx> GotocHook<'tcx> for Panic {
201201
fn hook_applies(&self, tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> bool {
202202
let def_id = instance.def.def_id();
203203
Some(def_id) == tcx.lang_items().panic_fn()
204-
|| Some(def_id) == tcx.lang_items().panic_display()
204+
|| tcx.has_attr(def_id, rustc_span::sym::rustc_const_panic_str)
205205
|| Some(def_id) == tcx.lang_items().panic_fmt()
206206
|| Some(def_id) == tcx.lang_items().begin_panic_fn()
207207
|| matches_function(tcx, instance, "KaniPanic")

kani-compiler/src/kani_middle/provide.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,24 @@ use crate::kani_middle::stubbing;
1111
use crate::kani_queries::QueryDb;
1212
use rustc_hir::def_id::{DefId, LocalDefId};
1313
use rustc_interface;
14-
use rustc_middle::{
15-
mir::Body,
16-
query::{queries, ExternProviders, Providers},
17-
ty::TyCtxt,
18-
};
14+
use rustc_middle::util::Providers;
15+
use rustc_middle::{mir::Body, query::queries, ty::TyCtxt};
1916

2017
/// Sets up rustc's query mechanism to apply Kani's custom queries to code from
21-
/// the present crate.
18+
/// a crate.
2219
pub fn provide(providers: &mut Providers, queries: &QueryDb) {
2320
let args = queries.args();
2421
if should_override(args) {
2522
// Don't override queries if we are only compiling our dependencies.
2623
providers.optimized_mir = run_mir_passes;
24+
providers.extern_queries.optimized_mir = run_mir_passes_extern;
2725
if args.stubbing_enabled {
2826
// TODO: Check if there's at least one stub being applied.
2927
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
3028
}
3129
}
3230
}
3331

34-
/// Sets up rustc's query mechanism to apply Kani's custom queries to code from
35-
/// external crates.
36-
pub fn provide_extern(providers: &mut ExternProviders, queries: &QueryDb) {
37-
if should_override(queries.args()) {
38-
// Don't override queries if we are only compiling our dependencies.
39-
providers.optimized_mir = run_mir_passes_extern;
40-
}
41-
}
42-
4332
fn should_override(args: &Arguments) -> bool {
4433
args.reachability_analysis != ReachabilityType::None && !args.build_std
4534
}
@@ -48,7 +37,7 @@ fn should_override(args: &Arguments) -> bool {
4837
/// running rustc's optimization passes followed by Kani-specific passes.
4938
fn run_mir_passes_extern(tcx: TyCtxt, def_id: DefId) -> &Body {
5039
tracing::debug!(?def_id, "run_mir_passes_extern");
51-
let body = (rustc_interface::DEFAULT_EXTERN_QUERY_PROVIDERS.optimized_mir)(tcx, def_id);
40+
let body = (rustc_interface::DEFAULT_QUERY_PROVIDERS.extern_queries.optimized_mir)(tcx, def_id);
5241
run_kani_mir_passes(tcx, def_id, body)
5342
}
5443

kani-compiler/src/kani_middle/reachability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'a, 'tcx> MonoItemsFnCollector<'a, 'tcx> {
242242
T: TypeFoldable<TyCtxt<'tcx>>,
243243
{
244244
trace!(instance=?self.instance, ?value, "monomorphize");
245-
self.instance.subst_mir_and_normalize_erasing_regions(
245+
self.instance.instantiate_mir_and_normalize_erasing_regions(
246246
self.tcx,
247247
ParamEnv::reveal_all(),
248248
EarlyBinder::bind(value),
@@ -519,7 +519,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MonoItemsFnCollector<'a, 'tcx> {
519519
// even the return type, for instance for a
520520
// trait like `FromIterator`.
521521
let generic_ty = outer_args[0].ty(self.body, tcx).peel_refs();
522-
let receiver_ty = tcx.subst_and_normalize_erasing_regions(
522+
let receiver_ty = tcx.instantiate_and_normalize_erasing_regions(
523523
substs,
524524
ParamEnv::reveal_all(),
525525
EarlyBinder::bind(generic_ty),

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
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-2023-09-23"
5+
channel = "nightly-2023-10-05"
66
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn appears_incomplete() -> Option<PathBuf> {
5959
let kani_dir = kani_dir().expect("couldn't find kani directory");
6060
let kani_dir_parent = kani_dir.parent().unwrap();
6161

62-
for entry in std::fs::read_dir(&kani_dir_parent).ok()?.flatten() {
62+
for entry in std::fs::read_dir(kani_dir_parent).ok()?.flatten() {
6363
if let Some(file_name) = entry.file_name().to_str() {
6464
if file_name.ends_with(".tar.gz") {
6565
return Some(kani_dir_parent.join(file_name));

0 commit comments

Comments
 (0)