Skip to content

Commit 52179c5

Browse files
committed
librustc_ast_lowering: fix misc fallout.
1 parent 7b6ef2b commit 52179c5

File tree

10 files changed

+78
-76
lines changed

10 files changed

+78
-76
lines changed

src/librustc/hir/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub mod def;
3939
pub mod def_id;
4040
pub mod intravisit;
4141
pub mod itemlikevisit;
42-
pub mod lowering;
4342
pub mod map;
4443
pub mod pat_util;
4544
pub mod print;
@@ -599,7 +598,7 @@ pub enum SyntheticTyParamKind {
599598
pub struct WhereClause<'hir> {
600599
pub predicates: &'hir [WherePredicate<'hir>],
601600
// Only valid if predicates isn't empty.
602-
span: Span,
601+
pub span: Span,
603602
}
604603

605604
impl WhereClause<'_> {

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
2929
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
3030
#![feature(arbitrary_self_types)]
31-
#![feature(array_value_iter)]
3231
#![feature(bool_to_option)]
3332
#![feature(box_patterns)]
3433
#![feature(box_syntax)]

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ pub enum BuiltinLintDiagnostics {
523523
DeprecatedMacro(Option<Symbol>, Span),
524524
}
525525

526-
pub(crate) fn add_elided_lifetime_in_path_suggestion(
526+
pub fn add_elided_lifetime_in_path_suggestion(
527527
sess: &Session,
528528
db: &mut DiagnosticBuilder<'_>,
529529
n: usize,

src/librustc_ast_lowering/expr.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
2-
use crate::hir;
3-
use crate::hir::def::Res;
42

3+
use rustc::bug;
4+
use rustc::hir;
5+
use rustc::hir::def::Res;
56
use rustc_data_structures::thin_vec::ThinVec;
6-
7+
use rustc_error_codes::*;
8+
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
9+
use rustc_span::symbol::{sym, Symbol};
710
use syntax::ast::*;
811
use syntax::attr;
912
use syntax::ptr::P as AstP;
10-
use syntax::source_map::{respan, DesugaringKind, Span, Spanned};
11-
use syntax::symbol::{sym, Symbol};
12-
13-
use rustc_error_codes::*;
13+
use syntax::{span_err, struct_span_err};
1414

1515
impl<'hir> LoweringContext<'_, 'hir> {
1616
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@@ -836,8 +836,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
836836
}
837837
}
838838

839-
fn lower_label(&mut self, label: Option<Label>) -> Option<hir::Label> {
840-
label.map(|label| hir::Label { ident: label.ident })
839+
fn lower_label(&mut self, label: Option<Label>) -> Option<Label> {
840+
label.map(|label| Label { ident: label.ident })
841841
}
842842

843843
fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {

src/librustc_ast_lowering/item.rs

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
use super::AnonymousLifetimeMode;
2-
use super::ImplTraitContext;
3-
use super::ImplTraitPosition;
4-
use super::ImplTraitTypeIdVisitor;
5-
use super::LoweringContext;
6-
use super::ParamMode;
7-
8-
use crate::arena::Arena;
9-
use crate::hir;
10-
use crate::hir::def::{DefKind, Res};
11-
use crate::hir::def_id::DefId;
12-
use crate::util::nodemap::NodeMap;
13-
1+
use super::{AnonymousLifetimeMode, LoweringContext, ParamMode};
2+
use super::{ImplTraitContext, ImplTraitPosition, ImplTraitTypeIdVisitor};
3+
4+
use rustc::arena::Arena;
5+
use rustc::bug;
6+
use rustc::hir;
7+
use rustc::hir::def::{DefKind, Res};
8+
use rustc::hir::def_id::DefId;
9+
use rustc::util::nodemap::NodeMap;
10+
use rustc_error_codes::*;
11+
use rustc_span::source_map::{respan, DesugaringKind};
12+
use rustc_span::symbol::{kw, sym};
13+
use rustc_span::Span;
1414
use rustc_target::spec::abi;
15-
16-
use smallvec::SmallVec;
17-
use std::collections::BTreeSet;
1815
use syntax::ast::*;
1916
use syntax::attr;
20-
use syntax::source_map::{respan, DesugaringKind};
21-
use syntax::symbol::{kw, sym};
17+
use syntax::struct_span_err;
2218
use syntax::visit::{self, Visitor};
23-
use syntax_pos::Span;
2419

25-
use rustc_error_codes::*;
20+
use log::debug;
21+
use smallvec::{smallvec, SmallVec};
22+
use std::collections::BTreeSet;
2623

2724
pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
2825
pub(super) lctx: &'a mut LoweringContext<'lowering, 'hir>,
@@ -1429,7 +1426,7 @@ pub(super) struct GenericsCtor<'hir> {
14291426
span: Span,
14301427
}
14311428

1432-
impl GenericsCtor<'hir> {
1429+
impl<'hir> GenericsCtor<'hir> {
14331430
pub(super) fn into_generics(self, arena: &'hir Arena<'hir>) -> hir::Generics<'hir> {
14341431
hir::Generics {
14351432
params: arena.alloc_from_iter(self.params),

src/librustc_ast_lowering/lib.rs

+37-35
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,47 @@
3232
//! get confused if the spans from leaf AST nodes occur in multiple places
3333
//! in the HIR, especially for multiple identifiers.
3434
35-
use crate::arena::Arena;
36-
use crate::dep_graph::DepGraph;
37-
use crate::hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
38-
use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
39-
use crate::hir::map::{DefKey, DefPathData, Definitions};
40-
use crate::hir::{self, ParamName};
41-
use crate::hir::{ConstArg, GenericArg};
42-
use crate::lint;
43-
use crate::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
44-
use crate::middle::cstore::CrateStore;
45-
use crate::session::config::nightly_options;
46-
use crate::session::Session;
47-
use crate::util::captures::Captures;
48-
use crate::util::common::FN_OUTPUT_NAME;
49-
use crate::util::nodemap::{DefIdMap, NodeMap};
50-
use errors::Applicability;
35+
#![feature(array_value_iter)]
36+
37+
use rustc::arena::Arena;
38+
use rustc::dep_graph::DepGraph;
39+
use rustc::hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
40+
use rustc::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
41+
use rustc::hir::map::{DefKey, DefPathData, Definitions};
42+
use rustc::hir::{self, ConstArg, GenericArg, ParamName};
43+
use rustc::lint;
44+
use rustc::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
45+
use rustc::middle::cstore::CrateStore;
46+
use rustc::session::config::nightly_options;
47+
use rustc::session::Session;
48+
use rustc::util::captures::Captures;
49+
use rustc::util::common::FN_OUTPUT_NAME;
50+
use rustc::util::nodemap::{DefIdMap, NodeMap};
51+
use rustc::{bug, span_bug};
5152
use rustc_data_structures::fx::FxHashSet;
5253
use rustc_data_structures::sync::Lrc;
54+
use rustc_error_codes::*;
55+
use rustc_errors::Applicability;
5356
use rustc_index::vec::IndexVec;
54-
55-
use smallvec::SmallVec;
56-
use std::collections::BTreeMap;
57-
use std::mem;
57+
use rustc_span::hygiene::ExpnId;
58+
use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind, Spanned};
59+
use rustc_span::symbol::{kw, sym, Symbol};
60+
use rustc_span::Span;
5861
use syntax::ast;
5962
use syntax::ast::*;
6063
use syntax::attr;
61-
use syntax::errors;
6264
use syntax::print::pprust;
6365
use syntax::ptr::P as AstP;
6466
use syntax::sess::ParseSess;
65-
use syntax::source_map::{respan, DesugaringKind, ExpnData, ExpnKind, Spanned};
66-
use syntax::symbol::{kw, sym, Symbol};
6767
use syntax::token::{self, Nonterminal, Token};
6868
use syntax::tokenstream::{TokenStream, TokenTree};
6969
use syntax::visit::{self, Visitor};
70-
use syntax_pos::hygiene::ExpnId;
71-
use syntax_pos::Span;
70+
use syntax::{help, struct_span_err, walk_list};
7271

73-
use rustc_error_codes::*;
72+
use log::{debug, trace};
73+
use smallvec::{smallvec, SmallVec};
74+
use std::collections::BTreeMap;
75+
use std::mem;
7476

7577
macro_rules! arena_vec {
7678
($this:expr; $($x:expr),*) => ({
@@ -84,7 +86,7 @@ mod item;
8486

8587
const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;
8688

87-
pub struct LoweringContext<'a, 'hir: 'a> {
89+
struct LoweringContext<'a, 'hir: 'a> {
8890
crate_root: Option<Symbol>,
8991

9092
/// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
@@ -235,13 +237,13 @@ enum ImplTraitPosition {
235237
Other,
236238
}
237239

238-
impl<'b, 'a> ImplTraitContext<'b, 'a> {
240+
impl<'a> ImplTraitContext<'_, 'a> {
239241
#[inline]
240242
fn disallowed() -> Self {
241243
ImplTraitContext::Disallowed(ImplTraitPosition::Other)
242244
}
243245

244-
fn reborrow(&'c mut self) -> ImplTraitContext<'c, 'a> {
246+
fn reborrow<'this>(&'this mut self) -> ImplTraitContext<'this, 'a> {
245247
use self::ImplTraitContext::*;
246248
match self {
247249
Universal(params) => Universal(params),
@@ -372,8 +374,8 @@ struct ImplTraitTypeIdVisitor<'a> {
372374
ids: &'a mut SmallVec<[NodeId; 1]>,
373375
}
374376

375-
impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
376-
fn visit_ty(&mut self, ty: &'a Ty) {
377+
impl Visitor<'_> for ImplTraitTypeIdVisitor<'_> {
378+
fn visit_ty(&mut self, ty: &Ty) {
377379
match ty.kind {
378380
TyKind::Typeof(_) | TyKind::BareFn(_) => return,
379381

@@ -383,7 +385,7 @@ impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
383385
visit::walk_ty(self, ty);
384386
}
385387

386-
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) {
388+
fn visit_path_segment(&mut self, path_span: Span, path_segment: &PathSegment) {
387389
if let Some(ref p) = path_segment.args {
388390
if let GenericArgs::Parenthesized(_) = **p {
389391
return;
@@ -687,7 +689,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
687689
self.resolver.get_import_res(id).present_items()
688690
}
689691

690-
fn diagnostic(&self) -> &errors::Handler {
692+
fn diagnostic(&self) -> &rustc_errors::Handler {
691693
self.sess.diagnostic()
692694
}
693695

@@ -3288,7 +3290,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
32883290
}
32893291
}
32903292

3291-
fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'hir>>) -> Vec<hir::BodyId> {
3293+
fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'_>>) -> Vec<hir::BodyId> {
32923294
// Sorting by span ensures that we get things in order within a
32933295
// file, and also puts the files in a sensible order.
32943296
let mut body_ids: Vec<_> = bodies.keys().cloned().collect();
@@ -3303,7 +3305,7 @@ struct GenericArgsCtor<'hir> {
33033305
parenthesized: bool,
33043306
}
33053307

3306-
impl GenericArgsCtor<'hir> {
3308+
impl<'hir> GenericArgsCtor<'hir> {
33073309
fn is_empty(&self) -> bool {
33083310
self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized
33093311
}

src/librustc_interface/passes.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc::arena::Arena;
77
use rustc::dep_graph::DepGraph;
88
use rustc::hir;
99
use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
10-
use rustc::hir::lowering::lower_crate;
1110
use rustc::lint;
1211
use rustc::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn};
1312
use rustc::middle::{self, resolve_lifetime, stability};
@@ -442,8 +441,14 @@ pub fn lower_to_hir<'res, 'tcx>(
442441
) -> Result<hir::map::Forest<'tcx>> {
443442
// Lower AST to HIR.
444443
let hir_forest = time(sess, "lowering AST -> HIR", || {
445-
let nt_to_tokenstream = rustc_parse::nt_to_tokenstream;
446-
let hir_crate = lower_crate(sess, &dep_graph, &krate, resolver, nt_to_tokenstream, arena);
444+
let hir_crate = rustc_ast_lowering::lower_crate(
445+
sess,
446+
&dep_graph,
447+
&krate,
448+
resolver,
449+
rustc_parse::nt_to_tokenstream,
450+
arena,
451+
);
447452

448453
if sess.opts.debugging_opts.hir_stats {
449454
hir_stats::print_hir_stats(&hir_crate);

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::{f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
1616

1717
use rustc_target::spec::abi::Abi;
1818
use syntax::errors::Applicability;
19-
use syntax::symbol::sym;
2019
use syntax::{ast, attr, source_map};
20+
use syntax_pos::symbol::sym;
2121
use syntax_pos::Span;
2222

2323
use rustc::hir;

src/librustc_resolve/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc::hir::def::Namespace::*;
2424
use rustc::hir::def::{self, CtorKind, CtorOf, DefKind, ExportMap, NonMacroAttrKind, PartialRes};
2525
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
2626
use rustc::hir::map::Definitions;
27-
use rustc::hir::{self, Bool, Char, Float, Int, PrimTy, Str, Uint};
27+
use rustc::hir::{Bool, Char, Float, Int, PrimTy, Str, Uint};
2828
use rustc::hir::{GlobMap, TraitMap};
2929
use rustc::lint;
3030
use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn};
@@ -1026,7 +1026,7 @@ impl<'a, 'b> DefIdTree for &'a Resolver<'b> {
10261026

10271027
/// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that
10281028
/// the resolver is no longer needed as all the relevant information is inline.
1029-
impl<'a> hir::lowering::Resolver for Resolver<'a> {
1029+
impl rustc_ast_lowering::Resolver for Resolver<'_> {
10301030
fn cstore(&self) -> &dyn CrateStore {
10311031
self.cstore()
10321032
}

src/librustc_typeck/check/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use errors::{Applicability, DiagnosticBuilder};
66
use rustc::hir::{self, is_range_literal, print, Node};
77
use rustc::ty::adjustment::AllowTwoPhase;
88
use rustc::ty::{self, AssocItem, Ty};
9-
use syntax::symbol::sym;
109
use syntax::util::parser::PREC_POSTFIX;
10+
use syntax_pos::symbol::sym;
1111
use syntax_pos::Span;
1212

1313
use super::method::probe;

0 commit comments

Comments
 (0)