Skip to content

[DRAFT] Update Rust toolchain to 2022-12-04 #1983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_middle::ty::{
use rustc_middle::ty::{List, TypeFoldable};
use rustc_span::def_id::DefId;
use rustc_target::abi::{
Abi::Vector, FieldsShape, Integer, Layout, Primitive, Size, TagEncoding, TyAndLayout,
Abi::Vector, FieldsShape, Integer, LayoutS, Primitive, Size, TagEncoding, TyAndLayout,
VariantIdx, Variants,
};
use rustc_target::spec::abi::Abi;
Expand Down Expand Up @@ -862,10 +862,10 @@ impl<'tcx> GotocCtx<'tcx> {
fn codegen_alignment_padding(
&self,
size: Size,
layout: &Layout,
layout: &LayoutS<VariantIdx>,
idx: usize,
) -> Option<DatatypeComponent> {
let align = Size::from_bits(layout.align().abi.bits());
let align = Size::from_bits(layout.align.abi.bits());
let overhang = Size::from_bits(size.bits() % align.bits());
if overhang != Size::ZERO {
self.codegen_struct_padding(size, size + align - overhang, idx)
Expand All @@ -887,16 +887,16 @@ impl<'tcx> GotocCtx<'tcx> {
fn codegen_struct_fields(
&mut self,
flds: Vec<(String, Ty<'tcx>)>,
layout: &Layout,
layout: &LayoutS<VariantIdx>,
initial_offset: Size,
) -> Vec<DatatypeComponent> {
match &layout.fields() {
match &layout.fields {
FieldsShape::Arbitrary { offsets, memory_index } => {
assert_eq!(flds.len(), offsets.len());
assert_eq!(offsets.len(), memory_index.len());
let mut final_fields = Vec::with_capacity(flds.len());
let mut offset = initial_offset;
for idx in layout.fields().index_by_increasing_offset() {
for idx in layout.fields.index_by_increasing_offset() {
let fld_offset = offsets[idx];
let (fld_name, fld_ty) = &flds[idx];
if let Some(padding) =
Expand All @@ -919,7 +919,7 @@ impl<'tcx> GotocCtx<'tcx> {
}
// Primitives, such as NEVER, have no fields
FieldsShape::Primitive => vec![],
_ => unreachable!("{}\n{:?}", self.current_fn().readable_name(), layout.fields()),
_ => unreachable!("{}\n{:?}", self.current_fn().readable_name(), layout.fields),
}
}

Expand All @@ -928,7 +928,7 @@ impl<'tcx> GotocCtx<'tcx> {
let flds: Vec<_> =
tys.iter().enumerate().map(|(i, t)| (GotocCtx::tuple_fld_name(i), *t)).collect();
// tuple cannot have other initial offset
self.codegen_struct_fields(flds, &layout.layout, Size::ZERO)
self.codegen_struct_fields(flds, &layout.layout.0, Size::ZERO)
}

/// A closure in Rust MIR takes two arguments:
Expand Down Expand Up @@ -1133,7 +1133,7 @@ impl<'tcx> GotocCtx<'tcx> {
}
fields.extend(ctx.codegen_alignment_padding(
offset,
&type_and_layout.layout,
&type_and_layout.layout.0,
fields.len(),
));
fields
Expand Down Expand Up @@ -1331,7 +1331,7 @@ impl<'tcx> GotocCtx<'tcx> {
self.ensure_struct(self.ty_mangled_name(ty), self.ty_pretty_name(ty), |ctx, _| {
let variant = &def.variants().raw[0];
let layout = ctx.layout_of(ty);
ctx.codegen_variant_struct_fields(variant, subst, &layout.layout, Size::ZERO)
ctx.codegen_variant_struct_fields(variant, subst, &layout.layout.0, Size::ZERO)
})
}

Expand All @@ -1340,7 +1340,7 @@ impl<'tcx> GotocCtx<'tcx> {
&mut self,
variant: &VariantDef,
subst: &'tcx InternalSubsts<'tcx>,
layout: &Layout,
layout: &LayoutS<VariantIdx>,
initial_offset: Size,
) -> Vec<DatatypeComponent> {
let flds: Vec<_> =
Expand Down Expand Up @@ -1423,7 +1423,7 @@ impl<'tcx> GotocCtx<'tcx> {
Some(variant) => {
// a single enum is pretty much like a struct
let layout = gcx.layout_of(ty).layout;
gcx.codegen_variant_struct_fields(variant, subst, &layout, Size::ZERO)
gcx.codegen_variant_struct_fields(variant, subst, &layout.0, Size::ZERO)
}
}
})
Expand Down Expand Up @@ -1509,9 +1509,9 @@ impl<'tcx> GotocCtx<'tcx> {
ty: Ty<'tcx>,
adtdef: &'tcx AdtDef,
subst: &'tcx InternalSubsts<'tcx>,
variants: &IndexVec<VariantIdx, Layout>,
variants: &IndexVec<VariantIdx, LayoutS<VariantIdx>>,
) -> Type {
let non_zst_count = variants.iter().filter(|layout| layout.size().bytes() > 0).count();
let non_zst_count = variants.iter().filter(|layout| layout.size.bytes() > 0).count();
let mangled_name = self.ty_mangled_name(ty);
let pretty_name = self.ty_pretty_name(ty);
tracing::trace!(?pretty_name, ?variants, ?subst, ?non_zst_count, "codegen_enum: Niche");
Expand All @@ -1528,23 +1528,20 @@ impl<'tcx> GotocCtx<'tcx> {

pub(crate) fn variant_min_offset(
&self,
variants: &IndexVec<VariantIdx, Layout>,
variants: &IndexVec<VariantIdx, LayoutS<VariantIdx>>,
) -> Option<Size> {
variants
.iter()
.filter_map(|lo| {
if lo.fields().count() == 0 {
if lo.fields.count() == 0 {
None
} else {
// get the offset of the leftmost field, which is the one
// with the least offset since we codegen fields in a struct
// in the order of increasing offsets. Note that this is not
// necessarily the 0th field since the compiler may reorder
// fields.
Some(
lo.fields()
.offset(lo.fields().index_by_increasing_offset().next().unwrap()),
)
Some(lo.fields.offset(lo.fields.index_by_increasing_offset().next().unwrap()))
}
})
.min()
Expand Down Expand Up @@ -1615,7 +1612,7 @@ impl<'tcx> GotocCtx<'tcx> {
pretty_name: InternedString,
def: &'tcx AdtDef,
subst: &'tcx InternalSubsts<'tcx>,
layouts: &IndexVec<VariantIdx, Layout>,
layouts: &IndexVec<VariantIdx, LayoutS<VariantIdx>>,
initial_offset: Size,
) -> Vec<DatatypeComponent> {
def.variants()
Expand Down Expand Up @@ -1647,7 +1644,7 @@ impl<'tcx> GotocCtx<'tcx> {
pretty_name: InternedString,
case: &VariantDef,
subst: &'tcx InternalSubsts<'tcx>,
variant: &Layout,
variant: &LayoutS<VariantIdx>,
initial_offset: Size,
) -> Type {
let case_name = format!("{name}::{}", case.name);
Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/kani_middle/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn extract_integer_argument(attr: &Attribute) -> Option<u128> {
let attr_args = attr.meta_item_list()?;
// Only extracts one integer value as argument
if attr_args.len() == 1 {
let x = attr_args[0].literal()?;
let x = attr_args[0].lit()?;
match x.kind {
LitKind::Int(y, ..) => Some(y),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/kani_middle/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn custom_coerce_unsize_info<'tcx>(

let trait_ref = ty::Binder::dummy(TraitRef {
def_id,
substs: tcx.mk_substs_trait(source_ty, &[target_ty.into()]),
substs: tcx.mk_substs_trait(source_ty, [target_ty.into()]),
});

match tcx.codegen_select_candidate((ParamEnv::reveal_all(), trait_ref)) {
Expand Down
5 changes: 4 additions & 1 deletion kani-compiler/src/kani_middle/reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MonoItemsFnCollector<'a, 'tcx> {
ConstKind::Value(v) => self.tcx.valtree_to_const_val((ct.ty(), v)),
ConstKind::Unevaluated(_) => unreachable!(),
// Nothing to do
ConstKind::Param(..) | ConstKind::Infer(..) | ConstKind::Error(..) => return,
ConstKind::Param(..)
| ConstKind::Infer(..)
| ConstKind::Error(..)
| ConstKind::Expr(..) => return,

// Shouldn't happen
ConstKind::Placeholder(..) | ConstKind::Bound(..) => {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

[toolchain]
channel = "nightly-2022-11-20"
channel = "nightly-2022-12-04"
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]