Skip to content

Commit 28ce3e8

Browse files
authored
Auto merge of #35163 - sanxiyn:rollup, r=sanxiyn
Rollup of 8 pull requests - Successful merges: #34802, #35033, #35085, #35114, #35134, #35140, #35141, #35157 - Failed merges:
2 parents 2c1612c + 5fb13cf commit 28ce3e8

File tree

121 files changed

+372
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+372
-474
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
# our configure script, so disable auto submodule management.
88
git:
99
submodules: false
10+
depth: 1
1011

1112
before_install:
1213
- docker build -t rust -f src/etc/Dockerfile src/etc

src/etc/Dockerfile

-6
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,5 @@ RUN apt-get update && apt-get -y install \
2323
libedit-dev zlib1g-dev \
2424
llvm-3.7-tools cmake
2525

26-
# When we compile compiler-rt we pass it the llvm-config we just installed on
27-
# the system, but unfortunately it doesn't infer correctly where
28-
# LLVMConfig.cmake is so we need to coerce it a bit...
29-
RUN mkdir -p /usr/lib/llvm-3.7/build/share/llvm
30-
RUN ln -s /usr/share/llvm-3.7/cmake /usr/lib/llvm-3.7/build/share/llvm/cmake
31-
3226
RUN mkdir /build
3327
WORKDIR /build

src/libcollections/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#![feature(specialization)]
5050
#![feature(staged_api)]
5151
#![feature(step_by)]
52-
#![feature(unboxed_closures)]
5352
#![feature(unicode)]
5453
#![feature(unique)]
5554
#![feature(unsafe_no_drop_flag)]

src/libcollections/slice.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,13 @@ impl<T> [T] {
577577
///
578578
/// # Example
579579
///
580-
/// Print the slice two elements at a time (i.e. `[1,2]`,
581-
/// `[3,4]`, `[5]`):
582-
///
583-
/// ```rust
584-
/// let v = &[1, 2, 3, 4, 5];
585-
///
586-
/// for chunk in v.chunks(2) {
587-
/// println!("{:?}", chunk);
588-
/// }
580+
/// ```
581+
/// let slice = ['l', 'o', 'r', 'e', 'm'];
582+
/// let mut iter = slice.chunks(2);
583+
/// assert_eq!(iter.next().unwrap(), &['l', 'o']);
584+
/// assert_eq!(iter.next().unwrap(), &['r', 'e']);
585+
/// assert_eq!(iter.next().unwrap(), &['m']);
586+
/// assert!(iter.next().is_none());
589587
/// ```
590588
#[stable(feature = "rust1", since = "1.0.0")]
591589
#[inline]

src/libcoretest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#![feature(step_by)]
3232
#![feature(test)]
3333
#![feature(try_from)]
34-
#![feature(unboxed_closures)]
3534
#![feature(unicode)]
3635
#![feature(unique)]
3736

src/librustc/hir/intravisit.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
867867
}
868868
}
869869

870-
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
870+
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq)]
871871
pub struct IdRange {
872872
pub min: NodeId,
873873
pub max: NodeId,
@@ -893,6 +893,7 @@ impl IdRange {
893893
self.min = cmp::min(self.min, id);
894894
self.max = cmp::max(self.max, id + 1);
895895
}
896+
896897
}
897898

898899

src/librustc/hir/map/mod.rs

+57-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use hir::print as pprust;
3232

3333
use arena::TypedArena;
3434
use std::cell::RefCell;
35+
use std::cmp;
3536
use std::io;
3637
use std::mem;
3738

@@ -127,7 +128,10 @@ impl<'ast> MapEntry<'ast> {
127128
EntryStructCtor(id, _) => id,
128129
EntryLifetime(id, _) => id,
129130
EntryTyParam(id, _) => id,
130-
_ => return None
131+
132+
NotPresent |
133+
RootCrate |
134+
RootInlinedParent(_) => return None,
131135
})
132136
}
133137

@@ -196,6 +200,10 @@ pub struct Map<'ast> {
196200
map: RefCell<Vec<MapEntry<'ast>>>,
197201

198202
definitions: RefCell<Definitions>,
203+
204+
/// All NodeIds that are numerically greater or equal to this value come
205+
/// from inlined items.
206+
local_node_id_watermark: NodeId,
199207
}
200208

201209
impl<'ast> Map<'ast> {
@@ -550,6 +558,13 @@ impl<'ast> Map<'ast> {
550558
}
551559
}
552560

561+
pub fn expect_inlined_item(&self, id: NodeId) -> &'ast InlinedItem {
562+
match self.find_entry(id) {
563+
Some(RootInlinedParent(inlined_item)) => inlined_item,
564+
_ => bug!("expected inlined item, found {}", self.node_to_string(id)),
565+
}
566+
}
567+
553568
/// Returns the name associated with the given NodeId's AST.
554569
pub fn name(&self, id: NodeId) -> Name {
555570
match self.get(id) {
@@ -649,6 +664,10 @@ impl<'ast> Map<'ast> {
649664
pub fn node_to_user_string(&self, id: NodeId) -> String {
650665
node_id_to_string(self, id, false)
651666
}
667+
668+
pub fn is_inlined(&self, id: NodeId) -> bool {
669+
id >= self.local_node_id_watermark
670+
}
652671
}
653672

654673
pub struct NodesMatchingSuffix<'a, 'ast:'a> {
@@ -765,13 +784,37 @@ pub trait FoldOps {
765784
}
766785

767786
/// A Folder that updates IDs and Span's according to fold_ops.
768-
struct IdAndSpanUpdater<F> {
769-
fold_ops: F
787+
pub struct IdAndSpanUpdater<F> {
788+
fold_ops: F,
789+
min_id_assigned: NodeId,
790+
max_id_assigned: NodeId,
791+
}
792+
793+
impl<F: FoldOps> IdAndSpanUpdater<F> {
794+
pub fn new(fold_ops: F) -> IdAndSpanUpdater<F> {
795+
IdAndSpanUpdater {
796+
fold_ops: fold_ops,
797+
min_id_assigned: ::std::u32::MAX,
798+
max_id_assigned: ::std::u32::MIN,
799+
}
800+
}
801+
802+
pub fn id_range(&self) -> intravisit::IdRange {
803+
intravisit::IdRange {
804+
min: self.min_id_assigned,
805+
max: self.max_id_assigned + 1,
806+
}
807+
}
770808
}
771809

772810
impl<F: FoldOps> Folder for IdAndSpanUpdater<F> {
773811
fn new_id(&mut self, id: NodeId) -> NodeId {
774-
self.fold_ops.new_id(id)
812+
let id = self.fold_ops.new_id(id);
813+
814+
self.min_id_assigned = cmp::min(self.min_id_assigned, id);
815+
self.max_id_assigned = cmp::max(self.max_id_assigned, id);
816+
817+
id
775818
}
776819

777820
fn new_span(&mut self, span: Span) -> Span {
@@ -802,11 +845,14 @@ pub fn map_crate<'ast>(forest: &'ast mut Forest,
802845
entries, vector_length, (entries as f64 / vector_length as f64) * 100.);
803846
}
804847

848+
let local_node_id_watermark = map.len() as NodeId;
849+
805850
Map {
806851
forest: forest,
807852
dep_graph: forest.dep_graph.clone(),
808853
map: RefCell::new(map),
809854
definitions: RefCell::new(definitions),
855+
local_node_id_watermark: local_node_id_watermark
810856
}
811857
}
812858

@@ -818,7 +864,7 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
818864
ii: InlinedItem,
819865
fold_ops: F)
820866
-> &'ast InlinedItem {
821-
let mut fld = IdAndSpanUpdater { fold_ops: fold_ops };
867+
let mut fld = IdAndSpanUpdater::new(fold_ops);
822868
let ii = match ii {
823869
II::Item(i) => II::Item(i.map(|i| fld.fold_item(i))),
824870
II::TraitItem(d, ti) => {
@@ -835,6 +881,12 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
835881
let ii = map.forest.inlined_items.alloc(ii);
836882
let ii_parent_id = fld.new_id(DUMMY_NODE_ID);
837883

884+
// Assert that the ii_parent_id is the last NodeId in our reserved range
885+
assert!(ii_parent_id == fld.max_id_assigned);
886+
// Assert that we did not violate the invariant that all inlined HIR items
887+
// have NodeIds greater than or equal to `local_node_id_watermark`
888+
assert!(fld.min_id_assigned >= map.local_node_id_watermark);
889+
838890
let defs = &mut *map.definitions.borrow_mut();
839891
let mut def_collector = DefCollector::extend(ii_parent_id,
840892
parent_def_path.clone(),

src/librustc/middle/cstore.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ pub struct ChildItem {
120120
pub vis: ty::Visibility,
121121
}
122122

123-
pub enum FoundAst<'ast> {
124-
Found(&'ast InlinedItem),
125-
FoundParent(DefId, &'ast hir::Item),
126-
NotFound,
127-
}
128-
129123
#[derive(Copy, Clone, Debug)]
130124
pub struct ExternCrate {
131125
/// def_id of an `extern crate` in the current crate that caused
@@ -250,7 +244,10 @@ pub trait CrateStore<'tcx> {
250244

251245
// misc. metadata
252246
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
253-
-> FoundAst<'tcx>;
247+
-> Option<(&'tcx InlinedItem, ast::NodeId)>;
248+
fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId>;
249+
fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId>;
250+
254251
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
255252
-> Option<Mir<'tcx>>;
256253
fn is_item_mir_available(&self, def: DefId) -> bool;
@@ -447,7 +444,16 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
447444

448445
// misc. metadata
449446
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
450-
-> FoundAst<'tcx> { bug!("maybe_get_item_ast") }
447+
-> Option<(&'tcx InlinedItem, ast::NodeId)> {
448+
bug!("maybe_get_item_ast")
449+
}
450+
fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId> {
451+
bug!("local_node_for_inlined_defid")
452+
}
453+
fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId> {
454+
bug!("defid_for_inlined_node")
455+
}
456+
451457
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
452458
-> Option<Mir<'tcx>> { bug!("maybe_get_item_mir") }
453459
fn is_item_mir_available(&self, def: DefId) -> bool {

src/librustc_back/target/x86_64_rumprun_netbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use target::{Target, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::netbsd_base::opts();
15+
base.cpu = "x86-64".to_string();
1516
base.pre_link_args.push("-m64".to_string());
1617
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
1718
base.ar = "x86_64-rumprun-netbsd-ar".to_string();

src/librustc_back/target/x86_64_unknown_bitrig.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use target::{Target, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::bitrig_base::opts();
15+
base.cpu = "x86-64".to_string();
1516
base.max_atomic_width = 64;
1617
base.pre_link_args.push("-m64".to_string());
1718

src/librustc_back/target/x86_64_unknown_netbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use target::{Target, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::netbsd_base::opts();
15+
base.cpu = "x86-64".to_string();
1516
base.max_atomic_width = 64;
1617
base.pre_link_args.push("-m64".to_string());
1718

src/librustc_const_eval/eval.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use self::EvalHint::*;
1717

1818
use rustc::hir::map as ast_map;
1919
use rustc::hir::map::blocks::FnLikeNode;
20-
use rustc::middle::cstore::{self, InlinedItem};
20+
use rustc::middle::cstore::InlinedItem;
2121
use rustc::traits;
2222
use rustc::hir::def::{Def, PathResolution};
2323
use rustc::hir::def_id::DefId;
@@ -142,13 +142,13 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
142142
}
143143
let mut used_substs = false;
144144
let expr_ty = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) {
145-
cstore::FoundAst::Found(&InlinedItem::Item(ref item)) => match item.node {
145+
Some((&InlinedItem::Item(ref item), _)) => match item.node {
146146
hir::ItemConst(ref ty, ref const_expr) => {
147147
Some((&**const_expr, tcx.ast_ty_to_prim_ty(ty)))
148148
},
149149
_ => None
150150
},
151-
cstore::FoundAst::Found(&InlinedItem::TraitItem(trait_id, ref ti)) => match ti.node {
151+
Some((&InlinedItem::TraitItem(trait_id, ref ti), _)) => match ti.node {
152152
hir::ConstTraitItem(_, _) => {
153153
used_substs = true;
154154
if let Some(substs) = substs {
@@ -163,7 +163,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
163163
}
164164
_ => None
165165
},
166-
cstore::FoundAst::Found(&InlinedItem::ImplItem(_, ref ii)) => match ii.node {
166+
Some((&InlinedItem::ImplItem(_, ref ii), _)) => match ii.node {
167167
hir::ImplItemKind::Const(ref ty, ref expr) => {
168168
Some((&**expr, tcx.ast_ty_to_prim_ty(ty)))
169169
},
@@ -198,8 +198,8 @@ fn inline_const_fn_from_external_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
198198
}
199199

200200
let fn_id = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) {
201-
cstore::FoundAst::Found(&InlinedItem::Item(ref item)) => Some(item.id),
202-
cstore::FoundAst::Found(&InlinedItem::ImplItem(_, ref item)) => Some(item.id),
201+
Some((&InlinedItem::Item(ref item), _)) => Some(item.id),
202+
Some((&InlinedItem::ImplItem(_, ref item), _)) => Some(item.id),
203203
_ => None
204204
};
205205
tcx.extern_const_fns.borrow_mut().insert(def_id,

src/librustc_driver/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#![feature(set_stdio)]
3232
#![feature(staged_api)]
3333
#![feature(question_mark)]
34-
#![feature(unboxed_closures)]
3534

3635
extern crate arena;
3736
extern crate flate;

0 commit comments

Comments
 (0)