Skip to content

Commit 5c54d04

Browse files
Rollup merge of rust-lang#87069 - sexxi-goose:copy_ref_always, r=nikomatsakis
ExprUseVisitor: Treat ByValue use of Copy types as ImmBorrow r? ```@nikomatsakis```
2 parents 1d084b1 + a9e9b7f commit 5c54d04

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

clippy_lints/src/escape.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::source_map::Span;
1111
use rustc_span::symbol::kw;
1212
use rustc_target::abi::LayoutOf;
1313
use rustc_target::spec::abi::Abi;
14-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
14+
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1515

1616
#[derive(Copy, Clone)]
1717
pub struct BoxedLocal {
@@ -133,13 +133,10 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
133133
}
134134

135135
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
136-
fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, mode: ConsumeMode) {
136+
fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) {
137137
if cmt.place.projections.is_empty() {
138138
if let PlaceBase::Local(lid) = cmt.place.base {
139-
if let ConsumeMode::Move = mode {
140-
// moved out or in. clearly can't be localized
141-
self.set.remove(&lid);
142-
}
139+
self.set.remove(&lid);
143140
let map = &self.cx.tcx.hir();
144141
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
145142
if self.set.contains(&lid) {

clippy_lints/src/loops/mut_range_bound.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_infer::infer::TyCtxtInferExt;
77
use rustc_lint::LateContext;
88
use rustc_middle::{mir::FakeReadCause, ty};
99
use rustc_span::source_map::Span;
10-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
10+
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1111

1212
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, body: &Expr<'_>) {
1313
if let Some(higher::Range {
@@ -82,7 +82,7 @@ struct MutatePairDelegate<'a, 'tcx> {
8282
}
8383

8484
impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
85-
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId, _: ConsumeMode) {}
85+
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
8686

8787
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
8888
if let ty::BorrowKind::MutBorrow = bk {

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,8 @@ impl MovedVariablesCtxt {
326326
}
327327

328328
impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
329-
fn consume(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, _: HirId, mode: euv::ConsumeMode) {
330-
if let euv::ConsumeMode::Move = mode {
331-
self.move_common(cmt);
332-
}
329+
fn consume(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, _: HirId) {
330+
self.move_common(cmt);
333331
}
334332

335333
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {}

clippy_utils/src/usage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_lint::LateContext;
1010
use rustc_middle::hir::map::Map;
1111
use rustc_middle::mir::FakeReadCause;
1212
use rustc_middle::ty;
13-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
13+
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1414

1515
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
1616
pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) -> Option<HirIdSet> {
@@ -67,7 +67,7 @@ impl<'tcx> MutVarsDelegate {
6767
}
6868

6969
impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
70-
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId, _: ConsumeMode) {}
70+
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
7171

7272
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) {
7373
if let ty::BorrowKind::MutBorrow = bk {

0 commit comments

Comments
 (0)