Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Adapt to nightly 2021-02-09
Browse files Browse the repository at this point in the history
  • Loading branch information
Herman Venter committed Feb 9, 2021
1 parent c11d88e commit f6f1509
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
# - windows
language: rust
rust:
- nightly-2021-01-01
- nightly-2021-01-28

before_install:
- if [ ${TRAVIS_OS_NAME} == "osx" ]; then curl -L https://github.com/mozilla/grcov/releases/download/v0.5.9/grcov-osx-x86_64.tar.bz2 | tar jxf -; fi
Expand Down
23 changes: 17 additions & 6 deletions checker/src/body_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use rpds::HashTrieMap;
use rustc_errors::DiagnosticBuilder;
use rustc_hir::def_id::DefId;
use rustc_middle::mir;
use rustc_middle::ty::{Ty, TyCtxt, TyKind};
use rustc_middle::ty::{Ty, TyCtxt, TyKind, UintTy};
use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::fmt::{Debug, Formatter, Result};
Expand Down Expand Up @@ -93,7 +93,9 @@ impl<'analysis, 'compilation, 'tcx, E> BodyVisitor<'analysis, 'compilation, 'tcx
.summary_cache
.get_summary_key_for(def_id)
.clone();
let mir = crate_visitor.tcx.optimized_mir(def_id);
let id = rustc_middle::ty::WithOptConstParam::unknown(def_id);
let def = rustc_middle::ty::InstanceDef::Item(id);
let mir = crate_visitor.tcx.instance_mir(def);
let tcx = crate_visitor.tcx;
BodyVisitor {
cv: crate_visitor,
Expand Down Expand Up @@ -161,8 +163,8 @@ impl<'analysis, 'compilation, 'tcx, E> BodyVisitor<'analysis, 'compilation, 'tcx
function_constant_args: &[(Rc<Path>, Rc<AbstractValue>)],
parameter_types: &[Ty<'tcx>],
) -> Summary {
if cfg!(DEBUG) {
let mut stdout = std::io::stdout();
if !cfg!(DEBUG) {
let mut stdout = std::io::sink();
stdout.write_fmt(format_args!("{:?}", self.def_id)).unwrap();
rustc_mir::util::write_mir_pretty(self.tcx, Some(self.def_id), &mut stdout).unwrap();
info!("{:?}", stdout.flush());
Expand Down Expand Up @@ -783,6 +785,13 @@ impl<'analysis, 'compilation, 'tcx, E> BodyVisitor<'analysis, 'compilation, 'tcx
#[logfn_inputs(TRACE)]
fn promote_constants(&mut self) -> Environment {
let mut environment = Environment::default();
if matches!(
self.tcx.def_kind(self.def_id),
rustc_hir::def::DefKind::Variant
) {
return environment;
}
trace!("def_id {:?}", self.tcx.def_kind(self.def_id));
let saved_mir = self.mir;
for (ordinal, constant_mir) in self.tcx.promoted_mir(self.def_id).iter().enumerate() {
self.mir = constant_mir;
Expand Down Expand Up @@ -1166,7 +1175,9 @@ impl<'analysis, 'compilation, 'tcx, E> BodyVisitor<'analysis, 'compilation, 'tcx
} = &tpath.value
{
match selector.as_ref() {
PathSelector::Field(0) | PathSelector::UnionField { .. } => {
PathSelector::Field(0)
| PathSelector::Slice(..)
| PathSelector::UnionField { .. } => {
// assign the pointer field of the slice pointer to the unqualified target
tpath = qualifier.clone();
}
Expand Down Expand Up @@ -2046,7 +2057,7 @@ impl<'analysis, 'compilation, 'tcx, E> BodyVisitor<'analysis, 'compilation, 'tcx
// The value is a string literal. See if the target will treat it as &[u8].
if let TyKind::Ref(_, ty, _) = root_rustc_type.kind() {
if let TyKind::Slice(elem_ty) = ty.kind() {
if let TyKind::Uint(rustc_ast::ast::UintTy::U8) = elem_ty.kind() {
if let TyKind::Uint(UintTy::U8) = elem_ty.kind() {
self.expand_aliased_string_literals_if_appropriate(
&target_path,
&value,
Expand Down
5 changes: 2 additions & 3 deletions checker/src/call_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

use log_derive::*;
use mirai_annotations::*;
use rustc_ast::ast;
use rustc_hir::def_id::DefId;
use rustc_middle::mir;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
use rustc_middle::ty::{AdtDef, Ty, TyCtxt, TyKind};
use rustc_middle::ty::{AdtDef, Ty, TyCtxt, TyKind, UintTy};
use std::collections::HashMap;
use std::fmt::{Debug, Formatter, Result};
use std::rc::Rc;
Expand Down Expand Up @@ -2783,7 +2782,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx, E>
let tag_propagation_set_rustc_const;
match tag_substs_ref[0].unpack() {
GenericArgKind::Const(rustc_const)
if *rustc_const.ty.kind() == TyKind::Uint(ast::UintTy::U128) =>
if *rustc_const.ty.kind() == TyKind::Uint(UintTy::U128) =>
{
tag_propagation_set_rustc_const = rustc_const
}
Expand Down
31 changes: 15 additions & 16 deletions checker/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use crate::type_visitor;

use log_derive::*;
use mirai_annotations::*;
use rustc_ast::ast;
use rustc_middle::ty::{Ty, TyCtxt, TyKind};
use rustc_middle::ty::{FloatTy, IntTy, Ty, TyCtxt, TyKind, UintTy};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt::{Debug, Formatter, Result};
Expand Down Expand Up @@ -1242,20 +1241,20 @@ impl<'a> From<&TyKind<'a>> for ExpressionType {
match ty_kind {
TyKind::Bool => ExpressionType::Bool,
TyKind::Char => ExpressionType::Char,
TyKind::Int(ast::IntTy::Isize) => ExpressionType::Isize,
TyKind::Int(ast::IntTy::I8) => ExpressionType::I8,
TyKind::Int(ast::IntTy::I16) => ExpressionType::I16,
TyKind::Int(ast::IntTy::I32) => ExpressionType::I32,
TyKind::Int(ast::IntTy::I64) => ExpressionType::I64,
TyKind::Int(ast::IntTy::I128) => ExpressionType::I128,
TyKind::Uint(ast::UintTy::Usize) => ExpressionType::Usize,
TyKind::Uint(ast::UintTy::U8) => ExpressionType::U8,
TyKind::Uint(ast::UintTy::U16) => ExpressionType::U16,
TyKind::Uint(ast::UintTy::U32) => ExpressionType::U32,
TyKind::Uint(ast::UintTy::U64) => ExpressionType::U64,
TyKind::Uint(ast::UintTy::U128) => ExpressionType::U128,
TyKind::Float(ast::FloatTy::F32) => ExpressionType::F32,
TyKind::Float(ast::FloatTy::F64) => ExpressionType::F64,
TyKind::Int(IntTy::Isize) => ExpressionType::Isize,
TyKind::Int(IntTy::I8) => ExpressionType::I8,
TyKind::Int(IntTy::I16) => ExpressionType::I16,
TyKind::Int(IntTy::I32) => ExpressionType::I32,
TyKind::Int(IntTy::I64) => ExpressionType::I64,
TyKind::Int(IntTy::I128) => ExpressionType::I128,
TyKind::Uint(UintTy::Usize) => ExpressionType::Usize,
TyKind::Uint(UintTy::U8) => ExpressionType::U8,
TyKind::Uint(UintTy::U16) => ExpressionType::U16,
TyKind::Uint(UintTy::U32) => ExpressionType::U32,
TyKind::Uint(UintTy::U64) => ExpressionType::U64,
TyKind::Uint(UintTy::U128) => ExpressionType::U128,
TyKind::Float(FloatTy::F32) => ExpressionType::F32,
TyKind::Float(FloatTy::F64) => ExpressionType::F64,
TyKind::Dynamic(..)
| TyKind::Foreign(..)
| TyKind::FnDef(..)
Expand Down
1 change: 0 additions & 1 deletion checker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(vec_remove_item)]

extern crate rustc_ast;
extern crate rustc_data_structures;
Expand Down
31 changes: 15 additions & 16 deletions checker/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_hir::{ItemKind, Node};
use rustc_middle::ty;
use rustc_middle::ty::print::{FmtPrinter, Printer};
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::{DefIdTree, ProjectionTy, Ty, TyCtxt, TyKind};
use rustc_middle::ty::{DefIdTree, FloatTy, IntTy, ProjectionTy, Ty, TyCtxt, TyKind, UintTy};
use std::rc::Rc;

/// Returns the location of the rust system binaries that are associated with this build of Mirai.
Expand Down Expand Up @@ -97,35 +97,34 @@ pub fn argument_types_key_str<'tcx>(
/// generic trait methods).
fn append_mangled_type<'tcx>(str: &mut String, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) {
trace!("append_mangled_type {:?} to {}", ty.kind(), str);
use rustc_ast::ast;
use TyKind::*;
match ty.kind() {
Bool => str.push_str("bool"),
Char => str.push_str("char"),
Int(int_ty) => {
str.push_str(match int_ty {
ast::IntTy::Isize => "isize",
ast::IntTy::I8 => "i8",
ast::IntTy::I16 => "i16",
ast::IntTy::I32 => "i32",
ast::IntTy::I64 => "i64",
ast::IntTy::I128 => "i128",
IntTy::Isize => "isize",
IntTy::I8 => "i8",
IntTy::I16 => "i16",
IntTy::I32 => "i32",
IntTy::I64 => "i64",
IntTy::I128 => "i128",
});
}
Uint(uint_ty) => {
str.push_str(match uint_ty {
ast::UintTy::Usize => "usize",
ast::UintTy::U8 => "u8",
ast::UintTy::U16 => "u16",
ast::UintTy::U32 => "u32",
ast::UintTy::U64 => "u64",
ast::UintTy::U128 => "u128",
UintTy::Usize => "usize",
UintTy::U8 => "u8",
UintTy::U16 => "u16",
UintTy::U32 => "u32",
UintTy::U64 => "u64",
UintTy::U128 => "u128",
});
}
Float(float_ty) => {
str.push_str(match float_ty {
ast::FloatTy::F32 => "f32",
ast::FloatTy::F64 => "f64",
FloatTy::F32 => "f32",
FloatTy::F64 => "f64",
});
}
Adt(def, subs) => {
Expand Down
3 changes: 1 addition & 2 deletions checker/src/z3_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,7 @@ impl Z3Solver {
Expression::UninterpretedCall {
callee, arguments, ..
} => {
let mut checks = Vec::new();
checks.push(self.general_has_tag(&callee.expression, tag));
let mut checks = vec![self.general_has_tag(&callee.expression, tag)];
for argument in arguments {
checks.push(self.general_has_tag(&argument.expression, tag));
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-01-01
nightly-2021-02-09
2 changes: 2 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ rustup "+$TOOLCHAIN" component add rustc-dev
rustup "+$TOOLCHAIN" component add llvm-tools-preview
# install audit
cargo "+$TOOLCHAIN" install cargo-audit
# override tool chain
rustup override set $TOOLCHAIN

0 comments on commit f6f1509

Please sign in to comment.