about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-22 18:15:02 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-31 17:56:25 +0100
commit52179c56be0df07d817a143577d3e082e0a7cfa5 (patch)
treed2448132ffd4a8e60820bcccc3d1ffc5fa89b54c
parent7b6ef2b369db3adef6f6fa33750c87c1ff1fe3fe (diff)
downloadrust-52179c56be0df07d817a143577d3e082e0a7cfa5.tar.gz
rust-52179c56be0df07d817a143577d3e082e0a7cfa5.zip
librustc_ast_lowering: fix misc fallout.
-rw-r--r--src/librustc/hir/mod.rs3
-rw-r--r--src/librustc/lib.rs1
-rw-r--r--src/librustc/lint/builtin.rs2
-rw-r--r--src/librustc_ast_lowering/expr.rs18
-rw-r--r--src/librustc_ast_lowering/item.rs39
-rw-r--r--src/librustc_ast_lowering/lib.rs72
-rw-r--r--src/librustc_interface/passes.rs11
-rw-r--r--src/librustc_lint/types.rs2
-rw-r--r--src/librustc_resolve/lib.rs4
-rw-r--r--src/librustc_typeck/check/demand.rs2
10 files changed, 78 insertions, 76 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index f56c9f8e72c..dfd06da969b 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -39,7 +39,6 @@ pub mod def;
 pub mod def_id;
 pub mod intravisit;
 pub mod itemlikevisit;
-pub mod lowering;
 pub mod map;
 pub mod pat_util;
 pub mod print;
@@ -599,7 +598,7 @@ pub enum SyntheticTyParamKind {
 pub struct WhereClause<'hir> {
     pub predicates: &'hir [WherePredicate<'hir>],
     // Only valid if predicates isn't empty.
-    span: Span,
+    pub span: Span,
 }
 
 impl WhereClause<'_> {
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 4e7913b8dfc..76588dfa5e2 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -28,7 +28,6 @@
 
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
 #![feature(arbitrary_self_types)]
-#![feature(array_value_iter)]
 #![feature(bool_to_option)]
 #![feature(box_patterns)]
 #![feature(box_syntax)]
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index 1da9661cbf2..fa6e93d867b 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -523,7 +523,7 @@ pub enum BuiltinLintDiagnostics {
     DeprecatedMacro(Option<Symbol>, Span),
 }
 
-pub(crate) fn add_elided_lifetime_in_path_suggestion(
+pub fn add_elided_lifetime_in_path_suggestion(
     sess: &Session,
     db: &mut DiagnosticBuilder<'_>,
     n: usize,
diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs
index 3911f09a227..0125e9e2c83 100644
--- a/src/librustc_ast_lowering/expr.rs
+++ b/src/librustc_ast_lowering/expr.rs
@@ -1,16 +1,16 @@
 use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
-use crate::hir;
-use crate::hir::def::Res;
 
+use rustc::bug;
+use rustc::hir;
+use rustc::hir::def::Res;
 use rustc_data_structures::thin_vec::ThinVec;
-
+use rustc_error_codes::*;
+use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
+use rustc_span::symbol::{sym, Symbol};
 use syntax::ast::*;
 use syntax::attr;
 use syntax::ptr::P as AstP;
-use syntax::source_map::{respan, DesugaringKind, Span, Spanned};
-use syntax::symbol::{sym, Symbol};
-
-use rustc_error_codes::*;
+use syntax::{span_err, struct_span_err};
 
 impl<'hir> LoweringContext<'_, 'hir> {
     fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@@ -836,8 +836,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
         }
     }
 
-    fn lower_label(&mut self, label: Option<Label>) -> Option<hir::Label> {
-        label.map(|label| hir::Label { ident: label.ident })
+    fn lower_label(&mut self, label: Option<Label>) -> Option<Label> {
+        label.map(|label| Label { ident: label.ident })
     }
 
     fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs
index 6f1088de6c2..c1eb8be0f8a 100644
--- a/src/librustc_ast_lowering/item.rs
+++ b/src/librustc_ast_lowering/item.rs
@@ -1,28 +1,25 @@
-use super::AnonymousLifetimeMode;
-use super::ImplTraitContext;
-use super::ImplTraitPosition;
-use super::ImplTraitTypeIdVisitor;
-use super::LoweringContext;
-use super::ParamMode;
-
-use crate::arena::Arena;
-use crate::hir;
-use crate::hir::def::{DefKind, Res};
-use crate::hir::def_id::DefId;
-use crate::util::nodemap::NodeMap;
-
+use super::{AnonymousLifetimeMode, LoweringContext, ParamMode};
+use super::{ImplTraitContext, ImplTraitPosition, ImplTraitTypeIdVisitor};
+
+use rustc::arena::Arena;
+use rustc::bug;
+use rustc::hir;
+use rustc::hir::def::{DefKind, Res};
+use rustc::hir::def_id::DefId;
+use rustc::util::nodemap::NodeMap;
+use rustc_error_codes::*;
+use rustc_span::source_map::{respan, DesugaringKind};
+use rustc_span::symbol::{kw, sym};
+use rustc_span::Span;
 use rustc_target::spec::abi;
-
-use smallvec::SmallVec;
-use std::collections::BTreeSet;
 use syntax::ast::*;
 use syntax::attr;
-use syntax::source_map::{respan, DesugaringKind};
-use syntax::symbol::{kw, sym};
+use syntax::struct_span_err;
 use syntax::visit::{self, Visitor};
-use syntax_pos::Span;
 
-use rustc_error_codes::*;
+use log::debug;
+use smallvec::{smallvec, SmallVec};
+use std::collections::BTreeSet;
 
 pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
     pub(super) lctx: &'a mut LoweringContext<'lowering, 'hir>,
@@ -1429,7 +1426,7 @@ pub(super) struct GenericsCtor<'hir> {
     span: Span,
 }
 
-impl GenericsCtor<'hir> {
+impl<'hir> GenericsCtor<'hir> {
     pub(super) fn into_generics(self, arena: &'hir Arena<'hir>) -> hir::Generics<'hir> {
         hir::Generics {
             params: arena.alloc_from_iter(self.params),
diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs
index 15eee3cad7f..a9214f31e7d 100644
--- a/src/librustc_ast_lowering/lib.rs
+++ b/src/librustc_ast_lowering/lib.rs
@@ -32,45 +32,47 @@
 //! get confused if the spans from leaf AST nodes occur in multiple places
 //! in the HIR, especially for multiple identifiers.
 
-use crate::arena::Arena;
-use crate::dep_graph::DepGraph;
-use crate::hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
-use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
-use crate::hir::map::{DefKey, DefPathData, Definitions};
-use crate::hir::{self, ParamName};
-use crate::hir::{ConstArg, GenericArg};
-use crate::lint;
-use crate::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
-use crate::middle::cstore::CrateStore;
-use crate::session::config::nightly_options;
-use crate::session::Session;
-use crate::util::captures::Captures;
-use crate::util::common::FN_OUTPUT_NAME;
-use crate::util::nodemap::{DefIdMap, NodeMap};
-use errors::Applicability;
+#![feature(array_value_iter)]
+
+use rustc::arena::Arena;
+use rustc::dep_graph::DepGraph;
+use rustc::hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
+use rustc::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
+use rustc::hir::map::{DefKey, DefPathData, Definitions};
+use rustc::hir::{self, ConstArg, GenericArg, ParamName};
+use rustc::lint;
+use rustc::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
+use rustc::middle::cstore::CrateStore;
+use rustc::session::config::nightly_options;
+use rustc::session::Session;
+use rustc::util::captures::Captures;
+use rustc::util::common::FN_OUTPUT_NAME;
+use rustc::util::nodemap::{DefIdMap, NodeMap};
+use rustc::{bug, span_bug};
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::sync::Lrc;
+use rustc_error_codes::*;
+use rustc_errors::Applicability;
 use rustc_index::vec::IndexVec;
-
-use smallvec::SmallVec;
-use std::collections::BTreeMap;
-use std::mem;
+use rustc_span::hygiene::ExpnId;
+use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind, Spanned};
+use rustc_span::symbol::{kw, sym, Symbol};
+use rustc_span::Span;
 use syntax::ast;
 use syntax::ast::*;
 use syntax::attr;
-use syntax::errors;
 use syntax::print::pprust;
 use syntax::ptr::P as AstP;
 use syntax::sess::ParseSess;
-use syntax::source_map::{respan, DesugaringKind, ExpnData, ExpnKind, Spanned};
-use syntax::symbol::{kw, sym, Symbol};
 use syntax::token::{self, Nonterminal, Token};
 use syntax::tokenstream::{TokenStream, TokenTree};
 use syntax::visit::{self, Visitor};
-use syntax_pos::hygiene::ExpnId;
-use syntax_pos::Span;
+use syntax::{help, struct_span_err, walk_list};
 
-use rustc_error_codes::*;
+use log::{debug, trace};
+use smallvec::{smallvec, SmallVec};
+use std::collections::BTreeMap;
+use std::mem;
 
 macro_rules! arena_vec {
     ($this:expr; $($x:expr),*) => ({
@@ -84,7 +86,7 @@ mod item;
 
 const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;
 
-pub struct LoweringContext<'a, 'hir: 'a> {
+struct LoweringContext<'a, 'hir: 'a> {
     crate_root: Option<Symbol>,
 
     /// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
@@ -235,13 +237,13 @@ enum ImplTraitPosition {
     Other,
 }
 
-impl<'b, 'a> ImplTraitContext<'b, 'a> {
+impl<'a> ImplTraitContext<'_, 'a> {
     #[inline]
     fn disallowed() -> Self {
         ImplTraitContext::Disallowed(ImplTraitPosition::Other)
     }
 
-    fn reborrow(&'c mut self) -> ImplTraitContext<'c, 'a> {
+    fn reborrow<'this>(&'this mut self) -> ImplTraitContext<'this, 'a> {
         use self::ImplTraitContext::*;
         match self {
             Universal(params) => Universal(params),
@@ -372,8 +374,8 @@ struct ImplTraitTypeIdVisitor<'a> {
     ids: &'a mut SmallVec<[NodeId; 1]>,
 }
 
-impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
-    fn visit_ty(&mut self, ty: &'a Ty) {
+impl Visitor<'_> for ImplTraitTypeIdVisitor<'_> {
+    fn visit_ty(&mut self, ty: &Ty) {
         match ty.kind {
             TyKind::Typeof(_) | TyKind::BareFn(_) => return,
 
@@ -383,7 +385,7 @@ impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
         visit::walk_ty(self, ty);
     }
 
-    fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) {
+    fn visit_path_segment(&mut self, path_span: Span, path_segment: &PathSegment) {
         if let Some(ref p) = path_segment.args {
             if let GenericArgs::Parenthesized(_) = **p {
                 return;
@@ -687,7 +689,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         self.resolver.get_import_res(id).present_items()
     }
 
-    fn diagnostic(&self) -> &errors::Handler {
+    fn diagnostic(&self) -> &rustc_errors::Handler {
         self.sess.diagnostic()
     }
 
@@ -3288,7 +3290,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
     }
 }
 
-fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'hir>>) -> Vec<hir::BodyId> {
+fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'_>>) -> Vec<hir::BodyId> {
     // Sorting by span ensures that we get things in order within a
     // file, and also puts the files in a sensible order.
     let mut body_ids: Vec<_> = bodies.keys().cloned().collect();
@@ -3303,7 +3305,7 @@ struct GenericArgsCtor<'hir> {
     parenthesized: bool,
 }
 
-impl GenericArgsCtor<'hir> {
+impl<'hir> GenericArgsCtor<'hir> {
     fn is_empty(&self) -> bool {
         self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized
     }
diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs
index 57fd2fb6d27..36bf5cb6cfa 100644
--- a/src/librustc_interface/passes.rs
+++ b/src/librustc_interface/passes.rs
@@ -7,7 +7,6 @@ use rustc::arena::Arena;
 use rustc::dep_graph::DepGraph;
 use rustc::hir;
 use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
-use rustc::hir::lowering::lower_crate;
 use rustc::lint;
 use rustc::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn};
 use rustc::middle::{self, resolve_lifetime, stability};
@@ -442,8 +441,14 @@ pub fn lower_to_hir<'res, 'tcx>(
 ) -> Result<hir::map::Forest<'tcx>> {
     // Lower AST to HIR.
     let hir_forest = time(sess, "lowering AST -> HIR", || {
-        let nt_to_tokenstream = rustc_parse::nt_to_tokenstream;
-        let hir_crate = lower_crate(sess, &dep_graph, &krate, resolver, nt_to_tokenstream, arena);
+        let hir_crate = rustc_ast_lowering::lower_crate(
+            sess,
+            &dep_graph,
+            &krate,
+            resolver,
+            rustc_parse::nt_to_tokenstream,
+            arena,
+        );
 
         if sess.opts.debugging_opts.hir_stats {
             hir_stats::print_hir_stats(&hir_crate);
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index 65018194af2..a57e98bd220 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -16,8 +16,8 @@ use std::{f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
 
 use rustc_target::spec::abi::Abi;
 use syntax::errors::Applicability;
-use syntax::symbol::sym;
 use syntax::{ast, attr, source_map};
+use syntax_pos::symbol::sym;
 use syntax_pos::Span;
 
 use rustc::hir;
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 357176ae090..1b9e3c3886f 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -24,7 +24,7 @@ use rustc::hir::def::Namespace::*;
 use rustc::hir::def::{self, CtorKind, CtorOf, DefKind, ExportMap, NonMacroAttrKind, PartialRes};
 use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
 use rustc::hir::map::Definitions;
-use rustc::hir::{self, Bool, Char, Float, Int, PrimTy, Str, Uint};
+use rustc::hir::{Bool, Char, Float, Int, PrimTy, Str, Uint};
 use rustc::hir::{GlobMap, TraitMap};
 use rustc::lint;
 use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn};
@@ -1026,7 +1026,7 @@ impl<'a, 'b> DefIdTree for &'a Resolver<'b> {
 
 /// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that
 /// the resolver is no longer needed as all the relevant information is inline.
-impl<'a> hir::lowering::Resolver for Resolver<'a> {
+impl rustc_ast_lowering::Resolver for Resolver<'_> {
     fn cstore(&self) -> &dyn CrateStore {
         self.cstore()
     }
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index 68f2943e9e1..6fdf4efc181 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -6,8 +6,8 @@ use errors::{Applicability, DiagnosticBuilder};
 use rustc::hir::{self, is_range_literal, print, Node};
 use rustc::ty::adjustment::AllowTwoPhase;
 use rustc::ty::{self, AssocItem, Ty};
-use syntax::symbol::sym;
 use syntax::util::parser::PREC_POSTFIX;
+use syntax_pos::symbol::sym;
 use syntax_pos::Span;
 
 use super::method::probe;