Skip to content

Commit 7f804a2

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

File tree

17 files changed

+157
-182
lines changed

17 files changed

+157
-182
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
@@ -254,11 +254,7 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
254254
// Higher-ranked lifetimes can't have bounds.
255255
assert_matches!(
256256
param,
257-
hir::GenericParam {
258-
kind: hir::GenericParamKind::Lifetime { .. },
259-
bounds: [],
260-
..
261-
}
257+
hir::GenericParam { kind: hir::GenericParamKind::Lifetime { .. }, .. }
262258
);
263259
Lifetime(param.name.ident().name)
264260
})
@@ -420,7 +416,7 @@ impl Clean<GenericParamDef> for ty::GenericParamDef {
420416
// `self_def_id` set, we override it here.
421417
// See https://github.com/rust-lang/rust/issues/85454
422418
if let QPath { ref mut self_def_id, .. } = default {
423-
*self_def_id = cx.tcx.parent(self.def_id);
419+
*self_def_id = Some(cx.tcx.parent(self.def_id));
424420
}
425421

426422
Some(default)
@@ -458,27 +454,19 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
458454
fn clean(&self, cx: &mut DocContext<'_>) -> GenericParamDef {
459455
let (name, kind) = match self.kind {
460456
hir::GenericParamKind::Lifetime { .. } => {
461-
let outlives = self
462-
.bounds
463-
.iter()
464-
.map(|bound| match bound {
465-
hir::GenericBound::Outlives(lt) => lt.clean(cx),
466-
_ => panic!(),
467-
})
468-
.collect();
469-
(self.name.ident().name, GenericParamDefKind::Lifetime { outlives })
457+
(self.name, GenericParamDefKind::Lifetime { outlives: vec![] })
470458
}
471-
hir::GenericParamKind::Type { ref default, synthetic } => (
472-
self.name.ident().name,
459+
hir::GenericParamKind::Type { ref default, synthetic, .. } => (
460+
self.name,
473461
GenericParamDefKind::Type {
474462
did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(),
475-
bounds: self.bounds.iter().filter_map(|x| x.clean(cx)).collect(),
463+
bounds: vec![],
476464
default: default.map(|t| t.clean(cx)).map(Box::new),
477465
synthetic,
478466
},
479467
),
480468
hir::GenericParamKind::Const { ref ty, default } => (
481-
self.name.ident().name,
469+
self.name,
482470
GenericParamDefKind::Const {
483471
did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(),
484472
ty: Box::new(ty.clean(cx)),
@@ -490,7 +478,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
490478
),
491479
};
492480

493-
GenericParamDef { name, kind }
481+
GenericParamDef { name: name.ident().name, kind }
494482
}
495483
}
496484

@@ -543,7 +531,7 @@ impl Clean<Generics> for hir::Generics<'_> {
543531

544532
let mut generics = Generics {
545533
params,
546-
where_predicates: self.where_clause.predicates.iter().map(|x| x.clean(cx)).collect(),
534+
where_predicates: self.predicates.iter().map(|x| x.clean(cx)).collect(),
547535
};
548536

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

16741662
fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
1675-
let parent = tcx
1676-
.parent(def_id)
1677-
.expect("is_field_vis_inherited can only be called on struct or variant fields");
1663+
let parent = tcx.parent(def_id);
16781664
match tcx.def_kind(parent) {
16791665
DefKind::Struct | DefKind::Union => false,
16801666
DefKind::Variant => true,

tools/bookrunner/librustdoc/clean/types.rs

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use std::cell::RefCell;
66
use std::default::Default;
77
use std::hash::Hash;
8+
use std::iter;
89
use std::lazy::SyncOnceCell as OnceCell;
910
use std::path::PathBuf;
1011
use std::rc::Rc;
@@ -25,6 +26,7 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE}
2526
use rustc_hir::lang_items::LangItem;
2627
use rustc_hir::{BodyId, Mutability};
2728
use rustc_index::vec::IndexVec;
29+
use rustc_middle::ty::fast_reject::SimplifiedType;
2830
use rustc_middle::ty::{self, TyCtxt};
2931
use rustc_session::Session;
3032
use rustc_span::hygiene::MacroKind;
@@ -1483,6 +1485,7 @@ crate enum PrimitiveType {
14831485
Never,
14841486
}
14851487

1488+
type SimplifiedTypes = FxHashMap<PrimitiveType, ArrayVec<SimplifiedType, 2>>;
14861489
impl PrimitiveType {
14871490
crate fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
14881491
use ast::{FloatTy, IntTy, UintTy};
@@ -1538,68 +1541,68 @@ impl PrimitiveType {
15381541
}
15391542
}
15401543

1541-
crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static ArrayVec<DefId, 4> {
1542-
Self::all_impls(tcx).get(self).expect("missing impl for primitive type")
1543-
}
1544-
1545-
crate fn all_impls(tcx: TyCtxt<'_>) -> &'static FxHashMap<PrimitiveType, ArrayVec<DefId, 4>> {
1546-
static CELL: OnceCell<FxHashMap<PrimitiveType, ArrayVec<DefId, 4>>> = OnceCell::new();
1544+
crate fn simplified_types() -> &'static SimplifiedTypes {
1545+
use ty::fast_reject::SimplifiedTypeGen::*;
1546+
use ty::{FloatTy, IntTy, UintTy};
1547+
use PrimitiveType::*;
1548+
static CELL: OnceCell<SimplifiedTypes> = OnceCell::new();
15471549

1550+
let single = |x| iter::once(x).collect();
15481551
CELL.get_or_init(move || {
1549-
use self::PrimitiveType::*;
1550-
1551-
let single = |a: Option<DefId>| a.into_iter().collect();
1552-
let both = |a: Option<DefId>, b: Option<DefId>| -> ArrayVec<_, 4> {
1553-
a.into_iter().chain(b).collect()
1554-
};
1555-
1556-
let lang_items = tcx.lang_items();
15571552
map! {
1558-
Isize => single(lang_items.isize_impl()),
1559-
I8 => single(lang_items.i8_impl()),
1560-
I16 => single(lang_items.i16_impl()),
1561-
I32 => single(lang_items.i32_impl()),
1562-
I64 => single(lang_items.i64_impl()),
1563-
I128 => single(lang_items.i128_impl()),
1564-
Usize => single(lang_items.usize_impl()),
1565-
U8 => single(lang_items.u8_impl()),
1566-
U16 => single(lang_items.u16_impl()),
1567-
U32 => single(lang_items.u32_impl()),
1568-
U64 => single(lang_items.u64_impl()),
1569-
U128 => single(lang_items.u128_impl()),
1570-
F32 => both(lang_items.f32_impl(), lang_items.f32_runtime_impl()),
1571-
F64 => both(lang_items.f64_impl(), lang_items.f64_runtime_impl()),
1572-
Char => single(lang_items.char_impl()),
1573-
Bool => single(lang_items.bool_impl()),
1574-
Str => both(lang_items.str_impl(), lang_items.str_alloc_impl()),
1575-
Slice => {
1576-
lang_items
1577-
.slice_impl()
1578-
.into_iter()
1579-
.chain(lang_items.slice_u8_impl())
1580-
.chain(lang_items.slice_alloc_impl())
1581-
.chain(lang_items.slice_u8_alloc_impl())
1582-
.collect()
1583-
},
1584-
Array => single(lang_items.array_impl()),
1585-
Tuple => ArrayVec::new(),
1586-
Unit => ArrayVec::new(),
1587-
RawPointer => {
1588-
lang_items
1589-
.const_ptr_impl()
1590-
.into_iter()
1591-
.chain(lang_items.mut_ptr_impl())
1592-
.chain(lang_items.const_slice_ptr_impl())
1593-
.chain(lang_items.mut_slice_ptr_impl())
1594-
.collect()
1595-
},
1596-
Reference => ArrayVec::new(),
1553+
Isize => single(IntSimplifiedType(IntTy::Isize)),
1554+
I8 => single(IntSimplifiedType(IntTy::I8)),
1555+
I16 => single(IntSimplifiedType(IntTy::I16)),
1556+
I32 => single(IntSimplifiedType(IntTy::I32)),
1557+
I64 => single(IntSimplifiedType(IntTy::I64)),
1558+
I128 => single(IntSimplifiedType(IntTy::I128)),
1559+
Usize => single(UintSimplifiedType(UintTy::Usize)),
1560+
U8 => single(UintSimplifiedType(UintTy::U8)),
1561+
U16 => single(UintSimplifiedType(UintTy::U16)),
1562+
U32 => single(UintSimplifiedType(UintTy::U32)),
1563+
U64 => single(UintSimplifiedType(UintTy::U64)),
1564+
U128 => single(UintSimplifiedType(UintTy::U128)),
1565+
F32 => single(FloatSimplifiedType(FloatTy::F32)),
1566+
F64 => single(FloatSimplifiedType(FloatTy::F64)),
1567+
Str => single(StrSimplifiedType),
1568+
Bool => single(BoolSimplifiedType),
1569+
Char => single(CharSimplifiedType),
1570+
Array => single(ArraySimplifiedType),
1571+
Slice => single(SliceSimplifiedType),
1572+
// FIXME: If we ever add an inherent impl for tuples
1573+
// with different lengths, they won't show in rustdoc.
1574+
//
1575+
// Either manually update this arrayvec at this point
1576+
// or start with a more complex refactoring.
1577+
Tuple => [TupleSimplifiedType(2), TupleSimplifiedType(3)].into(),
1578+
Unit => single(TupleSimplifiedType(0)),
1579+
RawPointer => [PtrSimplifiedType(Mutability::Not), PtrSimplifiedType(Mutability::Mut)].into(),
1580+
Reference => [RefSimplifiedType(Mutability::Not), RefSimplifiedType(Mutability::Mut)].into(),
1581+
// FIXME: This will be wrong if we ever add inherent impls
1582+
// for function pointers.
15971583
Fn => ArrayVec::new(),
1598-
Never => ArrayVec::new(),
1584+
Never => single(NeverSimplifiedType),
15991585
}
16001586
})
16011587
}
16021588

1589+
crate fn impls<'tcx>(&self, tcx: TyCtxt<'tcx>) -> impl Iterator<Item = DefId> + 'tcx {
1590+
Self::simplified_types()
1591+
.get(self)
1592+
.into_iter()
1593+
.flatten()
1594+
.flat_map(move |&simp| tcx.incoherent_impls(simp))
1595+
.copied()
1596+
}
1597+
1598+
crate fn all_impls(tcx: TyCtxt<'_>) -> impl Iterator<Item = DefId> + '_ {
1599+
Self::simplified_types()
1600+
.values()
1601+
.flatten()
1602+
.flat_map(move |&simp| tcx.incoherent_impls(simp))
1603+
.copied()
1604+
}
1605+
16031606
crate fn as_sym(&self) -> Symbol {
16041607
use PrimitiveType::*;
16051608
match self {

tools/bookrunner/librustdoc/clean/utils.rs

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

134134
if let Some(prim) = target.primitive_type() {
135135
let _prof_timer = cx.tcx.sess.prof.generic_activity("build_primitive_inherent_impls");
136-
for &did in prim.impls(tcx).iter().filter(|did| !did.is_local()) {
136+
for did in prim.impls(tcx).filter(|did| !did.is_local()) {
137137
inline::build_impl(cx, None, did, None, ret);
138138
}
139139
} else if let Type::Path { path } = target {
@@ -346,7 +346,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
346346
// These should be added to the cache using `record_extern_fqn`.
347347
Res::Def(
348348
kind @ (AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
349-
| Union | Mod | ForeignTy | Const | Static | Macro(..) | TraitAlias),
349+
| Union | Mod | ForeignTy | Const | Static(..) | Macro(..) | TraitAlias),
350350
i,
351351
) => (i, kind.into()),
352352
// This is part of a trait definition; document the trait.
@@ -404,7 +404,7 @@ crate fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<De
404404
let mut current = def_id;
405405
// The immediate parent might not always be a module.
406406
// Find the first parent which is.
407-
while let Some(parent) = tcx.parent(current) {
407+
while let parent = tcx.parent(current) {
408408
if tcx.def_kind(parent) == DefKind::Mod {
409409
return Some(parent);
410410
}

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
@@ -113,7 +113,7 @@ impl From<DefKind> for ItemType {
113113
DefKind::Fn => Self::Function,
114114
DefKind::Mod => Self::Module,
115115
DefKind::Const => Self::Constant,
116-
DefKind::Static => Self::Static,
116+
DefKind::Static(..) => Self::Static,
117117
DefKind::Struct => Self::Struct,
118118
DefKind::Union => Self::Union,
119119
DefKind::Trait => Self::Trait,

0 commit comments

Comments
 (0)