From ea3e9a38241ea5f9fa1b00021edb1c5184e221bd Mon Sep 17 00:00:00 2001 From: vlad20012 Date: Tue, 23 Oct 2018 07:51:22 +0300 Subject: [PATCH 01/14] Add libproc_macro to rust-src distribution --- src/bootstrap/dist.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 7341137e20d72..1164acd489304 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -853,6 +853,7 @@ impl Step for Src { "src/jemalloc", "src/libprofiler_builtins", "src/stdsimd", + "src/libproc_macro", ]; let std_src_dirs_exclude = [ "src/libcompiler_builtins/compiler-rt/test", From 465cd66286a158dec0d33fa210655214fa826e92 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 29 Oct 2018 11:45:00 +0100 Subject: [PATCH 02/14] Regression test for issue #54477. I removed the original file that more completely captured the original crate's tests, as its source crate (https://crates.io/crates/collection) is licensed under GPL3, and I suspect that license is not loose enough for me to put into our repo under our MIT/Apache licensing. (Would it be an option to attach the GPL3 licesne to just the one test? Probably. But do I want to bother with it that that point? Nope!) --- .../run-pass/issues/issue-54477-reduced-2.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/run-pass/issues/issue-54477-reduced-2.rs diff --git a/src/test/run-pass/issues/issue-54477-reduced-2.rs b/src/test/run-pass/issues/issue-54477-reduced-2.rs new file mode 100644 index 0000000000000..28731d4b0df02 --- /dev/null +++ b/src/test/run-pass/issues/issue-54477-reduced-2.rs @@ -0,0 +1,25 @@ +// rust-lang/rust#54477: runtime bug in the VecDeque library that was +// exposed by this test case, derived from test suite of crates.io +// `collection` crate. + +use std::collections::VecDeque; + +fn main() { + let mut vecdeque_13 = VecDeque::from(vec![ ]); + let mut vecdeque_29 = VecDeque::from(vec![ 0 ]); + vecdeque_29.insert(0, 30 ); + vecdeque_29.insert(1, 31 ); + vecdeque_29.insert(2, 32 ); + vecdeque_29.insert(3, 33 ); + vecdeque_29.insert(4, 34 ); + vecdeque_29.insert(5, 35 ); + // println!("vecdeque_13: {:?}", vecdeque_13); + // println!("vecdeque_29: {:?}", vecdeque_29); + + // println!("Invoking: `vecdeque_13.append(&mut vecdeque_29)`"); + vecdeque_13.append(&mut vecdeque_29); + + // println!("vecdeque_13: {:?}", vecdeque_13); + + assert_eq!(vecdeque_13, VecDeque::from(vec![30, 31, 32, 33, 34, 35, 0])); +} From d1e74a3356b8e311aab171bf316560b2f3d7f5c8 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 30 Oct 2018 14:37:26 +0100 Subject: [PATCH 03/14] Use vec![x; n] instead of iter::repeat(x).take(n).collect() --- src/librustc/mir/interpret/mod.rs | 6 ++---- src/librustc/traits/error_reporting.rs | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 62cc3113a3d37..61b5886e7832d 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -295,12 +295,10 @@ impl AllocDecodingState { } pub fn new(data_offsets: Vec) -> AllocDecodingState { - let decoding_state: Vec<_> = ::std::iter::repeat(Mutex::new(State::Empty)) - .take(data_offsets.len()) - .collect(); + let decoding_state = vec![Mutex::new(State::Empty); data_offsets.len()]; AllocDecodingState { - decoding_state: decoding_state, + decoding_state, data_offsets, } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 15a0adc3c0692..b463faef1921a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -34,7 +34,6 @@ use hir::def_id::DefId; use infer::{self, InferCtxt}; use infer::type_variable::TypeVariableOrigin; use std::fmt; -use std::iter; use syntax::ast; use session::DiagnosticMessageId; use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; @@ -1095,10 +1094,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // found arguments is empty (assume the user just wants to ignore args in this case). // For example, if `expected_args_length` is 2, suggest `|_, _|`. if found_args.is_empty() && is_closure { - let underscores = iter::repeat("_") - .take(expected_args.len()) - .collect::>() - .join(", "); + let underscores = vec!["_"; expected_args.len()].join(", "); err.span_suggestion_with_applicability( found_span, &format!( From f6b8876d45841a2b3b082376d3a5d265851208d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 31 Oct 2018 00:10:10 +0100 Subject: [PATCH 04/14] use String::from() instead of format!() macro to construct Strings. --- src/librustc/hir/map/mod.rs | 2 +- src/librustc_mir/borrow_check/error_reporting.rs | 4 ++-- src/librustc_mir/interpret/validity.rs | 2 +- src/librustc_mir/util/borrowck_errors.rs | 2 +- src/libsyntax/ext/expand.rs | 2 +- src/tools/compiletest/src/main.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 7a20146130d94..f5f8e3512a0ea 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -1254,7 +1254,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { Some(Node::MacroDef(_)) => { format!("macro {}{}", path_str(), id_str) } - Some(Node::Crate) => format!("root_crate"), + Some(Node::Crate) => String::from("root_crate"), None => format!("unknown node{}", id_str), } } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index b2b92a6f85784..3c4d8e09fc166 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -788,7 +788,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let what_was_dropped = match self.describe_place(place) { Some(name) => format!("`{}`", name.as_str()), - None => format!("temporary value"), + None => String::from("temporary value"), }; let label = match self.describe_place(&borrow.borrowed_place) { @@ -1028,7 +1028,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { match category { ConstraintCategory::Return => { - err.span_note(constraint_span, &format!("closure is returned here")); + err.span_note(constraint_span, "closure is returned here"); } ConstraintCategory::CallArgument => { fr_name.highlight_region_name(&mut err); diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 9d86e737dd5b6..15d0a9166a678 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -408,7 +408,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> ), _ => return validation_failure!( - format!("non-integer enum discriminant"), path + String::from("non-integer enum discriminant"), path ), } }; diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 1715086686c42..ae0483e3c140c 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -575,7 +575,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { OGN = o ); err.span_label(mutate_span, format!("cannot {}", action)); - err.span_label(match_span, format!("value is immutable in match guard")); + err.span_label(match_span, String::from("value is immutable in match guard")); self.cancel_if_wrong_origin(err, o) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 33b651e1b3854..ce326b728df45 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -687,7 +687,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { "proc_macro_hygiene", self.span, GateIssue::Language, - &format!("procedural macros cannot expand to macro definitions"), + "procedural macros cannot expand to macro definitions", ); } visit::walk_item(self, i); diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index ca30a4dd95d0e..f63950b448a14 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -766,7 +766,7 @@ fn make_test_name( .join(&testpaths.file.file_name().unwrap()); let mode_suffix = match config.compare_mode { Some(ref mode) => format!(" ({})", mode.to_str()), - None => format!(""), + None => String::new(), }; test::DynTestName(format!( "[{}{}] {}{}", From 9ff0f3374882275b8c6b321f94b14440454f8340 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 15 Oct 2018 13:16:05 +0200 Subject: [PATCH 05/14] Pass suggestions as impl Iterator instead of Vec --- src/librustc_errors/diagnostic.rs | 6 +++--- src/librustc_errors/diagnostic_builder.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_typeck/check/demand.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 870eeadc081e7..a323282f23353 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -350,10 +350,10 @@ impl Diagnostic { } pub fn span_suggestions_with_applicability(&mut self, sp: Span, msg: &str, - suggestions: Vec, - applicability: Applicability) -> &mut Self { + suggestions: impl Iterator, applicability: Applicability) -> &mut Self + { self.suggestions.push(CodeSuggestion { - substitutions: suggestions.into_iter().map(|snippet| Substitution { + substitutions: suggestions.map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp, diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index f4289ea2d4b26..2f16470530e43 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -253,7 +253,7 @@ impl<'a> DiagnosticBuilder<'a> { pub fn span_suggestions_with_applicability(&mut self, sp: Span, msg: &str, - suggestions: Vec, + suggestions: impl Iterator, applicability: Applicability) -> &mut Self { if !self.allow_suggestions { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ebd87e87ff60a..5b10d43417799 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4944,7 +4944,7 @@ fn show_candidates(err: &mut DiagnosticBuilder, err.span_suggestions_with_applicability( span, &msg, - path_strings, + path_strings.into_iter(), Applicability::Unspecified, ); } else { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 7773e2d570844..0a196834cb494 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -132,7 +132,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if compatible_variants.peek().is_some() { let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr)); let suggestions = compatible_variants - .map(|v| format!("{}({})", v, expr_text)).collect::>(); + .map(|v| format!("{}({})", v, expr_text)); err.span_suggestions_with_applicability( expr.span, "try using a variant of the expected type", diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 5a63a2971e49d..cd243d4144394 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -521,7 +521,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { with_crate_prefix(|| self.tcx.item_path_str(*did)), additional_newline ) - }).collect(); + }); err.span_suggestions_with_applicability( span, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4851938653b53..17784a4681d00 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4744,7 +4744,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else if !self.check_for_cast(err, expr, found, expected) { let methods = self.get_conversion_methods(expr.span, expected, found); if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) { - let suggestions = iter::repeat(&expr_text).zip(methods.iter()) + let mut suggestions = iter::repeat(&expr_text).zip(methods.iter()) .filter_map(|(receiver, method)| { let method_call = format!(".{}()", method.ident); if receiver.ends_with(&method_call) { @@ -4760,8 +4760,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Some(format!("{}{}", receiver, method_call)) } } - }).collect::>(); - if !suggestions.is_empty() { + }).peekable(); + if suggestions.peek().is_some() { err.span_suggestions_with_applicability( expr.span, "try using a conversion method", From f4c03fd8473c2b5a254789abcb712c90b558f92d Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 31 Oct 2018 16:58:51 +0100 Subject: [PATCH 06/14] syntax: improve a few allocations --- src/libsyntax/ext/expand.rs | 2 ++ src/libsyntax_ext/deriving/generic/mod.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 33b651e1b3854..37e7b44694f48 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -387,6 +387,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { add_derived_markers(&mut self.cx, item.span(), &traits, item.clone()); let derives = derives.entry(invoc.expansion_data.mark).or_default(); + derives.reserve(traits.len()); + invocations.reserve(traits.len()); for path in &traits { let mark = Mark::fresh(self.cx.current_expansion.mark); derives.push(mark); diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 002ecce58e652..dd90ef06c3929 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -1384,7 +1384,7 @@ impl<'a> MethodDef<'a> { // let __self2_vi = unsafe { // std::intrinsics::discriminant_value(&arg2) } as i32; // ``` - let mut index_let_stmts: Vec = Vec::new(); + let mut index_let_stmts: Vec = Vec::with_capacity(vi_idents.len() + 1); // We also build an expression which checks whether all discriminants are equal // discriminant_test = __self0_vi == __self1_vi && __self0_vi == __self2_vi && ... From c60ed5d22c4c2a4885fdfdfa8c6b008d79b0fc29 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 1 Nov 2018 05:35:20 +1100 Subject: [PATCH 07/14] Share empty `Vec`s more within `MatcherPos::matches`. `create_matches` creates a `Vec>>`. Even though all the inner `Vec`s are empty, each one is created separately. This commit changes `create_matches` so it instead creates one empty inner `Vec`, and shares it. The commit also changes `MatcherPos::matches` to a boxed slice, because its length doesn't change. --- src/libsyntax/ext/tt/macro_parser.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 03a8376e76361..bf91a233f7c69 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -168,7 +168,7 @@ struct MatcherPos<'a> { /// all bound matches from the submatcher into the shared top-level `matches` vector. If `sep` /// and `up` are `Some`, then `matches` is _not_ the shared top-level list. Instead, if one /// wants the shared `matches`, one should use `up.matches`. - matches: Vec>>, + matches: Box<[Rc>]>, /// The position in `matches` corresponding to the first metavar in this matcher's sequence of /// token trees. In other words, the first metavar in the first token of `top_elts` corresponds /// to `matches[match_lo]`. @@ -278,9 +278,14 @@ pub fn count_names(ms: &[TokenTree]) -> usize { }) } -/// Initialize `len` empty shared `Vec`s to be used to store matches of metavars. -fn create_matches(len: usize) -> Vec>> { - (0..len).into_iter().map(|_| Rc::new(Vec::new())).collect() +/// `len` `Vec`s (initially shared and empty) that will store matches of metavars. +fn create_matches(len: usize) -> Box<[Rc>]> { + if len == 0 { + vec![] + } else { + let empty_matches = Rc::new(Vec::new()); + vec![empty_matches.clone(); len] + }.into_boxed_slice() } /// Generate the top-level matcher position in which the "dot" is before the first token of the From 0d2abe46ca810dfab7db9e89977b751eca103084 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 1 Nov 2018 08:41:57 +1100 Subject: [PATCH 08/14] Use `SmallVec` for the inner vectors in `MatcherPos::matches`. This avoids some allocations. --- src/libsyntax/ext/tt/macro_parser.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index bf91a233f7c69..38bbfc6b4c375 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -143,6 +143,8 @@ struct MatcherTtFrame<'a> { idx: usize, } +type NamedMatchVec = SmallVec<[NamedMatch; 4]>; + /// Represents a single "position" (aka "matcher position", aka "item"), as described in the module /// documentation. #[derive(Clone)] @@ -168,7 +170,7 @@ struct MatcherPos<'a> { /// all bound matches from the submatcher into the shared top-level `matches` vector. If `sep` /// and `up` are `Some`, then `matches` is _not_ the shared top-level list. Instead, if one /// wants the shared `matches`, one should use `up.matches`. - matches: Box<[Rc>]>, + matches: Box<[Rc]>, /// The position in `matches` corresponding to the first metavar in this matcher's sequence of /// token trees. In other words, the first metavar in the first token of `top_elts` corresponds /// to `matches[match_lo]`. @@ -279,11 +281,11 @@ pub fn count_names(ms: &[TokenTree]) -> usize { } /// `len` `Vec`s (initially shared and empty) that will store matches of metavars. -fn create_matches(len: usize) -> Box<[Rc>]> { +fn create_matches(len: usize) -> Box<[Rc]> { if len == 0 { vec![] } else { - let empty_matches = Rc::new(Vec::new()); + let empty_matches = Rc::new(SmallVec::new()); vec![empty_matches.clone(); len] }.into_boxed_slice() } @@ -337,7 +339,7 @@ fn initial_matcher_pos(ms: &[TokenTree], open: Span) -> MatcherPos { /// token tree it was derived from. #[derive(Debug, Clone)] pub enum NamedMatch { - MatchedSeq(Rc>, DelimSpan), + MatchedSeq(Rc, DelimSpan), MatchedNonterminal(Rc), } @@ -545,7 +547,7 @@ fn inner_parse_loop<'a>( new_item.match_cur += seq.num_captures; new_item.idx += 1; for idx in item.match_cur..item.match_cur + seq.num_captures { - new_item.push_match(idx, MatchedSeq(Rc::new(vec![]), sp)); + new_item.push_match(idx, MatchedSeq(Rc::new(smallvec![]), sp)); } cur_items.push(new_item); } From 01e0d23d66d44f7a46b27a91b90b0d1c8aedc25f Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 31 Oct 2018 22:59:53 +0000 Subject: [PATCH 09/14] Fix invalid_const_promotion test on some archs On at least AArch64 `llvm.trap` raises SIGTRAP. --- src/test/run-pass/invalid_const_promotion.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/run-pass/invalid_const_promotion.rs b/src/test/run-pass/invalid_const_promotion.rs index ed8c4992417af..0f354e1aad6c9 100644 --- a/src/test/run-pass/invalid_const_promotion.rs +++ b/src/test/run-pass/invalid_const_promotion.rs @@ -39,6 +39,7 @@ fn check_status(status: std::process::ExitStatus) use std::os::unix::process::ExitStatusExt; assert!(status.signal() == Some(libc::SIGILL) + || status.signal() == Some(libc::SIGTRAP) || status.signal() == Some(libc::SIGABRT)); } From 283f2be1421eca11b1a3abbaac40ca946e806037 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 16 Sep 2018 18:27:56 +0000 Subject: [PATCH 10/14] Fix double_check tests on big-endian targets Since the enums get optimized down to 1 byte long, the bits set in the usize member don't align with the enums on big-endian machines. Avoid this issue by shrinking the integer member to the same size as the enums. --- src/test/ui/consts/const-eval/double_check.rs | 8 ++++---- src/test/ui/consts/const-eval/double_check2.rs | 8 ++++---- src/test/ui/consts/const-eval/double_check2.stderr | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/ui/consts/const-eval/double_check.rs b/src/test/ui/consts/const-eval/double_check.rs index 81f6e7ddd2de2..76f9276c05807 100644 --- a/src/test/ui/consts/const-eval/double_check.rs +++ b/src/test/ui/consts/const-eval/double_check.rs @@ -21,12 +21,12 @@ enum Bar { union Union { foo: &'static Foo, bar: &'static Bar, - usize: &'static usize, + u8: &'static u8, } -static BAR: usize = 42; +static BAR: u8 = 42; static FOO: (&Foo, &Bar) = unsafe {( - Union { usize: &BAR }.foo, - Union { usize: &BAR }.bar, + Union { u8: &BAR }.foo, + Union { u8: &BAR }.bar, )}; fn main() {} diff --git a/src/test/ui/consts/const-eval/double_check2.rs b/src/test/ui/consts/const-eval/double_check2.rs index b661ee92475e6..701632362ce7a 100644 --- a/src/test/ui/consts/const-eval/double_check2.rs +++ b/src/test/ui/consts/const-eval/double_check2.rs @@ -19,12 +19,12 @@ enum Bar { union Union { foo: &'static Foo, bar: &'static Bar, - usize: &'static usize, + u8: &'static u8, } -static BAR: usize = 5; +static BAR: u8 = 5; static FOO: (&Foo, &Bar) = unsafe {( //~ undefined behavior - Union { usize: &BAR }.foo, - Union { usize: &BAR }.bar, + Union { u8: &BAR }.foo, + Union { u8: &BAR }.bar, )}; fn main() {} diff --git a/src/test/ui/consts/const-eval/double_check2.stderr b/src/test/ui/consts/const-eval/double_check2.stderr index 9dd7570232d37..28825477c8102 100644 --- a/src/test/ui/consts/const-eval/double_check2.stderr +++ b/src/test/ui/consts/const-eval/double_check2.stderr @@ -2,8 +2,8 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/double_check2.rs:25:1 | LL | / static FOO: (&Foo, &Bar) = unsafe {( //~ undefined behavior -LL | | Union { usize: &BAR }.foo, -LL | | Union { usize: &BAR }.bar, +LL | | Union { u8: &BAR }.foo, +LL | | Union { u8: &BAR }.bar, LL | | )}; | |___^ type validation failed: encountered invalid enum discriminant 5 at .1. | From a85467748f1f6b88d18d5b1f1a0611d8e27b8627 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 1 Nov 2018 15:30:30 +0800 Subject: [PATCH 11/14] Make sure the installed `awscli` is found on macOS. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 990cac4dbe98b..3d8918095accb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -200,7 +200,7 @@ matrix: before_install: # We'll use the AWS cli to download/upload cached docker layers as well as # push our deployments, so download that here. - - pip install --user awscli; export PATH=$PATH:$HOME/.local/bin + - pip install --user awscli; export PATH=$PATH:$HOME/.local/bin:$HOME/Library/Python/2.7/bin/ - mkdir -p $HOME/rustsrc # FIXME(#46924): these two commands are required to enable IPv6, # they shouldn't exist, please revert once more official solutions appeared. From 0e5d7d2322db2a5db82161dc1d57158acad7b2d9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 1 Nov 2018 15:34:36 +1100 Subject: [PATCH 12/14] Use `SmallVec` within `MoveData`. This reduces allocation counts significantly in a few benchmarks, reducing instruction counts by up to 2%. --- src/librustc_mir/dataflow/move_paths/builder.rs | 10 +++++----- src/librustc_mir/dataflow/move_paths/mod.rs | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 08696dc098e00..b46489a162b85 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -12,12 +12,12 @@ use rustc::ty::{self, TyCtxt}; use rustc::mir::*; use rustc::mir::tcx::RvalueInitializationState; use rustc_data_structures::indexed_vec::{IndexVec}; +use smallvec::{SmallVec, smallvec}; use std::collections::hash_map::Entry; use std::mem; use super::abs_domain::Lift; - use super::{LocationMap, MoveData, MovePath, MovePathLookup, MovePathIndex, MoveOut, MoveOutIndex}; use super::{MoveError, InitIndex, Init, InitLocation, LookupResult, InitKind}; use super::IllegalMoveOriginKind::*; @@ -64,8 +64,8 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { } fn new_move_path(move_paths: &mut IndexVec>, - path_map: &mut IndexVec>, - init_path_map: &mut IndexVec>, + path_map: &mut IndexVec>, + init_path_map: &mut IndexVec>, parent: Option, place: Place<'tcx>) -> MovePathIndex @@ -83,10 +83,10 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { move_paths[move_path].next_sibling = next_sibling; } - let path_map_ent = path_map.push(vec![]); + let path_map_ent = path_map.push(smallvec![]); assert_eq!(path_map_ent, move_path); - let init_path_map_ent = init_path_map.push(vec![]); + let init_path_map_ent = init_path_map.push(smallvec![]); assert_eq!(init_path_map_ent, move_path); move_path diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index 58a2b9361032e..2a026b8f52c2a 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -13,6 +13,7 @@ use rustc::ty::{self, TyCtxt}; use rustc::mir::*; use rustc::util::nodemap::FxHashMap; use rustc_data_structures::indexed_vec::{IndexVec}; +use smallvec::SmallVec; use syntax_pos::{Span}; use std::fmt; @@ -141,14 +142,14 @@ pub struct MoveData<'tcx> { /// of executing the code at `l`. (There can be multiple MoveOut's /// for a given `l` because each MoveOut is associated with one /// particular path being moved.) - pub loc_map: LocationMap>, - pub path_map: IndexVec>, + pub loc_map: LocationMap>, + pub path_map: IndexVec>, pub rev_lookup: MovePathLookup<'tcx>, pub inits: IndexVec, /// Each Location `l` is mapped to the Inits that are effects /// of executing the code at `l`. - pub init_loc_map: LocationMap>, - pub init_path_map: IndexVec>, + pub init_loc_map: LocationMap>, + pub init_path_map: IndexVec>, } pub trait HasMoveData<'tcx> { From 0d38b0ec9a47cf571ab2af1ca6456593e174e678 Mon Sep 17 00:00:00 2001 From: Vincent Esche Date: Thu, 1 Nov 2018 11:52:44 +0100 Subject: [PATCH 13/14] =?UTF-8?q?Made=20doc=20example=20of=20`impl=20Defau?= =?UTF-8?q?lt=20for=20=E2=80=A6`=20use=20`->=20Self`=20instead=20of=20expl?= =?UTF-8?q?icit=20self=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libcore/default.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/default.rs b/src/libcore/default.rs index ab36e29b1e1d4..638acebd617bf 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -76,7 +76,7 @@ /// } /// /// impl Default for Kind { -/// fn default() -> Kind { Kind::A } +/// fn default() -> Self { Kind::A } /// } /// ``` /// @@ -118,7 +118,7 @@ pub trait Default: Sized { /// } /// /// impl Default for Kind { - /// fn default() -> Kind { Kind::A } + /// fn default() -> Self { Kind::A } /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] From 7fd98df96340c989fbb53ad0644c915dd6f3b41e Mon Sep 17 00:00:00 2001 From: Yuka Takahashi Date: Thu, 1 Nov 2018 14:52:00 +0100 Subject: [PATCH 14/14] Remove unused import copy from publish_toolstate.py --- src/tools/publish_toolstate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py index 1539c2e25781b..c794e169fca33 100755 --- a/src/tools/publish_toolstate.py +++ b/src/tools/publish_toolstate.py @@ -14,7 +14,6 @@ import sys import re import json -import copy import datetime import collections import textwrap