about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-31 03:35:33 +0000
committerbors <bors@rust-lang.org>2018-08-31 03:35:33 +0000
commit1114ab684fbad001c4e580326d8eb4d8c4e917d3 (patch)
treeca7e8212e95a1a99912f17d9df0c0313f75b8a0b /src/librustc
parent8adc69a5a873dd7e840b7d002ae48a4c638ef7ee (diff)
parent6b1fffae20ce2c542fb6ee860b3ecfadd055abd2 (diff)
downloadrust-1114ab684fbad001c4e580326d8eb4d8c4e917d3.tar.gz
rust-1114ab684fbad001c4e580326d8eb4d8c4e917d3.zip
Auto merge of #53832 - pietroalbini:rollup, r=pietroalbini
Rollup of 20 pull requests

Successful merges:

 - #51760 (Add another PartialEq example)
 - #53113 (Add example for Cow)
 - #53129 (remove `let x = baz` which was obscuring the real error)
 - #53389 (document effect of join on memory ordering)
 - #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.)
 - #53476 (Add partialeq implementation for TryFromIntError type)
 - #53513 (Force-inline `shallow_resolve` at its hottest call site.)
 - #53655 (set applicability)
 - #53702 (Fix stabilisation version for macro_vis_matcher.)
 - #53727 (Do not suggest dereferencing in macro)
 - #53732 (save-analysis: Differentiate foreign functions and statics.)
 - #53740 (add llvm-readobj to llvm-tools-preview)
 - #53743 (fix a typo: taget_env -> target_env)
 - #53747 (Rustdoc fixes)
 - #53753 (expand keep-stage --help text)
 - #53756 (Fix typo in comment)
 - #53768 (move file-extension based .gitignore down to src/)
 - #53785 (Fix a comment in src/libcore/slice/mod.rs)
 - #53786 (Replace usages of 'bad_style' with 'nonstandard_style'.)
 - #53806 (Fix UI issues on Implementations on Foreign types)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/hir/lowering.rs7
-rw-r--r--src/librustc/infer/mod.rs10
-rw-r--r--src/librustc/middle/weak_lang_items.rs5
-rw-r--r--src/librustc/session/config.rs4
-rw-r--r--src/librustc/session/filesearch.rs4
-rw-r--r--src/librustc/session/mod.rs5
-rw-r--r--src/librustc/traits/fulfill.rs3
-rw-r--r--src/librustc/ty/query/job.rs11
-rw-r--r--src/librustc/ty/query/plumbing.rs4
-rw-r--r--src/librustc/util/common.rs2
-rw-r--r--src/librustc/util/profiling.rs2
-rw-r--r--src/librustc/util/time_graph.rs6
12 files changed, 36 insertions, 27 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index cb05f7b44c3..8584b534ff2 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -50,6 +50,7 @@ use hir::GenericArg;
 use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
                     ELIDED_LIFETIMES_IN_PATHS};
 use middle::cstore::CrateStore;
+use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::indexed_vec::IndexVec;
 use rustc_data_structures::small_vec::OneVector;
 use rustc_data_structures::thin_vec::ThinVec;
@@ -57,7 +58,7 @@ use session::Session;
 use util::common::FN_OUTPUT_NAME;
 use util::nodemap::{DefIdMap, NodeMap};
 
-use std::collections::{BTreeMap, HashSet};
+use std::collections::BTreeMap;
 use std::fmt::Debug;
 use std::iter;
 use std::mem;
@@ -1342,7 +1343,7 @@ impl<'a> LoweringContext<'a> {
             exist_ty_id: NodeId,
             collect_elided_lifetimes: bool,
             currently_bound_lifetimes: Vec<hir::LifetimeName>,
-            already_defined_lifetimes: HashSet<hir::LifetimeName>,
+            already_defined_lifetimes: FxHashSet<hir::LifetimeName>,
             output_lifetimes: Vec<hir::GenericArg>,
             output_lifetime_params: Vec<hir::GenericParam>,
         }
@@ -1476,7 +1477,7 @@ impl<'a> LoweringContext<'a> {
             exist_ty_id,
             collect_elided_lifetimes: true,
             currently_bound_lifetimes: Vec::new(),
-            already_defined_lifetimes: HashSet::new(),
+            already_defined_lifetimes: FxHashSet::default(),
             output_lifetimes: Vec::new(),
             output_lifetime_params: Vec::new(),
         };
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index a3c9d14eef2..a379438275d 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -1116,7 +1116,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         self.resolve_type_vars_if_possible(t).to_string()
     }
 
-    pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
+    // We have this force-inlined variant of shallow_resolve() for the one
+    // callsite that is extremely hot. All other callsites use the normal
+    // variant.
+    #[inline(always)]
+    pub fn inlined_shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
         match typ.sty {
             ty::Infer(ty::TyVar(v)) => {
                 // Not entirely obvious: if `typ` is a type variable,
@@ -1157,6 +1161,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         }
     }
 
+    pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
+        self.inlined_shallow_resolve(typ)
+    }
+
     pub fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
         where T: TypeFoldable<'tcx>
     {
diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs
index bfc27e3b580..cbf6722c0fd 100644
--- a/src/librustc/middle/weak_lang_items.rs
+++ b/src/librustc/middle/weak_lang_items.rs
@@ -13,6 +13,7 @@
 use session::config;
 use middle::lang_items;
 
+use rustc_data_structures::fx::FxHashSet;
 use rustc_target::spec::PanicStrategy;
 use syntax::ast;
 use syntax::symbol::Symbol;
@@ -23,8 +24,6 @@ use hir::intravisit;
 use hir;
 use ty::TyCtxt;
 
-use std::collections::HashSet;
-
 macro_rules! weak_lang_items {
     ($($name:ident, $item:ident, $sym:ident;)*) => (
 
@@ -101,7 +100,7 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         return
     }
 
-    let mut missing = HashSet::new();
+    let mut missing = FxHashSet::default();
     for &cnum in tcx.crates().iter() {
         for &item in tcx.missing_lang_items(cnum).iter() {
             missing.insert(item);
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index a58bb4724d2..ee683e37648 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -37,10 +37,10 @@ use std::collections::btree_map::Iter as BTreeMapIter;
 use std::collections::btree_map::Keys as BTreeMapKeysIter;
 use std::collections::btree_map::Values as BTreeMapValuesIter;
 
+use rustc_data_structures::fx::FxHashSet;
 use std::{fmt, str};
 use std::hash::Hasher;
 use std::collections::hash_map::DefaultHasher;
-use std::collections::HashSet;
 use std::iter::FromIterator;
 use std::path::{Path, PathBuf};
 
@@ -1373,7 +1373,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
     let max_atomic_width = sess.target.target.max_atomic_width();
     let atomic_cas = sess.target.target.options.atomic_cas;
 
-    let mut ret = HashSet::new();
+    let mut ret = FxHashSet::default();
     // Target bindings.
     ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os))));
     if let Some(ref fam) = sess.target.target.options.target_family {
diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs
index 32044fdf2a8..0de5d3d03d5 100644
--- a/src/librustc/session/filesearch.rs
+++ b/src/librustc/session/filesearch.rs
@@ -12,8 +12,8 @@
 
 pub use self::FileMatch::*;
 
+use rustc_data_structures::fx::FxHashSet;
 use std::borrow::Cow;
-use std::collections::HashSet;
 use std::env;
 use std::fs;
 use std::path::{Path, PathBuf};
@@ -40,7 +40,7 @@ impl<'a> FileSearch<'a> {
     pub fn for_each_lib_search_path<F>(&self, mut f: F) where
         F: FnMut(&Path, PathKind)
     {
-        let mut visited_dirs = HashSet::new();
+        let mut visited_dirs = FxHashSet::default();
 
         for (path, kind) in self.search_paths.iter(self.kind) {
             f(path, kind);
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index c8c0d4c38a2..00c5369e064 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -47,7 +47,6 @@ use jobserver::Client;
 
 use std;
 use std::cell::{self, Cell, RefCell};
-use std::collections::HashMap;
 use std::env;
 use std::fmt;
 use std::io::Write;
@@ -122,7 +121,7 @@ pub struct Session {
     /// Map from imported macro spans (which consist of
     /// the localized span for the macro body) to the
     /// macro name and definition span in the source crate.
-    pub imported_macro_spans: OneThread<RefCell<HashMap<Span, (String, Span)>>>,
+    pub imported_macro_spans: OneThread<RefCell<FxHashMap<Span, (String, Span)>>>,
 
     incr_comp_session: OneThread<RefCell<IncrCompSession>>,
 
@@ -1122,7 +1121,7 @@ pub fn build_session_(
         injected_allocator: Once::new(),
         allocator_kind: Once::new(),
         injected_panic_runtime: Once::new(),
-        imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())),
+        imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
         incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
         self_profiling: Lock::new(SelfProfiler::new()),
         profile_channel: Lock::new(None),
diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs
index 5c977e1bf62..9998db4ad1d 100644
--- a/src/librustc/traits/fulfill.rs
+++ b/src/librustc/traits/fulfill.rs
@@ -269,7 +269,8 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
         // doing more work yet
         if !pending_obligation.stalled_on.is_empty() {
             if pending_obligation.stalled_on.iter().all(|&ty| {
-                let resolved_ty = self.selcx.infcx().shallow_resolve(&ty);
+                // Use the force-inlined variant of shallow_resolve() because this code is hot.
+                let resolved_ty = self.selcx.infcx().inlined_shallow_resolve(&ty);
                 resolved_ty == ty // nothing changed here
             }) {
                 debug!("process_predicate: pending obligation {:?} still stalled on {:?}",
diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs
index e3b0f8c4570..d07891fca12 100644
--- a/src/librustc/ty/query/job.rs
+++ b/src/librustc/ty/query/job.rs
@@ -11,6 +11,7 @@
 #![allow(warnings)]
 
 use std::mem;
+use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak};
 use rustc_data_structures::OnDrop;
 use syntax_pos::Span;
@@ -21,7 +22,7 @@ use ty::context::TyCtxt;
 use errors::Diagnostic;
 use std::process;
 use std::{fmt, ptr};
-use std::collections::HashSet;
+
 #[cfg(parallel_queries)]
 use {
     rayon_core,
@@ -282,7 +283,7 @@ where
 fn cycle_check<'tcx>(query: Lrc<QueryJob<'tcx>>,
                      span: Span,
                      stack: &mut Vec<(Span, Lrc<QueryJob<'tcx>>)>,
-                     visited: &mut HashSet<*const QueryJob<'tcx>>
+                     visited: &mut FxHashSet<*const QueryJob<'tcx>>
 ) -> Option<Option<Waiter<'tcx>>> {
     if visited.contains(&query.as_ptr()) {
         return if let Some(p) = stack.iter().position(|q| q.1.as_ptr() == query.as_ptr()) {
@@ -321,7 +322,7 @@ fn cycle_check<'tcx>(query: Lrc<QueryJob<'tcx>>,
 #[cfg(parallel_queries)]
 fn connected_to_root<'tcx>(
     query: Lrc<QueryJob<'tcx>>,
-    visited: &mut HashSet<*const QueryJob<'tcx>>
+    visited: &mut FxHashSet<*const QueryJob<'tcx>>
 ) -> bool {
     // We already visited this or we're deliberately ignoring it
     if visited.contains(&query.as_ptr()) {
@@ -357,7 +358,7 @@ fn remove_cycle<'tcx>(
     wakelist: &mut Vec<Lrc<QueryWaiter<'tcx>>>,
     tcx: TyCtxt<'_, 'tcx, '_>
 ) -> bool {
-    let mut visited = HashSet::new();
+    let mut visited = FxHashSet::default();
     let mut stack = Vec::new();
     // Look for a cycle starting with the last query in `jobs`
     if let Some(waiter) = cycle_check(jobs.pop().unwrap(),
@@ -389,7 +390,7 @@ fn remove_cycle<'tcx>(
         // connected to queries outside the cycle
         let entry_points: Vec<Lrc<QueryJob<'tcx>>> = stack.iter().filter_map(|query| {
             // Mark all the other queries in the cycle as already visited
-            let mut visited = HashSet::from_iter(stack.iter().filter_map(|q| {
+            let mut visited = FxHashSet::from_iter(stack.iter().filter_map(|q| {
                 if q.1.as_ptr() != query.1.as_ptr() {
                     Some(q.1.as_ptr())
                 } else {
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index 8473e4af40e..0edb1aa79e7 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -718,7 +718,7 @@ macro_rules! define_queries_inner {
             }
         }
 
-        #[allow(bad_style)]
+        #[allow(nonstandard_style)]
         #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
         pub enum Query<$tcx> {
             $($(#[$attr])* $name($K)),*
@@ -775,7 +775,7 @@ macro_rules! define_queries_inner {
         pub mod queries {
             use std::marker::PhantomData;
 
-            $(#[allow(bad_style)]
+            $(#[allow(nonstandard_style)]
             pub struct $name<$tcx> {
                 data: PhantomData<&$tcx ()>
             })*
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index bdfba7c3e3a..02bdc5f41b3 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -84,7 +84,7 @@ pub struct ProfQDumpParams {
     pub dump_profq_msg_log:bool,
 }
 
-#[allow(bad_style)]
+#[allow(nonstandard_style)]
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub struct QueryMsg {
     pub query: &'static str,
diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs
index 74ff1a5f4fd..70760d35f78 100644
--- a/src/librustc/util/profiling.rs
+++ b/src/librustc/util/profiling.rs
@@ -21,7 +21,7 @@ macro_rules! define_categories {
             $($name),*
         }
 
-        #[allow(bad_style)]
+        #[allow(nonstandard_style)]
         struct Categories<T> {
             $($name: T),*
         }
diff --git a/src/librustc/util/time_graph.rs b/src/librustc/util/time_graph.rs
index a8502682a80..3ba4e4ddbb1 100644
--- a/src/librustc/util/time_graph.rs
+++ b/src/librustc/util/time_graph.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::collections::HashMap;
+use rustc_data_structures::fx::FxHashMap;
 use std::fs::File;
 use std::io::prelude::*;
 use std::marker::PhantomData;
@@ -40,7 +40,7 @@ struct PerThread {
 
 #[derive(Clone)]
 pub struct TimeGraph {
-    data: Arc<Mutex<HashMap<TimelineId, PerThread>>>,
+    data: Arc<Mutex<FxHashMap<TimelineId, PerThread>>>,
 }
 
 #[derive(Clone, Copy)]
@@ -68,7 +68,7 @@ impl Drop for RaiiToken {
 impl TimeGraph {
     pub fn new() -> TimeGraph {
         TimeGraph {
-            data: Arc::new(Mutex::new(HashMap::new()))
+            data: Arc::new(Mutex::new(FxHashMap::default()))
         }
     }