Skip to content

rustup https://github.com/rust-lang/rust/pull/69745 #5450

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fn lint_for_missing_headers<'a, 'tcx>(
if let Some(body_id) = body_id;
if let Some(future) = cx.tcx.lang_items().future_trait();
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
let mir = cx.tcx.optimized_mir(def_id);
let mir = cx.tcx.optimized_mir(def_id.to_def_id());
let ret_ty = mir.return_ty();
if implements_trait(cx, ret_ty, future, &[]);
if let ty::Opaque(_, subs) = ret_ty.kind;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
for var in def.variants {
if let Some(anon_const) = &var.disr_expr {
let def_id = cx.tcx.hir().body_owner_def_id(anon_const.body);
let mut ty = cx.tcx.type_of(def_id);
let mut ty = cx.tcx.type_of(def_id.to_def_id());
let constant = cx
.tcx
.const_eval_poly(def_id)
.const_eval_poly(def_id.to_def_id())
.ok()
.map(|val| rustc_middle::ty::Const::from_value(cx.tcx, val, ty));
if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/implicit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitReturn {
let def_id = cx.tcx.hir().body_owner_def_id(body.id());

// Building MIR for `fn`s with unsatisfiable preds results in ICE.
if fn_has_unsatisfiable_preds(cx, def_id) {
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
return;
}

let mir = cx.tcx.optimized_mir(def_id);
let mir = cx.tcx.optimized_mir(def_id.to_def_id());

// checking return type through MIR, HIR is not able to determine inferred closure return types
// make sure it's not a macro
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {

let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec())
.filter(|p| !p.is_global())
.filter_map(|pred| {
if let ty::Predicate::Trait(poly_trait_ref, _) = pred {
.filter_map(|obligation| {
if let ty::Predicate::Trait(poly_trait_ref, _) = obligation.predicate {
if poly_trait_ref.def_id() == sized_trait || poly_trait_ref.skip_binder().has_escaping_bound_vars()
{
return None;
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
let def_id = cx.tcx.hir().body_owner_def_id(body.id());

// Building MIR for `fn`s with unsatisfiable preds results in ICE.
if fn_has_unsatisfiable_preds(cx, def_id) {
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
return;
}

let mir = cx.tcx.optimized_mir(def_id);
let mir = cx.tcx.optimized_mir(def_id.to_def_id());
let mir_read_only = mir.unwrap_read_only();

let maybe_storage_live_result = MaybeStorageLive
.into_engine(cx.tcx, mir, def_id)
.into_engine(cx.tcx, mir, def_id.to_def_id())
.iterate_to_fixpoint()
.into_results_cursor(mir);
let mut possible_borrower = {
Expand Down
7 changes: 6 additions & 1 deletion clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,12 @@ pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_, '_>, did: DefId) -> bool
.iter()
.filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None })
.collect();
!traits::normalize_and_test_predicates(cx.tcx, traits::elaborate_predicates(cx.tcx, predicates).collect())
!traits::normalize_and_test_predicates(
cx.tcx,
traits::elaborate_predicates(cx.tcx, predicates)
.map(|o| o.predicate)
.collect::<Vec<_>>(),
)
}

#[cfg(test)]
Expand Down