From 3ad0aabddab0c73dcf80f13dfb80d1a175f7364a Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Mon, 4 Feb 2019 01:05:45 +0900 Subject: [PATCH 01/21] Transition build_helper to 2018 edition --- src/build_helper/Cargo.toml | 1 + src/build_helper/lib.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/build_helper/Cargo.toml b/src/build_helper/Cargo.toml index 01d704f816bbc..04c7820b45665 100644 --- a/src/build_helper/Cargo.toml +++ b/src/build_helper/Cargo.toml @@ -2,6 +2,7 @@ name = "build_helper" version = "0.1.0" authors = ["The Rust Project Developers"] +edition = "2018" [lib] name = "build_helper" diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index c66c5c9249087..93aa91768121c 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + use std::fs::File; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; From fab032a01dd38693834f54ec424f30f6d9e3aace Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sun, 3 Feb 2019 10:12:47 +0100 Subject: [PATCH 02/21] Transition compiletest to Rust 2018 --- src/tools/compiletest/Cargo.toml | 1 + src/tools/compiletest/src/common.rs | 4 ++-- src/tools/compiletest/src/errors.rs | 2 +- src/tools/compiletest/src/header.rs | 6 ++--- src/tools/compiletest/src/json.rs | 4 ++-- src/tools/compiletest/src/main.rs | 22 +++++++----------- src/tools/compiletest/src/read2.rs | 11 ++++----- src/tools/compiletest/src/runtest.rs | 34 ++++++++++++++-------------- src/tools/compiletest/src/util.rs | 2 +- 9 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index edf4aeab1c70f..00e1a53473cda 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "compiletest" version = "0.0.0" +edition = "2018" [dependencies] diff = "0.1.10" diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index f6f8ef1dff485..42afb72c91f39 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use test::ColorConfig; -use util::PathBufExt; +use crate::util::PathBufExt; #[derive(Clone, Copy, PartialEq, Debug)] pub enum Mode { @@ -66,7 +66,7 @@ impl FromStr for Mode { } impl fmt::Display for Mode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = match *self { CompileFail => "compile-fail", RunFail => "run-fail", diff --git a/src/tools/compiletest/src/errors.rs b/src/tools/compiletest/src/errors.rs index fd3f002fb6682..0329fb0db1422 100644 --- a/src/tools/compiletest/src/errors.rs +++ b/src/tools/compiletest/src/errors.rs @@ -33,7 +33,7 @@ impl FromStr for ErrorKind { } impl fmt::Display for ErrorKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ErrorKind::Help => write!(f, "help message"), ErrorKind::Error => write!(f, "error"), diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 591d92f0cfa14..80a015d7aea56 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -4,10 +4,10 @@ use std::io::prelude::*; use std::io::BufReader; use std::path::{Path, PathBuf}; -use common::{self, CompareMode, Config, Mode}; -use util; +use crate::common::{self, CompareMode, Config, Mode}; +use crate::util; -use extract_gdb_version; +use crate::extract_gdb_version; /// Whether to ignore the test. #[derive(Clone, Copy, PartialEq, Debug)] diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 106aa67157a42..12aae303f29aa 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -1,5 +1,5 @@ -use errors::{Error, ErrorKind}; -use runtest::ProcRes; +use crate::errors::{Error, ErrorKind}; +use crate::runtest::ProcRes; use serde_json; use std::path::Path; use std::str::FromStr; diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 15d53f1e3755c..1f9b4b2ad4363 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -1,29 +1,21 @@ #![crate_name = "compiletest"] #![feature(test)] -#![deny(warnings)] +#![deny(warnings, rust_2018_idioms)] -extern crate diff; -extern crate env_logger; -extern crate filetime; -extern crate getopts; #[cfg(unix)] extern crate libc; #[macro_use] extern crate log; -extern crate regex; #[macro_use] extern crate lazy_static; #[macro_use] extern crate serde_derive; -extern crate serde_json; extern crate test; -extern crate rustfix; -extern crate walkdir; -use common::CompareMode; -use common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; -use common::{Config, TestPaths}; -use common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty}; +use crate::common::CompareMode; +use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; +use crate::common::{Config, TestPaths}; +use crate::common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty}; use filetime::FileTime; use getopts::Options; use std::env; @@ -33,8 +25,10 @@ use std::io::{self, ErrorKind}; use std::path::{Path, PathBuf}; use std::process::Command; use test::ColorConfig; -use util::logv; +use crate::util::logv; use walkdir::WalkDir; +use env_logger; +use getopts; use self::header::{EarlyProps, Ignore}; diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index 5a4caddcdd319..6dfd8e97c636d 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -100,18 +100,15 @@ mod imp { #[cfg(windows)] mod imp { - extern crate miow; - extern crate winapi; - use std::io; use std::os::windows::prelude::*; use std::process::{ChildStderr, ChildStdout}; use std::slice; - use self::miow::iocp::{CompletionPort, CompletionStatus}; - use self::miow::pipe::NamedPipe; - use self::miow::Overlapped; - use self::winapi::shared::winerror::ERROR_BROKEN_PIPE; + use miow::iocp::{CompletionPort, CompletionStatus}; + use miow::pipe::NamedPipe; + use miow::Overlapped; + use winapi::shared::winerror::ERROR_BROKEN_PIPE; struct Pipe<'a> { dst: &'a mut Vec, diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ff201b03a0bdc..31529810a04db 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1,18 +1,18 @@ -use common::CompareMode; -use common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT}; -use common::{output_base_dir, output_base_name, output_testname_unique}; -use common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc}; -use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind}; -use common::{Config, TestPaths}; -use common::{Incremental, MirOpt, RunMake, Ui}; +use crate::common::CompareMode; +use crate::common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT}; +use crate::common::{output_base_dir, output_base_name, output_testname_unique}; +use crate::common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc}; +use crate::common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind}; +use crate::common::{Config, TestPaths}; +use crate::common::{Incremental, MirOpt, RunMake, Ui}; use diff; -use errors::{self, Error, ErrorKind}; +use crate::errors::{self, Error, ErrorKind}; use filetime::FileTime; -use header::TestProps; -use json; +use crate::header::TestProps; +use crate::json; use regex::Regex; use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; -use util::{logv, PathBufExt}; +use crate::util::{logv, PathBufExt}; use std::collections::hash_map::DefaultHasher; use std::collections::{HashMap, HashSet, VecDeque}; @@ -27,8 +27,8 @@ use std::path::{Path, PathBuf}; use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::str; -use extract_gdb_version; -use is_android_gdb_target; +use crate::extract_gdb_version; +use crate::is_android_gdb_target; #[cfg(windows)] fn disable_error_reporting R, R>(f: F) -> R { @@ -1937,7 +1937,7 @@ impl<'test> TestCx<'test> { } fn make_cmdline(&self, command: &Command, libpath: &str) -> String { - use util; + use crate::util; // Linux and mac don't require adjusting the library search path if cfg!(unix) { @@ -3255,7 +3255,7 @@ impl<'test> TestCx<'test> { } fn create_stamp(&self) { - let stamp = ::stamp(&self.config, self.testpaths, self.revision); + let stamp = crate::stamp(&self.config, self.testpaths, self.revision); fs::write(&stamp, compute_stamp_hash(&self.config)).unwrap(); } } @@ -3311,7 +3311,7 @@ impl fmt::Debug for ExpectedLine where T: AsRef + fmt::Debug, { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { if let &ExpectedLine::Text(ref t) = self { write!(formatter, "{:?}", t) } else { @@ -3334,7 +3334,7 @@ fn nocomment_mir_line(line: &str) -> &str { } fn read2_abbreviated(mut child: Child) -> io::Result { - use read2::read2; + use crate::read2::read2; use std::mem::replace; const HEAD_LEN: usize = 160 * 1024; diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 90dfadeee4612..85be2fed07567 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -1,7 +1,7 @@ use std::ffi::OsStr; use std::env; use std::path::PathBuf; -use common::Config; +use crate::common::Config; /// Conversion table from triple OS name to Rust SYSNAME const OS_TABLE: &'static [(&'static str, &'static str)] = &[ From a6f2f7f15e4c4c24f9091bbbb8c56952c15ab70a Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Mon, 4 Feb 2019 00:39:37 +0900 Subject: [PATCH 03/21] Transition rustdoc to 2018 edition --- src/tools/rustdoc/Cargo.toml | 1 + src/tools/rustdoc/main.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/rustdoc/Cargo.toml b/src/tools/rustdoc/Cargo.toml index d38815004418c..36aa5916da733 100644 --- a/src/tools/rustdoc/Cargo.toml +++ b/src/tools/rustdoc/Cargo.toml @@ -2,6 +2,7 @@ name = "rustdoc-tool" version = "0.0.0" authors = ["The Rust Project Developers"] +edition = "2018" # Cargo adds a number of paths to the dylib search path on windows, which results in # the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool" diff --git a/src/tools/rustdoc/main.rs b/src/tools/rustdoc/main.rs index df9d2c6ba96db..8bdc365c4ca68 100644 --- a/src/tools/rustdoc/main.rs +++ b/src/tools/rustdoc/main.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + #![feature(link_args)] #[allow(unused_attributes)] @@ -10,6 +12,4 @@ // See src/rustc/rustc.rs for the corresponding rustc settings. extern {} -extern crate rustdoc; - fn main() { rustdoc::main() } From 44b2cc0941e63cb8b12fd3a361d8eb8564504a73 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 6 Feb 2019 22:55:03 +0900 Subject: [PATCH 04/21] librustc_allocator => 2018 --- src/librustc_allocator/Cargo.toml | 1 + src/librustc_allocator/expand.rs | 10 +++++----- src/librustc_allocator/lib.rs | 11 +---------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/librustc_allocator/Cargo.toml b/src/librustc_allocator/Cargo.toml index 03d33f413c807..cf6c598bfb17b 100644 --- a/src/librustc_allocator/Cargo.toml +++ b/src/librustc_allocator/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_allocator" version = "0.0.0" +edition = "2018" [lib] path = "lib.rs" diff --git a/src/librustc_allocator/expand.rs b/src/librustc_allocator/expand.rs index 1fb1794d5147d..d302e7646d168 100644 --- a/src/librustc_allocator/expand.rs +++ b/src/librustc_allocator/expand.rs @@ -1,6 +1,6 @@ +use log::debug; use rustc::middle::allocator::AllocatorKind; -use rustc_errors; -use smallvec::SmallVec; +use smallvec::{smallvec, SmallVec}; use syntax::{ ast::{ self, Arg, Attribute, Crate, Expr, FnHeader, Generics, Ident, Item, ItemKind, @@ -23,7 +23,7 @@ use syntax::{ }; use syntax_pos::Span; -use {AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS}; +use crate::{AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS}; pub fn modify( sess: &ParseSess, @@ -54,7 +54,7 @@ struct ExpandAllocatorDirectives<'a> { in_submod: isize, } -impl<'a> MutVisitor for ExpandAllocatorDirectives<'a> { +impl MutVisitor for ExpandAllocatorDirectives<'_> { fn flat_map_item(&mut self, item: P) -> SmallVec<[P; 1]> { debug!("in submodule {}", self.in_submod); @@ -168,7 +168,7 @@ struct AllocFnFactory<'a> { cx: ExtCtxt<'a>, } -impl<'a> AllocFnFactory<'a> { +impl AllocFnFactory<'_> { fn allocator_fn(&self, method: &AllocatorMethod) -> P { let mut abi_args = Vec::new(); let mut i = 0; diff --git a/src/librustc_allocator/lib.rs b/src/librustc_allocator/lib.rs index 41c0be615956e..16b9ccfda8010 100644 --- a/src/librustc_allocator/lib.rs +++ b/src/librustc_allocator/lib.rs @@ -1,15 +1,6 @@ -#![feature(nll)] #![feature(rustc_private)] -#[macro_use] extern crate log; -extern crate rustc; -extern crate rustc_data_structures; -extern crate rustc_errors; -extern crate rustc_target; -extern crate syntax; -extern crate syntax_pos; -#[macro_use] -extern crate smallvec; +#![deny(rust_2018_idioms)] pub mod expand; From ba0fbd763d8d6b88457c0c06f1a3f583b69fcd19 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 7 Feb 2019 01:02:00 +0900 Subject: [PATCH 05/21] librustc_save_analysis => 2018 --- src/librustc_save_analysis/Cargo.toml | 1 + src/librustc_save_analysis/dump_visitor.rs | 73 ++++++++++++---------- src/librustc_save_analysis/json_dumper.rs | 4 +- src/librustc_save_analysis/lib.rs | 30 +++------ src/librustc_save_analysis/sig.rs | 51 ++++++++------- src/librustc_save_analysis/span_utils.rs | 2 +- 6 files changed, 79 insertions(+), 82 deletions(-) diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index e47f89c64ff07..8bb2e722b5794 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_save_analysis" version = "0.0.0" +edition = "2018" [lib] name = "rustc_save_analysis" diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 995df3802aabd..4d8bc0ad5ddf0 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -16,6 +16,7 @@ use rustc::hir::def::Def as HirDef; use rustc::hir::def_id::DefId; use rustc::session::config::Input; +use rustc::span_bug; use rustc::ty::{self, TyCtxt}; use rustc_data_structures::fx::FxHashSet; @@ -32,16 +33,20 @@ use syntax::print::pprust::{ }; use syntax::ptr::P; use syntax::source_map::{Spanned, DUMMY_SP, respan}; +use syntax::walk_list; use syntax_pos::*; -use {escape, generated_code, lower_attributes, PathCollector, SaveContext}; -use json_dumper::{Access, DumpOutput, JsonDumper}; -use span_utils::SpanUtils; -use sig; +use crate::{escape, generated_code, id_from_def_id, id_from_node_id, lower_attributes, + PathCollector, SaveContext}; +use crate::json_dumper::{Access, DumpOutput, JsonDumper}; +use crate::span_utils::SpanUtils; +use crate::sig; use rls_data::{CompilationOptions, CratePreludeData, Def, DefKind, GlobalCrateId, Import, ImportKind, Ref, RefKind, Relation, RelationKind, SpanData}; +use log::{debug, error}; + macro_rules! down_cast_data { ($id:ident, $kind:ident, $sp:expr) => { let $id = if let super::Data::$kind(data) = $id { @@ -68,7 +73,7 @@ macro_rules! access_from { }; } -pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> { +pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput> { save_ctxt: SaveContext<'l, 'tcx>, tcx: TyCtxt<'l, 'tcx, 'tcx>, dumper: &'ll mut JsonDumper, @@ -245,7 +250,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { None => continue, }; if !self.span.filter_generated(ident.span) { - let id = ::id_from_node_id(id, &self.save_ctxt); + let id = id_from_node_id(id, &self.save_ctxt); let span = self.span_from_span(ident.span); self.dumper.dump_def( @@ -286,7 +291,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { debug!("process_method: {}:{}", id, ident); if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident, span) { - let sig_str = ::make_signature(&sig.decl, &generics); + let sig_str = crate::make_signature(&sig.decl, &generics); if body.is_some() { self.nest_tables( id, @@ -339,7 +344,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // Append $id to name to make sure each one is unique. let qualname = format!("{}::{}${}", prefix, name, id); if !self.span.filter_generated(param_ss) { - let id = ::id_from_node_id(param.id, &self.save_ctxt); + let id = id_from_node_id(param.id, &self.save_ctxt); let span = self.span_from_span(param_ss); self.dumper.dump_def( @@ -433,12 +438,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { &access_from!(self.save_ctxt, vis, id), Def { kind: DefKind::Const, - id: ::id_from_node_id(id, &self.save_ctxt), + id: id_from_node_id(id, &self.save_ctxt), span, name: ident.name.to_string(), qualname, value: ty_to_string(&typ), - parent: Some(::id_from_def_id(parent_id)), + parent: Some(id_from_def_id(parent_id)), children: vec![], decl_id: None, docs: self.save_ctxt.docs_for_attrs(attrs), @@ -495,7 +500,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { value, fields .iter() - .map(|f| ::id_from_node_id(f.id, &self.save_ctxt)) + .map(|f| id_from_node_id(f.id, &self.save_ctxt)) .collect(), ) } @@ -508,7 +513,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { &access_from!(self.save_ctxt, item), Def { kind, - id: ::id_from_node_id(item.id, &self.save_ctxt), + id: id_from_node_id(item.id, &self.save_ctxt), span, name, qualname: qualname.clone(), @@ -564,8 +569,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let value = format!("{}::{} {{ {} }}", enum_data.name, name, fields_str); if !self.span.filter_generated(name_span) { let span = self.span_from_span(name_span); - let id = ::id_from_node_id(variant.node.data.id(), &self.save_ctxt); - let parent = Some(::id_from_node_id(item.id, &self.save_ctxt)); + let id = id_from_node_id(variant.node.data.id(), &self.save_ctxt); + let parent = Some(id_from_node_id(item.id, &self.save_ctxt)); self.dumper.dump_def( &access, @@ -602,8 +607,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { } if !self.span.filter_generated(name_span) { let span = self.span_from_span(name_span); - let id = ::id_from_node_id(variant.node.data.id(), &self.save_ctxt); - let parent = Some(::id_from_node_id(item.id, &self.save_ctxt)); + let id = id_from_node_id(variant.node.data.id(), &self.save_ctxt); + let parent = Some(id_from_node_id(item.id, &self.save_ctxt)); self.dumper.dump_def( &access, @@ -686,11 +691,11 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { val.push_str(&bounds_to_string(trait_refs)); } if !self.span.filter_generated(item.ident.span) { - let id = ::id_from_node_id(item.id, &self.save_ctxt); + let id = id_from_node_id(item.id, &self.save_ctxt); let span = self.span_from_span(item.ident.span); let children = methods .iter() - .map(|i| ::id_from_node_id(i.id, &self.save_ctxt)) + .map(|i| id_from_node_id(i.id, &self.save_ctxt)) .collect(); self.dumper.dump_def( &access_from!(self.save_ctxt, item), @@ -726,14 +731,14 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { self.dumper.dump_ref(Ref { kind: RefKind::Type, span: span.clone(), - ref_id: ::id_from_def_id(id), + ref_id: id_from_def_id(id), }); self.dumper.dump_relation(Relation { kind: RelationKind::SuperTrait, span, - from: ::id_from_def_id(id), - to: ::id_from_node_id(item.id, &self.save_ctxt), + from: id_from_def_id(id), + to: id_from_node_id(item.id, &self.save_ctxt), }); } } @@ -873,7 +878,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { self.dumper.dump_ref(Ref { kind: RefKind::Variable, span, - ref_id: ::id_from_def_id(variant.fields[index].did), + ref_id: id_from_def_id(variant.fields[index].did), }); } } @@ -912,7 +917,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { if !self.span.filter_generated(ident.span) { let qualname = format!("{}${}", ident.to_string(), id); - let id = ::id_from_node_id(id, &self.save_ctxt); + let id = id_from_node_id(id, &self.save_ctxt); let span = self.span_from_span(ident.span); self.dumper.dump_def( @@ -988,7 +993,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // Rust uses the id of the pattern for var lookups, so we'll use it too. if !self.span.filter_generated(ident.span) { let qualname = format!("{}${}", ident.to_string(), id); - let id = ::id_from_node_id(id, &self.save_ctxt); + let id = id_from_node_id(id, &self.save_ctxt); let span = self.span_from_span(ident.span); self.dumper.dump_def( @@ -1091,7 +1096,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { if !self.span.filter_generated(trait_item.ident.span) { let span = self.span_from_span(trait_item.ident.span); - let id = ::id_from_node_id(trait_item.id, &self.save_ctxt); + let id = id_from_node_id(trait_item.id, &self.save_ctxt); self.dumper.dump_def( &Access { @@ -1105,7 +1110,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { name, qualname, value: self.span.snippet(trait_item.span), - parent: Some(::id_from_def_id(trait_id)), + parent: Some(id_from_def_id(trait_id)), children: vec![], decl_id: None, docs: self.save_ctxt.docs_for_attrs(&trait_item.attrs), @@ -1196,7 +1201,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // The parent def id of a given use tree is always the enclosing item. let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id) .and_then(|id| self.save_ctxt.tcx.parent_def_id(id)) - .map(::id_from_def_id); + .map(id_from_def_id); match use_tree.kind { ast::UseTreeKind::Simple(alias, ..) => { @@ -1212,7 +1217,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let sub_span = path.segments.last().unwrap().ident.span; if !self.span.filter_generated(sub_span) { - let ref_id = self.lookup_def_id(id).map(|id| ::id_from_def_id(id)); + let ref_id = self.lookup_def_id(id).map(|id| id_from_def_id(id)); let alias_span = alias.map(|i| self.span_from_span(i.span)); let span = self.span_from_span(sub_span); self.dumper.import(&access, Import { @@ -1298,10 +1303,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc let cm = self.tcx.sess.source_map(); let filename = cm.span_to_filename(span); - let data_id = ::id_from_node_id(id, &self.save_ctxt); + let data_id = id_from_node_id(id, &self.save_ctxt); let children = m.items .iter() - .map(|i| ::id_from_node_id(i.id, &self.save_ctxt)) + .map(|i| id_from_node_id(i.id, &self.save_ctxt)) .collect(); let span = self.span_from_span(span); @@ -1345,7 +1350,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc let span = self.span_from_span(name_span); let parent = self.save_ctxt.tcx.hir().opt_local_def_id(item.id) .and_then(|id| self.save_ctxt.tcx.parent_def_id(id)) - .map(::id_from_def_id); + .map(id_from_def_id); self.dumper.import( &Access { public: false, @@ -1387,7 +1392,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc let value = ty_to_string(&ty); if !self.span.filter_generated(item.ident.span) { let span = self.span_from_span(item.ident.span); - let id = ::id_from_node_id(item.id, &self.save_ctxt); + let id = id_from_node_id(item.id, &self.save_ctxt); self.dumper.dump_def( &access_from!(self.save_ctxt, item), @@ -1417,7 +1422,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc let value = String::new(); if !self.span.filter_generated(item.ident.span) { let span = self.span_from_span(item.ident.span); - let id = ::id_from_node_id(item.id, &self.save_ctxt); + let id = id_from_node_id(item.id, &self.save_ctxt); self.dumper.dump_def( &access_from!(self.save_ctxt, item), @@ -1476,7 +1481,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc self.dumper.dump_ref(Ref { kind: RefKind::Type, span, - ref_id: ::id_from_def_id(id), + ref_id: id_from_def_id(id), }); } diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 3627c5577a626..1840cf652e1d5 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -7,6 +7,8 @@ use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKin MacroRef, Ref, RefKind, Relation}; use rls_span::{Column, Row}; +use log::error; + #[derive(Debug)] pub struct Access { pub reachable: bool, @@ -23,7 +25,7 @@ pub trait DumpOutput { fn dump(&mut self, result: &Analysis); } -pub struct WriteOutput<'b, W: Write + 'b> { +pub struct WriteOutput<'b, W: Write> { output: &'b mut W, } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 73eb5de5c76f0..04ff1faf032cc 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -2,28 +2,11 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] -#![feature(nll)] +#![deny(rust_2018_idioms)] #![allow(unused_attributes)] #![recursion_limit="256"] -#[macro_use] -extern crate rustc; - -#[macro_use] -extern crate log; -extern crate rustc_data_structures; -extern crate rustc_codegen_utils; -extern crate rustc_serialize; -extern crate rustc_target; -extern crate rustc_typeck; -#[macro_use] -extern crate syntax; -extern crate syntax_pos; - -extern crate rls_data; -extern crate rls_span; - mod json_dumper; mod dump_visitor; @@ -39,6 +22,7 @@ use rustc::middle::privacy::AccessLevels; use rustc::middle::cstore::ExternCrate; use rustc::session::config::{CrateType, Input, OutputType}; use rustc::ty::{self, TyCtxt}; +use rustc::{bug, span_bug}; use rustc_typeck::hir_ty_to_ty; use rustc_codegen_utils::link::{filename_for_metadata, out_filename}; use rustc_data_structures::sync::Lrc; @@ -66,6 +50,8 @@ use rls_data::{Def, DefKind, ExternalCrateData, GlobalCrateId, MacroRef, Ref, Re RelationKind, SpanData, Impl, ImplKind}; use rls_data::config::Config; +use log::{debug, error, info}; + pub struct SaveContext<'l, 'tcx: 'l> { tcx: TyCtxt<'l, 'tcx, 'tcx>, @@ -172,7 +158,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { ast::ForeignItemKind::Static(ref ty, _) => { filter!(self.span_utils, item.ident.span); - let id = ::id_from_node_id(item.id, self); + let id = id_from_node_id(item.id, self); let span = self.span_from_span(item.ident.span); Some(Data::DefData(Def { @@ -1029,7 +1015,7 @@ impl<'a> DumpHandler<'a> { } } - fn output_file(&self, ctx: &SaveContext) -> File { + fn output_file(&self, ctx: &SaveContext<'_, '_>) -> File { let sess = &ctx.tcx.sess; let file_name = match ctx.config.output_file { Some(ref s) => PathBuf::from(s), @@ -1180,7 +1166,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id { } } -fn id_from_node_id(id: NodeId, scx: &SaveContext) -> rls_data::Id { +fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id { let def_id = scx.tcx.hir().opt_local_def_id(id); def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| { // Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId` @@ -1200,7 +1186,7 @@ fn null_id() -> rls_data::Id { } } -fn lower_attributes(attrs: Vec, scx: &SaveContext) -> Vec { +fn lower_attributes(attrs: Vec, scx: &SaveContext<'_, '_>) -> Vec { attrs.into_iter() // Only retain real attributes. Doc comments are lowered separately. .filter(|attr| attr.path != "doc") diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 7d4c0d0f9f56f..fcd6ad07cd88f 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -25,7 +25,7 @@ // // FIXME where clauses need implementing, defs/refs in generics are mostly missing. -use {id_from_def_id, id_from_node_id, SaveContext}; +use crate::{id_from_def_id, id_from_node_id, SaveContext}; use rls_data::{SigElement, Signature}; @@ -34,14 +34,17 @@ use syntax::ast::{self, NodeId}; use syntax::print::pprust; -pub fn item_signature(item: &ast::Item, scx: &SaveContext) -> Option { +pub fn item_signature(item: &ast::Item, scx: &SaveContext<'_, '_>) -> Option { if !scx.config.signatures { return None; } item.make(0, None, scx).ok() } -pub fn foreign_item_signature(item: &ast::ForeignItem, scx: &SaveContext) -> Option { +pub fn foreign_item_signature( + item: &ast::ForeignItem, + scx: &SaveContext<'_, '_> +) -> Option { if !scx.config.signatures { return None; } @@ -50,7 +53,7 @@ pub fn foreign_item_signature(item: &ast::ForeignItem, scx: &SaveContext) -> Opt /// Signature for a struct or tuple field declaration. /// Does not include a trailing comma. -pub fn field_signature(field: &ast::StructField, scx: &SaveContext) -> Option { +pub fn field_signature(field: &ast::StructField, scx: &SaveContext<'_, '_>) -> Option { if !scx.config.signatures { return None; } @@ -58,7 +61,7 @@ pub fn field_signature(field: &ast::StructField, scx: &SaveContext) -> Option Option { +pub fn variant_signature(variant: &ast::Variant, scx: &SaveContext<'_, '_>) -> Option { if !scx.config.signatures { return None; } @@ -70,7 +73,7 @@ pub fn method_signature( ident: ast::Ident, generics: &ast::Generics, m: &ast::MethodSig, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Option { if !scx.config.signatures { return None; @@ -83,7 +86,7 @@ pub fn assoc_const_signature( ident: ast::Name, ty: &ast::Ty, default: Option<&ast::Expr>, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Option { if !scx.config.signatures { return None; @@ -96,7 +99,7 @@ pub fn assoc_type_signature( ident: ast::Ident, bounds: Option<&ast::GenericBounds>, default: Option<&ast::Ty>, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Option { if !scx.config.signatures { return None; @@ -104,10 +107,10 @@ pub fn assoc_type_signature( make_assoc_type_signature(id, ident, bounds, default, scx).ok() } -type Result = ::std::result::Result; +type Result = std::result::Result; trait Sig { - fn make(&self, offset: usize, id: Option, scx: &SaveContext) -> Result; + fn make(&self, offset: usize, id: Option, scx: &SaveContext<'_, '_>) -> Result; } fn extend_sig( @@ -155,7 +158,7 @@ fn text_sig(text: String) -> Signature { } impl Sig for ast::Ty { - fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); match self.node { ast::TyKind::Slice(ref ty) => { @@ -227,7 +230,7 @@ impl Sig for ast::Ty { if f.unsafety == ast::Unsafety::Unsafe { text.push_str("unsafe "); } - if f.abi != ::rustc_target::spec::abi::Abi::Rust { + if f.abi != rustc_target::spec::abi::Abi::Rust { text.push_str("extern"); text.push_str(&f.abi.to_string()); text.push(' '); @@ -317,7 +320,7 @@ impl Sig for ast::Ty { } impl Sig for ast::Item { - fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); match self.node { @@ -381,7 +384,7 @@ impl Sig for ast::Item { if header.unsafety == ast::Unsafety::Unsafe { text.push_str("unsafe "); } - if header.abi != ::rustc_target::spec::abi::Abi::Rust { + if header.abi != rustc_target::spec::abi::Abi::Rust { text.push_str("extern"); text.push_str(&header.abi.to_string()); text.push(' '); @@ -571,7 +574,7 @@ impl Sig for ast::Item { } impl Sig for ast::Path { - fn make(&self, offset: usize, id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, id: Option, scx: &SaveContext<'_, '_>) -> Result { let def = scx.get_path_def(id.ok_or("Missing id for Path")?); let (name, start, end) = match def { @@ -613,7 +616,7 @@ impl Sig for ast::Path { // This does not cover the where clause, which must be processed separately. impl Sig for ast::Generics { - fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { if self.params.is_empty() { return Ok(text_sig(String::new())); } @@ -662,7 +665,7 @@ impl Sig for ast::Generics { } impl Sig for ast::StructField { - fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let mut text = String::new(); let mut defs = None; if let Some(ident) = self.ident { @@ -685,7 +688,7 @@ impl Sig for ast::StructField { impl Sig for ast::Variant_ { - fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let mut text = self.ident.to_string(); match self.data { ast::VariantData::Struct(ref fields, id) => { @@ -743,7 +746,7 @@ impl Sig for ast::Variant_ { } impl Sig for ast::ForeignItem { - fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext) -> Result { + fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); match self.node { ast::ForeignItemKind::Fn(ref decl, ref generics) => { @@ -827,7 +830,7 @@ fn name_and_generics( generics: &ast::Generics, id: NodeId, name: ast::Ident, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Result { let name = name.to_string(); let def = SigElement { @@ -848,7 +851,7 @@ fn make_assoc_type_signature( ident: ast::Ident, bounds: Option<&ast::GenericBounds>, default: Option<&ast::Ty>, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Result { let mut text = "type ".to_owned(); let name = ident.to_string(); @@ -882,7 +885,7 @@ fn make_assoc_const_signature( ident: ast::Name, ty: &ast::Ty, default: Option<&ast::Expr>, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Result { let mut text = "const ".to_owned(); let name = ident.to_string(); @@ -915,7 +918,7 @@ fn make_method_signature( ident: ast::Ident, generics: &ast::Generics, m: &ast::MethodSig, - scx: &SaveContext, + scx: &SaveContext<'_, '_>, ) -> Result { // FIXME code dup with function signature let mut text = String::new(); @@ -928,7 +931,7 @@ fn make_method_signature( if m.header.unsafety == ast::Unsafety::Unsafe { text.push_str("unsafe "); } - if m.header.abi != ::rustc_target::spec::abi::Abi::Rust { + if m.header.abi != rustc_target::spec::abi::Abi::Rust { text.push_str("extern"); text.push_str(&m.header.abi.to_string()); text.push(' '); diff --git a/src/librustc_save_analysis/span_utils.rs b/src/librustc_save_analysis/span_utils.rs index 88c6012f71f69..e2c93b6d33158 100644 --- a/src/librustc_save_analysis/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -1,6 +1,6 @@ use rustc::session::Session; -use generated_code; +use crate::generated_code; use std::cell::Cell; From f03704b2818b02891353cb4290a4786c7e82158a Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Thu, 7 Feb 2019 10:17:48 +0900 Subject: [PATCH 06/21] Transition librustc_traits to 2018 edition --- src/librustc_traits/Cargo.toml | 1 + src/librustc_traits/chalk_context/mod.rs | 6 +++--- src/librustc_traits/chalk_context/program_clauses.rs | 6 +++--- src/librustc_traits/dropck_outlives.rs | 4 ++-- src/librustc_traits/evaluate_obligation.rs | 2 +- src/librustc_traits/implied_outlives_bounds.rs | 2 +- src/librustc_traits/lib.rs | 10 +++------- src/librustc_traits/lowering/mod.rs | 6 +++--- src/librustc_traits/normalize_erasing_regions.rs | 2 +- src/librustc_traits/normalize_projection_ty.rs | 2 +- src/librustc_traits/type_op.rs | 2 +- 11 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/librustc_traits/Cargo.toml b/src/librustc_traits/Cargo.toml index bf946d39806ec..da19cc95eb95a 100644 --- a/src/librustc_traits/Cargo.toml +++ b/src/librustc_traits/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_traits" version = "0.0.0" +edition = "2018" [lib] name = "rustc_traits" diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index 303920b5842c9..ffa696c908039 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -502,13 +502,13 @@ type ChalkHhGoal<'tcx> = HhGoal>; type ChalkExClause<'tcx> = ExClause>; impl Debug for ChalkContext<'cx, 'gcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ChalkContext") } } impl Debug for ChalkInferenceContext<'cx, 'gcx, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ChalkInferenceContext") } } @@ -658,7 +658,7 @@ impl<'tcx, 'gcx: 'tcx, T> Upcast<'tcx, 'gcx> for Canonical<'gcx, T> } } -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { evaluate_goal, ..*p diff --git a/src/librustc_traits/chalk_context/program_clauses.rs b/src/librustc_traits/chalk_context/program_clauses.rs index 71f4945fd648d..adfd26814db1e 100644 --- a/src/librustc_traits/chalk_context/program_clauses.rs +++ b/src/librustc_traits/chalk_context/program_clauses.rs @@ -220,7 +220,7 @@ fn wf_clause_for_slice<'tcx>(tcx: ty::TyCtxt<'_, '_, 'tcx>) -> Clauses<'tcx> { def_id: sized_trait, substs: tcx.mk_substs_trait(ty, ty::List::empty()), }; - let sized_implemented: DomainGoal = ty::TraitPredicate { + let sized_implemented: DomainGoal<'_> = ty::TraitPredicate { trait_ref: sized_implemented }.lower(); @@ -252,7 +252,7 @@ fn wf_clause_for_array<'tcx>( def_id: sized_trait, substs: tcx.mk_substs_trait(ty, ty::List::empty()), }; - let sized_implemented: DomainGoal = ty::TraitPredicate { + let sized_implemented: DomainGoal<'_> = ty::TraitPredicate { trait_ref: sized_implemented }.lower(); @@ -326,7 +326,7 @@ fn wf_clause_for_ref<'tcx>( mutbl, }); - let _outlives: DomainGoal = ty::OutlivesPredicate(ty, region).lower(); + let _outlives: DomainGoal<'_> = ty::OutlivesPredicate(ty, region).lower(); let wf_clause = ProgramClause { goal: DomainGoal::WellFormed(WellFormed::Ty(ref_ty)), hypotheses: ty::List::empty(), diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 7979fe4a75073..45b19e1dc06af 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -10,7 +10,7 @@ use rustc::util::nodemap::FxHashSet; use rustc_data_structures::sync::Lrc; use syntax::source_map::{Span, DUMMY_SP}; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { dropck_outlives, adt_dtorck_constraint, @@ -305,7 +305,7 @@ crate fn adt_dtorck_constraint<'a, 'tcx>( let mut result = def.all_fields() .map(|field| tcx.type_of(field.did)) .map(|fty| dtorck_constraint_for_ty(tcx, span, fty, 0, fty)) - .collect::>()?; + .collect::, NoSolution>>()?; result.outlives.extend(tcx.destructor_constraints(def)); dedup_dtorck_constraint(&mut result); diff --git a/src/librustc_traits/evaluate_obligation.rs b/src/librustc_traits/evaluate_obligation.rs index c5b6de2793552..83aebd16e2400 100644 --- a/src/librustc_traits/evaluate_obligation.rs +++ b/src/librustc_traits/evaluate_obligation.rs @@ -6,7 +6,7 @@ use rustc::ty::query::Providers; use rustc::ty::{ParamEnvAnd, TyCtxt}; use syntax::source_map::DUMMY_SP; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { evaluate_obligation, ..*p diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs index a3fb96990545e..e4a032aaf7b18 100644 --- a/src/librustc_traits/implied_outlives_bounds.rs +++ b/src/librustc_traits/implied_outlives_bounds.rs @@ -17,7 +17,7 @@ use rustc::traits::FulfillmentContext; use rustc_data_structures::sync::Lrc; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { implied_outlives_bounds, ..*p diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index a220b92191369..d52a976981db0 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -1,22 +1,18 @@ //! New recursive solver modeled on Chalk's recursive solver. Most of //! the guts are broken up into modules; see the comments in those modules. +#![deny(rust_2018_idioms)] + #![feature(crate_visibility_modifier)] #![feature(in_band_lifetimes)] #![feature(nll)] #![recursion_limit="256"] -extern crate chalk_engine; #[macro_use] extern crate log; #[macro_use] extern crate rustc; -extern crate rustc_data_structures; -extern crate rustc_target; -extern crate syntax; -extern crate syntax_pos; -extern crate smallvec; mod chalk_context; mod dropck_outlives; @@ -30,7 +26,7 @@ mod type_op; use rustc::ty::query::Providers; -pub fn provide(p: &mut Providers) { +pub fn provide(p: &mut Providers<'_>) { dropck_outlives::provide(p); evaluate_obligation::provide(p); implied_outlives_bounds::provide(p); diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 9bdef3051e589..908fdcfe7430f 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -23,7 +23,7 @@ use syntax::ast; use std::iter; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { program_clauses_for, program_clauses_for_env: environment::program_clauses_for_env, @@ -193,7 +193,7 @@ fn program_clauses_for_trait<'a, 'tcx>( }; // `Implemented(Self: Trait)` - let impl_trait: DomainGoal = trait_pred.lower(); + let impl_trait: DomainGoal<'_> = trait_pred.lower(); // `FromEnv(Self: Trait)` let from_env_goal = tcx.mk_goal(impl_trait.into_from_env_goal().into_goal()); @@ -575,7 +575,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>( let ty = tcx.type_of(item_id); // `Implemented(A0: Trait)` - let trait_implemented: DomainGoal = ty::TraitPredicate { trait_ref }.lower(); + let trait_implemented: DomainGoal<'_> = ty::TraitPredicate { trait_ref }.lower(); // `>::AssocType` let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident); diff --git a/src/librustc_traits/normalize_erasing_regions.rs b/src/librustc_traits/normalize_erasing_regions.rs index c06cdbd0928da..412d2ca6dfcff 100644 --- a/src/librustc_traits/normalize_erasing_regions.rs +++ b/src/librustc_traits/normalize_erasing_regions.rs @@ -4,7 +4,7 @@ use rustc::ty::query::Providers; use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt}; use std::sync::atomic::Ordering; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { normalize_ty_after_erasing_regions, ..*p diff --git a/src/librustc_traits/normalize_projection_ty.rs b/src/librustc_traits/normalize_projection_ty.rs index b31e9c15d0367..6fe9e316cf36e 100644 --- a/src/librustc_traits/normalize_projection_ty.rs +++ b/src/librustc_traits/normalize_projection_ty.rs @@ -8,7 +8,7 @@ use std::sync::atomic::Ordering; use syntax::ast::DUMMY_NODE_ID; use syntax_pos::DUMMY_SP; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { normalize_projection_ty, ..*p diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index 526637e108d40..3cc2f77187ac7 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -21,7 +21,7 @@ use std::fmt; use syntax::ast; use syntax_pos::DUMMY_SP; -crate fn provide(p: &mut Providers) { +crate fn provide(p: &mut Providers<'_>) { *p = Providers { type_op_ascribe_user_type, type_op_eq, From 81613ad7cf9889a59d0a7233af9e462715945a72 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 7 Feb 2019 18:23:44 +0100 Subject: [PATCH 07/21] disable tests in Miri --- src/liballoc/tests/arc.rs | 2 ++ src/liballoc/tests/binary_heap.rs | 1 + src/liballoc/tests/btree/mod.rs | 2 ++ src/liballoc/tests/heap.rs | 2 ++ src/liballoc/tests/rc.rs | 2 ++ src/liballoc/tests/slice.rs | 2 ++ src/liballoc/tests/str.rs | 21 +++++++++++++++++++++ src/liballoc/tests/string.rs | 2 ++ src/liballoc/tests/vec.rs | 2 ++ src/liballoc/tests/vec_deque.rs | 7 +++++++ src/libcore/tests/cell.rs | 2 ++ src/libcore/tests/fmt/mod.rs | 2 ++ src/libcore/tests/hash/mod.rs | 2 ++ src/libcore/tests/iter.rs | 8 ++++++++ src/libcore/tests/num/mod.rs | 2 ++ src/libcore/tests/option.rs | 3 +++ src/libcore/tests/ptr.rs | 2 ++ src/libcore/tests/result.rs | 3 +++ src/libcore/tests/slice.rs | 12 ++++++++++++ src/libcore/tests/time.rs | 2 ++ 20 files changed, 81 insertions(+) diff --git a/src/liballoc/tests/arc.rs b/src/liballoc/tests/arc.rs index 2759b1b1cac27..7c5a8926126e3 100644 --- a/src/liballoc/tests/arc.rs +++ b/src/liballoc/tests/arc.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use std::any::Any; use std::sync::{Arc, Weak}; use std::cell::RefCell; diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index 94ae43237d19c..c1a1c5d88781f 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -282,6 +282,7 @@ fn assert_covariance() { // // Destructors must be called exactly once per element. #[test] +#[cfg(not(miri))] fn panic_safe() { static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); diff --git a/src/liballoc/tests/btree/mod.rs b/src/liballoc/tests/btree/mod.rs index 4c704d0f8c28f..653b3f5bcb49d 100644 --- a/src/liballoc/tests/btree/mod.rs +++ b/src/liballoc/tests/btree/mod.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + mod map; mod set; diff --git a/src/liballoc/tests/heap.rs b/src/liballoc/tests/heap.rs index 24eea1d294965..809d2bc094aee 100644 --- a/src/liballoc/tests/heap.rs +++ b/src/liballoc/tests/heap.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use std::alloc::{Global, Alloc, Layout, System}; /// https://github.com/rust-lang/rust/issues/45955 diff --git a/src/liballoc/tests/rc.rs b/src/liballoc/tests/rc.rs index 18f82e8041008..1be01d1a7ce1a 100644 --- a/src/liballoc/tests/rc.rs +++ b/src/liballoc/tests/rc.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use std::any::Any; use std::rc::{Rc, Weak}; use std::cell::RefCell; diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 0300bd7f3f6d4..6d4a30fc36c7a 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use std::cell::Cell; use std::cmp::Ordering::{Equal, Greater, Less}; use std::cmp::Ordering; diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 66a1b947a7d3a..b63945ffe972f 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -31,6 +31,7 @@ fn test_rfind() { } #[test] +#[cfg(not(miri))] fn test_collect() { let empty = ""; let s: String = empty.chars().collect(); @@ -118,6 +119,7 @@ fn test_concat_for_different_types() { #[test] fn test_concat_for_different_lengths() { let empty: &[&str] = &[]; + #[cfg(not(miri))] test_concat!("", empty); test_concat!("a", ["a"]); test_concat!("ab", ["a", "b"]); @@ -146,6 +148,7 @@ fn test_join_for_different_types() { #[test] fn test_join_for_different_lengths() { let empty: &[&str] = &[]; + #[cfg(not(miri))] test_join!("", empty, "-"); test_join!("a", ["a"], "-"); test_join!("a-b", ["a", "b"], "-"); @@ -159,6 +162,7 @@ fn test_join_for_different_lengths_with_long_separator() { assert_eq!("~~~~~".len(), 15); let empty: &[&str] = &[]; + #[cfg(not(miri))] test_join!("", empty, "~~~~~"); test_join!("a", ["a"], "~~~~~"); test_join!("a~~~~~b", ["a", "b"], "~~~~~"); @@ -166,6 +170,7 @@ fn test_join_for_different_lengths_with_long_separator() { } #[test] +#[cfg(not(miri))] fn test_unsafe_slice() { assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)}); assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)}); @@ -238,6 +243,7 @@ fn test_replacen() { #[test] fn test_replace() { let a = "a"; + #[cfg(not(miri))] assert_eq!("".replace(a, "b"), ""); assert_eq!("a".replace(a, "b"), "b"); assert_eq!("ab".replace(a, "b"), "bb"); @@ -297,6 +303,7 @@ fn test_replace_pattern() { // The current implementation of SliceIndex fails to handle methods // orthogonally from range types; therefore, it is worth testing // all of the indexing operations on each input. +#[cfg(not(miri))] mod slice_index { // Test a slicing operation **that should succeed,** // testing it on all of the indexing methods. @@ -679,6 +686,7 @@ fn test_str_slice_rangetoinclusive_ok() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_str_slice_rangetoinclusive_notok() { let s = "abcαβγ"; &s[..=3]; @@ -694,6 +702,7 @@ fn test_str_slicemut_rangetoinclusive_ok() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_str_slicemut_rangetoinclusive_notok() { let mut s = "abcαβγ".to_owned(); let s: &mut str = &mut s; @@ -883,6 +892,7 @@ fn test_as_bytes() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_as_bytes_fail() { // Don't double free. (I'm not sure if this exercises the // original problem code path anymore.) @@ -972,6 +982,7 @@ fn test_split_at_mut() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_split_at_boundscheck() { let s = "ศไทย中华Việt Nam"; s.split_at(1); @@ -1066,6 +1077,7 @@ fn test_rev_iterator() { } #[test] +#[cfg(not(miri))] fn test_chars_decoding() { let mut bytes = [0; 4]; for c in (0..0x110000).filter_map(::std::char::from_u32) { @@ -1077,6 +1089,7 @@ fn test_chars_decoding() { } #[test] +#[cfg(not(miri))] fn test_chars_rev_decoding() { let mut bytes = [0; 4]; for c in (0..0x110000).filter_map(::std::char::from_u32) { @@ -1306,6 +1319,7 @@ fn test_splitator() { } #[test] +#[cfg(not(miri))] fn test_str_default() { use std::default::Default; @@ -1365,6 +1379,7 @@ fn test_bool_from_str() { assert_eq!("not even a boolean".parse::().ok(), None); } +#[cfg(not(miri))] fn check_contains_all_substrings(s: &str) { assert!(s.contains("")); for i in 0..s.len() { @@ -1375,6 +1390,7 @@ fn check_contains_all_substrings(s: &str) { } #[test] +#[cfg(not(miri))] fn strslice_issue_16589() { assert!("bananas".contains("nana")); @@ -1384,6 +1400,7 @@ fn strslice_issue_16589() { } #[test] +#[cfg(not(miri))] fn strslice_issue_16878() { assert!(!"1234567ah012345678901ah".contains("hah")); assert!(!"00abc01234567890123456789abc".contains("bcabc")); @@ -1391,6 +1408,7 @@ fn strslice_issue_16878() { #[test] +#[cfg(not(miri))] fn test_strslice_contains() { let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'"; check_contains_all_substrings(x); @@ -1528,6 +1546,7 @@ fn trim_ws() { #[test] fn to_lowercase() { + #[cfg(not(miri))] assert_eq!("".to_lowercase(), ""); assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé "); @@ -1561,6 +1580,7 @@ fn to_lowercase() { #[test] fn to_uppercase() { + #[cfg(not(miri))] assert_eq!("".to_uppercase(), ""); assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ"); } @@ -1592,6 +1612,7 @@ fn test_cow_from() { } #[test] +#[cfg(not(miri))] fn test_repeat() { assert_eq!("".repeat(3), ""); assert_eq!("abc".repeat(0), ""); diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 8a5bfca8b7db5..7a03848a776e6 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use std::borrow::Cow; use std::collections::CollectionAllocErr::*; use std::mem::size_of; diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 0fdcf34c783a8..b214051e4883f 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use std::borrow::Cow; use std::mem::size_of; use std::{usize, isize}; diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index c9d16a06b4773..43b7351ef3299 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -107,6 +107,7 @@ fn test_index() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_index_out_of_bounds() { let mut deq = VecDeque::new(); for i in 1..4 { @@ -905,20 +906,24 @@ fn test_append() { // normal append a.append(&mut b); assert_eq!(a.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); + #[cfg(not(miri))] assert_eq!(b.iter().cloned().collect::>(), []); // append nothing to something a.append(&mut b); assert_eq!(a.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); + #[cfg(not(miri))] assert_eq!(b.iter().cloned().collect::>(), []); // append something to nothing b.append(&mut a); assert_eq!(b.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); + #[cfg(not(miri))] assert_eq!(a.iter().cloned().collect::>(), []); } #[test] +#[cfg(not(miri))] fn test_append_permutations() { fn construct_vec_deque( push_back: usize, @@ -1119,6 +1124,7 @@ fn test_reserve_exact_2() { } #[test] +#[cfg(not(miri))] fn test_try_reserve() { // These are the interesting cases: @@ -1220,6 +1226,7 @@ fn test_try_reserve() { } #[test] +#[cfg(not(miri))] fn test_try_reserve_exact() { // This is exactly the same as test_try_reserve with the method changed. diff --git a/src/libcore/tests/cell.rs b/src/libcore/tests/cell.rs index 56f295dff8e43..73bdaab5861e6 100644 --- a/src/libcore/tests/cell.rs +++ b/src/libcore/tests/cell.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use core::cell::*; use core::default::Default; use std::mem::drop; diff --git a/src/libcore/tests/fmt/mod.rs b/src/libcore/tests/fmt/mod.rs index d86e21cf40b6e..b10b63fc484cb 100644 --- a/src/libcore/tests/fmt/mod.rs +++ b/src/libcore/tests/fmt/mod.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + mod builders; mod float; mod num; diff --git a/src/libcore/tests/hash/mod.rs b/src/libcore/tests/hash/mod.rs index 135f4dfcac7d5..bf3039a7e51e8 100644 --- a/src/libcore/tests/hash/mod.rs +++ b/src/libcore/tests/hash/mod.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + mod sip; use std::hash::{Hash, Hasher}; diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 0fa99745d9065..9b4c78f8d3b02 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -190,6 +190,7 @@ fn test_iterator_step_by() { } #[test] +#[cfg(not(miri))] fn test_iterator_step_by_nth() { let mut it = (0..16).step_by(5); assert_eq!(it.nth(0), Some(0)); @@ -208,6 +209,7 @@ fn test_iterator_step_by_nth() { } #[test] +#[cfg(not(miri))] fn test_iterator_step_by_nth_overflow() { #[cfg(target_pointer_width = "8")] type Bigger = u16; @@ -253,12 +255,14 @@ fn test_iterator_step_by_nth_overflow() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_iterator_step_by_zero() { let mut it = (0..).step_by(0); it.next(); } #[test] +#[cfg(not(miri))] fn test_iterator_step_by_size_hint() { struct StubSizeHint(usize, Option); impl Iterator for StubSizeHint { @@ -1413,6 +1417,7 @@ fn test_rposition() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_rposition_panic() { let v: [(Box<_>, Box<_>); 4] = [(box 0, box 0), (box 0, box 0), @@ -1652,6 +1657,7 @@ fn test_range_inclusive_nth() { } #[test] +#[cfg(not(miri))] fn test_range_step() { #![allow(deprecated)] @@ -1675,6 +1681,7 @@ fn test_range_step() { } #[test] +#[cfg(not(miri))] fn test_step_by_skip() { assert_eq!((0..640).step_by(128).skip(1).collect::>(), [128, 256, 384, 512]); assert_eq!((0..=50).step_by(10).nth(3), Some(30)); @@ -1682,6 +1689,7 @@ fn test_step_by_skip() { } #[test] +#[cfg(not(miri))] fn test_range_inclusive_step() { assert_eq!((0..=50).step_by(10).collect::>(), [0, 10, 20, 30, 40, 50]); assert_eq!((0..=5).step_by(1).collect::>(), [0, 1, 2, 3, 4, 5]); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index a17c094679ea8..ab638e06cc10d 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use core::convert::{TryFrom, TryInto}; use core::cmp::PartialEq; use core::fmt::Debug; diff --git a/src/libcore/tests/option.rs b/src/libcore/tests/option.rs index b059b134868d9..1ba886ce037ee 100644 --- a/src/libcore/tests/option.rs +++ b/src/libcore/tests/option.rs @@ -69,6 +69,7 @@ fn test_option_dance() { } #[test] #[should_panic] +#[cfg(not(miri))] fn test_option_too_much_dance() { struct A; let mut y = Some(A); @@ -129,6 +130,7 @@ fn test_unwrap() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_unwrap_panic1() { let x: Option = None; x.unwrap(); @@ -136,6 +138,7 @@ fn test_unwrap_panic1() { #[test] #[should_panic] +#[cfg(not(miri))] fn test_unwrap_panic2() { let x: Option = None; x.unwrap(); diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs index 65c1a3e0254d2..5784559082266 100644 --- a/src/libcore/tests/ptr.rs +++ b/src/libcore/tests/ptr.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use core::ptr::*; use core::cell::RefCell; diff --git a/src/libcore/tests/result.rs b/src/libcore/tests/result.rs index 1fab07526a07f..7bfd396f68d17 100644 --- a/src/libcore/tests/result.rs +++ b/src/libcore/tests/result.rs @@ -117,6 +117,7 @@ fn test_unwrap_or_else() { #[test] #[should_panic] +#[cfg(not(miri))] pub fn test_unwrap_or_else_panic() { fn handler(msg: &'static str) -> isize { if msg == "I got this." { @@ -138,6 +139,7 @@ pub fn test_expect_ok() { } #[test] #[should_panic(expected="Got expected error: \"All good\"")] +#[cfg(not(miri))] pub fn test_expect_err() { let err: Result = Err("All good"); err.expect("Got expected error"); @@ -151,6 +153,7 @@ pub fn test_expect_err_err() { } #[test] #[should_panic(expected="Got expected ok: \"All good\"")] +#[cfg(not(miri))] pub fn test_expect_err_ok() { let err: Result<&'static str, isize> = Ok("All good"); err.expect_err("Got expected ok"); diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index e210e83122c47..04d646ea01d03 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -782,6 +782,7 @@ mod slice_index { // to be used in `should_panic`) #[test] #[should_panic(expected = "out of range")] + #[cfg(not(miri))] fn assert_range_eq_can_fail_by_panic() { assert_range_eq!([0, 1, 2], 0..5, [0, 1, 2]); } @@ -791,6 +792,7 @@ mod slice_index { // to be used in `should_panic`) #[test] #[should_panic(expected = "==")] + #[cfg(not(miri))] fn assert_range_eq_can_fail_by_inequality() { assert_range_eq!([0, 1, 2], 0..2, [0, 1, 2]); } @@ -840,6 +842,7 @@ mod slice_index { #[test] #[should_panic(expected = $expect_msg)] + #[cfg(not(miri))] fn index_fail() { let v = $data; let v: &[_] = &v; @@ -848,6 +851,7 @@ mod slice_index { #[test] #[should_panic(expected = $expect_msg)] + #[cfg(not(miri))] fn index_mut_fail() { let mut v = $data; let v: &mut [_] = &mut v; @@ -1011,6 +1015,7 @@ fn test_rotate_right() { #[test] #[cfg(not(target_arch = "wasm32"))] +#[cfg(not(miri))] fn sort_unstable() { use core::cmp::Ordering::{Equal, Greater, Less}; use core::slice::heapsort; @@ -1166,6 +1171,7 @@ pub mod memchr { } #[test] +#[cfg(not(miri))] fn test_align_to_simple() { let bytes = [1u8, 2, 3, 4, 5, 6, 7]; let (prefix, aligned, suffix) = unsafe { bytes.align_to::() }; @@ -1181,6 +1187,7 @@ fn test_align_to_simple() { } #[test] +#[cfg(not(miri))] fn test_align_to_zst() { let bytes = [1, 2, 3, 4, 5, 6, 7]; let (prefix, aligned, suffix) = unsafe { bytes.align_to::<()>() }; @@ -1189,6 +1196,7 @@ fn test_align_to_zst() { } #[test] +#[cfg(not(miri))] fn test_align_to_non_trivial() { #[repr(align(8))] struct U64(u64, u64); #[repr(align(8))] struct U64U64U32(u64, u64, u32); @@ -1200,6 +1208,7 @@ fn test_align_to_non_trivial() { } #[test] +#[cfg(not(miri))] fn test_align_to_empty_mid() { use core::mem; @@ -1297,6 +1306,7 @@ fn test_copy_within() { #[test] #[should_panic(expected = "src is out of bounds")] +#[cfg(not(miri))] fn test_copy_within_panics_src_too_long() { let mut bytes = *b"Hello, World!"; // The length is only 13, so 14 is out of bounds. @@ -1305,6 +1315,7 @@ fn test_copy_within_panics_src_too_long() { #[test] #[should_panic(expected = "dest is out of bounds")] +#[cfg(not(miri))] fn test_copy_within_panics_dest_too_long() { let mut bytes = *b"Hello, World!"; // The length is only 13, so a slice of length 4 starting at index 10 is out of bounds. @@ -1312,6 +1323,7 @@ fn test_copy_within_panics_dest_too_long() { } #[test] #[should_panic(expected = "src end is before src start")] +#[cfg(not(miri))] fn test_copy_within_panics_src_inverted() { let mut bytes = *b"Hello, World!"; // 2 is greater than 1, so this range is invalid. diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs index 6efd22572dc18..d39bd06930a36 100644 --- a/src/libcore/tests/time.rs +++ b/src/libcore/tests/time.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] + use core::time::Duration; #[test] From 725af308093818dc4386a06457eb1e452c7afee1 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 06:28:15 +0900 Subject: [PATCH 08/21] librustc_mir => 2018 --- src/librustc_mir/Cargo.toml | 3 +- src/librustc_mir/borrow_check/borrow_set.rs | 10 ++--- .../borrow_check/error_reporting.rs | 38 ++++++++++------- src/librustc_mir/borrow_check/flows.rs | 18 ++++---- src/librustc_mir/borrow_check/mod.rs | 26 ++++++------ src/librustc_mir/borrow_check/move_errors.rs | 12 +++--- .../borrow_check/mutability_errors.rs | 12 +++--- .../borrow_check/nll/constraint_generation.rs | 10 ++--- .../borrow_check/nll/constraints/graph.rs | 6 +-- .../borrow_check/nll/constraints/mod.rs | 4 +- .../nll/explain_borrow/find_use.rs | 6 +-- .../borrow_check/nll/explain_borrow/mod.rs | 20 ++++----- src/librustc_mir/borrow_check/nll/facts.rs | 4 +- .../borrow_check/nll/invalidation.rs | 24 +++++------ src/librustc_mir/borrow_check/nll/mod.rs | 38 ++++++++--------- .../nll/region_infer/error_reporting/mod.rs | 12 +++--- .../error_reporting/region_name.rs | 8 ++-- .../region_infer/error_reporting/var_name.rs | 4 +- .../borrow_check/nll/region_infer/graphviz.rs | 3 +- .../borrow_check/nll/region_infer/mod.rs | 12 +++--- .../nll/type_check/constraint_conversion.rs | 10 ++--- .../nll/type_check/free_region_relations.rs | 8 ++-- .../nll/type_check/input_output.rs | 2 +- .../nll/type_check/liveness/liveness_map.rs | 6 +-- .../nll/type_check/liveness/local_use_map.rs | 6 +-- .../nll/type_check/liveness/mod.rs | 16 +++---- .../nll/type_check/liveness/trace.rs | 20 ++++----- .../borrow_check/nll/type_check/mod.rs | 42 +++++++++---------- .../borrow_check/nll/type_check/relate_tys.rs | 4 +- src/librustc_mir/borrow_check/path_utils.rs | 10 ++--- src/librustc_mir/borrow_check/place_ext.rs | 2 +- .../borrow_check/places_conflict.rs | 6 +-- src/librustc_mir/borrow_check/used_muts.rs | 2 +- src/librustc_mir/build/block.rs | 8 ++-- src/librustc_mir/build/cfg.rs | 2 +- src/librustc_mir/build/expr/as_constant.rs | 4 +- src/librustc_mir/build/expr/as_operand.rs | 6 +-- src/librustc_mir/build/expr/as_place.rs | 8 ++-- src/librustc_mir/build/expr/as_rvalue.rs | 6 +-- src/librustc_mir/build/expr/as_temp.rs | 4 +- src/librustc_mir/build/expr/category.rs | 2 +- src/librustc_mir/build/expr/into.rs | 6 +-- src/librustc_mir/build/expr/stmt.rs | 6 +-- src/librustc_mir/build/into.rs | 6 +-- src/librustc_mir/build/matches/mod.rs | 10 ++--- src/librustc_mir/build/matches/simplify.rs | 6 +-- src/librustc_mir/build/matches/test.rs | 8 ++-- src/librustc_mir/build/matches/util.rs | 6 +-- src/librustc_mir/build/misc.rs | 2 +- src/librustc_mir/build/mod.rs | 18 ++++---- src/librustc_mir/build/scope.rs | 4 +- src/librustc_mir/const_eval.rs | 2 +- src/librustc_mir/dataflow/at_location.rs | 8 ++-- .../dataflow/drop_flag_effects.rs | 2 +- src/librustc_mir/dataflow/graphviz.rs | 22 +++++----- .../dataflow/impls/borrowed_locals.rs | 6 +-- src/librustc_mir/dataflow/impls/borrows.rs | 26 ++++++------ src/librustc_mir/dataflow/impls/mod.rs | 24 +++++------ .../dataflow/impls/storage_liveness.rs | 6 +-- src/librustc_mir/dataflow/mod.rs | 12 +++--- src/librustc_mir/dataflow/move_paths/mod.rs | 19 +++++---- src/librustc_mir/hair/cx/block.rs | 6 +-- src/librustc_mir/hair/cx/expr.rs | 10 ++--- src/librustc_mir/hair/cx/mod.rs | 8 ++-- src/librustc_mir/hair/cx/to_ref.rs | 2 +- src/librustc_mir/hair/pattern/_match.rs | 8 ++-- src/librustc_mir/hair/pattern/check_match.rs | 22 +++++----- src/librustc_mir/hair/pattern/mod.rs | 8 ++-- src/librustc_mir/interpret/eval_context.rs | 2 +- src/librustc_mir/interpret/snapshot.rs | 14 +++---- src/librustc_mir/interpret/terminator.rs | 6 +-- src/librustc_mir/interpret/traits.rs | 2 +- src/librustc_mir/interpret/visitor.rs | 2 +- src/librustc_mir/lib.rs | 20 +++------ src/librustc_mir/lints.rs | 2 +- src/librustc_mir/monomorphize/collector.rs | 4 +- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_mir/monomorphize/partitioning.rs | 22 +++++----- src/librustc_mir/shim.rs | 14 +++---- src/librustc_mir/transform/add_call_guards.rs | 4 +- .../transform/add_moves_for_packed_drops.rs | 6 +-- src/librustc_mir/transform/add_retag.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 10 +++-- .../transform/cleanup_post_borrowck.rs | 2 +- src/librustc_mir/transform/const_prop.rs | 8 ++-- src/librustc_mir/transform/copy_prop.rs | 6 +-- src/librustc_mir/transform/deaggregator.rs | 2 +- src/librustc_mir/transform/dump_mir.rs | 6 +-- src/librustc_mir/transform/elaborate_drops.rs | 24 +++++------ src/librustc_mir/transform/erase_regions.rs | 2 +- src/librustc_mir/transform/generator.rs | 20 ++++----- src/librustc_mir/transform/inline.rs | 6 +-- src/librustc_mir/transform/instcombine.rs | 2 +- src/librustc_mir/transform/lower_128bit.rs | 5 +-- src/librustc_mir/transform/mod.rs | 6 +-- src/librustc_mir/transform/no_landing_pads.rs | 2 +- src/librustc_mir/transform/promote_consts.rs | 3 +- src/librustc_mir/transform/qualify_consts.rs | 8 ++-- .../transform/remove_noop_landing_pads.rs | 8 ++-- src/librustc_mir/transform/rustc_peek.rs | 26 ++++++------ src/librustc_mir/transform/simplify.rs | 6 +-- .../transform/simplify_branches.rs | 2 +- .../transform/uniform_array_move_out.rs | 4 +- src/librustc_mir/util/borrowck_errors.rs | 6 +-- src/librustc_mir/util/def_use.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 2 +- src/librustc_mir/util/graphviz.rs | 11 +++-- src/librustc_mir/util/liveness.rs | 4 +- src/librustc_mir/util/patch.rs | 4 +- src/librustc_mir/util/pretty.rs | 23 ++++++---- 110 files changed, 514 insertions(+), 505 deletions(-) diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index f0234c48c3eca..44a6b41cdfe45 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_mir" version = "0.0.0" +edition = "2018" [lib] name = "rustc_mir" @@ -12,7 +13,7 @@ crate-type = ["dylib"] arena = { path = "../libarena" } bitflags = "1.0" either = "1.5.0" -graphviz = { path = "../libgraphviz" } +dot = { path = "../libgraphviz", package = "graphviz" } log = "0.4" log_settings = "0.1.1" polonius-engine = "0.6.2" diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index ecbc6118bc37c..2788f5d4325a9 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -1,7 +1,7 @@ -use borrow_check::place_ext::PlaceExt; -use borrow_check::nll::ToRegionVid; -use dataflow::indexes::BorrowIndex; -use dataflow::move_paths::MoveData; +use crate::borrow_check::place_ext::PlaceExt; +use crate::borrow_check::nll::ToRegionVid; +use crate::dataflow::indexes::BorrowIndex; +use crate::dataflow::move_paths::MoveData; use rustc::mir::traversal; use rustc::mir::visit::{ PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext @@ -72,7 +72,7 @@ crate struct BorrowData<'tcx> { } impl<'tcx> fmt::Display for BorrowData<'tcx> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { let kind = match self.kind { mir::BorrowKind::Shared => "", mir::BorrowKind::Shallow => "shallow ", diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index b070031756798..afb26963217ff 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -1,7 +1,7 @@ -use borrow_check::nll::explain_borrow::BorrowExplanation; -use borrow_check::nll::region_infer::{RegionName, RegionNameSource}; -use borrow_check::prefixes::IsPrefixOf; -use borrow_check::WriteKind; +use crate::borrow_check::nll::explain_borrow::BorrowExplanation; +use crate::borrow_check::nll::region_infer::{RegionName, RegionNameSource}; +use crate::borrow_check::prefixes::IsPrefixOf; +use crate::borrow_check::WriteKind; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::middle::region::ScopeTree; @@ -22,10 +22,10 @@ use syntax_pos::Span; use super::borrow_set::BorrowData; use super::{Context, MirBorrowckCtxt}; use super::{InitializationRequiringAction, PrefixSet}; -use dataflow::drop_flag_effects; -use dataflow::move_paths::indexes::MoveOutIndex; -use dataflow::move_paths::MovePathIndex; -use util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::dataflow::drop_flag_effects; +use crate::dataflow::move_paths::indexes::MoveOutIndex; +use crate::dataflow::move_paths::MovePathIndex; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; #[derive(Debug)] struct MoveSite { @@ -1726,7 +1726,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } /// End-user visible description of the `field`nth field of `base` - fn describe_field(&self, base: &Place, field: Field) -> String { + fn describe_field(&self, base: &Place<'_>, field: Field) -> String { match *base { Place::Local(local) => { let local = &self.mir.local_decls[local]; @@ -1751,7 +1751,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } /// End-user visible description of the `field_index`nth field of `ty` - fn describe_field_from_ty(&self, ty: &ty::Ty, field: Field) -> String { + fn describe_field_from_ty(&self, ty: &ty::Ty<'_>, field: Field) -> String { if ty.is_box() { // If the type is a box, the field is described from the boxed type self.describe_field_from_ty(&ty.boxed_ty(), field) @@ -1860,7 +1860,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn annotate_argument_and_return_for_borrow( &self, borrow: &BorrowData<'tcx>, - ) -> Option { + ) -> Option> { // Define a fallback for when we can't match a closure. let fallback = || { let is_closure = self.infcx.tcx.is_closure(self.mir_def_id); @@ -2081,7 +2081,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &self, did: DefId, sig: ty::PolyFnSig<'tcx>, - ) -> Option { + ) -> Option> { debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); let is_closure = self.infcx.tcx.is_closure(did); let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?; @@ -2368,14 +2368,22 @@ impl UseSpans { } // Add a span label to the arguments of the closure, if it exists. - pub(super) fn args_span_label(self, err: &mut DiagnosticBuilder, message: impl Into) { + pub(super) fn args_span_label( + self, + err: &mut DiagnosticBuilder<'_>, + message: impl Into, + ) { if let UseSpans::ClosureUse { args_span, .. } = self { err.span_label(args_span, message); } } // Add a span label to the use of the captured variable, if it exists. - pub(super) fn var_span_label(self, err: &mut DiagnosticBuilder, message: impl Into) { + pub(super) fn var_span_label( + self, + err: &mut DiagnosticBuilder<'_>, + message: impl Into, + ) { if let UseSpans::ClosureUse { var_span, .. } = self { err.span_label(var_span, message); } @@ -2563,7 +2571,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// Helper to retrieve span(s) of given borrow from the current MIR /// representation - pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData) -> UseSpans { + pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData<'_>) -> UseSpans { let span = self.mir.source_info(borrow.reserve_location).span; self.borrow_spans(span, borrow.reserve_location) } diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs index 4eeb19c4e7a67..8de39f0efc1a5 100644 --- a/src/librustc_mir/borrow_check/flows.rs +++ b/src/librustc_mir/borrow_check/flows.rs @@ -7,16 +7,16 @@ use rustc::mir::{BasicBlock, Location}; use rustc::ty::RegionVid; use rustc_data_structures::bit_set::BitIter; -use borrow_check::location::LocationIndex; +use crate::borrow_check::location::LocationIndex; use polonius_engine::Output; -use dataflow::move_paths::indexes::BorrowIndex; -use dataflow::move_paths::HasMoveData; -use dataflow::Borrows; -use dataflow::EverInitializedPlaces; -use dataflow::{FlowAtLocation, FlowsAtLocation}; -use dataflow::MaybeUninitializedPlaces; +use crate::dataflow::move_paths::indexes::BorrowIndex; +use crate::dataflow::move_paths::HasMoveData; +use crate::dataflow::Borrows; +use crate::dataflow::EverInitializedPlaces; +use crate::dataflow::{FlowAtLocation, FlowsAtLocation}; +use crate::dataflow::MaybeUninitializedPlaces; use either::Either; use std::fmt; use std::rc::Rc; @@ -57,7 +57,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> { } } - crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter)) { + crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<'_, BorrowIndex>)) { self.borrows.with_iter_outgoing(op) } } @@ -93,7 +93,7 @@ impl<'b, 'gcx, 'tcx> FlowsAtLocation for Flows<'b, 'gcx, 'tcx> { } impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut s = String::new(); s.push_str("borrows in effect: ["); diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 5597e4a6c597e..45a8c9e8e6909 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1,6 +1,6 @@ //! This query borrow-checks the MIR to (further) ensure it is not broken. -use borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; @@ -25,16 +25,16 @@ use std::collections::BTreeMap; use syntax_pos::Span; -use dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex}; -use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError}; -use dataflow::Borrows; -use dataflow::DataflowResultsConsumer; -use dataflow::FlowAtLocation; -use dataflow::MoveDataParamEnv; -use dataflow::{do_dataflow, DebugFormatted}; -use dataflow::EverInitializedPlaces; -use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; -use util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex}; +use crate::dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError}; +use crate::dataflow::Borrows; +use crate::dataflow::DataflowResultsConsumer; +use crate::dataflow::FlowAtLocation; +use crate::dataflow::MoveDataParamEnv; +use crate::dataflow::{do_dataflow, DebugFormatted}; +use crate::dataflow::EverInitializedPlaces; +use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; use self::borrow_set::{BorrowData, BorrowSet}; use self::flows::Flows; @@ -59,7 +59,7 @@ mod used_muts; pub(crate) mod nll; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { mir_borrowck, ..*providers @@ -108,7 +108,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC } let opt_closure_req = tcx.infer_ctxt().enter(|infcx| { - let input_mir: &Mir = &input_mir.borrow(); + let input_mir: &Mir<'_> = &input_mir.borrow(); do_mir_borrowck(&infcx, input_mir, def_id) }); debug!("mir_borrowck done"); diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index 8539b5c26cee8..f7d46925e17df 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -6,13 +6,13 @@ use rustc::ty; use rustc_errors::{DiagnosticBuilder,Applicability}; use syntax_pos::Span; -use borrow_check::MirBorrowckCtxt; -use borrow_check::prefixes::PrefixSet; -use dataflow::move_paths::{ +use crate::borrow_check::MirBorrowckCtxt; +use crate::borrow_check::prefixes::PrefixSet; +use crate::dataflow::move_paths::{ IllegalMoveOrigin, IllegalMoveOriginKind, InitLocation, LookupResult, MoveError, MovePathIndex, }; -use util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; // Often when desugaring a pattern match we may have many individual moves in // MIR that are all part of one operation from the user's point-of-view. For @@ -63,7 +63,7 @@ enum BorrowedContentSource { } impl Display for BorrowedContentSource { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { BorrowedContentSource::Arc => write!(f, "an `Arc`"), BorrowedContentSource::Rc => write!(f, "an `Rc`"), @@ -240,7 +240,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { fn report(&mut self, error: GroupedMoveError<'tcx>) { let (mut err, err_span) = { - let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind) = + let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind<'_>) = match error { GroupedMoveError::MovesFromPlace { span, diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 9d3ce7693ea86..dad8d903cf9fe 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -8,11 +8,11 @@ use rustc_data_structures::indexed_vec::Idx; use syntax_pos::Span; use syntax_pos::symbol::keywords; -use dataflow::move_paths::InitLocation; -use borrow_check::MirBorrowckCtxt; -use util::borrowck_errors::{BorrowckErrors, Origin}; -use util::collect_writes::FindAssignments; -use util::suggest_ref_mut; +use crate::dataflow::move_paths::InitLocation; +use crate::borrow_check::MirBorrowckCtxt; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::util::collect_writes::FindAssignments; +use crate::util::suggest_ref_mut; use rustc_errors::Applicability; #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -611,7 +611,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>( }) } -fn is_closure_or_generator(ty: ty::Ty) -> bool { +fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool { ty.is_closure() || ty.is_generator() } diff --git a/src/librustc_mir/borrow_check/nll/constraint_generation.rs b/src/librustc_mir/borrow_check/nll/constraint_generation.rs index 588f46cb77fe2..c02c2b4934cf4 100644 --- a/src/librustc_mir/borrow_check/nll/constraint_generation.rs +++ b/src/librustc_mir/borrow_check/nll/constraint_generation.rs @@ -1,8 +1,8 @@ -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::LocationTable; -use borrow_check::nll::ToRegionVid; -use borrow_check::nll::facts::AllFacts; -use borrow_check::nll::region_infer::values::LivenessValues; +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::facts::AllFacts; +use crate::borrow_check::nll::region_infer::values::LivenessValues; use rustc::infer::InferCtxt; use rustc::mir::visit::TyContext; use rustc::mir::visit::Visitor; diff --git a/src/librustc_mir/borrow_check/nll/constraints/graph.rs b/src/librustc_mir/borrow_check/nll/constraints/graph.rs index fe9ccb489e425..2479dfd1c7093 100644 --- a/src/librustc_mir/borrow_check/nll/constraints/graph.rs +++ b/src/librustc_mir/borrow_check/nll/constraints/graph.rs @@ -1,6 +1,6 @@ -use borrow_check::nll::type_check::Locations; -use borrow_check::nll::constraints::ConstraintIndex; -use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; +use crate::borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::constraints::ConstraintIndex; +use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; use rustc::mir::ConstraintCategory; use rustc::ty::RegionVid; use rustc_data_structures::graph; diff --git a/src/librustc_mir/borrow_check/nll/constraints/mod.rs b/src/librustc_mir/borrow_check/nll/constraints/mod.rs index 146bd65dd1143..d3f9743dfed77 100644 --- a/src/librustc_mir/borrow_check/nll/constraints/mod.rs +++ b/src/librustc_mir/borrow_check/nll/constraints/mod.rs @@ -2,7 +2,7 @@ use rustc::mir::ConstraintCategory; use rustc::ty::RegionVid; use rustc_data_structures::graph::scc::Sccs; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::type_check::Locations; use std::fmt; use std::ops::Deref; @@ -84,7 +84,7 @@ pub struct OutlivesConstraint { } impl fmt::Debug for OutlivesConstraint { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!( formatter, "({:?}: {:?}) due to {:?}", diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs index 53035dae4f35c..c5aaf5b811ed7 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs @@ -1,13 +1,13 @@ use std::collections::VecDeque; use std::rc::Rc; -use borrow_check::nll::region_infer::{Cause, RegionInferenceContext}; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext}; +use crate::borrow_check::nll::ToRegionVid; +use crate::util::liveness::{self, DefUse}; use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor}; use rustc::mir::{Local, Location, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::fx::FxHashSet; -use util::liveness::{self, DefUse}; crate fn find<'tcx>( mir: &Mir<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs index 968c0f53a4852..8e57d107aa61e 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs @@ -1,8 +1,8 @@ -use borrow_check::borrow_set::BorrowData; -use borrow_check::error_reporting::UseSpans; -use borrow_check::nll::ConstraintDescription; -use borrow_check::nll::region_infer::{Cause, RegionName}; -use borrow_check::{Context, MirBorrowckCtxt, WriteKind}; +use crate::borrow_check::borrow_set::BorrowData; +use crate::borrow_check::error_reporting::UseSpans; +use crate::borrow_check::nll::ConstraintDescription; +use crate::borrow_check::nll::region_infer::{Cause, RegionName}; +use crate::borrow_check::{Context, MirBorrowckCtxt, WriteKind}; use rustc::ty::{self, TyCtxt}; use rustc::mir::{ CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand, @@ -14,7 +14,7 @@ use syntax_pos::Span; mod find_use; -pub(in borrow_check) enum BorrowExplanation { +pub(in crate::borrow_check) enum BorrowExplanation { UsedLater(LaterUseKind, Span), UsedLaterInLoop(LaterUseKind, Span), UsedLaterWhenDropped { @@ -33,7 +33,7 @@ pub(in borrow_check) enum BorrowExplanation { } #[derive(Clone, Copy)] -pub(in borrow_check) enum LaterUseKind { +pub(in crate::borrow_check) enum LaterUseKind { TraitCapture, ClosureCapture, Call, @@ -42,13 +42,13 @@ pub(in borrow_check) enum LaterUseKind { } impl BorrowExplanation { - pub(in borrow_check) fn is_explained(&self) -> bool { + pub(in crate::borrow_check) fn is_explained(&self) -> bool { match self { BorrowExplanation::Unexplained => false, _ => true, } } - pub(in borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>( + pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>( &self, tcx: TyCtxt<'cx, 'gcx, 'tcx>, mir: &Mir<'tcx>, @@ -187,7 +187,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// - second half is the place being accessed /// /// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points - pub(in borrow_check) fn explain_why_borrow_contains_point( + pub(in crate::borrow_check) fn explain_why_borrow_contains_point( &self, context: Context, borrow: &BorrowData<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/facts.rs b/src/librustc_mir/borrow_check/nll/facts.rs index bc33a1c9c65aa..9672d3e78cd50 100644 --- a/src/librustc_mir/borrow_check/nll/facts.rs +++ b/src/librustc_mir/borrow_check/nll/facts.rs @@ -1,5 +1,5 @@ -use borrow_check::location::{LocationIndex, LocationTable}; -use dataflow::indexes::BorrowIndex; +use crate::borrow_check::location::{LocationIndex, LocationTable}; +use crate::dataflow::indexes::BorrowIndex; use polonius_engine::AllFacts as PoloniusAllFacts; use polonius_engine::Atom; use rustc::ty::{RegionVid, TyCtxt}; diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 112b39952559b..3df6b797a44fb 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -1,15 +1,15 @@ -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::LocationTable; -use borrow_check::{JustWrite, WriteAndRead}; -use borrow_check::{AccessDepth, Deep, Shallow}; -use borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write}; -use borrow_check::{Context, ContextKind}; -use borrow_check::{LocalMutationIsAllowed, MutateMode}; -use borrow_check::ArtificialField; -use borrow_check::{ReadKind, WriteKind}; -use borrow_check::nll::facts::AllFacts; -use borrow_check::path_utils::*; -use dataflow::move_paths::indexes::BorrowIndex; +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::{JustWrite, WriteAndRead}; +use crate::borrow_check::{AccessDepth, Deep, Shallow}; +use crate::borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write}; +use crate::borrow_check::{Context, ContextKind}; +use crate::borrow_check::{LocalMutationIsAllowed, MutateMode}; +use crate::borrow_check::ArtificialField; +use crate::borrow_check::{ReadKind, WriteKind}; +use crate::borrow_check::nll::facts::AllFacts; +use crate::borrow_check::path_utils::*; +use crate::dataflow::move_paths::indexes::BorrowIndex; use rustc::ty::TyCtxt; use rustc::mir::visit::Visitor; use rustc::mir::{BasicBlock, Location, Mir, Place, Rvalue}; diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index a092c3b8ecde2..128d54c9f49d7 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -1,13 +1,14 @@ -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::{LocationIndex, LocationTable}; -use borrow_check::nll::facts::AllFactsExt; -use borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints}; -use borrow_check::nll::type_check::liveness::liveness_map::NllLivenessMap; -use borrow_check::nll::region_infer::values::RegionValueElements; -use dataflow::indexes::BorrowIndex; -use dataflow::move_paths::MoveData; -use dataflow::FlowAtLocation; -use dataflow::MaybeInitializedPlaces; +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::{LocationIndex, LocationTable}; +use crate::borrow_check::nll::facts::AllFactsExt; +use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::type_check::liveness::liveness_map::NllLivenessMap; +use crate::borrow_check::nll::region_infer::values::RegionValueElements; +use crate::dataflow::indexes::BorrowIndex; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::FlowAtLocation; +use crate::dataflow::MaybeInitializedPlaces; +use crate::transform::MirSource; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir}; @@ -19,12 +20,11 @@ use std::io; use std::path::PathBuf; use std::rc::Rc; use std::str::FromStr; -use transform::MirSource; use self::mir_util::PassWhere; use polonius_engine::{Algorithm, Output}; -use util as mir_util; -use util::pretty; +use crate::util as mir_util; +use crate::util::pretty; mod constraint_generation; pub mod explain_borrow; @@ -45,7 +45,7 @@ use self::universal_regions::UniversalRegions; /// scraping out the set of universal regions (e.g., region parameters) /// declared on the function. That set will need to be given to /// `compute_regions`. -pub(in borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( +pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( infcx: &InferCtxt<'cx, 'gcx, 'tcx>, def_id: DefId, param_env: ty::ParamEnv<'tcx>, @@ -68,7 +68,7 @@ pub(in borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( /// Computes the (non-lexical) regions from the input MIR. /// /// This may result in errors being reported. -pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( +pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( infcx: &InferCtxt<'cx, 'gcx, 'tcx>, def_id: DefId, universal_regions: UniversalRegions<'tcx>, @@ -211,8 +211,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( infcx: &InferCtxt<'a, 'gcx, 'tcx>, source: MirSource, mir: &Mir<'tcx>, - regioncx: &RegionInferenceContext, - closure_region_requirements: &Option, + regioncx: &RegionInferenceContext<'_>, + closure_region_requirements: &Option>, ) { if !mir_util::dump_enabled(infcx.tcx, "nll", source) { return; @@ -273,7 +273,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>( mir: &Mir<'tcx>, mir_def_id: DefId, regioncx: &RegionInferenceContext<'tcx>, - closure_region_requirements: &Option, + closure_region_requirements: &Option>, errors_buffer: &mut Vec, ) { let tcx = infcx.tcx; @@ -322,7 +322,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>( } fn for_each_region_constraint( - closure_region_requirements: &ClosureRegionRequirements, + closure_region_requirements: &ClosureRegionRequirements<'_>, with_msg: &mut dyn FnMut(&str) -> io::Result<()>, ) -> io::Result<()> { for req in &closure_region_requirements.outlives_requirements { diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 550668a7ceece..3498e3437676c 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -1,8 +1,9 @@ -use borrow_check::nll::constraints::OutlivesConstraint; -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::type_check::Locations; -use borrow_check::nll::universal_regions::DefiningTy; -use borrow_check::nll::ConstraintDescription; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::universal_regions::DefiningTy; +use crate::borrow_check::nll::ConstraintDescription; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; use rustc::hir::def_id::DefId; use rustc::infer::error_reporting::nice_region_error::NiceRegionError; use rustc::infer::InferCtxt; @@ -15,7 +16,6 @@ use std::collections::VecDeque; use syntax::errors::Applicability; use syntax::symbol::keywords; use syntax_pos::Span; -use util::borrowck_errors::{BorrowckErrors, Origin}; mod region_name; mod var_name; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index bff8015511242..2c4f359f65fa5 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -1,7 +1,7 @@ use std::fmt::{self, Display}; -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::universal_regions::DefiningTy; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::universal_regions::DefiningTy; +use crate::borrow_check::nll::ToRegionVid; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; @@ -109,7 +109,7 @@ impl RegionName { } impl Display for RegionName { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.name) } } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs index c2f2e99c0a55b..bd7b8829c7b4f 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs @@ -1,5 +1,5 @@ -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::ToRegionVid; use rustc::mir::{Local, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::indexed_vec::Idx; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs index 2da158be432be..cffc66ac7ddfd 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs @@ -3,8 +3,7 @@ //! data to rendered labels. use super::*; -use borrow_check::nll::constraints::OutlivesConstraint; -use dot; +use crate::borrow_check::nll::constraints::OutlivesConstraint; use std::borrow::Cow; use std::io::{self, Write}; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index fee5dc8646587..7fe657702d756 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -1,9 +1,11 @@ use super::universal_regions::UniversalRegions; -use borrow_check::nll::constraints::graph::NormalConstraintGraph; -use borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint}; -use borrow_check::nll::region_infer::values::{PlaceholderIndices, RegionElement, ToElementIndex}; -use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations; -use borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::constraints::graph::NormalConstraintGraph; +use crate::borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint}; +use crate::borrow_check::nll::region_infer::values::{ + PlaceholderIndices, RegionElement, ToElementIndex +}; +use crate::borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations; +use crate::borrow_check::nll::type_check::Locations; use rustc::hir::def_id::DefId; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::region_constraints::{GenericKind, VarInfos, VerifyBound}; diff --git a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs index b7555e57a62bb..1a72205ad7ae1 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs @@ -1,8 +1,8 @@ -use borrow_check::nll::constraints::OutlivesConstraint; -use borrow_check::nll::region_infer::TypeTest; -use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; -use borrow_check::nll::universal_regions::UniversalRegions; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::region_infer::TypeTest; +use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::universal_regions::UniversalRegions; +use crate::borrow_check::nll::ToRegionVid; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::outlives::env::RegionBoundPairs; use rustc::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate}; diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs index b19dc9091cb86..f549aea81f69f 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs @@ -1,7 +1,7 @@ -use borrow_check::nll::type_check::constraint_conversion; -use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; -use borrow_check::nll::universal_regions::UniversalRegions; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::type_check::constraint_conversion; +use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::universal_regions::UniversalRegions; +use crate::borrow_check::nll::ToRegionVid; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::outlives::free_region_map::FreeRegionRelations; use rustc::infer::region_constraints::GenericKind; diff --git a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs index ef0f7e1b217a9..50828c294fa1b 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs @@ -7,7 +7,7 @@ //! `RETURN_PLACE` the MIR arguments) are always fully normalized (and //! contain revealed `impl Trait` values). -use borrow_check::nll::universal_regions::UniversalRegions; +use crate::borrow_check::nll::universal_regions::UniversalRegions; use rustc::infer::LateBoundRegionConversionTime; use rustc::mir::*; use rustc::ty::Ty; diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs index dda74e6a6a688..5e2e4407cbecd 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs @@ -6,13 +6,13 @@ //! liveness code so that it only operates over variables with regions in their //! types, instead of all variables. -use borrow_check::nll::ToRegionVid; -use borrow_check::nll::facts::{AllFacts, AllFactsExt}; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::facts::{AllFacts, AllFactsExt}; +use crate::util::liveness::LiveVariableMap; use rustc::mir::{Local, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use util::liveness::LiveVariableMap; /// Map between Local and LiveVar indices: the purpose of this /// map is to define the subset of local variables for which we need diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs index 3f13cc8b64778..e9765d2798cd7 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs @@ -1,10 +1,10 @@ -use borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements}; -use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; +use crate::borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements}; +use crate::borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; +use crate::util::liveness::{categorize, DefUse, LiveVariableMap}; use rustc::mir::visit::{PlaceContext, Visitor}; use rustc::mir::{Local, Location, Mir}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::vec_linked_list as vll; -use util::liveness::{categorize, DefUse, LiveVariableMap}; /// A map that cross references each local with the locations where it /// is defined (assigned), used, or dropped. Used during liveness diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs index 633695a9b9ce5..a5510ba6936cc 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs @@ -1,11 +1,11 @@ -use borrow_check::location::LocationTable; -use borrow_check::nll::region_infer::values::RegionValueElements; -use borrow_check::nll::constraints::ConstraintSet; -use borrow_check::nll::NllLivenessMap; -use borrow_check::nll::universal_regions::UniversalRegions; -use dataflow::move_paths::MoveData; -use dataflow::MaybeInitializedPlaces; -use dataflow::FlowAtLocation; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::region_infer::values::RegionValueElements; +use crate::borrow_check::nll::constraints::ConstraintSet; +use crate::borrow_check::nll::NllLivenessMap; +use crate::borrow_check::nll::universal_regions::UniversalRegions; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::MaybeInitializedPlaces; +use crate::dataflow::FlowAtLocation; use rustc::mir::Mir; use rustc::ty::RegionVid; use rustc_data_structures::fx::FxHashSet; diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index 77e8dd9d130e3..d058be03f55e6 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -1,12 +1,13 @@ -use borrow_check::location::LocationTable; -use borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements}; -use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; -use borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap; -use borrow_check::nll::type_check::NormalizeLocation; -use borrow_check::nll::type_check::TypeChecker; -use dataflow::move_paths::indexes::MovePathIndex; -use dataflow::move_paths::MoveData; -use dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces}; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements}; +use crate::borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; +use crate::borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap; +use crate::borrow_check::nll::type_check::NormalizeLocation; +use crate::borrow_check::nll::type_check::TypeChecker; +use crate::dataflow::move_paths::indexes::MovePathIndex; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces}; +use crate::util::liveness::LiveVariableMap; use rustc::infer::canonical::QueryRegionConstraint; use rustc::mir::{BasicBlock, ConstraintCategory, Local, Location, Mir}; use rustc::traits::query::dropck_outlives::DropckOutlivesResult; @@ -16,7 +17,6 @@ use rustc::ty::{Ty, TypeFoldable}; use rustc_data_structures::bit_set::HybridBitSet; use rustc_data_structures::fx::FxHashMap; use std::rc::Rc; -use util::liveness::LiveVariableMap; /// This is the heart of the liveness computation. For each variable X /// that requires a liveness computation, it walks over all the uses diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 3e6aa358ee0d1..19ff47f9c390d 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -2,24 +2,25 @@ #![allow(unreachable_code)] -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::LocationTable; -use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; -use borrow_check::nll::facts::AllFacts; -use borrow_check::nll::region_infer::values::LivenessValues; -use borrow_check::nll::region_infer::values::PlaceholderIndex; -use borrow_check::nll::region_infer::values::PlaceholderIndices; -use borrow_check::nll::region_infer::values::RegionValueElements; -use borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest}; -use borrow_check::nll::renumber; -use borrow_check::nll::type_check::free_region_relations::{ +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; +use crate::borrow_check::nll::facts::AllFacts; +use crate::borrow_check::nll::region_infer::values::LivenessValues; +use crate::borrow_check::nll::region_infer::values::PlaceholderIndex; +use crate::borrow_check::nll::region_infer::values::PlaceholderIndices; +use crate::borrow_check::nll::region_infer::values::RegionValueElements; +use crate::borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest}; +use crate::borrow_check::nll::renumber; +use crate::borrow_check::nll::type_check::free_region_relations::{ CreateResult, UniversalRegionRelations, }; -use borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions}; -use borrow_check::nll::ToRegionVid; -use dataflow::move_paths::MoveData; -use dataflow::FlowAtLocation; -use dataflow::MaybeInitializedPlaces; +use crate::borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions}; +use crate::borrow_check::nll::ToRegionVid; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::FlowAtLocation; +use crate::dataflow::MaybeInitializedPlaces; +use crate::transform::{MirPass, MirSource}; use either::Either; use rustc::hir; use rustc::hir::def_id::DefId; @@ -46,7 +47,6 @@ use rustc::ty::layout::VariantIdx; use std::rc::Rc; use std::{fmt, iter}; use syntax_pos::{Span, DUMMY_SP}; -use transform::{MirPass, MirSource}; macro_rules! span_mirbug { ($context:expr, $elem:expr, $($message:tt)*) => ({ @@ -210,7 +210,7 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>( extra(&mut checker) } -fn translate_outlives_facts(cx: &mut BorrowCheckContext) { +fn translate_outlives_facts(cx: &mut BorrowCheckContext<'_, '_>) { if let Some(facts) = cx.all_facts { let location_table = cx.location_table; facts @@ -235,7 +235,7 @@ fn translate_outlives_facts(cx: &mut BorrowCheckContext) { } } -fn mirbug(tcx: TyCtxt, span: Span, msg: &str) { +fn mirbug(tcx: TyCtxt<'_, '_, '_>, span: Span, msg: &str) { // We sometimes see MIR failures (notably predicate failures) due to // the fact that we check rvalue sized predicates here. So use `delay_span_bug` // to avoid reporting bugs in those cases. @@ -266,7 +266,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> { } } - fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { + fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext<'_>, location: Location) { self.sanitize_place(place, location, context); } @@ -447,7 +447,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { &mut self, place: &Place<'tcx>, location: Location, - context: PlaceContext, + context: PlaceContext<'_>, ) -> PlaceTy<'tcx> { debug!("sanitize_place: {:?}", place); let place_ty = match *place { diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index 74ad7d988cc1a..1748e30089021 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -1,5 +1,5 @@ -use borrow_check::nll::constraints::OutlivesConstraint; -use borrow_check::nll::type_check::{BorrowCheckContext, Locations}; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::type_check::{BorrowCheckContext, Locations}; use rustc::infer::nll_relate::{TypeRelating, TypeRelatingDelegate, NormalizationStrategy}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; use rustc::mir::ConstraintCategory; diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index 6875aced8d231..1cea9f662d351 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -1,8 +1,8 @@ -use borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation}; -use borrow_check::places_conflict; -use borrow_check::Context; -use borrow_check::AccessDepth; -use dataflow::indexes::BorrowIndex; +use crate::borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation}; +use crate::borrow_check::places_conflict; +use crate::borrow_check::Context; +use crate::borrow_check::AccessDepth; +use crate::dataflow::indexes::BorrowIndex; use rustc::mir::{BasicBlock, Location, Mir, Place}; use rustc::mir::{ProjectionElem, BorrowKind}; use rustc::ty::TyCtxt; diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index 4d0b25b1024a3..bad236a6f5256 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -2,7 +2,7 @@ use rustc::hir; use rustc::mir::ProjectionElem; use rustc::mir::{Local, Mir, Place, Mutability}; use rustc::ty::{self, TyCtxt}; -use borrow_check::borrow_set::LocalsStateAtExit; +use crate::borrow_check::borrow_set::LocalsStateAtExit; /// Extension methods for the `Place` type. crate trait PlaceExt<'tcx> { diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index ac7182abb36da..cd33f22bf3cb7 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -1,6 +1,6 @@ -use borrow_check::ArtificialField; -use borrow_check::Overlap; -use borrow_check::{Deep, Shallow, AccessDepth}; +use crate::borrow_check::ArtificialField; +use crate::borrow_check::Overlap; +use crate::borrow_check::{Deep, Shallow, AccessDepth}; use rustc::hir; use rustc::mir::{BorrowKind, Mir, Place}; use rustc::mir::{Projection, ProjectionElem}; diff --git a/src/librustc_mir/borrow_check/used_muts.rs b/src/librustc_mir/borrow_check/used_muts.rs index 0ff7ff4de10de..8c7359bdee768 100644 --- a/src/librustc_mir/borrow_check/used_muts.rs +++ b/src/librustc_mir/borrow_check/used_muts.rs @@ -3,7 +3,7 @@ use rustc::mir::{BasicBlock, Local, Location, Place, Statement, StatementKind, T use rustc_data_structures::fx::FxHashSet; -use borrow_check::MirBorrowckCtxt; +use crate::borrow_check::MirBorrowckCtxt; impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index f3d89a7a02515..7d93e131a6ca9 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -1,7 +1,7 @@ -use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use build::ForGuard::OutsideGuard; -use build::matches::ArmHasGuard; -use hair::*; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::build::ForGuard::OutsideGuard; +use crate::build::matches::ArmHasGuard; +use crate::hair::*; use rustc::mir::*; use rustc::hir; use syntax_pos::Span; diff --git a/src/librustc_mir/build/cfg.rs b/src/librustc_mir/build/cfg.rs index a9e468db1d1b7..778d1e71cedfc 100644 --- a/src/librustc_mir/build/cfg.rs +++ b/src/librustc_mir/build/cfg.rs @@ -1,6 +1,6 @@ //! Routines for manipulating the control-flow graph. -use build::CFG; +use crate::build::CFG; use rustc::mir::*; impl<'tcx> CFG<'tcx> { diff --git a/src/librustc_mir/build/expr/as_constant.rs b/src/librustc_mir/build/expr/as_constant.rs index 31e0c0daa3fa6..614668170d5be 100644 --- a/src/librustc_mir/build/expr/as_constant.rs +++ b/src/librustc_mir/build/expr/as_constant.rs @@ -1,7 +1,7 @@ //! See docs in build/expr/mod.rs -use build::Builder; -use hair::*; +use crate::build::Builder; +use crate::hair::*; use rustc::mir::*; use rustc::ty::CanonicalUserTypeAnnotation; diff --git a/src/librustc_mir/build/expr/as_operand.rs b/src/librustc_mir/build/expr/as_operand.rs index 1f653575a7fbf..38fae8539c8d7 100644 --- a/src/librustc_mir/build/expr/as_operand.rs +++ b/src/librustc_mir/build/expr/as_operand.rs @@ -1,8 +1,8 @@ //! See docs in build/expr/mod.rs -use build::expr::category::Category; -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::expr::category::Category; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::middle::region; use rustc::mir::*; diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index 6bd61ab53fd21..ed444191226a1 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -1,9 +1,9 @@ //! See docs in build/expr/mod.rs -use build::expr::category::Category; -use build::ForGuard::{OutsideGuard, RefWithinGuard}; -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::expr::category::Category; +use crate::build::ForGuard::{OutsideGuard, RefWithinGuard}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::mir::interpret::EvalErrorKind::BoundsCheck; use rustc::mir::*; use rustc::ty::{CanonicalUserTypeAnnotation, Variance}; diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 3de2f47578650..06658675f70f4 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -3,9 +3,9 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; -use build::expr::category::{Category, RvalueFunc}; -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::middle::region; use rustc::mir::interpret::EvalErrorKind; use rustc::mir::*; diff --git a/src/librustc_mir/build/expr/as_temp.rs b/src/librustc_mir/build/expr/as_temp.rs index df271ff6e4016..efa1a4895e0c0 100644 --- a/src/librustc_mir/build/expr/as_temp.rs +++ b/src/librustc_mir/build/expr/as_temp.rs @@ -1,7 +1,7 @@ //! See docs in build/expr/mod.rs -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::middle::region; use rustc::mir::*; diff --git a/src/librustc_mir/build/expr/category.rs b/src/librustc_mir/build/expr/category.rs index 53f84a495696c..ca7d435e62229 100644 --- a/src/librustc_mir/build/expr/category.rs +++ b/src/librustc_mir/build/expr/category.rs @@ -1,4 +1,4 @@ -use hair::*; +use crate::hair::*; #[derive(Debug, PartialEq)] pub enum Category { diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 2ffff68137dd2..05231bc7b3f16 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -1,8 +1,8 @@ //! See docs in build/expr/mod.rs -use build::expr::category::{Category, RvalueFunc}; -use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use hair::*; +use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::hair::*; use rustc::mir::*; use rustc::ty; diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index 1cbc60586c356..aadc2368f5aec 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -1,6 +1,6 @@ -use build::scope::BreakableScope; -use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use hair::*; +use crate::build::scope::BreakableScope; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::hair::*; use rustc::mir::*; impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { diff --git a/src/librustc_mir/build/into.rs b/src/librustc_mir/build/into.rs index 1b29126082067..67b6540febea8 100644 --- a/src/librustc_mir/build/into.rs +++ b/src/librustc_mir/build/into.rs @@ -4,11 +4,11 @@ //! wrapped up as expressions (e.g., blocks). To make this ergonomic, we use this //! latter `EvalInto` trait. -use build::{BlockAnd, Builder}; -use hair::*; +use crate::build::{BlockAnd, Builder}; +use crate::hair::*; use rustc::mir::*; -pub(in build) trait EvalInto<'tcx> { +pub(in crate::build) trait EvalInto<'tcx> { fn eval_into<'a, 'gcx>(self, builder: &mut Builder<'a, 'gcx, 'tcx>, destination: &Place<'tcx>, diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 2f1e8c03f2f7e..cf051ba2e0fa6 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -3,11 +3,11 @@ //! includes the high-level algorithm, the submodules contain the //! details. -use build::scope::{CachedBlock, DropKind}; -use build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard}; -use build::{BlockAnd, BlockAndExtension, Builder}; -use build::{GuardFrame, GuardFrameLocal, LocalsForNode}; -use hair::*; +use crate::build::scope::{CachedBlock, DropKind}; +use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; +use crate::hair::*; use rustc::mir::*; use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty}; use rustc::ty::layout::VariantIdx; diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index c219fd2218223..6be9ccb27036e 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -12,9 +12,9 @@ //! sort of test: for example, testing which variant an enum is, or //! testing a value against a constant. -use build::Builder; -use build::matches::{Ascription, Binding, MatchPair, Candidate}; -use hair::*; +use crate::build::Builder; +use crate::build::matches::{Ascription, Binding, MatchPair, Candidate}; +use crate::hair::*; use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; use syntax::attr::{SignedInt, UnsignedInt}; diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 696c173b048ad..395858c07b606 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -5,10 +5,10 @@ // identify what tests are needed, perform the tests, and then filter // the candidates based on the result. -use build::Builder; -use build::matches::{Candidate, MatchPair, Test, TestKind}; -use hair::*; -use hair::pattern::compare_const_vals; +use crate::build::Builder; +use crate::build::matches::{Candidate, MatchPair, Test, TestKind}; +use crate::hair::*; +use crate::hair::pattern::compare_const_vals; use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::FxHashMap; use rustc::ty::{self, Ty}; diff --git a/src/librustc_mir/build/matches/util.rs b/src/librustc_mir/build/matches/util.rs index b5a1a388e9cbc..ed12c1b3bc9c1 100644 --- a/src/librustc_mir/build/matches/util.rs +++ b/src/librustc_mir/build/matches/util.rs @@ -1,6 +1,6 @@ -use build::Builder; -use build::matches::MatchPair; -use hair::*; +use crate::build::Builder; +use crate::build::matches::MatchPair; +use crate::hair::*; use rustc::mir::*; use std::u32; use std::convert::TryInto; diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index c849c02242840..1634c36d34acf 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -1,7 +1,7 @@ //! Miscellaneous builder routines that are not specific to building any particular //! kind of thing. -use build::Builder; +use crate::build::Builder; use rustc::ty::{self, Ty}; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index f38648fda0e36..a52b032aeb508 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -1,7 +1,10 @@ -use build; -use build::scope::{CachedBlock, DropKind}; -use hair::cx::Cx; -use hair::{LintLevel, BindingMode, PatternKind}; +use crate::build; +use crate::build::scope::{CachedBlock, DropKind}; +use crate::hair::cx::Cx; +use crate::hair::{LintLevel, BindingMode, PatternKind}; +use crate::shim; +use crate::transform::MirSource; +use crate::util as mir_util; use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; @@ -13,7 +16,6 @@ use rustc::ty::subst::Substs; use rustc::util::nodemap::NodeMap; use rustc_target::spec::PanicStrategy; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -use shim; use std::mem; use std::u32; use rustc_target::spec::abi::Abi; @@ -21,8 +23,6 @@ use syntax::ast; use syntax::attr::{self, UnwindAttr}; use syntax::symbol::keywords; use syntax_pos::Span; -use transform::MirSource; -use util as mir_util; use super::lints; @@ -161,7 +161,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t }; globalizer.visit_mir(&mut mir); let mir = unsafe { - mem::transmute::>(mir) + mem::transmute::, Mir<'tcx>>(mir) }; mir_util::dump_mir(tcx, None, "mir_map", &0, @@ -241,7 +241,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; globalizer.visit_mir(&mut mir); let mir = unsafe { - mem::transmute::>(mir) + mem::transmute::, Mir<'tcx>>(mir) }; mir_util::dump_mir(tcx, None, "mir_map", &0, diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 78abba5f885b2..3872f5db26278 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -77,8 +77,8 @@ should go to. */ -use build::{BlockAnd, BlockAndExtension, Builder, CFG}; -use hair::LintLevel; +use crate::build::{BlockAnd, BlockAndExtension, Builder, CFG}; +use crate::hair::LintLevel; use rustc::middle::region; use rustc::ty::Ty; use rustc::hir; diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index f83a930353b73..d1b4486dd9345 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -190,7 +190,7 @@ enum ConstEvalError { } impl fmt::Display for ConstEvalError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::ConstEvalError::*; match *self { NeedsRfc(ref msg) => { diff --git a/src/librustc_mir/dataflow/at_location.rs b/src/librustc_mir/dataflow/at_location.rs index 375bc4fead443..d0b9fbc99f03f 100644 --- a/src/librustc_mir/dataflow/at_location.rs +++ b/src/librustc_mir/dataflow/at_location.rs @@ -4,8 +4,8 @@ use rustc::mir::{BasicBlock, Location}; use rustc_data_structures::bit_set::{BitIter, BitSet, HybridBitSet}; -use dataflow::{BitDenotation, BlockSets, DataflowResults}; -use dataflow::move_paths::{HasMoveData, MovePathIndex}; +use crate::dataflow::{BitDenotation, BlockSets, DataflowResults}; +use crate::dataflow::move_paths::{HasMoveData, MovePathIndex}; use std::iter; @@ -115,7 +115,7 @@ where } /// Returns an iterator over the elements present in the current state. - pub fn iter_incoming(&self) -> iter::Peekable> { + pub fn iter_incoming(&self) -> iter::Peekable> { self.curr_state.iter().peekable() } @@ -124,7 +124,7 @@ where /// Invokes `f` with an iterator over the resulting state. pub fn with_iter_outgoing(&self, f: F) where - F: FnOnce(BitIter), + F: FnOnce(BitIter<'_, BD::Idx>), { let mut curr_state = self.curr_state.clone(); curr_state.union(&self.stmt_gen); diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index 22fb7a3bc470e..49499cf928d74 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -1,6 +1,6 @@ use rustc::mir::{self, Mir, Location}; use rustc::ty::{self, TyCtxt}; -use util::elaborate_drops::DropFlagState; +use crate::util::elaborate_drops::DropFlagState; use super::{MoveDataParamEnv}; use super::indexes::MovePathIndex; diff --git a/src/librustc_mir/dataflow/graphviz.rs b/src/librustc_mir/dataflow/graphviz.rs index 34752baa020e2..9d9f18d4b0dcf 100644 --- a/src/librustc_mir/dataflow/graphviz.rs +++ b/src/librustc_mir/dataflow/graphviz.rs @@ -3,8 +3,6 @@ use syntax::ast::NodeId; use rustc::mir::{BasicBlock, Mir}; -use dot; - use std::fs; use std::io; use std::marker::PhantomData; @@ -59,7 +57,7 @@ pub type Node = BasicBlock; #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Edge { source: BasicBlock, index: usize } -fn outgoing(mir: &Mir, bb: BasicBlock) -> Vec { +fn outgoing(mir: &Mir<'_>, bb: BasicBlock) -> Vec { (0..mir[bb].terminator().successors().count()) .map(|index| Edge { source: bb, index: index}).collect() } @@ -70,18 +68,18 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P> { type Node = Node; type Edge = Edge; - fn graph_id(&self) -> dot::Id { + fn graph_id(&self) -> dot::Id<'_> { dot::Id::new(format!("graph_for_node_{}", self.mbcx.node_id())) .unwrap() } - fn node_id(&self, n: &Node) -> dot::Id { + fn node_id(&self, n: &Node) -> dot::Id<'_> { dot::Id::new(format!("bb_{}", n.index())) .unwrap() } - fn node_label(&self, n: &Node) -> dot::LabelText { + fn node_label(&self, n: &Node) -> dot::LabelText<'_> { // Node label is something like this: // +---------+----------------------------------+------------------+------------------+ // | ENTRY | MIR | GEN | KILL | @@ -105,7 +103,7 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P> } - fn node_shape(&self, _n: &Node) -> Option { + fn node_shape(&self, _n: &Node) -> Option> { Some(dot::LabelText::label("none")) } @@ -125,7 +123,7 @@ where MWF: MirWithFlowState<'tcx>, n: &Node, w: &mut W, block: BasicBlock, - mir: &Mir) -> io::Result<()> { + mir: &Mir<'_>) -> io::Result<()> { // Header rows const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"]; const HDR_FMT: &str = "bgcolor=\"grey\""; @@ -150,7 +148,7 @@ where MWF: MirWithFlowState<'tcx>, n: &Node, w: &mut W, block: BasicBlock, - mir: &Mir) + mir: &Mir<'_>) -> io::Result<()> { let i = n.index(); @@ -200,7 +198,7 @@ where MWF: MirWithFlowState<'tcx>, n: &Node, w: &mut W, block: BasicBlock, - mir: &Mir) + mir: &Mir<'_>) -> io::Result<()> { let i = n.index(); @@ -241,7 +239,7 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P> { type Node = Node; type Edge = Edge; - fn nodes(&self) -> dot::Nodes { + fn nodes(&self) -> dot::Nodes<'_, Node> { self.mbcx.mir() .basic_blocks() .indices() @@ -249,7 +247,7 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P> .into() } - fn edges(&self) -> dot::Edges { + fn edges(&self) -> dot::Edges<'_, Edge> { let mir = self.mbcx.mir(); mir.basic_blocks() diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index 9d03e35a35069..51d628ce6c5c2 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -2,7 +2,7 @@ pub use super::*; use rustc::mir::*; use rustc::mir::visit::Visitor; -use dataflow::BitDenotation; +use crate::dataflow::BitDenotation; /// This calculates if any part of a MIR local could have previously been borrowed. /// This means that once a local has been borrowed, its bit will be set @@ -38,7 +38,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> { } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Local>, loc: Location) { let stmt = &self.mir[loc.block].statements[loc.statement_index]; @@ -54,7 +54,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> { } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Local>, loc: Location) { BorrowedLocalsVisitor { sets, diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 72218e29cfd20..beb0b3187082b 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -1,5 +1,5 @@ -use borrow_check::borrow_set::{BorrowSet, BorrowData}; -use borrow_check::place_ext::PlaceExt; +use crate::borrow_check::borrow_set::{BorrowSet, BorrowData}; +use crate::borrow_check::place_ext::PlaceExt; use rustc::mir::{self, Location, Place, Mir}; use rustc::ty::TyCtxt; @@ -9,11 +9,11 @@ use rustc_data_structures::bit_set::{BitSet, BitSetOperator}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use dataflow::{BitDenotation, BlockSets, InitialFlow}; -pub use dataflow::indexes::BorrowIndex; -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::ToRegionVid; -use borrow_check::places_conflict; +use crate::dataflow::{BitDenotation, BlockSets, InitialFlow}; +pub use crate::dataflow::indexes::BorrowIndex; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::places_conflict; use std::rc::Rc; @@ -163,7 +163,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { /// Add all borrows to the kill set, if those borrows are out of scope at `location`. /// That means they went out of a nonlexical scope fn kill_loans_out_of_scope_at_location(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { // NOTE: The state associated with a given `location` // reflects the dataflow on entry to the statement. @@ -184,7 +184,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { /// Kill any borrows that conflict with `place`. fn kill_borrows_on_place( &self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, place: &Place<'tcx> ) { debug!("kill_borrows_on_place: place={:?}", place); @@ -243,13 +243,13 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { } fn before_statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { debug!("Borrows::before_statement_effect sets: {:?} location: {:?}", sets, location); self.kill_loans_out_of_scope_at_location(sets, location); } - fn statement_effect(&self, sets: &mut BlockSets, location: Location) { + fn statement_effect(&self, sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { debug!("Borrows::statement_effect: sets={:?} location={:?}", sets, location); let block = &self.mir.basic_blocks().get(location.block).unwrap_or_else(|| { @@ -307,13 +307,13 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { } fn before_terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { debug!("Borrows::before_terminator_effect sets: {:?} location: {:?}", sets, location); self.kill_loans_out_of_scope_at_location(sets, location); } - fn terminator_effect(&self, _: &mut BlockSets, _: Location) {} + fn terminator_effect(&self, _: &mut BlockSets<'_, BorrowIndex>, _: Location) {} fn propagate_call_return( &self, diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 1ccda3a12e433..c8965b9f7f4c7 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -9,7 +9,7 @@ use rustc_data_structures::indexed_vec::Idx; use super::MoveDataParamEnv; -use util::elaborate_drops::DropFlagState; +use crate::util::elaborate_drops::DropFlagState; use super::move_paths::{HasMoveData, MoveData, MovePathIndex, InitIndex}; use super::move_paths::{LookupResult, InitKind}; @@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tcx> impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { - fn update_bits(sets: &mut BlockSets, path: MovePathIndex, + fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { match state { @@ -262,7 +262,7 @@ impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { } impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { - fn update_bits(sets: &mut BlockSets, path: MovePathIndex, + fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { match state { @@ -273,7 +273,7 @@ impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { } impl<'a, 'gcx, 'tcx> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { - fn update_bits(sets: &mut BlockSets, path: MovePathIndex, + fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { match state { @@ -300,7 +300,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 't } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -311,7 +311,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 't } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -358,7 +358,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -369,7 +369,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -414,7 +414,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'gc } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -425,7 +425,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'gc } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -464,7 +464,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, InitIndex>, location: Location) { let (_, mir, move_data) = (self.tcx, self.mir, self.move_data()); let stmt = &mir[location.block].statements[location.statement_index]; @@ -511,7 +511,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, InitIndex>, location: Location) { let (mir, move_data) = (self.mir, self.move_data()); diff --git a/src/librustc_mir/dataflow/impls/storage_liveness.rs b/src/librustc_mir/dataflow/impls/storage_liveness.rs index 9c17076e6fde0..6b8eb6f17f6c1 100644 --- a/src/librustc_mir/dataflow/impls/storage_liveness.rs +++ b/src/librustc_mir/dataflow/impls/storage_liveness.rs @@ -1,7 +1,7 @@ pub use super::*; use rustc::mir::*; -use dataflow::BitDenotation; +use crate::dataflow::BitDenotation; #[derive(Copy, Clone)] pub struct MaybeStorageLive<'a, 'tcx: 'a> { @@ -31,7 +31,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> { } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Local>, loc: Location) { let stmt = &self.mir[loc.block].statements[loc.statement_index]; @@ -43,7 +43,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> { } fn terminator_effect(&self, - _sets: &mut BlockSets, + _sets: &mut BlockSets<'_, Local>, _loc: Location) { // Terminators have no effect } diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index f09db970b7353..1853b60efd7e6 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -58,7 +58,7 @@ impl DebugFormatted { } impl fmt::Debug for DebugFormatted { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { write!(w, "{}", self.0) } } @@ -525,7 +525,7 @@ impl<'a, E:Idx> BlockSets<'a, E> { impl AllSets { pub fn bits_per_block(&self) -> usize { self.bits_per_block } - pub fn for_block(&mut self, block_idx: usize) -> BlockSets { + pub fn for_block(&mut self, block_idx: usize) -> BlockSets<'_, E> { BlockSets { on_entry: &mut self.on_entry_sets[block_idx], gen_set: &mut self.gen_sets[block_idx], @@ -616,7 +616,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// applied, in that order, before moving for the next /// statement. fn before_statement_effect(&self, - _sets: &mut BlockSets, + _sets: &mut BlockSets<'_, Self::Idx>, _location: Location) {} /// Mutates the block-sets (the flow sets for the given @@ -630,7 +630,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// `bb_data` is the sequence of statements identified by `bb` in /// the MIR. fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Self::Idx>, location: Location); /// Similar to `terminator_effect`, except it applies @@ -645,7 +645,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// applied, in that order, before moving for the next /// terminator. fn before_terminator_effect(&self, - _sets: &mut BlockSets, + _sets: &mut BlockSets<'_, Self::Idx>, _location: Location) {} /// Mutates the block-sets (the flow sets for the given @@ -659,7 +659,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// The effects applied here cannot depend on which branch the /// terminator took. fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Self::Idx>, location: Location); /// Mutates the block-sets according to the (flow-dependent) diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index d77216220ac2b..efd979a7da4fb 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -37,7 +37,7 @@ pub(crate) mod indexes { } impl fmt::Debug for $Index { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{}{}", $debug_name, self.index()) } } @@ -62,7 +62,7 @@ pub use self::indexes::MoveOutIndex; pub use self::indexes::InitIndex; impl MoveOutIndex { - pub fn move_path_index(&self, move_data: &MoveData) -> MovePathIndex { + pub fn move_path_index(&self, move_data: &MoveData<'_>) -> MovePathIndex { move_data.moves[*self].path } } @@ -88,7 +88,10 @@ pub struct MovePath<'tcx> { } impl<'tcx> MovePath<'tcx> { - pub fn parents(&self, move_paths: &IndexVec) -> Vec { + pub fn parents( + &self, + move_paths: &IndexVec>, + ) -> Vec { let mut parents = Vec::new(); let mut curr_parent = self.parent; @@ -102,7 +105,7 @@ impl<'tcx> MovePath<'tcx> { } impl<'tcx> fmt::Debug for MovePath<'tcx> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { write!(w, "MovePath {{")?; if let Some(parent) = self.parent { write!(w, " parent: {:?},", parent)?; @@ -118,7 +121,7 @@ impl<'tcx> fmt::Debug for MovePath<'tcx> { } impl<'tcx> fmt::Display for MovePath<'tcx> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { write!(w, "{:?}", self.place) } } @@ -166,7 +169,7 @@ impl IndexMut for LocationMap { } impl LocationMap where T: Default + Clone { - fn new(mir: &Mir) -> Self { + fn new(mir: &Mir<'_>) -> Self { LocationMap { map: mir.basic_blocks().iter().map(|block| { vec![T::default(); block.statements.len()+1] @@ -190,7 +193,7 @@ pub struct MoveOut { } impl fmt::Debug for MoveOut { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{:?}@{:?}", self.path, self.source) } } @@ -227,7 +230,7 @@ pub enum InitKind { } impl fmt::Debug for Init { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{:?}@{:?} ({:?})", self.path, self.location, self.kind) } } diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 518ae978ae17a..c24cf956504da 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -1,6 +1,6 @@ -use hair::*; -use hair::cx::Cx; -use hair::cx::to_ref::ToRef; +use crate::hair::*; +use crate::hair::cx::Cx; +use crate::hair::cx::to_ref::ToRef; use rustc::middle::region; use rustc::hir; use rustc::ty; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 8d64c9e9ada89..0759b95a78ff4 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -1,9 +1,9 @@ -use hair::*; +use crate::hair::*; +use crate::hair::cx::Cx; +use crate::hair::cx::block; +use crate::hair::cx::to_ref::ToRef; +use crate::hair::util::UserAnnotatedTyHelpers; use rustc_data_structures::indexed_vec::Idx; -use hair::cx::Cx; -use hair::cx::block; -use hair::cx::to_ref::ToRef; -use hair::util::UserAnnotatedTyHelpers; use rustc::hir::def::{Def, CtorKind}; use rustc::mir::interpret::{GlobalId, ErrorHandled}; use rustc::ty::{self, AdtKind, Ty}; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index f514cac6326be..6d61801fc7162 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -4,8 +4,8 @@ //! work. //! -use hair::*; -use hair::util::UserAnnotatedTyHelpers; +use crate::hair::*; +use crate::hair::util::UserAnnotatedTyHelpers; use rustc_data_structures::indexed_vec::Idx; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; @@ -21,7 +21,7 @@ use syntax::attr; use syntax::symbol::Symbol; use rustc::hir; use rustc_data_structures::sync::Lrc; -use hair::constant::{lit_to_const, LitToConstError}; +use crate::hair::constant::{lit_to_const, LitToConstError}; #[derive(Clone)] pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { @@ -239,7 +239,7 @@ impl UserAnnotatedTyHelpers<'gcx, 'tcx> for Cx<'_, 'gcx, 'tcx> { } } -fn lint_level_for_hir_id(tcx: TyCtxt, mut id: ast::NodeId) -> ast::NodeId { +fn lint_level_for_hir_id(tcx: TyCtxt<'_, '_, '_>, mut id: ast::NodeId) -> ast::NodeId { // Right now we insert a `with_ignore` node in the dep graph here to // ignore the fact that `lint_levels` below depends on the entire crate. // For now this'll prevent false positives of recompiling too much when diff --git a/src/librustc_mir/hair/cx/to_ref.rs b/src/librustc_mir/hair/cx/to_ref.rs index 1b87e4450c56e..a462c61c2acba 100644 --- a/src/librustc_mir/hair/cx/to_ref.rs +++ b/src/librustc_mir/hair/cx/to_ref.rs @@ -1,4 +1,4 @@ -use hair::*; +use crate::hair::*; use rustc::hir; use syntax::ptr::P; diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 7f5b1a761d261..5779a032acc4d 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -307,7 +307,7 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> { /// + _ + [_, _, ..tail] + /// ++++++++++++++++++++++++++ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "\n")?; let &Matrix(ref m) = self; @@ -442,7 +442,7 @@ impl<'tcx> Constructor<'tcx> { VariantIdx::new(0) } &ConstantValue(c) => { - ::const_eval::const_variant_index( + crate::const_eval::const_variant_index( cx.tcx, cx.param_env, c, @@ -1115,7 +1115,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, } else { debug!("is_useful - expanding wildcard"); - let used_ctors: Vec = rows.iter().flat_map(|row| { + let used_ctors: Vec> = rows.iter().flat_map(|row| { pat_constructors(cx, row[0], pcx).unwrap_or(vec![]) }).collect(); debug!("used_ctors = {:#?}", used_ctors); @@ -1302,7 +1302,7 @@ fn is_useful_specialized<'p, 'a: 'p, 'tcx: 'a>( /// Returns None in case of a catch-all, which can't be specialized. fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, pat: &Pattern<'tcx>, - pcx: PatternContext) + pcx: PatternContext<'_>) -> Option>> { match *pat.kind { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index a47d64319bdc5..978051aab591b 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -229,7 +229,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { return; } - let matrix: Matrix = inlined_arms + let matrix: Matrix<'_, '_> = inlined_arms .iter() .filter(|&&(_, guard)| guard.is_none()) .flat_map(|arm| &arm.0) @@ -248,7 +248,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { self.tables); let pattern = patcx.lower_pattern(pat); let pattern_ty = pattern.ty; - let pats: Matrix = vec![smallvec![ + let pats: Matrix<'_, '_> = vec![smallvec![ expand_pattern(cx, pattern) ]].into_iter().collect(); @@ -283,7 +283,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { } } -fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor, pat: &Pat) { +fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) { pat.walk(|p| { if let PatKind::Binding(_, _, _, ident, None) = p.node { if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) { @@ -462,7 +462,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, } // Legality of move bindings checking -fn check_legality_of_move_bindings(cx: &MatchVisitor, +fn check_legality_of_move_bindings(cx: &MatchVisitor<'_, '_>, has_guard: bool, pats: &[P]) { let mut by_ref_span = None; @@ -541,7 +541,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor, /// assign. /// /// FIXME: this should be done by borrowck. -fn check_for_mutation_in_guard(cx: &MatchVisitor, guard: &hir::Guard) { +fn check_for_mutation_in_guard(cx: &MatchVisitor<'_, '_>, guard: &hir::Guard) { let mut checker = MutationChecker { cx, }; @@ -561,13 +561,13 @@ struct MutationChecker<'a, 'tcx: 'a> { } impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { - fn matched_pat(&mut self, _: &Pat, _: &cmt_, _: euv::MatchMode) {} - fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_, _: ConsumeMode) {} - fn consume_pat(&mut self, _: &Pat, _: &cmt_, _: ConsumeMode) {} + fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {} + fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {} + fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {} fn borrow(&mut self, _: ast::NodeId, span: Span, - _: &cmt_, + _: &cmt_<'_>, _: ty::Region<'tcx>, kind:ty:: BorrowKind, _: LoanCause) { @@ -588,7 +588,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { } } fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {} - fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_, mode: MutateMode) { + fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_<'_>, mode: MutateMode) { match mode { MutateMode::JustWrite | MutateMode::WriteAndRead => { struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard") @@ -603,7 +603,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { /// Forbids bindings in `@` patterns. This is necessary for memory safety, /// because of the way rvalues are handled in the borrow check. (See issue /// #14587.) -fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor, pat: &Pat) { +fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat) { AtBindingPatternVisitor { cx: cx, bindings_allowed: true }.visit_pat(pat); } diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 6b7e14161186d..8d32becd439e0 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -6,10 +6,10 @@ mod check_match; pub use self::check_match::check_crate; pub(crate) use self::check_match::check_match; -use const_eval::{const_field, const_variant_index}; +use crate::const_eval::{const_field, const_variant_index}; -use hair::util::UserAnnotatedTyHelpers; -use hair::constant::*; +use crate::hair::util::UserAnnotatedTyHelpers; +use crate::hair::constant::*; use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability}; use rustc::mir::{UserTypeProjection}; @@ -176,7 +176,7 @@ pub struct PatternRange<'tcx> { } impl<'tcx> fmt::Display for Pattern<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self.kind { PatternKind::Wild => write!(f, "_"), PatternKind::AscribeUserType { ref subpattern, .. } => diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 1b976d822ebff..c87338fb0ce94 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -322,7 +322,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc ) -> EvalResult<'tcx, TyLayout<'tcx>> { match frame.locals[local].layout.get() { None => { - let layout = ::interpret::operand::from_known_layout(layout, || { + let layout = crate::interpret::operand::from_known_layout(layout, || { let local_ty = frame.mir.local_decls[local].ty; let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs); self.layout_of(local_ty) diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 5fae461bdc203..ee295116ba962 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -25,7 +25,7 @@ use syntax::source_map::Span; use super::eval_context::{LocalState, StackPopCleanup}; use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef, LocalValue}; -use const_eval::CompileTimeInterpreter; +use crate::const_eval::CompileTimeInterpreter; #[derive(Default)] pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir> { @@ -200,7 +200,7 @@ impl_snapshot_for!(enum ScalarMaybeUndef { Undef, }); -impl_stable_hash_for!(struct ::interpret::MemPlace { +impl_stable_hash_for!(struct crate::interpret::MemPlace { ptr, align, meta, @@ -211,7 +211,7 @@ impl_snapshot_for!(struct MemPlace { align -> *align, // just copy alignment verbatim }); -impl_stable_hash_for!(enum ::interpret::Place { +impl_stable_hash_for!(enum crate::interpret::Place { Ptr(mem_place), Local { frame, local }, }); @@ -232,7 +232,7 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for Place } } -impl_stable_hash_for!(enum ::interpret::Immediate { +impl_stable_hash_for!(enum crate::interpret::Immediate { Scalar(x), ScalarPair(x, y), }); @@ -241,7 +241,7 @@ impl_snapshot_for!(enum Immediate { ScalarPair(s, t), }); -impl_stable_hash_for!(enum ::interpret::Operand { +impl_stable_hash_for!(enum crate::interpret::Operand { Immediate(x), Indirect(x), }); @@ -250,7 +250,7 @@ impl_snapshot_for!(enum Operand { Indirect(m), }); -impl_stable_hash_for!(enum ::interpret::LocalValue { +impl_stable_hash_for!(enum crate::interpret::LocalValue { Dead, Live(x), }); @@ -298,7 +298,7 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for &'a Allocation } } -impl_stable_hash_for!(enum ::interpret::eval_context::StackPopCleanup { +impl_stable_hash_for!(enum crate::interpret::eval_context::StackPopCleanup { Goto(block), None { cleanup }, }); diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 7e823524c180c..be50daa17092f 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -112,7 +112,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let ty = place.layout.ty; trace!("TerminatorKind::drop: {:?}, type {}", location, ty); - let instance = ::monomorphize::resolve_drop_in_place(*self.tcx, ty); + let instance = crate::monomorphize::resolve_drop_in_place(*self.tcx, ty); self.drop_in_place( place, instance, @@ -326,7 +326,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // last incoming argument. These two iterators do not have the same type, // so to keep the code paths uniform we accept an allocation // (for RustCall ABI only). - let caller_args : Cow<[OpTy<'tcx, M::PointerTag>]> = + let caller_args : Cow<'_, [OpTy<'tcx, M::PointerTag>]> = if caller_abi == Abi::RustCall && !args.is_empty() { // Untuple let (&untuple_arg, args) = args.split_last().unwrap(); @@ -335,7 +335,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> .chain((0..untuple_arg.layout.fields.count()).into_iter() .map(|i| self.operand_field(untuple_arg, i as u64)) ) - .collect::>>>()?) + .collect::>>>()?) } else { // Plain arg passing Cow::from(args) diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index 642bbc114f562..63253bae9078b 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -52,7 +52,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> ).with_default_tag(); let tcx = &*self.tcx; - let drop = ::monomorphize::resolve_drop_in_place(*tcx, ty); + let drop = crate::monomorphize::resolve_drop_in_place(*tcx, ty); let drop = self.memory.create_fn_alloc(drop).with_default_tag(); // no need to do any alignment checks on the memory accesses below, because we know the // allocation is correctly aligned as we created it above. Also we're only offsetting by diff --git a/src/librustc_mir/interpret/visitor.rs b/src/librustc_mir/interpret/visitor.rs index 4773f5627d716..930bcb44374aa 100644 --- a/src/librustc_mir/interpret/visitor.rs +++ b/src/librustc_mir/interpret/visitor.rs @@ -26,7 +26,7 @@ pub trait Value<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>: Copy ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>>; /// Create this from an `MPlaceTy`. - fn from_mem_place(MPlaceTy<'tcx, M::PointerTag>) -> Self; + fn from_mem_place(mplace: MPlaceTy<'tcx, M::PointerTag>) -> Self; /// Project to the given enum variant. fn project_downcast( diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index ccfc15bac042c..72a13c791cec0 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -4,7 +4,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ -#![feature(nll)] #![feature(in_band_lifetimes)] #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] @@ -29,28 +28,19 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![recursion_limit="256"] -extern crate arena; +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] #[macro_use] extern crate bitflags; #[macro_use] extern crate log; -extern crate either; -extern crate graphviz as dot; -extern crate polonius_engine; #[macro_use] extern crate rustc; #[macro_use] extern crate rustc_data_structures; -extern crate serialize as rustc_serialize; -extern crate rustc_errors; +#[allow(unused_extern_crates)] +extern crate serialize as rustc_serialize; // used by deriving #[macro_use] extern crate syntax; -extern crate syntax_pos; -extern crate rustc_target; -extern crate log_settings; -extern crate rustc_apfloat; -extern crate byteorder; -extern crate core; -extern crate smallvec; // Once we can use edition 2018 in the compiler, // replace this with real try blocks. @@ -77,7 +67,7 @@ pub mod const_eval; pub use hair::pattern::check_crate as matchck_crate; use rustc::ty::query::Providers; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { borrow_check::provide(providers); shim::provide(providers); transform::provide(providers); diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 8ded31d89daea..6b6e8fcdc82cf 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -18,7 +18,7 @@ pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, } fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, - fn_kind: FnKind, + fn_kind: FnKind<'_>, mir: &Mir<'tcx>, def_id: DefId) { if let FnKind::Closure(_) = fn_kind { diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index e713ab17c3af5..7f3c24daf606d 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -189,11 +189,11 @@ use rustc::mir::visit::Visitor as MirVisitor; use rustc::mir::mono::MonoItem; use rustc::mir::interpret::{Scalar, GlobalId, AllocKind, ErrorHandled}; -use monomorphize::{self, Instance}; +use crate::monomorphize::{self, Instance}; use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap}; use rustc::util::common::time; -use monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode}; +use crate::monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode}; use rustc_data_structures::bit_set::GrowableBitSet; use rustc_data_structures::sync::{MTRef, MTLock, ParallelIterator, par_iter}; diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 431cc0d52b4c8..d3381f463f49e 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -1,4 +1,4 @@ -use monomorphize::Instance; +use crate::monomorphize::Instance; use rustc::hir; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::session::config::OptLevel; diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index 569e4c828f601..d4c7ebefe1753 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -111,9 +111,9 @@ use rustc::util::common::time; use rustc::util::nodemap::{DefIdSet, FxHashMap, FxHashSet}; use rustc::mir::mono::MonoItem; -use monomorphize::collector::InliningMap; -use monomorphize::collector::{self, MonoItemCollectionMode}; -use monomorphize::item::{MonoItemExt, InstantiationMode}; +use crate::monomorphize::collector::InliningMap; +use crate::monomorphize::collector::{self, MonoItemCollectionMode}; +use crate::monomorphize::item::{MonoItemExt, InstantiationMode}; pub use rustc::mir::mono::CodegenUnit; @@ -146,7 +146,7 @@ pub trait CodegenUnitExt<'tcx> { WorkProductId::from_cgu_name(&self.name().as_str()) } - fn work_product(&self, tcx: TyCtxt) -> WorkProduct { + fn work_product(&self, tcx: TyCtxt<'_, '_, '_>) -> WorkProduct { let work_product_id = self.work_product_id(); tcx.dep_graph .previous_work_product(&work_product_id) @@ -213,7 +213,7 @@ impl<'tcx> CodegenUnitExt<'tcx> for CodegenUnit<'tcx> { } // Anything we can't find a proper codegen unit for goes into this. -fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder) -> InternedString { +fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>) -> InternedString { name_builder.build_cgu_name(LOCAL_CRATE, &["fallback"], Some("cgu")) } @@ -536,7 +536,7 @@ fn mono_item_visibility( } } -fn default_visibility(tcx: TyCtxt, id: DefId, is_generic: bool) -> Visibility { +fn default_visibility(tcx: TyCtxt<'_, '_, '_>, id: DefId, is_generic: bool) -> Visibility { if !tcx.sess.target.target.options.default_hidden_visibility { return Visibility::Default } @@ -795,8 +795,8 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, type CguNameCache = FxHashMap<(DefId, bool), InternedString>; -fn compute_codegen_unit_name(tcx: TyCtxt, - name_builder: &mut CodegenUnitNameBuilder, +fn compute_codegen_unit_name(tcx: TyCtxt<'_, '_, '_>, + name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>, def_id: DefId, volatile: bool, cache: &mut CguNameCache) @@ -855,7 +855,7 @@ fn compute_codegen_unit_name(tcx: TyCtxt, }).clone() } -fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder, +fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>, index: usize) -> InternedString { name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(index)) @@ -929,7 +929,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( tcx.sess.abort_if_errors(); - ::monomorphize::assert_symbols_are_distinct(tcx, items.iter()); + crate::monomorphize::assert_symbols_are_distinct(tcx, items.iter()); let strategy = if tcx.sess.opts.incremental.is_some() { PartitioningStrategy::PerModule @@ -1013,7 +1013,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( (Arc::new(mono_items), Arc::new(codegen_units)) } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.collect_and_partition_mono_items = collect_and_partition_mono_items; diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 751815eab287b..942e7a1f1bbbd 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -16,12 +16,12 @@ use syntax_pos::Span; use std::fmt; use std::iter; -use transform::{add_moves_for_packed_drops, add_call_guards}; -use transform::{remove_noop_landing_pads, no_landing_pads, simplify}; -use util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode}; -use util::patch::MirPatch; +use crate::transform::{add_moves_for_packed_drops, add_call_guards}; +use crate::transform::{remove_noop_landing_pads, no_landing_pads, simplify}; +use crate::util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode}; +use crate::util::patch::MirPatch; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.mir_shims = make_shim; } @@ -138,7 +138,7 @@ enum CallKind { Direct(DefId), } -fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl { +fn temp_decl(mutability: Mutability, ty: Ty<'_>, span: Span) -> LocalDecl<'_> { let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span }; LocalDecl { mutability, @@ -259,7 +259,7 @@ pub struct DropShimElaborator<'a, 'tcx: 'a> { } impl<'a, 'tcx> fmt::Debug for DropShimElaborator<'a, 'tcx> { - fn fmt(&self, _f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { Ok(()) } } diff --git a/src/librustc_mir/transform/add_call_guards.rs b/src/librustc_mir/transform/add_call_guards.rs index 3ea1c8e82ff2b..dab96faaa2a5e 100644 --- a/src/librustc_mir/transform/add_call_guards.rs +++ b/src/librustc_mir/transform/add_call_guards.rs @@ -1,7 +1,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; #[derive(PartialEq)] pub enum AddCallGuards { @@ -40,7 +40,7 @@ impl MirPass for AddCallGuards { } impl AddCallGuards { - pub fn add_call_guards(&self, mir: &mut Mir) { + pub fn add_call_guards(&self, mir: &mut Mir<'_>) { let pred_count: IndexVec<_, _> = mir.predecessors().iter().map(|ps| ps.len()).collect(); diff --git a/src/librustc_mir/transform/add_moves_for_packed_drops.rs b/src/librustc_mir/transform/add_moves_for_packed_drops.rs index 8ec6902cf15fd..1492f0c50a31a 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -2,9 +2,9 @@ use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; -use util; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; +use crate::util; // This pass moves values being dropped that are within a packed // struct to a separate local before dropping them, to ensure that diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index 3d5897bca9f52..7bfcd318afe2d 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -6,7 +6,7 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::*; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct AddRetag; diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index ab8da2f352c1c..b2e1afc519ec5 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -17,7 +17,7 @@ use syntax::symbol::Symbol; use std::ops::Bound; -use util; +use crate::util; pub struct UnsafetyChecker<'a, 'tcx: 'a> { mir: &'a Mir<'tcx>, @@ -458,7 +458,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { } } -pub(crate) fn provide(providers: &mut Providers) { +pub(crate) fn provide(providers: &mut Providers<'_>) { *providers = Providers { unsafety_check_result, unsafe_derive_on_repr_packed, @@ -575,7 +575,7 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D } /// Return the NodeId for an enclosing scope that is also `unsafe` -fn is_enclosed(tcx: TyCtxt, +fn is_enclosed(tcx: TyCtxt<'_, '_, '_>, used_unsafe: &FxHashSet, id: ast::NodeId) -> Option<(String, ast::NodeId)> { let parent_id = tcx.hir().get_parent_node(id); @@ -598,7 +598,9 @@ fn is_enclosed(tcx: TyCtxt, } } -fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet, id: ast::NodeId) { +fn report_unused_unsafe(tcx: TyCtxt<'_, '_, '_>, + used_unsafe: &FxHashSet, + id: ast::NodeId) { let span = tcx.sess.source_map().def_span(tcx.hir().span(id)); let msg = "unnecessary `unsafe` block"; let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg); diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index e6df6b7fd2724..240ef7c8ba42a 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -26,7 +26,7 @@ use rustc::mir::{BasicBlock, FakeReadCause, Local, Location, Mir, Place}; use rustc::mir::{Statement, StatementKind}; use rustc::mir::visit::MutVisitor; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct CleanAscribeUserType; diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index dc556a15cd855..dd1f37a591888 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -18,12 +18,12 @@ use rustc::ty::layout::{ HasTyCtxt, TargetDataLayout, HasDataLayout, }; -use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; -use const_eval::{ +use crate::interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; +use crate::const_eval::{ CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_eval_cx, lazy_const_to_op, }; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct ConstProp; @@ -486,7 +486,7 @@ struct CanConstProp { impl CanConstProp { /// returns true if `local` can be propagated - fn check(mir: &Mir) -> IndexVec { + fn check(mir: &Mir<'_>) -> IndexVec { let mut cpv = CanConstProp { can_const_prop: IndexVec::from_elem(true, &mir.local_decls), found_assignment: IndexVec::from_elem(false, &mir.local_decls), diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index 55e14077c3ed0..4789c35740eb3 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -22,8 +22,8 @@ use rustc::mir::{Constant, Local, LocalKind, Location, Place, Mir, Operand, Rvalue, StatementKind}; use rustc::mir::visit::MutVisitor; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; -use util::def_use::DefUseAnalysis; +use crate::transform::{MirPass, MirSource}; +use crate::util::def_use::DefUseAnalysis; pub struct CopyPropagation; @@ -173,7 +173,7 @@ enum Action<'tcx> { } impl<'tcx> Action<'tcx> { - fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'tcx>) + fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis<'_>, src_place: &Place<'tcx>) -> Option> { // The source must be a local. let src_local = if let Place::Local(local) = *src_place { diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index a2fe9def8eeba..669384e31dac3 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -1,7 +1,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc_data_structures::indexed_vec::Idx; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct Deaggregator; diff --git a/src/librustc_mir/transform/dump_mir.rs b/src/librustc_mir/transform/dump_mir.rs index 8fabb2d11fc46..d7f697a320049 100644 --- a/src/librustc_mir/transform/dump_mir.rs +++ b/src/librustc_mir/transform/dump_mir.rs @@ -8,8 +8,8 @@ use std::io; use rustc::mir::Mir; use rustc::session::config::{OutputFilenames, OutputType}; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; -use util as mir_util; +use crate::transform::{MirPass, MirSource}; +use crate::util as mir_util; pub struct Marker(pub &'static str); @@ -31,7 +31,7 @@ pub struct Disambiguator { } impl fmt::Display for Disambiguator { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let title = if self.is_after { "after" } else { "before" }; write!(formatter, "{}", title) } diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 06e16de8b43bc..4aaa0be7964a4 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -1,10 +1,14 @@ -use dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult}; -use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; -use dataflow::{DataflowResults}; -use dataflow::{on_all_children_bits, on_all_drop_children_bits}; -use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits}; -use dataflow::MoveDataParamEnv; -use dataflow::{self, do_dataflow, DebugFormatted}; +use crate::dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult}; +use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; +use crate::dataflow::{DataflowResults}; +use crate::dataflow::{on_all_children_bits, on_all_drop_children_bits}; +use crate::dataflow::{drop_flag_effects_for_location, on_lookup_result_bits}; +use crate::dataflow::MoveDataParamEnv; +use crate::dataflow::{self, do_dataflow, DebugFormatted}; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; +use crate::util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop}; +use crate::util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode}; use rustc::ty::{self, TyCtxt}; use rustc::ty::layout::VariantIdx; use rustc::mir::*; @@ -13,10 +17,6 @@ use rustc_data_structures::bit_set::BitSet; use std::fmt; use syntax::ast; use syntax_pos::Span; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; -use util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop}; -use util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode}; pub struct ElaborateDrops; @@ -174,7 +174,7 @@ struct Elaborator<'a, 'b: 'a, 'tcx: 'b> { } impl<'a, 'b, 'tcx> fmt::Debug for Elaborator<'a, 'b, 'tcx> { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index b464b7d65e466..b555a2aa83ee3 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -8,7 +8,7 @@ use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::*; use rustc::mir::visit::{MutVisitor, TyContext}; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; struct EraseRegionsVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index f5cc6a43e28b9..9897f9833ca62 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -56,19 +56,19 @@ use rustc::mir::visit::{PlaceContext, Visitor, MutVisitor}; use rustc::ty::{self, TyCtxt, AdtDef, Ty}; use rustc::ty::layout::VariantIdx; use rustc::ty::subst::Substs; -use util::dump_mir; -use util::liveness::{self, IdentityMap}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::bit_set::BitSet; use std::borrow::Cow; use std::iter::once; use std::mem; -use transform::{MirPass, MirSource}; -use transform::simplify; -use transform::no_landing_pads::no_landing_pads; -use dataflow::{do_dataflow, DebugFormatted, state_for_location}; -use dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals}; +use crate::transform::{MirPass, MirSource}; +use crate::transform::simplify; +use crate::transform::no_landing_pads::no_landing_pads; +use crate::dataflow::{do_dataflow, DebugFormatted, state_for_location}; +use crate::dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals}; +use crate::util::dump_mir; +use crate::util::liveness::{self, IdentityMap}; pub struct StateTransform; @@ -581,9 +581,9 @@ fn insert_switch<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, mir: &mut Mir<'tcx>) { - use util::elaborate_drops::{elaborate_drop, Unwind}; - use util::patch::MirPatch; - use shim::DropShimElaborator; + use crate::util::elaborate_drops::{elaborate_drop, Unwind}; + use crate::util::patch::MirPatch; + use crate::shim::DropShimElaborator; // Note that `elaborate_drops` only drops the upvars of a generator, and // this is ok because `open_drop` can only be reached within that own diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 9f0907adc9892..4fddf6f8e09c2 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -13,10 +13,10 @@ use rustc::ty::subst::{Subst,Substs}; use std::collections::VecDeque; use std::iter; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; use super::simplify::{remove_dead_blocks, CfgSimplifier}; -use syntax::{attr}; +use syntax::attr; use rustc_target::spec::abi::Abi; const DEFAULT_THRESHOLD: usize = 50; @@ -426,7 +426,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { // Place could result in two different locations if `f` // writes to `i`. To prevent this we need to create a temporary // borrow of the place and pass the destination as `*temp` instead. - fn dest_needs_borrow(place: &Place) -> bool { + fn dest_needs_borrow(place: &Place<'_>) -> bool { match *place { Place::Projection(ref p) => { match p.elem { diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 2b5e761d1d055..21772e1f1cd5b 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -6,7 +6,7 @@ use rustc::ty::{TyCtxt, TyKind}; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::Idx; use std::mem; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct InstCombine; diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index d14e0f078e6c6..aa248ba7c53df 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -5,8 +5,7 @@ use rustc::middle::lang_items::LangItem; use rustc::mir::*; use rustc::ty::{List, Ty, TyCtxt, TyKind}; use rustc_data_structures::indexed_vec::{Idx}; -use transform::{MirPass, MirSource}; -use syntax; +use crate::transform::{MirPass, MirSource}; pub struct Lower128Bit; @@ -182,7 +181,7 @@ impl RhsKind { } } -fn sign_of_128bit(ty: Ty) -> Option { +fn sign_of_128bit(ty: Ty<'_>) -> Option { match ty.sty { TyKind::Int(syntax::ast::IntTy::I128) => Some(true), TyKind::Uint(syntax::ast::UintTy::U128) => Some(false), diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index a4f011b2e2ec9..cc37a8381f234 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -1,5 +1,5 @@ -use borrow_check::nll::type_check; -use build; +use crate::borrow_check::nll::type_check; +use crate::build; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::mir::{Mir, MirPhase, Promoted}; use rustc::ty::TyCtxt; @@ -38,7 +38,7 @@ pub mod inline; pub mod lower_128bit; pub mod uniform_array_move_out; -pub(crate) fn provide(providers: &mut Providers) { +pub(crate) fn provide(providers: &mut Providers<'_>) { self::qualify_consts::provide(providers); self::check_unsafety::provide(providers); *providers = Providers { diff --git a/src/librustc_mir/transform/no_landing_pads.rs b/src/librustc_mir/transform/no_landing_pads.rs index 2d13b066270a2..15b59d36d363c 100644 --- a/src/librustc_mir/transform/no_landing_pads.rs +++ b/src/librustc_mir/transform/no_landing_pads.rs @@ -4,7 +4,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc::mir::visit::MutVisitor; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct NoLandingPads; diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 1602fc35a2c95..d1dc5cfec994d 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -130,7 +130,8 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> { } } -pub fn collect_temps(mir: &Mir, rpo: &mut ReversePostorder) -> IndexVec { +pub fn collect_temps(mir: &Mir<'_>, + rpo: &mut ReversePostorder<'_, '_>) -> IndexVec { let mut collector = TempCollector { temps: IndexVec::from_elem(TempState::Undefined, &mir.local_decls), span: mir.span, diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 7d1943e21b90d..c786e9438af12 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -27,7 +27,7 @@ use syntax_pos::{Span, DUMMY_SP}; use std::fmt; use std::usize; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; use super::promote_consts::{self, Candidate, TempState}; bitflags! { @@ -84,7 +84,7 @@ enum Mode { } impl fmt::Display for Mode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Mode::Const => write!(f, "constant"), Mode::Static | Mode::StaticMut => write!(f, "static"), @@ -1128,7 +1128,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { mir_const_qualif, ..*providers @@ -1317,7 +1317,7 @@ impl MirPass for QualifyAndPromoteConstants { } } -fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option> { +fn args_required_const(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option> { let attrs = tcx.get_attrs(def_id); let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?; let mut ret = FxHashSet::default(); diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index c8ef2decf2606..4fcb4c10f9e6d 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -1,8 +1,8 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc_data_structures::bit_set::BitSet; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; /// A pass that removes no-op landing pads and replaces jumps to them with /// `None`. This is important because otherwise LLVM generates terrible @@ -34,7 +34,7 @@ impl RemoveNoopLandingPads { fn is_nop_landing_pad( &self, bb: BasicBlock, - mir: &Mir, + mir: &Mir<'_>, nop_landing_pads: &BitSet, ) -> bool { for stmt in &mir[bb].statements { @@ -86,7 +86,7 @@ impl RemoveNoopLandingPads { } } - fn remove_nop_landing_pads(&self, mir: &mut Mir) { + fn remove_nop_landing_pads(&self, mir: &mut Mir<'_>) { // make sure there's a single resume block let resume_block = { let patch = MirPatch::new(mir); diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 36a6279e50320..806c1c1cca457 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -5,18 +5,20 @@ use syntax_pos::Span; use rustc::ty::{self, TyCtxt}; use rustc::mir::{self, Mir, Location}; use rustc_data_structures::bit_set::BitSet; -use transform::{MirPass, MirSource}; - -use dataflow::{do_dataflow, DebugFormatted}; -use dataflow::MoveDataParamEnv; -use dataflow::BitDenotation; -use dataflow::DataflowResults; -use dataflow::{DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces}; -use dataflow::move_paths::{MovePathIndex, LookupResult}; -use dataflow::move_paths::{HasMoveData, MoveData}; -use dataflow; - -use dataflow::has_rustc_mir_with; +use crate::transform::{MirPass, MirSource}; + +use crate::dataflow::{do_dataflow, DebugFormatted}; +use crate::dataflow::MoveDataParamEnv; +use crate::dataflow::BitDenotation; +use crate::dataflow::DataflowResults; +use crate::dataflow::{ + DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces +}; +use crate::dataflow::move_paths::{MovePathIndex, LookupResult}; +use crate::dataflow::move_paths::{HasMoveData, MoveData}; +use crate::dataflow; + +use crate::dataflow::has_rustc_mir_with; pub struct SanityCheck; diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index ed2da98dd5311..90486d1566413 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -34,7 +34,7 @@ use rustc::mir::*; use rustc::mir::visit::{MutVisitor, Visitor, PlaceContext}; use rustc::session::config::DebugInfo; use std::borrow::Cow; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct SimplifyCfg { label: String } @@ -44,7 +44,7 @@ impl SimplifyCfg { } } -pub fn simplify_cfg(mir: &mut Mir) { +pub fn simplify_cfg(mir: &mut Mir<'_>) { CfgSimplifier::new(mir).simplify(); remove_dead_blocks(mir); @@ -263,7 +263,7 @@ impl<'a, 'tcx: 'a> CfgSimplifier<'a, 'tcx> { } } -pub fn remove_dead_blocks(mir: &mut Mir) { +pub fn remove_dead_blocks(mir: &mut Mir<'_>) { let mut seen = BitSet::new_empty(mir.basic_blocks().len()); for (bb, _) in traversal::preorder(mir) { seen.insert(bb.index()); diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index abaea70946383..0dc89bfe14709 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -2,7 +2,7 @@ use rustc::ty::{TyCtxt, ParamEnv}; use rustc::mir::*; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; use std::borrow::Cow; diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 5ab9669baaca0..09918436817f3 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -30,9 +30,9 @@ use rustc::ty; use rustc::ty::TyCtxt; use rustc::mir::*; use rustc::mir::visit::{Visitor, PlaceContext, NonUseContext}; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; use rustc_data_structures::indexed_vec::{IndexVec}; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; pub struct UniformArrayMoveOut; diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 7ad73aaa3f9a9..fd694ddbbd19f 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -12,7 +12,7 @@ pub enum Origin { } impl fmt::Display for Origin { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { // If the user passed `-Z borrowck=compare`, then include // origin info as part of the error report, // otherwise @@ -437,7 +437,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { fn cannot_move_out_of_interior_noncopy( self, move_from_span: Span, - ty: ty::Ty, + ty: ty::Ty<'_>, is_index: Option, o: Origin, ) -> DiagnosticBuilder<'cx> { @@ -464,7 +464,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { fn cannot_move_out_of_interior_of_drop( self, move_from_span: Span, - container_ty: ty::Ty, + container_ty: ty::Ty<'_>, o: Origin, ) -> DiagnosticBuilder<'cx> { let mut err = struct_span_err!( diff --git a/src/librustc_mir/util/def_use.rs b/src/librustc_mir/util/def_use.rs index 057a7c8be88c9..3b9d7c3612a57 100644 --- a/src/librustc_mir/util/def_use.rs +++ b/src/librustc_mir/util/def_use.rs @@ -107,7 +107,7 @@ impl<'tcx> Info<'tcx> { pub fn defs_not_including_drop( &self, - ) -> iter::Filter>, fn(&&Use<'tcx>) -> bool> { + ) -> iter::Filter>, fn(&&Use<'tcx>) -> bool> { self.defs_and_uses.iter().filter(|place_use| { place_use.context.is_mutating_use() && !place_use.context.is_drop() }) diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 8b55a4424ae29..23e92b3e933d3 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -8,7 +8,7 @@ use rustc::ty::layout::VariantIdx; use rustc::ty::subst::Substs; use rustc::ty::util::IntTypeExt; use rustc_data_structures::indexed_vec::Idx; -use util::patch::MirPatch; +use crate::util::patch::MirPatch; use std::u32; diff --git a/src/librustc_mir/util/graphviz.rs b/src/librustc_mir/util/graphviz.rs index b68898f713021..e93b96c12161c 100644 --- a/src/librustc_mir/util/graphviz.rs +++ b/src/librustc_mir/util/graphviz.rs @@ -1,4 +1,3 @@ -use dot; use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::ty::TyCtxt; @@ -24,7 +23,7 @@ pub fn write_mir_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, /// Write a graphviz DOT graph of the MIR. pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, def_id: DefId, - mir: &Mir, + mir: &Mir<'_>, w: &mut W) -> io::Result<()> where W: Write { @@ -58,7 +57,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, /// `init` and `fini` are callbacks for emitting additional rows of /// data (using HTML enclosed with `` in the emitted text). pub fn write_node_label(block: BasicBlock, - mir: &Mir, + mir: &Mir<'_>, w: &mut W, num_cols: u32, init: INIT, @@ -100,7 +99,7 @@ pub fn write_node_label(block: BasicBlock, } /// Write a graphviz DOT node for the given basic block. -fn write_node(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> { +fn write_node(block: BasicBlock, mir: &Mir<'_>, w: &mut W) -> io::Result<()> { // Start a new node with the label to follow, in one of DOT's pseudo-HTML tables. write!(w, r#" {} [shape="none", label=<"#, node(block))?; write_node_label(block, mir, w, 1, |_| Ok(()), |_| Ok(()))?; @@ -109,7 +108,7 @@ fn write_node(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<( } /// Write graphviz DOT edges with labels between the given basic block and all of its successors. -fn write_edges(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> { +fn write_edges(source: BasicBlock, mir: &Mir<'_>, w: &mut W) -> io::Result<()> { let terminator = mir[source].terminator(); let labels = terminator.kind.fmt_successor_labels(); @@ -125,7 +124,7 @@ fn write_edges(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result /// all the variables and temporaries. fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId, - mir: &Mir, + mir: &Mir<'_>, w: &mut W) -> io::Result<()> { write!(w, " label= = BitSet; diff --git a/src/librustc_mir/util/patch.rs b/src/librustc_mir/util/patch.rs index 5a1f94677a1d4..366cd71f6d4e9 100644 --- a/src/librustc_mir/util/patch.rs +++ b/src/librustc_mir/util/patch.rs @@ -170,14 +170,14 @@ impl<'tcx> MirPatch<'tcx> { } } - pub fn source_info_for_index(data: &BasicBlockData, loc: Location) -> SourceInfo { + pub fn source_info_for_index(data: &BasicBlockData<'_>, loc: Location) -> SourceInfo { match data.statements.get(loc.statement_index) { Some(stmt) => stmt.source_info, None => data.terminator().source_info } } - pub fn source_info_for_location(&self, mir: &Mir, loc: Location) -> SourceInfo { + pub fn source_info_for_location(&self, mir: &Mir<'_>, loc: Location) -> SourceInfo { let data = match loc.block.index().checked_sub(mir.basic_blocks().len()) { Some(new) => &self.new_blocks[new], None => &mir[loc.block] diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 3a15356806a97..6e1ec31c9372f 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -12,7 +12,7 @@ use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use super::graphviz::write_mir_fn_graphviz; -use transform::MirSource; +use crate::transform::MirSource; const INDENT: &str = " "; /// Alignment for lining up comments following MIR statements @@ -446,7 +446,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for ExtraComments<'cx, 'gcx, 'tcx> { } } -fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String { +fn comment(tcx: TyCtxt<'_, '_, '_>, SourceInfo { span, scope }: SourceInfo) -> String { format!( "scope {} at {}", scope.index(), @@ -458,8 +458,8 @@ fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String { /// /// Returns the total number of variables printed. fn write_scope_tree( - tcx: TyCtxt, - mir: &Mir, + tcx: TyCtxt<'_, '_, '_>, + mir: &Mir<'_>, scope_tree: &FxHashMap>, w: &mut dyn Write, parent: SourceScope, @@ -529,7 +529,7 @@ fn write_scope_tree( pub fn write_mir_intro<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, src: MirSource, - mir: &Mir, + mir: &Mir<'_>, w: &mut dyn Write, ) -> io::Result<()> { write_mir_sig(tcx, src, mir, w)?; @@ -568,7 +568,12 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>( Ok(()) } -fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> io::Result<()> { +fn write_mir_sig( + tcx: TyCtxt<'_, '_, '_>, + src: MirSource, + mir: &Mir<'_>, + w: &mut dyn Write, +) -> io::Result<()> { let id = tcx.hir().as_local_node_id(src.def_id).unwrap(); let body_owner_kind = tcx.hir().body_owner_kind(id); match (body_owner_kind, src.promoted) { @@ -614,7 +619,7 @@ fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> i Ok(()) } -fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { +fn write_temp_decls(mir: &Mir<'_>, w: &mut dyn Write) -> io::Result<()> { // Compiler-introduced temporary types. for temp in mir.temps_iter() { writeln!( @@ -630,7 +635,7 @@ fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { Ok(()) } -fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { +fn write_user_type_annotations(mir: &Mir<'_>, w: &mut dyn Write) -> io::Result<()> { if !mir.user_type_annotations.is_empty() { writeln!(w, "| User Type Annotations")?; } @@ -643,7 +648,7 @@ fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { Ok(()) } -pub fn dump_mir_def_ids(tcx: TyCtxt, single: Option) -> Vec { +pub fn dump_mir_def_ids(tcx: TyCtxt<'_, '_, '_>, single: Option) -> Vec { if let Some(i) = single { vec![i] } else { From efa8fb006e6e7d0d70f1e65810b69993df44006c Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 16:44:15 +0900 Subject: [PATCH 09/21] error_index_generator => 2018 --- src/tools/error_index_generator/Cargo.toml | 1 + src/tools/error_index_generator/main.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/error_index_generator/Cargo.toml b/src/tools/error_index_generator/Cargo.toml index 7f8783c9d89be..116be234f3ceb 100644 --- a/src/tools/error_index_generator/Cargo.toml +++ b/src/tools/error_index_generator/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "error_index_generator" version = "0.0.0" +edition = "2018" [dependencies] rustdoc = { path = "../../librustdoc" } diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 72cfd7d5e58e9..ef045495a0864 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -1,8 +1,9 @@ #![feature(rustc_private)] +#![deny(rust_2018_idioms)] + extern crate env_logger; extern crate syntax; -extern crate rustdoc; extern crate serialize as rustc_serialize; use std::collections::BTreeMap; From 7815c9b1c80c96d80b2054a5bc182bc628473cfd Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 19:56:52 +0900 Subject: [PATCH 10/21] Revert removed #![feature(nll)] --- src/librustc_mir/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 72a13c791cec0..afd33a51a6a3b 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -4,6 +4,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ +#![feature(nll)] #![feature(in_band_lifetimes)] #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] From d2514523db8d02fedc6f5d88545b96c55dd26a43 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:08:08 +0900 Subject: [PATCH 11/21] Use real try blocks --- src/librustc_mir/borrow_check/nll/mod.rs | 4 ++-- src/librustc_mir/lib.rs | 9 +-------- src/librustc_mir/util/pretty.rs | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index 128d54c9f49d7..1fca104cd3825 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -254,14 +254,14 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( ); // Also dump the inference graph constraints as a graphviz file. - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = pretty::create_dump_file(infcx.tcx, "regioncx.all.dot", None, "nll", &0, source)?; regioncx.dump_graphviz_raw_constraints(&mut file)?; }; // Also dump the inference graph constraints as a graphviz file. - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = pretty::create_dump_file(infcx.tcx, "regioncx.scc.dot", None, "nll", &0, source)?; regioncx.dump_graphviz_scc_constraints(&mut file)?; diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index afd33a51a6a3b..143104a0feec1 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -26,6 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(slice_concat_ext)] #![feature(try_from)] #![feature(reverse_bits)] +#![feature(try_blocks)] #![recursion_limit="256"] @@ -43,14 +44,6 @@ extern crate serialize as rustc_serialize; // used by deriving #[macro_use] extern crate syntax; -// Once we can use edition 2018 in the compiler, -// replace this with real try blocks. -macro_rules! try_block { - ($($inside:tt)*) => ( - (||{ ::std::ops::Try::from_ok({ $($inside)* }) })() - ) -} - mod diagnostics; mod borrow_check; diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6e1ec31c9372f..2e1fc756833b8 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -131,7 +131,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>( ) where F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>, { - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = create_dump_file(tcx, "mir", pass_num, pass_name, disambiguator, source)?; writeln!(file, "// MIR for `{}`", node_path)?; writeln!(file, "// source = {:?}", source)?; @@ -148,7 +148,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>( }; if tcx.sess.opts.debugging_opts.dump_mir_graphviz { - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = create_dump_file(tcx, "dot", pass_num, pass_name, disambiguator, source)?; write_mir_fn_graphviz(tcx, source.def_id, mir, &mut file)?; From c9bc85ecf100da1358ff2c2545fe5fa6caa506c2 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:13:12 +0900 Subject: [PATCH 12/21] Remove #[macro_use] extern crate bitflags --- src/librustc_mir/lib.rs | 2 -- src/librustc_mir/transform/qualify_consts.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 143104a0feec1..909f96956695d 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -33,8 +33,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#[macro_use] -extern crate bitflags; #[macro_use] extern crate log; #[macro_use] extern crate rustc; diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index c786e9438af12..ab4e3ad23f69a 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -30,7 +30,7 @@ use std::usize; use crate::transform::{MirPass, MirSource}; use super::promote_consts::{self, Candidate, TempState}; -bitflags! { +bitflags::bitflags! { // Borrows of temporaries can be promoted only if // they have none of these qualifications, with // the exception of `STATIC_REF` (in statics only). From 6140134b6f2004a4d331821278c8b17f47a51f25 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:35:41 +0900 Subject: [PATCH 13/21] librustc_lint => 2018 --- src/librustc_lint/Cargo.toml | 1 + src/librustc_lint/builtin.rs | 108 +++++++++++++------------ src/librustc_lint/diagnostics.rs | 2 + src/librustc_lint/lib.rs | 10 +-- src/librustc_lint/nonstandard_style.rs | 39 ++++----- src/librustc_lint/types.rs | 19 +++-- src/librustc_lint/unused.rs | 29 ++++--- 7 files changed, 108 insertions(+), 100 deletions(-) diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index 7fb7a06ea1ad5..82f7118df2d0b 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_lint" version = "0.0.0" +edition = "2018" [lib] name = "rustc_lint" diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 7c25d8d8b793f..cbcc7f3574d03 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -21,6 +21,7 @@ use rustc::hir::def::Def; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::ty::{self, Ty}; +use rustc::{lint, util}; use hir::Node; use util::nodemap::NodeSet; use lint::{LateContext, LintContext, LintArray}; @@ -42,10 +43,13 @@ use syntax::symbol::keywords; use syntax::errors::{Applicability, DiagnosticBuilder}; use syntax::print::pprust::expr_to_string; use syntax::visit::FnKind; +use syntax::struct_span_err; use rustc::hir::{self, GenericParamKind, PatKind}; -use nonstandard_style::{MethodLateContext, method_context}; +use crate::nonstandard_style::{MethodLateContext, method_context}; + +use log::debug; // hardwired lints from librustc pub use lint::builtin::*; @@ -70,7 +74,7 @@ impl LintPass for WhileTrue { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue { - fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { if let hir::ExprKind::While(ref cond, ..) = e.node { if let hir::ExprKind::Lit(ref lit) = cond.node { if let ast::LitKind::Bool(true) = lit.node { @@ -102,7 +106,7 @@ declare_lint! { pub struct BoxPointers; impl BoxPointers { - fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext, span: Span, ty: Ty) { + fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext<'_, '_>, span: Span, ty: Ty<'_>) { for leaf_ty in ty.walk() { if leaf_ty.is_box() { let m = format!("type uses owned (Box type) pointers: {}", ty); @@ -123,7 +127,7 @@ impl LintPass for BoxPointers { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { match it.node { hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) | @@ -150,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { } } - fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { let ty = cx.tables.node_id_to_type(e.hir_id); self.check_heap_type(cx, e.span, ty); } @@ -176,7 +180,7 @@ impl LintPass for NonShorthandFieldPatterns { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns { - fn check_pat(&mut self, cx: &LateContext, pat: &hir::Pat) { + fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) { if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.node { let variant = cx.tables.pat_ty(pat).ty_adt_def() .expect("struct pattern type is not an ADT") @@ -233,7 +237,7 @@ impl LintPass for UnsafeCode { } impl UnsafeCode { - fn report_unsafe(&self, cx: &EarlyContext, span: Span, desc: &'static str) { + fn report_unsafe(&self, cx: &EarlyContext<'_>, span: Span, desc: &'static str) { // This comes from a macro that has #[allow_internal_unsafe]. if span.allows_unsafe() { return; @@ -244,7 +248,7 @@ impl UnsafeCode { } impl EarlyLintPass for UnsafeCode { - fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) { + fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) { if attr.check_name("allow_internal_unsafe") { self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining \ macros using unsafe without triggering \ @@ -252,7 +256,7 @@ impl EarlyLintPass for UnsafeCode { } } - fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) { + fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { if let ast::ExprKind::Block(ref blk, _) = e.node { // Don't warn about generated blocks, that'll just pollute the output. if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) { @@ -261,7 +265,7 @@ impl EarlyLintPass for UnsafeCode { } } - fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { + fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) { match it.node { ast::ItemKind::Trait(_, ast::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait") @@ -276,8 +280,8 @@ impl EarlyLintPass for UnsafeCode { } fn check_fn(&mut self, - cx: &EarlyContext, - fk: FnKind, + cx: &EarlyContext<'_>, + fk: FnKind<'_>, _: &ast::FnDecl, span: Span, _: ast::NodeId) { @@ -296,7 +300,7 @@ impl EarlyLintPass for UnsafeCode { } } - fn check_trait_item(&mut self, cx: &EarlyContext, item: &ast::TraitItem) { + fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::TraitItem) { if let ast::TraitItemKind::Method(ref sig, None) = item.node { if sig.header.unsafety == ast::Unsafety::Unsafe { self.report_unsafe(cx, item.span, "declaration of an `unsafe` method") @@ -354,7 +358,7 @@ impl MissingDoc { } fn check_missing_docs_attrs(&self, - cx: &LateContext, + cx: &LateContext<'_, '_>, id: Option, attrs: &[ast::Attribute], sp: Span, @@ -399,7 +403,7 @@ impl LintPass for MissingDoc { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { - fn enter_lint_attrs(&mut self, _: &LateContext, attrs: &[ast::Attribute]) { + fn enter_lint_attrs(&mut self, _: &LateContext<'_, '_>, attrs: &[ast::Attribute]) { let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| { attr.check_name("doc") && @@ -411,11 +415,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { self.doc_hidden_stack.push(doc_hidden); } - fn exit_lint_attrs(&mut self, _: &LateContext, _attrs: &[ast::Attribute]) { + fn exit_lint_attrs(&mut self, _: &LateContext<'_, '_>, _attrs: &[ast::Attribute]) { self.doc_hidden_stack.pop().expect("empty doc_hidden_stack"); } - fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) { + fn check_crate(&mut self, cx: &LateContext<'_, '_>, krate: &hir::Crate) { self.check_missing_docs_attrs(cx, None, &krate.attrs, krate.span, "crate"); for macro_def in &krate.exported_macros { @@ -428,7 +432,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } } - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { let desc = match it.node { hir::ItemKind::Fn(..) => "a function", hir::ItemKind::Mod(..) => "a module", @@ -473,7 +477,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { self.check_missing_docs_attrs(cx, Some(it.id), &it.attrs, it.span, desc); } - fn check_trait_item(&mut self, cx: &LateContext, trait_item: &hir::TraitItem) { + fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, trait_item: &hir::TraitItem) { if self.private_traits.contains(&trait_item.id) { return; } @@ -491,7 +495,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { desc); } - fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) { + fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) { // If the method is an impl for a trait, don't doc. if method_context(cx, impl_item.id) == MethodLateContext::TraitImpl { return; @@ -510,7 +514,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { desc); } - fn check_struct_field(&mut self, cx: &LateContext, sf: &hir::StructField) { + fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField) { if !sf.is_positional() { self.check_missing_docs_attrs(cx, Some(sf.id), @@ -520,7 +524,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } } - fn check_variant(&mut self, cx: &LateContext, v: &hir::Variant, _: &hir::Generics) { + fn check_variant(&mut self, cx: &LateContext<'_, '_>, v: &hir::Variant, _: &hir::Generics) { self.check_missing_docs_attrs(cx, Some(v.node.data.id()), &v.node.attrs, @@ -549,7 +553,7 @@ impl LintPass for MissingCopyImplementations { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { - fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { if !cx.access_levels.is_reachable(item.id) { return; } @@ -620,7 +624,7 @@ impl LintPass for MissingDebugImplementations { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { - fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { if !cx.access_levels.is_reachable(item.id) { return; } @@ -681,7 +685,7 @@ impl LintPass for AnonymousParameters { } impl EarlyLintPass for AnonymousParameters { - fn check_trait_item(&mut self, cx: &EarlyContext, it: &ast::TraitItem) { + fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) { match it.node { ast::TraitItemKind::Method(ref sig, _) => { for arg in sig.decl.inputs.iter() { @@ -749,7 +753,7 @@ impl LintPass for DeprecatedAttr { } impl EarlyLintPass for DeprecatedAttr { - fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) { + fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) { for &&(n, _, _, ref g) in &self.depr_attrs { if attr.name() == n { if let &AttributeGate::Gated(Stability::Deprecated(link, suggestion), @@ -804,15 +808,15 @@ impl UnusedDocComment { } impl EarlyLintPass for UnusedDocComment { - fn check_local(&mut self, cx: &EarlyContext, decl: &ast::Local) { + fn check_local(&mut self, cx: &EarlyContext<'_>, decl: &ast::Local) { self.warn_if_doc(decl.attrs.iter(), cx); } - fn check_arm(&mut self, cx: &EarlyContext, arm: &ast::Arm) { + fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) { self.warn_if_doc(arm.attrs.iter(), cx); } - fn check_expr(&mut self, cx: &EarlyContext, expr: &ast::Expr) { + fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) { self.warn_if_doc(expr.attrs.iter(), cx); } } @@ -837,7 +841,7 @@ impl LintPass for PluginAsLibrary { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { if cx.tcx.plugin_registrar_fn(LOCAL_CRATE).is_some() { // We're compiling a plugin; it's fine to link other plugins. return; @@ -894,7 +898,7 @@ impl LintPass for InvalidNoMangleItems { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { match it.node { hir::ItemKind::Fn(.., ref generics, _) => { if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, "no_mangle") { @@ -968,7 +972,7 @@ impl LintPass for MutableTransmutes { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { - fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) { use rustc_target::spec::abi::Abi::RustIntrinsic; let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ @@ -1004,7 +1008,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { None } - fn def_id_is_transmute(cx: &LateContext, def_id: DefId) -> bool { + fn def_id_is_transmute(cx: &LateContext<'_, '_>, def_id: DefId) -> bool { cx.tcx.fn_sig(def_id).abi() == RustIntrinsic && cx.tcx.item_name(def_id) == "transmute" } @@ -1032,7 +1036,7 @@ impl LintPass for UnstableFeatures { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnstableFeatures { - fn check_attribute(&mut self, ctx: &LateContext, attr: &ast::Attribute) { + fn check_attribute(&mut self, ctx: &LateContext<'_, '_>, attr: &ast::Attribute) { if attr.check_name("feature") { if let Some(items) = attr.meta_item_list() { for item in items { @@ -1063,7 +1067,7 @@ impl LintPass for UnionsWithDropFields { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { - fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) { + fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) { if let hir::ItemKind::Union(ref vdata, _) = item.node { for field in vdata.fields() { let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id)); @@ -1099,7 +1103,7 @@ impl LintPass for UnreachablePub { } impl UnreachablePub { - fn perform_lint(&self, cx: &LateContext, what: &str, id: ast::NodeId, + fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: ast::NodeId, vis: &hir::Visibility, span: Span, exportable: bool) { let mut applicability = Applicability::MachineApplicable; match vis.node { @@ -1134,20 +1138,20 @@ impl UnreachablePub { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub { - fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { self.perform_lint(cx, "item", item.id, &item.vis, item.span, true); } - fn check_foreign_item(&mut self, cx: &LateContext, foreign_item: &hir::ForeignItem) { + fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, foreign_item: &hir::ForeignItem) { self.perform_lint(cx, "item", foreign_item.id, &foreign_item.vis, foreign_item.span, true); } - fn check_struct_field(&mut self, cx: &LateContext, field: &hir::StructField) { + fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) { self.perform_lint(cx, "field", field.id, &field.vis, field.span, false); } - fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) { + fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) { self.perform_lint(cx, "item", impl_item.id, &impl_item.vis, impl_item.span, false); } } @@ -1193,7 +1197,7 @@ impl TypeAliasBounds { } } - fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder) { + fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder<'_>) { // Access to associates types should use `::Assoc`, which does not need a // bound. Let's see if this type does that. @@ -1225,7 +1229,7 @@ impl TypeAliasBounds { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { - fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { let (ty, type_alias_generics) = match item.node { hir::ItemKind::Ty(ref ty, ref generics) => (&*ty, generics), _ => return, @@ -1281,7 +1285,7 @@ impl LintPass for UnusedBrokenConst { lint_array!() } } -fn check_const(cx: &LateContext, body_id: hir::BodyId) { +fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) { let def_id = cx.tcx.hir().body_owner_def_id(body_id); let is_static = cx.tcx.is_static(def_id).is_some(); let param_env = if is_static { @@ -1299,7 +1303,7 @@ fn check_const(cx: &LateContext, body_id: hir::BodyId) { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { match it.node { hir::ItemKind::Const(_, body_id) => { check_const(cx, body_id); @@ -1429,7 +1433,7 @@ impl LintPass for EllipsisInclusiveRangePatterns { } impl EarlyLintPass for EllipsisInclusiveRangePatterns { - fn check_pat(&mut self, cx: &EarlyContext, pat: &ast::Pat, visit_subpats: &mut bool) { + fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat, visit_subpats: &mut bool) { use self::ast::{PatKind, RangeEnd, RangeSyntax::DotDotDot}; /// If `pat` is a `...` pattern, return the start and end of the range, as well as the span @@ -1507,7 +1511,7 @@ impl LintPass for UnnameableTestItems { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestItems { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { if self.items_nameable { if let hir::ItemKind::Mod(..) = it.node {} else { @@ -1526,7 +1530,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestItems { } } - fn check_item_post(&mut self, _cx: &LateContext, it: &hir::Item) { + fn check_item_post(&mut self, _cx: &LateContext<'_, '_>, it: &hir::Item) { if !self.items_nameable && self.boundary == it.id { self.items_nameable = true; } @@ -1554,7 +1558,7 @@ impl LintPass for KeywordIdents { } impl KeywordIdents { - fn check_tokens(&mut self, cx: &EarlyContext, tokens: TokenStream) { + fn check_tokens(&mut self, cx: &EarlyContext<'_>, tokens: TokenStream) { for tt in tokens.into_trees() { match tt { TokenTree::Token(span, tok) => match tok.ident() { @@ -1576,13 +1580,13 @@ impl KeywordIdents { } impl EarlyLintPass for KeywordIdents { - fn check_mac_def(&mut self, cx: &EarlyContext, mac_def: &ast::MacroDef, _id: ast::NodeId) { + fn check_mac_def(&mut self, cx: &EarlyContext<'_>, mac_def: &ast::MacroDef, _id: ast::NodeId) { self.check_tokens(cx, mac_def.stream()); } - fn check_mac(&mut self, cx: &EarlyContext, mac: &ast::Mac) { + fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) { self.check_tokens(cx, mac.node.tts.clone().into()); } - fn check_ident(&mut self, cx: &EarlyContext, ident: ast::Ident) { + fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) { let ident_str = &ident.as_str()[..]; let cur_edition = cx.sess.edition(); let is_raw_ident = |ident: ast::Ident| { @@ -1665,7 +1669,7 @@ impl LintPass for ExplicitOutlivesRequirements { impl ExplicitOutlivesRequirements { fn collect_outlives_bound_spans( &self, - cx: &LateContext, + cx: &LateContext<'_, '_>, item_def_id: DefId, param_name: &str, bounds: &hir::GenericBounds, diff --git a/src/librustc_lint/diagnostics.rs b/src/librustc_lint/diagnostics.rs index 9a608e4fef08b..3165673111cca 100644 --- a/src/librustc_lint/diagnostics.rs +++ b/src/librustc_lint/diagnostics.rs @@ -1,3 +1,5 @@ +use syntax::{register_diagnostic, register_diagnostics}; + register_diagnostics! { E0721, // `await` keyword } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 6607951d2cd14..fa9d8ce6cb7c4 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -21,15 +21,10 @@ #![recursion_limit="256"] -#[macro_use] -extern crate syntax; +#![deny(rust_2018_idioms)] + #[macro_use] extern crate rustc; -#[macro_use] -extern crate log; -extern crate rustc_target; -extern crate syntax_pos; -extern crate rustc_data_structures; mod diagnostics; mod nonstandard_style; @@ -51,7 +46,6 @@ use rustc::lint::builtin::{ parser::ILL_FORMED_ATTRIBUTE_INPUT, }; use rustc::session; -use rustc::util; use rustc::hir; use syntax::ast; diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index ae2ed28104e5b..2dbafc7ede2a2 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -1,6 +1,7 @@ use rustc::hir::{self, GenericParamKind, PatKind}; use rustc::hir::def::Def; use rustc::hir::intravisit::FnKind; +use rustc::lint; use rustc::ty; use rustc_target::spec::abi::Abi; use lint::{EarlyContext, LateContext, LintContext, LintArray}; @@ -17,7 +18,7 @@ pub enum MethodLateContext { PlainImpl, } -pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext { +pub fn method_context(cx: &LateContext<'_, '_>, id: ast::NodeId) -> MethodLateContext { let def_id = cx.tcx.hir().local_def_id(id); let item = cx.tcx.associated_item(def_id); match item.container { @@ -41,7 +42,7 @@ declare_lint! { pub struct NonCamelCaseTypes; impl NonCamelCaseTypes { - fn check_case(&self, cx: &EarlyContext, sort: &str, ident: &Ident) { + fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) { fn char_has_case(c: char) -> bool { c.is_lowercase() || c.is_uppercase() } @@ -115,7 +116,7 @@ impl LintPass for NonCamelCaseTypes { } impl EarlyLintPass for NonCamelCaseTypes { - fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { + fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) { let has_repr_c = it.attrs .iter() .any(|attr| { @@ -138,11 +139,11 @@ impl EarlyLintPass for NonCamelCaseTypes { } } - fn check_variant(&mut self, cx: &EarlyContext, v: &ast::Variant, _: &ast::Generics) { + fn check_variant(&mut self, cx: &EarlyContext<'_>, v: &ast::Variant, _: &ast::Generics) { self.check_case(cx, "variant", &v.node.ident); } - fn check_generic_param(&mut self, cx: &EarlyContext, param: &ast::GenericParam) { + fn check_generic_param(&mut self, cx: &EarlyContext<'_>, param: &ast::GenericParam) { if let ast::GenericParamKind::Type { .. } = param.kind { self.check_case(cx, "type parameter", ¶m.ident); } @@ -190,7 +191,7 @@ impl NonSnakeCase { } /// Checks if a given identifier is snake case, and reports a diagnostic if not. - fn check_snake_case(&self, cx: &LateContext, sort: &str, ident: &Ident) { + fn check_snake_case(&self, cx: &LateContext<'_, '_>, sort: &str, ident: &Ident) { fn is_snake_case(ident: &str) -> bool { if ident.is_empty() { return true; @@ -249,7 +250,7 @@ impl LintPass for NonSnakeCase { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { - fn check_crate(&mut self, cx: &LateContext, cr: &hir::Crate) { + fn check_crate(&mut self, cx: &LateContext<'_, '_>, cr: &hir::Crate) { let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name { Some(Ident::from_str(name)) } else { @@ -286,7 +287,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } } - fn check_generic_param(&mut self, cx: &LateContext, param: &hir::GenericParam) { + fn check_generic_param(&mut self, cx: &LateContext<'_, '_>, param: &hir::GenericParam) { if let GenericParamKind::Lifetime { .. } = param.kind { self.check_snake_case(cx, "lifetime", ¶m.name.ident()); } @@ -294,8 +295,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { fn check_fn( &mut self, - cx: &LateContext, - fk: FnKind, + cx: &LateContext<'_, '_>, + fk: FnKind<'_>, _: &hir::FnDecl, _: &hir::Body, _: Span, @@ -324,13 +325,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } } - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { if let hir::ItemKind::Mod(_) = it.node { self.check_snake_case(cx, "module", &it.ident); } } - fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) { + fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem) { if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node { self.check_snake_case(cx, "trait method", &item.ident); for param_name in pnames { @@ -339,7 +340,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } } - fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) { + fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) { if let &PatKind::Binding(_, _, _, ident, _) = &p.node { self.check_snake_case(cx, "variable", &ident); } @@ -347,7 +348,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { fn check_struct_def( &mut self, - cx: &LateContext, + cx: &LateContext<'_, '_>, s: &hir::VariantData, _: ast::Name, _: &hir::Generics, @@ -369,7 +370,7 @@ declare_lint! { pub struct NonUpperCaseGlobals; impl NonUpperCaseGlobals { - fn check_upper_case(cx: &LateContext, sort: &str, ident: &Ident) { + fn check_upper_case(cx: &LateContext<'_, '_>, sort: &str, ident: &Ident) { let name = &ident.name.as_str(); if name.chars().any(|c| c.is_lowercase()) { @@ -399,7 +400,7 @@ impl LintPass for NonUpperCaseGlobals { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { match it.node { hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, "no_mangle") => { NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident); @@ -411,19 +412,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { } } - fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) { + fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, ti: &hir::TraitItem) { if let hir::TraitItemKind::Const(..) = ti.node { NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident); } } - fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) { + fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) { if let hir::ImplItemKind::Const(..) = ii.node { NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident); } } - fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) { + fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) { // Lint for constants that look like binding identifiers (#7526) if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node { if let Def::Const(..) = path.def { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 4abd55b7e31f7..f6b7ccfe2ecd8 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -4,6 +4,7 @@ use rustc::hir::Node; use rustc::ty::subst::Substs; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; use rustc::ty::layout::{self, IntegerExt, LayoutOf, VariantIdx}; +use rustc::{lint, util}; use rustc_data_structures::indexed_vec::Idx; use util::nodemap::FxHashSet; use lint::{LateContext, LintContext, LintArray}; @@ -23,6 +24,8 @@ use rustc::hir; use rustc::mir::interpret::{sign_extend, truncate}; +use log::debug; + declare_lint! { UNUSED_COMPARISONS, Warn, @@ -241,7 +244,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } } - fn check_limits(cx: &LateContext, + fn check_limits(cx: &LateContext<'_, '_>, binop: hir::BinOp, l: &hir::Expr, r: &hir::Expr) @@ -298,7 +301,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } } - fn get_bin_hex_repr(cx: &LateContext, lit: &ast::Lit) -> Option { + fn get_bin_hex_repr(cx: &LateContext<'_, '_>, lit: &ast::Lit) -> Option { let src = cx.sess().source_map().span_to_snippet(lit.span).ok()?; let firstch = src.chars().next()?; @@ -320,7 +323,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { // // No suggestion for: `isize`, `usize`. fn get_type_suggestion<'a>( - t: &ty::TyKind, + t: &ty::TyKind<'_>, val: u128, negative: bool, ) -> Option { @@ -364,9 +367,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } fn report_bin_hex_error( - cx: &LateContext, + cx: &LateContext<'_, '_>, expr: &hir::Expr, - ty: ty::TyKind, + ty: ty::TyKind<'_>, repr_str: String, val: u128, negative: bool, @@ -481,7 +484,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { fn check_type_for_ffi(&self, cache: &mut FxHashSet>, ty: Ty<'tcx>) -> FfiResult<'tcx> { - use self::FfiResult::*; + use FfiResult::*; let cx = self.cx.tcx; @@ -799,7 +802,7 @@ impl LintPass for ImproperCTypes { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { - fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) { + fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem) { let mut vis = ImproperCTypesVisitor { cx }; let abi = cx.tcx.hir().get_foreign_abi(it.id); if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic { @@ -829,7 +832,7 @@ impl LintPass for VariantSizeDifferences { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { if let hir::ItemKind::Enum(ref enum_definition, _) = it.node { let item_def_id = cx.tcx.hir().local_def_id(it.id); let t = cx.tcx.type_of(item_def_id); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index acf5da1e1886a..407e684293515 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -1,5 +1,6 @@ use rustc::hir::def::Def; use rustc::hir::def_id::DefId; +use rustc::lint; use rustc::ty; use rustc::ty::adjustment; use lint::{LateContext, EarlyContext, LintContext, LintArray}; @@ -16,6 +17,8 @@ use syntax_pos::Span; use rustc::hir; +use log::debug; + declare_lint! { pub UNUSED_MUST_USE, Warn, @@ -43,7 +46,7 @@ impl LintPass for UnusedResults { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { - fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { + fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { let expr = match s.node { hir::StmtKind::Semi(ref expr) => &**expr, _ => return, @@ -168,7 +171,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { } fn check_must_use( - cx: &LateContext, + cx: &LateContext<'_, '_>, def_id: DefId, sp: Span, descr_pre_path: &str, @@ -212,7 +215,7 @@ impl LintPass for PathStatements { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { - fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { + fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { if let hir::StmtKind::Semi(ref expr) = s.node { if let hir::ExprKind::Path(_) = expr.node { cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect"); @@ -241,7 +244,7 @@ impl LintPass for UnusedAttributes { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes { - fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) { + fn check_attribute(&mut self, cx: &LateContext<'_, '_>, attr: &ast::Attribute) { debug!("checking attribute: {:?}", attr); // Note that check_name() marks the attribute as used if it matches. for &(name, ty, ..) in BUILTIN_ATTRIBUTES { @@ -303,7 +306,7 @@ pub struct UnusedParens; impl UnusedParens { fn check_unused_parens_expr(&self, - cx: &EarlyContext, + cx: &EarlyContext<'_>, value: &ast::Expr, msg: &str, followed_by_block: bool) { @@ -325,7 +328,7 @@ impl UnusedParens { } fn check_unused_parens_pat(&self, - cx: &EarlyContext, + cx: &EarlyContext<'_>, value: &ast::Pat, msg: &str) { if let ast::PatKind::Paren(_) = value.node { @@ -339,7 +342,7 @@ impl UnusedParens { } } - fn remove_outer_parens(cx: &EarlyContext, span: Span, pattern: &str, msg: &str) { + fn remove_outer_parens(cx: &EarlyContext<'_>, span: Span, pattern: &str, msg: &str) { let span_msg = format!("unnecessary parentheses around {}", msg); let mut err = cx.struct_span_lint(UNUSED_PARENS, span, &span_msg); let mut ate_left_paren = false; @@ -387,7 +390,7 @@ impl LintPass for UnusedParens { } impl EarlyLintPass for UnusedParens { - fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) { + fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { use syntax::ast::ExprKind::*; let (value, msg, followed_by_block) = match e.node { If(ref cond, ..) => (cond, "`if` condition", true), @@ -429,7 +432,7 @@ impl EarlyLintPass for UnusedParens { self.check_unused_parens_expr(cx, &value, msg, followed_by_block); } - fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat, _: &mut bool) { + fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat, _: &mut bool) { use ast::PatKind::{Paren, Range}; // The lint visitor will visit each subpattern of `p`. We do not want to lint any range // pattern no matter where it occurs in the pattern. For something like `&(a..=b)`, there @@ -443,7 +446,7 @@ impl EarlyLintPass for UnusedParens { } } - fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) { + fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) { if let ast::StmtKind::Local(ref local) = s.node { if let Some(ref value) = local.init { self.check_unused_parens_expr(cx, &value, "assigned value", false); @@ -462,7 +465,7 @@ declare_lint! { pub struct UnusedImportBraces; impl UnusedImportBraces { - fn check_use_tree(&self, cx: &EarlyContext, use_tree: &ast::UseTree, item: &ast::Item) { + fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &ast::Item) { if let ast::UseTreeKind::Nested(ref items) = use_tree.kind { // Recursively check nested UseTrees for &(ref tree, _) in items { @@ -509,7 +512,7 @@ impl LintPass for UnusedImportBraces { } impl EarlyLintPass for UnusedImportBraces { - fn check_item(&mut self, cx: &EarlyContext, item: &ast::Item) { + fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { if let ast::ItemKind::Use(ref use_tree) = item.node { self.check_use_tree(cx, use_tree, item); } @@ -536,7 +539,7 @@ impl LintPass for UnusedAllocation { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { - fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { match e.node { hir::ExprKind::Box(_) => {} _ => return, From bf531bd4594ad78fe3443554e2b80d7a496faf4a Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:40:49 +0900 Subject: [PATCH 14/21] librustc_passes => 2018 --- src/librustc_passes/Cargo.toml | 3 ++- src/librustc_passes/ast_validation.rs | 3 ++- src/librustc_passes/diagnostics.rs | 2 ++ src/librustc_passes/hir_stats.rs | 2 +- src/librustc_passes/lib.rs | 14 +++----------- src/librustc_passes/loops.rs | 5 +++-- src/librustc_passes/rvalue_promotion.rs | 16 ++++++++++------ 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index f5154a033af8d..00bdcdc0cc021 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_passes" version = "0.0.0" +edition = "2018" [lib] name = "rustc_passes" @@ -16,4 +17,4 @@ rustc_data_structures = { path = "../librustc_data_structures" } syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } syntax_pos = { path = "../libsyntax_pos" } -rustc_errors = { path = "../librustc_errors" } +errors = { path = "../librustc_errors", package = "rustc_errors" } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 3deb2ff8d8a0b..4b1cf6a035ef7 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -15,10 +15,11 @@ use syntax::source_map::Spanned; use syntax::symbol::keywords; use syntax::ptr::P; use syntax::visit::{self, Visitor}; +use syntax::{span_err, struct_span_err, walk_list}; use syntax_ext::proc_macro_decls::is_proc_macro_attr; use syntax_pos::Span; -use errors; use errors::Applicability; +use log::debug; struct AstValidator<'a> { session: &'a Session, diff --git a/src/librustc_passes/diagnostics.rs b/src/librustc_passes/diagnostics.rs index 037227aeb715d..19d4d3aeb0f65 100644 --- a/src/librustc_passes/diagnostics.rs +++ b/src/librustc_passes/diagnostics.rs @@ -1,5 +1,7 @@ #![allow(non_snake_case)] +use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics}; + register_long_diagnostics! { /* E0014: r##" diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index 74d6d75a7f528..2427abad07c95 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -61,7 +61,7 @@ impl<'k> StatCollector<'k> { }); entry.count += 1; - entry.size = ::std::mem::size_of_val(node); + entry.size = std::mem::size_of_val(node); } fn print(&self, title: &str) { diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 76605c58a7889..7b0e57846f360 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -13,18 +13,10 @@ #![recursion_limit="256"] -#[macro_use] -extern crate rustc; -extern crate rustc_mir; -extern crate rustc_data_structures; +#![deny(rust_2018_idioms)] #[macro_use] -extern crate log; -#[macro_use] -extern crate syntax; -extern crate syntax_ext; -extern crate syntax_pos; -extern crate rustc_errors as errors; +extern crate rustc; use rustc::ty::query::Providers; @@ -38,7 +30,7 @@ pub mod loops; __build_diagnostic_array! { librustc_passes, DIAGNOSTICS } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { rvalue_promotion::provide(providers); loops::provide(providers); } diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index f05a7be7d7513..533e043efa9d2 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -1,4 +1,4 @@ -use self::Context::*; +use Context::*; use rustc::session::Session; @@ -9,6 +9,7 @@ use rustc::hir::map::Map; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; use rustc::hir::{self, Node, Destination}; use syntax::ast; +use syntax::struct_span_err; use syntax_pos::Span; use errors::Applicability; @@ -59,7 +60,7 @@ fn check_mod_loops<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) { }.as_deep_visitor()); } -pub(crate) fn provide(providers: &mut Providers) { +pub(crate) fn provide(providers: &mut Providers<'_>) { *providers = Providers { check_mod_loops, ..*providers diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index c11b1af97766d..748500ac46b57 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -28,10 +28,11 @@ use rustc::hir; use rustc_data_structures::sync::Lrc; use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; -use self::Promotability::*; +use log::debug; +use Promotability::*; use std::ops::{BitAnd, BitAndAssign, BitOr}; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { rvalue_promotable_map, const_is_rvalue_promotable_to_static, @@ -622,7 +623,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> { fn consume(&mut self, _consume_id: ast::NodeId, _consume_span: Span, - _cmt: &mc::cmt_, + _cmt: &mc::cmt_<'_>, _mode: euv::ConsumeMode) {} fn borrow(&mut self, @@ -681,11 +682,14 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> { fn mutate(&mut self, _assignment_id: ast::NodeId, _assignment_span: Span, - _assignee_cmt: &mc::cmt_, + _assignee_cmt: &mc::cmt_<'_>, _mode: euv::MutateMode) { } - fn matched_pat(&mut self, _: &hir::Pat, _: &mc::cmt_, _: euv::MatchMode) {} + fn matched_pat(&mut self, _: &hir::Pat, _: &mc::cmt_<'_>, _: euv::MatchMode) {} - fn consume_pat(&mut self, _consume_pat: &hir::Pat, _cmt: &mc::cmt_, _mode: euv::ConsumeMode) {} + fn consume_pat(&mut self, + _consume_pat: &hir::Pat, + _cmt: &mc::cmt_<'_>, + _mode: euv::ConsumeMode) {} } From 7267bc2d4a0ba006d63b58eb927362d620930c68 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:50:17 +0900 Subject: [PATCH 15/21] librustc_metadata => 2018 --- src/librustc_metadata/Cargo.toml | 3 ++- src/librustc_metadata/creader.rs | 19 +++++++++-------- src/librustc_metadata/cstore.rs | 4 ++-- src/librustc_metadata/cstore_impl.rs | 16 +++++++------- src/librustc_metadata/decoder.rs | 7 +++--- src/librustc_metadata/diagnostics.rs | 2 ++ src/librustc_metadata/dynamic_lib.rs | 2 -- src/librustc_metadata/encoder.rs | 11 +++++----- src/librustc_metadata/index.rs | 7 +++--- src/librustc_metadata/index_builder.rs | 26 +++++++++++------------ src/librustc_metadata/isolated_encoder.rs | 4 ++-- src/librustc_metadata/lib.rs | 14 +++--------- src/librustc_metadata/locator.rs | 13 +++++++----- src/librustc_metadata/native_libs.rs | 1 + src/librustc_metadata/schema.rs | 4 ++-- 15 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 337c87c24ba2b..e234f4f880703 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_metadata" version = "0.0.0" +edition = "2018" [lib] name = "rustc_metadata" @@ -14,7 +15,7 @@ log = "0.4" memmap = "0.6" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } -rustc_errors = { path = "../librustc_errors" } +errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_target = { path = "../librustc_target" } serialize = { path = "../libserialize" } stable_deref_trait = "1.0.0" diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index e9785e7c88d0d..0b4c8a5367c15 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -1,9 +1,9 @@ //! Validates all used crates and extern libraries and loads their metadata -use cstore::{self, CStore, CrateSource, MetadataBlob}; -use locator::{self, CratePaths}; -use decoder::proc_macro_def_path_table; -use schema::CrateRoot; +use crate::cstore::{self, CStore, CrateSource, MetadataBlob}; +use crate::locator::{self, CratePaths}; +use crate::decoder::proc_macro_def_path_table; +use crate::schema::CrateRoot; use rustc_data_structures::sync::{Lrc, RwLock, Lock}; use rustc::hir::def_id::CrateNum; @@ -29,8 +29,9 @@ use syntax::attr; use syntax::ext::base::SyntaxExtension; use syntax::symbol::Symbol; use syntax::visit; +use syntax::{span_err, span_fatal}; use syntax_pos::{Span, DUMMY_SP}; -use log; +use log::{debug, info, log_enabled}; pub struct Library { pub dylib: Option<(PathBuf, PathKind)>, @@ -342,7 +343,7 @@ impl<'a> CrateLoader<'a> { } } - fn load(&mut self, locate_ctxt: &mut locator::Context) -> Option { + fn load(&mut self, locate_ctxt: &mut locator::Context<'_>) -> Option { let library = locate_ctxt.maybe_load_library_crate()?; // In the case that we're loading a crate, but not matching @@ -427,7 +428,7 @@ impl<'a> CrateLoader<'a> { // The map from crate numbers in the crate we're resolving to local crate numbers. // We map 0 and all other holes in the map to our parent crate. The "additional" // self-dependencies should be harmless. - ::std::iter::once(krate).chain(crate_root.crate_deps + std::iter::once(krate).chain(crate_root.crate_deps .decode(metadata) .map(|dep| { info!("resolving dep crate {} hash: `{}` extra filename: `{}`", dep.name, dep.hash, @@ -522,7 +523,7 @@ impl<'a> CrateLoader<'a> { fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option, span: Span) -> Vec<(ast::Name, Lrc)> { use std::{env, mem}; - use dynamic_lib::DynamicLibrary; + use crate::dynamic_lib::DynamicLibrary; use proc_macro::bridge::client::ProcMacro; use syntax_ext::deriving::custom::ProcMacroDerive; use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro}; @@ -996,7 +997,7 @@ impl<'a> CrateLoader<'a> { item.ident, orig_name); let orig_name = match orig_name { Some(orig_name) => { - ::validate_crate_name(Some(self.sess), &orig_name.as_str(), + crate::validate_crate_name(Some(self.sess), &orig_name.as_str(), Some(item.span)); orig_name } diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 543fb5d5df5be..a2f69bc45634d 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -1,7 +1,7 @@ // The crate store - a central repo for information collected about external // crates and libraries -use schema; +use crate::schema; use rustc::hir::def_id::{CrateNum, DefIndex}; use rustc::hir::map::definitions::DefPathTable; use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader}; @@ -19,7 +19,7 @@ pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePrefere pub use rustc::middle::cstore::NativeLibraryKind::*; pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule}; -pub use cstore_impl::{provide, provide_extern}; +pub use crate::cstore_impl::{provide, provide_extern}; // A map from external crate numbers (as decoded from some crate file) to // local crate numbers (as generated during this session). Each external diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index e61229db86ddb..49a3e335e3417 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -1,9 +1,9 @@ -use cstore::{self, LoadedMacro}; -use encoder; -use link_args; -use native_libs; -use foreign_modules; -use schema; +use crate::cstore::{self, LoadedMacro}; +use crate::encoder; +use crate::link_args; +use crate::native_libs; +use crate::foreign_modules; +use crate::schema; use rustc::ty::query::QueryConfig; use rustc::middle::cstore::{CrateStore, DepKind, @@ -51,7 +51,7 @@ macro_rules! provide { index: CRATE_DEF_INDEX }); let dep_node = def_path_hash - .to_dep_node(::rustc::dep_graph::DepKind::CrateMetadata); + .to_dep_node(rustc::dep_graph::DepKind::CrateMetadata); // The DepNodeIndex of the DepNode::CrateMetadata should be // cached somewhere, so that we can use read_index(). $tcx.dep_graph.read(dep_node); @@ -421,7 +421,7 @@ impl cstore::CStore { use syntax::ext::base::SyntaxExtension; use syntax_ext::proc_macro_impl::BangProcMacro; - let client = ::proc_macro::bridge::client::Client::expand1(::proc_macro::quote); + let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote); let ext = SyntaxExtension::ProcMacro { expander: Box::new(BangProcMacro { client }), allow_internal_unstable: true, diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index ad6296e1a3bd8..6d7907b096ac6 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1,7 +1,7 @@ // Decoding metadata from a single crate's metadata -use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule}; -use schema::*; +use crate::cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule}; +use crate::schema::*; use rustc_data_structures::sync::{Lrc, ReadGuard}; use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, Definitions}; @@ -34,6 +34,7 @@ use syntax::symbol::InternedString; use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::hygiene::Mark; use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION}; +use log::debug; pub struct DecodeContext<'a, 'tcx: 'a> { opaque: opaque::Decoder<'a>, @@ -545,7 +546,7 @@ impl<'a, 'tcx> CrateMetadata { fn get_variant(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, - item: &Entry, + item: &Entry<'_>, index: DefIndex, adt_kind: ty::AdtKind) -> ty::VariantDef diff --git a/src/librustc_metadata/diagnostics.rs b/src/librustc_metadata/diagnostics.rs index 1b1852434740c..c27d13be49358 100644 --- a/src/librustc_metadata/diagnostics.rs +++ b/src/librustc_metadata/diagnostics.rs @@ -1,5 +1,7 @@ #![allow(non_snake_case)] +use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics}; + register_long_diagnostics! { E0454: r##" A link name was given with an empty name. Erroneous code example: diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs index 7d1c3c09d33e9..b9dc4195cb228 100644 --- a/src/librustc_metadata/dynamic_lib.rs +++ b/src/librustc_metadata/dynamic_lib.rs @@ -76,7 +76,6 @@ impl DynamicLibrary { #[cfg(test)] mod tests { use super::*; - use libc; use std::mem; #[test] @@ -127,7 +126,6 @@ mod tests { #[cfg(unix)] mod dl { - use libc; use std::ffi::{CStr, OsStr, CString}; use std::os::unix::prelude::*; use std::ptr; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 3b212f3b7472d..d68ab9750b970 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1,7 +1,7 @@ -use index::Index; -use index_builder::{FromId, IndexBuilder, Untracked}; -use isolated_encoder::IsolatedEncoder; -use schema::*; +use crate::index::Index; +use crate::index_builder::{FromId, IndexBuilder, Untracked}; +use crate::isolated_encoder::IsolatedEncoder; +use crate::schema::*; use rustc::middle::cstore::{LinkagePreference, NativeLibrary, EncodedMetadata, ForeignModule}; @@ -34,6 +34,7 @@ use syntax::attr; use syntax::source_map::Spanned; use syntax::symbol::keywords; use syntax_pos::{self, hygiene, FileName, SourceFile, Span}; +use log::{debug, trace}; use rustc::hir::{self, PatKind}; use rustc::hir::itemlikevisit::ItemLikeVisitor; @@ -1521,7 +1522,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { // symbol associated with them (they weren't translated) or if they're an FFI // definition (as that's not defined in this crate). fn encode_exported_symbols(&mut self, - exported_symbols: &[(ExportedSymbol, SymbolExportLevel)]) + exported_symbols: &[(ExportedSymbol<'_>, SymbolExportLevel)]) -> EncodedExportedSymbols { // The metadata symbol name is special. It should not show up in // downstream crates. diff --git a/src/librustc_metadata/index.rs b/src/librustc_metadata/index.rs index ccf398241b191..18f30383090cd 100644 --- a/src/librustc_metadata/index.rs +++ b/src/librustc_metadata/index.rs @@ -1,9 +1,10 @@ -use schema::*; +use crate::schema::*; use rustc::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace}; use rustc_serialize::opaque::Encoder; use std::slice; use std::u32; +use log::debug; /// While we are generating the metadata, we also track the position /// of each DefIndex. It is not required that all definitions appear @@ -24,12 +25,12 @@ impl Index { } } - pub fn record(&mut self, def_id: DefId, entry: Lazy) { + pub fn record(&mut self, def_id: DefId, entry: Lazy>) { assert!(def_id.is_local()); self.record_index(def_id.index, entry); } - pub fn record_index(&mut self, item: DefIndex, entry: Lazy) { + pub fn record_index(&mut self, item: DefIndex, entry: Lazy>) { assert!(entry.position < (u32::MAX as usize)); let position = entry.position as u32; let space_index = item.address_space().index(); diff --git a/src/librustc_metadata/index_builder.rs b/src/librustc_metadata/index_builder.rs index 3608b12aea934..4175f7acd0688 100644 --- a/src/librustc_metadata/index_builder.rs +++ b/src/librustc_metadata/index_builder.rs @@ -45,10 +45,10 @@ //! give a callback fn, rather than taking a closure: it allows us to //! easily control precisely what data is given to that fn. -use encoder::EncodeContext; -use index::Index; -use schema::*; -use isolated_encoder::IsolatedEncoder; +use crate::encoder::EncodeContext; +use crate::index::Index; +use crate::schema::*; +use crate::isolated_encoder::IsolatedEncoder; use rustc::hir; use rustc::hir::def_id::DefId; @@ -133,21 +133,21 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { /// `DefId` index, or implement the `read` method so that it can add /// a read of whatever dep-graph nodes are appropriate. pub trait DepGraphRead { - fn read(&self, tcx: TyCtxt); + fn read(&self, tcx: TyCtxt<'_, '_, '_>); } impl DepGraphRead for DefId { - fn read(&self, _tcx: TyCtxt) {} + fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {} } impl DepGraphRead for ast::NodeId { - fn read(&self, _tcx: TyCtxt) {} + fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {} } impl DepGraphRead for Option where T: DepGraphRead { - fn read(&self, tcx: TyCtxt) { + fn read(&self, tcx: TyCtxt<'_, '_, '_>) { match *self { Some(ref v) => v.read(tcx), None => (), @@ -158,7 +158,7 @@ impl DepGraphRead for Option impl DepGraphRead for [T] where T: DepGraphRead { - fn read(&self, tcx: TyCtxt) { + fn read(&self, tcx: TyCtxt<'_, '_, '_>) { for i in self { i.read(tcx); } @@ -171,7 +171,7 @@ macro_rules! read_tuple { where $($name: DepGraphRead),* { #[allow(non_snake_case)] - fn read(&self, tcx: TyCtxt) { + fn read(&self, tcx: TyCtxt<'_, '_, '_>) { let &($(ref $name),*) = self; $($name.read(tcx);)* } @@ -184,7 +184,7 @@ read_tuple!(A, B, C); macro_rules! read_hir { ($t:ty) => { impl<'tcx> DepGraphRead for &'tcx $t { - fn read(&self, tcx: TyCtxt) { + fn read(&self, tcx: TyCtxt<'_, '_, '_>) { tcx.hir().read(self.id); } } @@ -208,7 +208,7 @@ read_hir!(hir::MacroDef); pub struct Untracked(pub T); impl DepGraphRead for Untracked { - fn read(&self, _tcx: TyCtxt) {} + fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {} } /// Newtype that can be used to package up misc data extracted from a @@ -218,7 +218,7 @@ impl DepGraphRead for Untracked { pub struct FromId(pub ast::NodeId, pub T); impl DepGraphRead for FromId { - fn read(&self, tcx: TyCtxt) { + fn read(&self, tcx: TyCtxt<'_, '_, '_>) { tcx.hir().read(self.0); } } diff --git a/src/librustc_metadata/isolated_encoder.rs b/src/librustc_metadata/isolated_encoder.rs index c09d35d150a12..e879a73e650bb 100644 --- a/src/librustc_metadata/isolated_encoder.rs +++ b/src/librustc_metadata/isolated_encoder.rs @@ -1,5 +1,5 @@ -use encoder::EncodeContext; -use schema::{Lazy, LazySeq}; +use crate::encoder::EncodeContext; +use crate::schema::{Lazy, LazySeq}; use rustc::ty::TyCtxt; use rustc_serialize::Encodable; diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 1a6614212407d..c8891296417d8 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -15,23 +15,15 @@ #![recursion_limit="256"] +#![deny(rust_2018_idioms)] + extern crate libc; -#[macro_use] -extern crate log; -extern crate memmap; -extern crate stable_deref_trait; -#[macro_use] -extern crate syntax; -extern crate syntax_pos; -extern crate flate2; +#[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving -extern crate rustc_errors as errors; -extern crate syntax_ext; extern crate proc_macro; #[macro_use] extern crate rustc; -extern crate rustc_target; #[macro_use] extern crate rustc_data_structures; diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 6b49d6b9e52cb..f120072b37c05 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -212,9 +212,9 @@ //! no means all of the necessary details. Take a look at the rest of //! metadata::locator or metadata::creader for all the juicy details! -use cstore::{MetadataRef, MetadataBlob}; -use creader::Library; -use schema::{METADATA_HEADER, rustc_version}; +use crate::cstore::{MetadataRef, MetadataBlob}; +use crate::creader::Library; +use crate::schema::{METADATA_HEADER, rustc_version}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::svh::Svh; @@ -226,6 +226,7 @@ use rustc::util::nodemap::FxHashMap; use errors::DiagnosticBuilder; use syntax::symbol::Symbol; +use syntax::struct_span_err; use syntax_pos::Span; use rustc_target::spec::{Target, TargetTriple}; @@ -241,6 +242,8 @@ use flate2::read::DeflateDecoder; use rustc_data_structures::owning_ref::OwningRef; +use log::{debug, info, warn}; + pub struct CrateMismatch { path: PathBuf, got: String, @@ -283,7 +286,7 @@ enum CrateFlavor { } impl fmt::Display for CrateFlavor { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match *self { CrateFlavor::Rlib => "rlib", CrateFlavor::Rmeta => "rmeta", @@ -600,7 +603,7 @@ impl<'a> Context<'a> { } } - let mut err: Option = None; + let mut err: Option> = None; for (lib, kind) in m { info!("{} reading metadata from: {}", flavor, lib.display()); let (hash, metadata) = diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 1f00086e32fe1..118fb203c69a1 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -9,6 +9,7 @@ use syntax::attr; use syntax::source_map::Span; use syntax::feature_gate::{self, GateIssue}; use syntax::symbol::Symbol; +use syntax::{span_err, struct_span_err}; pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec { let mut collector = Collector { diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index f3ff9747625f5..af79ea37dff55 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -1,4 +1,4 @@ -use index; +use crate::index; use rustc::hir; use rustc::hir::def::{self, CtorKind}; @@ -518,7 +518,7 @@ pub enum AssociatedContainer { ImplFinal, } -impl_stable_hash_for!(enum ::schema::AssociatedContainer { +impl_stable_hash_for!(enum crate::schema::AssociatedContainer { TraitRequired, TraitWithDefault, ImplDefault, From fed677e56fadde3cbdc2a7161765165407be47b6 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:55:12 +0900 Subject: [PATCH 16/21] librustc_cratesio_shim => 2018 --- src/librustc_cratesio_shim/Cargo.toml | 1 + src/librustc_cratesio_shim/src/lib.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/librustc_cratesio_shim/Cargo.toml b/src/librustc_cratesio_shim/Cargo.toml index b8e494e4040ec..6bdfbe09354b4 100644 --- a/src/librustc_cratesio_shim/Cargo.toml +++ b/src/librustc_cratesio_shim/Cargo.toml @@ -15,6 +15,7 @@ authors = ["The Rust Project Developers"] name = "rustc_cratesio_shim" version = "0.0.0" +edition = "2018" [lib] crate-type = ["dylib"] diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs index 4024087f4d3ef..4c170f4f5f6f9 100644 --- a/src/librustc_cratesio_shim/src/lib.rs +++ b/src/librustc_cratesio_shim/src/lib.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + // See Cargo.toml for a comment explaining this crate. #![allow(unused_extern_crates)] From a7241c8ca6e37d4861c0ddc5639aee9d66fdbe8f Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 21:00:07 +0900 Subject: [PATCH 17/21] librustc_target => 2018 --- src/librustc_target/Cargo.toml | 1 + src/librustc_target/abi/call/aarch64.rs | 4 ++-- src/librustc_target/abi/call/amdgpu.rs | 4 ++-- src/librustc_target/abi/call/arm.rs | 6 +++--- src/librustc_target/abi/call/asmjs.rs | 6 +++--- src/librustc_target/abi/call/hexagon.rs | 8 ++++---- src/librustc_target/abi/call/mips.rs | 10 +++++----- src/librustc_target/abi/call/mips64.rs | 6 +++--- src/librustc_target/abi/call/mod.rs | 18 +++++++++--------- src/librustc_target/abi/call/msp430.rs | 8 ++++---- src/librustc_target/abi/call/nvptx.rs | 8 ++++---- src/librustc_target/abi/call/nvptx64.rs | 8 ++++---- src/librustc_target/abi/call/powerpc.rs | 10 +++++----- src/librustc_target/abi/call/powerpc64.rs | 8 ++++---- src/librustc_target/abi/call/riscv.rs | 8 ++++---- src/librustc_target/abi/call/s390x.rs | 6 +++--- src/librustc_target/abi/call/sparc.rs | 10 +++++----- src/librustc_target/abi/call/sparc64.rs | 4 ++-- src/librustc_target/abi/call/wasm32.rs | 8 ++++---- src/librustc_target/abi/call/x86.rs | 6 +++--- src/librustc_target/abi/call/x86_64.rs | 4 ++-- src/librustc_target/abi/call/x86_win64.rs | 8 ++++---- src/librustc_target/abi/mod.rs | 10 +++++----- src/librustc_target/lib.rs | 6 +++--- src/librustc_target/spec/aarch64_apple_ios.rs | 2 +- src/librustc_target/spec/aarch64_fuchsia.rs | 2 +- .../spec/aarch64_linux_android.rs | 2 +- .../spec/aarch64_pc_windows_msvc.rs | 2 +- .../spec/aarch64_unknown_cloudabi.rs | 2 +- .../spec/aarch64_unknown_freebsd.rs | 2 +- .../spec/aarch64_unknown_hermit.rs | 2 +- .../spec/aarch64_unknown_linux_gnu.rs | 2 +- .../spec/aarch64_unknown_linux_musl.rs | 2 +- .../spec/aarch64_unknown_netbsd.rs | 2 +- .../spec/aarch64_unknown_openbsd.rs | 2 +- src/librustc_target/spec/abi.rs | 2 +- src/librustc_target/spec/android_base.rs | 2 +- src/librustc_target/spec/apple_base.rs | 2 +- src/librustc_target/spec/apple_ios_base.rs | 4 ++-- src/librustc_target/spec/arm_base.rs | 2 +- .../spec/arm_linux_androideabi.rs | 2 +- .../spec/arm_unknown_linux_gnueabi.rs | 2 +- .../spec/arm_unknown_linux_gnueabihf.rs | 2 +- .../spec/arm_unknown_linux_musleabi.rs | 2 +- .../spec/arm_unknown_linux_musleabihf.rs | 2 +- src/librustc_target/spec/armebv7r_none_eabi.rs | 2 +- .../spec/armebv7r_none_eabihf.rs | 2 +- .../spec/armv4t_unknown_linux_gnueabi.rs | 2 +- .../spec/armv5te_unknown_linux_gnueabi.rs | 2 +- .../spec/armv5te_unknown_linux_musleabi.rs | 2 +- .../spec/armv6_unknown_netbsd_eabihf.rs | 2 +- src/librustc_target/spec/armv7_apple_ios.rs | 2 +- .../spec/armv7_linux_androideabi.rs | 2 +- .../spec/armv7_unknown_cloudabi_eabihf.rs | 2 +- .../spec/armv7_unknown_linux_gnueabihf.rs | 2 +- .../spec/armv7_unknown_linux_musleabihf.rs | 2 +- .../spec/armv7_unknown_netbsd_eabihf.rs | 2 +- src/librustc_target/spec/armv7r_none_eabi.rs | 2 +- src/librustc_target/spec/armv7r_none_eabihf.rs | 2 +- src/librustc_target/spec/armv7s_apple_ios.rs | 2 +- src/librustc_target/spec/bitrig_base.rs | 2 +- src/librustc_target/spec/cloudabi_base.rs | 2 +- src/librustc_target/spec/dragonfly_base.rs | 2 +- src/librustc_target/spec/freebsd_base.rs | 2 +- src/librustc_target/spec/fuchsia_base.rs | 2 +- src/librustc_target/spec/haiku_base.rs | 2 +- src/librustc_target/spec/hermit_base.rs | 2 +- src/librustc_target/spec/i386_apple_ios.rs | 2 +- .../spec/i586_pc_windows_msvc.rs | 2 +- .../spec/i586_unknown_linux_gnu.rs | 2 +- .../spec/i586_unknown_linux_musl.rs | 2 +- src/librustc_target/spec/i686_apple_darwin.rs | 2 +- src/librustc_target/spec/i686_linux_android.rs | 2 +- .../spec/i686_pc_windows_gnu.rs | 2 +- .../spec/i686_pc_windows_msvc.rs | 2 +- .../spec/i686_unknown_cloudabi.rs | 2 +- .../spec/i686_unknown_dragonfly.rs | 2 +- .../spec/i686_unknown_freebsd.rs | 2 +- src/librustc_target/spec/i686_unknown_haiku.rs | 2 +- .../spec/i686_unknown_linux_gnu.rs | 2 +- .../spec/i686_unknown_linux_musl.rs | 2 +- .../spec/i686_unknown_netbsd.rs | 2 +- .../spec/i686_unknown_openbsd.rs | 2 +- src/librustc_target/spec/l4re_base.rs | 2 +- src/librustc_target/spec/linux_base.rs | 2 +- src/librustc_target/spec/linux_musl_base.rs | 2 +- .../spec/mips64_unknown_linux_gnuabi64.rs | 2 +- .../spec/mips64el_unknown_linux_gnuabi64.rs | 2 +- .../spec/mips_unknown_linux_gnu.rs | 2 +- .../spec/mips_unknown_linux_musl.rs | 2 +- .../spec/mips_unknown_linux_uclibc.rs | 2 +- .../spec/mipsel_unknown_linux_gnu.rs | 2 +- .../spec/mipsel_unknown_linux_musl.rs | 2 +- .../spec/mipsel_unknown_linux_uclibc.rs | 2 +- src/librustc_target/spec/mod.rs | 4 ++-- src/librustc_target/spec/msp430_none_elf.rs | 2 +- src/librustc_target/spec/netbsd_base.rs | 2 +- .../spec/nvptx64_nvidia_cuda.rs | 4 ++-- src/librustc_target/spec/openbsd_base.rs | 2 +- .../spec/powerpc64_unknown_freebsd.rs | 2 +- .../spec/powerpc64_unknown_linux_gnu.rs | 2 +- .../spec/powerpc64_unknown_linux_musl.rs | 2 +- .../spec/powerpc64le_unknown_linux_gnu.rs | 2 +- .../spec/powerpc64le_unknown_linux_musl.rs | 2 +- .../spec/powerpc_unknown_linux_gnu.rs | 2 +- .../spec/powerpc_unknown_linux_gnuspe.rs | 2 +- .../spec/powerpc_unknown_linux_musl.rs | 2 +- .../spec/powerpc_unknown_netbsd.rs | 2 +- src/librustc_target/spec/redox_base.rs | 2 +- .../spec/riscv32imac_unknown_none_elf.rs | 2 +- .../spec/riscv32imc_unknown_none_elf.rs | 2 +- src/librustc_target/spec/riscv_base.rs | 2 +- .../spec/s390x_unknown_linux_gnu.rs | 2 +- src/librustc_target/spec/solaris_base.rs | 2 +- .../spec/sparc64_unknown_linux_gnu.rs | 2 +- .../spec/sparc64_unknown_netbsd.rs | 2 +- .../spec/sparc_unknown_linux_gnu.rs | 2 +- .../spec/sparcv9_sun_solaris.rs | 2 +- src/librustc_target/spec/thumb_base.rs | 2 +- src/librustc_target/spec/thumbv6m_none_eabi.rs | 2 +- .../spec/thumbv7a_pc_windows_msvc.rs | 2 +- .../spec/thumbv7em_none_eabi.rs | 2 +- .../spec/thumbv7em_none_eabihf.rs | 2 +- src/librustc_target/spec/thumbv7m_none_eabi.rs | 2 +- .../spec/thumbv7neon_linux_androideabi.rs | 2 +- .../thumbv7neon_unknown_linux_gnueabihf.rs | 2 +- .../spec/thumbv8m_base_none_eabi.rs | 2 +- .../spec/thumbv8m_main_none_eabi.rs | 2 +- .../spec/thumbv8m_main_none_eabihf.rs | 2 +- src/librustc_target/spec/uefi_base.rs | 2 +- src/librustc_target/spec/windows_base.rs | 2 +- src/librustc_target/spec/windows_msvc_base.rs | 2 +- .../spec/x86_64_apple_darwin.rs | 2 +- src/librustc_target/spec/x86_64_apple_ios.rs | 2 +- src/librustc_target/spec/x86_64_fuchsia.rs | 2 +- .../spec/x86_64_linux_android.rs | 2 +- .../spec/x86_64_pc_windows_gnu.rs | 2 +- .../spec/x86_64_pc_windows_msvc.rs | 2 +- .../spec/x86_64_rumprun_netbsd.rs | 2 +- src/librustc_target/spec/x86_64_sun_solaris.rs | 2 +- .../spec/x86_64_unknown_bitrig.rs | 2 +- .../spec/x86_64_unknown_cloudabi.rs | 2 +- .../spec/x86_64_unknown_dragonfly.rs | 2 +- .../spec/x86_64_unknown_freebsd.rs | 2 +- .../spec/x86_64_unknown_haiku.rs | 2 +- .../spec/x86_64_unknown_hermit.rs | 2 +- .../spec/x86_64_unknown_l4re_uclibc.rs | 2 +- .../spec/x86_64_unknown_linux_gnu.rs | 2 +- .../spec/x86_64_unknown_linux_gnux32.rs | 2 +- .../spec/x86_64_unknown_linux_musl.rs | 2 +- .../spec/x86_64_unknown_netbsd.rs | 2 +- .../spec/x86_64_unknown_openbsd.rs | 2 +- .../spec/x86_64_unknown_redox.rs | 2 +- .../spec/x86_64_unknown_uefi.rs | 2 +- 154 files changed, 221 insertions(+), 220 deletions(-) diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index dfdd7f0ae58e5..ecea15a992250 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_target" version = "0.0.0" +edition = "2018" [lib] name = "rustc_target" diff --git a/src/librustc_target/abi/call/aarch64.rs b/src/librustc_target/abi/call/aarch64.rs index 9f9bba14b963e..f50ec6c2e7e3a 100644 --- a/src/librustc_target/abi/call/aarch64.rs +++ b/src/librustc_target/abi/call/aarch64.rs @@ -1,5 +1,5 @@ -use abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; -use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>) -> Option diff --git a/src/librustc_target/abi/call/amdgpu.rs b/src/librustc_target/abi/call/amdgpu.rs index ea9d4172cbc23..6bfd1f4387385 100644 --- a/src/librustc_target/abi/call/amdgpu.rs +++ b/src/librustc_target/abi/call/amdgpu.rs @@ -1,5 +1,5 @@ -use abi::call::{ArgType, FnType, }; -use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::abi::call::{ArgType, FnType, }; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; fn classify_ret_ty<'a, Ty, C>(_cx: &C, ret: &mut ArgType<'a, Ty>) where Ty: TyLayoutMethods<'a, C> + Copy, diff --git a/src/librustc_target/abi/call/arm.rs b/src/librustc_target/abi/call/arm.rs index 228dd36216158..52d7f3ac3dcbf 100644 --- a/src/librustc_target/abi/call/arm.rs +++ b/src/librustc_target/abi/call/arm.rs @@ -1,6 +1,6 @@ -use abi::call::{Conv, FnType, ArgType, Reg, RegKind, Uniform}; -use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; -use spec::HasTargetSpec; +use crate::abi::call::{Conv, FnType, ArgType, Reg, RegKind, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::spec::HasTargetSpec; fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>) -> Option diff --git a/src/librustc_target/abi/call/asmjs.rs b/src/librustc_target/abi/call/asmjs.rs index 85444500c5e11..92c86372a86f3 100644 --- a/src/librustc_target/abi/call/asmjs.rs +++ b/src/librustc_target/abi/call/asmjs.rs @@ -1,5 +1,5 @@ -use abi::call::{FnType, ArgType, Uniform}; -use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::abi::call::{FnType, ArgType, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; // Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128 @@ -26,7 +26,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>) } } -fn classify_arg_ty(arg: &mut ArgType) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>) { if arg.layout.is_aggregate() { arg.make_indirect_byval(); } diff --git a/src/librustc_target/abi/call/hexagon.rs b/src/librustc_target/abi/call/hexagon.rs index d538a8068ac4a..db8c915cdb4bd 100644 --- a/src/librustc_target/abi/call/hexagon.rs +++ b/src/librustc_target/abi/call/hexagon.rs @@ -1,8 +1,8 @@ #![allow(non_upper_case_globals)] -use abi::call::{FnType, ArgType}; +use crate::abi::call::{FnType, ArgType}; -fn classify_ret_ty(ret: &mut ArgType) { +fn classify_ret_ty(ret: &mut ArgType<'_, Ty>) { if ret.layout.is_aggregate() && ret.layout.size.bits() > 64 { ret.make_indirect(); } else { @@ -10,7 +10,7 @@ fn classify_ret_ty(ret: &mut ArgType) { } } -fn classify_arg_ty(arg: &mut ArgType) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>) { if arg.layout.is_aggregate() && arg.layout.size.bits() > 64 { arg.make_indirect(); } else { @@ -18,7 +18,7 @@ fn classify_arg_ty(arg: &mut ArgType) { } } -pub fn compute_abi_info(fty: &mut FnType) { +pub fn compute_abi_info(fty: &mut FnType<'_,Ty>) { if !fty.ret.is_ignore() { classify_ret_ty(&mut fty.ret); } diff --git a/src/librustc_target/abi/call/mips.rs b/src/librustc_target/abi/call/mips.rs index 2335bfbb5b87b..d496abf8e8b28 100644 --- a/src/librustc_target/abi/call/mips.rs +++ b/src/librustc_target/abi/call/mips.rs @@ -1,7 +1,7 @@ -use abi::call::{ArgType, FnType, Reg, Uniform}; -use abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods}; +use crate::abi::call::{ArgType, FnType, Reg, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods}; -fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType, offset: &mut Size) +fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'_, Ty>, offset: &mut Size) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { if !ret.layout.is_aggregate() { @@ -12,7 +12,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType, offset: &mut Size) } } -fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType, offset: &mut Size) +fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'_, Ty>, offset: &mut Size) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { let dl = cx.data_layout(); @@ -34,7 +34,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType, offset: &mut Size) *offset = offset.align_to(align) + size.align_to(align); } -pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType) +pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'_, Ty>) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { let mut offset = Size::ZERO; diff --git a/src/librustc_target/abi/call/mips64.rs b/src/librustc_target/abi/call/mips64.rs index 6f3e6494a4ae8..5ba05c6bcde37 100644 --- a/src/librustc_target/abi/call/mips64.rs +++ b/src/librustc_target/abi/call/mips64.rs @@ -1,7 +1,7 @@ -use abi::call::{ArgAttribute, ArgType, CastTarget, FnType, PassMode, Reg, RegKind, Uniform}; -use abi::{self, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods}; +use crate::abi::call::{ArgAttribute, ArgType, CastTarget, FnType, PassMode, Reg, RegKind, Uniform}; +use crate::abi::{self, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods}; -fn extend_integer_width_mips(arg: &mut ArgType, bits: u64) { +fn extend_integer_width_mips(arg: &mut ArgType<'_, Ty>, bits: u64) { // Always sign extend u32 values on 64-bit mips if let abi::Abi::Scalar(ref scalar) = arg.layout.abi { if let abi::Int(i, signed) = scalar.value { diff --git a/src/librustc_target/abi/call/mod.rs b/src/librustc_target/abi/call/mod.rs index 0d50439c67ec0..839c9a857e64a 100644 --- a/src/librustc_target/abi/call/mod.rs +++ b/src/librustc_target/abi/call/mod.rs @@ -1,6 +1,6 @@ -use abi::{self, Abi, Align, FieldPlacement, Size}; -use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; -use spec::HasTargetSpec; +use crate::abi::{self, Abi, Align, FieldPlacement, Size}; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::spec::{self, HasTargetSpec}; mod aarch64; mod amdgpu; @@ -42,13 +42,13 @@ pub enum PassMode { // Hack to disable non_upper_case_globals only for the bitflags! and not for the rest // of this module -pub use self::attr_impl::ArgAttribute; +pub use attr_impl::ArgAttribute; #[allow(non_upper_case_globals)] #[allow(unused)] mod attr_impl { // The subset of llvm::Attribute needed for arguments, packed into a bitfield. - bitflags! { + bitflags::bitflags! { #[derive(Default)] pub struct ArgAttribute: u16 { const ByVal = 1 << 0; @@ -526,22 +526,22 @@ pub struct FnType<'a, Ty> { } impl<'a, Ty> FnType<'a, Ty> { - pub fn adjust_for_cabi(&mut self, cx: &C, abi: ::spec::abi::Abi) -> Result<(), String> + pub fn adjust_for_cabi(&mut self, cx: &C, abi: spec::abi::Abi) -> Result<(), String> where Ty: TyLayoutMethods<'a, C> + Copy, C: LayoutOf> + HasDataLayout + HasTargetSpec { match &cx.target_spec().arch[..] { "x86" => { - let flavor = if abi == ::spec::abi::Abi::Fastcall { + let flavor = if abi == spec::abi::Abi::Fastcall { x86::Flavor::Fastcall } else { x86::Flavor::General }; x86::compute_abi_info(cx, self, flavor); }, - "x86_64" => if abi == ::spec::abi::Abi::SysV64 { + "x86_64" => if abi == spec::abi::Abi::SysV64 { x86_64::compute_abi_info(cx, self); - } else if abi == ::spec::abi::Abi::Win64 || cx.target_spec().options.is_like_windows { + } else if abi == spec::abi::Abi::Win64 || cx.target_spec().options.is_like_windows { x86_win64::compute_abi_info(self); } else { x86_64::compute_abi_info(cx, self); diff --git a/src/librustc_target/abi/call/msp430.rs b/src/librustc_target/abi/call/msp430.rs index d8ba37db53d4d..7ae1116cba847 100644 --- a/src/librustc_target/abi/call/msp430.rs +++ b/src/librustc_target/abi/call/msp430.rs @@ -1,7 +1,7 @@ // Reference: MSP430 Embedded Application Binary Interface // http://www.ti.com/lit/an/slaa534/slaa534.pdf -use abi::call::{ArgType, FnType}; +use crate::abi::call::{ArgType, FnType}; // 3.5 Structures or Unions Passed and Returned by Reference // @@ -9,7 +9,7 @@ use abi::call::{ArgType, FnType}; // returned by reference. To pass a structure or union by reference, the caller // places its address in the appropriate location: either in a register or on // the stack, according to its position in the argument list. (..)" -fn classify_ret_ty(ret: &mut ArgType) { +fn classify_ret_ty(ret: &mut ArgType<'_, Ty>) { if ret.layout.is_aggregate() && ret.layout.size.bits() > 32 { ret.make_indirect(); } else { @@ -17,7 +17,7 @@ fn classify_ret_ty(ret: &mut ArgType) { } } -fn classify_arg_ty(arg: &mut ArgType) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>) { if arg.layout.is_aggregate() && arg.layout.size.bits() > 32 { arg.make_indirect(); } else { @@ -25,7 +25,7 @@ fn classify_arg_ty(arg: &mut ArgType) { } } -pub fn compute_abi_info(fty: &mut FnType) { +pub fn compute_abi_info(fty: &mut FnType<'_, Ty>) { if !fty.ret.is_ignore() { classify_ret_ty(&mut fty.ret); } diff --git a/src/librustc_target/abi/call/nvptx.rs b/src/librustc_target/abi/call/nvptx.rs index 4cf0f11eb1e4a..4722249f73007 100644 --- a/src/librustc_target/abi/call/nvptx.rs +++ b/src/librustc_target/abi/call/nvptx.rs @@ -1,9 +1,9 @@ // Reference: PTX Writer's Guide to Interoperability // http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability -use abi::call::{ArgType, FnType}; +use crate::abi::call::{ArgType, FnType}; -fn classify_ret_ty(ret: &mut ArgType) { +fn classify_ret_ty(ret: &mut ArgType<'_, Ty>) { if ret.layout.is_aggregate() && ret.layout.size.bits() > 32 { ret.make_indirect(); } else { @@ -11,7 +11,7 @@ fn classify_ret_ty(ret: &mut ArgType) { } } -fn classify_arg_ty(arg: &mut ArgType) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>) { if arg.layout.is_aggregate() && arg.layout.size.bits() > 32 { arg.make_indirect(); } else { @@ -19,7 +19,7 @@ fn classify_arg_ty(arg: &mut ArgType) { } } -pub fn compute_abi_info(fty: &mut FnType) { +pub fn compute_abi_info(fty: &mut FnType<'_, Ty>) { if !fty.ret.is_ignore() { classify_ret_ty(&mut fty.ret); } diff --git a/src/librustc_target/abi/call/nvptx64.rs b/src/librustc_target/abi/call/nvptx64.rs index 8ccc77598c90a..51c00ae007c3c 100644 --- a/src/librustc_target/abi/call/nvptx64.rs +++ b/src/librustc_target/abi/call/nvptx64.rs @@ -1,9 +1,9 @@ // Reference: PTX Writer's Guide to Interoperability // http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability -use abi::call::{ArgType, FnType}; +use crate::abi::call::{ArgType, FnType}; -fn classify_ret_ty(ret: &mut ArgType) { +fn classify_ret_ty(ret: &mut ArgType<'_, Ty>) { if ret.layout.is_aggregate() && ret.layout.size.bits() > 64 { ret.make_indirect(); } else { @@ -11,7 +11,7 @@ fn classify_ret_ty(ret: &mut ArgType) { } } -fn classify_arg_ty(arg: &mut ArgType) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>) { if arg.layout.is_aggregate() && arg.layout.size.bits() > 64 { arg.make_indirect(); } else { @@ -19,7 +19,7 @@ fn classify_arg_ty(arg: &mut ArgType) { } } -pub fn compute_abi_info(fty: &mut FnType) { +pub fn compute_abi_info(fty: &mut FnType<'_, Ty>) { if !fty.ret.is_ignore() { classify_ret_ty(&mut fty.ret); } diff --git a/src/librustc_target/abi/call/powerpc.rs b/src/librustc_target/abi/call/powerpc.rs index 2335bfbb5b87b..d496abf8e8b28 100644 --- a/src/librustc_target/abi/call/powerpc.rs +++ b/src/librustc_target/abi/call/powerpc.rs @@ -1,7 +1,7 @@ -use abi::call::{ArgType, FnType, Reg, Uniform}; -use abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods}; +use crate::abi::call::{ArgType, FnType, Reg, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods}; -fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType, offset: &mut Size) +fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'_, Ty>, offset: &mut Size) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { if !ret.layout.is_aggregate() { @@ -12,7 +12,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType, offset: &mut Size) } } -fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType, offset: &mut Size) +fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'_, Ty>, offset: &mut Size) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { let dl = cx.data_layout(); @@ -34,7 +34,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType, offset: &mut Size) *offset = offset.align_to(align) + size.align_to(align); } -pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType) +pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'_, Ty>) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { let mut offset = Size::ZERO; diff --git a/src/librustc_target/abi/call/powerpc64.rs b/src/librustc_target/abi/call/powerpc64.rs index 305a2d4225056..a9683104d164e 100644 --- a/src/librustc_target/abi/call/powerpc64.rs +++ b/src/librustc_target/abi/call/powerpc64.rs @@ -2,16 +2,16 @@ // Alignment of 128 bit types is not currently handled, this will // need to be fixed when PowerPC vector support is added. -use abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; -use abi::{Endian, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; -use spec::HasTargetSpec; +use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; +use crate::abi::{Endian, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::spec::HasTargetSpec; #[derive(Debug, Clone, Copy, PartialEq)] enum ABI { ELFv1, // original ABI used for powerpc64 (big-endian) ELFv2, // newer ABI used for powerpc64le and musl (both endians) } -use self::ABI::*; +use ABI::*; fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>, abi: ABI) -> Option diff --git a/src/librustc_target/abi/call/riscv.rs b/src/librustc_target/abi/call/riscv.rs index 4950bcd3330aa..ba82e49ddb03e 100644 --- a/src/librustc_target/abi/call/riscv.rs +++ b/src/librustc_target/abi/call/riscv.rs @@ -1,9 +1,9 @@ // Reference: RISC-V ELF psABI specification // https://github.com/riscv/riscv-elf-psabi-doc -use abi::call::{ArgType, FnType}; +use crate::abi::call::{ArgType, FnType}; -fn classify_ret_ty(arg: &mut ArgType, xlen: u64) { +fn classify_ret_ty(arg: &mut ArgType<'_, Ty>, xlen: u64) { // "Scalars wider than 2✕XLEN are passed by reference and are replaced in // the argument list with the address." // "Aggregates larger than 2✕XLEN bits are passed by reference and are @@ -19,7 +19,7 @@ fn classify_ret_ty(arg: &mut ArgType, xlen: u64) { arg.extend_integer_width_to(xlen); // this method only affects integer scalars } -fn classify_arg_ty(arg: &mut ArgType, xlen: u64) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>, xlen: u64) { // "Scalars wider than 2✕XLEN are passed by reference and are replaced in // the argument list with the address." // "Aggregates larger than 2✕XLEN bits are passed by reference and are @@ -35,7 +35,7 @@ fn classify_arg_ty(arg: &mut ArgType, xlen: u64) { arg.extend_integer_width_to(xlen); // this method only affects integer scalars } -pub fn compute_abi_info(fty: &mut FnType, xlen: u64) { +pub fn compute_abi_info(fty: &mut FnType<'_, Ty>, xlen: u64) { if !fty.ret.is_ignore() { classify_ret_ty(&mut fty.ret, xlen); } diff --git a/src/librustc_target/abi/call/s390x.rs b/src/librustc_target/abi/call/s390x.rs index 954c37fee42dd..c2717b1bcb815 100644 --- a/src/librustc_target/abi/call/s390x.rs +++ b/src/librustc_target/abi/call/s390x.rs @@ -1,10 +1,10 @@ // FIXME: The assumes we're using the non-vector ABI, i.e., compiling // for a pre-z13 machine or using -mno-vx. -use abi::call::{FnType, ArgType, Reg}; -use abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::abi::call::{FnType, ArgType, Reg}; +use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; -fn classify_ret_ty<'a, Ty, C>(ret: &mut ArgType) +fn classify_ret_ty<'a, Ty, C>(ret: &mut ArgType<'_, Ty>) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { if !ret.layout.is_aggregate() && ret.layout.size.bits() <= 64 { diff --git a/src/librustc_target/abi/call/sparc.rs b/src/librustc_target/abi/call/sparc.rs index 2335bfbb5b87b..d496abf8e8b28 100644 --- a/src/librustc_target/abi/call/sparc.rs +++ b/src/librustc_target/abi/call/sparc.rs @@ -1,7 +1,7 @@ -use abi::call::{ArgType, FnType, Reg, Uniform}; -use abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods}; +use crate::abi::call::{ArgType, FnType, Reg, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods}; -fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType, offset: &mut Size) +fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'_, Ty>, offset: &mut Size) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { if !ret.layout.is_aggregate() { @@ -12,7 +12,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType, offset: &mut Size) } } -fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType, offset: &mut Size) +fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'_, Ty>, offset: &mut Size) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { let dl = cx.data_layout(); @@ -34,7 +34,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType, offset: &mut Size) *offset = offset.align_to(align) + size.align_to(align); } -pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType) +pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'_, Ty>) where Ty: TyLayoutMethods<'a, C>, C: LayoutOf + HasDataLayout { let mut offset = Size::ZERO; diff --git a/src/librustc_target/abi/call/sparc64.rs b/src/librustc_target/abi/call/sparc64.rs index 150b48a8d0255..d8930a875efbc 100644 --- a/src/librustc_target/abi/call/sparc64.rs +++ b/src/librustc_target/abi/call/sparc64.rs @@ -1,7 +1,7 @@ // FIXME: This needs an audit for correctness and completeness. -use abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; -use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>) -> Option diff --git a/src/librustc_target/abi/call/wasm32.rs b/src/librustc_target/abi/call/wasm32.rs index 78f43f8b508b3..1fdcbb8e39bdf 100644 --- a/src/librustc_target/abi/call/wasm32.rs +++ b/src/librustc_target/abi/call/wasm32.rs @@ -1,14 +1,14 @@ -use abi::call::{FnType, ArgType}; +use crate::abi::call::{FnType, ArgType}; -fn classify_ret_ty(ret: &mut ArgType) { +fn classify_ret_ty(ret: &mut ArgType<'_, Ty>) { ret.extend_integer_width_to(32); } -fn classify_arg_ty(arg: &mut ArgType) { +fn classify_arg_ty(arg: &mut ArgType<'_, Ty>) { arg.extend_integer_width_to(32); } -pub fn compute_abi_info(fty: &mut FnType) { +pub fn compute_abi_info(fty: &mut FnType<'_, Ty>) { if !fty.ret.is_ignore() { classify_ret_ty(&mut fty.ret); } diff --git a/src/librustc_target/abi/call/x86.rs b/src/librustc_target/abi/call/x86.rs index 648a4b5bb9d79..2e809571ab18b 100644 --- a/src/librustc_target/abi/call/x86.rs +++ b/src/librustc_target/abi/call/x86.rs @@ -1,6 +1,6 @@ -use abi::call::{ArgAttribute, FnType, PassMode, Reg, RegKind}; -use abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; -use spec::HasTargetSpec; +use crate::abi::call::{ArgAttribute, FnType, PassMode, Reg, RegKind}; +use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::spec::HasTargetSpec; #[derive(PartialEq)] pub enum Flavor { diff --git a/src/librustc_target/abi/call/x86_64.rs b/src/librustc_target/abi/call/x86_64.rs index 9d8cc19aac524..680e529b108e0 100644 --- a/src/librustc_target/abi/call/x86_64.rs +++ b/src/librustc_target/abi/call/x86_64.rs @@ -1,8 +1,8 @@ // The classification code for the x86_64 ABI is taken from the clay language // https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp -use abi::call::{ArgType, CastTarget, FnType, Reg, RegKind}; -use abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods}; +use crate::abi::call::{ArgType, CastTarget, FnType, Reg, RegKind}; +use crate::abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods}; /// Classification of "eightbyte" components. // N.B., the order of the variants is from general to specific, diff --git a/src/librustc_target/abi/call/x86_win64.rs b/src/librustc_target/abi/call/x86_win64.rs index c583f7a0a2a24..ebdeb63150a46 100644 --- a/src/librustc_target/abi/call/x86_win64.rs +++ b/src/librustc_target/abi/call/x86_win64.rs @@ -1,10 +1,10 @@ -use abi::call::{ArgType, FnType, Reg}; -use abi::Abi; +use crate::abi::call::{ArgType, FnType, Reg}; +use crate::abi::Abi; // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx -pub fn compute_abi_info(fty: &mut FnType) { - let fixup = |a: &mut ArgType| { +pub fn compute_abi_info(fty: &mut FnType<'_, Ty>) { + let fixup = |a: &mut ArgType<'_, Ty>| { match a.layout.abi { Abi::Uninhabited => {} Abi::ScalarPair(..) | diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 3f95e666535be..bb194d5bb1285 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -1,7 +1,7 @@ -pub use self::Integer::*; -pub use self::Primitive::*; +pub use Integer::*; +pub use Primitive::*; -use spec::Target; +use crate::spec::Target; use std::fmt; use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive}; @@ -533,13 +533,13 @@ pub enum FloatTy { } impl fmt::Debug for FloatTy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self, f) } } impl fmt::Display for FloatTy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.ty_to_string()) } } diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index 0df0027c171aa..aab286a4a7d1b 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -17,11 +17,11 @@ #![feature(slice_patterns)] #![feature(step_trait)] -#[macro_use] -extern crate bitflags; -extern crate serialize; +#![deny(rust_2018_idioms)] + #[macro_use] extern crate log; +#[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. diff --git a/src/librustc_target/spec/aarch64_apple_ios.rs b/src/librustc_target/spec/aarch64_apple_ios.rs index 2210fd1e9e7c9..8bdc08c788d01 100644 --- a/src/librustc_target/spec/aarch64_apple_ios.rs +++ b/src/librustc_target/spec/aarch64_apple_ios.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; use super::apple_ios_base::{opts, Arch}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/aarch64_fuchsia.rs b/src/librustc_target/spec/aarch64_fuchsia.rs index e39a1c2e1068c..308954d56f8bf 100644 --- a/src/librustc_target/spec/aarch64_fuchsia.rs +++ b/src/librustc_target/spec/aarch64_fuchsia.rs @@ -1,4 +1,4 @@ -use spec::{LldFlavor, LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LldFlavor, LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::fuchsia_base::opts(); diff --git a/src/librustc_target/spec/aarch64_linux_android.rs b/src/librustc_target/spec/aarch64_linux_android.rs index c05964295d37a..65160f6231e8c 100644 --- a/src/librustc_target/spec/aarch64_linux_android.rs +++ b/src/librustc_target/spec/aarch64_linux_android.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; // See https://developer.android.com/ndk/guides/abis.html#arm64-v8a // for target ABI requirements. diff --git a/src/librustc_target/spec/aarch64_pc_windows_msvc.rs b/src/librustc_target/spec/aarch64_pc_windows_msvc.rs index b33430b59e8f9..1aee381d604c3 100644 --- a/src/librustc_target/spec/aarch64_pc_windows_msvc.rs +++ b/src/librustc_target/spec/aarch64_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult, PanicStrategy}; +use crate::spec::{LinkerFlavor, Target, TargetResult, PanicStrategy}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_cloudabi.rs b/src/librustc_target/spec/aarch64_unknown_cloudabi.rs index ac3345ce3f214..7141954306769 100644 --- a/src/librustc_target/spec/aarch64_unknown_cloudabi.rs +++ b/src/librustc_target/spec/aarch64_unknown_cloudabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::cloudabi_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_freebsd.rs b/src/librustc_target/spec/aarch64_unknown_freebsd.rs index 1fb0a2bcf7c22..36860649c53ad 100644 --- a/src/librustc_target/spec/aarch64_unknown_freebsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_hermit.rs b/src/librustc_target/spec/aarch64_unknown_hermit.rs index 26006d0060d49..7b020605102b1 100644 --- a/src/librustc_target/spec/aarch64_unknown_hermit.rs +++ b/src/librustc_target/spec/aarch64_unknown_hermit.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::hermit_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs b/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs index d30d927b6dd3d..e772d8b532cb0 100644 --- a/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_linux_musl.rs b/src/librustc_target/spec/aarch64_unknown_linux_musl.rs index 258725fed15be..8123ee82ed524 100644 --- a/src/librustc_target/spec/aarch64_unknown_linux_musl.rs +++ b/src/librustc_target/spec/aarch64_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_netbsd.rs b/src/librustc_target/spec/aarch64_unknown_netbsd.rs index 10aef8f923d4c..47ae08ade9a6b 100644 --- a/src/librustc_target/spec/aarch64_unknown_netbsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/aarch64_unknown_openbsd.rs b/src/librustc_target/spec/aarch64_unknown_openbsd.rs index 815e11a919c0f..c9cd64c3a84af 100644 --- a/src/librustc_target/spec/aarch64_unknown_openbsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_openbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::openbsd_base::opts(); diff --git a/src/librustc_target/spec/abi.rs b/src/librustc_target/spec/abi.rs index 46606e707d757..c9c41f1092240 100644 --- a/src/librustc_target/spec/abi.rs +++ b/src/librustc_target/spec/abi.rs @@ -96,7 +96,7 @@ impl Abi { } impl fmt::Display for Abi { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "\"{}\"", self.name()) } } diff --git a/src/librustc_target/spec/android_base.rs b/src/librustc_target/spec/android_base.rs index a8f8ad3185f0d..684c059b41482 100644 --- a/src/librustc_target/spec/android_base.rs +++ b/src/librustc_target/spec/android_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, TargetOptions}; +use crate::spec::{LinkerFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/apple_base.rs b/src/librustc_target/spec/apple_base.rs index a80d1904a7471..c21f7f38ca5a3 100644 --- a/src/librustc_target/spec/apple_base.rs +++ b/src/librustc_target/spec/apple_base.rs @@ -1,6 +1,6 @@ use std::env; -use spec::{LinkArgs, TargetOptions}; +use crate::spec::{LinkArgs, TargetOptions}; pub fn opts() -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 diff --git a/src/librustc_target/spec/apple_ios_base.rs b/src/librustc_target/spec/apple_ios_base.rs index 72346ab1f34b6..3068ed8d206cd 100644 --- a/src/librustc_target/spec/apple_ios_base.rs +++ b/src/librustc_target/spec/apple_ios_base.rs @@ -1,8 +1,8 @@ use std::io; use std::process::Command; -use spec::{LinkArgs, LinkerFlavor, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; -use self::Arch::*; +use Arch::*; #[allow(non_camel_case_types)] #[derive(Copy, Clone)] diff --git a/src/librustc_target/spec/arm_base.rs b/src/librustc_target/spec/arm_base.rs index 1d51d60c8f258..77e7bfac62d58 100644 --- a/src/librustc_target/spec/arm_base.rs +++ b/src/librustc_target/spec/arm_base.rs @@ -1,4 +1,4 @@ -use spec::abi::Abi; +use crate::spec::abi::Abi; // All the calling conventions trigger an assertion(Unsupported calling convention) in llvm on arm pub fn abi_blacklist() -> Vec { diff --git a/src/librustc_target/spec/arm_linux_androideabi.rs b/src/librustc_target/spec/arm_linux_androideabi.rs index 5e4bebfa1c1a4..bb066dc9ad833 100644 --- a/src/librustc_target/spec/arm_linux_androideabi.rs +++ b/src/librustc_target/spec/arm_linux_androideabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::android_base::opts(); diff --git a/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs b/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs index 0f891dacc6dbf..f291818ba80f5 100644 --- a/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs b/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs index 5503bf326cd7b..32b509d9721ef 100644 --- a/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs +++ b/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/arm_unknown_linux_musleabi.rs b/src/librustc_target/spec/arm_unknown_linux_musleabi.rs index c2162beba26e8..7637577e7e848 100644 --- a/src/librustc_target/spec/arm_unknown_linux_musleabi.rs +++ b/src/librustc_target/spec/arm_unknown_linux_musleabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs b/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs index b3f00331b3c9e..9def151b3ef29 100644 --- a/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs +++ b/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/armebv7r_none_eabi.rs b/src/librustc_target/spec/armebv7r_none_eabi.rs index cd41ffbab4d9c..86c62daa6180a 100644 --- a/src/librustc_target/spec/armebv7r_none_eabi.rs +++ b/src/librustc_target/spec/armebv7r_none_eabi.rs @@ -1,7 +1,7 @@ // Targets the Big endian Cortex-R4/R5 processor (ARMv7-R) use std::default::Default; -use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/armebv7r_none_eabihf.rs b/src/librustc_target/spec/armebv7r_none_eabihf.rs index 05b12dd28bacd..50ee76414ef9a 100644 --- a/src/librustc_target/spec/armebv7r_none_eabihf.rs +++ b/src/librustc_target/spec/armebv7r_none_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Cortex-R4F/R5F processor (ARMv7-R) use std::default::Default; -use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs b/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs index 7fe021e5327b9..7cd4b14cdebc8 100644 --- a/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs b/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs index c85a80f6e8a4c..15f614827718b 100644 --- a/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs b/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs index dce767898c06b..74915b942ea4f 100644 --- a/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs +++ b/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs b/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs index 95cc41e6c98fb..e460b6c574a26 100644 --- a/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs +++ b/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/armv7_apple_ios.rs b/src/librustc_target/spec/armv7_apple_ios.rs index 98018215c805a..2052d17403dfd 100644 --- a/src/librustc_target/spec/armv7_apple_ios.rs +++ b/src/librustc_target/spec/armv7_apple_ios.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; use super::apple_ios_base::{opts, Arch}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/armv7_linux_androideabi.rs b/src/librustc_target/spec/armv7_linux_androideabi.rs index 65c3c7f7057ab..92f1a55e024d7 100644 --- a/src/librustc_target/spec/armv7_linux_androideabi.rs +++ b/src/librustc_target/spec/armv7_linux_androideabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; // This target if is for the baseline of the Android v7a ABI // in thumb mode. It's named armv7-* instead of thumbv7-* diff --git a/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs b/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs index fa43879dccab8..a6c7fb537c785 100644 --- a/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::cloudabi_base::opts(); diff --git a/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs b/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs index 864c59b81844e..f16215433c766 100644 --- a/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; // This target is for glibc Linux on ARMv7 without NEON or // thumb-mode. See the thumbv7neon variant for enabling both. diff --git a/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs b/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs index ae0cb2c08b430..45a26966b716b 100644 --- a/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; // This target is for musl Linux on ARMv7 without thumb-mode or NEON. diff --git a/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs b/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs index f9e416fd06e92..44e2636e9188e 100644 --- a/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/armv7r_none_eabi.rs b/src/librustc_target/spec/armv7r_none_eabi.rs index 38d115bc85e7f..19d332467dec5 100644 --- a/src/librustc_target/spec/armv7r_none_eabi.rs +++ b/src/librustc_target/spec/armv7r_none_eabi.rs @@ -1,7 +1,7 @@ // Targets the Little-endian Cortex-R4/R5 processor (ARMv7-R) use std::default::Default; -use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/armv7r_none_eabihf.rs b/src/librustc_target/spec/armv7r_none_eabihf.rs index cb707f7183a49..06ef9f3ec4e37 100644 --- a/src/librustc_target/spec/armv7r_none_eabihf.rs +++ b/src/librustc_target/spec/armv7r_none_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Little-endian Cortex-R4F/R5F processor (ARMv7-R) use std::default::Default; -use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/armv7s_apple_ios.rs b/src/librustc_target/spec/armv7s_apple_ios.rs index 6d9635b308e90..29e290285e4a9 100644 --- a/src/librustc_target/spec/armv7s_apple_ios.rs +++ b/src/librustc_target/spec/armv7s_apple_ios.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; use super::apple_ios_base::{opts, Arch}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/bitrig_base.rs b/src/librustc_target/spec/bitrig_base.rs index 3b6985fa4c826..9b34119fc00c9 100644 --- a/src/librustc_target/spec/bitrig_base.rs +++ b/src/librustc_target/spec/bitrig_base.rs @@ -1,4 +1,4 @@ -use spec::{TargetOptions, RelroLevel}; +use crate::spec::{TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/cloudabi_base.rs b/src/librustc_target/spec/cloudabi_base.rs index 145de0ebe6995..a34122d3e0fe2 100644 --- a/src/librustc_target/spec/cloudabi_base.rs +++ b/src/librustc_target/spec/cloudabi_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; pub fn opts() -> TargetOptions { let mut args = LinkArgs::new(); diff --git a/src/librustc_target/spec/dragonfly_base.rs b/src/librustc_target/spec/dragonfly_base.rs index 6ce2912da75cf..766030e8015d0 100644 --- a/src/librustc_target/spec/dragonfly_base.rs +++ b/src/librustc_target/spec/dragonfly_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/freebsd_base.rs b/src/librustc_target/spec/freebsd_base.rs index 47316f77e634e..51f030f59084d 100644 --- a/src/librustc_target/spec/freebsd_base.rs +++ b/src/librustc_target/spec/freebsd_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/fuchsia_base.rs b/src/librustc_target/spec/fuchsia_base.rs index 5d94f308410a6..4e4f2fa0cf34c 100644 --- a/src/librustc_target/spec/fuchsia_base.rs +++ b/src/librustc_target/spec/fuchsia_base.rs @@ -1,4 +1,4 @@ -use spec::{LldFlavor, LinkArgs, LinkerFlavor, TargetOptions}; +use crate::spec::{LldFlavor, LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/haiku_base.rs b/src/librustc_target/spec/haiku_base.rs index 00c6bd40dc584..d071062705306 100644 --- a/src/librustc_target/spec/haiku_base.rs +++ b/src/librustc_target/spec/haiku_base.rs @@ -1,4 +1,4 @@ -use spec::{TargetOptions, RelroLevel}; +use crate::spec::{TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/hermit_base.rs b/src/librustc_target/spec/hermit_base.rs index d7d8562e055d8..ee753393ddb3d 100644 --- a/src/librustc_target/spec/hermit_base.rs +++ b/src/librustc_target/spec/hermit_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/i386_apple_ios.rs b/src/librustc_target/spec/i386_apple_ios.rs index d0e317630013b..78e9cbb61ef58 100644 --- a/src/librustc_target/spec/i386_apple_ios.rs +++ b/src/librustc_target/spec/i386_apple_ios.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; use super::apple_ios_base::{opts, Arch}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/i586_pc_windows_msvc.rs b/src/librustc_target/spec/i586_pc_windows_msvc.rs index 12a7f98beff95..ba712aced8474 100644 --- a/src/librustc_target/spec/i586_pc_windows_msvc.rs +++ b/src/librustc_target/spec/i586_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use spec::TargetResult; +use crate::spec::TargetResult; pub fn target() -> TargetResult { let mut base = super::i686_pc_windows_msvc::target()?; diff --git a/src/librustc_target/spec/i586_unknown_linux_gnu.rs b/src/librustc_target/spec/i586_unknown_linux_gnu.rs index 76f6a4eba389f..49f4f2cb6b999 100644 --- a/src/librustc_target/spec/i586_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/i586_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::TargetResult; +use crate::spec::TargetResult; pub fn target() -> TargetResult { let mut base = super::i686_unknown_linux_gnu::target()?; diff --git a/src/librustc_target/spec/i586_unknown_linux_musl.rs b/src/librustc_target/spec/i586_unknown_linux_musl.rs index 2b56fd7a7e370..0f2ccebd6dace 100644 --- a/src/librustc_target/spec/i586_unknown_linux_musl.rs +++ b/src/librustc_target/spec/i586_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::TargetResult; +use crate::spec::TargetResult; pub fn target() -> TargetResult { let mut base = super::i686_unknown_linux_musl::target()?; diff --git a/src/librustc_target/spec/i686_apple_darwin.rs b/src/librustc_target/spec/i686_apple_darwin.rs index 40d9588e463a6..c8a61296d33d2 100644 --- a/src/librustc_target/spec/i686_apple_darwin.rs +++ b/src/librustc_target/spec/i686_apple_darwin.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::apple_base::opts(); diff --git a/src/librustc_target/spec/i686_linux_android.rs b/src/librustc_target/spec/i686_linux_android.rs index 5b8cb7ac55d58..3f73d24ee848b 100644 --- a/src/librustc_target/spec/i686_linux_android.rs +++ b/src/librustc_target/spec/i686_linux_android.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; // See https://developer.android.com/ndk/guides/abis.html#x86 // for target ABI requirements. diff --git a/src/librustc_target/spec/i686_pc_windows_gnu.rs b/src/librustc_target/spec/i686_pc_windows_gnu.rs index d7bc38ca172d5..12214a7d53119 100644 --- a/src/librustc_target/spec/i686_pc_windows_gnu.rs +++ b/src/librustc_target/spec/i686_pc_windows_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_base::opts(); diff --git a/src/librustc_target/spec/i686_pc_windows_msvc.rs b/src/librustc_target/spec/i686_pc_windows_msvc.rs index f0d75ae4e9bdd..1967834819ab2 100644 --- a/src/librustc_target/spec/i686_pc_windows_msvc.rs +++ b/src/librustc_target/spec/i686_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_cloudabi.rs b/src/librustc_target/spec/i686_unknown_cloudabi.rs index 3a9e424698127..f3b40633b4007 100644 --- a/src/librustc_target/spec/i686_unknown_cloudabi.rs +++ b/src/librustc_target/spec/i686_unknown_cloudabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::cloudabi_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_dragonfly.rs b/src/librustc_target/spec/i686_unknown_dragonfly.rs index 9d71c5a823361..20315e7145c73 100644 --- a/src/librustc_target/spec/i686_unknown_dragonfly.rs +++ b/src/librustc_target/spec/i686_unknown_dragonfly.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::dragonfly_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_freebsd.rs b/src/librustc_target/spec/i686_unknown_freebsd.rs index 627dffa89d247..71f05a140f3df 100644 --- a/src/librustc_target/spec/i686_unknown_freebsd.rs +++ b/src/librustc_target/spec/i686_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_haiku.rs b/src/librustc_target/spec/i686_unknown_haiku.rs index 86c64ce684bb8..b807e4eee39a5 100644 --- a/src/librustc_target/spec/i686_unknown_haiku.rs +++ b/src/librustc_target/spec/i686_unknown_haiku.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::haiku_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_linux_gnu.rs b/src/librustc_target/spec/i686_unknown_linux_gnu.rs index ab38832831157..5875cbf78bfe6 100644 --- a/src/librustc_target/spec/i686_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/i686_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_linux_musl.rs b/src/librustc_target/spec/i686_unknown_linux_musl.rs index 81cbf57e577a6..732949034e824 100644 --- a/src/librustc_target/spec/i686_unknown_linux_musl.rs +++ b/src/librustc_target/spec/i686_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_netbsd.rs b/src/librustc_target/spec/i686_unknown_netbsd.rs index 1027e240224c9..e8a9f29ea5f4c 100644 --- a/src/librustc_target/spec/i686_unknown_netbsd.rs +++ b/src/librustc_target/spec/i686_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/i686_unknown_openbsd.rs b/src/librustc_target/spec/i686_unknown_openbsd.rs index d2bbc6bb2dbaf..d7c323e0d8a8a 100644 --- a/src/librustc_target/spec/i686_unknown_openbsd.rs +++ b/src/librustc_target/spec/i686_unknown_openbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::openbsd_base::opts(); diff --git a/src/librustc_target/spec/l4re_base.rs b/src/librustc_target/spec/l4re_base.rs index 951005998be07..9317f053efe70 100644 --- a/src/librustc_target/spec/l4re_base.rs +++ b/src/librustc_target/spec/l4re_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions}; use std::default::Default; //use std::process::Command; diff --git a/src/librustc_target/spec/linux_base.rs b/src/librustc_target/spec/linux_base.rs index b036bf81a7542..195fba3915f94 100644 --- a/src/librustc_target/spec/linux_base.rs +++ b/src/librustc_target/spec/linux_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs index 1bc90d1a73287..e294e63982de4 100644 --- a/src/librustc_target/spec/linux_musl_base.rs +++ b/src/librustc_target/spec/linux_musl_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, TargetOptions}; +use crate::spec::{LinkerFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs b/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs index 650f38702b67b..3b38e64050f3b 100644 --- a/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs +++ b/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs b/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs index cb348d49479b9..0f6cd86d616d8 100644 --- a/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs +++ b/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/mips_unknown_linux_gnu.rs b/src/librustc_target/spec/mips_unknown_linux_gnu.rs index 6cc3d30be1fb0..b4d29c5fbeaf4 100644 --- a/src/librustc_target/spec/mips_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/mips_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/mips_unknown_linux_musl.rs b/src/librustc_target/spec/mips_unknown_linux_musl.rs index 152b11b4aeeb5..c56c6e3822959 100644 --- a/src/librustc_target/spec/mips_unknown_linux_musl.rs +++ b/src/librustc_target/spec/mips_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/mips_unknown_linux_uclibc.rs b/src/librustc_target/spec/mips_unknown_linux_uclibc.rs index 99cd20e9a52e8..cb02769c7dfe4 100644 --- a/src/librustc_target/spec/mips_unknown_linux_uclibc.rs +++ b/src/librustc_target/spec/mips_unknown_linux_uclibc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs b/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs index 476cf15270649..ed49ddd49937f 100644 --- a/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/mipsel_unknown_linux_musl.rs b/src/librustc_target/spec/mipsel_unknown_linux_musl.rs index 9df131dbe2510..bcc49cf5ffe4f 100644 --- a/src/librustc_target/spec/mipsel_unknown_linux_musl.rs +++ b/src/librustc_target/spec/mipsel_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs b/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs index 37c55d11f25c9..205f328a24cec 100644 --- a/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs +++ b/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index aeecce49b0c67..107583e4fc0a0 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -40,7 +40,7 @@ use std::default::Default; use std::{fmt, io}; use std::path::{Path, PathBuf}; use std::str::FromStr; -use spec::abi::{Abi, lookup as lookup_abi}; +use crate::spec::abi::{Abi, lookup as lookup_abi}; pub mod abi; mod android_base; @@ -1408,7 +1408,7 @@ impl TargetTriple { } impl fmt::Display for TargetTriple { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.debug_triple()) } } diff --git a/src/librustc_target/spec/msp430_none_elf.rs b/src/librustc_target/spec/msp430_none_elf.rs index df564bc924baf..90af5898089b8 100644 --- a/src/librustc_target/spec/msp430_none_elf.rs +++ b/src/librustc_target/spec/msp430_none_elf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/netbsd_base.rs b/src/librustc_target/spec/netbsd_base.rs index b88d360dd3785..e9cd98c0e7151 100644 --- a/src/librustc_target/spec/netbsd_base.rs +++ b/src/librustc_target/spec/netbsd_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/nvptx64_nvidia_cuda.rs b/src/librustc_target/spec/nvptx64_nvidia_cuda.rs index e8512415e66a3..db9d6a7409ee5 100644 --- a/src/librustc_target/spec/nvptx64_nvidia_cuda.rs +++ b/src/librustc_target/spec/nvptx64_nvidia_cuda.rs @@ -1,5 +1,5 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy, MergeFunctions}; -use spec::abi::Abi; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy, MergeFunctions}; +use crate::spec::abi::Abi; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/openbsd_base.rs b/src/librustc_target/spec/openbsd_base.rs index 4bdf73fc92213..5bcfd62d75bd4 100644 --- a/src/librustc_target/spec/openbsd_base.rs +++ b/src/librustc_target/spec/openbsd_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/powerpc64_unknown_freebsd.rs b/src/librustc_target/spec/powerpc64_unknown_freebsd.rs index cc7b87bfdebc3..360876b9ff557 100644 --- a/src/librustc_target/spec/powerpc64_unknown_freebsd.rs +++ b/src/librustc_target/spec/powerpc64_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); diff --git a/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs b/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs index 1f7ae933cedd1..c16db7583f32b 100644 --- a/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult, RelroLevel}; +use crate::spec::{LinkerFlavor, Target, TargetResult, RelroLevel}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/powerpc64_unknown_linux_musl.rs b/src/librustc_target/spec/powerpc64_unknown_linux_musl.rs index 6fc8be8a5c4d8..ac0b7431f91a4 100644 --- a/src/librustc_target/spec/powerpc64_unknown_linux_musl.rs +++ b/src/librustc_target/spec/powerpc64_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs b/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs index 21791a75d2a29..038b925a28692 100644 --- a/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs b/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs index 38f7fe887f5a9..57103345f0a0c 100644 --- a/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs +++ b/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs b/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs index 286d177c864e4..38a801d5ab507 100644 --- a/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs b/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs index ae144af047232..675b2c749d648 100644 --- a/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs +++ b/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/powerpc_unknown_linux_musl.rs b/src/librustc_target/spec/powerpc_unknown_linux_musl.rs index 3b61889163b4c..240443aa98db4 100644 --- a/src/librustc_target/spec/powerpc_unknown_linux_musl.rs +++ b/src/librustc_target/spec/powerpc_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/powerpc_unknown_netbsd.rs b/src/librustc_target/spec/powerpc_unknown_netbsd.rs index e8662a7851907..10e7089cf1c4c 100644 --- a/src/librustc_target/spec/powerpc_unknown_netbsd.rs +++ b/src/librustc_target/spec/powerpc_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/redox_base.rs b/src/librustc_target/spec/redox_base.rs index dd32f02e34049..dc51aeb58391f 100644 --- a/src/librustc_target/spec/redox_base.rs +++ b/src/librustc_target/spec/redox_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs b/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs index 8adf562ca7e52..5064393d31135 100644 --- a/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, LldFlavor, PanicStrategy, +use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs b/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs index 5d8157ee59a0a..31e74c5920cf9 100644 --- a/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, LldFlavor, PanicStrategy, +use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/riscv_base.rs b/src/librustc_target/spec/riscv_base.rs index ea7fdc39a9a96..ec1dc9b4918bd 100644 --- a/src/librustc_target/spec/riscv_base.rs +++ b/src/librustc_target/spec/riscv_base.rs @@ -1,4 +1,4 @@ -use spec::abi::Abi; +use crate::spec::abi::Abi; // All the calling conventions trigger an assertion(Unsupported calling // convention) in llvm on RISCV diff --git a/src/librustc_target/spec/s390x_unknown_linux_gnu.rs b/src/librustc_target/spec/s390x_unknown_linux_gnu.rs index c18c94511f8d7..f259787e1d54d 100644 --- a/src/librustc_target/spec/s390x_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/s390x_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/solaris_base.rs b/src/librustc_target/spec/solaris_base.rs index f5f8509210570..0dfbb13b77317 100644 --- a/src/librustc_target/spec/solaris_base.rs +++ b/src/librustc_target/spec/solaris_base.rs @@ -1,4 +1,4 @@ -use spec::TargetOptions; +use crate::spec::TargetOptions; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs b/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs index e5e3752be7f82..c842b22d4e16e 100644 --- a/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/sparc64_unknown_netbsd.rs b/src/librustc_target/spec/sparc64_unknown_netbsd.rs index 62efd41dbb8ee..78d53e69e8b52 100644 --- a/src/librustc_target/spec/sparc64_unknown_netbsd.rs +++ b/src/librustc_target/spec/sparc64_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/sparc_unknown_linux_gnu.rs b/src/librustc_target/spec/sparc_unknown_linux_gnu.rs index b6468993790d8..162cd311a3826 100644 --- a/src/librustc_target/spec/sparc_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/sparc_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/sparcv9_sun_solaris.rs b/src/librustc_target/spec/sparcv9_sun_solaris.rs index f1c5c5ac44f1a..acc03fd0d79ee 100644 --- a/src/librustc_target/spec/sparcv9_sun_solaris.rs +++ b/src/librustc_target/spec/sparcv9_sun_solaris.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::solaris_base::opts(); diff --git a/src/librustc_target/spec/thumb_base.rs b/src/librustc_target/spec/thumb_base.rs index 06cb6a8d823ef..ed0dbb766a835 100644 --- a/src/librustc_target/spec/thumb_base.rs +++ b/src/librustc_target/spec/thumb_base.rs @@ -28,7 +28,7 @@ // build scripts / gcc flags. use std::default::Default; -use spec::{PanicStrategy, TargetOptions}; +use crate::spec::{PanicStrategy, TargetOptions}; pub fn opts() -> TargetOptions { // See rust-lang/rfcs#1645 for a discussion about these defaults diff --git a/src/librustc_target/spec/thumbv6m_none_eabi.rs b/src/librustc_target/spec/thumbv6m_none_eabi.rs index 98c46e9c600a3..2ab61b57f6bb6 100644 --- a/src/librustc_target/spec/thumbv6m_none_eabi.rs +++ b/src/librustc_target/spec/thumbv6m_none_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture) -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs b/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs index eaa08fadbc0f3..310fac31c0c5b 100644 --- a/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs +++ b/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); diff --git a/src/librustc_target/spec/thumbv7em_none_eabi.rs b/src/librustc_target/spec/thumbv7em_none_eabi.rs index 8a1fe09cdb07a..97114c342cdc7 100644 --- a/src/librustc_target/spec/thumbv7em_none_eabi.rs +++ b/src/librustc_target/spec/thumbv7em_none_eabi.rs @@ -9,7 +9,7 @@ // To opt-in to hardware accelerated floating point operations, you can use, for example, // `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`. -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/thumbv7em_none_eabihf.rs b/src/librustc_target/spec/thumbv7em_none_eabihf.rs index 0c9aa1c5149ff..e4358bdd7991e 100644 --- a/src/librustc_target/spec/thumbv7em_none_eabihf.rs +++ b/src/librustc_target/spec/thumbv7em_none_eabihf.rs @@ -8,7 +8,7 @@ // // To opt into double precision hardware support, use the `-C target-feature=-fp-only-sp` flag. -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/thumbv7m_none_eabi.rs b/src/librustc_target/spec/thumbv7m_none_eabi.rs index 9bff3473c58af..daf25b16d58d6 100644 --- a/src/librustc_target/spec/thumbv7m_none_eabi.rs +++ b/src/librustc_target/spec/thumbv7m_none_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M3 processor (ARMv7-M) -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs b/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs index 2d92e29c09d96..e248b930e6e4c 100644 --- a/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs +++ b/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; // This target if is for the Android v7a ABI in thumb mode with // NEON unconditionally enabled and, therefore, with 32 FPU registers diff --git a/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs b/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs index bdf57969154c0..bef62b0a2ebe6 100644 --- a/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs +++ b/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; // This target is for glibc Linux on ARMv7 with thumb mode enabled // (for consistency with Android and Debian-based distributions) diff --git a/src/librustc_target/spec/thumbv8m_base_none_eabi.rs b/src/librustc_target/spec/thumbv8m_base_none_eabi.rs index 0e0e73efd45cc..be8a476db4dbc 100644 --- a/src/librustc_target/spec/thumbv8m_base_none_eabi.rs +++ b/src/librustc_target/spec/thumbv8m_base_none_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M23 processor (Baseline ARMv8-M) -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/thumbv8m_main_none_eabi.rs b/src/librustc_target/spec/thumbv8m_main_none_eabi.rs index dc2454d749780..49ab643d484bc 100644 --- a/src/librustc_target/spec/thumbv8m_main_none_eabi.rs +++ b/src/librustc_target/spec/thumbv8m_main_none_eabi.rs @@ -1,7 +1,7 @@ // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), // without the Floating Point extension. -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/thumbv8m_main_none_eabihf.rs b/src/librustc_target/spec/thumbv8m_main_none_eabihf.rs index 5fa1f42288d1a..6a3d8e61d7fe8 100644 --- a/src/librustc_target/spec/thumbv8m_main_none_eabihf.rs +++ b/src/librustc_target/spec/thumbv8m_main_none_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), // with the Floating Point extension. -use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { Ok(Target { diff --git a/src/librustc_target/spec/uefi_base.rs b/src/librustc_target/spec/uefi_base.rs index 4628089ffe1f4..5078d500679d1 100644 --- a/src/librustc_target/spec/uefi_base.rs +++ b/src/librustc_target/spec/uefi_base.rs @@ -9,7 +9,7 @@ // the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all // code runs in the same environment, no process separation is supported. -use spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/windows_base.rs b/src/librustc_target/spec/windows_base.rs index 65d618232a249..38db9cd356cd8 100644 --- a/src/librustc_target/spec/windows_base.rs +++ b/src/librustc_target/spec/windows_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/windows_msvc_base.rs b/src/librustc_target/spec/windows_msvc_base.rs index 89f6b1bcc71c5..fdd747cdb865a 100644 --- a/src/librustc_target/spec/windows_msvc_base.rs +++ b/src/librustc_target/spec/windows_msvc_base.rs @@ -1,4 +1,4 @@ -use spec::{LinkArgs, LinkerFlavor, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { diff --git a/src/librustc_target/spec/x86_64_apple_darwin.rs b/src/librustc_target/spec/x86_64_apple_darwin.rs index 7de33fe8ac52a..0911ce06c13d7 100644 --- a/src/librustc_target/spec/x86_64_apple_darwin.rs +++ b/src/librustc_target/spec/x86_64_apple_darwin.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::apple_base::opts(); diff --git a/src/librustc_target/spec/x86_64_apple_ios.rs b/src/librustc_target/spec/x86_64_apple_ios.rs index 286a73d48048c..1f9594b906282 100644 --- a/src/librustc_target/spec/x86_64_apple_ios.rs +++ b/src/librustc_target/spec/x86_64_apple_ios.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; use super::apple_ios_base::{opts, Arch}; pub fn target() -> TargetResult { diff --git a/src/librustc_target/spec/x86_64_fuchsia.rs b/src/librustc_target/spec/x86_64_fuchsia.rs index 00fb7066ca28f..a24d432c591d2 100644 --- a/src/librustc_target/spec/x86_64_fuchsia.rs +++ b/src/librustc_target/spec/x86_64_fuchsia.rs @@ -1,4 +1,4 @@ -use spec::{LldFlavor, LinkerFlavor, Target, TargetResult}; +use crate::spec::{LldFlavor, LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::fuchsia_base::opts(); diff --git a/src/librustc_target/spec/x86_64_linux_android.rs b/src/librustc_target/spec/x86_64_linux_android.rs index 29d5dfa5790a1..c3c6c7bf56fef 100644 --- a/src/librustc_target/spec/x86_64_linux_android.rs +++ b/src/librustc_target/spec/x86_64_linux_android.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::android_base::opts(); diff --git a/src/librustc_target/spec/x86_64_pc_windows_gnu.rs b/src/librustc_target/spec/x86_64_pc_windows_gnu.rs index c3c36d22cef5e..35e0d55cd045e 100644 --- a/src/librustc_target/spec/x86_64_pc_windows_gnu.rs +++ b/src/librustc_target/spec/x86_64_pc_windows_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_base::opts(); diff --git a/src/librustc_target/spec/x86_64_pc_windows_msvc.rs b/src/librustc_target/spec/x86_64_pc_windows_msvc.rs index 178d67784e653..073d49be5a9ab 100644 --- a/src/librustc_target/spec/x86_64_pc_windows_msvc.rs +++ b/src/librustc_target/spec/x86_64_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); diff --git a/src/librustc_target/spec/x86_64_rumprun_netbsd.rs b/src/librustc_target/spec/x86_64_rumprun_netbsd.rs index 37c7925c6985e..a2c706c4c7232 100644 --- a/src/librustc_target/spec/x86_64_rumprun_netbsd.rs +++ b/src/librustc_target/spec/x86_64_rumprun_netbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/x86_64_sun_solaris.rs b/src/librustc_target/spec/x86_64_sun_solaris.rs index 3534f9e6436b4..3bf3f51ae2512 100644 --- a/src/librustc_target/spec/x86_64_sun_solaris.rs +++ b/src/librustc_target/spec/x86_64_sun_solaris.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::solaris_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_bitrig.rs b/src/librustc_target/spec/x86_64_unknown_bitrig.rs index fa5392175606a..999d93a7e6090 100644 --- a/src/librustc_target/spec/x86_64_unknown_bitrig.rs +++ b/src/librustc_target/spec/x86_64_unknown_bitrig.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::bitrig_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_cloudabi.rs b/src/librustc_target/spec/x86_64_unknown_cloudabi.rs index c1253a3b2727b..d48120c5401c2 100644 --- a/src/librustc_target/spec/x86_64_unknown_cloudabi.rs +++ b/src/librustc_target/spec/x86_64_unknown_cloudabi.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::cloudabi_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_dragonfly.rs b/src/librustc_target/spec/x86_64_unknown_dragonfly.rs index 815aa57252561..f55ee6969092b 100644 --- a/src/librustc_target/spec/x86_64_unknown_dragonfly.rs +++ b/src/librustc_target/spec/x86_64_unknown_dragonfly.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::dragonfly_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_freebsd.rs b/src/librustc_target/spec/x86_64_unknown_freebsd.rs index 8d43883f33bf3..1d9c5cce3f729 100644 --- a/src/librustc_target/spec/x86_64_unknown_freebsd.rs +++ b/src/librustc_target/spec/x86_64_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_haiku.rs b/src/librustc_target/spec/x86_64_unknown_haiku.rs index 608354732d9d1..4ab15fa4e90f5 100644 --- a/src/librustc_target/spec/x86_64_unknown_haiku.rs +++ b/src/librustc_target/spec/x86_64_unknown_haiku.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::haiku_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_hermit.rs b/src/librustc_target/spec/x86_64_unknown_hermit.rs index de5992cbf5ef2..a696ee16d7c9e 100644 --- a/src/librustc_target/spec/x86_64_unknown_hermit.rs +++ b/src/librustc_target/spec/x86_64_unknown_hermit.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::hermit_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_l4re_uclibc.rs b/src/librustc_target/spec/x86_64_unknown_l4re_uclibc.rs index cf04cc1bdc2f5..e5fdb386ef301 100644 --- a/src/librustc_target/spec/x86_64_unknown_l4re_uclibc.rs +++ b/src/librustc_target/spec/x86_64_unknown_l4re_uclibc.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::l4re_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_linux_gnu.rs b/src/librustc_target/spec/x86_64_unknown_linux_gnu.rs index c6ec8de5b7312..cb279e86f1498 100644 --- a/src/librustc_target/spec/x86_64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/x86_64_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs b/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs index e4dfb8d05cdfa..0b2d7aacc4ddf 100644 --- a/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs +++ b/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_linux_musl.rs b/src/librustc_target/spec/x86_64_unknown_linux_musl.rs index 95321fe2f783e..2e1bc839873c7 100644 --- a/src/librustc_target/spec/x86_64_unknown_linux_musl.rs +++ b/src/librustc_target/spec/x86_64_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_netbsd.rs b/src/librustc_target/spec/x86_64_unknown_netbsd.rs index fbd07ecce1afb..ffc4f1d5c49b7 100644 --- a/src/librustc_target/spec/x86_64_unknown_netbsd.rs +++ b/src/librustc_target/spec/x86_64_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_openbsd.rs b/src/librustc_target/spec/x86_64_unknown_openbsd.rs index 68496247b1596..f2abd1071227e 100644 --- a/src/librustc_target/spec/x86_64_unknown_openbsd.rs +++ b/src/librustc_target/spec/x86_64_unknown_openbsd.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::openbsd_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_redox.rs b/src/librustc_target/spec/x86_64_unknown_redox.rs index d04bc5cc6ec21..f0a4519f59548 100644 --- a/src/librustc_target/spec/x86_64_unknown_redox.rs +++ b/src/librustc_target/spec/x86_64_unknown_redox.rs @@ -1,4 +1,4 @@ -use spec::{LinkerFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::redox_base::opts(); diff --git a/src/librustc_target/spec/x86_64_unknown_uefi.rs b/src/librustc_target/spec/x86_64_unknown_uefi.rs index 0d7b4fc060bd9..9ac17a1693fb5 100644 --- a/src/librustc_target/spec/x86_64_unknown_uefi.rs +++ b/src/librustc_target/spec/x86_64_unknown_uefi.rs @@ -5,7 +5,7 @@ // The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with // LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features. -use spec::{LinkerFlavor, LldFlavor, Target, TargetResult}; +use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::uefi_base::opts(); From 0e622a8ba1d43904ff16231e4fe8a1907e66d563 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 21:06:07 +0900 Subject: [PATCH 18/21] librustc_codegen_utils => 2018 --- src/librustc_codegen_utils/Cargo.toml | 1 + src/librustc_codegen_utils/codegen_backend.rs | 22 +++++++++---------- src/librustc_codegen_utils/lib.rs | 12 ++-------- src/librustc_codegen_utils/link.rs | 2 +- src/librustc_codegen_utils/symbol_names.rs | 4 +++- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/librustc_codegen_utils/Cargo.toml b/src/librustc_codegen_utils/Cargo.toml index 34a09f30b6411..5f241eb20fb55 100644 --- a/src/librustc_codegen_utils/Cargo.toml +++ b/src/librustc_codegen_utils/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_codegen_utils" version = "0.0.0" +edition = "2018" [lib] name = "rustc_codegen_utils" diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 8981c542961e2..8270d2a4077cf 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -31,7 +31,7 @@ use rustc::middle::cstore::EncodedMetadata; use rustc::middle::cstore::MetadataLoader; use rustc::dep_graph::DepGraph; use rustc_target::spec::Target; -use link::out_filename; +use crate::link::out_filename; pub use rustc_data_structures::sync::MetadataRef; @@ -44,8 +44,8 @@ pub trait CodegenBackend { fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] } fn metadata_loader(&self) -> Box; - fn provide(&self, _providers: &mut Providers); - fn provide_extern(&self, _providers: &mut Providers); + fn provide(&self, _providers: &mut Providers<'_>); + fn provide_extern(&self, _providers: &mut Providers<'_>); fn codegen_crate<'a, 'tcx>( &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -111,8 +111,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { box NoLlvmMetadataLoader } - fn provide(&self, providers: &mut Providers) { - ::symbol_names::provide(providers); + fn provide(&self, providers: &mut Providers<'_>) { + crate::symbol_names::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| { Default::default() // Just a dummy @@ -120,7 +120,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { providers.is_reachable_non_generic = |_tcx, _defid| true; 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; } @@ -131,12 +131,12 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { ) -> Box { use rustc_mir::monomorphize::item::MonoItem; - ::check_for_rustc_errors_attr(tcx); - ::symbol_names_test::report_symbol_names(tcx); - ::rustc_incremental::assert_dep_graph(tcx); - ::rustc_incremental::assert_module_sources::assert_module_sources(tcx); + crate::check_for_rustc_errors_attr(tcx); + crate::symbol_names_test::report_symbol_names(tcx); + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::assert_module_sources::assert_module_sources(tcx); // FIXME: Fix this - // ::rustc::middle::dependency_format::calculate(tcx); + // rustc::middle::dependency_format::calculate(tcx); let _ = tcx.link_args(LOCAL_CRATE); let _ = tcx.native_libraries(LOCAL_CRATE); let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 8e96f98540117..4c01681320f2b 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -16,18 +16,10 @@ #![recursion_limit="256"] -extern crate flate2; -#[macro_use] -extern crate log; +#![deny(rust_2018_idioms)] #[macro_use] 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; use rustc::ty::TyCtxt; @@ -42,7 +34,7 @@ pub mod symbol_names_test; /// error in codegen. This is used to write compile-fail tests /// that actually test that compilation succeeds without /// 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 tcx.has_attr(def_id, "rustc_error") { tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful"); diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs index 09e22bd2c91a9..f3a1b219f8a84 100644 --- a/src/librustc_codegen_utils/link.rs +++ b/src/librustc_codegen_utils/link.rs @@ -41,7 +41,7 @@ pub fn find_crate_name(sess: Option<&Session>, attrs: &[ast::Attribute], input: &Input) -> String { let validate = |s: String, span: Option| { - ::rustc_metadata::validate_crate_name(sess, &s, span); + rustc_metadata::validate_crate_name(sess, &s, span); s }; diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 3238a0b10bfd6..8d105853d92f1 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -103,10 +103,12 @@ use rustc_mir::monomorphize::Instance; use syntax_pos::symbol::Symbol; +use log::debug; + use std::fmt::Write; use std::mem::discriminant; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { def_symbol_name, symbol_name, From a2c4a36c6132ad6e462992e1c8ab9c2c22eb5e0f Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 21:11:10 +0900 Subject: [PATCH 19/21] librustc_borrowck => 2018 --- src/librustc_borrowck/Cargo.toml | 9 +++-- src/librustc_borrowck/borrowck/check_loans.rs | 11 +++--- .../borrowck/gather_loans/gather_moves.rs | 9 ++--- .../borrowck/gather_loans/lifetime.rs | 3 +- .../borrowck/gather_loans/mod.rs | 9 ++--- .../borrowck/gather_loans/move_error.rs | 9 ++--- .../borrowck/gather_loans/restrictions.rs | 5 +-- src/librustc_borrowck/borrowck/mod.rs | 35 ++++++++++--------- src/librustc_borrowck/borrowck/move_data.rs | 15 ++++---- src/librustc_borrowck/borrowck/unused.rs | 2 +- src/librustc_borrowck/dataflow.rs | 9 ++--- src/librustc_borrowck/graphviz.rs | 13 ++++--- src/librustc_borrowck/lib.rs | 11 +----- 13 files changed, 71 insertions(+), 69 deletions(-) diff --git a/src/librustc_borrowck/Cargo.toml b/src/librustc_borrowck/Cargo.toml index 3368bbf3855a5..f293739dec727 100644 --- a/src/librustc_borrowck/Cargo.toml +++ b/src/librustc_borrowck/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_borrowck" version = "0.0.0" +edition = "2018" [lib] name = "rustc_borrowck" @@ -13,8 +14,10 @@ test = false log = "0.4" syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -graphviz = { path = "../libgraphviz" } +# for "clarity", rename the graphviz crate to dot; graphviz within `borrowck` +# refers to the borrowck-specific graphviz adapter traits. +dot = { path = "../libgraphviz", package = "graphviz" } rustc = { path = "../librustc" } rustc_mir = { path = "../librustc_mir" } -rustc_errors = { path = "../librustc_errors" } -rustc_data_structures = { path = "../librustc_data_structures" } \ No newline at end of file +errors = { path = "../librustc_errors", package = "rustc_errors" } +rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index cafb29ed99a41..f675c8d38a676 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -7,10 +7,10 @@ // 3. assignments do not affect things loaned out as immutable // 4. moves do not affect things loaned out in any way -use self::UseError::*; +use UseError::*; -use borrowck::*; -use borrowck::InteriorKind::{InteriorElement, InteriorField}; +use crate::borrowck::*; +use crate::borrowck::InteriorKind::{InteriorElement, InteriorField}; use rustc::middle::expr_use_visitor as euv; use rustc::middle::expr_use_visitor::MutateMode; use rustc::middle::mem_categorization as mc; @@ -22,6 +22,7 @@ use syntax_pos::Span; use rustc::hir; use rustc::hir::Node; use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin}; +use log::debug; use std::rc::Rc; @@ -101,7 +102,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { fn matched_pat(&mut self, _matched_pat: &hir::Pat, - _cmt: &mc::cmt_, + _cmt: &mc::cmt_<'_>, _mode: euv::MatchMode) { } fn consume_pat(&mut self, @@ -910,7 +911,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { pub fn report_illegal_mutation(&self, span: Span, loan_path: &LoanPath<'tcx>, - loan: &Loan) { + loan: &Loan<'_>) { self.bccx.cannot_assign_to_borrowed( span, loan.span, &self.bccx.loan_path_to_string(loan_path), Origin::Ast) .emit(); diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index f5e27a953c27d..6b050fd9ba230 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -1,9 +1,9 @@ //! Computes moves. -use borrowck::*; -use borrowck::gather_loans::move_error::MovePlace; -use borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector}; -use borrowck::move_data::*; +use crate::borrowck::*; +use crate::borrowck::gather_loans::move_error::MovePlace; +use crate::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector}; +use crate::borrowck::move_data::*; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; @@ -15,6 +15,7 @@ use syntax::ast; use syntax_pos::Span; use rustc::hir::*; use rustc::hir::Node; +use log::debug; struct GatherMoveInfo<'c, 'tcx: 'c> { id: hir::ItemLocalId, diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 8fc0a3d63384a..11597455bca8f 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -1,7 +1,7 @@ //! This module implements the check that the lifetime of a borrow //! does not exceed the lifetime of the value being borrowed. -use borrowck::*; +use crate::borrowck::*; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; @@ -10,6 +10,7 @@ use rustc::ty; use syntax::ast; use syntax_pos::Span; +use log::debug; type R = Result<(),()>; diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index d681c771d2fa9..c21a43bc68333 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -6,8 +6,8 @@ // their associated scopes. In phase two, checking loans, we will then make // sure that all of these loans are honored. -use borrowck::*; -use borrowck::move_data::MoveData; +use crate::borrowck::*; +use crate::borrowck::move_data::MoveData; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; @@ -17,8 +17,9 @@ use rustc::ty::{self, TyCtxt}; use syntax::ast; use syntax_pos::Span; use rustc::hir; +use log::debug; -use self::restrictions::RestrictionResult; +use restrictions::RestrictionResult; mod lifetime; mod restrictions; @@ -427,7 +428,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { // } } - pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath) { + pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath<'_>) { //! For mutable loans of content whose mutability derives //! from a local variable, mark the mutability decl as necessary. diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index 00cbc250bd686..622dd8e891ac7 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -1,4 +1,4 @@ -use borrowck::BorrowckCtxt; +use crate::borrowck::BorrowckCtxt; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::mem_categorization::NoteClosureEnv; @@ -8,7 +8,8 @@ use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin}; use syntax::ast; use syntax_pos; use errors::{DiagnosticBuilder, Applicability}; -use borrowck::gather_loans::gather_moves::PatternSource; +use crate::borrowck::gather_loans::gather_moves::PatternSource; +use log::debug; pub struct MoveErrorCollector<'tcx> { errors: Vec> @@ -167,10 +168,10 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &'a BorrowckCtxt<'a, 'tcx>, } } -fn note_move_destination(mut err: DiagnosticBuilder, +fn note_move_destination(mut err: DiagnosticBuilder<'_>, move_to_span: syntax_pos::Span, pat_name: ast::Name, - is_first_note: bool) -> DiagnosticBuilder { + is_first_note: bool) -> DiagnosticBuilder<'_> { if is_first_note { err.span_label( move_to_span, diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index a43a7f1e09ae1..9f4c05a6b255f 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -1,13 +1,14 @@ //! Computes the restrictions that result from a borrow. -use borrowck::*; +use crate::borrowck::*; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::ty; use syntax_pos::Span; +use log::debug; -use borrowck::ToInteriorKind; +use crate::borrowck::ToInteriorKind; use std::rc::Rc; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index e40c2b4508922..4ced72cd279b2 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -2,13 +2,13 @@ #![allow(non_camel_case_types)] -pub use self::LoanPathKind::*; -pub use self::LoanPathElem::*; -pub use self::bckerr_code::*; -pub use self::AliasableViolationKind::*; -pub use self::MovedValueUseKind::*; +pub use LoanPathKind::*; +pub use LoanPathElem::*; +pub use bckerr_code::*; +pub use AliasableViolationKind::*; +pub use MovedValueUseKind::*; -use self::InteriorKind::*; +use InteriorKind::*; use rustc::hir::HirId; use rustc::hir::Node; @@ -37,10 +37,11 @@ use std::hash::{Hash, Hasher}; use syntax::ast; use syntax_pos::{MultiSpan, Span}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use log::debug; use rustc::hir; -use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom}; +use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom}; pub mod check_loans; @@ -61,7 +62,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { }); } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { borrowck, ..*providers @@ -398,7 +399,7 @@ pub enum LoanPathElem<'tcx> { } fn closure_to_block(closure_id: LocalDefId, - tcx: TyCtxt) -> ast::NodeId { + tcx: TyCtxt<'_, '_, '_>) -> ast::NodeId { let closure_id = tcx.hir().local_def_id_to_node_id(closure_id); match tcx.hir().get(closure_id) { Node::Expr(expr) => match expr.node { @@ -1214,8 +1215,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } fn note_immutability_blame(&self, - db: &mut DiagnosticBuilder, - blame: Option, + db: &mut DiagnosticBuilder<'_>, + blame: Option>, error_node_id: ast::NodeId) { match blame { None => {} @@ -1271,7 +1272,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { // binding: either to make the binding mutable (if its type is // not a mutable reference) or to avoid borrowing altogether fn note_immutable_local(&self, - db: &mut DiagnosticBuilder, + db: &mut DiagnosticBuilder<'_>, borrowed_node_id: ast::NodeId, binding_node_id: ast::NodeId) { let let_span = self.tcx.hir().span(binding_node_id); @@ -1349,7 +1350,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } } - fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder, err: &BckError<'a, 'tcx>, + fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder<'_>, err: &BckError<'a, 'tcx>, error_span: &Span) { match err.cmt.note { mc::NoteClosureEnv(upvar_id) | mc::NoteUpvarRef(upvar_id) => { @@ -1487,7 +1488,7 @@ impl DataFlowOperator for LoanDataFlowOperator { } impl<'tcx> fmt::Debug for InteriorKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { InteriorField(mc::FieldIndex(_, info)) => write!(f, "{}", info), InteriorElement => write!(f, "[]"), @@ -1496,7 +1497,7 @@ impl<'tcx> fmt::Debug for InteriorKind { } impl<'tcx> fmt::Debug for Loan<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Loan_{}({:?}, {:?}, {:?}-{:?}, {:?})", self.index, self.loan_path, @@ -1508,7 +1509,7 @@ impl<'tcx> fmt::Debug for Loan<'tcx> { } impl<'tcx> fmt::Debug for LoanPath<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.kind { LpVar(id) => { write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id))) @@ -1543,7 +1544,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> { } impl<'tcx> fmt::Display for LoanPath<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.kind { LpVar(id) => { write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id))) diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 56c9f928eb03a..a206c37e97b09 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -1,11 +1,11 @@ //! Data structures used for tracking moves. Please see the extensive //! comments in the section "Moves and initialization" in `README.md`. -pub use self::MoveKind::*; +pub use MoveKind::*; -use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom}; +use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom}; -use borrowck::*; +use crate::borrowck::*; use rustc::cfg; use rustc::ty::{self, TyCtxt}; use rustc::util::nodemap::FxHashMap; @@ -15,6 +15,7 @@ use std::rc::Rc; use std::usize; use syntax_pos::Span; use rustc::hir; +use log::debug; #[derive(Default)] pub struct MoveData<'tcx> { @@ -145,7 +146,7 @@ pub struct AssignDataFlowOperator; pub type AssignDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, AssignDataFlowOperator>; -fn loan_path_is_precise(loan_path: &LoanPath) -> bool { +fn loan_path_is_precise(loan_path: &LoanPath<'_>) -> bool { match loan_path.kind { LpVar(_) | LpUpvar(_) => { true @@ -428,8 +429,8 @@ impl<'a, 'tcx> MoveData<'tcx> { /// killed by scoping. See `README.md` for more details. fn add_gen_kills(&self, bccx: &BorrowckCtxt<'a, 'tcx>, - dfcx_moves: &mut MoveDataFlow, - dfcx_assign: &mut AssignDataFlow) { + dfcx_moves: &mut MoveDataFlow<'_, '_>, + dfcx_assign: &mut AssignDataFlow<'_, '_>) { for (i, the_move) in self.moves.borrow().iter().enumerate() { dfcx_moves.add_gen(the_move.id, i); } @@ -537,7 +538,7 @@ impl<'a, 'tcx> MoveData<'tcx> { path: MovePathIndex, kill_id: hir::ItemLocalId, kill_kind: KillFrom, - dfcx_moves: &mut MoveDataFlow) { + dfcx_moves: &mut MoveDataFlow<'_, '_>) { // We can only perform kills for paths that refer to a unique location, // since otherwise we may kill a move from one location with an // assignment referring to another location. diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 5db98f0e223e4..60a9c18e95ee9 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -7,7 +7,7 @@ use errors::Applicability; use std::slice; use syntax::ptr::P; -use borrowck::BorrowckCtxt; +use crate::borrowck::BorrowckCtxt; pub fn check<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &'tcx hir::Body) { let mut used_mut = bccx.used_mut_nodes.borrow().clone(); diff --git a/src/librustc_borrowck/dataflow.rs b/src/librustc_borrowck/dataflow.rs index 8cf620567405c..90f33ede62c21 100644 --- a/src/librustc_borrowck/dataflow.rs +++ b/src/librustc_borrowck/dataflow.rs @@ -10,6 +10,7 @@ use std::io; use std::mem; use std::usize; use syntax::print::pprust::PrintState; +use log::debug; use rustc_data_structures::graph::implementation::OUTGOING; @@ -80,7 +81,7 @@ pub trait DataFlowOperator : BitwiseOperator { fn initial_value(&self) -> bool; } -struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O: 'a> { +struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O> { dfcx: &'a mut DataFlowContext<'b, 'tcx, O>, changed: bool } @@ -99,12 +100,12 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { } impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> { - fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> { + fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> { pprust::PpAnn::nested(self.tcx.hir(), state, nested) } fn pre(&self, - ps: &mut pprust::State, - node: pprust::AnnNode) -> io::Result<()> { + ps: &mut pprust::State<'_>, + node: pprust::AnnNode<'_>) -> io::Result<()> { let id = match node { pprust::AnnNode::Name(_) => return Ok(()), pprust::AnnNode::Expr(expr) => expr.hir_id.local_id, diff --git a/src/librustc_borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs index adad8c55f2159..77056d4d3eb15 100644 --- a/src/librustc_borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -2,16 +2,15 @@ //! libgraphviz traits, specialized to attaching borrowck analysis //! data to rendered labels. -pub use self::Variant::*; +pub use Variant::*; pub use rustc::cfg::graphviz::{Node, Edge}; use rustc::cfg::graphviz as cfg_dot; -use borrowck; -use borrowck::{BorrowckCtxt, LoanPath}; -use dot; +use crate::borrowck::{self, BorrowckCtxt, LoanPath}; +use crate::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; +use log::debug; use rustc::cfg::CFGIndex; -use dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; use std::rc::Rc; #[derive(Debug, Copy, Clone)] @@ -53,7 +52,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> { sets } - fn dataflow_for_variant(&self, e: EntryOrExit, n: &Node, v: Variant) -> String { + fn dataflow_for_variant(&self, e: EntryOrExit, n: &Node<'_>, v: Variant) -> String { let cfgidx = n.0; match v { Loans => self.dataflow_loans_for(e, cfgidx), @@ -89,7 +88,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> { let dfcx = &self.analysis_data.loans; let loan_index_to_path = |loan_index| { let all_loans = &self.analysis_data.all_loans; - let l: &borrowck::Loan = &all_loans[loan_index]; + let l: &borrowck::Loan<'_> = &all_loans[loan_index]; l.loan_path() }; self.build_set(e, cfgidx, dfcx, loan_index_to_path) diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 8bdc4e1d5c1ea..75ac38209371a 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -3,23 +3,14 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![allow(non_camel_case_types)] +#![deny(rust_2018_idioms)] #![feature(nll)] #![recursion_limit="256"] -#[macro_use] extern crate log; -extern crate syntax; -extern crate syntax_pos; -extern crate rustc_errors as errors; -extern crate rustc_data_structures; - -// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck` -// refers to the borrowck-specific graphviz adapter traits. -extern crate graphviz as dot; #[macro_use] extern crate rustc; -extern crate rustc_mir; pub use borrowck::check_crate; pub use borrowck::build_borrowck_dataflow_data_for_fn; From 4f2e97e0ed4a988a037a132f1efdd9456f1c1315 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 21:16:35 +0900 Subject: [PATCH 20/21] librustc_incremental => 2018 --- src/librustc_incremental/Cargo.toml | 1 + src/librustc_incremental/assert_dep_graph.rs | 12 ++++----- src/librustc_incremental/lib.rs | 11 +++----- .../persist/dirty_clean.rs | 4 +-- src/librustc_incremental/persist/load.rs | 1 - src/librustc_incremental/persist/mod.rs | 26 +++++++++---------- src/librustc_incremental/persist/save.rs | 4 +-- .../persist/work_product.rs | 2 +- 8 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index b8519ee1ab1a5..10b448b7fec3f 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_incremental" version = "0.0.0" +edition = "2018" [lib] name = "rustc_incremental" diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 57ab48493fa93..b715a32cb0573 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -217,7 +217,7 @@ fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } -fn dump_graph(tcx: TyCtxt) { +fn dump_graph(tcx: TyCtxt<'_, '_, '_>) { let path: String = env::var("RUST_DEP_GRAPH").unwrap_or_else(|_| "dep_graph".to_string()); let query = tcx.dep_graph.query(); @@ -261,11 +261,11 @@ pub struct GraphvizDepGraph<'q>(FxHashSet<&'q DepNode>, impl<'a, 'tcx, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> { type Node = &'q DepNode; type Edge = (&'q DepNode, &'q DepNode); - fn nodes(&self) -> dot::Nodes<&'q DepNode> { + fn nodes(&self) -> dot::Nodes<'_, &'q DepNode> { let nodes: Vec<_> = self.0.iter().cloned().collect(); nodes.into() } - fn edges(&self) -> dot::Edges<(&'q DepNode, &'q DepNode)> { + fn edges(&self) -> dot::Edges<'_, (&'q DepNode, &'q DepNode)> { self.1[..].into() } fn source(&self, edge: &(&'q DepNode, &'q DepNode)) -> &'q DepNode { @@ -279,10 +279,10 @@ impl<'a, 'tcx, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> { impl<'a, 'tcx, 'q> dot::Labeller<'a> for GraphvizDepGraph<'q> { type Node = &'q DepNode; type Edge = (&'q DepNode, &'q DepNode); - fn graph_id(&self) -> dot::Id { + fn graph_id(&self) -> dot::Id<'_> { dot::Id::new("DependencyGraph").unwrap() } - fn node_id(&self, n: &&'q DepNode) -> dot::Id { + fn node_id(&self, n: &&'q DepNode) -> dot::Id<'_> { let s: String = format!("{:?}", n).chars() .map(|c| if c == '_' || c.is_alphanumeric() { c } else { '_' }) @@ -290,7 +290,7 @@ impl<'a, 'tcx, 'q> dot::Labeller<'a> for GraphvizDepGraph<'q> { debug!("n={:?} s={:?}", n, s); dot::Id::new(s).unwrap() } - fn node_label(&self, n: &&'q DepNode) -> dot::LabelText { + fn node_label(&self, n: &&'q DepNode) -> dot::LabelText<'_> { dot::LabelText::label(format!("{:?}", n)) } } diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index ae2e6e0b94cfc..1fc51c2731140 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -9,16 +9,13 @@ #![recursion_limit="256"] -extern crate graphviz; +#![deny(rust_2018_idioms)] + #[macro_use] extern crate rustc; -extern crate rustc_data_structures; -extern crate serialize as rustc_serialize; -extern crate rand; -extern crate rustc_fs_util; +#[allow(unused_extern_crates)] +extern crate serialize as rustc_serialize; // used by deriving #[macro_use] extern crate log; -extern crate syntax; -extern crate syntax_pos; mod assert_dep_graph; pub mod assert_module_sources; diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 3ff4d2ec38dff..9b52199465b5c 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -538,7 +538,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'a, 'tcx> { /// /// Also make sure that the `label` and `except` fields do not /// both exist. -fn check_config(tcx: TyCtxt, attr: &Attribute) -> bool { +fn check_config(tcx: TyCtxt<'_, '_, '_>, attr: &Attribute) -> bool { debug!("check_config(attr={:?})", attr); let config = &tcx.sess.parse_sess.config; debug!("check_config: config={:?}", config); @@ -573,7 +573,7 @@ fn check_config(tcx: TyCtxt, attr: &Attribute) -> bool { } } -fn expect_associated_value(tcx: TyCtxt, item: &NestedMetaItem) -> ast::Name { +fn expect_associated_value(tcx: TyCtxt<'_, '_, '_>, item: &NestedMetaItem) -> ast::Name { if let Some(value) = item.value_str() { value } else { diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index f330de7191865..ecf8bc4a88084 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -9,7 +9,6 @@ use rustc::util::common::time_ext; use rustc_serialize::Decodable as RustcDecodable; use rustc_serialize::opaque::Decoder; use std::path::Path; -use std; use super::data::*; use super::fs::*; diff --git a/src/librustc_incremental/persist/mod.rs b/src/librustc_incremental/persist/mod.rs index bd59f24d04e79..3aad4f5abb884 100644 --- a/src/librustc_incremental/persist/mod.rs +++ b/src/librustc_incremental/persist/mod.rs @@ -10,16 +10,16 @@ mod save; mod work_product; mod file_format; -pub use self::fs::finalize_session_directory; -pub use self::fs::garbage_collect_session_directories; -pub use self::fs::in_incr_comp_dir; -pub use self::fs::in_incr_comp_dir_sess; -pub use self::fs::prepare_session_directory; -pub use self::load::dep_graph_tcx_init; -pub use self::load::load_dep_graph; -pub use self::load::load_query_result_cache; -pub use self::load::LoadResult; -pub use self::save::save_dep_graph; -pub use self::save::save_work_product_index; -pub use self::work_product::copy_cgu_workproducts_to_incr_comp_cache_dir; -pub use self::work_product::delete_workproduct_files; +pub use fs::finalize_session_directory; +pub use fs::garbage_collect_session_directories; +pub use fs::in_incr_comp_dir; +pub use fs::in_incr_comp_dir_sess; +pub use fs::prepare_session_directory; +pub use load::dep_graph_tcx_init; +pub use load::load_dep_graph; +pub use load::load_query_result_cache; +pub use load::LoadResult; +pub use save::save_dep_graph; +pub use save::save_work_product_index; +pub use work_product::copy_cgu_workproducts_to_incr_comp_cache_dir; +pub use work_product::delete_workproduct_files; diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 6a7553b388297..34fe2f1c25d04 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -129,7 +129,7 @@ fn save_in(sess: &Session, path_buf: PathBuf, encode: F) } } -fn encode_dep_graph(tcx: TyCtxt, +fn encode_dep_graph(tcx: TyCtxt<'_, '_, '_>, encoder: &mut Encoder) { // First encode the commandline arguments hash tcx.sess.opts.dep_tracking_hash().encode(encoder).unwrap(); @@ -234,7 +234,7 @@ fn encode_work_product_index(work_products: &FxHashMap, encoder: &mut Encoder) { time(tcx.sess, "serialize query result cache", || { tcx.serialize_query_result_cache(encoder).unwrap(); diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs index 535f6930aa39a..3495b27c5ebca 100644 --- a/src/librustc_incremental/persist/work_product.rs +++ b/src/librustc_incremental/persist/work_product.rs @@ -1,6 +1,6 @@ //! This module contains files for saving intermediate work-products. -use persist::fs::*; +use crate::persist::fs::*; use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind}; use rustc::session::Session; use rustc_fs_util::link_or_copy; From 3e2b5a4b08d9647f7438f4e945d4c8b37c36a58c Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 9 Feb 2019 01:36:22 +0900 Subject: [PATCH 21/21] librustc_data_structures => 2018 --- src/librustc_data_structures/Cargo.toml | 5 +-- src/librustc_data_structures/bit_set.rs | 8 ++--- src/librustc_data_structures/fingerprint.rs | 4 +-- src/librustc_data_structures/flock.rs | 13 ------- .../graph/dominators/mod.rs | 8 ++--- .../graph/implementation/mod.rs | 26 ++++++-------- .../graph/implementation/tests.rs | 2 +- src/librustc_data_structures/graph/scc/mod.rs | 8 ++--- .../graph/scc/test.rs | 2 +- src/librustc_data_structures/graph/test.rs | 2 +- src/librustc_data_structures/indexed_vec.rs | 8 ++--- src/librustc_data_structures/lib.rs | 13 ++----- .../obligation_forest/graphviz.rs | 14 ++++---- .../obligation_forest/mod.rs | 4 +-- .../owning_ref/mod.rs | 6 ++-- src/librustc_data_structures/ptr_key.rs | 2 +- .../snapshot_map/mod.rs | 2 +- src/librustc_data_structures/sorted_map.rs | 2 +- src/librustc_data_structures/stable_hasher.rs | 10 +++--- src/librustc_data_structures/svh.rs | 4 +-- src/librustc_data_structures/sync.rs | 34 +++++++++---------- src/librustc_data_structures/tiny_list.rs | 2 +- .../transitive_relation.rs | 8 ++--- .../vec_linked_list.rs | 2 +- src/librustc_data_structures/work_queue.rs | 4 +-- 25 files changed, 86 insertions(+), 107 deletions(-) diff --git a/src/librustc_data_structures/Cargo.toml b/src/librustc_data_structures/Cargo.toml index 1754376a5d7f9..f781952d4172c 100644 --- a/src/librustc_data_structures/Cargo.toml +++ b/src/librustc_data_structures/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_data_structures" version = "0.0.0" +edition = "2018" [lib] name = "rustc_data_structures" @@ -16,8 +17,8 @@ serialize = { path = "../libserialize" } graphviz = { path = "../libgraphviz" } cfg-if = "0.1.2" stable_deref_trait = "1.0.0" -rustc-rayon = "0.1.1" -rustc-rayon-core = "0.1.1" +rayon = { version = "0.1.1", package = "rustc-rayon" } +rayon-core = { version = "0.1.1", package = "rustc-rayon-core" } rustc-hash = "1.0.1" smallvec = { version = "0.6.7", features = ["union", "may_dangle"] } diff --git a/src/librustc_data_structures/bit_set.rs b/src/librustc_data_structures/bit_set.rs index 8adfe3749af8e..05d2185ae69b4 100644 --- a/src/librustc_data_structures/bit_set.rs +++ b/src/librustc_data_structures/bit_set.rs @@ -1,4 +1,4 @@ -use indexed_vec::{Idx, IndexVec}; +use crate::indexed_vec::{Idx, IndexVec}; use smallvec::SmallVec; use std::fmt; use std::iter; @@ -208,7 +208,7 @@ impl SubtractFromBitSet for BitSet { } impl fmt::Debug for BitSet { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { w.debug_list() .entries(self.iter()) .finish() @@ -366,7 +366,7 @@ impl SparseBitSet { dense } - fn iter(&self) -> slice::Iter { + fn iter(&self) -> slice::Iter<'_, T> { self.elems.iter() } } @@ -536,7 +536,7 @@ impl HybridBitSet { } } - pub fn iter(&self) -> HybridIter { + pub fn iter(&self) -> HybridIter<'_, T> { match self { HybridBitSet::Sparse(sparse) => HybridIter::Sparse(sparse.iter()), HybridBitSet::Dense(dense) => HybridIter::Dense(dense.iter()), diff --git a/src/librustc_data_structures/fingerprint.rs b/src/librustc_data_structures/fingerprint.rs index 2e596ca3e44f1..c4c0db5801209 100644 --- a/src/librustc_data_structures/fingerprint.rs +++ b/src/librustc_data_structures/fingerprint.rs @@ -1,5 +1,5 @@ +use crate::stable_hasher; use std::mem; -use stable_hasher; use serialize; use serialize::opaque::{EncodeResult, Encoder, Decoder}; @@ -70,7 +70,7 @@ impl Fingerprint { } impl ::std::fmt::Display for Fingerprint { - fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, formatter: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(formatter, "{:x}-{:x}", self.0, self.1) } } diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs index 2dea249f1c07c..255c5fd7fe7ec 100644 --- a/src/librustc_data_structures/flock.rs +++ b/src/librustc_data_structures/flock.rs @@ -14,12 +14,9 @@ cfg_if! { if #[cfg(unix)] { use std::ffi::{CString, OsStr}; use std::os::unix::prelude::*; - use libc; #[cfg(any(target_os = "linux", target_os = "android"))] mod os { - use libc; - #[repr(C)] pub struct flock { pub l_type: libc::c_short, @@ -35,8 +32,6 @@ cfg_if! { #[cfg(target_os = "freebsd")] mod os { - use libc; - #[repr(C)] pub struct flock { pub l_start: libc::off_t, @@ -53,8 +48,6 @@ cfg_if! { target_os = "netbsd", target_os = "openbsd"))] mod os { - use libc; - #[repr(C)] pub struct flock { pub l_start: libc::off_t, @@ -70,8 +63,6 @@ cfg_if! { #[cfg(target_os = "haiku")] mod os { - use libc; - #[repr(C)] pub struct flock { pub l_type: libc::c_short, @@ -87,8 +78,6 @@ cfg_if! { #[cfg(any(target_os = "macos", target_os = "ios"))] mod os { - use libc; - #[repr(C)] pub struct flock { pub l_start: libc::off_t, @@ -104,8 +93,6 @@ cfg_if! { #[cfg(target_os = "solaris")] mod os { - use libc; - #[repr(C)] pub struct flock { pub l_type: libc::c_short, diff --git a/src/librustc_data_structures/graph/dominators/mod.rs b/src/librustc_data_structures/graph/dominators/mod.rs index 536efffbb22f4..aaed41d9fa362 100644 --- a/src/librustc_data_structures/graph/dominators/mod.rs +++ b/src/librustc_data_structures/graph/dominators/mod.rs @@ -117,7 +117,7 @@ impl Dominators { self.immediate_dominators[node].unwrap() } - pub fn dominators(&self, node: Node) -> Iter { + pub fn dominators(&self, node: Node) -> Iter<'_, Node> { assert!(self.is_reachable(node), "node {:?} is not reachable", node); Iter { dominators: self, @@ -136,7 +136,7 @@ impl Dominators { } } -pub struct Iter<'dom, Node: Idx + 'dom> { +pub struct Iter<'dom, Node: Idx> { dominators: &'dom Dominators, node: Option, } @@ -171,7 +171,7 @@ impl DominatorTree { } impl fmt::Debug for DominatorTree { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt( &DominatorTreeNode { tree: self, @@ -188,7 +188,7 @@ struct DominatorTreeNode<'tree, Node: Idx> { } impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let subtrees: Vec<_> = self.tree .children(self.node) .iter() diff --git a/src/librustc_data_structures/graph/implementation/mod.rs b/src/librustc_data_structures/graph/implementation/mod.rs index 0768873f83626..a8b734094064a 100644 --- a/src/librustc_data_structures/graph/implementation/mod.rs +++ b/src/librustc_data_structures/graph/implementation/mod.rs @@ -20,10 +20,10 @@ //! the field `next_edge`). Each of those fields is an array that should //! be indexed by the direction (see the type `Direction`). -use bit_set::BitSet; +use crate::bit_set::BitSet; +use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate}; use std::fmt::Debug; use std::usize; -use snapshot_vec::{SnapshotVec, SnapshotVecDelegate}; #[cfg(test)] mod tests; @@ -212,15 +212,19 @@ impl Graph { .all(|(edge_idx, edge)| f(edge_idx, edge)) } - pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges { + pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> { self.adjacent_edges(source, OUTGOING) } - pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges { + pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> { self.adjacent_edges(source, INCOMING) } - pub fn adjacent_edges(&self, source: NodeIndex, direction: Direction) -> AdjacentEdges { + pub fn adjacent_edges( + &self, + source: NodeIndex, + direction: Direction + ) -> AdjacentEdges<'_, N, E> { let first_edge = self.node(source).first_edge[direction.repr]; AdjacentEdges { graph: self, @@ -291,11 +295,7 @@ impl Graph { // # Iterators -pub struct AdjacentEdges<'g, N, E> -where - N: 'g, - E: 'g, -{ +pub struct AdjacentEdges<'g, N, E> { graph: &'g Graph, direction: Direction, next: EdgeIndex, @@ -331,11 +331,7 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> { } } -pub struct DepthFirstTraversal<'g, N, E> -where - N: 'g, - E: 'g, -{ +pub struct DepthFirstTraversal<'g, N, E> { graph: &'g Graph, stack: Vec, visited: BitSet, diff --git a/src/librustc_data_structures/graph/implementation/tests.rs b/src/librustc_data_structures/graph/implementation/tests.rs index a7a2504239610..82c6da3f42711 100644 --- a/src/librustc_data_structures/graph/implementation/tests.rs +++ b/src/librustc_data_structures/graph/implementation/tests.rs @@ -1,4 +1,4 @@ -use graph::implementation::*; +use crate::graph::implementation::*; use std::fmt::Debug; type TestGraph = Graph<&'static str, &'static str>; diff --git a/src/librustc_data_structures/graph/scc/mod.rs b/src/librustc_data_structures/graph/scc/mod.rs index baab377ef1276..e3264fda2629c 100644 --- a/src/librustc_data_structures/graph/scc/mod.rs +++ b/src/librustc_data_structures/graph/scc/mod.rs @@ -3,9 +3,9 @@ //! node in the graph. This uses Tarjan's algorithm that completes in //! O(n) time. -use fx::FxHashSet; -use graph::{DirectedGraph, WithNumNodes, WithSuccessors}; -use indexed_vec::{Idx, IndexVec}; +use crate::fx::FxHashSet; +use crate::graph::{DirectedGraph, WithNumNodes, WithSuccessors}; +use crate::indexed_vec::{Idx, IndexVec}; use std::ops::Range; mod test; @@ -93,7 +93,7 @@ impl SccData { } } -struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors + 'c, S: Idx> { +struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors, S: Idx> { graph: &'c G, /// The state of each node; used during walk to record the stack diff --git a/src/librustc_data_structures/graph/scc/test.rs b/src/librustc_data_structures/graph/scc/test.rs index e23cb1348b015..da3a1ceefe94b 100644 --- a/src/librustc_data_structures/graph/scc/test.rs +++ b/src/librustc_data_structures/graph/scc/test.rs @@ -1,6 +1,6 @@ #![cfg(test)] -use graph::test::TestGraph; +use crate::graph::test::TestGraph; use super::*; #[test] diff --git a/src/librustc_data_structures/graph/test.rs b/src/librustc_data_structures/graph/test.rs index 3d482e448bdb7..b390c41957294 100644 --- a/src/librustc_data_structures/graph/test.rs +++ b/src/librustc_data_structures/graph/test.rs @@ -1,4 +1,4 @@ -use fx::FxHashMap; +use crate::fx::FxHashMap; use std::cmp::max; use std::slice; use std::iter; diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 8d8fbe588a021..516ea7fb7d946 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -257,7 +257,7 @@ macro_rules! newtype_index { @type [$type:ident] @debug_format [$debug_format:tt]) => ( impl ::std::fmt::Debug for $type { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(fmt, $debug_format, self.as_u32()) } } @@ -495,7 +495,7 @@ impl serialize::Decodable for IndexVec { } impl fmt::Debug for IndexVec { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.raw, fmt) } } @@ -573,7 +573,7 @@ impl IndexVec { } #[inline] - pub fn iter(&self) -> slice::Iter { + pub fn iter(&self) -> slice::Iter<'_, T> { self.raw.iter() } @@ -589,7 +589,7 @@ impl IndexVec { } #[inline] - pub fn iter_mut(&mut self) -> slice::IterMut { + pub fn iter_mut(&mut self) -> slice::IterMut<'_, T> { self.raw.iter_mut() } diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index a46f8aed32499..08b453cf493f8 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -24,23 +24,16 @@ #![cfg_attr(unix, feature(libc))] #![cfg_attr(test, feature(test))] -extern crate core; -extern crate ena; +#![deny(rust_2018_idioms)] + #[macro_use] extern crate log; +#[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving #[cfg(unix)] extern crate libc; -extern crate parking_lot; #[macro_use] extern crate cfg_if; -extern crate stable_deref_trait; -extern crate rustc_rayon as rayon; -extern crate rustc_rayon_core as rayon_core; -extern crate rustc_hash; -extern crate serialize; -extern crate graphviz; -extern crate smallvec; // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/librustc_data_structures/obligation_forest/graphviz.rs b/src/librustc_data_structures/obligation_forest/graphviz.rs index c2e3938b305d2..72551b42324d0 100644 --- a/src/librustc_data_structures/obligation_forest/graphviz.rs +++ b/src/librustc_data_structures/obligation_forest/graphviz.rs @@ -1,5 +1,5 @@ +use crate::obligation_forest::{ForestObligation, ObligationForest}; use graphviz as dot; -use obligation_forest::{ForestObligation, ObligationForest}; use std::env::var_os; use std::fs::File; use std::path::Path; @@ -41,22 +41,22 @@ impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest type Node = usize; type Edge = (usize, usize); - fn graph_id(&self) -> dot::Id { + fn graph_id(&self) -> dot::Id<'_> { dot::Id::new("trait_obligation_forest").unwrap() } - fn node_id(&self, index: &Self::Node) -> dot::Id { + fn node_id(&self, index: &Self::Node) -> dot::Id<'_> { dot::Id::new(format!("obligation_{}", index)).unwrap() } - fn node_label(&self, index: &Self::Node) -> dot::LabelText { + fn node_label(&self, index: &Self::Node) -> dot::LabelText<'_> { let node = &self.nodes[*index]; let label = format!("{:?} ({:?})", node.obligation.as_predicate(), node.state.get()); dot::LabelText::LabelStr(label.into()) } - fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText { + fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText<'_> { dot::LabelText::LabelStr("".into()) } } @@ -65,11 +65,11 @@ impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest dot::Nodes { + fn nodes(&self) -> dot::Nodes<'_, Self::Node> { (0..self.nodes.len()).collect() } - fn edges(&self) -> dot::Edges { + fn edges(&self) -> dot::Edges<'_, Self::Edge> { (0..self.nodes.len()) .flat_map(|i| { let node = &self.nodes[i]; diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 9dd7d204f0373..546bb64168e14 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -80,7 +80,7 @@ //! processing step, we compress the vector to remove completed and error //! nodes, which aren't needed anymore. -use fx::{FxHashMap, FxHashSet}; +use crate::fx::{FxHashMap, FxHashSet}; use std::cell::Cell; use std::collections::hash_map::Entry; @@ -733,7 +733,7 @@ impl Node { // I need a Clone closure #[derive(Clone)] -struct GetObligation<'a, O: 'a>(&'a [Node]); +struct GetObligation<'a, O>(&'a [Node]); impl<'a, 'b, O> FnOnce<(&'b usize,)> for GetObligation<'a, O> { type Output = &'a O; diff --git a/src/librustc_data_structures/owning_ref/mod.rs b/src/librustc_data_structures/owning_ref/mod.rs index 0b126e5c572ed..30e510cc5b055 100644 --- a/src/librustc_data_structures/owning_ref/mod.rs +++ b/src/librustc_data_structures/owning_ref/mod.rs @@ -1002,7 +1002,7 @@ impl Debug for OwningRef where O: Debug, T: Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "OwningRef {{ owner: {:?}, reference: {:?} }}", self.owner(), @@ -1014,7 +1014,7 @@ impl Debug for OwningRefMut where O: Debug, T: Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "OwningRefMut {{ owner: {:?}, reference: {:?} }}", self.owner(), @@ -1047,7 +1047,7 @@ unsafe impl Sync for OwningRefMut where O: Sync, for<'a> (&'a mut T): Sync {} impl Debug for dyn Erased { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "",) } } diff --git a/src/librustc_data_structures/ptr_key.rs b/src/librustc_data_structures/ptr_key.rs index 322dcbe8f08fb..bf3ae2d7af58f 100644 --- a/src/librustc_data_structures/ptr_key.rs +++ b/src/librustc_data_structures/ptr_key.rs @@ -4,7 +4,7 @@ use std::ops::Deref; /// A wrapper around reference that compares and hashes like a pointer. /// Can be used as a key in sets/maps indexed by pointers to avoid `unsafe`. #[derive(Debug)] -pub struct PtrKey<'a, T: 'a>(pub &'a T); +pub struct PtrKey<'a, T>(pub &'a T); impl<'a, T> Clone for PtrKey<'a, T> { fn clone(&self) -> Self { *self } diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs index d408727aea504..91d6e29237002 100644 --- a/src/librustc_data_structures/snapshot_map/mod.rs +++ b/src/librustc_data_structures/snapshot_map/mod.rs @@ -1,4 +1,4 @@ -use fx::FxHashMap; +use crate::fx::FxHashMap; use std::hash::Hash; use std::ops; use std::mem; diff --git a/src/librustc_data_structures/sorted_map.rs b/src/librustc_data_structures/sorted_map.rs index 64bbb8d7c08d1..1f674c1c664e4 100644 --- a/src/librustc_data_structures/sorted_map.rs +++ b/src/librustc_data_structures/sorted_map.rs @@ -111,7 +111,7 @@ impl SortedMap { /// Iterate over elements, sorted by key #[inline] - pub fn iter(&self) -> ::std::slice::Iter<(K, V)> { + pub fn iter(&self) -> ::std::slice::Iter<'_, (K, V)> { self.data.iter() } diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 4583f12ec8cbc..19343a9250df3 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -1,7 +1,9 @@ use std::hash::{Hash, Hasher, BuildHasher}; use std::marker::PhantomData; use std::mem; -use sip128::SipHasher128; +use crate::sip128::SipHasher128; +use crate::indexed_vec; +use crate::bit_set; /// When hashing something that ends up affecting properties like symbol names, /// we want these symbol names to be calculated independently of other factors @@ -17,7 +19,7 @@ pub struct StableHasher { } impl ::std::fmt::Debug for StableHasher { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "{:?}", self.state) } } @@ -433,7 +435,7 @@ impl HashStable for ::std::mem::Discriminant { } } -impl HashStable for ::indexed_vec::IndexVec +impl HashStable for indexed_vec::IndexVec where T: HashStable, { fn hash_stable(&self, @@ -447,7 +449,7 @@ impl HashStable for ::indexed_vec::IndexVec< } -impl HashStable for ::bit_set::BitSet +impl HashStable for bit_set::BitSet { fn hash_stable(&self, ctx: &mut CTX, diff --git a/src/librustc_data_structures/svh.rs b/src/librustc_data_structures/svh.rs index 749479534979c..3757f921098f2 100644 --- a/src/librustc_data_structures/svh.rs +++ b/src/librustc_data_structures/svh.rs @@ -9,7 +9,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; use serialize::{Encodable, Decodable, Encoder, Decoder}; -use stable_hasher; +use crate::stable_hasher; #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Svh { @@ -40,7 +40,7 @@ impl Hash for Svh { } impl fmt::Display for Svh { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad(&self.to_string()) } } diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index 7fef1f374d6fd..ba1f6eb56fe88 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -21,7 +21,7 @@ use std::collections::HashMap; use std::hash::{Hash, BuildHasher}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -use owning_ref::{Erased, OwningRef}; +use crate::owning_ref::{Erased, OwningRef}; pub fn serial_join(oper_a: A, oper_b: B) -> (RA, RB) where A: FnOnce() -> RA, @@ -261,12 +261,12 @@ cfg_if! { } #[inline(always)] - pub fn lock(&self) -> LockGuard { + pub fn lock(&self) -> LockGuard<'_, T> { self.0.lock() } #[inline(always)] - pub fn lock_mut(&self) -> LockGuard { + pub fn lock_mut(&self) -> LockGuard<'_, T> { self.lock() } } @@ -490,19 +490,19 @@ impl Lock { #[cfg(parallel_compiler)] #[inline(always)] - pub fn try_lock(&self) -> Option> { + pub fn try_lock(&self) -> Option> { self.0.try_lock() } #[cfg(not(parallel_compiler))] #[inline(always)] - pub fn try_lock(&self) -> Option> { + pub fn try_lock(&self) -> Option> { self.0.try_borrow_mut().ok() } #[cfg(parallel_compiler)] #[inline(always)] - pub fn lock(&self) -> LockGuard { + pub fn lock(&self) -> LockGuard<'_, T> { if ERROR_CHECKING { self.0.try_lock().expect("lock was already held") } else { @@ -512,7 +512,7 @@ impl Lock { #[cfg(not(parallel_compiler))] #[inline(always)] - pub fn lock(&self) -> LockGuard { + pub fn lock(&self) -> LockGuard<'_, T> { self.0.borrow_mut() } @@ -522,12 +522,12 @@ impl Lock { } #[inline(always)] - pub fn borrow(&self) -> LockGuard { + pub fn borrow(&self) -> LockGuard<'_, T> { self.lock() } #[inline(always)] - pub fn borrow_mut(&self) -> LockGuard { + pub fn borrow_mut(&self) -> LockGuard<'_, T> { self.lock() } } @@ -568,13 +568,13 @@ impl RwLock { #[cfg(not(parallel_compiler))] #[inline(always)] - pub fn read(&self) -> ReadGuard { + pub fn read(&self) -> ReadGuard<'_, T> { self.0.borrow() } #[cfg(parallel_compiler)] #[inline(always)] - pub fn read(&self) -> ReadGuard { + pub fn read(&self) -> ReadGuard<'_, T> { if ERROR_CHECKING { self.0.try_read().expect("lock was already held") } else { @@ -589,25 +589,25 @@ impl RwLock { #[cfg(not(parallel_compiler))] #[inline(always)] - pub fn try_write(&self) -> Result, ()> { + pub fn try_write(&self) -> Result, ()> { self.0.try_borrow_mut().map_err(|_| ()) } #[cfg(parallel_compiler)] #[inline(always)] - pub fn try_write(&self) -> Result, ()> { + pub fn try_write(&self) -> Result, ()> { self.0.try_write().ok_or(()) } #[cfg(not(parallel_compiler))] #[inline(always)] - pub fn write(&self) -> WriteGuard { + pub fn write(&self) -> WriteGuard<'_, T> { self.0.borrow_mut() } #[cfg(parallel_compiler)] #[inline(always)] - pub fn write(&self) -> WriteGuard { + pub fn write(&self) -> WriteGuard<'_, T> { if ERROR_CHECKING { self.0.try_write().expect("lock was already held") } else { @@ -621,12 +621,12 @@ impl RwLock { } #[inline(always)] - pub fn borrow(&self) -> ReadGuard { + pub fn borrow(&self) -> ReadGuard<'_, T> { self.read() } #[inline(always)] - pub fn borrow_mut(&self) -> WriteGuard { + pub fn borrow_mut(&self) -> WriteGuard<'_, T> { self.write() } } diff --git a/src/librustc_data_structures/tiny_list.rs b/src/librustc_data_structures/tiny_list.rs index d660486d58446..3d74516d9c326 100644 --- a/src/librustc_data_structures/tiny_list.rs +++ b/src/librustc_data_structures/tiny_list.rs @@ -123,7 +123,7 @@ impl Element { mod test { use super::*; extern crate test; - use self::test::Bencher; + use test::Bencher; #[test] fn test_contains_and_insert() { diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index 9d675ed3096e0..39aed9833607f 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -1,8 +1,8 @@ -use bit_set::BitMatrix; -use fx::FxHashMap; -use sync::Lock; +use crate::bit_set::BitMatrix; +use crate::fx::FxHashMap; +use crate::stable_hasher::{HashStable, StableHasher, StableHasherResult}; +use crate::sync::Lock; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; -use stable_hasher::{HashStable, StableHasher, StableHasherResult}; use std::fmt::Debug; use std::hash::Hash; use std::mem; diff --git a/src/librustc_data_structures/vec_linked_list.rs b/src/librustc_data_structures/vec_linked_list.rs index 3b6984dd07599..c00c707a43542 100644 --- a/src/librustc_data_structures/vec_linked_list.rs +++ b/src/librustc_data_structures/vec_linked_list.rs @@ -1,4 +1,4 @@ -use indexed_vec::{Idx, IndexVec}; +use crate::indexed_vec::{Idx, IndexVec}; pub fn iter( first: Option, diff --git a/src/librustc_data_structures/work_queue.rs b/src/librustc_data_structures/work_queue.rs index 0a928de7961b5..06418b1051ac3 100644 --- a/src/librustc_data_structures/work_queue.rs +++ b/src/librustc_data_structures/work_queue.rs @@ -1,5 +1,5 @@ -use bit_set::BitSet; -use indexed_vec::Idx; +use crate::bit_set::BitSet; +use crate::indexed_vec::Idx; use std::collections::VecDeque; /// A work queue is a handy data structure for tracking work left to