Skip to content

Commit 1443181

Browse files
committed
Update rust toolchain to nightly-2022-05-03
This compiles but regression is failing due to unimplemented statement.
1 parent 8c848e2 commit 1443181

File tree

10 files changed

+107
-96
lines changed

10 files changed

+107
-96
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl<'tcx> GotocCtx<'tcx> {
482482
};
483483
let relative_max =
484484
niche_variants.end().as_u32() - niche_variants.start().as_u32();
485-
let is_niche = if tag.value == Primitive::Pointer {
485+
let is_niche = if tag.primitive() == Primitive::Pointer {
486486
discr_ty.null().eq(relative_discr.clone())
487487
} else {
488488
relative_discr

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,12 @@ impl<'tcx> GotocCtx<'tcx> {
686686
let niche_value =
687687
variant_index.as_u32() - niche_variants.start().as_u32();
688688
let niche_value = (niche_value as u128).wrapping_add(*niche_start);
689-
let value = if niche_value == 0 && tag.value == Primitive::Pointer {
690-
discr_ty.null()
691-
} else {
692-
Expr::int_constant(niche_value, discr_ty.clone())
693-
};
689+
let value =
690+
if niche_value == 0 && tag.primitive() == Primitive::Pointer {
691+
discr_ty.null()
692+
} else {
693+
Expr::int_constant(niche_value, discr_ty.clone())
694+
};
694695
let place = unwrap_or_return_codegen_unimplemented_stmt!(
695696
self,
696697
self.codegen_place(place)
@@ -739,6 +740,7 @@ impl<'tcx> GotocCtx<'tcx> {
739740
| StatementKind::AscribeUserType(_, _)
740741
| StatementKind::Nop
741742
| StatementKind::Coverage { .. } => Stmt::skip(Location::none()),
743+
StatementKind::Deinit(_) => todo!("Unimplemented statement. See: "),
742744
}
743745
.with_location(self.codegen_span(&stmt.source_info.span))
744746
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ impl<'tcx> GotocCtx<'tcx> {
12061206
pub fn codegen_enum_discr_typ(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
12071207
let layout = self.layout_of(ty);
12081208
match &layout.variants {
1209-
Variants::Multiple { tag, .. } => self.codegen_prim_typ(tag.value),
1209+
Variants::Multiple { tag, .. } => self.codegen_prim_typ(tag.primitive()),
12101210
_ => unreachable!("only enum has discriminant"),
12111211
}
12121212
}
@@ -1263,7 +1263,7 @@ impl<'tcx> GotocCtx<'tcx> {
12631263
_ => unreachable!(),
12641264
};
12651265

1266-
let rustc_target::abi::Scalar { value: prim_type, .. } = element;
1266+
let prim_type = element.primitive();
12671267
let rust_type = self.codegen_prim_typ(prim_type);
12681268
let cbmc_type = self.codegen_ty(rust_type);
12691269

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

tools/bookrunner/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ crate fn try_inline(
104104
record_extern_fqn(cx, did, ItemType::Module);
105105
clean::ModuleItem(build_module(cx, did, visited))
106106
}
107-
Res::Def(DefKind::Static, did) => {
107+
Res::Def(DefKind::Static(..), did) => {
108108
record_extern_fqn(cx, did, ItemType::Static);
109109
clean::StaticItem(build_static(cx, did, cx.tcx.is_mutable_static(did)))
110110
}

tools/bookrunner/librustdoc/clean/mod.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,7 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
248248
// Higher-ranked lifetimes can't have bounds.
249249
assert_matches!(
250250
param,
251-
hir::GenericParam {
252-
kind: hir::GenericParamKind::Lifetime { .. },
253-
bounds: [],
254-
..
255-
}
251+
hir::GenericParam { kind: hir::GenericParamKind::Lifetime { .. }, .. }
256252
);
257253
Lifetime(param.name.ident().name)
258254
})
@@ -414,7 +410,7 @@ impl Clean<GenericParamDef> for ty::GenericParamDef {
414410
// `self_def_id` set, we override it here.
415411
// See https://github.com/rust-lang/rust/issues/85454
416412
if let QPath { ref mut self_def_id, .. } = default {
417-
*self_def_id = cx.tcx.parent(self.def_id);
413+
*self_def_id = Some(cx.tcx.parent(self.def_id));
418414
}
419415

420416
Some(default)
@@ -452,27 +448,19 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
452448
fn clean(&self, cx: &mut DocContext<'_>) -> GenericParamDef {
453449
let (name, kind) = match self.kind {
454450
hir::GenericParamKind::Lifetime { .. } => {
455-
let outlives = self
456-
.bounds
457-
.iter()
458-
.map(|bound| match bound {
459-
hir::GenericBound::Outlives(lt) => lt.clean(cx),
460-
_ => panic!(),
461-
})
462-
.collect();
463-
(self.name.ident().name, GenericParamDefKind::Lifetime { outlives })
451+
(self.name, GenericParamDefKind::Lifetime { outlives: vec![] })
464452
}
465-
hir::GenericParamKind::Type { ref default, synthetic } => (
466-
self.name.ident().name,
453+
hir::GenericParamKind::Type { ref default, synthetic, .. } => (
454+
self.name,
467455
GenericParamDefKind::Type {
468456
did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(),
469-
bounds: self.bounds.iter().filter_map(|x| x.clean(cx)).collect(),
457+
bounds: vec![],
470458
default: default.map(|t| t.clean(cx)).map(Box::new),
471459
synthetic,
472460
},
473461
),
474462
hir::GenericParamKind::Const { ref ty, default } => (
475-
self.name.ident().name,
463+
self.name,
476464
GenericParamDefKind::Const {
477465
did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(),
478466
ty: Box::new(ty.clean(cx)),
@@ -484,7 +472,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
484472
),
485473
};
486474

487-
GenericParamDef { name, kind }
475+
GenericParamDef { name: name.ident().name, kind }
488476
}
489477
}
490478

@@ -537,7 +525,7 @@ impl Clean<Generics> for hir::Generics<'_> {
537525

538526
let mut generics = Generics {
539527
params,
540-
where_predicates: self.where_clause.predicates.iter().map(|x| x.clean(cx)).collect(),
528+
where_predicates: self.predicates.iter().map(|x| x.clean(cx)).collect(),
541529
};
542530

543531
// Some duplicates are generated for ?Sized bounds between type params and where
@@ -1666,9 +1654,7 @@ fn clean_field(def_id: DefId, name: Symbol, ty: Type, cx: &mut DocContext<'_>) -
16661654
}
16671655

16681656
fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
1669-
let parent = tcx
1670-
.parent(def_id)
1671-
.expect("is_field_vis_inherited can only be called on struct or variant fields");
1657+
let parent = tcx.parent(def_id);
16721658
match tcx.def_kind(parent) {
16731659
DefKind::Struct | DefKind::Union => false,
16741660
DefKind::Variant => true,

tools/bookrunner/librustdoc/clean/types.rs

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// See GitHub history for details.
55
use std::default::Default;
66
use std::hash::Hash;
7+
use std::iter;
78
use std::lazy::SyncOnceCell as OnceCell;
89
use std::sync::Arc;
910
use std::{slice, vec};
@@ -21,6 +22,7 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE};
2122
use rustc_hir::lang_items::LangItem;
2223
use rustc_hir::{BodyId, Mutability};
2324
use rustc_index::vec::IndexVec;
25+
use rustc_middle::ty::fast_reject::SimplifiedType;
2426
use rustc_middle::ty::{self, TyCtxt};
2527
use rustc_span::hygiene::MacroKind;
2628
use rustc_span::source_map::DUMMY_SP;
@@ -935,69 +937,70 @@ crate enum PrimitiveType {
935937
Never,
936938
}
937939

940+
type SimplifiedTypes = FxHashMap<PrimitiveType, ArrayVec<SimplifiedType, 2>>;
938941
impl PrimitiveType {
939-
crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static ArrayVec<DefId, 4> {
940-
Self::all_impls(tcx).get(self).expect("missing impl for primitive type")
941-
}
942-
943-
crate fn all_impls(tcx: TyCtxt<'_>) -> &'static FxHashMap<PrimitiveType, ArrayVec<DefId, 4>> {
944-
static CELL: OnceCell<FxHashMap<PrimitiveType, ArrayVec<DefId, 4>>> = OnceCell::new();
942+
crate fn simplified_types() -> &'static SimplifiedTypes {
943+
use ty::fast_reject::SimplifiedTypeGen::*;
944+
use ty::{FloatTy, IntTy, UintTy};
945+
use PrimitiveType::*;
946+
static CELL: OnceCell<SimplifiedTypes> = OnceCell::new();
945947

948+
let single = |x| iter::once(x).collect();
946949
CELL.get_or_init(move || {
947-
use self::PrimitiveType::*;
948-
949-
let single = |a: Option<DefId>| a.into_iter().collect();
950-
let both = |a: Option<DefId>, b: Option<DefId>| -> ArrayVec<_, 4> {
951-
a.into_iter().chain(b).collect()
952-
};
953-
954-
let lang_items = tcx.lang_items();
955950
map! {
956-
Isize => single(lang_items.isize_impl()),
957-
I8 => single(lang_items.i8_impl()),
958-
I16 => single(lang_items.i16_impl()),
959-
I32 => single(lang_items.i32_impl()),
960-
I64 => single(lang_items.i64_impl()),
961-
I128 => single(lang_items.i128_impl()),
962-
Usize => single(lang_items.usize_impl()),
963-
U8 => single(lang_items.u8_impl()),
964-
U16 => single(lang_items.u16_impl()),
965-
U32 => single(lang_items.u32_impl()),
966-
U64 => single(lang_items.u64_impl()),
967-
U128 => single(lang_items.u128_impl()),
968-
F32 => both(lang_items.f32_impl(), lang_items.f32_runtime_impl()),
969-
F64 => both(lang_items.f64_impl(), lang_items.f64_runtime_impl()),
970-
Char => single(lang_items.char_impl()),
971-
Bool => single(lang_items.bool_impl()),
972-
Str => both(lang_items.str_impl(), lang_items.str_alloc_impl()),
973-
Slice => {
974-
lang_items
975-
.slice_impl()
976-
.into_iter()
977-
.chain(lang_items.slice_u8_impl())
978-
.chain(lang_items.slice_alloc_impl())
979-
.chain(lang_items.slice_u8_alloc_impl())
980-
.collect()
981-
},
982-
Array => single(lang_items.array_impl()),
983-
Tuple => ArrayVec::new(),
984-
Unit => ArrayVec::new(),
985-
RawPointer => {
986-
lang_items
987-
.const_ptr_impl()
988-
.into_iter()
989-
.chain(lang_items.mut_ptr_impl())
990-
.chain(lang_items.const_slice_ptr_impl())
991-
.chain(lang_items.mut_slice_ptr_impl())
992-
.collect()
993-
},
994-
Reference => ArrayVec::new(),
951+
Isize => single(IntSimplifiedType(IntTy::Isize)),
952+
I8 => single(IntSimplifiedType(IntTy::I8)),
953+
I16 => single(IntSimplifiedType(IntTy::I16)),
954+
I32 => single(IntSimplifiedType(IntTy::I32)),
955+
I64 => single(IntSimplifiedType(IntTy::I64)),
956+
I128 => single(IntSimplifiedType(IntTy::I128)),
957+
Usize => single(UintSimplifiedType(UintTy::Usize)),
958+
U8 => single(UintSimplifiedType(UintTy::U8)),
959+
U16 => single(UintSimplifiedType(UintTy::U16)),
960+
U32 => single(UintSimplifiedType(UintTy::U32)),
961+
U64 => single(UintSimplifiedType(UintTy::U64)),
962+
U128 => single(UintSimplifiedType(UintTy::U128)),
963+
F32 => single(FloatSimplifiedType(FloatTy::F32)),
964+
F64 => single(FloatSimplifiedType(FloatTy::F64)),
965+
Str => single(StrSimplifiedType),
966+
Bool => single(BoolSimplifiedType),
967+
Char => single(CharSimplifiedType),
968+
Array => single(ArraySimplifiedType),
969+
Slice => single(SliceSimplifiedType),
970+
// FIXME: If we ever add an inherent impl for tuples
971+
// with different lengths, they won't show in rustdoc.
972+
//
973+
// Either manually update this arrayvec at this point
974+
// or start with a more complex refactoring.
975+
Tuple => [TupleSimplifiedType(2), TupleSimplifiedType(3)].into(),
976+
Unit => single(TupleSimplifiedType(0)),
977+
RawPointer => [PtrSimplifiedType(Mutability::Not), PtrSimplifiedType(Mutability::Mut)].into(),
978+
Reference => [RefSimplifiedType(Mutability::Not), RefSimplifiedType(Mutability::Mut)].into(),
979+
// FIXME: This will be wrong if we ever add inherent impls
980+
// for function pointers.
995981
Fn => ArrayVec::new(),
996-
Never => ArrayVec::new(),
982+
Never => single(NeverSimplifiedType),
997983
}
998984
})
999985
}
1000986

987+
crate fn impls<'tcx>(&self, tcx: TyCtxt<'tcx>) -> impl Iterator<Item = DefId> + 'tcx {
988+
Self::simplified_types()
989+
.get(self)
990+
.into_iter()
991+
.flatten()
992+
.flat_map(move |&simp| tcx.incoherent_impls(simp))
993+
.copied()
994+
}
995+
996+
crate fn all_impls(tcx: TyCtxt<'_>) -> impl Iterator<Item = DefId> + '_ {
997+
Self::simplified_types()
998+
.values()
999+
.flatten()
1000+
.flat_map(move |&simp| tcx.incoherent_impls(simp))
1001+
.copied()
1002+
}
1003+
10011004
crate fn as_sym(&self) -> Symbol {
10021005
use PrimitiveType::*;
10031006
match self {

tools/bookrunner/librustdoc/clean/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ crate fn build_deref_target_impls(cx: &mut DocContext<'_>, items: &[Item], ret:
113113

114114
if let Some(prim) = target.primitive_type() {
115115
let _prof_timer = cx.tcx.sess.prof.generic_activity("build_primitive_inherent_impls");
116-
for &did in prim.impls(tcx).iter().filter(|did| !did.is_local()) {
116+
for did in prim.impls(tcx).filter(|did| !did.is_local()) {
117117
inline::build_impl(cx, None, did, None, ret);
118118
}
119119
} else if let Type::Path { path } = target {
@@ -229,7 +229,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
229229
// These should be added to the cache using `record_extern_fqn`.
230230
Res::Def(
231231
kind @ (AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
232-
| Union | Mod | ForeignTy | Const | Static | Macro(..) | TraitAlias),
232+
| Union | Mod | ForeignTy | Const | Static(..) | Macro(..) | TraitAlias),
233233
i,
234234
) => (i, kind.into()),
235235
// This is part of a trait definition; document the trait.

tools/bookrunner/librustdoc/doctest.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,32 @@ pub fn make_test(
333333
// Any errors in parsing should also appear when the doctest is compiled for real, so just
334334
// send all the errors that librustc_ast emits directly into a `Sink` instead of stderr.
335335
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
336-
supports_color =
337-
EmitterWriter::stderr(ColorConfig::Auto, None, false, false, Some(80), false)
338-
.supports_color();
339336

340-
let emitter =
341-
EmitterWriter::new(box io::sink(), None, false, false, false, None, false);
337+
let fallback_bundle =
338+
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
339+
supports_color = EmitterWriter::stderr(
340+
ColorConfig::Auto,
341+
None,
342+
None,
343+
fallback_bundle.clone(),
344+
false,
345+
false,
346+
Some(80),
347+
false,
348+
)
349+
.supports_color();
350+
351+
let emitter = EmitterWriter::new(
352+
box io::sink(),
353+
None,
354+
None,
355+
fallback_bundle,
356+
false,
357+
false,
358+
false,
359+
None,
360+
false,
361+
);
342362

343363
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
344364
let handler = Handler::with_emitter(false, None, box emitter);

tools/bookrunner/librustdoc/formats/item_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl From<DefKind> for ItemType {
116116
DefKind::Fn => Self::Function,
117117
DefKind::Mod => Self::Module,
118118
DefKind::Const => Self::Constant,
119-
DefKind::Static => Self::Static,
119+
DefKind::Static(..) => Self::Static,
120120
DefKind::Struct => Self::Struct,
121121
DefKind::Union => Self::Union,
122122
DefKind::Trait => Self::Trait,

0 commit comments

Comments
 (0)