Don't compare host param by name
This commit is contained in:
parent
09df6108c8
commit
9917ef9a66
@ -46,10 +46,11 @@ impl<'tcx> Bounds<'tcx> {
|
|||||||
) {
|
) {
|
||||||
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
|
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
|
||||||
|
|
||||||
// if we have a host param, we push an unconst trait bound in addition
|
// push a non-const (`host = true`) version of the bound if it is `~const`.
|
||||||
// to the const one.
|
if tcx.features().effects
|
||||||
// FIXME(effects) we should find a better way than name matching
|
&& let Some(host_effect_idx) = tcx.generics_of(trait_ref.def_id()).host_effect_index
|
||||||
if tcx.features().effects && trait_ref.skip_binder().args.host_effect_param().is_some() {
|
&& trait_ref.skip_binder().args.const_at(host_effect_idx) != tcx.consts.true_
|
||||||
|
{
|
||||||
let generics = tcx.generics_of(trait_ref.def_id());
|
let generics = tcx.generics_of(trait_ref.def_id());
|
||||||
let Some(host_index) = generics.host_effect_index else { return };
|
let Some(host_index) = generics.host_effect_index else { return };
|
||||||
let trait_ref = trait_ref.map_bound(|mut trait_ref| {
|
let trait_ref = trait_ref.map_bound(|mut trait_ref| {
|
||||||
|
@ -786,8 +786,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
tcx.consts.false_
|
tcx.consts.false_
|
||||||
}
|
}
|
||||||
Some(hir::ConstContext::ConstFn) => {
|
Some(hir::ConstContext::ConstFn) => {
|
||||||
let args = ty::GenericArgs::identity_for_item(tcx, context);
|
let host_idx = tcx
|
||||||
args.host_effect_param().expect("ConstContext::Maybe must have host effect param")
|
.generics_of(context)
|
||||||
|
.host_effect_index
|
||||||
|
.expect("ConstContext::Maybe must have host effect param");
|
||||||
|
ty::GenericArgs::identity_for_item(tcx, context).const_at(host_idx)
|
||||||
}
|
}
|
||||||
None => tcx.consts.true_,
|
None => tcx.consts.true_,
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,6 @@ use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
|||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_serialize::{self, Decodable, Encodable};
|
use rustc_serialize::{self, Decodable, Encodable};
|
||||||
use rustc_span::sym;
|
|
||||||
use rustc_type_ir::WithCachedTypeInfo;
|
use rustc_type_ir::WithCachedTypeInfo;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
@ -452,10 +451,6 @@ impl<'tcx> GenericArgs<'tcx> {
|
|||||||
tcx.mk_args_from_iter(self.iter().take(generics.count()))
|
tcx.mk_args_from_iter(self.iter().take(generics.count()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn host_effect_param(&'tcx self) -> Option<ty::Const<'tcx>> {
|
|
||||||
self.consts().rfind(|x| matches!(x.kind(), ty::ConstKind::Param(p) if p.name == sym::host))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn print_as_list(&self) -> String {
|
pub fn print_as_list(&self) -> String {
|
||||||
let v = self.iter().map(|arg| arg.to_string()).collect::<Vec<_>>();
|
let v = self.iter().map(|arg| arg.to_string()).collect::<Vec<_>>();
|
||||||
format!("[{}]", v.join(", "))
|
format!("[{}]", v.join(", "))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user