Skip to content

Commit 7497d93

Browse files
committed
Auto merge of #69534 - Dylan-DPC:rollup-fwa2lip, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #69379 (Fail on multiple declarations of `main`.) - #69430 (librustc_typeck: remove loop that never actually loops) - #69449 (Do not ping PR reviewers in toolstate breakage) - #69491 (rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages) - #69495 (don't take redundant references to operands) - #69496 (use find(x) instead of filter(x).next()) - #69501 (note that find(f) is equivalent to filter(f).next() in the docs.) - #69527 (Ignore untracked paths when running `rustfmt` on repository.) - #69529 (don't use .into() to convert types into identical types.) Failed merges: r? @ghost
2 parents fbc46b7 + 02b96b3 commit 7497d93

File tree

51 files changed

+115
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+115
-94
lines changed

src/bootstrap/format.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Runs rustfmt on the repository.
22
33
use crate::Build;
4-
use build_helper::t;
4+
use build_helper::{output, t};
55
use ignore::WalkBuilder;
66
use std::path::Path;
77
use std::process::Command;
@@ -53,6 +53,17 @@ pub fn format(build: &Build, check: bool) {
5353
for ignore in rustfmt_config.ignore {
5454
ignore_fmt.add(&format!("!{}", ignore)).expect(&ignore);
5555
}
56+
let untracked_paths_output = output(
57+
Command::new("git").arg("status").arg("--porcelain").arg("--untracked-files=normal"),
58+
);
59+
let untracked_paths = untracked_paths_output
60+
.lines()
61+
.filter(|entry| entry.starts_with("??"))
62+
.map(|entry| entry.split(" ").nth(1).expect("every git status entry should list a path"));
63+
for untracked_path in untracked_paths {
64+
eprintln!("skip untracked path {} during rustfmt invocations", untracked_path);
65+
ignore_fmt.add(&format!("!{}", untracked_path)).expect(&untracked_path);
66+
}
5667
let ignore_fmt = ignore_fmt.build().unwrap();
5768

5869
let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {

src/libcore/iter/traits/iterator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ pub trait Iterator {
719719
/// ```
720720
///
721721
/// of these layers.
722+
///
723+
/// Note that `iter.filter(f).next()` is equivalent to `iter.find(f)`.
722724
#[inline]
723725
#[stable(feature = "rust1", since = "1.0.0")]
724726
fn filter<P>(self, predicate: P) -> Filter<Self, P>
@@ -2152,6 +2154,8 @@ pub trait Iterator {
21522154
/// // we can still use `iter`, as there are more elements.
21532155
/// assert_eq!(iter.next(), Some(&3));
21542156
/// ```
2157+
///
2158+
/// Note that `iter.find(f)` is equivalent to `iter.filter(f).next()`.
21552159
#[inline]
21562160
#[stable(feature = "rust1", since = "1.0.0")]
21572161
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>

src/libcore/str/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ impl TwoWaySearcher {
10501050
// &v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
10511051
// "Algorithm CP2", which is optimized for when the period of the needle
10521052
// is large.
1053-
if &needle[..crit_pos] == &needle[period..period + crit_pos] {
1053+
if needle[..crit_pos] == needle[period..period + crit_pos] {
10541054
// short period case -- the period is exact
10551055
// compute a separate critical factorization for the reversed needle
10561056
// x = u' v' where |v'| < period(x).

src/librustc/mir/interpret/allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
472472
val: ScalarMaybeUndef<Tag>,
473473
) -> InterpResult<'tcx> {
474474
let ptr_size = cx.data_layout().pointer_size;
475-
self.write_scalar(cx, ptr.into(), val, ptr_size)
475+
self.write_scalar(cx, ptr, val, ptr_size)
476476
}
477477
}
478478

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ impl<'tcx> TerminatorKind<'tcx> {
15191519
values
15201520
.iter()
15211521
.map(|&u| {
1522-
ty::Const::from_scalar(tcx, Scalar::from_uint(u, size).into(), switch_ty)
1522+
ty::Const::from_scalar(tcx, Scalar::from_uint(u, size), switch_ty)
15231523
.to_string()
15241524
.into()
15251525
})

src/librustc/mir/tcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'tcx> Rvalue<'tcx> {
156156
}
157157
Rvalue::AddressOf(mutability, ref place) => {
158158
let place_ty = place.ty(local_decls, tcx).ty;
159-
tcx.mk_ptr(ty::TypeAndMut { ty: place_ty, mutbl: mutability.into() })
159+
tcx.mk_ptr(ty::TypeAndMut { ty: place_ty, mutbl: mutability })
160160
}
161161
Rvalue::Len(..) => tcx.types.usize,
162162
Rvalue::Cast(.., ty) => ty,

src/librustc/traits/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,7 @@ impl ObjectSafetyViolation {
820820
MethodViolationCode::UndispatchableReceiver,
821821
span,
822822
) => (
823-
format!("consider changing method `{}`'s `self` parameter to be `&self`", name)
824-
.into(),
823+
format!("consider changing method `{}`'s `self` parameter to be `&self`", name),
825824
Some(("&Self".to_string(), span)),
826825
),
827826
ObjectSafetyViolation::AssocConst(name, _)

src/librustc/ty/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<'tcx> TyCtxt<'tcx> {
341341
db.note("distinct uses of `impl Trait` result in different opaque types");
342342
let e_str = values.expected.to_string();
343343
let f_str = values.found.to_string();
344-
if &e_str == &f_str && &e_str == "impl std::future::Future" {
344+
if e_str == f_str && &e_str == "impl std::future::Future" {
345345
// FIXME: use non-string based check.
346346
db.help(
347347
"if both `Future`s have the same `Output` type, consider \

src/librustc/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl RegionHighlightMode {
136136
pub fn highlighting_region(&mut self, region: ty::Region<'_>, number: usize) {
137137
let num_slots = self.highlight_regions.len();
138138
let first_avail_slot =
139-
self.highlight_regions.iter_mut().filter(|s| s.is_none()).next().unwrap_or_else(|| {
139+
self.highlight_regions.iter_mut().find(|s| s.is_none()).unwrap_or_else(|| {
140140
bug!("can only highlight {} placeholders at a time", num_slots,)
141141
});
142142
*first_avail_slot = Some((*region, number));

src/librustc_ast_lowering/expr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
831831
.last()
832832
.cloned()
833833
.map(|id| Ok(self.lower_node_id(id)))
834-
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope))
835-
.into(),
834+
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope)),
836835
};
837836
hir::Destination { label: destination.map(|(_, label)| label), target_id }
838837
}
@@ -841,7 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
841840
if self.is_in_loop_condition && opt_label.is_none() {
842841
hir::Destination {
843842
label: None,
844-
target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition).into(),
843+
target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition),
845844
}
846845
} else {
847846
self.lower_loop_destination(opt_label.map(|label| (id, label)))
@@ -912,7 +911,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
912911
.collect(),
913912
asm: asm.asm,
914913
asm_str_style: asm.asm_str_style,
915-
clobbers: asm.clobbers.clone().into(),
914+
clobbers: asm.clobbers.clone(),
916915
volatile: asm.volatile,
917916
alignstack: asm.alignstack,
918917
dialect: asm.dialect,

0 commit comments

Comments
 (0)