From ce8dbf05f9072dfcf2580fb8f5c6d8c54ca4c7e9 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 22 Dec 2019 18:08:34 +0100 Subject: [PATCH 1/4] librustc_ast_lowering: move the files. --- src/{librustc/hir/lowering => librustc_ast_lowering}/expr.rs | 0 src/{librustc/hir/lowering => librustc_ast_lowering}/item.rs | 0 src/{librustc/hir/lowering.rs => librustc_ast_lowering/lib.rs} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/{librustc/hir/lowering => librustc_ast_lowering}/expr.rs (100%) rename src/{librustc/hir/lowering => librustc_ast_lowering}/item.rs (100%) rename src/{librustc/hir/lowering.rs => librustc_ast_lowering/lib.rs} (100%) diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc_ast_lowering/expr.rs similarity index 100% rename from src/librustc/hir/lowering/expr.rs rename to src/librustc_ast_lowering/expr.rs diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc_ast_lowering/item.rs similarity index 100% rename from src/librustc/hir/lowering/item.rs rename to src/librustc_ast_lowering/item.rs diff --git a/src/librustc/hir/lowering.rs b/src/librustc_ast_lowering/lib.rs similarity index 100% rename from src/librustc/hir/lowering.rs rename to src/librustc_ast_lowering/lib.rs From 7b6ef2b369db3adef6f6fa33750c87c1ff1fe3fe Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 22 Dec 2019 18:12:56 +0100 Subject: [PATCH 2/4] librustc_ast_lowering: cargo changes. --- Cargo.lock | 18 ++++++++++++++++++ src/librustc_ast_lowering/Cargo.toml | 22 ++++++++++++++++++++++ src/librustc_interface/Cargo.toml | 1 + src/librustc_resolve/Cargo.toml | 3 ++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/librustc_ast_lowering/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 8a76ffcbe72..947c0b8f465 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3358,6 +3358,22 @@ dependencies = [ "core", ] +[[package]] +name = "rustc_ast_lowering" +version = "0.0.0" +dependencies = [ + "log", + "rustc", + "rustc_data_structures", + "rustc_error_codes", + "rustc_errors", + "rustc_index", + "rustc_span", + "rustc_target", + "smallvec 1.0.0", + "syntax", +] + [[package]] name = "rustc_builtin_macros" version = "0.0.0" @@ -3578,6 +3594,7 @@ dependencies = [ "once_cell", "rustc", "rustc-rayon", + "rustc_ast_lowering", "rustc_builtin_macros", "rustc_codegen_llvm", "rustc_codegen_ssa", @@ -3783,6 +3800,7 @@ dependencies = [ "bitflags", "log", "rustc", + "rustc_ast_lowering", "rustc_data_structures", "rustc_error_codes", "rustc_errors", diff --git a/src/librustc_ast_lowering/Cargo.toml b/src/librustc_ast_lowering/Cargo.toml new file mode 100644 index 00000000000..664d41c45f2 --- /dev/null +++ b/src/librustc_ast_lowering/Cargo.toml @@ -0,0 +1,22 @@ +[package] +authors = ["The Rust Project Developers"] +name = "rustc_ast_lowering" +version = "0.0.0" +edition = "2018" + +[lib] +name = "rustc_ast_lowering" +path = "lib.rs" +doctest = false + +[dependencies] +log = { version = "0.4", features = ["release_max_level_info", "std"] } +rustc = { path = "../librustc" } +rustc_target = { path = "../librustc_target" } +rustc_data_structures = { path = "../librustc_data_structures" } +rustc_index = { path = "../librustc_index" } +rustc_span = { path = "../librustc_span" } +rustc_error_codes = { path = "../librustc_error_codes" } +rustc_errors = { path = "../librustc_errors" } +syntax = { path = "../libsyntax" } +smallvec = { version = "1.0", features = ["union", "may_dangle"] } diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index 73ff0cd52d7..4926cb23081 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -20,6 +20,7 @@ rustc_parse = { path = "../librustc_parse" } syntax_pos = { path = "../librustc_span", package = "rustc_span" } rustc_serialize = { path = "../libserialize", package = "serialize" } rustc = { path = "../librustc" } +rustc_ast_lowering = { path = "../librustc_ast_lowering" } rustc_incremental = { path = "../librustc_incremental" } rustc_traits = { path = "../librustc_traits" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index 0efc0de3a67..00ca06872c9 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -15,10 +15,11 @@ bitflags = "1.2.1" log = "0.4" syntax = { path = "../libsyntax" } rustc_expand = { path = "../librustc_expand" } -rustc = { path = "../librustc" } arena = { path = "../libarena" } errors = { path = "../librustc_errors", package = "rustc_errors" } syntax_pos = { path = "../librustc_span", package = "rustc_span" } +rustc = { path = "../librustc" } +rustc_ast_lowering = { path = "../librustc_ast_lowering" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_feature = { path = "../librustc_feature" } rustc_metadata = { path = "../librustc_metadata" } From 52179c56be0df07d817a143577d3e082e0a7cfa5 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 22 Dec 2019 18:15:02 +0100 Subject: [PATCH 3/4] librustc_ast_lowering: fix misc fallout. --- src/librustc/hir/mod.rs | 3 +- src/librustc/lib.rs | 1 - src/librustc/lint/builtin.rs | 2 +- src/librustc_ast_lowering/expr.rs | 18 ++++---- src/librustc_ast_lowering/item.rs | 37 +++++++-------- src/librustc_ast_lowering/lib.rs | 72 +++++++++++++++-------------- src/librustc_interface/passes.rs | 11 +++-- src/librustc_lint/types.rs | 2 +- src/librustc_resolve/lib.rs | 4 +- src/librustc_typeck/check/demand.rs | 2 +- 10 files changed, 77 insertions(+), 75 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, 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]) -> &'hir [hir::Expr<'hir>] { @@ -836,8 +836,8 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - fn lower_label(&mut self, label: Option