Rollup merge of #55930 - ljedrz:hir_bonuses, r=cramertj

A handful of hir tweaks

- remove an unused `hir_vec` macro pattern
- simplify `fmt::Debug` for `hir::Path` (take advantage of the `Display` implementation)
- remove an unused type alias (`CrateConfig`)
- simplify a `match` expression (join common patterns)
This commit is contained in:
Pietro Albini 2018-11-15 11:04:45 +01:00 committed by GitHub
commit c915f921d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ use syntax_pos::{Span, DUMMY_SP, symbol::InternedString};
use syntax::source_map::{self, Spanned}; use syntax::source_map::{self, Spanned};
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect}; use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect};
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem}; use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy};
use syntax::attr::InlineAttr; use syntax::attr::InlineAttr;
use syntax::ext::hygiene::SyntaxContext; use syntax::ext::hygiene::SyntaxContext;
use syntax::ptr::P; use syntax::ptr::P;
@ -57,7 +57,6 @@ macro_rules! hir_vec {
($($x:expr),*) => ( ($($x:expr),*) => (
$crate::hir::HirVec::from(vec![$($x),*]) $crate::hir::HirVec::from(vec![$($x),*])
); );
($($x:expr,)*) => (hir_vec![$($x),*])
} }
pub mod check_attr; pub mod check_attr;
@ -318,7 +317,7 @@ impl Path {
impl fmt::Debug for Path { impl fmt::Debug for Path {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "path({})", print::to_string(print::NO_ANN, |s| s.print_path(self, false))) write!(f, "path({})", self)
} }
} }
@ -685,8 +684,6 @@ pub struct WhereEqPredicate {
pub rhs_ty: P<Ty>, pub rhs_ty: P<Ty>,
} }
pub type CrateConfig = HirVec<P<MetaItem>>;
/// The top-level data structure that stores the entire contents of /// The top-level data structure that stores the entire contents of
/// the crate currently being compiled. /// the crate currently being compiled.
/// ///
@ -1183,8 +1180,8 @@ impl StmtKind {
pub fn id(&self) -> NodeId { pub fn id(&self) -> NodeId {
match *self { match *self {
StmtKind::Decl(_, id) => id, StmtKind::Decl(_, id) |
StmtKind::Expr(_, id) => id, StmtKind::Expr(_, id) |
StmtKind::Semi(_, id) => id, StmtKind::Semi(_, id) => id,
} }
} }