Remove constness from TraitPredicate
This commit is contained in:
parent
b0e64a9c09
commit
b07de24a58
@ -15,7 +15,7 @@
|
|||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_middle::traits::Reveal;
|
use rustc_middle::traits::Reveal;
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, BoundConstness, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv,
|
self, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv,
|
||||||
ToPredicate, TraitPredicate, Ty, TyCtxt,
|
ToPredicate, TraitPredicate, Ty, TyCtxt,
|
||||||
};
|
};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
@ -523,7 +523,6 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
|
|||||||
if let ClauseKind::Trait(p) = p.kind().skip_binder()
|
if let ClauseKind::Trait(p) = p.kind().skip_binder()
|
||||||
&& p.trait_ref.def_id == eq_trait_id
|
&& p.trait_ref.def_id == eq_trait_id
|
||||||
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
|
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
|
||||||
&& p.constness == BoundConstness::NotConst
|
|
||||||
{
|
{
|
||||||
// Flag types which already have an `Eq` bound.
|
// Flag types which already have an `Eq` bound.
|
||||||
params[self_ty.index as usize].1 = false;
|
params[self_ty.index as usize].1 = false;
|
||||||
@ -535,7 +534,6 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
|
|||||||
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
|
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
|
||||||
ClauseKind::Trait(TraitPredicate {
|
ClauseKind::Trait(TraitPredicate {
|
||||||
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
|
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
|
||||||
constness: BoundConstness::NotConst,
|
|
||||||
polarity: ImplPolarity::Positive,
|
polarity: ImplPolarity::Positive,
|
||||||
})
|
})
|
||||||
.to_predicate(tcx)
|
.to_predicate(tcx)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, Binder, BoundConstness, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind,
|
self, Binder, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind,
|
||||||
GenericArgsRef, ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults,
|
GenericArgsRef, ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults,
|
||||||
};
|
};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
@ -171,7 +171,6 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
|||||||
= cx.tcx.infer_ctxt().build().type_implements_fn_trait(
|
= cx.tcx.infer_ctxt().build().type_implements_fn_trait(
|
||||||
cx.param_env,
|
cx.param_env,
|
||||||
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
|
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
|
||||||
BoundConstness::NotConst,
|
|
||||||
ImplPolarity::Positive,
|
ImplPolarity::Positive,
|
||||||
) && path_to_local(callee)
|
) && path_to_local(callee)
|
||||||
.map_or(
|
.map_or(
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
};
|
};
|
||||||
use rustc_middle::traits::{ImplSource, ObligationCause, BuiltinImplSource};
|
use rustc_middle::traits::{ImplSource, ObligationCause, BuiltinImplSource};
|
||||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||||
use rustc_middle::ty::{self, BoundConstness, GenericArgKind, TraitRef, Ty, TyCtxt};
|
use rustc_middle::ty::{self, GenericArgKind, TraitRef, Ty, TyCtxt};
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
@ -399,11 +399,12 @@ fn is_ty_const_destruct_unused<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Bod
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(effects) constness
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
tcx,
|
tcx,
|
||||||
ObligationCause::dummy_with_span(body.span),
|
ObligationCause::dummy_with_span(body.span),
|
||||||
ConstCx::new(tcx, body).param_env,
|
ConstCx::new(tcx, body).param_env,
|
||||||
TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]).with_constness(BoundConstness::ConstIfConst),
|
TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let infcx = tcx.infer_ctxt().build();
|
let infcx = tcx.infer_ctxt().build();
|
||||||
|
@ -267,7 +267,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
|||||||
cause: ObligationCause::dummy(),
|
cause: ObligationCause::dummy(),
|
||||||
param_env,
|
param_env,
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
|
predicate: ty::Binder::dummy(trait_ref).to_predicate(tcx),
|
||||||
};
|
};
|
||||||
infcx
|
infcx
|
||||||
.evaluate_obligation(&obligation)
|
.evaluate_obligation(&obligation)
|
||||||
|
Loading…
Reference in New Issue
Block a user