From 931eb4c4d5169ebff249387f2049295eb7925c79 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Mon, 6 Aug 2018 17:33:32 +0300 Subject: [PATCH 01/26] Add one more example for Cow that shows how to keep Cow in a struct --- src/liballoc/borrow.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index c6741ddb822d5..dd4f958804dee 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -141,6 +141,40 @@ impl ToOwned for T /// let mut input = Cow::from(vec![-1, 0, 1]); /// abs_all(&mut input); /// ``` +/// +/// ``` +/// use std::borrow::{Cow, ToOwned}; +/// +/// struct Items<'a, X: 'a> where [X]: ToOwned> { +/// values: Cow<'a, [X]>, +/// } +/// +/// impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned> { +/// fn new(v: Cow<'a, [X]>) -> Self { +/// Items { values: v } +/// } +/// } +/// +/// // Creates a container from borrowed values of a slice +/// let readonly = [1, 2]; +/// let borrowed = Items::new((&readonly[..]).into()); +/// match borrowed { +/// Items { values: Cow::Borrowed(b) } => println!("borrowed {:?}", b), +/// _ => panic!("expect borrowed value"), +/// } +/// +/// let mut clone_on_write = borrowed; +/// // Mutates the data from slice into owned vec and pushes a new value on top +/// clone_on_write.values.to_mut().push(3); +/// println!("clone_on_write = {:?}", clone_on_write.values); +/// +/// // The data was mutated. Let check it out. +/// match clone_on_write { +/// Items { values: Cow::Owned(_) } => println!("clone_on_write contains owned data"), +/// _ => panic!("expect owned data"), +/// } +/// ``` + #[stable(feature = "rust1", since = "1.0.0")] pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned From 9a3a12eaa37b46f4eedd0c93fa61f35e2d748ee8 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Wed, 15 Aug 2018 14:00:59 +0300 Subject: [PATCH 02/26] Fix review notes --- src/liballoc/borrow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index dd4f958804dee..95980735f7e14 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -142,6 +142,7 @@ impl ToOwned for T /// abs_all(&mut input); /// ``` /// +/// Another example showing how to keep `Cow` in a struct: /// ``` /// use std::borrow::{Cow, ToOwned}; /// @@ -174,7 +175,6 @@ impl ToOwned for T /// _ => panic!("expect owned data"), /// } /// ``` - #[stable(feature = "rust1", since = "1.0.0")] pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned From 34b65db8420ecfec94126483c7c170c270fd2ead Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 15 Aug 2018 15:22:54 +0200 Subject: [PATCH 03/26] document effect of join on memory ordering --- src/libstd/thread/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 61c6084a25023..b580b1ec510b7 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1308,13 +1308,17 @@ impl JoinHandle { &self.0.thread } - /// Waits for the associated thread to finish. + /// Waits for the associated thread to finish. In terms of [atomic memory orderings], + /// the completion of the associated thread synchronizes with this function returning. + /// In other words, all operations performed by that thread are ordered before all + /// operations that happen after `join` returns. /// /// If the child thread panics, [`Err`] is returned with the parameter given /// to [`panic`]. /// /// [`Err`]: ../../std/result/enum.Result.html#variant.Err /// [`panic`]: ../../std/macro.panic.html + /// [atomic memory orderings]: ../../std/sync/atomic/index.html /// /// # Panics /// From 5bfb7850782c440f27e0a5b64157aed9e04c5cc6 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Wed, 15 Aug 2018 22:06:35 +0300 Subject: [PATCH 04/26] Review fix --- src/liballoc/borrow.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 95980735f7e14..5ae5339138fbe 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -143,6 +143,7 @@ impl ToOwned for T /// ``` /// /// Another example showing how to keep `Cow` in a struct: +/// /// ``` /// use std::borrow::{Cow, ToOwned}; /// From b73843f9422fb487b2d26ac2d65f79f73a4c9ae3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 17 Aug 2018 16:05:24 +1000 Subject: [PATCH 05/26] Force-inline `shallow_resolve` at its hottest call site. It's a ~1% win on `keccak` and `inflate`. --- src/librustc/infer/mod.rs | 10 +++++++++- src/librustc/traits/fulfill.rs | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index eed6215150fdb..1cdbc80ccacf8 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::TyInfer(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(&self, value: &T) -> T where T: TypeFoldable<'tcx> { diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 5113f3cde3284..a3cc650511883 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 {:?}", From 3995bff26ce657ec6bac43cb0bdb4769e36ccc67 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 21 Aug 2018 23:24:23 +0200 Subject: [PATCH 06/26] Add another PartialEq example --- src/libcore/cmp.rs | 85 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 58d6c4f5e0923..ef7d83a0993da 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -75,7 +75,12 @@ use self::Ordering::*; /// the same book if their ISBN matches, even if the formats differ: /// /// ``` -/// enum BookFormat { Paperback, Hardback, Ebook } +/// enum BookFormat { +/// Paperback, +/// Hardback, +/// Ebook, +/// } +/// /// struct Book { /// isbn: i32, /// format: BookFormat, @@ -95,6 +100,84 @@ use self::Ordering::*; /// assert!(b1 != b3); /// ``` /// +/// ## How can I compare two different types? +/// +/// The type you can compare with is controlled by `PartialEq`'s type parameter. +/// For example, let's tweak our previous code a bit: +/// +/// ``` +/// enum BookFormat { +/// Paperback, +/// Hardback, +/// Ebook, +/// } +/// +/// struct Book { +/// isbn: i32, +/// format: BookFormat, +/// } +/// +/// impl PartialEq for Book { +/// fn eq(&self, other: &BookFormat) -> bool { +/// match (&self.format, other) { +/// (BookFormat::Paperback, BookFormat::Paperback) => true, +/// (BookFormat::Hardback, BookFormat::Hardback) => true, +/// (BookFormat::Ebook, BookFormat::Ebook) => true, +/// (_, _) => false, +/// } +/// } +/// } +/// +/// let b1 = Book { isbn: 3, format: BookFormat::Paperback }; +/// +/// assert!(b1 == BookFormat::Paperback); +/// assert!(b1 != BookFormat::Ebook); +/// ``` +/// +/// By changing `impl PartialEq for Book` to `impl PartialEq for Book`, +/// we've changed what type we can use on the right side of the `==` operator. +/// This lets us use it in the `assert!` statements at the bottom. +/// +/// You can also combine these implementations to let the `==` operator work with +/// two different types: +/// +/// ``` +/// enum BookFormat { +/// Paperback, +/// Hardback, +/// Ebook, +/// } +/// +/// struct Book { +/// isbn: i32, +/// format: BookFormat, +/// } +/// +/// impl PartialEq for Book { +/// fn eq(&self, other: &BookFormat) -> bool { +/// match (&self.format, other) { +/// (&BookFormat::Paperback, &BookFormat::Paperback) => true, +/// (&BookFormat::Hardback, &BookFormat::Hardback) => true, +/// (&BookFormat::Ebook, &BookFormat::Ebook) => true, +/// (_, _) => false, +/// } +/// } +/// } +/// +/// impl PartialEq for Book { +/// fn eq(&self, other: &Book) -> bool { +/// self.isbn == other.isbn +/// } +/// } +/// +/// let b1 = Book { isbn: 3, format: BookFormat::Paperback }; +/// let b2 = Book { isbn: 3, format: BookFormat::Ebook }; +/// +/// assert!(b1 == BookFormat::Paperback); +/// assert!(b1 != BookFormat::Ebook); +/// assert!(b1 == b2); +/// ``` +/// /// # Examples /// /// ``` From 9395a02b5aba108ce015f4baa761b8927f91d3d0 Mon Sep 17 00:00:00 2001 From: Jakub Kozlowski Date: Sat, 25 Aug 2018 17:49:45 +0100 Subject: [PATCH 07/26] Fix stabilisation version for macro_vis_matcher. --- src/libsyntax/feature_gate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e2a22167b7e45..654bc96f192dc 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -641,7 +641,7 @@ declare_features! ( // Defining procedural macros in `proc-macro` crates (accepted, proc_macro, "1.29.0", Some(38356), None), // Allows use of the :vis macro fragment specifier - (accepted, macro_vis_matcher, "1.29.0", Some(41022), None), + (accepted, macro_vis_matcher, "1.30.0", Some(41022), None), // Allows importing and reexporting macros with `use`, // enables macro modularization in general. (accepted, use_extern_macros, "1.30.0", Some(35896), None), From 1f421d645633f600e85ecec60a56ac5b4c19335c Mon Sep 17 00:00:00 2001 From: Joseph Post Date: Sat, 25 Aug 2018 22:47:46 -0500 Subject: [PATCH 08/26] call span_suggestion with applicability --- src/librustc_resolve/lib.rs | 62 ++++++++++++++++-------- src/librustc_typeck/structured_errors.rs | 11 +++-- src/libsyntax/parse/parser.rs | 14 +++++- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 264f5c0113581..8ef5144501972 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -69,7 +69,7 @@ use syntax::feature_gate::{feature_err, GateIssue}; use syntax::ptr::P; use syntax_pos::{Span, DUMMY_SP, MultiSpan}; -use errors::{DiagnosticBuilder, DiagnosticId}; +use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; use std::cell::{Cell, RefCell}; use std::cmp; @@ -220,9 +220,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, let sugg_msg = "try using a local type parameter instead"; if let Some((sugg_span, new_snippet)) = cm.generate_local_type_param_snippet(span) { // Suggest the modification to the user - err.span_suggestion(sugg_span, - sugg_msg, - new_snippet); + err.span_suggestion_with_applicability( + sugg_span, + sugg_msg, + new_snippet, + Applicability::MachineApplicable, + ); } else if let Some(sp) = cm.generate_fn_name_span(span) { err.span_label(sp, "try adding a local type parameter in this method instead"); } else { @@ -2998,8 +3001,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { enum_path); err.help(&msg); } else { - err.span_suggestion(span, "you can try using the variant's enum", - enum_path); + err.span_suggestion_with_applicability( + span, + "you can try using the variant's enum", + enum_path, + Applicability::MachineApplicable, + ); } } } @@ -3008,20 +3015,32 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { let self_is_available = this.self_value_is_available(path[0].span, span); match candidate { AssocSuggestion::Field => { - err.span_suggestion(span, "try", - format!("self.{}", path_str)); + err.span_suggestion_with_applicability( + span, + "try", + format!("self.{}", path_str), + Applicability::MachineApplicable, + ); if !self_is_available { err.span_label(span, format!("`self` value is only available in \ methods with `self` parameter")); } } AssocSuggestion::MethodWithSelf if self_is_available => { - err.span_suggestion(span, "try", - format!("self.{}", path_str)); + err.span_suggestion_with_applicability( + span, + "try", + format!("self.{}", path_str), + Applicability::MachineApplicable, + ); } AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => { - err.span_suggestion(span, "try", - format!("Self::{}", path_str)); + err.span_suggestion_with_applicability( + span, + "try", + format!("Self::{}", path_str), + Applicability::MachineApplicable, + ); } } return (err, candidates); @@ -4617,15 +4636,16 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { format!("other_{}", name) }; - err.span_suggestion(binding.span, - rename_msg, - if snippet.ends_with(';') { - format!("{} as {};", - &snippet[..snippet.len()-1], - suggested_name) - } else { - format!("{} as {}", snippet, suggested_name) - }); + err.span_suggestion_with_applicability( + binding.span, + rename_msg, + if snippet.ends_with(';') { + format!("{} as {};", &snippet[..snippet.len() - 1], suggested_name) + } else { + format!("{} as {}", snippet, suggested_name) + }, + Applicability::MachineApplicable, + ); } else { err.span_label(binding.span, rename_msg); } diff --git a/src/librustc_typeck/structured_errors.rs b/src/librustc_typeck/structured_errors.rs index ffd9da8c8b95c..12863cc66a053 100644 --- a/src/librustc_typeck/structured_errors.rs +++ b/src/librustc_typeck/structured_errors.rs @@ -10,7 +10,7 @@ use rustc::session::Session; use syntax_pos::Span; -use errors::{DiagnosticId, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticId, DiagnosticBuilder}; use rustc::ty::{Ty, TypeFoldable}; pub trait StructuredDiagnostic<'tcx> { @@ -73,9 +73,12 @@ impl<'tcx> StructuredDiagnostic<'tcx> for VariadicError<'tcx> { ) }; if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.span) { - err.span_suggestion(self.span, - &format!("cast the value to `{}`", self.cast_ty), - format!("{} as {}", snippet, self.cast_ty)); + err.span_suggestion_with_applicability( + self.span, + &format!("cast the value to `{}`", self.cast_ty), + format!("{} as {}", snippet, self.cast_ty), + Applicability::MachineApplicable, + ); } else { err.help(&format!("cast the value to `{}`", self.cast_ty)); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 725360b842d43..a9bb013698e97 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -786,7 +786,12 @@ impl<'a> Parser<'a> { } else { err.span_label(self.span, "expected identifier"); if self.token == token::Comma && self.look_ahead(1, |t| t.is_ident()) { - err.span_suggestion(self.span, "remove this comma", String::new()); + err.span_suggestion_with_applicability( + self.span, + "remove this comma", + String::new(), + Applicability::MachineApplicable, + ); } } err @@ -6077,7 +6082,12 @@ impl<'a> Parser<'a> { self.this_token_to_string())); if self.token.is_ident() { // This is likely another field; emit the diagnostic and keep going - err.span_suggestion(sp, "try adding a comma", ",".into()); + err.span_suggestion_with_applicability( + sp, + "try adding a comma", + ",".into(), + Applicability::MachineApplicable, + ); err.emit(); } else { return Err(err) From 26f38c0f344f35e8d252ed756bf6794cbe974329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 26 Aug 2018 16:54:06 -0700 Subject: [PATCH 09/26] Do not suggest dereferencing in macro --- src/librustc_typeck/check/demand.rs | 13 ++++++++----- src/test/ui/deref-suggestion.rs | 16 +++++++++++----- src/test/ui/deref-suggestion.stderr | 26 ++++++++++++++++++-------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index b0b2799c793b2..f0ca0df1b48bf 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -351,11 +351,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !self.infcx.type_moves_by_default(self.param_env, checked, sp) { - let sp = cm.call_span_if_macro(sp); - if let Ok(code) = cm.span_to_snippet(sp) { - return Some((sp, - "consider dereferencing the borrow", - format!("*{}", code))); + // do not suggest if the span comes from a macro (#52783) + if let (Ok(code), + true) = (cm.span_to_snippet(sp), sp == expr.span) { + return Some(( + sp, + "consider dereferencing the borrow", + format!("*{}", code), + )); } } } diff --git a/src/test/ui/deref-suggestion.rs b/src/test/ui/deref-suggestion.rs index 04ba4ab905eb1..49df7108f29a1 100644 --- a/src/test/ui/deref-suggestion.rs +++ b/src/test/ui/deref-suggestion.rs @@ -15,20 +15,26 @@ macro_rules! borrow { fn foo(_: String) {} fn foo2(s: &String) { - foo(s); //~ ERROR mismatched types + foo(s); + //~^ ERROR mismatched types } fn foo3(_: u32) {} fn foo4(u: &u32) { - foo3(u); //~ ERROR mismatched types + foo3(u); + //~^ ERROR mismatched types } fn main() { let s = String::new(); let r_s = &s; foo2(r_s); - foo(&"aaa".to_owned()); //~ ERROR mismatched types - foo(&mut "aaa".to_owned()); //~ ERROR mismatched types + foo(&"aaa".to_owned()); + //~^ ERROR mismatched types + foo(&mut "aaa".to_owned()); + //~^ ERROR mismatched types foo3(borrow!(0)); foo4(&0); -} + assert_eq!(3i32, &3i32); + //~^ ERROR mismatched types +} \ No newline at end of file diff --git a/src/test/ui/deref-suggestion.stderr b/src/test/ui/deref-suggestion.stderr index a5f87928924ca..9811c5969dad6 100644 --- a/src/test/ui/deref-suggestion.stderr +++ b/src/test/ui/deref-suggestion.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:18:9 | -LL | foo(s); //~ ERROR mismatched types +LL | foo(s); | ^ | | | expected struct `std::string::String`, found reference @@ -11,9 +11,9 @@ LL | foo(s); //~ ERROR mismatched types found type `&std::string::String` error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:23:10 + --> $DIR/deref-suggestion.rs:24:10 | -LL | foo3(u); //~ ERROR mismatched types +LL | foo3(u); | ^ | | | expected u32, found &u32 @@ -23,9 +23,9 @@ LL | foo3(u); //~ ERROR mismatched types found type `&u32` error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:30:9 + --> $DIR/deref-suggestion.rs:32:9 | -LL | foo(&"aaa".to_owned()); //~ ERROR mismatched types +LL | foo(&"aaa".to_owned()); | ^^^^^^^^^^^^^^^^^ | | | expected struct `std::string::String`, found reference @@ -35,9 +35,9 @@ LL | foo(&"aaa".to_owned()); //~ ERROR mismatched types found type `&std::string::String` error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:31:9 + --> $DIR/deref-suggestion.rs:34:9 | -LL | foo(&mut "aaa".to_owned()); //~ ERROR mismatched types +LL | foo(&mut "aaa".to_owned()); | ^^^^^^^^^^^^^^^^^^^^^ | | | expected struct `std::string::String`, found mutable reference @@ -58,6 +58,16 @@ LL | foo3(borrow!(0)); = note: expected type `u32` found type `&{integer}` -error: aborting due to 5 previous errors +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:38:5 + | +LL | assert_eq!(3i32, &3i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found &i32 + | + = note: expected type `i32` + found type `&i32` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0308`. From a2722f326138813d1d9cf0946523dd38d1f06b35 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sun, 26 Aug 2018 18:03:57 -0700 Subject: [PATCH 10/26] readd final newline --- src/test/ui/deref-suggestion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/deref-suggestion.rs b/src/test/ui/deref-suggestion.rs index 49df7108f29a1..1776a71a6bb47 100644 --- a/src/test/ui/deref-suggestion.rs +++ b/src/test/ui/deref-suggestion.rs @@ -37,4 +37,4 @@ fn main() { foo4(&0); assert_eq!(3i32, &3i32); //~^ ERROR mismatched types -} \ No newline at end of file +} From 4570ace630cac4c2badeacbee9e1d9c518bf6009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 18 Aug 2018 17:16:46 +0200 Subject: [PATCH 11/26] save-analysis: Differentiate foreign functions and statics. --- src/librustc_save_analysis/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 1549634e9b590..1f45cc4c25cae 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -147,7 +147,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { filter!(self.span_utils, sub_span, item.span, None); Some(Data::DefData(Def { - kind: DefKind::Function, + kind: DefKind::ForeignFunction, id: id_from_node_id(item.id, self), span: self.span_from_span(sub_span.unwrap()), name: item.ident.to_string(), @@ -170,7 +170,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let span = self.span_from_span(sub_span.unwrap()); Some(Data::DefData(Def { - kind: DefKind::Static, + kind: DefKind::ForeignStatic, id, span, name: item.ident.to_string(), From c874e36ad18808206281a4860ae88a359e223f01 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 27 Aug 2018 19:00:07 +0200 Subject: [PATCH 12/26] add llvm-readobj to llvm-tools-preview --- src/bootstrap/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 5bb475e07ba8d..720edaa91958c 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -213,6 +213,7 @@ const LLVM_TOOLS: &[&str] = &[ "llvm-profdata", // used to inspect and merge files generated by profiles "llvm-size", // used to prints the size of the linker sections of a program "llvm-strip", // used to discard symbols from binary files to reduce their size + "llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide ]; /// A structure representing a Rust compiler. From 8486efaf924dae203faa25b4d1965759417eb2f5 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Mon, 27 Aug 2018 13:25:58 -0400 Subject: [PATCH 13/26] fix a typo: taget_env -> target_env This typo was introduced in https://github.com/rust-lang/rust/pull/47334. A couple tests bitrotted as a result, so we fix those too, and move them to a more sensible place. --- src/libstd/sys/unix/net.rs | 27 --------------------------- src/libstd/sys/unix/os.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index 8c73fe8c6129f..2d10541752c83 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -395,30 +395,3 @@ fn on_resolver_failure() { #[cfg(not(target_env = "gnu"))] fn on_resolver_failure() {} - -#[cfg(all(test, taget_env = "gnu"))] -mod test { - use super::*; - - #[test] - fn test_res_init() { - // This mostly just tests that the weak linkage doesn't panic wildly... - res_init_if_glibc_before_2_26().unwrap(); - } - - #[test] - fn test_parse_glibc_version() { - let cases = [ - ("0.0", Some((0, 0))), - ("01.+2", Some((1, 2))), - ("3.4.5.six", Some((3, 4))), - ("1", None), - ("1.-2", None), - ("1.foo", None), - ("foo.1", None), - ]; - for &(version_str, parsed) in cases.iter() { - assert_eq!(parsed, parse_glibc_version(version_str)); - } - } -} diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index f8f0bbd5bc250..971e6501c2c2a 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -569,3 +569,30 @@ fn parse_glibc_version(version: &str) -> Option<(usize, usize)> { _ => None } } + +#[cfg(all(test, target_env = "gnu"))] +mod test { + use super::*; + + #[test] + fn test_glibc_version() { + // This mostly just tests that the weak linkage doesn't panic wildly... + glibc_version(); + } + + #[test] + fn test_parse_glibc_version() { + let cases = [ + ("0.0", Some((0, 0))), + ("01.+2", Some((1, 2))), + ("3.4.5.six", Some((3, 4))), + ("1", None), + ("1.-2", None), + ("1.foo", None), + ("foo.1", None), + ]; + for &(version_str, parsed) in cases.iter() { + assert_eq!(parsed, parse_glibc_version(version_str)); + } + } +} From 1d79d8be5619a4c51741dffd8d63d2db75a618f1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Aug 2018 21:51:56 +0200 Subject: [PATCH 14/26] Fix source automatic scroll --- src/librustdoc/html/static/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 88c25567d2963..51ed626782926 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -242,6 +242,7 @@ } } + highlightSourceLines(null); window.onhashchange = highlightSourceLines; // Gets the human-readable string for the virtual-key code of the From 04b4c40682c01cad8f9bc8d5b3907be91d6f81d4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Aug 2018 21:52:10 +0200 Subject: [PATCH 15/26] Fix invalid display of unstable messages --- src/librustdoc/html/static/rustdoc.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index ffe6a40b36998..870b024a3ba00 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -502,6 +502,7 @@ h4 > code, h3 > code, .invisible > code { margin-left: 33px; margin-top: -13px; } + .content .stability::before { content: '˪'; font-size: 30px; @@ -510,6 +511,10 @@ h4 > code, h3 > code, .invisible > code { left: -13px; } +#main > .stability { + margin-top: 0; +} + nav { border-bottom: 1px solid; padding-bottom: 10px; From f77ad5c6e56689bde62f631d75757242a52e5eaf Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 6 Aug 2018 16:41:35 -0400 Subject: [PATCH 16/26] remove `let x = baz` which was obscuring the real error --- ...-push-one-existing-name-early-bound.nll.stderr | 15 ++++++++------- .../ex2a-push-one-existing-name-early-bound.rs | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr index c5f3510fa0ed2..b4cbed03153a7 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr @@ -4,14 +4,15 @@ warning: not reporting region error due to nll LL | x.push(y); //~ ERROR explicit lifetime required | ^ -error[E0282]: type annotations needed - --> $DIR/ex2a-push-one-existing-name-early-bound.rs:20:9 +error[E0621]: explicit lifetime required in the type of `y` + --> $DIR/ex2a-push-one-existing-name-early-bound.rs:17:5 | -LL | let x = baz; - | - ^^^ cannot infer type for `T` - | | - | consider giving `x` a type +LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) + | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` +... +LL | x.push(y); //~ ERROR explicit lifetime required + | ^^^^^^^^^ lifetime `'a` required error: aborting due to previous error -For more information about this error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs index 18a720f345d7f..cad0a3c6ac13d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs @@ -17,5 +17,4 @@ fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) x.push(y); //~ ERROR explicit lifetime required } fn main() { -let x = baz; } From e6dcdee7d9b0d78cc991f87c168fe3e54c83974e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 28 Aug 2018 10:20:24 +0200 Subject: [PATCH 17/26] expand keep-stage --help text --- src/bootstrap/flags.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 60b4d65f44401..2084b8bdb65ff 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -125,7 +125,8 @@ To learn more about a subcommand, run `./x.py -h`" "stage to build (indicates compiler to use/test, e.g. stage 0 uses the \ bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)", "N"); - opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling", "N"); + opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling \ + (pass multiple times to keep e.g. both stages 0 and 1)", "N"); opts.optopt("", "src", "path to the root of the rust checkout", "DIR"); opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS"); opts.optflag("h", "help", "print this help message"); From 31b63d0ca8b117217c1612826a7ce2786b509c6c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 28 Aug 2018 10:49:45 +0200 Subject: [PATCH 18/26] split paragraph --- src/libstd/thread/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index b580b1ec510b7..a7c7dbb1b4027 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1308,9 +1308,11 @@ impl JoinHandle { &self.0.thread } - /// Waits for the associated thread to finish. In terms of [atomic memory orderings], - /// the completion of the associated thread synchronizes with this function returning. - /// In other words, all operations performed by that thread are ordered before all + /// Waits for the associated thread to finish. + /// + /// In terms of [atomic memory orderings], the completion of the associated + /// thread synchronizes with this function returning. In other words, all + /// operations performed by that thread are ordered before all /// operations that happen after `join` returns. /// /// If the child thread panics, [`Err`] is returned with the parameter given From 13113391a08161a3e9583e47f98da23bd9cf2445 Mon Sep 17 00:00:00 2001 From: Dimitri Merejkowsky Date: Tue, 28 Aug 2018 11:06:40 +0200 Subject: [PATCH 19/26] Fix typo in comment --- src/libstd/sys/unix/fd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index 4830e38d6a92f..12e14734ff515 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -282,7 +282,7 @@ impl Drop for FileDesc { // reason for this is that if an error occurs we don't actually know if // the file descriptor was closed or not, and if we retried (for // something like EINTR), we might close another valid file descriptor - // (opened after we closed ours. + // opened after we closed ours. let _ = unsafe { libc::close(self.fd) }; } } From 84796cbc01efe0f3b12985869c7a3efa88caf9f0 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 28 Aug 2018 14:58:52 +0200 Subject: [PATCH 20/26] sort --- src/bootstrap/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 720edaa91958c..862002f6e97fd 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -211,9 +211,9 @@ const LLVM_TOOLS: &[&str] = &[ "llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume "llvm-objdump", // used to disassemble programs "llvm-profdata", // used to inspect and merge files generated by profiles + "llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide "llvm-size", // used to prints the size of the linker sections of a program "llvm-strip", // used to discard symbols from binary files to reduce their size - "llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide ]; /// A structure representing a Rust compiler. From 93f3f5b1552489dbee03020505d896f01fd53852 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 18 Aug 2018 13:55:43 +0300 Subject: [PATCH 21/26] Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc. --- src/librustc/hir/lowering.rs | 7 ++- src/librustc/middle/weak_lang_items.rs | 5 +- src/librustc/session/config.rs | 4 +- src/librustc/session/filesearch.rs | 4 +- src/librustc/session/mod.rs | 5 +- src/librustc/ty/query/job.rs | 11 ++-- src/librustc/util/time_graph.rs | 6 +- src/librustc_codegen_llvm/back/linker.rs | 4 +- src/librustc_codegen_llvm/back/rpath.rs | 4 +- src/librustc_data_structures/graph/test.rs | 10 ++-- src/librustc_driver/profile/trace.rs | 8 +-- src/librustc_errors/emitter.rs | 6 +- src/librustc_errors/registry.rs | 4 +- .../persist/dirty_clean.rs | 11 ++-- src/librustc_lint/builtin.rs | 7 +-- src/librustc_metadata/locator.rs | 6 +- src/librustc_mir/transform/generator.rs | 29 ++++++---- src/librustc_plugin/registry.rs | 6 +- src/librustc_save_analysis/dump_visitor.rs | 4 +- src/librustdoc/html/markdown.rs | 11 ++-- src/librustdoc/html/render.rs | 57 ++++++++++--------- src/librustdoc/theme.rs | 8 +-- src/libsyntax/ast.rs | 4 +- src/libsyntax/ext/base.rs | 6 +- src/libsyntax/ext/derive.rs | 4 +- src/libsyntax/ext/expand.rs | 4 +- src/libsyntax/ext/placeholders.rs | 6 +- src/libsyntax/ext/tt/macro_parser.rs | 10 ++-- src/libsyntax/ext/tt/macro_rules.rs | 6 +- src/libsyntax/ext/tt/transcribe.rs | 12 ++-- src/libsyntax/parse/lexer/mod.rs | 6 +- src/libsyntax/parse/mod.rs | 8 +-- src/libsyntax_ext/format.rs | 16 +++--- src/libsyntax_pos/hygiene.rs | 9 ++- 34 files changed, 156 insertions(+), 152 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index cb05f7b44c3b9..8584b534ff240 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, - already_defined_lifetimes: HashSet, + already_defined_lifetimes: FxHashSet, output_lifetimes: Vec, output_lifetime_params: Vec, } @@ -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/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index bfc27e3b5806c..cbf6722c0fd37 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 a58bb4724d2e2..ee683e37648f0 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 32044fdf2a8cb..0de5d3d03d5c3 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(&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 ef81cd3a4575e..adab73c3b7290 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>>, + pub imported_macro_spans: OneThread>>, incr_comp_session: OneThread>, @@ -1129,7 +1128,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/ty/query/job.rs b/src/librustc/ty/query/job.rs index e3b0f8c4570df..d07891fca12ae 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>, span: Span, stack: &mut Vec<(Span, Lrc>)>, - visited: &mut HashSet<*const QueryJob<'tcx>> + visited: &mut FxHashSet<*const QueryJob<'tcx>> ) -> Option>> { 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>, #[cfg(parallel_queries)] fn connected_to_root<'tcx>( query: Lrc>, - 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>>, 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>> = 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/util/time_graph.rs b/src/librustc/util/time_graph.rs index a8502682a806b..3ba4e4ddbb13b 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>>, + data: Arc>>, } #[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())) } } diff --git a/src/librustc_codegen_llvm/back/linker.rs b/src/librustc_codegen_llvm/back/linker.rs index a429e8f2d815d..24f6156bd7692 100644 --- a/src/librustc_codegen_llvm/back/linker.rs +++ b/src/librustc_codegen_llvm/back/linker.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::ffi::{OsStr, OsString}; use std::fs::{self, File}; use std::io::prelude::*; @@ -30,7 +30,7 @@ use serialize::{json, Encoder}; /// For all the linkers we support, and information they might /// need out of the shared crate context before we get rid of it. pub struct LinkerInfo { - exports: HashMap>, + exports: FxHashMap>, } impl LinkerInfo { diff --git a/src/librustc_codegen_llvm/back/rpath.rs b/src/librustc_codegen_llvm/back/rpath.rs index 2c3a143646c24..aa4f7688b0f42 100644 --- a/src/librustc_codegen_llvm/back/rpath.rs +++ b/src/librustc_codegen_llvm/back/rpath.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::collections::HashSet; +use rustc_data_structures::fx::FxHashSet; use std::env; use std::path::{Path, PathBuf}; use std::fs; @@ -172,7 +172,7 @@ fn get_install_prefix_rpath(config: &mut RPathConfig) -> String { } fn minimize_rpaths(rpaths: &[String]) -> Vec { - let mut set = HashSet::new(); + let mut set = FxHashSet::default(); let mut minimized = Vec::new(); for rpath in rpaths { if set.insert(rpath) { diff --git a/src/librustc_data_structures/graph/test.rs b/src/librustc_data_structures/graph/test.rs index b72d011c99bad..26cc2c9f17cfb 100644 --- a/src/librustc_data_structures/graph/test.rs +++ b/src/librustc_data_structures/graph/test.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 fx::FxHashMap; use std::cmp::max; use std::slice; use std::iter; @@ -18,8 +18,8 @@ use super::*; pub struct TestGraph { num_nodes: usize, start_node: usize, - successors: HashMap>, - predecessors: HashMap>, + successors: FxHashMap>, + predecessors: FxHashMap>, } impl TestGraph { @@ -27,8 +27,8 @@ impl TestGraph { let mut graph = TestGraph { num_nodes: start_node + 1, start_node, - successors: HashMap::new(), - predecessors: HashMap::new(), + successors: FxHashMap::default(), + predecessors: FxHashMap::default(), }; for &(source, target) in edges { graph.num_nodes = max(graph.num_nodes, source + 1); diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs index 56cb3e9dbb829..e329b037d22aa 100644 --- a/src/librustc_driver/profile/trace.rs +++ b/src/librustc_driver/profile/trace.rs @@ -10,10 +10,10 @@ use super::*; use syntax_pos::SpanData; +use rustc_data_structures::fx::FxHashMap; use rustc::util::common::QueryMsg; use std::fs::File; use std::time::{Duration, Instant}; -use std::collections::hash_map::HashMap; use rustc::dep_graph::{DepNode}; #[derive(Debug, Clone, Eq, PartialEq)] @@ -149,7 +149,7 @@ fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usi } } -fn compute_counts_rec(counts: &mut HashMap, traces: &[Rec]) { +fn compute_counts_rec(counts: &mut FxHashMap, traces: &[Rec]) { for t in traces.iter() { match t.effect { Effect::TimeBegin(ref msg) => { @@ -200,7 +200,7 @@ fn compute_counts_rec(counts: &mut HashMap, traces: &[Rec]) } } -pub fn write_counts(count_file: &mut File, counts: &mut HashMap) { +pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap) { use rustc::util::common::duration_to_secs_str; use std::cmp::Reverse; @@ -219,7 +219,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap = HashMap::with_capacity(capacity); + let mut counts = FxHashMap::with_capacity_and_hasher(capacity, Default::default()); compute_counts_rec(&mut counts, traces); write_counts(counts_file, &mut counts); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index c08cf3d039df5..5f275b7003873 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -16,12 +16,12 @@ use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, D use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style}; use styled_buffer::StyledBuffer; +use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; use atty; use std::borrow::Cow; use std::io::prelude::*; use std::io; -use std::collections::HashMap; use std::cmp::{min, Reverse}; use termcolor::{StandardStream, ColorChoice, ColorSpec, BufferWriter}; use termcolor::{WriteColor, Color, Buffer}; @@ -1090,7 +1090,7 @@ impl EmitterWriter { max_line_num_len + 1); // Contains the vertical lines' positions for active multiline annotations - let mut multilines = HashMap::new(); + let mut multilines = FxHashMap::default(); // Next, output the annotate source for this file for line_idx in 0..annotated_file.lines.len() { @@ -1109,7 +1109,7 @@ impl EmitterWriter { width_offset, code_offset); - let mut to_add = HashMap::new(); + let mut to_add = FxHashMap::default(); for (depth, style) in depths { if multilines.get(&depth).is_some() { diff --git a/src/librustc_errors/registry.rs b/src/librustc_errors/registry.rs index 83737681471e2..9a2302171bab3 100644 --- a/src/librustc_errors/registry.rs +++ b/src/librustc_errors/registry.rs @@ -8,11 +8,11 @@ // 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; #[derive(Clone)] pub struct Registry { - descriptions: HashMap<&'static str, &'static str>, + descriptions: FxHashMap<&'static str, &'static str>, } impl Registry { diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index f715057541ffa..1b3819474c22e 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -24,7 +24,6 @@ //! the required condition is not met. //! -use std::collections::HashSet; use std::iter::FromIterator; use std::vec::Vec; use rustc::dep_graph::{DepNode, label_strs}; @@ -193,7 +192,7 @@ const LABELS_TRAIT: &[&[&str]] = &[ // // TypeOfItem for these. -type Labels = HashSet; +type Labels = FxHashSet; /// Represents the requested configuration by rustc_clean/dirty struct Assertion { @@ -205,13 +204,13 @@ impl Assertion { fn from_clean_labels(labels: Labels) -> Assertion { Assertion { clean: labels, - dirty: Labels::new(), + dirty: Labels::default(), } } fn from_dirty_labels(labels: Labels) -> Assertion { Assertion { - clean: Labels::new(), + clean: Labels::default(), dirty: labels, } } @@ -328,7 +327,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { } } // if no `label` or `except` is given, only the node's group are asserted - Labels::new() + Labels::default() } /// Return all DepNode labels that should be asserted for this item. @@ -436,7 +435,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { } fn resolve_labels(&self, item: &NestedMetaItem, value: &str) -> Labels { - let mut out: Labels = HashSet::new(); + let mut out = Labels::default(); for label in value.split(',') { let label = label.trim(); if DepNode::has_label_string(label) { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d84972b32c108..ab210b013c308 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -39,7 +39,6 @@ use util::nodemap::NodeSet; use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext}; -use std::collections::HashSet; use rustc::util::nodemap::FxHashSet; use syntax::tokenstream::{TokenTree, TokenStream}; @@ -304,14 +303,14 @@ pub struct MissingDoc { doc_hidden_stack: Vec, /// Private traits or trait items that leaked through. Don't check their methods. - private_traits: HashSet, + private_traits: FxHashSet, } impl MissingDoc { pub fn new() -> MissingDoc { MissingDoc { doc_hidden_stack: vec![false], - private_traits: HashSet::new(), + private_traits: FxHashSet::default(), } } @@ -908,7 +907,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { let mut work_queue = vec![cfg.entry]; let mut reached_exit_without_self_call = false; let mut self_call_spans = vec![]; - let mut visited = HashSet::new(); + let mut visited = FxHashSet::default(); while let Some(idx) = work_queue.pop() { if idx == cfg.exit { diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index f78a19403acf8..9492385957eab 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -226,6 +226,7 @@ use cstore::{MetadataRef, MetadataBlob}; use creader::Library; use schema::{METADATA_HEADER, rustc_version}; +use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::svh::Svh; use rustc::middle::cstore::MetadataLoader; use rustc::session::{config, Session}; @@ -239,7 +240,6 @@ use syntax_pos::Span; use rustc_target::spec::{Target, TargetTriple}; use std::cmp; -use std::collections::HashSet; use std::fmt; use std::fs; use std::io::{self, Read}; @@ -308,7 +308,7 @@ impl CratePaths { impl<'a> Context<'a> { pub fn maybe_load_library_crate(&mut self) -> Option { - let mut seen_paths = HashSet::new(); + let mut seen_paths = FxHashSet::default(); match self.extra_filename { Some(s) => self.find_library_crate(s, &mut seen_paths) .or_else(|| self.find_library_crate("", &mut seen_paths)), @@ -431,7 +431,7 @@ impl<'a> Context<'a> { fn find_library_crate(&mut self, extra_prefix: &str, - seen_paths: &mut HashSet) + seen_paths: &mut FxHashSet) -> Option { // If an SVH is specified, then this is a transitive dependency that // must be loaded via -L plus some filtering. diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index e9afa7df5c4f2..dcbf92b57b13a 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -67,9 +67,9 @@ use rustc::ty::{self, TyCtxt, AdtDef, Ty}; 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::indexed_set::IdxSet; -use std::collections::HashMap; use std::borrow::Cow; use std::iter::once; use std::mem; @@ -142,10 +142,12 @@ struct TransformVisitor<'a, 'tcx: 'a> { state_field: usize, // Mapping from Local to (type of local, generator struct index) - remap: HashMap, usize)>, + // FIXME(eddyb) This should use `IndexVec>`. + remap: FxHashMap, usize)>, // A map from a suspension point in a block to the locals which have live storage at that point - storage_liveness: HashMap>, + // FIXME(eddyb) This should use `IndexVec>`. + storage_liveness: FxHashMap>, // A list of suspension points, generated during the transform suspension_points: Vec, @@ -364,12 +366,15 @@ impl<'tcx> Visitor<'tcx> for BorrowedLocals { } } -fn locals_live_across_suspend_points<'a, 'tcx,>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - mir: &Mir<'tcx>, - source: MirSource, - movable: bool) -> - (liveness::LiveVarSet, - HashMap>) { +fn locals_live_across_suspend_points( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + mir: &Mir<'tcx>, + source: MirSource, + movable: bool, +) -> ( + liveness::LiveVarSet, + FxHashMap>, +) { let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); @@ -413,7 +418,7 @@ fn locals_live_across_suspend_points<'a, 'tcx,>(tcx: TyCtxt<'a, 'tcx, 'tcx>, &liveness, ); - let mut storage_liveness_map = HashMap::new(); + let mut storage_liveness_map = FxHashMap::default(); for (block, data) in mir.basic_blocks().iter_enumerated() { if let TerminatorKind::Yield { .. } = data.terminator().kind { @@ -477,9 +482,9 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, interior: Ty<'tcx>, movable: bool, mir: &mut Mir<'tcx>) - -> (HashMap, usize)>, + -> (FxHashMap, usize)>, GeneratorLayout<'tcx>, - HashMap>) + FxHashMap>) { // Use a liveness analysis to compute locals which are live across a suspension point let (live_locals, storage_liveness) = locals_live_across_suspend_points(tcx, diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs index b1ab86674cf90..5ef05cb1d6b6e 100644 --- a/src/librustc_plugin/registry.rs +++ b/src/librustc_plugin/registry.rs @@ -12,6 +12,7 @@ use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint}; use rustc::session::Session; +use rustc::util::nodemap::FxHashMap; use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT, IdentTT}; use syntax::ext::base::MacroExpanderFn; @@ -21,7 +22,6 @@ use syntax::ast; use syntax::feature_gate::AttributeType; use syntax_pos::Span; -use std::collections::HashMap; use std::borrow::ToOwned; /// Structure used to register plugins. @@ -53,7 +53,7 @@ pub struct Registry<'a> { pub late_lint_passes: Vec, #[doc(hidden)] - pub lint_groups: HashMap<&'static str, Vec>, + pub lint_groups: FxHashMap<&'static str, Vec>, #[doc(hidden)] pub llvm_passes: Vec, @@ -74,7 +74,7 @@ impl<'a> Registry<'a> { syntax_exts: vec![], early_lint_passes: vec![], late_lint_passes: vec![], - lint_groups: HashMap::new(), + lint_groups: FxHashMap::default(), llvm_passes: vec![], attributes: vec![], whitelisted_custom_derives: Vec::new(), diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index dc9310cdcdaa4..6f5655b8cec53 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -91,7 +91,7 @@ pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> { // of macro use (callsite) spans. We store these to ensure // we only write one macro def per unique macro definition, and // one macro use per unique callsite span. - // mac_defs: HashSet, + // mac_defs: FxHashSet, macro_calls: FxHashSet, } @@ -107,7 +107,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { dumper, span: span_utils.clone(), cur_scope: CRATE_NODE_ID, - // mac_defs: HashSet::new(), + // mac_defs: FxHashSet::default(), macro_calls: FxHashSet(), } } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index c104b88334061..18ad862c11bb0 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -29,8 +29,9 @@ #![allow(non_camel_case_types)] +use rustc_data_structures::fx::FxHashMap; use std::cell::RefCell; -use std::collections::{HashMap, VecDeque}; +use std::collections::VecDeque; use std::default::Default; use std::fmt::{self, Write}; use std::borrow::Cow; @@ -417,14 +418,14 @@ impl<'a, I: Iterator>> Iterator for SummaryLine<'a, I> { /// references. struct Footnotes<'a, I: Iterator>> { inner: I, - footnotes: HashMap>, u16)>, + footnotes: FxHashMap>, u16)>, } impl<'a, I: Iterator>> Footnotes<'a, I> { fn new(iter: I) -> Self { Footnotes { inner: iter, - footnotes: HashMap::new(), + footnotes: FxHashMap::default(), } } fn get_entry(&mut self, key: &str) -> &mut (Vec>, u16) { @@ -865,7 +866,7 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option>)> { #[derive(Default)] pub struct IdMap { - map: HashMap, + map: FxHashMap, } impl IdMap { @@ -880,7 +881,7 @@ impl IdMap { } pub fn reset(&mut self) { - self.map = HashMap::new(); + self.map = FxHashMap::default(); } pub fn derive(&mut self, candidate: String) -> String { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 8fb3b570f8a4b..1abe01dd0ac20 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -38,7 +38,7 @@ pub use self::ExternalLocation::*; use std::borrow::Cow; use std::cell::RefCell; use std::cmp::Ordering; -use std::collections::{BTreeMap, HashSet, VecDeque}; +use std::collections::{BTreeMap, VecDeque}; use std::default::Default; use std::error; use std::fmt::{self, Display, Formatter, Write as FmtWrite}; @@ -741,7 +741,7 @@ fn write_shared(cx: &Context, // To avoid "light.css" to be overwritten, we'll first run over the received themes and only // then we'll run over the "official" styles. - let mut themes: HashSet = HashSet::new(); + let mut themes: FxHashSet = FxHashSet::default(); for entry in &cx.shared.themes { let mut content = Vec::with_capacity(100000); @@ -1539,35 +1539,36 @@ impl Ord for ItemEntry { #[derive(Debug)] struct AllTypes { - structs: HashSet, - enums: HashSet, - unions: HashSet, - primitives: HashSet, - traits: HashSet, - macros: HashSet, - functions: HashSet, - typedefs: HashSet, - existentials: HashSet, - statics: HashSet, - constants: HashSet, - keywords: HashSet, + structs: FxHashSet, + enums: FxHashSet, + unions: FxHashSet, + primitives: FxHashSet, + traits: FxHashSet, + macros: FxHashSet, + functions: FxHashSet, + typedefs: FxHashSet, + existentials: FxHashSet, + statics: FxHashSet, + constants: FxHashSet, + keywords: FxHashSet, } impl AllTypes { fn new() -> AllTypes { + let new_set = |cap| FxHashSet::with_capacity_and_hasher(cap, Default::default()); AllTypes { - structs: HashSet::with_capacity(100), - enums: HashSet::with_capacity(100), - unions: HashSet::with_capacity(100), - primitives: HashSet::with_capacity(26), - traits: HashSet::with_capacity(100), - macros: HashSet::with_capacity(100), - functions: HashSet::with_capacity(100), - typedefs: HashSet::with_capacity(100), - existentials: HashSet::with_capacity(100), - statics: HashSet::with_capacity(100), - constants: HashSet::with_capacity(100), - keywords: HashSet::with_capacity(100), + structs: new_set(100), + enums: new_set(100), + unions: new_set(100), + primitives: new_set(26), + traits: new_set(100), + macros: new_set(100), + functions: new_set(100), + typedefs: new_set(100), + existentials: new_set(100), + statics: new_set(100), + constants: new_set(100), + keywords: new_set(100), } } @@ -1595,7 +1596,7 @@ impl AllTypes { } } -fn print_entries(f: &mut fmt::Formatter, e: &HashSet, title: &str, +fn print_entries(f: &mut fmt::Formatter, e: &FxHashSet, title: &str, class: &str) -> fmt::Result { if !e.is_empty() { let mut e: Vec<&ItemEntry> = e.iter().collect(); @@ -4185,7 +4186,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { } } let format_impls = |impls: Vec<&Impl>| { - let mut links = HashSet::new(); + let mut links = FxHashSet::default(); impls.iter() .filter_map(|i| { let is_negative_impl = is_negative_impl(i.inner_impl()); diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index 96a67e0788758..73cc363009de5 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::collections::HashSet; +use rustc_data_structures::fx::FxHashSet; use std::fs::File; use std::hash::{Hash, Hasher}; use std::io::Read; @@ -31,7 +31,7 @@ macro_rules! try_something { #[derive(Debug, Clone, Eq)] pub struct CssPath { pub name: String, - pub children: HashSet, + pub children: FxHashSet, } // This PartialEq implementation IS NOT COMMUTATIVE!!! @@ -66,7 +66,7 @@ impl CssPath { fn new(name: String) -> CssPath { CssPath { name, - children: HashSet::new(), + children: FxHashSet::default(), } } } @@ -211,7 +211,7 @@ fn build_rule(v: &[u8], positions: &[usize]) -> String { .join(" ") } -fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { +fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> FxHashSet { let mut paths = Vec::with_capacity(50); while *pos < events.len() { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b6084bcf34307..bd0e0d277ee54 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -28,8 +28,8 @@ use ThinVec; use tokenstream::{ThinTokenStream, TokenStream}; use serialize::{self, Encoder, Decoder}; -use std::collections::HashSet; use std::fmt; +use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; use std::u32; @@ -407,7 +407,7 @@ pub struct WhereEqPredicate { /// The set of MetaItems that define the compilation environment of the crate, /// used to drive conditional compilation -pub type CrateConfig = HashSet<(Name, Option)>; +pub type CrateConfig = FxHashSet<(Name, Option)>; #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Crate { diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 75d24df7b629f..e8a68b6d7676c 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -26,7 +26,7 @@ use OneVector; use symbol::{keywords, Ident, Symbol}; use ThinVec; -use std::collections::HashMap; +use rustc_data_structures::fx::FxHashMap; use std::iter; use std::path::PathBuf; use std::rc::Rc; @@ -800,7 +800,7 @@ pub struct ExtCtxt<'a> { pub resolver: &'a mut dyn Resolver, pub resolve_err_count: usize, pub current_expansion: ExpansionData, - pub expansions: HashMap>, + pub expansions: FxHashMap>, } impl<'a> ExtCtxt<'a> { @@ -821,7 +821,7 @@ impl<'a> ExtCtxt<'a> { directory_ownership: DirectoryOwnership::Owned { relative: None }, crate_span: None, }, - expansions: HashMap::new(), + expansions: FxHashMap::default(), } } diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index 80bbc618932ef..684cee3887463 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -17,7 +17,7 @@ use parse::parser::PathStyle; use symbol::Symbol; use syntax_pos::Span; -use std::collections::HashSet; +use rustc_data_structures::fx::FxHashSet; pub fn collect_derives(cx: &mut ExtCtxt, attrs: &mut Vec) -> Vec { let mut result = Vec::new(); @@ -48,7 +48,7 @@ pub fn collect_derives(cx: &mut ExtCtxt, attrs: &mut Vec) -> Vec pub fn add_derived_markers(cx: &mut ExtCtxt, span: Span, traits: &[ast::Path], item: T) -> T where T: HasAttrs, { - let (mut names, mut pretty_name) = (HashSet::new(), "derive(".to_owned()); + let (mut names, mut pretty_name) = (FxHashSet::default(), "derive(".to_owned()); for (i, path) in traits.iter().enumerate() { if i > 0 { pretty_name.push_str(", "); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a2e84b508dc12..6e38f820586ff 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -34,7 +34,7 @@ use syntax_pos::hygiene::ExpnFormat; use tokenstream::{TokenStream, TokenTree}; use visit::{self, Visitor}; -use std::collections::HashMap; +use rustc_data_structures::fx::FxHashMap; use std::fs::File; use std::io::Read; use std::iter::FromIterator; @@ -319,7 +319,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // Unresolved macros produce dummy outputs as a recovery measure. invocations.reverse(); let mut expanded_fragments = Vec::new(); - let mut derives: HashMap> = HashMap::new(); + let mut derives: FxHashMap> = FxHashMap::default(); let mut undetermined_invocations = Vec::new(); let (mut progress, mut force) = (false, !self.monotonic); loop { diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 7a8ccfddf8eb6..5906412883ad0 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -21,7 +21,7 @@ use symbol::keywords; use ThinVec; use util::move_map::MoveMap; -use std::collections::HashMap; +use rustc_data_structures::fx::FxHashMap; pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { fn mac_placeholder() -> ast::Mac { @@ -81,7 +81,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { } pub struct PlaceholderExpander<'a, 'b: 'a> { - expanded_fragments: HashMap, + expanded_fragments: FxHashMap, cx: &'a mut ExtCtxt<'b>, monotonic: bool, } @@ -90,7 +90,7 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> { pub fn new(cx: &'a mut ExtCtxt<'b>, monotonic: bool) -> Self { PlaceholderExpander { cx, - expanded_fragments: HashMap::new(), + expanded_fragments: FxHashMap::default(), monotonic, } } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index dcdeee5c2e700..c962e7fcbb4cf 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -96,11 +96,11 @@ use OneVector; use symbol::keywords; use tokenstream::TokenStream; +use rustc_data_structures::fx::FxHashMap; +use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::mem; use std::ops::{Deref, DerefMut}; use std::rc::Rc; -use std::collections::HashMap; -use std::collections::hash_map::Entry::{Occupied, Vacant}; // To avoid costly uniqueness checks, we require that `MatchSeq` always has a nonempty body. @@ -263,7 +263,7 @@ pub enum ParseResult { /// A `ParseResult` where the `Success` variant contains a mapping of `Ident`s to `NamedMatch`es. /// This represents the mapping of metavars to the token trees they bind to. -pub type NamedParseResult = ParseResult>>; +pub type NamedParseResult = ParseResult>>; /// Count how many metavars are named in the given matcher `ms`. pub fn count_names(ms: &[TokenTree]) -> usize { @@ -351,7 +351,7 @@ fn nameize>( sess: &ParseSess, m: &TokenTree, res: &mut I, - ret_val: &mut HashMap>, + ret_val: &mut FxHashMap>, ) -> Result<(), (syntax_pos::Span, String)> { match *m { TokenTree::Sequence(_, ref seq) => for next_m in &seq.tts { @@ -382,7 +382,7 @@ fn nameize>( Ok(()) } - let mut ret_val = HashMap::new(); + let mut ret_val = FxHashMap::default(); for m in ms { match n_rec(sess, m, res.by_ref(), &mut ret_val) { Ok(_) => {} diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 2c738ac2a04cd..d09127d6b08b7 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -27,8 +27,8 @@ use parse::token::Token::*; use symbol::Symbol; use tokenstream::{TokenStream, TokenTree}; +use rustc_data_structures::fx::FxHashMap; use std::borrow::Cow; -use std::collections::HashMap; use std::collections::hash_map::Entry; use rustc_data_structures::sync::Lrc; @@ -451,14 +451,14 @@ struct FirstSets { // If two sequences have the same span in a matcher, then map that // span to None (invalidating the mapping here and forcing the code to // use a slow path). - first: HashMap>, + first: FxHashMap>, } impl FirstSets { fn new(tts: &[quoted::TokenTree]) -> FirstSets { use self::quoted::TokenTree; - let mut sets = FirstSets { first: HashMap::new() }; + let mut sets = FirstSets { first: FxHashMap::default() }; build_recur(&mut sets, tts); return sets; diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 67a15b149f6d5..549e5f00dcec4 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -19,11 +19,11 @@ use OneVector; use syntax_pos::{Span, DUMMY_SP}; use tokenstream::{TokenStream, TokenTree, Delimited}; -use std::rc::Rc; +use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; use std::mem; use std::ops::Add; -use std::collections::HashMap; +use std::rc::Rc; // An iterator over the token trees in a delimited token tree (`{ ... }`) or a sequence (`$(...)`). enum Frame { @@ -67,11 +67,11 @@ impl Iterator for Frame { /// `src` contains no `TokenTree::{Sequence, MetaVar, MetaVarDecl}`s, `interp` can /// (and should) be None. pub fn transcribe(cx: &ExtCtxt, - interp: Option>>, + interp: Option>>, src: Vec) -> TokenStream { let mut stack: OneVector = smallvec![Frame::new(src)]; - let interpolations = interp.unwrap_or_else(HashMap::new); /* just a convenience */ + let interpolations = interp.unwrap_or_else(FxHashMap::default); /* just a convenience */ let mut repeats = Vec::new(); let mut result: Vec = Vec::new(); let mut result_stack = Vec::new(); @@ -187,7 +187,7 @@ pub fn transcribe(cx: &ExtCtxt, } fn lookup_cur_matched(ident: Ident, - interpolations: &HashMap>, + interpolations: &FxHashMap>, repeats: &[(usize, usize)]) -> Option> { interpolations.get(&ident).map(|matched| { @@ -234,7 +234,7 @@ impl Add for LockstepIterSize { } fn lockstep_iter_size(tree: "ed::TokenTree, - interpolations: &HashMap>, + interpolations: &FxHashMap>, repeats: &[(usize, usize)]) -> LockstepIterSize { use self::quoted::TokenTree; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 448ff9676c927..96584a580f175 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1831,10 +1831,10 @@ mod tests { use errors; use feature_gate::UnstableFeatures; use parse::token; - use std::collections::HashSet; use std::io; use std::path::PathBuf; use diagnostics::plugin::ErrorMap; + use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lock; use with_globals; fn mk_sess(cm: Lrc) -> ParseSess { @@ -1845,10 +1845,10 @@ mod tests { ParseSess { span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), unstable_features: UnstableFeatures::from_environment(), - config: CrateConfig::new(), + config: CrateConfig::default(), included_mod_stack: Lock::new(Vec::new()), code_map: cm, - missing_fragment_specifiers: Lock::new(HashSet::new()), + missing_fragment_specifiers: Lock::new(FxHashSet::default()), raw_identifier_spans: Lock::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), non_modrs_mods: Lock::new(vec![]), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 1136cda5ee359..28d63399b4461 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -24,8 +24,8 @@ use symbol::Symbol; use tokenstream::{TokenStream, TokenTree}; use diagnostics::plugin::ErrorMap; +use rustc_data_structures::fx::FxHashSet; use std::borrow::Cow; -use std::collections::HashSet; use std::iter; use std::path::{Path, PathBuf}; use std::str; @@ -46,7 +46,7 @@ pub struct ParseSess { pub span_diagnostic: Handler, pub unstable_features: UnstableFeatures, pub config: CrateConfig, - pub missing_fragment_specifiers: Lock>, + pub missing_fragment_specifiers: Lock>, /// Places where raw identifiers were used. This is used for feature gating /// raw identifiers pub raw_identifier_spans: Lock>, @@ -75,8 +75,8 @@ impl ParseSess { ParseSess { span_diagnostic: handler, unstable_features: UnstableFeatures::from_environment(), - config: HashSet::new(), - missing_fragment_specifiers: Lock::new(HashSet::new()), + config: FxHashSet::default(), + missing_fragment_specifiers: Lock::new(FxHashSet::default()), raw_identifier_spans: Lock::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), included_mod_stack: Lock::new(vec![]), diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index b23c2ec3db101..efe9c2cefdebe 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -24,9 +24,9 @@ use syntax::tokenstream; use syntax_pos::{MultiSpan, Span, DUMMY_SP}; use errors::Applicability; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use std::borrow::Cow; use std::collections::hash_map::Entry; -use std::collections::{HashMap, HashSet}; #[derive(PartialEq)] enum ArgumentType { @@ -65,7 +65,7 @@ struct Context<'a, 'b: 'a> { /// Unique format specs seen for each argument. arg_unique_types: Vec>, /// Map from named arguments to their resolved indices. - names: HashMap, + names: FxHashMap, /// The latest consecutive literal strings, or empty if there weren't any. literal: String, @@ -104,7 +104,7 @@ struct Context<'a, 'b: 'a> { /// * `count_args`: `vec![Exact(0), Exact(5), Exact(3)]` count_args: Vec, /// Relative slot numbers for count arguments. - count_positions: HashMap, + count_positions: FxHashMap, /// Number of count slots assigned. count_positions_count: usize, @@ -134,9 +134,9 @@ struct Context<'a, 'b: 'a> { fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Option<(P, Vec>, HashMap)> { + -> Option<(P, Vec>, FxHashMap)> { let mut args = Vec::>::new(); - let mut names = HashMap::::new(); + let mut names = FxHashMap::::default(); let mut p = ecx.new_parser_from_tts(tts); @@ -768,7 +768,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, efmt: P, args: Vec>, - names: HashMap, + names: FxHashMap, append_newline: bool) -> P { // NOTE: this verbose way of initializing `Vec>` is because @@ -852,7 +852,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, curpiece: 0, arg_index_map: Vec::new(), count_args: Vec::new(), - count_positions: HashMap::new(), + count_positions: FxHashMap::default(), count_positions_count: 0, count_args_index_offset: 0, literal: String::new(), @@ -952,7 +952,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, // The set of foreign substitutions we've explained. This prevents spamming the user // with `%d should be written as {}` over and over again. - let mut explained = HashSet::new(); + let mut explained = FxHashSet::default(); macro_rules! check_foreign { ($kind:ident) => {{ diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 99342f362360b..7e985cf52f550 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -21,8 +21,7 @@ use edition::Edition; use symbol::Symbol; use serialize::{Encodable, Decodable, Encoder, Decoder}; -use std::collections::HashMap; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use std::fmt; /// A SyntaxContext represents a chain of macro expansions (represented by marks). @@ -190,7 +189,7 @@ impl Mark { crate struct HygieneData { marks: Vec, syntax_contexts: Vec, - markings: HashMap<(SyntaxContext, Mark, Transparency), SyntaxContext>, + markings: FxHashMap<(SyntaxContext, Mark, Transparency), SyntaxContext>, default_edition: Edition, } @@ -212,7 +211,7 @@ impl HygieneData { opaque: SyntaxContext(0), opaque_and_semitransparent: SyntaxContext(0), }], - markings: HashMap::new(), + markings: FxHashMap::default(), default_edition: Edition::Edition2015, } } @@ -231,7 +230,7 @@ pub fn set_default_edition(edition: Edition) { } pub fn clear_markings() { - HygieneData::with(|data| data.markings = HashMap::new()); + HygieneData::with(|data| data.markings = FxHashMap::default()); } impl SyntaxContext { From 6628d39f4a07600067324d83932b55b89c586ec3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 28 Aug 2018 20:04:52 +0200 Subject: [PATCH 22/26] move file-extension based .gitignore down to src/ --- .gitignore | 46 ---------------------------------------------- src/.gitignore | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 src/.gitignore diff --git a/.gitignore b/.gitignore index 9ffaa82e1c8b5..e18acfd98e241 100644 --- a/.gitignore +++ b/.gitignore @@ -1,49 +1,3 @@ -*.a -*.aux -*.bc -*.boot -*.bz2 -*.cmi -*.cmo -*.cmx -*.cp -*.cps -*.d -*.dSYM -*.def -*.diff -*.dll -*.dylib -*.elc -*.epub -*.exe -*.fn -*.html -*.kdev4 -*.ky -*.ll -*.llvm -*.log -*.o -*.orig -*.out -*.patch -*.pdb -*.pdf -*.pg -*.pot -*.pyc -*.rej -*.rlib -*.rustc -*.so -*.swo -*.swp -*.tmp -*.toc -*.tp -*.vr -*.x86 *~ .#* .DS_Store diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000000000..f1b36f5858037 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,46 @@ +*.a +*.aux +*.bc +*.boot +*.bz2 +*.cmi +*.cmo +*.cmx +*.cp +*.cps +*.d +*.dSYM +*.def +*.diff +*.dll +*.dylib +*.elc +*.epub +*.exe +*.fn +*.html +*.kdev4 +*.ky +*.ll +*.llvm +*.log +*.o +*.orig +*.out +*.patch +*.pdb +*.pdf +*.pg +*.pot +*.pyc +*.rej +*.rlib +*.rustc +*.so +*.swo +*.swp +*.tmp +*.toc +*.tp +*.vr +*.x86 From da4febd51e96f312f80f1c8cc7c7d65b00c50df6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 18 Aug 2018 23:24:25 +0200 Subject: [PATCH 23/26] Add partialeq implementation for TryFromIntError type --- src/libcore/num/mod.rs | 2 +- .../run-pass/try-from-int-error-partial-eq.rs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/try-from-int-error-partial-eq.rs diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index eb63966354b86..cfcdbc5a76a9d 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -4248,7 +4248,7 @@ from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct TryFromIntError(()); impl TryFromIntError { diff --git a/src/test/run-pass/try-from-int-error-partial-eq.rs b/src/test/run-pass/try-from-int-error-partial-eq.rs new file mode 100644 index 0000000000000..1122f5a75592c --- /dev/null +++ b/src/test/run-pass/try-from-int-error-partial-eq.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(try_from)] +#![allow(unused_must_use)] + +use std::convert::TryFrom; +use std::num::TryFromIntError; + +fn main() { + let x: u32 = 125; + let y: Result = u8::try_from(x); + y == Ok(125); +} From 890d04d00f4a846dfcca0cf90595e8cfee13d42b Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Wed, 29 Aug 2018 15:23:06 +0200 Subject: [PATCH 24/26] Fix a comment in src/libcore/slice/mod.rs --- src/libcore/slice/mod.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 3366c4a3e661c..f8c3feba74ca6 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -21,14 +21,9 @@ // The library infrastructure for slices is fairly messy. There's // a lot of stuff defined here. Let's keep it clean. // -// Since slices don't support inherent methods; all operations -// on them are defined on traits, which are then re-exported from -// the prelude for convenience. So there are a lot of traits here. -// // The layout of this file is thus: // -// * Slice-specific 'extension' traits and their implementations. This -// is where most of the slice API resides. +// * Inherent methods. This is where most of the slice API resides. // * Implementations of a few common traits with important slice ops. // * Definitions of a bunch of iterators. // * Free functions. From e477a13d63c2139f39c192c8e22dcfd0810f68e4 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 08:21:01 -0500 Subject: [PATCH 25/26] Replace usages of 'bad_style' with 'nonstandard_style'. `bad_style` is being deprecated in favor of `nonstandard_style`: - https://github.com/rust-lang/rust/issues/41646 --- src/bootstrap/job.rs | 2 +- src/bootstrap/util.rs | 2 +- src/liballoc_system/lib.rs | 2 +- src/libpanic_unwind/seh.rs | 2 +- src/libpanic_unwind/seh64_gnu.rs | 2 +- src/libpanic_unwind/windows.rs | 2 +- src/librustc/ty/query/plumbing.rs | 4 +-- src/librustc/util/common.rs | 2 +- src/librustc/util/profiling.rs | 2 +- src/librustc_data_structures/flock.rs | 2 +- src/librustc_errors/lock.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/lib.rs | 4 +-- .../{bad_style.rs => nonstandard_style.rs} | 0 src/librustc_platform_intrinsics/lib.rs | 2 +- src/libstd/os/mod.rs | 2 +- src/libstd/sys/redox/mod.rs | 2 +- src/libstd/sys/unix/mod.rs | 2 +- src/libstd/sys/wasm/net.rs | 2 +- src/libstd/sys/windows/c.rs | 2 +- src/libstd/sys/windows/mod.rs | 2 +- src/libstd/sys/windows/os.rs | 2 +- src/libtest/lib.rs | 2 +- src/libunwind/libunwind.rs | 2 +- .../run-pass/simd-target-feature-mixup.rs | 2 +- src/test/rustdoc/intra-links.rs | 2 +- src/test/ui/lint/lint-group-style.rs | 8 ++--- src/test/ui/lint/lint-group-style.stderr | 30 +++++++++---------- src/test/ui/lint/lint-shorthand-field.rs | 2 +- src/test/ui/lint/outer-forbid.rs | 4 +-- src/test/ui/lint/outer-forbid.stderr | 6 ++-- 31 files changed, 52 insertions(+), 52 deletions(-) rename src/librustc_lint/{bad_style.rs => nonstandard_style.rs} (100%) diff --git a/src/bootstrap/job.rs b/src/bootstrap/job.rs index 6445ce8da332e..e6ee525ca2e03 100644 --- a/src/bootstrap/job.rs +++ b/src/bootstrap/job.rs @@ -37,7 +37,7 @@ //! Note that this module has a #[cfg(windows)] above it as none of this logic //! is required on Unix. -#![allow(bad_style, dead_code)] +#![allow(nonstandard_style, dead_code)] use std::env; use std::io; diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index be03796921af8..8ce8f20add3ad 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -137,7 +137,7 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> { // // Copied from std #[cfg(windows)] - #[allow(bad_style)] + #[allow(nonstandard_style)] fn symlink_dir_inner(target: &Path, junction: &Path) -> io::Result<()> { use std::ptr; use std::ffi::OsStr; diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index ffab9e8e4af3c..8848be5903810 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -220,7 +220,7 @@ mod platform { } #[cfg(windows)] -#[allow(bad_style)] +#[allow(nonstandard_style)] mod platform { use MIN_ALIGN; use System; diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs index 015be2dea2157..d6298a38a2601 100644 --- a/src/libpanic_unwind/seh.rs +++ b/src/libpanic_unwind/seh.rs @@ -54,7 +54,7 @@ //! [win64]: http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx //! [llvm]: http://llvm.org/docs/ExceptionHandling.html#background-on-windows-exceptions -#![allow(bad_style)] +#![allow(nonstandard_style)] #![allow(private_no_mangle_fns)] use alloc::boxed::Box; diff --git a/src/libpanic_unwind/seh64_gnu.rs b/src/libpanic_unwind/seh64_gnu.rs index 0b08e54c6739a..c2074db00385b 100644 --- a/src/libpanic_unwind/seh64_gnu.rs +++ b/src/libpanic_unwind/seh64_gnu.rs @@ -11,7 +11,7 @@ //! Unwinding implementation of top of native Win64 SEH, //! however the unwind handler data (aka LSDA) uses GCC-compatible encoding. -#![allow(bad_style)] +#![allow(nonstandard_style)] #![allow(private_no_mangle_fns)] use alloc::boxed::Box; diff --git a/src/libpanic_unwind/windows.rs b/src/libpanic_unwind/windows.rs index 5f1dda36a889e..0a1c9b3adf183 100644 --- a/src/libpanic_unwind/windows.rs +++ b/src/libpanic_unwind/windows.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(bad_style)] +#![allow(nonstandard_style)] #![allow(dead_code)] #![cfg(windows)] diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 8473e4af40e3b..0edb1aa79e745 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 bdfba7c3e3a37..02bdc5f41b354 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 74ff1a5f4fd0d..70760d35f7865 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 { $($name: T),* } diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs index 3f248dadb66c1..f10a9a68bed5b 100644 --- a/src/librustc_data_structures/flock.rs +++ b/src/librustc_data_structures/flock.rs @@ -239,7 +239,7 @@ mod imp { } #[cfg(windows)] -#[allow(bad_style)] +#[allow(nonstandard_style)] mod imp { use std::io; use std::mem; diff --git a/src/librustc_errors/lock.rs b/src/librustc_errors/lock.rs index dff8d53986db5..e5baf93b00064 100644 --- a/src/librustc_errors/lock.rs +++ b/src/librustc_errors/lock.rs @@ -22,7 +22,7 @@ use std::any::Any; #[cfg(windows)] -#[allow(bad_style)] +#[allow(nonstandard_style)] pub fn acquire_global_lock(name: &str) -> Box { use std::ffi::CString; use std::io; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c497627415f1a..acce4bc0650af 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -54,7 +54,7 @@ use syntax::errors::{Applicability, DiagnosticBuilder}; use rustc::hir::{self, GenericParamKind, PatKind}; use rustc::hir::intravisit::FnKind; -use bad_style::{MethodLateContext, method_context}; +use nonstandard_style::{MethodLateContext, method_context}; // hardwired lints from librustc pub use lint::builtin::*; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 05b11e3ba3a4c..0fcf0ca30c136 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -62,12 +62,12 @@ use syntax::edition::Edition; use lint::LintId; use lint::FutureIncompatibleInfo; -mod bad_style; +mod nonstandard_style; pub mod builtin; mod types; mod unused; -use bad_style::*; +use nonstandard_style::*; use builtin::*; use types::*; use unused::*; diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/nonstandard_style.rs similarity index 100% rename from src/librustc_lint/bad_style.rs rename to src/librustc_lint/nonstandard_style.rs diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index 62405150cd29a..f093d672498ad 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(bad_style)] +#![allow(nonstandard_style)] #![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(infer_outlives_requirements))] diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs index c384ec9168ac4..6d8298f01cdce 100644 --- a/src/libstd/os/mod.rs +++ b/src/libstd/os/mod.rs @@ -11,7 +11,7 @@ //! OS-specific functionality. #![stable(feature = "os", since = "1.0.0")] -#![allow(missing_docs, bad_style, missing_debug_implementations)] +#![allow(missing_docs, nonstandard_style, missing_debug_implementations)] cfg_if! { if #[cfg(dox)] { diff --git a/src/libstd/sys/redox/mod.rs b/src/libstd/sys/redox/mod.rs index 4352b72c30773..f943257c68733 100644 --- a/src/libstd/sys/redox/mod.rs +++ b/src/libstd/sys/redox/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code, missing_docs, bad_style)] +#![allow(dead_code, missing_docs, nonstandard_style)] use io::{self, ErrorKind}; diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index c738003caf1d9..2b9fbc9ef3945 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(missing_docs, bad_style)] +#![allow(missing_docs, nonstandard_style)] use io::{self, ErrorKind}; use libc; diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index e7476ab37f7c8..03a5b2d779e1f 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -297,7 +297,7 @@ pub fn lookup_host(_: &str) -> io::Result { unsupported() } -#[allow(bad_style)] +#[allow(nonstandard_style)] pub mod netc { pub const AF_INET: u8 = 0; pub const AF_INET6: u8 = 1; diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index e514a56dcc436..8a744519e9175 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -10,7 +10,7 @@ //! C definitions used by libnative that don't belong in liblibc -#![allow(bad_style)] +#![allow(nonstandard_style)] #![cfg_attr(test, allow(dead_code))] #![unstable(issue = "0", feature = "windows_c")] diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index ccf79de909fa9..31ef9fa2bedfd 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(missing_docs, bad_style)] +#![allow(missing_docs, nonstandard_style)] use ptr; use ffi::{OsStr, OsString}; diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index b94482435597e..29ea82c2053cd 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -10,7 +10,7 @@ //! Implementation of `std::os` functionality for Windows -#![allow(bad_style)] +#![allow(nonstandard_style)] use os::windows::prelude::*; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 29d7cfd2a3a21..d993c6244fc16 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1184,7 +1184,7 @@ fn get_concurrency() -> usize { }; #[cfg(windows)] - #[allow(bad_style)] + #[allow(nonstandard_style)] fn num_cpus() -> usize { #[repr(C)] struct SYSTEM_INFO { diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 73a259bd4438e..43c3e1e766623 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(bad_style)] +#![allow(nonstandard_style)] macro_rules! cfg_if { ( $( if #[cfg( $meta:meta )] { $($it1:item)* } else { $($it2:item)* } )* ) => diff --git a/src/test/run-pass/simd-target-feature-mixup.rs b/src/test/run-pass/simd-target-feature-mixup.rs index 139da04645264..a7fd9f299c033 100644 --- a/src/test/run-pass/simd-target-feature-mixup.rs +++ b/src/test/run-pass/simd-target-feature-mixup.rs @@ -52,7 +52,7 @@ fn is_sigill(status: ExitStatus) -> bool { } #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[allow(bad_style)] +#[allow(nonstandard_style)] mod test { // An SSE type #[repr(simd)] diff --git a/src/test/rustdoc/intra-links.rs b/src/test/rustdoc/intra-links.rs index c822d0f8b21b8..81b81a9a141da 100644 --- a/src/test/rustdoc/intra-links.rs +++ b/src/test/rustdoc/intra-links.rs @@ -75,7 +75,7 @@ pub static THIS_STATIC: usize = 5usize; pub trait SoAmbiguous {} -#[allow(bad_style)] +#[allow(nonstandard_style)] pub fn SoAmbiguous() {} diff --git a/src/test/ui/lint/lint-group-style.rs b/src/test/ui/lint/lint-group-style.rs index 9f33f57f48a28..55d6168e6e008 100644 --- a/src/test/ui/lint/lint-group-style.rs +++ b/src/test/ui/lint/lint-group-style.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(bad_style)] +#![deny(nonstandard_style)] #![allow(dead_code)] fn CamelCase() {} //~ ERROR should have a snake -#[allow(bad_style)] +#[allow(nonstandard_style)] mod test { fn CamelCase() {} - #[forbid(bad_style)] + #[forbid(nonstandard_style)] mod bad { fn CamelCase() {} //~ ERROR should have a snake @@ -25,7 +25,7 @@ mod test { } mod warn { - #![warn(bad_style)] + #![warn(nonstandard_style)] fn CamelCase() {} //~ WARN should have a snake diff --git a/src/test/ui/lint/lint-group-style.stderr b/src/test/ui/lint/lint-group-style.stderr index c1b15160bc501..6b91ce5b93ca6 100644 --- a/src/test/ui/lint/lint-group-style.stderr +++ b/src/test/ui/lint/lint-group-style.stderr @@ -7,9 +7,9 @@ LL | fn CamelCase() {} //~ ERROR should have a snake note: lint level defined here --> $DIR/lint-group-style.rs:11:9 | -LL | #![deny(bad_style)] - | ^^^^^^^^^ - = note: #[deny(non_snake_case)] implied by #[deny(bad_style)] +LL | #![deny(nonstandard_style)] + | ^^^^^^^^^^^^^^^^^ + = note: #[deny(non_snake_case)] implied by #[deny(nonstandard_style)] error: function `CamelCase` should have a snake case name such as `camel_case` --> $DIR/lint-group-style.rs:22:9 @@ -20,9 +20,9 @@ LL | fn CamelCase() {} //~ ERROR should have a snake note: lint level defined here --> $DIR/lint-group-style.rs:20:14 | -LL | #[forbid(bad_style)] - | ^^^^^^^^^ - = note: #[forbid(non_snake_case)] implied by #[forbid(bad_style)] +LL | #[forbid(nonstandard_style)] + | ^^^^^^^^^^^^^^^^^ + = note: #[forbid(non_snake_case)] implied by #[forbid(nonstandard_style)] error: static variable `bad` should have an upper case name such as `BAD` --> $DIR/lint-group-style.rs:24:9 @@ -33,9 +33,9 @@ LL | static bad: isize = 1; //~ ERROR should have an upper note: lint level defined here --> $DIR/lint-group-style.rs:20:14 | -LL | #[forbid(bad_style)] - | ^^^^^^^^^ - = note: #[forbid(non_upper_case_globals)] implied by #[forbid(bad_style)] +LL | #[forbid(nonstandard_style)] + | ^^^^^^^^^^^^^^^^^ + = note: #[forbid(non_upper_case_globals)] implied by #[forbid(nonstandard_style)] warning: function `CamelCase` should have a snake case name such as `camel_case` --> $DIR/lint-group-style.rs:30:9 @@ -46,9 +46,9 @@ LL | fn CamelCase() {} //~ WARN should have a snake note: lint level defined here --> $DIR/lint-group-style.rs:28:17 | -LL | #![warn(bad_style)] - | ^^^^^^^^^ - = note: #[warn(non_snake_case)] implied by #[warn(bad_style)] +LL | #![warn(nonstandard_style)] + | ^^^^^^^^^^^^^^^^^ + = note: #[warn(non_snake_case)] implied by #[warn(nonstandard_style)] warning: type `snake_case` should have a camel case name such as `SnakeCase` --> $DIR/lint-group-style.rs:32:9 @@ -59,9 +59,9 @@ LL | struct snake_case; //~ WARN should have a camel note: lint level defined here --> $DIR/lint-group-style.rs:28:17 | -LL | #![warn(bad_style)] - | ^^^^^^^^^ - = note: #[warn(non_camel_case_types)] implied by #[warn(bad_style)] +LL | #![warn(nonstandard_style)] + | ^^^^^^^^^^^^^^^^^ + = note: #[warn(non_camel_case_types)] implied by #[warn(nonstandard_style)] error: aborting due to 3 previous errors diff --git a/src/test/ui/lint/lint-shorthand-field.rs b/src/test/ui/lint/lint-shorthand-field.rs index 97a976a493f80..1e37ac0dc586c 100644 --- a/src/test/ui/lint/lint-shorthand-field.rs +++ b/src/test/ui/lint/lint-shorthand-field.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(bad_style, unused_variables)] +#![allow(nonstandard_style, unused_variables)] #![deny(non_shorthand_field_patterns)] struct Foo { diff --git a/src/test/ui/lint/outer-forbid.rs b/src/test/ui/lint/outer-forbid.rs index d72f307b46124..23e98cc22fc3a 100644 --- a/src/test/ui/lint/outer-forbid.rs +++ b/src/test/ui/lint/outer-forbid.rs @@ -11,7 +11,7 @@ // Forbidding a group (here, `unused`) overrules subsequent allowance of both // the group, and an individual lint in the group (here, `unused_variables`); // and, forbidding an individual lint (here, `non_snake_case`) overrules -// subsequent allowance of a lint group containing it (here, `bad_style`). See +// subsequent allowance of a lint group containing it (here, `nonstandard_style`). See // Issue #42873. #![forbid(unused, non_snake_case)] @@ -22,7 +22,7 @@ fn foo() {} #[allow(unused)] //~ ERROR overruled fn bar() {} -#[allow(bad_style)] //~ ERROR overruled +#[allow(nonstandard_style)] //~ ERROR overruled fn main() { println!("hello forbidden world") } diff --git a/src/test/ui/lint/outer-forbid.stderr b/src/test/ui/lint/outer-forbid.stderr index e49dcd4a2d19d..c011b49eaee7d 100644 --- a/src/test/ui/lint/outer-forbid.stderr +++ b/src/test/ui/lint/outer-forbid.stderr @@ -16,14 +16,14 @@ LL | #![forbid(unused, non_snake_case)] LL | #[allow(unused)] //~ ERROR overruled | ^^^^^^ overruled by previous forbid -error[E0453]: allow(bad_style) overruled by outer forbid(non_snake_case) +error[E0453]: allow(nonstandard_style) overruled by outer forbid(non_snake_case) --> $DIR/outer-forbid.rs:25:9 | LL | #![forbid(unused, non_snake_case)] | -------------- `forbid` level set here ... -LL | #[allow(bad_style)] //~ ERROR overruled - | ^^^^^^^^^ overruled by previous forbid +LL | #[allow(nonstandard_style)] //~ ERROR overruled + | ^^^^^^^^^^^^^^^^^ overruled by previous forbid error: aborting due to 3 previous errors From e08a84a0c18739417a50c3e46917ced5037244eb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 29 Aug 2018 22:48:37 +0200 Subject: [PATCH 26/26] Fix UI issues on Implementations on Foreign types --- src/librustdoc/html/static/rustdoc.css | 3 +++ src/librustdoc/html/static/themes/dark.css | 4 ++++ src/librustdoc/html/static/themes/light.css | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index ffe6a40b36998..eb0ef1cc5615c 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -509,6 +509,9 @@ h4 > code, h3 > code, .invisible > code { top: -9px; left: -13px; } +.methods > .stability { + margin-top: -8px; +} nav { border-bottom: 1px solid; diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 2ed7f7a926a48..12d2208489368 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -407,3 +407,7 @@ kbd { .search-results td span.grey { color: #ccc; } + +.impl-items code { + background-color: rgba(0, 0, 0, 0); +} diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index f7cb51163ecfc..043d7ae23c2e4 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -401,3 +401,7 @@ kbd { .search-results td span.grey { color: #999; } + +.impl-items code { + background-color: rgba(0, 0, 0, 0); +}