This commit is contained in:
Yuki Okushi 2020-01-08 15:42:54 +09:00
parent c092068996
commit fa33681d5c
2 changed files with 5 additions and 2 deletions

View file

@ -9,6 +9,7 @@ use rustc::declare_lint_pass;
use rustc::hir::intravisit::FnKind;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::traits;
use rustc::traits::misc::can_type_implement_copy;
use rustc::ty::{self, RegionKind, TypeFoldable};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::Applicability;
@ -205,7 +206,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
let sugg = |db: &mut DiagnosticBuilder<'_>| {
if let ty::Adt(def, ..) = ty.kind {
if let Some(span) = cx.tcx.hir().span_if_local(def.did) {
if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
if can_type_implement_copy(cx.tcx, cx.param_env, ty).is_ok() {
db.span_help(span, "consider marking this type as `Copy`");
}
}

View file

@ -28,6 +28,7 @@ use matches::matches;
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
use rustc::lint::{LateContext, Level, Lint, LintContext};
use rustc::traits;
use rustc::traits::predicate_for_trait_def;
use rustc::ty::{
self,
layout::{self, IntegerExt},
@ -312,7 +313,8 @@ pub fn implements_trait<'a, 'tcx>(
ty_params: &[GenericArg<'tcx>],
) -> bool {
let ty = cx.tcx.erase_regions(&ty);
let obligation = cx.tcx.predicate_for_trait_def(
let obligation = predicate_for_trait_def(
cx.tcx,
cx.param_env,
traits::ObligationCause::dummy(),
trait_id,