Skip to content

Commit 71cd918

Browse files
committed
cleanup: don't clone types that are Copy
1 parent 9903b25 commit 71cd918

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

compiler/rustc_middle/src/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn early_report_macro_deprecation(
217217
suggestion_span: span,
218218
note: depr.note,
219219
path,
220-
since_kind: deprecated_since_kind(is_in_effect, depr.since.clone()),
220+
since_kind: deprecated_since_kind(is_in_effect, depr.since),
221221
};
222222
lint_buffer.buffer_lint(deprecation_lint(is_in_effect), node_id, span, diag);
223223
}

compiler/rustc_mir_transform/src/coroutine/by_move_body.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ pub(crate) fn coroutine_by_move_body_def_id<'tcx>(
223223

224224
// Inherited from the by-ref coroutine.
225225
body_def.codegen_fn_attrs(tcx.codegen_fn_attrs(coroutine_def_id).clone());
226-
body_def.constness(tcx.constness(coroutine_def_id).clone());
227-
body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id).clone());
226+
body_def.constness(tcx.constness(coroutine_def_id));
227+
body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id));
228228
body_def.def_ident_span(tcx.def_ident_span(coroutine_def_id));
229229
body_def.def_span(tcx.def_span(coroutine_def_id));
230-
body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id).clone());
230+
body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id));
231231
body_def.generics_of(tcx.generics_of(coroutine_def_id).clone());
232-
body_def.param_env(tcx.param_env(coroutine_def_id).clone());
233-
body_def.predicates_of(tcx.predicates_of(coroutine_def_id).clone());
232+
body_def.param_env(tcx.param_env(coroutine_def_id));
233+
body_def.predicates_of(tcx.predicates_of(coroutine_def_id));
234234

235235
// The type of the coroutine is the `by_move_coroutine_ty`.
236236
body_def.type_of(ty::EarlyBinder::bind(by_move_coroutine_ty));

compiler/rustc_mir_transform/src/single_use_consts.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,14 @@ impl<'tcx> MutVisitor<'tcx> for LocalReplacer<'tcx> {
185185
&& let Some(local) = place.as_local()
186186
&& local == self.local
187187
{
188-
let const_op = self
188+
let const_op = *self
189189
.operand
190190
.as_ref()
191191
.unwrap_or_else(|| {
192192
bug!("the operand was already stolen");
193193
})
194194
.constant()
195-
.unwrap()
196-
.clone();
195+
.unwrap();
197196
var_debug_info.value = VarDebugInfoContents::Const(const_op);
198197
}
199198
}

compiler/rustc_pattern_analysis/src/constructor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,10 @@ impl<Cx: PatCx> Clone for Constructor<Cx> {
735735
Constructor::UnionField => Constructor::UnionField,
736736
Constructor::Bool(b) => Constructor::Bool(*b),
737737
Constructor::IntRange(range) => Constructor::IntRange(*range),
738-
Constructor::F16Range(lo, hi, end) => Constructor::F16Range(lo.clone(), *hi, *end),
739-
Constructor::F32Range(lo, hi, end) => Constructor::F32Range(lo.clone(), *hi, *end),
740-
Constructor::F64Range(lo, hi, end) => Constructor::F64Range(lo.clone(), *hi, *end),
741-
Constructor::F128Range(lo, hi, end) => Constructor::F128Range(lo.clone(), *hi, *end),
738+
Constructor::F16Range(lo, hi, end) => Constructor::F16Range(*lo, *hi, *end),
739+
Constructor::F32Range(lo, hi, end) => Constructor::F32Range(*lo, *hi, *end),
740+
Constructor::F64Range(lo, hi, end) => Constructor::F64Range(*lo, *hi, *end),
741+
Constructor::F128Range(lo, hi, end) => Constructor::F128Range(*lo, *hi, *end),
742742
Constructor::Str(value) => Constructor::Str(value.clone()),
743743
Constructor::Opaque(inner) => Constructor::Opaque(inner.clone()),
744744
Constructor::Or => Constructor::Or,

compiler/rustc_resolve/src/diagnostics.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1469,11 +1469,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14691469
}
14701470

14711471
let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| {
1472-
if unused_ident.name == ident.name {
1473-
Some((def_id.clone(), unused_ident.clone()))
1474-
} else {
1475-
None
1476-
}
1472+
if unused_ident.name == ident.name { Some((def_id, unused_ident)) } else { None }
14771473
});
14781474

14791475
if let Some((def_id, unused_ident)) = unused_macro {

0 commit comments

Comments
 (0)