Skip to content

Commit 822aa66

Browse files
Don't compare host param by name
1 parent 09df610 commit 822aa66

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Diff for: compiler/rustc_hir_typeck/src/callee.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
786786
tcx.consts.false_
787787
}
788788
Some(hir::ConstContext::ConstFn) => {
789-
let args = ty::GenericArgs::identity_for_item(tcx, context);
790-
args.host_effect_param().expect("ConstContext::Maybe must have host effect param")
789+
let host_idx = tcx
790+
.generics_of(context)
791+
.host_effect_index
792+
.expect("ConstContext::Maybe must have host effect param");
793+
ty::GenericArgs::identity_for_item(tcx, context).const_at(host_idx)
791794
}
792795
None => tcx.consts.true_,
793796
};

Diff for: compiler/rustc_middle/src/ty/generic_args.rs

-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
1111
use rustc_hir::def_id::DefId;
1212
use rustc_macros::HashStable;
1313
use rustc_serialize::{self, Decodable, Encodable};
14-
use rustc_span::sym;
1514
use rustc_type_ir::WithCachedTypeInfo;
1615
use smallvec::SmallVec;
1716

@@ -452,10 +451,6 @@ impl<'tcx> GenericArgs<'tcx> {
452451
tcx.mk_args_from_iter(self.iter().take(generics.count()))
453452
}
454453

455-
pub fn host_effect_param(&'tcx self) -> Option<ty::Const<'tcx>> {
456-
self.consts().rfind(|x| matches!(x.kind(), ty::ConstKind::Param(p) if p.name == sym::host))
457-
}
458-
459454
pub fn print_as_list(&self) -> String {
460455
let v = self.iter().map(|arg| arg.to_string()).collect::<Vec<_>>();
461456
format!("[{}]", v.join(", "))

0 commit comments

Comments
 (0)