Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #34552

Merged
merged 31 commits into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7ffd46c
add regression test for #33455
dsprenkels Jun 24, 2016
58955de
Add new error codes and improve some explanations
GuillaumeGomez Jun 25, 2016
e01a2ba
Forbid type parameters and global paths in macro invocations
jseyfried Jun 27, 2016
b4611b1
Add regression test
jseyfried Jun 27, 2016
b8f9c88
Revert "skip double negation in const eval"
oli-obk Jun 27, 2016
f41de0f
Disable debuginfo tests for a given blacklist of LLDB versions
michaelwoerister Jun 27, 2016
beebaf1
rustdoc: Fix a few stripping issues
ollie27 Jun 27, 2016
b968ee3
cleanup: don't count attributes on an item in a statement position as…
jseyfried Jun 14, 2016
2dc15f2
cleanup: use `DummyResult` to implement `MacroGenerable::dummy`
jseyfried Jun 17, 2016
4a13bcb
groundwork: use `resolve_identifier` instead of `resolve_path` to cla…
jseyfried Jun 19, 2016
36a4eb9
cleanup: refactor away `ast::NodeIdAssigner`
jseyfried Jun 22, 2016
ec0c150
groundwork: refactor the interface that `resolve` exposes to `driver`
jseyfried Jun 22, 2016
e58963d
groundwork: create the `Resolver` earlier in phase 2
jseyfried Jun 22, 2016
f05da01
rustdoc: Fix empty Implementations section on some module pages
ollie27 Jun 28, 2016
232783c
Fix infinite loop on recursive module exports in an extern crate
jseyfried Jun 28, 2016
9ffe1c9
Add regression test
jseyfried Jun 29, 2016
66ef652
Disallow `derive` on items with type macros
jseyfried Jun 24, 2016
a595ffa
Treat `MultiDecorator`s as a special case of `MultiModifier`s
jseyfried Jun 24, 2016
a9d25f8
Refactor away `parser.commit_stmt_expecting()`
jseyfried Jun 29, 2016
8557a2e
Give `ast::ExprKind::Paren` no-op expressions the same node ids as th…
jseyfried Jun 19, 2016
f74d0fb
Rollup merge of #34355 - jseyfried:paren_expression_ids_nonunique, r=nrc
Manishearth Jun 29, 2016
470c519
Rollup merge of #34446 - jseyfried:refactor_decorators, r=nrc
Manishearth Jun 29, 2016
fd45e6e
Rollup merge of #34459 - jseyfried:expansion_cleanup, r=nrc
Manishearth Jun 29, 2016
d11ac23
Rollup merge of #34460 - dsprenkels:issue-33455, r=alexcrichton
Manishearth Jun 29, 2016
2a0c2c3
Rollup merge of #34467 - GuillaumeGomez:err-codes, r=brson
Manishearth Jun 29, 2016
8886818
Rollup merge of #34495 - jseyfried:only_ident_macro_invocations, r=eddyb
Manishearth Jun 29, 2016
2e893ea
Rollup merge of #34497 - oli-obk:double_negation, r=eddyb
Manishearth Jun 29, 2016
5bd3ef8
Rollup merge of #34499 - michaelwoerister:lldb-blacklist, r=alexcrichton
Manishearth Jun 29, 2016
b393c7e
Rollup merge of #34513 - ollie27:rustdoc_stripped, r=alexcrichton
Manishearth Jun 29, 2016
cc15c21
Rollup merge of #34536 - ollie27:rustdoc_module_impls, r=alexcrichton
Manishearth Jun 29, 2016
8e2598c
Rollup merge of #34542 - jseyfried:fix_recursive_modules, r=nrc
Manishearth Jun 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use session::Session;
use std::collections::BTreeMap;
use std::iter;
use syntax::ast::*;
use syntax::errors;
use syntax::ptr::P;
use syntax::codemap::{respan, Spanned};
use syntax::parse::token;
Expand All @@ -60,7 +61,7 @@ use syntax_pos::Span;
pub struct LoweringContext<'a> {
crate_root: Option<&'static str>,
// Use to assign ids to hir nodes that do not directly correspond to an ast node
id_assigner: &'a NodeIdAssigner,
sess: Option<&'a Session>,
// As we walk the AST we must keep track of the current 'parent' def id (in
// the form of a DefIndex) so that if we create a new node which introduces
// a definition, then we can properly create the def id.
Expand Down Expand Up @@ -99,7 +100,6 @@ impl Resolver for DummyResolver {

pub fn lower_crate(sess: &Session,
krate: &Crate,
id_assigner: &NodeIdAssigner,
resolver: &mut Resolver)
-> hir::Crate {
// We're constructing the HIR here; we don't care what we will
Expand All @@ -115,17 +115,17 @@ pub fn lower_crate(sess: &Session,
} else {
Some("std")
},
id_assigner: id_assigner,
sess: Some(sess),
parent_def: None,
resolver: resolver,
}.lower_crate(krate)
}

impl<'a> LoweringContext<'a> {
pub fn testing_context(id_assigner: &'a NodeIdAssigner, resolver: &'a mut Resolver) -> Self {
pub fn testing_context(resolver: &'a mut Resolver) -> Self {
LoweringContext {
crate_root: None,
id_assigner: id_assigner,
sess: None,
parent_def: None,
resolver: resolver,
}
Expand Down Expand Up @@ -161,7 +161,12 @@ impl<'a> LoweringContext<'a> {
}

fn next_id(&self) -> NodeId {
self.id_assigner.next_node_id()
self.sess.map(Session::next_node_id).unwrap_or(0)
}

fn diagnostic(&self) -> &errors::Handler {
self.sess.map(Session::diagnostic)
.unwrap_or_else(|| panic!("this lowerer cannot emit diagnostics"))
}

fn str_to_ident(&self, s: &'static str) -> Name {
Expand Down Expand Up @@ -786,7 +791,7 @@ impl<'a> LoweringContext<'a> {
if let Some(SelfKind::Explicit(..)) = sig.decl.get_self().map(|eself| eself.node) {
match hir_sig.decl.get_self().map(|eself| eself.node) {
Some(hir::SelfKind::Value(..)) | Some(hir::SelfKind::Region(..)) => {
self.id_assigner.diagnostic().span_err(sig.decl.inputs[0].ty.span,
self.diagnostic().span_err(sig.decl.inputs[0].ty.span,
"the type placeholder `_` is not allowed within types on item signatures");
}
_ => {}
Expand Down Expand Up @@ -1212,7 +1217,7 @@ impl<'a> LoweringContext<'a> {
make_struct(self, e, &["RangeInclusive", "NonEmpty"],
&[("start", e1), ("end", e2)]),

_ => panic!(self.id_assigner.diagnostic()
_ => panic!(self.diagnostic()
.span_fatal(e.span, "inclusive range with no end")),
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ pub struct DefCollector<'ast> {
// If we are walking HIR (c.f., AST), we need to keep a reference to the
// crate.
hir_crate: Option<&'ast hir::Crate>,
pub definitions: Definitions,
definitions: &'ast mut Definitions,
parent_def: Option<DefIndex>,
}

impl<'ast> DefCollector<'ast> {
pub fn root() -> DefCollector<'ast> {
pub fn root(definitions: &'ast mut Definitions) -> DefCollector<'ast> {
let mut collector = DefCollector {
hir_crate: None,
definitions: Definitions::new(),
definitions: definitions,
parent_def: None,
};
let root = collector.create_def_with_parent(None, CRATE_NODE_ID, DefPathData::CrateRoot);
Expand All @@ -48,7 +48,7 @@ impl<'ast> DefCollector<'ast> {
pub fn extend(parent_node: NodeId,
parent_def_path: DefPath,
parent_def_id: DefId,
definitions: Definitions)
definitions: &'ast mut Definitions)
-> DefCollector<'ast> {
let mut collector = DefCollector {
hir_crate: None,
Expand Down
8 changes: 7 additions & 1 deletion src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

use middle::cstore::LOCAL_CRATE;
use hir::def_id::{DefId, DefIndex};
use hir::map::def_collector::DefCollector;
use rustc_data_structures::fnv::FnvHashMap;
use syntax::ast;
use syntax::{ast, visit};
use syntax::parse::token::InternedString;
use util::nodemap::NodeMap;

Expand Down Expand Up @@ -189,6 +190,11 @@ impl Definitions {
}
}

pub fn collect(&mut self, krate: &ast::Crate) {
let mut def_collector = DefCollector::root(self);
visit::walk_crate(&mut def_collector, krate);
}

/// Get the number of definitions.
pub fn len(&self) -> usize {
self.data.len()
Expand Down
10 changes: 1 addition & 9 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use hir::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
use syntax::abi::Abi;
use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID, };
use syntax::codemap::Spanned;
use syntax::visit;
use syntax_pos::Span;

use hir::*;
Expand Down Expand Up @@ -780,12 +779,6 @@ impl<F: FoldOps> Folder for IdAndSpanUpdater<F> {
}
}

pub fn collect_definitions<'ast>(krate: &'ast ast::Crate) -> Definitions {
let mut def_collector = DefCollector::root();
visit::walk_crate(&mut def_collector, krate);
def_collector.definitions
}

pub fn map_crate<'ast>(forest: &'ast mut Forest,
definitions: Definitions)
-> Map<'ast> {
Expand Down Expand Up @@ -842,13 +835,12 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
let ii = map.forest.inlined_items.alloc(ii);
let ii_parent_id = fld.new_id(DUMMY_NODE_ID);

let defs = mem::replace(&mut *map.definitions.borrow_mut(), Definitions::new());
let defs = &mut *map.definitions.borrow_mut();
let mut def_collector = DefCollector::extend(ii_parent_id,
parent_def_path.clone(),
parent_def_id,
defs);
def_collector.walk_item(ii, map.krate());
*map.definitions.borrow_mut() = def_collector.definitions;

let mut collector = NodeCollector::extend(map.krate(),
ii,
Expand Down
19 changes: 4 additions & 15 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ty::tls;
use util::nodemap::{NodeMap, FnvHashMap};
use mir::transform as mir_pass;

use syntax::ast::{NodeId, NodeIdAssigner, Name};
use syntax::ast::{NodeId, Name};
use errors::{self, DiagnosticBuilder};
use errors::emitter::{Emitter, BasicEmitter, EmitterWriter};
use syntax::json::JsonEmitter;
Expand Down Expand Up @@ -272,6 +272,9 @@ impl Session {

id
}
pub fn next_node_id(&self) -> NodeId {
self.reserve_node_ids(1)
}
pub fn diagnostic<'a>(&'a self) -> &'a errors::Handler {
&self.parse_sess.span_diagnostic
}
Expand Down Expand Up @@ -345,20 +348,6 @@ impl Session {
}
}

impl NodeIdAssigner for Session {
fn next_node_id(&self) -> NodeId {
self.reserve_node_ids(1)
}

fn peek_node_id(&self) -> NodeId {
self.next_node_id.get().checked_add(1).unwrap()
}

fn diagnostic(&self) -> &errors::Handler {
self.diagnostic()
}
}

fn split_msg_into_multilines(msg: &str) -> Option<String> {
// Conditions for enabling multi-line errors:
if !msg.contains("mismatched types") &&
Expand Down
89 changes: 41 additions & 48 deletions src/librustc_const_eval/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,54 +543,47 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let result = match e.node {
hir::ExprUnary(hir::UnNeg, ref inner) => {
// unary neg literals already got their sign during creation
match inner.node {
hir::ExprLit(ref lit) => {
use syntax::ast::*;
use syntax::ast::LitIntType::*;
const I8_OVERFLOW: u64 = ::std::i8::MAX as u64 + 1;
const I16_OVERFLOW: u64 = ::std::i16::MAX as u64 + 1;
const I32_OVERFLOW: u64 = ::std::i32::MAX as u64 + 1;
const I64_OVERFLOW: u64 = ::std::i64::MAX as u64 + 1;
match (&lit.node, ety.map(|t| &t.sty)) {
(&LitKind::Int(I8_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I8))) |
(&LitKind::Int(I8_OVERFLOW, Signed(IntTy::I8)), _) => {
return Ok(Integral(I8(::std::i8::MIN)))
},
(&LitKind::Int(I16_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I16))) |
(&LitKind::Int(I16_OVERFLOW, Signed(IntTy::I16)), _) => {
return Ok(Integral(I16(::std::i16::MIN)))
},
(&LitKind::Int(I32_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I32))) |
(&LitKind::Int(I32_OVERFLOW, Signed(IntTy::I32)), _) => {
return Ok(Integral(I32(::std::i32::MIN)))
},
(&LitKind::Int(I64_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I64))) |
(&LitKind::Int(I64_OVERFLOW, Signed(IntTy::I64)), _) => {
return Ok(Integral(I64(::std::i64::MIN)))
},
(&LitKind::Int(n, Unsuffixed), Some(&ty::TyInt(IntTy::Is))) |
(&LitKind::Int(n, Signed(IntTy::Is)), _) => {
match tcx.sess.target.int_type {
IntTy::I16 => if n == I16_OVERFLOW {
return Ok(Integral(Isize(Is16(::std::i16::MIN))));
},
IntTy::I32 => if n == I32_OVERFLOW {
return Ok(Integral(Isize(Is32(::std::i32::MIN))));
},
IntTy::I64 => if n == I64_OVERFLOW {
return Ok(Integral(Isize(Is64(::std::i64::MIN))));
},
_ => bug!(),
}
},
_ => {},
}
},
hir::ExprUnary(hir::UnNeg, ref inner) => {
// skip `--$expr`
return eval_const_expr_partial(tcx, inner, ty_hint, fn_args);
},
_ => {},
if let hir::ExprLit(ref lit) = inner.node {
use syntax::ast::*;
use syntax::ast::LitIntType::*;
const I8_OVERFLOW: u64 = ::std::i8::MAX as u64 + 1;
const I16_OVERFLOW: u64 = ::std::i16::MAX as u64 + 1;
const I32_OVERFLOW: u64 = ::std::i32::MAX as u64 + 1;
const I64_OVERFLOW: u64 = ::std::i64::MAX as u64 + 1;
match (&lit.node, ety.map(|t| &t.sty)) {
(&LitKind::Int(I8_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I8))) |
(&LitKind::Int(I8_OVERFLOW, Signed(IntTy::I8)), _) => {
return Ok(Integral(I8(::std::i8::MIN)))
},
(&LitKind::Int(I16_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I16))) |
(&LitKind::Int(I16_OVERFLOW, Signed(IntTy::I16)), _) => {
return Ok(Integral(I16(::std::i16::MIN)))
},
(&LitKind::Int(I32_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I32))) |
(&LitKind::Int(I32_OVERFLOW, Signed(IntTy::I32)), _) => {
return Ok(Integral(I32(::std::i32::MIN)))
},
(&LitKind::Int(I64_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I64))) |
(&LitKind::Int(I64_OVERFLOW, Signed(IntTy::I64)), _) => {
return Ok(Integral(I64(::std::i64::MIN)))
},
(&LitKind::Int(n, Unsuffixed), Some(&ty::TyInt(IntTy::Is))) |
(&LitKind::Int(n, Signed(IntTy::Is)), _) => {
match tcx.sess.target.int_type {
IntTy::I16 => if n == I16_OVERFLOW {
return Ok(Integral(Isize(Is16(::std::i16::MIN))));
},
IntTy::I32 => if n == I32_OVERFLOW {
return Ok(Integral(Isize(Is32(::std::i32::MIN))));
},
IntTy::I64 => if n == I64_OVERFLOW {
return Ok(Integral(Isize(Is64(::std::i64::MIN))));
},
_ => bug!(),
}
},
_ => {},
}
}
match eval_const_expr_partial(tcx, &inner, ty_hint, fn_args)? {
Float(f) => Float(-f),
Expand Down
Loading