Skip to content

Commit 451987d

Browse files
committed
Auto merge of #55579 - pietroalbini:rollup, r=kennytm
Rollup of 13 pull requests Successful merges: - #55280 (Add libproc_macro to rust-src distribution) - #55469 (Regression tests for issue #54477.) - #55504 (Use vec![x; n] instead of iter::repeat(x).take(n).collect()) - #55522 (use String::from() instead of format!() macro to construct Strings.) - #55536 (Pass suggestions as impl Iterator instead of Vec) - #55542 (syntax: improve a few allocations) - #55558 (Tweak `MatcherPos::matches`) - #55561 (Fix double_check tests on big-endian targets) - #55573 (Make sure the `aws` executable is in $PATH on macOS) - #55574 (Use `SmallVec` within `MoveData`.) - #55575 (Fix invalid_const_promotion test on some archs) - #55578 (Made doc example of `impl Default for …` use `-> Self` instead of explicit self type) - #55582 (Remove unused import copy from publish_toolstate.py)
2 parents f6e9a6e + f76a8e3 commit 451987d

File tree

27 files changed

+86
-56
lines changed

27 files changed

+86
-56
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ matrix:
200200
before_install:
201201
# We'll use the AWS cli to download/upload cached docker layers as well as
202202
# push our deployments, so download that here.
203-
- pip install --user awscli; export PATH=$PATH:$HOME/.local/bin
203+
- pip install --user awscli; export PATH=$PATH:$HOME/.local/bin:$HOME/Library/Python/2.7/bin/
204204
- mkdir -p $HOME/rustsrc
205205
# FIXME(#46924): these two commands are required to enable IPv6,
206206
# they shouldn't exist, please revert once more official solutions appeared.

src/bootstrap/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ impl Step for Src {
881881
"src/jemalloc",
882882
"src/libprofiler_builtins",
883883
"src/stdsimd",
884+
"src/libproc_macro",
884885
];
885886
let std_src_dirs_exclude = [
886887
"src/libcompiler_builtins/compiler-rt/test",

src/libcore/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
/// }
7777
///
7878
/// impl Default for Kind {
79-
/// fn default() -> Kind { Kind::A }
79+
/// fn default() -> Self { Kind::A }
8080
/// }
8181
/// ```
8282
///
@@ -118,7 +118,7 @@ pub trait Default: Sized {
118118
/// }
119119
///
120120
/// impl Default for Kind {
121-
/// fn default() -> Kind { Kind::A }
121+
/// fn default() -> Self { Kind::A }
122122
/// }
123123
/// ```
124124
#[stable(feature = "rust1", since = "1.0.0")]

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
12541254
Some(Node::MacroDef(_)) => {
12551255
format!("macro {}{}", path_str(), id_str)
12561256
}
1257-
Some(Node::Crate) => format!("root_crate"),
1257+
Some(Node::Crate) => String::from("root_crate"),
12581258
None => format!("unknown node{}", id_str),
12591259
}
12601260
}

src/librustc/mir/interpret/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,10 @@ impl AllocDecodingState {
295295
}
296296

297297
pub fn new(data_offsets: Vec<u32>) -> AllocDecodingState {
298-
let decoding_state: Vec<_> = ::std::iter::repeat(Mutex::new(State::Empty))
299-
.take(data_offsets.len())
300-
.collect();
298+
let decoding_state = vec![Mutex::new(State::Empty); data_offsets.len()];
301299

302300
AllocDecodingState {
303-
decoding_state: decoding_state,
301+
decoding_state,
304302
data_offsets,
305303
}
306304
}

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use hir::def_id::DefId;
3434
use infer::{self, InferCtxt};
3535
use infer::type_variable::TypeVariableOrigin;
3636
use std::fmt;
37-
use std::iter;
3837
use syntax::ast;
3938
use session::DiagnosticMessageId;
4039
use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable};
@@ -1095,10 +1094,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10951094
// found arguments is empty (assume the user just wants to ignore args in this case).
10961095
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
10971096
if found_args.is_empty() && is_closure {
1098-
let underscores = iter::repeat("_")
1099-
.take(expected_args.len())
1100-
.collect::<Vec<_>>()
1101-
.join(", ");
1097+
let underscores = vec!["_"; expected_args.len()].join(", ");
11021098
err.span_suggestion_with_applicability(
11031099
found_span,
11041100
&format!(

src/librustc_errors/diagnostic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ impl Diagnostic {
350350
}
351351

352352
pub fn span_suggestions_with_applicability(&mut self, sp: Span, msg: &str,
353-
suggestions: Vec<String>,
354-
applicability: Applicability) -> &mut Self {
353+
suggestions: impl Iterator<Item = String>, applicability: Applicability) -> &mut Self
354+
{
355355
self.suggestions.push(CodeSuggestion {
356-
substitutions: suggestions.into_iter().map(|snippet| Substitution {
356+
substitutions: suggestions.map(|snippet| Substitution {
357357
parts: vec![SubstitutionPart {
358358
snippet,
359359
span: sp,

src/librustc_errors/diagnostic_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl<'a> DiagnosticBuilder<'a> {
253253
pub fn span_suggestions_with_applicability(&mut self,
254254
sp: Span,
255255
msg: &str,
256-
suggestions: Vec<String>,
256+
suggestions: impl Iterator<Item = String>,
257257
applicability: Applicability)
258258
-> &mut Self {
259259
if !self.allow_suggestions {

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
788788

789789
let what_was_dropped = match self.describe_place(place) {
790790
Some(name) => format!("`{}`", name.as_str()),
791-
None => format!("temporary value"),
791+
None => String::from("temporary value"),
792792
};
793793

794794
let label = match self.describe_place(&borrow.borrowed_place) {
@@ -1028,7 +1028,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
10281028

10291029
match category {
10301030
ConstraintCategory::Return => {
1031-
err.span_note(constraint_span, &format!("closure is returned here"));
1031+
err.span_note(constraint_span, "closure is returned here");
10321032
}
10331033
ConstraintCategory::CallArgument => {
10341034
fr_name.highlight_region_name(&mut err);

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use rustc::ty::{self, TyCtxt};
1212
use rustc::mir::*;
1313
use rustc::mir::tcx::RvalueInitializationState;
1414
use rustc_data_structures::indexed_vec::{IndexVec};
15+
use smallvec::{SmallVec, smallvec};
1516

1617
use std::collections::hash_map::Entry;
1718
use std::mem;
1819

1920
use super::abs_domain::Lift;
20-
2121
use super::{LocationMap, MoveData, MovePath, MovePathLookup, MovePathIndex, MoveOut, MoveOutIndex};
2222
use super::{MoveError, InitIndex, Init, InitLocation, LookupResult, InitKind};
2323
use super::IllegalMoveOriginKind::*;
@@ -64,8 +64,8 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
6464
}
6565

6666
fn new_move_path(move_paths: &mut IndexVec<MovePathIndex, MovePath<'tcx>>,
67-
path_map: &mut IndexVec<MovePathIndex, Vec<MoveOutIndex>>,
68-
init_path_map: &mut IndexVec<MovePathIndex, Vec<InitIndex>>,
67+
path_map: &mut IndexVec<MovePathIndex, SmallVec<[MoveOutIndex; 4]>>,
68+
init_path_map: &mut IndexVec<MovePathIndex, SmallVec<[InitIndex; 4]>>,
6969
parent: Option<MovePathIndex>,
7070
place: Place<'tcx>)
7171
-> MovePathIndex
@@ -83,10 +83,10 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
8383
move_paths[move_path].next_sibling = next_sibling;
8484
}
8585

86-
let path_map_ent = path_map.push(vec![]);
86+
let path_map_ent = path_map.push(smallvec![]);
8787
assert_eq!(path_map_ent, move_path);
8888

89-
let init_path_map_ent = init_path_map.push(vec![]);
89+
let init_path_map_ent = init_path_map.push(smallvec![]);
9090
assert_eq!(init_path_map_ent, move_path);
9191

9292
move_path

0 commit comments

Comments
 (0)