Skip to content

Commit f706876

Browse files
committed
Update to nightly-2019-04-08
We need rust-lang/rust#59173 to be in our nightly for LLVM 8 builds against system libLLVM-8.so on linux.
1 parent 50889af commit f706876

File tree

22 files changed

+79
-73
lines changed

22 files changed

+79
-73
lines changed

c2rust-ast-builder/src/builder.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,15 @@ impl Make<GenericArg> for Lifetime {
225225
}
226226
}
227227

228-
impl Make<NestedMetaItemKind> for MetaItem {
229-
fn make(self, _mk: &Builder) -> NestedMetaItemKind {
230-
NestedMetaItemKind::MetaItem(self)
228+
impl Make<NestedMetaItem> for MetaItem {
229+
fn make(self, _mk: &Builder) -> NestedMetaItem {
230+
NestedMetaItem::MetaItem(self)
231231
}
232232
}
233233

234-
impl Make<NestedMetaItemKind> for Lit {
235-
fn make(self, _mk: &Builder) -> NestedMetaItemKind {
236-
NestedMetaItemKind::Literal(self)
234+
impl Make<NestedMetaItem> for Lit {
235+
fn make(self, _mk: &Builder) -> NestedMetaItem {
236+
NestedMetaItem::Literal(self)
237237
}
238238
}
239239

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

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

@@ -1367,6 +1367,7 @@ impl Builder {
13671367
node: Variant_ {
13681368
ident: name,
13691369
attrs: self.attrs,
1370+
id: DUMMY_NODE_ID,
13701371
data: dat,
13711372
disr_expr: None,
13721373
},
@@ -1382,6 +1383,7 @@ impl Builder {
13821383
node: Variant_ {
13831384
ident: name,
13841385
attrs: self.attrs,
1386+
id: DUMMY_NODE_ID,
13851387
data: VariantData::Unit(self.id),
13861388
disr_expr: disc,
13871389
},
@@ -1664,17 +1666,16 @@ impl Builder {
16641666
let path = path.make(&self);
16651667
let kind = kind.make(&self);
16661668
MetaItem {
1667-
ident: path,
1669+
path: path,
16681670
node: kind,
16691671
span: DUMMY_SP,
16701672
}
16711673
}
16721674

16731675
pub fn nested_meta_item<K>(self, kind: K) -> NestedMetaItem
1674-
where K: Make<NestedMetaItemKind>
1675-
{
1676-
let kind = kind.make(&self);
1677-
dummy_spanned(kind)
1676+
where K: Make<NestedMetaItem>
1677+
{
1678+
kind.make(&self)
16781679
}
16791680

16801681
// Convert the current internal list of outer attributes

c2rust-refactor/gen/ast.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct TraitRef { path, ref_id }
8888

8989
struct EnumDef { variants }
9090
#[extend_span]
91-
struct Variant_ { ident, #[match=ignore] attrs, data, disr_expr }
91+
struct Variant_ { ident, #[match=ignore] attrs, id, data, disr_expr }
9292
enum VariantData {
9393
Struct(fields, id),
9494
Tuple(fields, id),
@@ -455,13 +455,13 @@ struct DelimSpan { open, close }
455455
flag DelimToken;
456456
flag Token;
457457

458-
struct MetaItem { ident, node, span }
458+
struct MetaItem { path, node, span }
459459
enum MetaItemKind {
460460
Word,
461461
List(l),
462462
NameValue(lit),
463463
}
464-
enum NestedMetaItemKind {
464+
enum NestedMetaItem {
465465
MetaItem(mi),
466466
Literal(lit),
467467
}

c2rust-refactor/src/analysis/ownership/annot.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub fn handle_attrs<'a, 'hir, 'tcx, 'lty>(cx: &mut Ctxt<'lty, 'a, 'tcx>,
199199

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

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

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

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

354-
let name = meta.name().as_str();
354+
let name = meta.path.to_string();
355355
match &name as &str {
356356
"READ" => Ok(ConcretePerm::Read),
357357
"WRITE" => Ok(ConcretePerm::Write),

c2rust-refactor/src/analysis/ownership/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ fn preload_constraints<'lty, 'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
392392
sig: LFnSig<'lty, 'tcx>) -> Option<ConstraintSet<'lty>> {
393393
let mut cset = ConstraintSet::new();
394394

395-
let path = tcx.absolute_item_path_str(def_id);
395+
let path = tcx.def_path_str(def_id);
396396
match &path as &str {
397397
"core::ptr::<impl *const T>::offset" |
398398
"core::ptr::<impl *mut T>::offset" => {

c2rust-refactor/src/analysis/ownership/intra.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use rustc::hir::def_id::DefId;
44
use rustc::mir::*;
5-
use rustc::mir::tcx::PlaceTy;
65
use rustc::ty::{Ty, TyKind};
76
use rustc_data_structures::indexed_vec::IndexVec;
87
use rustc_target::abi::VariantIdx;
@@ -236,14 +235,15 @@ impl<'c, 'lty, 'a: 'lty, 'tcx: 'a> IntraCtxt<'c, 'lty, 'a, 'tcx> {
236235
match lv {
237236
Place::Base(PlaceBase::Local(l)) => (self.local_var_ty(*l), Perm::move_(), None),
238237

239-
Place::Base(PlaceBase::Static(ref s)) => (self.static_ty(s.def_id), Perm::move_(), None),
240-
241-
Place::Base(PlaceBase::Promoted(ref _p)) => {
242-
// TODO: test this
243-
let pty = lv.ty(self.mir, self.cx.tcx);
244-
let ty = expect!([pty] PlaceTy::Ty { ty } => ty);
245-
(self.local_ty(ty), Perm::read(), None)
246-
},
238+
Place::Base(PlaceBase::Static(ref s)) => match s.kind {
239+
StaticKind::Static(def_id) => (self.static_ty(def_id), Perm::move_(), None),
240+
StaticKind::Promoted(ref _p) => {
241+
// TODO: test this
242+
let pty = lv.ty(self.mir, self.cx.tcx);
243+
let ty = pty.ty;
244+
(self.local_ty(ty), Perm::read(), None)
245+
}
246+
}
247247

248248
Place::Projection(box p) => {
249249
let (base_ty, base_perm, base_variant) = self.place_lty_downcast(&p.base);

c2rust-refactor/src/analysis/type_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ impl<'lty, 'a, 'hir> Visitor<'hir> for UnifyVisitor<'lty, 'a, 'hir> {
790790
// "unsafe" tag on the function pointer.
791791
self.ltt.unify(rty, prev_ty);
792792
},
793-
Adjust::ClosureFnPointer => {}, // unsupported
793+
Adjust::ClosureFnPointer(_) => {}, // unsupported
794794
Adjust::MutToConstPointer => {
795795
// Only the mutability tag changes
796796
self.ltt.unify(rty, prev_ty);

c2rust-refactor/src/ast_manip/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub fn namespace(def: &Def) -> Option<Namespace> {
229229
| SelfTy(..)
230230
| ToolMod => Some(Namespace::TypeNS),
231231

232-
Fn(..) | Const(..) | Static(..) | StructCtor(..) | VariantCtor(..) | SelfCtor(..)
232+
Fn(..) | Const(..) | Static(..) | SelfCtor(..)
233233
| Method(..) | AssociatedConst(..) | Local(..) | Upvar(..) | Label(..) => {
234234
Some(Namespace::ValueNS)
235235
}

c2rust-refactor/src/collapse/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use crate::node_map::NodeMap;
3939
use deleted::DeletedNode;
4040

4141
pub struct CollapseInfo<'ast> {
42-
unexpanded: &'ast Crate,
4342
mac_table: MacTable<'ast>,
4443
cfg_attr_info: HashMap<NodeId, Vec<Attribute>>,
4544
deleted_info: Vec<DeletedNode<'ast>>,
@@ -67,7 +66,6 @@ impl<'ast> CollapseInfo<'ast> {
6766
node_map.commit();
6867

6968
CollapseInfo {
70-
unexpanded,
7169
mac_table,
7270
cfg_attr_info,
7371
deleted_info,

c2rust-refactor/src/context.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ impl<'a, 'tcx: 'a> RefactorCtxt<'a, 'tcx> {
127127
}
128128

129129
pub fn def_to_hir_id(&self, def: &hir::def::Def) -> Option<hir::HirId> {
130-
use rustc::hir::def::Def;
131130
match def {
132131
Def::Mod(did) |
133132
Def::Struct(did) |
@@ -145,8 +144,7 @@ impl<'a, 'tcx: 'a> RefactorCtxt<'a, 'tcx> {
145144
Def::Const(did) |
146145
Def::ConstParam(did) |
147146
Def::Static(did, _) |
148-
Def::StructCtor(did, _) |
149-
Def::VariantCtor(did, _) |
147+
Def::Ctor(did, ..) |
150148
Def::SelfCtor(did) |
151149
Def::Method(did) |
152150
Def::AssociatedConst(did) |

c2rust-refactor/src/driver.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ pub fn run_refactoring<F, R>(
305305
})
306306
}
307307

308+
#[allow(dead_code)]
308309
pub struct Compiler {
309310
pub sess: Lrc<Session>,
310311
pub codegen_backend: Lrc<Box<dyn CodegenBackend>>,
@@ -318,6 +319,7 @@ pub struct Compiler {
318319
crate_name: Option<String>,
319320
}
320321

322+
#[allow(dead_code)]
321323
#[derive(Default)]
322324
struct Queries {
323325
dep_graph_future: Query<Option<DepGraphFuture>>,
@@ -335,6 +337,7 @@ struct Queries {
335337
link: Query<()>,
336338
}
337339

340+
#[allow(dead_code)]
338341
struct Query<T> {
339342
result: RefCell<Option<Result<T, ErrorReported>>>,
340343
}
@@ -347,6 +350,7 @@ impl<T> Default for Query<T> {
347350
}
348351
}
349352

353+
#[allow(dead_code)]
350354
struct PluginInfo {
351355
syntax_exts: Vec<NamedSyntaxExtension>,
352356
attributes: Vec<(String, AttributeType)>,

c2rust-refactor/src/illtyped.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ impl<'a, 'tcx, F: IlltypedFolder<'tcx>> FoldIlltyped<'a, 'tcx, F> {
103103

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

215-
// Updating to nightly-2019-03-13 note: cast_kinds is gone now,
217+
// Updating to nightly-2019-04-08 note: cast_kinds is gone now,
216218
// and cast checking only marks coercion casts. We don't need to
217219
// implement the logic for coercions, but it looks like we need
218220
// to implement logic for real cast typechecking.

c2rust-refactor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn get_rustc_arg_strings(src: RustcArgSource) -> Vec<String> {
203203
}
204204

205205
fn get_rustc_cargo_args() -> Vec<String> {
206-
use std::sync::{Arc, Mutex};
206+
use std::sync::Mutex;
207207
use cargo::Config;
208208
use cargo::core::{Workspace, PackageId, Target, maybe_allow_nightly_features};
209209
use cargo::core::compiler::{CompileMode, Executor, DefaultExecutor, Context, Unit};

c2rust-refactor/src/mark_adjust.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ impl<'a, 'tcx> MarkUseVisitor<'a, 'tcx> {
3333
}
3434

3535
// For struct and node constructors, also check the parent item
36-
if matches!([path.def] Def::StructCtor(..)) ||
37-
matches!([path.def] Def::VariantCtor(..)) {
36+
if matches!([path.def] Def::Ctor(..)) {
3837
let parent_id = self.cx.hir_map().get_parent(id);
3938
if self.st.marked(parent_id, self.label) {
4039
self.st.add_mark(use_id, self.label);

c2rust-refactor/src/reflect.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::hir::map::definitions::DefPathData;
66
use rustc::hir::map::Map as HirMap;
77
use rustc::hir::Node;
88
use rustc::middle::cstore::{ExternCrate, ExternCrateSource};
9-
use rustc::ty::{self, LazyConst, TyCtxt, GenericParamDefKind};
9+
use rustc::ty::{self, DefIdTree, TyCtxt, GenericParamDefKind};
1010
use rustc::ty::subst::Subst;
1111
use syntax::ast::*;
1212
use syntax::ptr::P;
@@ -50,10 +50,7 @@ fn reflect_tcx_ty_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
5050
Str => mk().ident_ty("str"),
5151
Array(ty, len) => mk().array_ty(
5252
reflect_tcx_ty(tcx, ty),
53-
match len {
54-
LazyConst::Unevaluated(did, _substs) => anon_const_to_expr(tcx.hir(), *did),
55-
_ => mk().lit_expr(mk().int_lit(len.unwrap_usize(tcx) as u128, "usize")),
56-
},
53+
mk().lit_expr(mk().int_lit(len.unwrap_usize(tcx) as u128, "usize")),
5754
),
5855
Slice(ty) => mk().slice_ty(reflect_tcx_ty(tcx, ty)),
5956
RawPtr(mty) => mk().set_mutbl(mty.mutbl).ptr_ty(reflect_tcx_ty(tcx, mty.ty)),
@@ -86,7 +83,7 @@ fn reflect_tcx_ty_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
8683
}
8784
}
8885

89-
fn anon_const_to_expr(hir_map: &HirMap, def_id: DefId) -> P<Expr> {
86+
pub fn anon_const_to_expr(hir_map: &HirMap, def_id: DefId) -> P<Expr> {
9087
let node = hir_map.get_if_local(def_id).unwrap();
9188
let ac = expect!([node] Node::AnonConst(ac) => ac);
9289
let body_id = ac.body;
@@ -225,7 +222,7 @@ fn reflect_def_path_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
225222
DefPathData::AssocExistentialInImpl(_) |
226223
DefPathData::ClosureExpr |
227224
DefPathData::LifetimeParam(_) |
228-
DefPathData::StructCtor |
225+
DefPathData::Ctor |
229226
DefPathData::AnonConst |
230227
DefPathData::ImplTrait |
231228
DefPathData::TraitAlias(_) => {},
@@ -255,10 +252,10 @@ fn reflect_def_path_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
255252
}
256253
},
257254

258-
DefPathData::StructCtor => {
255+
DefPathData::Ctor => {
259256
// The parent of the struct ctor in `visible_parent_map` is the parent of the
260257
// struct. But we want to visit the struct first, so we can add its name.
261-
if let Some(parent_id) = tcx.parent_def_id(id) {
258+
if let Some(parent_id) = tcx.parent(id) {
262259
id = parent_id;
263260
continue;
264261
} else {
@@ -272,7 +269,7 @@ fn reflect_def_path_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
272269
let visible_parent_map = tcx.visible_parent_map(LOCAL_CRATE);
273270
if let Some(&parent_id) = visible_parent_map.get(&id) {
274271
id = parent_id;
275-
} else if let Some(parent_id) = tcx.parent_def_id(id) {
272+
} else if let Some(parent_id) = tcx.parent(id) {
276273
id = parent_id;
277274
} else {
278275
break;
@@ -300,7 +297,7 @@ pub fn can_reflect_path(hir_map: &hir::map::Map, id: NodeId) -> bool {
300297
Node::Binding(_) |
301298
Node::Local(_) |
302299
Node::MacroDef(_) |
303-
Node::StructCtor(_) |
300+
Node::Ctor(_) |
304301
Node::GenericParam(_) => true,
305302

306303
Node::AnonConst(_) |

c2rust-refactor/src/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn push_hir_mod_children(tcx: TyCtxt, m: &Mod, children: &mut Vec<(Symbol, Def)>
1111
use rustc::hir::ItemKind::*;
1212

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

1717
match item.node {

0 commit comments

Comments
 (0)