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

+12-1
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

+4
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-2
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

+1-1
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

+1-1
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

+3-4
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,

src/librustc_codegen_ssa/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
437437
// listing.
438438
let main_ret_ty = cx.tcx().erase_regions(&main_ret_ty.no_bound_vars().unwrap());
439439

440-
if cx.get_defined_value("main").is_some() {
440+
if cx.get_declared_value("main").is_some() {
441441
// FIXME: We should be smart and show a better diagnostic here.
442442
cx.sess()
443-
.struct_span_err(sp, "entry symbol `main` defined multiple times")
443+
.struct_span_err(sp, "entry symbol `main` declared multiple times")
444444
.help("did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead")
445445
.emit();
446446
cx.sess().abort_if_errors();

src/librustc_codegen_ssa/mir/operand.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
9292
let a = Scalar::from(Pointer::new(
9393
bx.tcx().alloc_map.lock().create_memory_alloc(data),
9494
Size::from_bytes(start as u64),
95-
))
96-
.into();
95+
));
9796
let a_llval = bx.scalar_to_backend(
9897
a,
9998
a_scalar,

src/librustc_codegen_ssa/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
387387

388388
mir::Rvalue::AddressOf(mutability, ref place) => {
389389
let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {
390-
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability.into() })
390+
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability })
391391
};
392392
self.codegen_place_to_pointer(bx, place, mk_ptr)
393393
}

src/librustc_expand/mbe/quoted.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn parse_tree(
112112
sess.span_diagnostic.span_err(span.entire(), &msg);
113113
}
114114
// Parse the contents of the sequence itself
115-
let sequence = parse(tts.into(), expect_matchers, sess);
115+
let sequence = parse(tts, expect_matchers, sess);
116116
// Get the Kleene operator and optional separator
117117
let (separator, kleene) = parse_sep_and_kleene_op(trees, span.entire(), sess);
118118
// Count the number of captured "names" (i.e., named metavars)
@@ -159,7 +159,7 @@ fn parse_tree(
159159
// descend into the delimited set and further parse it.
160160
tokenstream::TokenTree::Delimited(span, delim, tts) => TokenTree::Delimited(
161161
span,
162-
Lrc::new(Delimited { delim, tts: parse(tts.into(), expect_matchers, sess) }),
162+
Lrc::new(Delimited { delim, tts: parse(tts, expect_matchers, sess) }),
163163
),
164164
}
165165
}

src/librustc_expand/mbe/transcribe.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ pub(super) fn transcribe(
155155
}
156156

157157
// Step back into the parent Delimited.
158-
let tree =
159-
TokenTree::Delimited(span, forest.delim, TokenStream::new(result).into());
158+
let tree = TokenTree::Delimited(span, forest.delim, TokenStream::new(result));
160159
result = result_stack.pop().unwrap();
161160
result.push(tree.into());
162161
}

src/librustc_expand/proc_macro_server.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
6060
let Token { kind, span } = match tree {
6161
tokenstream::TokenTree::Delimited(span, delim, tts) => {
6262
let delimiter = Delimiter::from_internal(delim);
63-
return TokenTree::Group(Group { delimiter, stream: tts.into(), span });
63+
return TokenTree::Group(Group { delimiter, stream: tts, span });
6464
}
6565
tokenstream::TokenTree::Token(token) => token,
6666
};
@@ -196,12 +196,8 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> {
196196
let (ch, joint, span) = match self {
197197
TokenTree::Punct(Punct { ch, joint, span }) => (ch, joint, span),
198198
TokenTree::Group(Group { delimiter, stream, span }) => {
199-
return tokenstream::TokenTree::Delimited(
200-
span,
201-
delimiter.to_internal(),
202-
stream.into(),
203-
)
204-
.into();
199+
return tokenstream::TokenTree::Delimited(span, delimiter.to_internal(), stream)
200+
.into();
205201
}
206202
TokenTree::Ident(self::Ident { sym, is_raw, span }) => {
207203
return tokenstream::TokenTree::token(Ident(sym, is_raw), span).into();

src/librustc_infer/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
669669
} else {
670670
let var = self.canonical_var(info, const_var.into());
671671
self.tcx().mk_const(ty::Const {
672-
val: ty::ConstKind::Bound(self.binder_index, var.into()),
672+
val: ty::ConstKind::Bound(self.binder_index, var),
673673
ty: self.fold_ty(const_var.ty),
674674
})
675675
}

src/librustc_infer/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
745745
.join(", ");
746746
if !lifetimes.is_empty() {
747747
if sub.regions().count() < len {
748-
value.push_normal(lifetimes + &", ");
748+
value.push_normal(lifetimes + ", ");
749749
} else {
750750
value.push_normal(lifetimes);
751751
}

src/librustc_infer/infer/outlives/verify.rs

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
140140
// Extend with bounds that we can find from the trait.
141141
let trait_bounds = self
142142
.projection_declared_bounds_from_trait(projection_ty)
143-
.into_iter()
144143
.map(|r| VerifyBound::OutlivedBy(r));
145144

146145
// see the extensive comment in projection_must_outlive

src/librustc_infer/traits/coherence.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ fn orphan_check_trait_ref<'tcx>(
399399
let local_type = trait_ref
400400
.input_types()
401401
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
402-
.filter(|ty| ty_is_non_local_constructor(ty, in_crate).is_none())
403-
.next();
402+
.find(|ty| ty_is_non_local_constructor(ty, in_crate).is_none());
404403

405404
debug!("orphan_check_trait_ref: uncovered ty local_type: `{:?}`", local_type);
406405

src/librustc_infer/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ pub fn suggest_constraining_type_param(
14421442
const MSG_RESTRICT_TYPE: &str = "consider restricting this type parameter with";
14431443
const MSG_RESTRICT_TYPE_FURTHER: &str = "consider further restricting this type parameter with";
14441444

1445-
let param = generics.params.iter().filter(|p| p.name.ident().as_str() == param_name).next();
1445+
let param = generics.params.iter().find(|p| p.name.ident().as_str() == param_name);
14461446

14471447
let param = if let Some(param) = param {
14481448
param

src/librustc_infer/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3202,7 +3202,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
32023202
obligation.predicate.def_id(),
32033203
obligation.recursion_depth + 1,
32043204
a_last.expect_ty(),
3205-
&[b_last.into()],
3205+
&[b_last],
32063206
));
32073207
}
32083208

src/librustc_interface/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
639639
ast::GenericArg::Type(ty) => Some(ty),
640640
_ => None,
641641
});
642-
any_involves_impl_trait(types.into_iter())
642+
any_involves_impl_trait(types)
643643
|| data.constraints.iter().any(|c| match c.kind {
644644
ast::AssocTyConstraintKind::Bound { .. } => true,
645645
ast::AssocTyConstraintKind::Equality { ref ty } => {

src/librustc_mir/borrow_check/region_infer/reverse_sccs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl RegionInferenceContext<'_> {
5656
let mut scc_regions = FxHashMap::default();
5757
let mut start = 0;
5858
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
59-
let group_size = group.into_iter().count();
59+
let group_size = group.count();
6060
scc_regions.insert(scc, start..start + group_size);
6161
start += group_size;
6262
}

src/librustc_mir/const_eval/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) fn const_caller_location<'tcx>(
5252

5353
let loc_place = ecx.alloc_caller_location(file, line, col);
5454
intern_const_alloc_recursive(&mut ecx, InternKind::Constant, loc_place, false).unwrap();
55-
ConstValue::Scalar(loc_place.ptr.into())
55+
ConstValue::Scalar(loc_place.ptr)
5656
}
5757

5858
// this function uses `unwrap` copiously, because an already validated constant

src/librustc_mir/interpret/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ crate fn eval_nullary_intrinsic<'tcx>(
6767
};
6868
ConstValue::from_machine_usize(n, &tcx)
6969
}
70-
sym::type_id => ConstValue::from_u64(tcx.type_id_hash(tp_ty).into()),
70+
sym::type_id => ConstValue::from_u64(tcx.type_id_hash(tp_ty)),
7171
other => bug!("`{}` is not a zero arg intrinsic", other),
7272
})
7373
}

src/librustc_mir/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
293293
let (&untuple_arg, args) = args.split_last().unwrap();
294294
trace!("eval_fn_call: Will pass last argument by untupling");
295295
Cow::from(args.iter().map(|&a| Ok(a))
296-
.chain((0..untuple_arg.layout.fields.count()).into_iter()
296+
.chain((0..untuple_arg.layout.fields.count())
297297
.map(|i| self.operand_field(untuple_arg, i as u64))
298298
)
299299
.collect::<InterpResult<'_, Vec<OpTy<'tcx, M::PointerTag>>>>()?)

src/librustc_mir/transform/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> ConstQualifs {
209209

210210
// We return the qualifs in the return place for every MIR body, even though it is only used
211211
// when deciding to promote a reference to a `const` for now.
212-
validator.qualifs_in_return_place().into()
212+
validator.qualifs_in_return_place()
213213
}
214214

215215
fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<BodyAndCache<'_>> {

src/librustc_mir/util/aggregate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub fn expand_aggregate<'tcx>(
4949
};
5050

5151
operands
52-
.into_iter()
5352
.enumerate()
5453
.map(move |(i, (op, ty))| {
5554
let lhs_field = if let AggregateKind::Array(_) = kind {

src/librustc_mir_build/build/matches/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1942,8 +1942,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19421942
let tcx = self.hir.tcx();
19431943
let debug_source_info = SourceInfo { span: source_info.span, scope: visibility_scope };
19441944
let binding_mode = match mode {
1945-
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability.into()),
1946-
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability.into()),
1945+
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability),
1946+
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability),
19471947
};
19481948
debug!("declare_binding: user_ty={:?}", user_ty);
19491949
let local = LocalDecl::<'tcx> {

src/librustc_mir_build/build/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
882882
span: tcx_hir.span(var_id),
883883
},
884884
place: Place {
885-
local: closure_env_arg.into(),
885+
local: closure_env_arg,
886886
projection: tcx.intern_place_elems(&projs),
887887
},
888888
});
@@ -927,7 +927,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
927927
self.local_decls[local].local_info = if let Some(kind) = self_binding {
928928
LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(*kind)))
929929
} else {
930-
let binding_mode = ty::BindingMode::BindByValue(mutability.into());
930+
let binding_mode = ty::BindingMode::BindByValue(mutability);
931931
LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
932932
VarBindingForm {
933933
binding_mode,

0 commit comments

Comments
 (0)