diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-01-09 00:19:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-09 00:19:36 +0100 |
| commit | cd93114debd864b5100a71f3f67fa13e943c8d8e (patch) | |
| tree | 46992067f7b02cf1885eef88cadbf2f6f927cc1b /compiler/rustc_middle | |
| parent | 5efa69d979445dd5c96adbb8981508afd3be2aa1 (diff) | |
| parent | e651f6f029c138004583028df3961e1b24636a07 (diff) | |
Rollup merge of #119725 - compiler-errors:has_effect_param, r=fmease
Add helper for when we want to know if an item has a host param r? ````@fmease```` since you're a good reviewer and no good deed goes unpunished This helper will see far more usages as built-in traits get constified.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index b9c75bd205b..f2a33429bd7 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1,7 +1,7 @@ //! Miscellaneous type-system utilities that are too small to deserve their own modules. use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; -use crate::query::Providers; +use crate::query::{IntoQueryParam, Providers}; use crate::ty::layout::IntegerExt; use crate::ty::{ self, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, @@ -786,6 +786,13 @@ impl<'tcx> TyCtxt<'tcx> { || self.extern_crate(key.as_def_id()).is_some_and(|e| e.is_direct()) } + /// Whether the item has a host effect param. This is different from `TyCtxt::is_const`, + /// because the item must also be "maybe const", and the crate where the item is + /// defined must also have the effects feature enabled. + pub fn has_host_param(self, def_id: impl IntoQueryParam<DefId>) -> bool { + self.generics_of(def_id).host_effect_index.is_some() + } + pub fn expected_host_effect_param_for_body(self, def_id: impl Into<DefId>) -> ty::Const<'tcx> { let def_id = def_id.into(); // FIXME(effects): This is suspicious and should probably not be done, |
