Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errors
Remove `#[rustc_host]`, use internal desugaring Also removed a way for users to explicitly specify the host param since that isn't particularly useful. This should eliminate any pain with encoding attributes across crates and etc. r? `@compiler-errors`
This commit is contained in:
commit
f32d29837d
16 changed files with 56 additions and 88 deletions
|
@ -859,7 +859,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
|
|||
hir::GenericParamKind::Lifetime { .. } | hir::GenericParamKind::Type { .. } => Ok(()),
|
||||
|
||||
// Const parameters are well formed if their type is structural match.
|
||||
hir::GenericParamKind::Const { ty: hir_ty, default: _ } => {
|
||||
hir::GenericParamKind::Const { ty: hir_ty, default: _, is_host_effect: _ } => {
|
||||
let ty = tcx.type_of(param.def_id).instantiate_identity();
|
||||
|
||||
if tcx.features().adt_const_params {
|
||||
|
|
|
@ -1383,7 +1383,7 @@ fn impl_trait_ref(
|
|||
let last_segment = path_segments.len() - 1;
|
||||
let mut args = *path_segments[last_segment].args();
|
||||
let last_arg = args.args.len() - 1;
|
||||
assert!(matches!(args.args[last_arg], hir::GenericArg::Const(anon_const) if tcx.has_attr(anon_const.value.def_id, sym::rustc_host)));
|
||||
assert!(matches!(args.args[last_arg], hir::GenericArg::Const(anon_const) if anon_const.is_desugared_from_effects));
|
||||
args.args = &args.args[..args.args.len() - 1];
|
||||
path_segments[last_segment].args = Some(&args);
|
||||
let path = hir::Path {
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc_hir::def_id::LocalDefId;
|
|||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
||||
use rustc_hir::*;
|
||||
|
@ -298,13 +298,11 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
kind,
|
||||
})
|
||||
}
|
||||
GenericParamKind::Const { default, .. } => {
|
||||
let is_host_param = tcx.has_attr(param.def_id, sym::rustc_host);
|
||||
|
||||
GenericParamKind::Const { ty: _, default, is_host_effect } => {
|
||||
if !matches!(allow_defaults, Defaults::Allowed)
|
||||
&& default.is_some()
|
||||
// `rustc_host` effect params are allowed to have defaults.
|
||||
&& !is_host_param
|
||||
// `host` effect params are allowed to have defaults.
|
||||
&& !is_host_effect
|
||||
{
|
||||
tcx.sess.span_err(
|
||||
param.span,
|
||||
|
@ -315,7 +313,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
|
||||
let index = next_index();
|
||||
|
||||
if is_host_param {
|
||||
if is_host_effect {
|
||||
if let Some(idx) = host_effect_index {
|
||||
bug!("parent also has host effect param? index: {idx}, def: {def_id:?}");
|
||||
}
|
||||
|
@ -330,7 +328,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
pure_wrt_drop: param.pure_wrt_drop,
|
||||
kind: ty::GenericParamDefKind::Const {
|
||||
has_default: default.is_some(),
|
||||
is_host_effect: is_host_param,
|
||||
is_host_effect,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -489,7 +487,7 @@ struct AnonConstInParamTyDetector {
|
|||
|
||||
impl<'v> Visitor<'v> for AnonConstInParamTyDetector {
|
||||
fn visit_generic_param(&mut self, p: &'v hir::GenericParam<'v>) {
|
||||
if let GenericParamKind::Const { ty, default: _ } = p.kind {
|
||||
if let GenericParamKind::Const { ty, default: _, is_host_effect: _ } = p.kind {
|
||||
let prev = self.in_param_ty;
|
||||
self.in_param_ty = true;
|
||||
self.visit_ty(ty);
|
||||
|
|
|
@ -992,7 +992,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
self.visit_ty(ty);
|
||||
}
|
||||
}
|
||||
GenericParamKind::Const { ty, default } => {
|
||||
GenericParamKind::Const { ty, default, is_host_effect: _ } => {
|
||||
self.visit_ty(ty);
|
||||
if let Some(default) = default {
|
||||
self.visit_body(self.tcx.hir().body(default.body));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue