未验证 提交 555df0f4 编写于 作者: P Pietro Albini 提交者: GitHub

Rollup merge of #55282 - sinkuu:redundant_clone, r=estebank

Remove redundant clone
...@@ -180,7 +180,7 @@ pub fn new(cm: &'a SourceMap, ...@@ -180,7 +180,7 @@ pub fn new(cm: &'a SourceMap,
State { State {
s: pp::mk_printer(out, default_columns), s: pp::mk_printer(out, default_columns),
cm: Some(cm), cm: Some(cm),
comments: comments.clone(), comments,
literals: literals.unwrap_or_default().into_iter().peekable(), literals: literals.unwrap_or_default().into_iter().peekable(),
cur_cmnt: 0, cur_cmnt: 0,
boxes: Vec::new(), boxes: Vec::new(),
......
...@@ -44,7 +44,7 @@ pub fn new(source_map: &'cm SourceMap) -> CachingSourceMapView<'cm> { ...@@ -44,7 +44,7 @@ pub fn new(source_map: &'cm SourceMap) -> CachingSourceMapView<'cm> {
CachingSourceMapView { CachingSourceMapView {
source_map, source_map,
line_cache: [entry.clone(), entry.clone(), entry.clone()], line_cache: [entry.clone(), entry.clone(), entry],
time_stamp: 0, time_stamp: 0,
} }
} }
......
...@@ -340,7 +340,7 @@ fn fold<T:TypeFoldable<'tcx>>(&mut self, value: &T) -> T { ...@@ -340,7 +340,7 @@ fn fold<T:TypeFoldable<'tcx>>(&mut self, value: &T) -> T {
let value = self.selcx.infcx().resolve_type_vars_if_possible(value); let value = self.selcx.infcx().resolve_type_vars_if_possible(value);
if !value.has_projections() { if !value.has_projections() {
value.clone() value
} else { } else {
value.fold_with(self) value.fold_with(self)
} }
......
...@@ -967,7 +967,7 @@ pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> { ...@@ -967,7 +967,7 @@ pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output) self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
} }
pub fn output(&self) -> ty::Binder<Ty<'tcx>> { pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
self.map_bound_ref(|fn_sig| fn_sig.output().clone()) self.map_bound_ref(|fn_sig| fn_sig.output())
} }
pub fn variadic(&self) -> bool { pub fn variadic(&self) -> bool {
self.skip_binder().variadic self.skip_binder().variadic
......
...@@ -1048,7 +1048,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ...@@ -1048,7 +1048,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
if let Some(constructors) = pat_constructors(cx, v[0], pcx) { if let Some(constructors) = pat_constructors(cx, v[0], pcx) {
debug!("is_useful - expanding constructors: {:#?}", constructors); debug!("is_useful - expanding constructors: {:#?}", constructors);
split_grouped_constructors(cx.tcx, constructors, matrix, pcx.ty).into_iter().map(|c| split_grouped_constructors(cx.tcx, constructors, matrix, pcx.ty).into_iter().map(|c|
is_useful_specialized(cx, matrix, v, c.clone(), pcx.ty, witness) is_useful_specialized(cx, matrix, v, c, pcx.ty, witness)
).find(|result| result.is_useful()).unwrap_or(NotUseful) ).find(|result| result.is_useful()).unwrap_or(NotUseful)
} else { } else {
debug!("is_useful - expanding wildcard"); debug!("is_useful - expanding wildcard");
...@@ -1096,7 +1096,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ...@@ -1096,7 +1096,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
if missing_ctors.is_empty() && !is_non_exhaustive { if missing_ctors.is_empty() && !is_non_exhaustive {
split_grouped_constructors(cx.tcx, all_ctors, matrix, pcx.ty).into_iter().map(|c| { split_grouped_constructors(cx.tcx, all_ctors, matrix, pcx.ty).into_iter().map(|c| {
is_useful_specialized(cx, matrix, v, c.clone(), pcx.ty, witness) is_useful_specialized(cx, matrix, v, c, pcx.ty, witness)
}).find(|result| result.is_useful()).unwrap_or(NotUseful) }).find(|result| result.is_useful()).unwrap_or(NotUseful)
} else { } else {
let matrix = rows.iter().filter_map(|r| { let matrix = rows.iter().filter_map(|r| {
......
...@@ -965,7 +965,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind { ...@@ -965,7 +965,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
polarity, polarity,
defaultness, defaultness,
folder.fold_generics(generics), folder.fold_generics(generics),
ifce.map(|trait_ref| folder.fold_trait_ref(trait_ref.clone())), ifce.map(|trait_ref| folder.fold_trait_ref(trait_ref)),
folder.fold_ty(ty), folder.fold_ty(ty),
impl_items.move_flat_map(|item| folder.fold_impl_item(item)), impl_items.move_flat_map(|item| folder.fold_impl_item(item)),
), ),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册