Skip to content

Commit

Permalink
Update to nightly-2019-04-08
Browse files Browse the repository at this point in the history
We need rust-lang/rust#59173 to be in our nightly for
LLVM 8 builds against system libLLVM-8.so on linux.
  • Loading branch information
rinon committed Apr 10, 2019
1 parent 50889af commit f706876
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 73 deletions.
27 changes: 14 additions & 13 deletions c2rust-ast-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ impl Make<GenericArg> for Lifetime {
}
}

impl Make<NestedMetaItemKind> for MetaItem {
fn make(self, _mk: &Builder) -> NestedMetaItemKind {
NestedMetaItemKind::MetaItem(self)
impl Make<NestedMetaItem> for MetaItem {
fn make(self, _mk: &Builder) -> NestedMetaItem {
NestedMetaItem::MetaItem(self)
}
}

impl Make<NestedMetaItemKind> for Lit {
fn make(self, _mk: &Builder) -> NestedMetaItemKind {
NestedMetaItemKind::Literal(self)
impl Make<NestedMetaItem> for Lit {
fn make(self, _mk: &Builder) -> NestedMetaItem {
NestedMetaItem::Literal(self)
}
}

Expand Down Expand Up @@ -1308,15 +1308,15 @@ impl Builder {
where I: Make<Ident> {
let name = name.make(&self);
Self::item(name, self.attrs, self.vis, self.span, self.id,
ItemKind::Struct(VariantData::Struct(fields, DUMMY_NODE_ID),
ItemKind::Struct(VariantData::Struct(fields, false),
self.generics))
}

pub fn union_item<I>(self, name: I, fields: Vec<StructField>) -> P<Item>
where I: Make<Ident> {
let name = name.make(&self);
Self::item(name, self.attrs, self.vis, self.span, self.id,
ItemKind::Union(VariantData::Struct(fields, DUMMY_NODE_ID),
ItemKind::Union(VariantData::Struct(fields, false),
self.generics))
}

Expand Down Expand Up @@ -1367,6 +1367,7 @@ impl Builder {
node: Variant_ {
ident: name,
attrs: self.attrs,
id: DUMMY_NODE_ID,
data: dat,
disr_expr: None,
},
Expand All @@ -1382,6 +1383,7 @@ impl Builder {
node: Variant_ {
ident: name,
attrs: self.attrs,
id: DUMMY_NODE_ID,
data: VariantData::Unit(self.id),
disr_expr: disc,
},
Expand Down Expand Up @@ -1664,17 +1666,16 @@ impl Builder {
let path = path.make(&self);
let kind = kind.make(&self);
MetaItem {
ident: path,
path: path,
node: kind,
span: DUMMY_SP,
}
}

pub fn nested_meta_item<K>(self, kind: K) -> NestedMetaItem
where K: Make<NestedMetaItemKind>
{
let kind = kind.make(&self);
dummy_spanned(kind)
where K: Make<NestedMetaItem>
{
kind.make(&self)
}

// Convert the current internal list of outer attributes
Expand Down
6 changes: 3 additions & 3 deletions c2rust-refactor/gen/ast.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct TraitRef { path, ref_id }

struct EnumDef { variants }
#[extend_span]
struct Variant_ { ident, #[match=ignore] attrs, data, disr_expr }
struct Variant_ { ident, #[match=ignore] attrs, id, data, disr_expr }
enum VariantData {
Struct(fields, id),
Tuple(fields, id),
Expand Down Expand Up @@ -455,13 +455,13 @@ struct DelimSpan { open, close }
flag DelimToken;
flag Token;

struct MetaItem { ident, node, span }
struct MetaItem { path, node, span }
enum MetaItemKind {
Word,
List(l),
NameValue(lit),
}
enum NestedMetaItemKind {
enum NestedMetaItem {
MetaItem(mi),
Literal(lit),
}
16 changes: 8 additions & 8 deletions c2rust-refactor/src/analysis/ownership/annot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn handle_attrs<'a, 'hir, 'tcx, 'lty>(cx: &mut Ctxt<'lty, 'a, 'tcx>,

for attr in attrs {
let meta = match_or!([attr.meta()] Some(x) => x; continue);
match &meta.name().as_str() as &str {
match &meta.path.to_string() as &str {
"ownership_constraints" => {
let cset = parse_ownership_constraints(&meta, cx.arena)
.unwrap_or_else(|e| panic!("bad #[ownership_constraints] for {:?}: {}",
Expand Down Expand Up @@ -268,15 +268,15 @@ fn meta_item_word(meta: &ast::MetaItem) -> Result<(), &'static str> {
}

fn nested_meta_item(nmeta: &ast::NestedMetaItem) -> Result<&ast::MetaItem, &'static str> {
match nmeta.node {
ast::NestedMetaItemKind::MetaItem(ref m) => Ok(m),
_ => Err("expected NestedMetaItemKind::MetaItem"),
match nmeta {
ast::NestedMetaItem::MetaItem(ref m) => Ok(m),
_ => Err("expected NestedMetaItem::MetaItem"),
}
}

fn nested_str(nmeta: &ast::NestedMetaItem) -> Result<Symbol, &'static str> {
match nmeta.node {
ast::NestedMetaItemKind::Literal(ref lit) => {
match nmeta {
ast::NestedMetaItem::Literal(ref lit) => {
match lit.node {
ast::LitKind::Str(s, _) => Ok(s),
_ => Err("expected str"),
Expand Down Expand Up @@ -332,7 +332,7 @@ fn parse_perm<'lty, 'tcx>(meta: &ast::MetaItem,
} else {
meta_item_word(meta)?;

let name = meta.name().as_str();
let name = meta.path.to_string();
match &name as &str {
"READ" => return Ok(Perm::read()),
"WRITE" => return Ok(Perm::write()),
Expand All @@ -351,7 +351,7 @@ fn parse_perm<'lty, 'tcx>(meta: &ast::MetaItem,
fn parse_concrete(meta: &ast::MetaItem) -> Result<ConcretePerm, &'static str> {
meta_item_word(meta)?;

let name = meta.name().as_str();
let name = meta.path.to_string();
match &name as &str {
"READ" => Ok(ConcretePerm::Read),
"WRITE" => Ok(ConcretePerm::Write),
Expand Down
2 changes: 1 addition & 1 deletion c2rust-refactor/src/analysis/ownership/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ fn preload_constraints<'lty, 'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
sig: LFnSig<'lty, 'tcx>) -> Option<ConstraintSet<'lty>> {
let mut cset = ConstraintSet::new();

let path = tcx.absolute_item_path_str(def_id);
let path = tcx.def_path_str(def_id);
match &path as &str {
"core::ptr::<impl *const T>::offset" |
"core::ptr::<impl *mut T>::offset" => {
Expand Down
18 changes: 9 additions & 9 deletions c2rust-refactor/src/analysis/ownership/intra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use rustc::hir::def_id::DefId;
use rustc::mir::*;
use rustc::mir::tcx::PlaceTy;
use rustc::ty::{Ty, TyKind};
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_target::abi::VariantIdx;
Expand Down Expand Up @@ -236,14 +235,15 @@ impl<'c, 'lty, 'a: 'lty, 'tcx: 'a> IntraCtxt<'c, 'lty, 'a, 'tcx> {
match lv {
Place::Base(PlaceBase::Local(l)) => (self.local_var_ty(*l), Perm::move_(), None),

Place::Base(PlaceBase::Static(ref s)) => (self.static_ty(s.def_id), Perm::move_(), None),

Place::Base(PlaceBase::Promoted(ref _p)) => {
// TODO: test this
let pty = lv.ty(self.mir, self.cx.tcx);
let ty = expect!([pty] PlaceTy::Ty { ty } => ty);
(self.local_ty(ty), Perm::read(), None)
},
Place::Base(PlaceBase::Static(ref s)) => match s.kind {
StaticKind::Static(def_id) => (self.static_ty(def_id), Perm::move_(), None),
StaticKind::Promoted(ref _p) => {
// TODO: test this
let pty = lv.ty(self.mir, self.cx.tcx);
let ty = pty.ty;
(self.local_ty(ty), Perm::read(), None)
}
}

Place::Projection(box p) => {
let (base_ty, base_perm, base_variant) = self.place_lty_downcast(&p.base);
Expand Down
2 changes: 1 addition & 1 deletion c2rust-refactor/src/analysis/type_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ impl<'lty, 'a, 'hir> Visitor<'hir> for UnifyVisitor<'lty, 'a, 'hir> {
// "unsafe" tag on the function pointer.
self.ltt.unify(rty, prev_ty);
},
Adjust::ClosureFnPointer => {}, // unsupported
Adjust::ClosureFnPointer(_) => {}, // unsupported
Adjust::MutToConstPointer => {
// Only the mutability tag changes
self.ltt.unify(rty, prev_ty);
Expand Down
2 changes: 1 addition & 1 deletion c2rust-refactor/src/ast_manip/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub fn namespace(def: &Def) -> Option<Namespace> {
| SelfTy(..)
| ToolMod => Some(Namespace::TypeNS),

Fn(..) | Const(..) | Static(..) | StructCtor(..) | VariantCtor(..) | SelfCtor(..)
Fn(..) | Const(..) | Static(..) | SelfCtor(..)
| Method(..) | AssociatedConst(..) | Local(..) | Upvar(..) | Label(..) => {
Some(Namespace::ValueNS)
}
Expand Down
2 changes: 0 additions & 2 deletions c2rust-refactor/src/collapse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use crate::node_map::NodeMap;
use deleted::DeletedNode;

pub struct CollapseInfo<'ast> {
unexpanded: &'ast Crate,
mac_table: MacTable<'ast>,
cfg_attr_info: HashMap<NodeId, Vec<Attribute>>,
deleted_info: Vec<DeletedNode<'ast>>,
Expand Down Expand Up @@ -67,7 +66,6 @@ impl<'ast> CollapseInfo<'ast> {
node_map.commit();

CollapseInfo {
unexpanded,
mac_table,
cfg_attr_info,
deleted_info,
Expand Down
4 changes: 1 addition & 3 deletions c2rust-refactor/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ impl<'a, 'tcx: 'a> RefactorCtxt<'a, 'tcx> {
}

pub fn def_to_hir_id(&self, def: &hir::def::Def) -> Option<hir::HirId> {
use rustc::hir::def::Def;
match def {
Def::Mod(did) |
Def::Struct(did) |
Expand All @@ -145,8 +144,7 @@ impl<'a, 'tcx: 'a> RefactorCtxt<'a, 'tcx> {
Def::Const(did) |
Def::ConstParam(did) |
Def::Static(did, _) |
Def::StructCtor(did, _) |
Def::VariantCtor(did, _) |
Def::Ctor(did, ..) |
Def::SelfCtor(did) |
Def::Method(did) |
Def::AssociatedConst(did) |
Expand Down
4 changes: 4 additions & 0 deletions c2rust-refactor/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ pub fn run_refactoring<F, R>(
})
}

#[allow(dead_code)]
pub struct Compiler {
pub sess: Lrc<Session>,
pub codegen_backend: Lrc<Box<dyn CodegenBackend>>,
Expand All @@ -318,6 +319,7 @@ pub struct Compiler {
crate_name: Option<String>,
}

#[allow(dead_code)]
#[derive(Default)]
struct Queries {
dep_graph_future: Query<Option<DepGraphFuture>>,
Expand All @@ -335,6 +337,7 @@ struct Queries {
link: Query<()>,
}

#[allow(dead_code)]
struct Query<T> {
result: RefCell<Option<Result<T, ErrorReported>>>,
}
Expand All @@ -347,6 +350,7 @@ impl<T> Default for Query<T> {
}
}

#[allow(dead_code)]
struct PluginInfo {
syntax_exts: Vec<NamedSyntaxExtension>,
attributes: Vec<(String, AttributeType)>,
Expand Down
4 changes: 3 additions & 1 deletion c2rust-refactor/src/illtyped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ impl<'a, 'tcx, F: IlltypedFolder<'tcx>> FoldIlltyped<'a, 'tcx, F> {

/// Attempt to ensure that `expr` has the type `expected_ty`, inserting
/// casts if needed. Return true if retyping was needed.
// TODO: Use this when checking casts
#[allow(dead_code)]
fn ensure_cast(
&mut self,
sub_e: &mut P<Expr>,
Expand Down Expand Up @@ -212,7 +214,7 @@ impl<'a, 'tcx, F: IlltypedFolder<'tcx>> MutVisitor for FoldIlltyped<'a, 'tcx, F>
// (yes, the subexpression) in the `cast_kinds` table - if there's nothing
// there, it's not a valid cast.

// Updating to nightly-2019-03-13 note: cast_kinds is gone now,
// Updating to nightly-2019-04-08 note: cast_kinds is gone now,
// and cast checking only marks coercion casts. We don't need to
// implement the logic for coercions, but it looks like we need
// to implement logic for real cast typechecking.
Expand Down
2 changes: 1 addition & 1 deletion c2rust-refactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn get_rustc_arg_strings(src: RustcArgSource) -> Vec<String> {
}

fn get_rustc_cargo_args() -> Vec<String> {
use std::sync::{Arc, Mutex};
use std::sync::Mutex;
use cargo::Config;
use cargo::core::{Workspace, PackageId, Target, maybe_allow_nightly_features};
use cargo::core::compiler::{CompileMode, Executor, DefaultExecutor, Context, Unit};
Expand Down
3 changes: 1 addition & 2 deletions c2rust-refactor/src/mark_adjust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ impl<'a, 'tcx> MarkUseVisitor<'a, 'tcx> {
}

// For struct and node constructors, also check the parent item
if matches!([path.def] Def::StructCtor(..)) ||
matches!([path.def] Def::VariantCtor(..)) {
if matches!([path.def] Def::Ctor(..)) {
let parent_id = self.cx.hir_map().get_parent(id);
if self.st.marked(parent_id, self.label) {
self.st.add_mark(use_id, self.label);
Expand Down
19 changes: 8 additions & 11 deletions c2rust-refactor/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc::hir::map::definitions::DefPathData;
use rustc::hir::map::Map as HirMap;
use rustc::hir::Node;
use rustc::middle::cstore::{ExternCrate, ExternCrateSource};
use rustc::ty::{self, LazyConst, TyCtxt, GenericParamDefKind};
use rustc::ty::{self, DefIdTree, TyCtxt, GenericParamDefKind};
use rustc::ty::subst::Subst;
use syntax::ast::*;
use syntax::ptr::P;
Expand Down Expand Up @@ -50,10 +50,7 @@ fn reflect_tcx_ty_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
Str => mk().ident_ty("str"),
Array(ty, len) => mk().array_ty(
reflect_tcx_ty(tcx, ty),
match len {
LazyConst::Unevaluated(did, _substs) => anon_const_to_expr(tcx.hir(), *did),
_ => mk().lit_expr(mk().int_lit(len.unwrap_usize(tcx) as u128, "usize")),
},
mk().lit_expr(mk().int_lit(len.unwrap_usize(tcx) as u128, "usize")),
),
Slice(ty) => mk().slice_ty(reflect_tcx_ty(tcx, ty)),
RawPtr(mty) => mk().set_mutbl(mty.mutbl).ptr_ty(reflect_tcx_ty(tcx, mty.ty)),
Expand Down Expand Up @@ -86,7 +83,7 @@ fn reflect_tcx_ty_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
}
}

fn anon_const_to_expr(hir_map: &HirMap, def_id: DefId) -> P<Expr> {
pub fn anon_const_to_expr(hir_map: &HirMap, def_id: DefId) -> P<Expr> {
let node = hir_map.get_if_local(def_id).unwrap();
let ac = expect!([node] Node::AnonConst(ac) => ac);
let body_id = ac.body;
Expand Down Expand Up @@ -225,7 +222,7 @@ fn reflect_def_path_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
DefPathData::AssocExistentialInImpl(_) |
DefPathData::ClosureExpr |
DefPathData::LifetimeParam(_) |
DefPathData::StructCtor |
DefPathData::Ctor |
DefPathData::AnonConst |
DefPathData::ImplTrait |
DefPathData::TraitAlias(_) => {},
Expand Down Expand Up @@ -255,10 +252,10 @@ fn reflect_def_path_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
}
},

DefPathData::StructCtor => {
DefPathData::Ctor => {
// The parent of the struct ctor in `visible_parent_map` is the parent of the
// struct. But we want to visit the struct first, so we can add its name.
if let Some(parent_id) = tcx.parent_def_id(id) {
if let Some(parent_id) = tcx.parent(id) {
id = parent_id;
continue;
} else {
Expand All @@ -272,7 +269,7 @@ fn reflect_def_path_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
let visible_parent_map = tcx.visible_parent_map(LOCAL_CRATE);
if let Some(&parent_id) = visible_parent_map.get(&id) {
id = parent_id;
} else if let Some(parent_id) = tcx.parent_def_id(id) {
} else if let Some(parent_id) = tcx.parent(id) {
id = parent_id;
} else {
break;
Expand Down Expand Up @@ -300,7 +297,7 @@ pub fn can_reflect_path(hir_map: &hir::map::Map, id: NodeId) -> bool {
Node::Binding(_) |
Node::Local(_) |
Node::MacroDef(_) |
Node::StructCtor(_) |
Node::Ctor(_) |
Node::GenericParam(_) => true,

Node::AnonConst(_) |
Expand Down
2 changes: 1 addition & 1 deletion c2rust-refactor/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn push_hir_mod_children(tcx: TyCtxt, m: &Mod, children: &mut Vec<(Symbol, Def)>
use rustc::hir::ItemKind::*;

for &iid in &m.item_ids {
let node = tcx.hir().get(iid.id);
let node = tcx.hir().get_by_hir_id(iid.id);
let item = expect!([node] Node::Item(i) => i);

match item.node {
Expand Down
Loading

0 comments on commit f706876

Please sign in to comment.