Skip to content

Commit d0dc9ef

Browse files
committed
Auto merge of #105876 - matthiaskrgr:rollup-a9dgzjt, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #96584 (Fix `x setup -h -v` should work) - #105420 (Remove dead code after destination propagation) - #105844 (Make the x tool use the x and x.ps1 scripts) - #105854 (remove redundant clone) - #105858 (Another `as_chunks` example) - #105870 (avoid .into() conversion to identical types) - #105875 (don't destuct references just to reborrow) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 37efc81 + 2237977 commit d0dc9ef

File tree

42 files changed

+287
-131
lines changed

Some content is hidden

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

42 files changed

+287
-131
lines changed

compiler/rustc_builtin_macros/src/global_allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn expand(
3535
(item, true, ecx.with_def_site_ctxt(ty.span))
3636
} else {
3737
ecx.sess.parse_sess.span_diagnostic.span_err(item.span(), "allocators must be statics");
38-
return vec![orig_item.clone()]
38+
return vec![orig_item];
3939
};
4040

4141
// Generate a bunch of new items using the AllocFnFactory

compiler/rustc_builtin_macros/src/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ pub fn expand_test_or_bench(
239239
cx.attr_nested_word(sym::cfg, sym::test, attr_sp),
240240
// #[rustc_test_marker = "test_case_sort_key"]
241241
cx.attr_name_value_str(sym::rustc_test_marker, test_path_symbol, attr_sp),
242-
]
243-
.into(),
242+
],
244243
// const $ident: test::TestDescAndFn =
245244
ast::ItemKind::Const(
246245
ast::Defaultness::Final,

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ fn thin_lto(
425425
info!("going for that thin, thin LTO");
426426

427427
let green_modules: FxHashMap<_, _> =
428-
cached_modules.iter().map(|&(_, ref wp)| (wp.cgu_name.clone(), wp.clone())).collect();
428+
cached_modules.iter().map(|(_, wp)| (wp.cgu_name.clone(), wp.clone())).collect();
429429

430430
let full_scope_len = modules.len() + serialized_modules.len() + cached_modules.len();
431431
let mut thin_buffers = Vec::with_capacity(modules.len());

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ fn link_natively<'a>(
722722

723723
linker::disable_localization(&mut cmd);
724724

725-
for &(ref k, ref v) in sess.target.link_env.as_ref() {
725+
for (k, v) in sess.target.link_env.as_ref() {
726726
cmd.env(k.as_ref(), v.as_ref());
727727
}
728728
for k in sess.target.link_env_remove.as_ref() {

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn get_linker<'a>(
108108
if sess.target.is_like_msvc {
109109
if let Some(ref tool) = msvc_tool {
110110
cmd.args(tool.args());
111-
for &(ref k, ref v) in tool.env() {
111+
for (k, v) in tool.env() {
112112
if k == "PATH" {
113113
new_path.extend(env::split_paths(v));
114114
msvc_changed_path = true;

compiler/rustc_const_eval/src/interpret/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
332332
Immediate::new_slice(ptr, length.eval_usize(*self.tcx, self.param_env), self);
333333
self.write_immediate(val, dest)
334334
}
335-
(&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => {
335+
(ty::Dynamic(data_a, ..), ty::Dynamic(data_b, ..)) => {
336336
let val = self.read_immediate(src)?;
337337
if data_a.principal() == data_b.principal() {
338338
// A NOP cast that doesn't actually change anything, should be allowed even with mismatching vtables.

compiler/rustc_const_eval/src/interpret/operand.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum Immediate<Prov: Provenance = AllocId> {
3939
impl<Prov: Provenance> From<Scalar<Prov>> for Immediate<Prov> {
4040
#[inline(always)]
4141
fn from(val: Scalar<Prov>) -> Self {
42-
Immediate::Scalar(val.into())
42+
Immediate::Scalar(val)
4343
}
4444
}
4545

@@ -53,15 +53,15 @@ impl<Prov: Provenance> Immediate<Prov> {
5353
}
5454

5555
pub fn new_slice(val: Scalar<Prov>, len: u64, cx: &impl HasDataLayout) -> Self {
56-
Immediate::ScalarPair(val.into(), Scalar::from_machine_usize(len, cx).into())
56+
Immediate::ScalarPair(val, Scalar::from_machine_usize(len, cx))
5757
}
5858

5959
pub fn new_dyn_trait(
6060
val: Scalar<Prov>,
6161
vtable: Pointer<Option<Prov>>,
6262
cx: &impl HasDataLayout,
6363
) -> Self {
64-
Immediate::ScalarPair(val.into(), Scalar::from_maybe_pointer(vtable, cx))
64+
Immediate::ScalarPair(val, Scalar::from_maybe_pointer(vtable, cx))
6565
}
6666

6767
#[inline]
@@ -341,10 +341,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
341341
alloc_range(b_offset, b_size),
342342
/*read_provenance*/ b.is_ptr(),
343343
)?;
344-
Some(ImmTy {
345-
imm: Immediate::ScalarPair(a_val.into(), b_val.into()),
346-
layout: mplace.layout,
347-
})
344+
Some(ImmTy { imm: Immediate::ScalarPair(a_val, b_val), layout: mplace.layout })
348345
}
349346
_ => {
350347
// Neither a scalar nor scalar pair.

compiler/rustc_const_eval/src/interpret/operator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
3636
if let Abi::ScalarPair(..) = dest.layout.abi {
3737
// We can use the optimized path and avoid `place_field` (which might do
3838
// `force_allocation`).
39-
let pair = Immediate::ScalarPair(val.into(), Scalar::from_bool(overflowed).into());
39+
let pair = Immediate::ScalarPair(val, Scalar::from_bool(overflowed));
4040
self.write_immediate(pair, dest)?;
4141
} else {
4242
assert!(self.tcx.sess.opts.unstable_opts.randomize_layout);

compiler/rustc_const_eval/src/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<Prov: Provenance> MemPlace<Prov> {
141141
match self.meta {
142142
MemPlaceMeta::None => Immediate::from(Scalar::from_maybe_pointer(self.ptr, cx)),
143143
MemPlaceMeta::Meta(meta) => {
144-
Immediate::ScalarPair(Scalar::from_maybe_pointer(self.ptr, cx).into(), meta.into())
144+
Immediate::ScalarPair(Scalar::from_maybe_pointer(self.ptr, cx), meta)
145145
}
146146
}
147147
}

compiler/rustc_expand/src/mbe/macro_check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn check_nested_occurrences(
468468
// We check that the meta-variable is correctly used.
469469
check_occurrences(sess, node_id, tt, macros, binders, ops, valid);
470470
}
471-
(NestedMacroState::MacroName, &TokenTree::Delimited(_, ref del))
471+
(NestedMacroState::MacroName, TokenTree::Delimited(_, del))
472472
if del.delim == Delimiter::Parenthesis =>
473473
{
474474
state = NestedMacroState::MacroNameParen;
@@ -483,7 +483,7 @@ fn check_nested_occurrences(
483483
valid,
484484
);
485485
}
486-
(NestedMacroState::MacroNameParen, &TokenTree::Delimited(_, ref del))
486+
(NestedMacroState::MacroNameParen, TokenTree::Delimited(_, del))
487487
if del.delim == Delimiter::Brace =>
488488
{
489489
state = NestedMacroState::Empty;

compiler/rustc_expand/src/mbe/macro_rules.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl<'tt> FirstSets<'tt> {
792792
TokenTree::Sequence(sp, ref seq_rep) => {
793793
let subfirst_owned;
794794
let subfirst = match self.first.get(&sp.entire()) {
795-
Some(&Some(ref subfirst)) => subfirst,
795+
Some(Some(subfirst)) => subfirst,
796796
Some(&None) => {
797797
subfirst_owned = self.first(&seq_rep.tts);
798798
&subfirst_owned

compiler/rustc_hir_typeck/src/demand.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12751275
};
12761276

12771277
match (&expected_ty.kind(), &checked_ty.kind()) {
1278-
(&ty::Int(ref exp), &ty::Int(ref found)) => {
1278+
(ty::Int(exp), ty::Int(found)) => {
12791279
let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width())
12801280
{
12811281
(Some(exp), Some(found)) if exp < found => (true, false),
@@ -1288,7 +1288,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12881288
suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible);
12891289
true
12901290
}
1291-
(&ty::Uint(ref exp), &ty::Uint(ref found)) => {
1291+
(ty::Uint(exp), ty::Uint(found)) => {
12921292
let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width())
12931293
{
12941294
(Some(exp), Some(found)) if exp < found => (true, false),
@@ -1321,7 +1321,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13211321
suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible);
13221322
true
13231323
}
1324-
(&ty::Float(ref exp), &ty::Float(ref found)) => {
1324+
(ty::Float(exp), ty::Float(found)) => {
13251325
if found.bit_width() < exp.bit_width() {
13261326
suggest_to_change_suffix_or_into(err, false, true);
13271327
} else if literal_is_ty_suffixed(expr) {
@@ -1357,7 +1357,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13571357
}
13581358
true
13591359
}
1360-
(&ty::Float(ref exp), &ty::Uint(ref found)) => {
1360+
(ty::Float(exp), ty::Uint(found)) => {
13611361
// if `found` is `None` (meaning found is `usize`), don't suggest `.into()`
13621362
if exp.bit_width() > found.bit_width().unwrap_or(256) {
13631363
err.multipart_suggestion_verbose(
@@ -1386,7 +1386,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13861386
}
13871387
true
13881388
}
1389-
(&ty::Float(ref exp), &ty::Int(ref found)) => {
1389+
(ty::Float(exp), ty::Int(found)) => {
13901390
// if `found` is `None` (meaning found is `isize`), don't suggest `.into()`
13911391
if exp.bit_width() > found.bit_width().unwrap_or(256) {
13921392
err.multipart_suggestion_verbose(

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18741874
// I don't use 'is_range_literal' because only double-sided, half-open ranges count.
18751875
if let ExprKind::Struct(
18761876
QPath::LangItem(LangItem::Range, ..),
1877-
&[ref range_start, ref range_end],
1877+
[range_start, range_end],
18781878
_,
18791879
) = last_expr_field.expr.kind
18801880
&& let variant_field =

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
754754
return true
755755
}
756756
}
757-
&hir::FnRetTy::Return(ref ty) => {
757+
hir::FnRetTy::Return(ty) => {
758758
// Only point to return type if the expected type is the return type, as if they
759759
// are not, the expectation must have been caused by something else.
760760
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind);

compiler/rustc_incremental/src/assert_dep_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn dump_graph(query: &DepGraphQuery) {
249249
// dump a .txt file with just the edges:
250250
let txt_path = format!("{}.txt", path);
251251
let mut file = BufWriter::new(File::create(&txt_path).unwrap());
252-
for &(ref source, ref target) in &edges {
252+
for (source, target) in &edges {
253253
write!(file, "{:?} -> {:?}\n", source, target).unwrap();
254254
}
255255
}

compiler/rustc_infer/src/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ impl<'tcx> TypeTrace<'tcx> {
19201920
) -> TypeTrace<'tcx> {
19211921
TypeTrace {
19221922
cause: cause.clone(),
1923-
values: PolyTraitRefs(ExpectedFound::new(a_is_expected, a.into(), b.into())),
1923+
values: PolyTraitRefs(ExpectedFound::new(a_is_expected, a, b)),
19241924
}
19251925
}
19261926

compiler/rustc_infer/src/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'tcx> ProjectionCache<'_, 'tcx> {
200200
pub fn complete(&mut self, key: ProjectionCacheKey<'tcx>, result: EvaluationResult) {
201201
let mut map = self.map();
202202
match map.get(&key) {
203-
Some(&ProjectionCacheEntry::NormalizedTy { ref ty, complete: _ }) => {
203+
Some(ProjectionCacheEntry::NormalizedTy { ty, complete: _ }) => {
204204
info!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty);
205205
let mut ty = ty.clone();
206206
if result.must_apply_considering_regions() {

compiler/rustc_lint/src/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,18 @@ impl LintStore {
438438
return CheckLintNameResult::Tool(Ok(&lint_ids));
439439
}
440440
},
441-
Some(&Id(ref id)) => return CheckLintNameResult::Tool(Ok(slice::from_ref(id))),
441+
Some(Id(id)) => return CheckLintNameResult::Tool(Ok(slice::from_ref(id))),
442442
// If the lint was registered as removed or renamed by the lint tool, we don't need
443443
// to treat tool_lints and rustc lints different and can use the code below.
444444
_ => {}
445445
}
446446
}
447447
match self.by_name.get(&complete_name) {
448-
Some(&Renamed(ref new_name, _)) => CheckLintNameResult::Warning(
448+
Some(Renamed(new_name, _)) => CheckLintNameResult::Warning(
449449
format!("lint `{}` has been renamed to `{}`", complete_name, new_name),
450450
Some(new_name.to_owned()),
451451
),
452-
Some(&Removed(ref reason)) => CheckLintNameResult::Warning(
452+
Some(Removed(reason)) => CheckLintNameResult::Warning(
453453
format!("lint `{}` has been removed: {}", complete_name, reason),
454454
None,
455455
),
@@ -470,7 +470,7 @@ impl LintStore {
470470
CheckLintNameResult::Ok(&lint_ids)
471471
}
472472
},
473-
Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::from_ref(id)),
473+
Some(Id(id)) => CheckLintNameResult::Ok(slice::from_ref(id)),
474474
Some(&Ignored) => CheckLintNameResult::Ok(&[]),
475475
}
476476
}
@@ -513,7 +513,7 @@ impl LintStore {
513513
CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name)))
514514
}
515515
},
516-
Some(&Id(ref id)) => {
516+
Some(Id(id)) => {
517517
CheckLintNameResult::Tool(Err((Some(slice::from_ref(id)), complete_name)))
518518
}
519519
Some(other) => {

compiler/rustc_lint/src/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ impl UnusedImportBraces {
12791279
fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &ast::Item) {
12801280
if let ast::UseTreeKind::Nested(ref items) = use_tree.kind {
12811281
// Recursively check nested UseTrees
1282-
for &(ref tree, _) in items {
1282+
for (tree, _) in items {
12831283
self.check_use_tree(cx, tree, item);
12841284
}
12851285

compiler/rustc_metadata/src/rmeta/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18491849
// the assumption that they are numbered 1 to n.
18501850
// FIXME (#2166): This is not nearly enough to support correct versioning
18511851
// but is enough to get transitive crate dependencies working.
1852-
self.lazy_array(deps.iter().map(|&(_, ref dep)| dep))
1852+
self.lazy_array(deps.iter().map(|(_, dep)| dep))
18531853
}
18541854

18551855
fn encode_lib_features(&mut self) -> LazyArray<(Symbol, Option<Symbol>)> {
@@ -1986,7 +1986,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19861986
self.lazy_array(
19871987
exported_symbols
19881988
.iter()
1989-
.filter(|&&(ref exported_symbol, _)| match *exported_symbol {
1989+
.filter(|&(exported_symbol, _)| match *exported_symbol {
19901990
ExportedSymbol::NoDefId(symbol_name) => symbol_name != metadata_symbol_name,
19911991
_ => true,
19921992
})

compiler/rustc_middle/src/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<'tcx> Operand<'tcx> {
235235
{
236236
match self {
237237
&Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
238-
&Operand::Constant(ref c) => c.literal.ty(),
238+
Operand::Constant(c) => c.literal.ty(),
239239
}
240240
}
241241
}

compiler/rustc_middle/src/ty/flags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl FlagComputation {
9595
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
9696
}
9797

98-
&ty::Generator(_, ref substs, _) => {
98+
ty::Generator(_, substs, _) => {
9999
let substs = substs.as_generator();
100100
let should_remove_further_specializable =
101101
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
@@ -186,7 +186,7 @@ impl FlagComputation {
186186

187187
&ty::Slice(tt) => self.add_ty(tt),
188188

189-
&ty::RawPtr(ref m) => {
189+
ty::RawPtr(m) => {
190190
self.add_ty(m.ty);
191191
}
192192

compiler/rustc_middle/src/ty/relate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
428428
Ok(a)
429429
}
430430

431-
(&ty::Param(ref a_p), &ty::Param(ref b_p)) if a_p.index == b_p.index => Ok(a),
431+
(ty::Param(a_p), ty::Param(b_p)) if a_p.index == b_p.index => Ok(a),
432432

433433
(ty::Placeholder(p1), ty::Placeholder(p2)) if p1 == p2 => Ok(a),
434434

compiler/rustc_middle/src/ty/vtable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ pub(super) fn vtable_allocation_provider<'tcx>(
8888
let fn_ptr = Pointer::from(fn_alloc_id);
8989
Scalar::from_pointer(fn_ptr, &tcx)
9090
}
91-
VtblEntry::MetadataSize => Scalar::from_uint(size, ptr_size).into(),
92-
VtblEntry::MetadataAlign => Scalar::from_uint(align, ptr_size).into(),
91+
VtblEntry::MetadataSize => Scalar::from_uint(size, ptr_size),
92+
VtblEntry::MetadataAlign => Scalar::from_uint(align, ptr_size),
9393
VtblEntry::Vacant => continue,
9494
VtblEntry::Method(instance) => {
9595
// Prepare the fn ptr we write into the vtable.

compiler/rustc_mir_build/src/build/expr/as_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl<'tcx> PlaceBuilder<'tcx> {
356356
match self {
357357
PlaceBuilder::Local { local, projection } => PlaceBuilder::Local {
358358
local: *local,
359-
projection: Vec::from_iter(projection.iter().copied().chain([elem.into()])),
359+
projection: Vec::from_iter(projection.iter().copied().chain([elem])),
360360
},
361361
PlaceBuilder::Upvar { upvar, projection } => PlaceBuilder::Upvar {
362362
upvar: *upvar,

0 commit comments

Comments
 (0)