Skip to content

Commit

Permalink
Auto merge of #69534 - Dylan-DPC:rollup-fwa2lip, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Feb 28, 2020
2 parents fbc46b7 + 02b96b3 commit 7497d93
Show file tree
Hide file tree
Showing 51 changed files with 115 additions and 94 deletions.
13 changes: 12 additions & 1 deletion src/bootstrap/format.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Runs rustfmt on the repository.

use crate::Build;
use build_helper::t;
use build_helper::{output, t};
use ignore::WalkBuilder;
use std::path::Path;
use std::process::Command;
Expand Down Expand Up @@ -53,6 +53,17 @@ pub fn format(build: &Build, check: bool) {
for ignore in rustfmt_config.ignore {
ignore_fmt.add(&format!("!{}", ignore)).expect(&ignore);
}
let untracked_paths_output = output(
Command::new("git").arg("status").arg("--porcelain").arg("--untracked-files=normal"),
);
let untracked_paths = untracked_paths_output
.lines()
.filter(|entry| entry.starts_with("??"))
.map(|entry| entry.split(" ").nth(1).expect("every git status entry should list a path"));
for untracked_path in untracked_paths {
eprintln!("skip untracked path {} during rustfmt invocations", untracked_path);
ignore_fmt.add(&format!("!{}", untracked_path)).expect(&untracked_path);
}
let ignore_fmt = ignore_fmt.build().unwrap();

let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ pub trait Iterator {
/// ```
///
/// of these layers.
///
/// Note that `iter.filter(f).next()` is equivalent to `iter.find(f)`.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn filter<P>(self, predicate: P) -> Filter<Self, P>
Expand Down Expand Up @@ -2152,6 +2154,8 @@ pub trait Iterator {
/// // we can still use `iter`, as there are more elements.
/// assert_eq!(iter.next(), Some(&3));
/// ```
///
/// Note that `iter.find(f)` is equivalent to `iter.filter(f).next()`.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ impl TwoWaySearcher {
// &v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
// "Algorithm CP2", which is optimized for when the period of the needle
// is large.
if &needle[..crit_pos] == &needle[period..period + crit_pos] {
if needle[..crit_pos] == needle[period..period + crit_pos] {
// short period case -- the period is exact
// compute a separate critical factorization for the reversed needle
// x = u' v' where |v'| < period(x).
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
val: ScalarMaybeUndef<Tag>,
) -> InterpResult<'tcx> {
let ptr_size = cx.data_layout().pointer_size;
self.write_scalar(cx, ptr.into(), val, ptr_size)
self.write_scalar(cx, ptr, val, ptr_size)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ impl<'tcx> TerminatorKind<'tcx> {
values
.iter()
.map(|&u| {
ty::Const::from_scalar(tcx, Scalar::from_uint(u, size).into(), switch_ty)
ty::Const::from_scalar(tcx, Scalar::from_uint(u, size), switch_ty)
.to_string()
.into()
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'tcx> Rvalue<'tcx> {
}
Rvalue::AddressOf(mutability, ref place) => {
let place_ty = place.ty(local_decls, tcx).ty;
tcx.mk_ptr(ty::TypeAndMut { ty: place_ty, mutbl: mutability.into() })
tcx.mk_ptr(ty::TypeAndMut { ty: place_ty, mutbl: mutability })
}
Rvalue::Len(..) => tcx.types.usize,
Rvalue::Cast(.., ty) => ty,
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,7 @@ impl ObjectSafetyViolation {
MethodViolationCode::UndispatchableReceiver,
span,
) => (
format!("consider changing method `{}`'s `self` parameter to be `&self`", name)
.into(),
format!("consider changing method `{}`'s `self` parameter to be `&self`", name),
Some(("&Self".to_string(), span)),
),
ObjectSafetyViolation::AssocConst(name, _)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<'tcx> TyCtxt<'tcx> {
db.note("distinct uses of `impl Trait` result in different opaque types");
let e_str = values.expected.to_string();
let f_str = values.found.to_string();
if &e_str == &f_str && &e_str == "impl std::future::Future" {
if e_str == f_str && &e_str == "impl std::future::Future" {
// FIXME: use non-string based check.
db.help(
"if both `Future`s have the same `Output` type, consider \
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl RegionHighlightMode {
pub fn highlighting_region(&mut self, region: ty::Region<'_>, number: usize) {
let num_slots = self.highlight_regions.len();
let first_avail_slot =
self.highlight_regions.iter_mut().filter(|s| s.is_none()).next().unwrap_or_else(|| {
self.highlight_regions.iter_mut().find(|s| s.is_none()).unwrap_or_else(|| {
bug!("can only highlight {} placeholders at a time", num_slots,)
});
*first_avail_slot = Some((*region, number));
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.last()
.cloned()
.map(|id| Ok(self.lower_node_id(id)))
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope))
.into(),
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope)),
};
hir::Destination { label: destination.map(|(_, label)| label), target_id }
}
Expand All @@ -841,7 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
if self.is_in_loop_condition && opt_label.is_none() {
hir::Destination {
label: None,
target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition).into(),
target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition),
}
} else {
self.lower_loop_destination(opt_label.map(|label| (id, label)))
Expand Down Expand Up @@ -912,7 +911,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.collect(),
asm: asm.asm,
asm_str_style: asm.asm_str_style,
clobbers: asm.clobbers.clone().into(),
clobbers: asm.clobbers.clone(),
volatile: asm.volatile,
alignstack: asm.alignstack,
dialect: asm.dialect,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// listing.
let main_ret_ty = cx.tcx().erase_regions(&main_ret_ty.no_bound_vars().unwrap());

if cx.get_defined_value("main").is_some() {
if cx.get_declared_value("main").is_some() {
// FIXME: We should be smart and show a better diagnostic here.
cx.sess()
.struct_span_err(sp, "entry symbol `main` defined multiple times")
.struct_span_err(sp, "entry symbol `main` declared multiple times")
.help("did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead")
.emit();
cx.sess().abort_if_errors();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_codegen_ssa/mir/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
let a = Scalar::from(Pointer::new(
bx.tcx().alloc_map.lock().create_memory_alloc(data),
Size::from_bytes(start as u64),
))
.into();
));
let a_llval = bx.scalar_to_backend(
a,
a_scalar,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

mir::Rvalue::AddressOf(mutability, ref place) => {
let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability.into() })
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability })
};
self.codegen_place_to_pointer(bx, place, mk_ptr)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_expand/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn parse_tree(
sess.span_diagnostic.span_err(span.entire(), &msg);
}
// Parse the contents of the sequence itself
let sequence = parse(tts.into(), expect_matchers, sess);
let sequence = parse(tts, expect_matchers, sess);
// Get the Kleene operator and optional separator
let (separator, kleene) = parse_sep_and_kleene_op(trees, span.entire(), sess);
// Count the number of captured "names" (i.e., named metavars)
Expand Down Expand Up @@ -159,7 +159,7 @@ fn parse_tree(
// descend into the delimited set and further parse it.
tokenstream::TokenTree::Delimited(span, delim, tts) => TokenTree::Delimited(
span,
Lrc::new(Delimited { delim, tts: parse(tts.into(), expect_matchers, sess) }),
Lrc::new(Delimited { delim, tts: parse(tts, expect_matchers, sess) }),
),
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_expand/mbe/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ pub(super) fn transcribe(
}

// Step back into the parent Delimited.
let tree =
TokenTree::Delimited(span, forest.delim, TokenStream::new(result).into());
let tree = TokenTree::Delimited(span, forest.delim, TokenStream::new(result));
result = result_stack.pop().unwrap();
result.push(tree.into());
}
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_expand/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
let Token { kind, span } = match tree {
tokenstream::TokenTree::Delimited(span, delim, tts) => {
let delimiter = Delimiter::from_internal(delim);
return TokenTree::Group(Group { delimiter, stream: tts.into(), span });
return TokenTree::Group(Group { delimiter, stream: tts, span });
}
tokenstream::TokenTree::Token(token) => token,
};
Expand Down Expand Up @@ -196,12 +196,8 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> {
let (ch, joint, span) = match self {
TokenTree::Punct(Punct { ch, joint, span }) => (ch, joint, span),
TokenTree::Group(Group { delimiter, stream, span }) => {
return tokenstream::TokenTree::Delimited(
span,
delimiter.to_internal(),
stream.into(),
)
.into();
return tokenstream::TokenTree::Delimited(span, delimiter.to_internal(), stream)
.into();
}
TokenTree::Ident(self::Ident { sym, is_raw, span }) => {
return tokenstream::TokenTree::token(Ident(sym, is_raw), span).into();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
} else {
let var = self.canonical_var(info, const_var.into());
self.tcx().mk_const(ty::Const {
val: ty::ConstKind::Bound(self.binder_index, var.into()),
val: ty::ConstKind::Bound(self.binder_index, var),
ty: self.fold_ty(const_var.ty),
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
.join(", ");
if !lifetimes.is_empty() {
if sub.regions().count() < len {
value.push_normal(lifetimes + &", ");
value.push_normal(lifetimes + ", ");
} else {
value.push_normal(lifetimes);
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_infer/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
// Extend with bounds that we can find from the trait.
let trait_bounds = self
.projection_declared_bounds_from_trait(projection_ty)
.into_iter()
.map(|r| VerifyBound::OutlivedBy(r));

// see the extensive comment in projection_must_outlive
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_infer/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ fn orphan_check_trait_ref<'tcx>(
let local_type = trait_ref
.input_types()
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
.filter(|ty| ty_is_non_local_constructor(ty, in_crate).is_none())
.next();
.find(|ty| ty_is_non_local_constructor(ty, in_crate).is_none());

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

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ pub fn suggest_constraining_type_param(
const MSG_RESTRICT_TYPE: &str = "consider restricting this type parameter with";
const MSG_RESTRICT_TYPE_FURTHER: &str = "consider further restricting this type parameter with";

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

let param = if let Some(param) = param {
param
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation.predicate.def_id(),
obligation.recursion_depth + 1,
a_last.expect_ty(),
&[b_last.into()],
&[b_last],
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
ast::GenericArg::Type(ty) => Some(ty),
_ => None,
});
any_involves_impl_trait(types.into_iter())
any_involves_impl_trait(types)
|| data.constraints.iter().any(|c| match c.kind {
ast::AssocTyConstraintKind::Bound { .. } => true,
ast::AssocTyConstraintKind::Equality { ref ty } => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/region_infer/reverse_sccs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl RegionInferenceContext<'_> {
let mut scc_regions = FxHashMap::default();
let mut start = 0;
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
let group_size = group.into_iter().count();
let group_size = group.count();
scc_regions.insert(scc, start..start + group_size);
start += group_size;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/const_eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub(crate) fn const_caller_location<'tcx>(

let loc_place = ecx.alloc_caller_location(file, line, col);
intern_const_alloc_recursive(&mut ecx, InternKind::Constant, loc_place, false).unwrap();
ConstValue::Scalar(loc_place.ptr.into())
ConstValue::Scalar(loc_place.ptr)
}

// this function uses `unwrap` copiously, because an already validated constant
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ crate fn eval_nullary_intrinsic<'tcx>(
};
ConstValue::from_machine_usize(n, &tcx)
}
sym::type_id => ConstValue::from_u64(tcx.type_id_hash(tp_ty).into()),
sym::type_id => ConstValue::from_u64(tcx.type_id_hash(tp_ty)),
other => bug!("`{}` is not a zero arg intrinsic", other),
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let (&untuple_arg, args) = args.split_last().unwrap();
trace!("eval_fn_call: Will pass last argument by untupling");
Cow::from(args.iter().map(|&a| Ok(a))
.chain((0..untuple_arg.layout.fields.count()).into_iter()
.chain((0..untuple_arg.layout.fields.count())
.map(|i| self.operand_field(untuple_arg, i as u64))
)
.collect::<InterpResult<'_, Vec<OpTy<'tcx, M::PointerTag>>>>()?)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> ConstQualifs {

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

fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<BodyAndCache<'_>> {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/util/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub fn expand_aggregate<'tcx>(
};

operands
.into_iter()
.enumerate()
.map(move |(i, (op, ty))| {
let lhs_field = if let AggregateKind::Array(_) = kind {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir_build/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1942,8 +1942,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let tcx = self.hir.tcx();
let debug_source_info = SourceInfo { span: source_info.span, scope: visibility_scope };
let binding_mode = match mode {
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability.into()),
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability.into()),
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability),
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability),
};
debug!("declare_binding: user_ty={:?}", user_ty);
let local = LocalDecl::<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir_build/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
span: tcx_hir.span(var_id),
},
place: Place {
local: closure_env_arg.into(),
local: closure_env_arg,
projection: tcx.intern_place_elems(&projs),
},
});
Expand Down Expand Up @@ -927,7 +927,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.local_decls[local].local_info = if let Some(kind) = self_binding {
LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(*kind)))
} else {
let binding_mode = ty::BindingMode::BindByValue(mutability.into());
let binding_mode = ty::BindingMode::BindByValue(mutability);
LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
VarBindingForm {
binding_mode,
Expand Down
Loading

0 comments on commit 7497d93

Please sign in to comment.