Skip to content

Commit 53e07cc

Browse files
qinhepingtautschnig
authored andcommitted
Upgrade toolchain to nightly-2023-03-09
- Introduce -Zterminal-urls to use OSC8 for error codes rust-lang/rust#107838 - Unify validity checks into a single query rust-lang/rust#108364 - Rename interner funcs rust-lang/rust#108250 - Optimize mk_region rust-lang/rust#108020 - Clarify iterator interners rust-lang/rust#108112
1 parent b4152b2 commit 53e07cc

File tree

8 files changed

+37
-22
lines changed

8 files changed

+37
-22
lines changed

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use cbmc::goto_program::{
99
Type, ARITH_OVERFLOW_OVERFLOWED_FIELD, ARITH_OVERFLOW_RESULT_FIELD,
1010
};
1111
use rustc_middle::mir::{BasicBlock, Operand, Place};
12-
use rustc_middle::ty::layout::LayoutOf;
12+
use rustc_middle::ty::layout::{LayoutOf, ValidityRequirement};
1313
use rustc_middle::ty::{self, Ty};
1414
use rustc_middle::ty::{Instance, InstanceDef};
1515
use rustc_span::Span;
@@ -788,7 +788,10 @@ impl<'tcx> GotocCtx<'tcx> {
788788
// Then we check if the type allows "raw" initialization for the cases
789789
// where memory is zero-initialized or entirely uninitialized
790790
if intrinsic == "assert_zero_valid"
791-
&& !self.tcx.permits_zero_init(param_env_and_type).ok().unwrap()
791+
&& !self
792+
.tcx
793+
.check_validity_requirement((ValidityRequirement::Zero, param_env_and_type))
794+
.unwrap()
792795
{
793796
return self.codegen_fatal_error(
794797
PropertyClass::SafetyCheck,
@@ -798,7 +801,13 @@ impl<'tcx> GotocCtx<'tcx> {
798801
}
799802

800803
if intrinsic == "assert_uninit_valid"
801-
&& !self.tcx.permits_uninit_init(param_env_and_type).ok().unwrap()
804+
&& !self
805+
.tcx
806+
.check_validity_requirement((
807+
ValidityRequirement::UninitMitigated0x01Fill,
808+
param_env_and_type,
809+
))
810+
.unwrap()
802811
{
803812
return self.codegen_fatal_error(
804813
PropertyClass::SafetyCheck,

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl<'tcx> GotocCtx<'tcx> {
272272
let env = prev_args[0];
273273

274274
// Recombine arguments: environment first, then the flattened tuple elements
275-
let recombined_args = iter::once(env).chain(args);
275+
let recombined_args: Vec<_> = iter::once(env).chain(args).collect();
276276

277277
return ty::Binder::bind_with_vars(
278278
self.tcx.mk_fn_sig(
@@ -297,7 +297,7 @@ impl<'tcx> GotocCtx<'tcx> {
297297

298298
// In addition to `def_id` and `substs`, we need to provide the kind of region `env_region`
299299
// in `closure_env_ty`, which we can build from the bound variables as follows
300-
let bound_vars = self.tcx.mk_bound_variable_kinds(
300+
let bound_vars = self.tcx.mk_bound_variable_kinds_from_iter(
301301
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
302302
);
303303
let br = ty::BoundRegion {
@@ -314,7 +314,7 @@ impl<'tcx> GotocCtx<'tcx> {
314314
// * the rest of attributes are obtained from `sig`
315315
let sig = ty::Binder::bind_with_vars(
316316
self.tcx.mk_fn_sig(
317-
iter::once(env_ty).chain(iter::once(sig.inputs()[0])),
317+
[env_ty, sig.inputs()[0]],
318318
sig.output(),
319319
sig.c_variadic,
320320
sig.unsafety,
@@ -338,19 +338,19 @@ impl<'tcx> GotocCtx<'tcx> {
338338
) -> ty::PolyFnSig<'tcx> {
339339
let sig = substs.as_generator().poly_sig();
340340

341-
let bound_vars = self.tcx.mk_bound_variable_kinds(
341+
let bound_vars = self.tcx.mk_bound_variable_kinds_from_iter(
342342
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
343343
);
344344
let br = ty::BoundRegion {
345345
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
346346
kind: ty::BoundRegionKind::BrEnv,
347347
};
348348
let env_region = ty::ReLateBound(ty::INNERMOST, br);
349-
let env_ty = self.tcx.mk_mut_ref(self.tcx.mk_region(env_region), ty);
349+
let env_ty = self.tcx.mk_mut_ref(self.tcx.mk_region_from_kind(env_region), ty);
350350

351351
let pin_did = self.tcx.require_lang_item(LangItem::Pin, None);
352352
let pin_adt_ref = self.tcx.adt_def(pin_did);
353-
let pin_substs = self.tcx.intern_substs(&[env_ty.into()]);
353+
let pin_substs = self.tcx.mk_substs(&[env_ty.into()]);
354354
let env_ty = self.tcx.mk_adt(pin_adt_ref, pin_substs);
355355

356356
let sig = sig.skip_binder();
@@ -363,7 +363,7 @@ impl<'tcx> GotocCtx<'tcx> {
363363
// The signature should be `Future::poll(_, &mut Context<'_>) -> Poll<Output>`
364364
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
365365
let poll_adt_ref = tcx.adt_def(poll_did);
366-
let poll_substs = tcx.intern_substs(&[sig.return_ty.into()]);
366+
let poll_substs = tcx.mk_substs(&[sig.return_ty.into()]);
367367
let ret_ty = tcx.mk_adt(poll_adt_ref, poll_substs);
368368

369369
// We have to replace the `ResumeTy` that is used for type and borrow checking
@@ -384,16 +384,16 @@ impl<'tcx> GotocCtx<'tcx> {
384384
// The signature should be `Generator::resume(_, Resume) -> GeneratorState<Yield, Return>`
385385
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
386386
let state_adt_ref = tcx.adt_def(state_did);
387-
let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]);
387+
let state_substs = tcx.mk_substs(&[sig.yield_ty.into(), sig.return_ty.into()]);
388388
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
389389

390390
(sig.resume_ty, ret_ty)
391391
};
392392

393393
ty::Binder::bind_with_vars(
394394
tcx.mk_fn_sig(
395-
[env_ty, resume_ty].iter(),
396-
&ret_ty,
395+
[env_ty, resume_ty],
396+
ret_ty,
397397
false,
398398
Unsafety::Normal,
399399
rustc_target::spec::abi::Abi::Rust,
@@ -423,7 +423,7 @@ impl<'tcx> GotocCtx<'tcx> {
423423
impl<'tcx> GotocCtx<'tcx> {
424424
pub fn monomorphize<T>(&self, value: T) -> T
425425
where
426-
T: TypeFoldable<'tcx>,
426+
T: TypeFoldable<TyCtxt<'tcx>>,
427427
{
428428
// Instance is Some(..) only when current codegen unit is a function.
429429
if let Some(current_fn) = &self.current_fn {

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_codegen_ssa::traits::CodegenBackend;
2323
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
2424
use rustc_data_structures::fx::FxHashMap;
2525
use rustc_data_structures::temp_dir::MaybeTempDir;
26-
use rustc_errors::ErrorGuaranteed;
26+
use rustc_errors::{ErrorGuaranteed, DEFAULT_LOCALE_RESOURCE};
2727
use rustc_hir::def_id::LOCAL_CRATE;
2828
use rustc_metadata::fs::{emit_wrapper_file, METADATA_FILENAME};
2929
use rustc_metadata::EncodedMetadata;
@@ -70,6 +70,10 @@ impl GotocCodegenBackend {
7070
}
7171

7272
impl CodegenBackend for GotocCodegenBackend {
73+
fn locale_resource(&self) -> &'static str {
74+
DEFAULT_LOCALE_RESOURCE
75+
}
76+
7377
fn metadata_loader(&self) -> Box<MetadataLoaderDyn> {
7478
Box::new(rustc_codegen_ssa::back::metadata::DefaultMetadataLoader)
7579
}

kani-compiler/src/codegen_cprover_gotoc/context/goto_ctx.rs

+1
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for GotocCtx<'tcx> {
422422
}
423423
}
424424

425+
#[derive(Debug)]
425426
pub struct GotocMetadataLoader();
426427
impl MetadataLoader for GotocMetadataLoader {
427428
fn get_rlib_metadata(&self, _: &Target, _filename: &Path) -> Result<MetadataRef, String> {

kani-compiler/src/kani_middle/reachability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct MonoItemsFnCollector<'a, 'tcx> {
215215
impl<'a, 'tcx> MonoItemsFnCollector<'a, 'tcx> {
216216
fn monomorphize<T>(&self, value: T) -> T
217217
where
218-
T: TypeFoldable<'tcx>,
218+
T: TypeFoldable<TyCtxt<'tcx>>,
219219
{
220220
trace!(instance=?self.instance, ?value, "monomorphize");
221221
self.instance.subst_mir_and_normalize_erasing_regions(

kani-compiler/src/session.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::parser;
77
use clap::ArgMatches;
88
use rustc_errors::{
99
emitter::Emitter, emitter::HumanReadableErrorType, fallback_fluent_bundle, json::JsonEmitter,
10-
ColorConfig, Diagnostic, TerminalUrl,
10+
ColorConfig, Diagnostic, TerminalUrl, DEFAULT_LOCALE_RESOURCE,
1111
};
1212
use std::panic;
1313
use std::str::FromStr;
@@ -47,8 +47,7 @@ static JSON_PANIC_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send
4747
panic::set_hook(Box::new(|info| {
4848
// Print stack trace.
4949
let msg = format!("Kani unexpectedly panicked at {info}.",);
50-
let fallback_bundle =
51-
fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
50+
let fallback_bundle = fallback_fluent_bundle(vec![DEFAULT_LOCALE_RESOURCE], false);
5251
let mut emitter = JsonEmitter::basic(
5352
false,
5453
HumanReadableErrorType::Default(ColorConfig::Never),

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-2023-02-18"
5+
channel = "nightly-2023-03-09"
66
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

tools/bookrunner/librustdoc/doctest.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ pub fn make_test(
7878
// send all the errors that librustc_ast emits directly into a `Sink` instead of stderr.
7979
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
8080

81-
let fallback_bundle =
82-
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
81+
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
82+
vec![rustc_errors::DEFAULT_LOCALE_RESOURCE],
83+
false,
84+
);
8385
supports_color = EmitterWriter::stderr(
8486
ColorConfig::Auto,
8587
None,

0 commit comments

Comments
 (0)