Rollup merge of #58259 - taiki-e:librustc_codegen_utils-2018, r=Centril

librustc_codegen_utils => 2018

Transitions `librustc_codegen_utils` to Rust 2018; cc #58099

r? @Centril
This commit is contained in:
Mazdak Farrokhzad 2019-02-09 00:15:59 +01:00 committed by GitHub
commit d7a4dd1074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 23 deletions

View File

@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"] authors = ["The Rust Project Developers"]
name = "rustc_codegen_utils" name = "rustc_codegen_utils"
version = "0.0.0" version = "0.0.0"
edition = "2018"
[lib] [lib]
name = "rustc_codegen_utils" name = "rustc_codegen_utils"

View File

@ -29,7 +29,7 @@
use rustc::middle::cstore::MetadataLoader; use rustc::middle::cstore::MetadataLoader;
use rustc::dep_graph::DepGraph; use rustc::dep_graph::DepGraph;
use rustc_target::spec::Target; use rustc_target::spec::Target;
use link::out_filename; use crate::link::out_filename;
pub use rustc_data_structures::sync::MetadataRef; pub use rustc_data_structures::sync::MetadataRef;
@ -42,8 +42,8 @@ fn print_version(&self) {}
fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] } fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] }
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>; fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>;
fn provide(&self, _providers: &mut Providers); fn provide(&self, _providers: &mut Providers<'_>);
fn provide_extern(&self, _providers: &mut Providers); fn provide_extern(&self, _providers: &mut Providers<'_>);
fn codegen_crate<'a, 'tcx>( fn codegen_crate<'a, 'tcx>(
&self, &self,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>,
@ -109,8 +109,8 @@ fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
box NoLlvmMetadataLoader box NoLlvmMetadataLoader
} }
fn provide(&self, providers: &mut Providers) { fn provide(&self, providers: &mut Providers<'_>) {
::symbol_names::provide(providers); crate::symbol_names::provide(providers);
providers.target_features_whitelist = |_tcx, _cnum| { providers.target_features_whitelist = |_tcx, _cnum| {
Default::default() // Just a dummy Default::default() // Just a dummy
@ -118,7 +118,7 @@ fn provide(&self, providers: &mut Providers) {
providers.is_reachable_non_generic = |_tcx, _defid| true; providers.is_reachable_non_generic = |_tcx, _defid| true;
providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new());
} }
fn provide_extern(&self, providers: &mut Providers) { fn provide_extern(&self, providers: &mut Providers<'_>) {
providers.is_reachable_non_generic = |_tcx, _defid| true; providers.is_reachable_non_generic = |_tcx, _defid| true;
} }
@ -129,12 +129,12 @@ fn codegen_crate<'a, 'tcx>(
) -> Box<dyn Any> { ) -> Box<dyn Any> {
use rustc_mir::monomorphize::item::MonoItem; use rustc_mir::monomorphize::item::MonoItem;
::check_for_rustc_errors_attr(tcx); crate::check_for_rustc_errors_attr(tcx);
::symbol_names_test::report_symbol_names(tcx); crate::symbol_names_test::report_symbol_names(tcx);
::rustc_incremental::assert_dep_graph(tcx); rustc_incremental::assert_dep_graph(tcx);
::rustc_incremental::assert_module_sources::assert_module_sources(tcx); rustc_incremental::assert_module_sources::assert_module_sources(tcx);
// FIXME: Fix this // FIXME: Fix this
// ::rustc::middle::dependency_format::calculate(tcx); // rustc::middle::dependency_format::calculate(tcx);
let _ = tcx.link_args(LOCAL_CRATE); let _ = tcx.link_args(LOCAL_CRATE);
let _ = tcx.native_libraries(LOCAL_CRATE); let _ = tcx.native_libraries(LOCAL_CRATE);
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);

View File

@ -14,18 +14,10 @@
#![recursion_limit="256"] #![recursion_limit="256"]
extern crate flate2; #![deny(rust_2018_idioms)]
#[macro_use]
extern crate log;
#[macro_use] #[macro_use]
extern crate rustc; extern crate rustc;
extern crate rustc_target;
extern crate rustc_metadata;
extern crate rustc_mir;
extern crate rustc_incremental;
extern crate syntax;
extern crate syntax_pos;
#[macro_use] extern crate rustc_data_structures; #[macro_use] extern crate rustc_data_structures;
use rustc::ty::TyCtxt; use rustc::ty::TyCtxt;
@ -40,7 +32,7 @@
/// error in codegen. This is used to write compile-fail tests /// error in codegen. This is used to write compile-fail tests
/// that actually test that compilation succeeds without /// that actually test that compilation succeeds without
/// reporting an error. /// reporting an error.
pub fn check_for_rustc_errors_attr(tcx: TyCtxt) { pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_, '_, '_>) {
if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) { if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
if tcx.has_attr(def_id, "rustc_error") { if tcx.has_attr(def_id, "rustc_error") {
tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful"); tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");

View File

@ -41,7 +41,7 @@ pub fn find_crate_name(sess: Option<&Session>,
attrs: &[ast::Attribute], attrs: &[ast::Attribute],
input: &Input) -> String { input: &Input) -> String {
let validate = |s: String, span: Option<Span>| { let validate = |s: String, span: Option<Span>| {
::rustc_metadata::validate_crate_name(sess, &s, span); rustc_metadata::validate_crate_name(sess, &s, span);
s s
}; };

View File

@ -103,10 +103,12 @@
use syntax_pos::symbol::Symbol; use syntax_pos::symbol::Symbol;
use log::debug;
use std::fmt::Write; use std::fmt::Write;
use std::mem::discriminant; use std::mem::discriminant;
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers { *providers = Providers {
def_symbol_name, def_symbol_name,
symbol_name, symbol_name,