Skip to content

Commit 49ff0d9

Browse files
committed
Auto merge of #4292 - mikerite:fix-breakage-20190721, r=matthiaskrgr
Fix breakage due to rust-lang/rust#62705 Also rename `OUTER_EXPN_INFO` to `OUTER_EXPN_EXPN_INFO` to match new function names. changelog: none
2 parents bd4c4e7 + f05e295 commit 49ff0d9

File tree

5 files changed

+42
-28
lines changed

5 files changed

+42
-28
lines changed

clippy_lints/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// error-pattern:cargo-clippy
22

33
#![feature(box_syntax)]
4+
#![feature(box_patterns)]
45
#![feature(never_type)]
56
#![feature(rustc_private)]
67
#![feature(slice_patterns)]
@@ -668,7 +669,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
668669
utils::internal_lints::CLIPPY_LINTS_INTERNAL,
669670
utils::internal_lints::COMPILER_LINT_FUNCTIONS,
670671
utils::internal_lints::LINT_WITHOUT_LINT_PASS,
671-
utils::internal_lints::OUTER_EXPN_INFO,
672+
utils::internal_lints::OUTER_EXPN_EXPN_INFO,
672673
]);
673674

674675
reg.register_lint_group("clippy::all", Some("clippy"), vec![

clippy_lints/src/redundant_clone.rs

+29-16
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
132132
let pred_arg = if_chain! {
133133
if let Some((pred_fn_def_id, pred_arg, pred_arg_ty, Some(res))) =
134134
is_call_with_ref_arg(cx, mir, &pred_terminator.kind);
135-
if *res == mir::Place::Base(mir::PlaceBase::Local(cloned));
135+
if res.base == mir::PlaceBase::Local(cloned);
136136
if match_def_path(cx, pred_fn_def_id, &paths::DEREF_TRAIT_METHOD);
137137
if match_type(cx, pred_arg_ty, &paths::PATH_BUF)
138138
|| match_type(cx, pred_arg_ty, &paths::OS_STRING);
@@ -218,7 +218,7 @@ fn is_call_with_ref_arg<'tcx>(
218218
if_chain! {
219219
if let TerminatorKind::Call { func, args, destination, .. } = kind;
220220
if args.len() == 1;
221-
if let mir::Operand::Move(mir::Place::Base(mir::PlaceBase::Local(local))) = &args[0];
221+
if let mir::Operand::Move(mir::Place { base: mir::PlaceBase::Local(local), .. }) = &args[0];
222222
if let ty::FnDef(def_id, _) = func.ty(&*mir, cx.tcx).sty;
223223
if let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].ty(&*mir, cx.tcx));
224224
if !is_copy(cx, inner_ty);
@@ -244,7 +244,14 @@ fn find_stmt_assigns_to<'a, 'tcx: 'a>(
244244
stmts
245245
.rev()
246246
.find_map(|stmt| {
247-
if let mir::StatementKind::Assign(mir::Place::Base(mir::PlaceBase::Local(local)), v) = &stmt.kind {
247+
if let mir::StatementKind::Assign(
248+
mir::Place {
249+
base: mir::PlaceBase::Local(local),
250+
..
251+
},
252+
v,
253+
) = &stmt.kind
254+
{
248255
if *local == to {
249256
return Some(v);
250257
}
@@ -271,28 +278,34 @@ fn find_stmt_assigns_to<'a, 'tcx: 'a>(
271278
fn base_local_and_movability<'tcx>(
272279
cx: &LateContext<'_, 'tcx>,
273280
mir: &mir::Body<'tcx>,
274-
mut place: &mir::Place<'tcx>,
281+
place: &mir::Place<'tcx>,
275282
) -> Option<(mir::Local, CannotMoveOut)> {
276-
use rustc::mir::Place::*;
283+
use rustc::mir::Place;
277284
use rustc::mir::PlaceBase;
285+
use rustc::mir::PlaceRef;
286+
use rustc::mir::Projection;
278287

279288
// Dereference. You cannot move things out from a borrowed value.
280289
let mut deref = false;
281290
// Accessing a field of an ADT that has `Drop`. Moving the field out will cause E0509.
282291
let mut field = false;
283292

284-
loop {
285-
match place {
286-
Base(PlaceBase::Local(local)) => return Some((*local, deref || field)),
287-
Projection(proj) => {
288-
place = &proj.base;
289-
deref = deref || matches!(proj.elem, mir::ProjectionElem::Deref);
290-
if !field && matches!(proj.elem, mir::ProjectionElem::Field(..)) {
291-
field = has_drop(cx, place.ty(&mir.local_decls, cx.tcx).ty);
292-
}
293-
},
294-
_ => return None,
293+
let PlaceRef {
294+
base: place_base,
295+
mut projection,
296+
} = place.as_place_ref();
297+
if let PlaceBase::Local(local) = place_base {
298+
while let Some(box Projection { base, elem }) = projection {
299+
projection = base;
300+
deref = matches!(elem, mir::ProjectionElem::Deref);
301+
field = !field
302+
&& matches!(elem, mir::ProjectionElem::Field(..))
303+
&& has_drop(cx, Place::ty_from(place_base, projection, &mir.local_decls, cx.tcx).ty);
295304
}
305+
306+
Some((*local, deref || field))
307+
} else {
308+
None
296309
}
297310
}
298311

clippy_lints/src/utils/internal_lints.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ declare_clippy_lint! {
9393
/// ```rust
9494
/// expr.span.ctxt().outer_expn_info()
9595
/// ```
96-
pub OUTER_EXPN_INFO,
96+
pub OUTER_EXPN_EXPN_INFO,
9797
internal,
98-
"using `cx.outer().expn_info()` instead of `cx.outer_expn_info()`"
98+
"using `cx.outer_expn().expn_info()` instead of `cx.outer_expn_info()`"
9999
}
100100

101101
declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);
@@ -280,15 +280,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
280280

281281
pub struct OuterExpnInfoPass;
282282

283-
impl_lint_pass!(OuterExpnInfoPass => [OUTER_EXPN_INFO]);
283+
impl_lint_pass!(OuterExpnInfoPass => [OUTER_EXPN_EXPN_INFO]);
284284

285285
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OuterExpnInfoPass {
286286
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
287287
let (method_names, arg_lists) = method_calls(expr, 2);
288288
let method_names: Vec<LocalInternedString> = method_names.iter().map(|s| s.as_str()).collect();
289289
let method_names: Vec<&str> = method_names.iter().map(std::convert::AsRef::as_ref).collect();
290290
if_chain! {
291-
if let ["expn_info", "outer"] = method_names.as_slice();
291+
if let ["expn_info", "outer_expn"] = method_names.as_slice();
292292
let args = arg_lists[1];
293293
if args.len() == 1;
294294
let self_arg = &args[0];
@@ -297,9 +297,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OuterExpnInfoPass {
297297
then {
298298
span_lint_and_sugg(
299299
cx,
300-
OUTER_EXPN_INFO,
300+
OUTER_EXPN_EXPN_INFO,
301301
expr.span.trim_start(self_arg.span).unwrap_or(expr.span),
302-
"usage of `outer().expn_info()`",
302+
"usage of `outer_expn().expn_info()`",
303303
"try",
304304
".outer_expn_info()".to_string(),
305305
Applicability::MachineApplicable,

tests/ui/outer_expn_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
1616

1717
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
1818
fn check_expr(&mut self, _cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
19-
let _ = expr.span.ctxt().outer().expn_info();
19+
let _ = expr.span.ctxt().outer_expn().expn_info();
2020
}
2121
}
2222

tests/ui/outer_expn_info.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
error: usage of `outer().expn_info()`
1+
error: usage of `outer_expn().expn_info()`
22
--> $DIR/outer_expn_info.rs:19:33
33
|
4-
LL | let _ = expr.span.ctxt().outer().expn_info();
5-
| ^^^^^^^^^^^^^^^^^^^^ help: try: `.outer_expn_info()`
4+
LL | let _ = expr.span.ctxt().outer_expn().expn_info();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.outer_expn_info()`
66
|
77
note: lint level defined here
88
--> $DIR/outer_expn_info.rs:1:9
99
|
1010
LL | #![deny(clippy::internal)]
1111
| ^^^^^^^^^^^^^^^^
12-
= note: `#[deny(clippy::outer_expn_info)]` implied by `#[deny(clippy::internal)]`
12+
= note: `#[deny(clippy::outer_expn_expn_info)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: aborting due to previous error
1515

0 commit comments

Comments
 (0)