Rollup merge of #131931 - compiler-errors:constness-valid, r=fmease
Remove unnecessary constness from `lower_generic_args_of_path` We pass `NotConst` to all callsites of `lower_generic_args_of_path` except for `lower_poly_trait_ref`, so let's not do that.
This commit is contained in:
commit
426e90682e
@ -516,7 +516,6 @@ pub fn lower_ty_maybe_return_type_notation(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<
|
|||||||
self_ty,
|
self_ty,
|
||||||
trait_segment,
|
trait_segment,
|
||||||
false,
|
false,
|
||||||
ty::BoundConstness::NotConst,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// SUBTLE: As noted at the end of `try_append_return_type_notation_params`
|
// SUBTLE: As noted at the end of `try_append_return_type_notation_params`
|
||||||
|
@ -336,14 +336,7 @@ pub fn lower_generic_args_of_path_segment(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
item_segment: &hir::PathSegment<'tcx>,
|
item_segment: &hir::PathSegment<'tcx>,
|
||||||
) -> GenericArgsRef<'tcx> {
|
) -> GenericArgsRef<'tcx> {
|
||||||
let (args, _) = self.lower_generic_args_of_path(
|
let (args, _) = self.lower_generic_args_of_path(span, def_id, &[], item_segment, None);
|
||||||
span,
|
|
||||||
def_id,
|
|
||||||
&[],
|
|
||||||
item_segment,
|
|
||||||
None,
|
|
||||||
ty::BoundConstness::NotConst,
|
|
||||||
);
|
|
||||||
if let Some(c) = item_segment.args().constraints.first() {
|
if let Some(c) = item_segment.args().constraints.first() {
|
||||||
prohibit_assoc_item_constraint(self, c, Some((def_id, item_segment, span)));
|
prohibit_assoc_item_constraint(self, c, Some((def_id, item_segment, span)));
|
||||||
}
|
}
|
||||||
@ -392,7 +385,6 @@ fn lower_generic_args_of_path(
|
|||||||
parent_args: &[ty::GenericArg<'tcx>],
|
parent_args: &[ty::GenericArg<'tcx>],
|
||||||
segment: &hir::PathSegment<'tcx>,
|
segment: &hir::PathSegment<'tcx>,
|
||||||
self_ty: Option<Ty<'tcx>>,
|
self_ty: Option<Ty<'tcx>>,
|
||||||
constness: ty::BoundConstness,
|
|
||||||
) -> (GenericArgsRef<'tcx>, GenericArgCountResult) {
|
) -> (GenericArgsRef<'tcx>, GenericArgCountResult) {
|
||||||
// If the type is parameterized by this region, then replace this
|
// If the type is parameterized by this region, then replace this
|
||||||
// region with the current anon region binding (in other words,
|
// region with the current anon region binding (in other words,
|
||||||
@ -415,7 +407,7 @@ fn lower_generic_args_of_path(
|
|||||||
assert!(self_ty.is_none());
|
assert!(self_ty.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut arg_count = check_generic_arg_count(
|
let arg_count = check_generic_arg_count(
|
||||||
self,
|
self,
|
||||||
def_id,
|
def_id,
|
||||||
segment,
|
segment,
|
||||||
@ -573,16 +565,6 @@ fn inferred_kind(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness
|
|
||||||
&& generics.has_self
|
|
||||||
&& !tcx.is_const_trait(def_id)
|
|
||||||
{
|
|
||||||
let reported = self.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait {
|
|
||||||
span,
|
|
||||||
modifier: constness.as_str(),
|
|
||||||
});
|
|
||||||
arg_count.correct = Err(GenericArgCountMismatch { reported, invalid_args: vec![] });
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut args_ctx = GenericArgsCtxt {
|
let mut args_ctx = GenericArgsCtxt {
|
||||||
lowerer: self,
|
lowerer: self,
|
||||||
@ -614,14 +596,8 @@ pub fn lower_generic_args_of_assoc_item(
|
|||||||
parent_args: GenericArgsRef<'tcx>,
|
parent_args: GenericArgsRef<'tcx>,
|
||||||
) -> GenericArgsRef<'tcx> {
|
) -> GenericArgsRef<'tcx> {
|
||||||
debug!(?span, ?item_def_id, ?item_segment);
|
debug!(?span, ?item_def_id, ?item_segment);
|
||||||
let (args, _) = self.lower_generic_args_of_path(
|
let (args, _) =
|
||||||
span,
|
self.lower_generic_args_of_path(span, item_def_id, parent_args, item_segment, None);
|
||||||
item_def_id,
|
|
||||||
parent_args,
|
|
||||||
item_segment,
|
|
||||||
None,
|
|
||||||
ty::BoundConstness::NotConst,
|
|
||||||
);
|
|
||||||
if let Some(c) = item_segment.args().constraints.first() {
|
if let Some(c) = item_segment.args().constraints.first() {
|
||||||
prohibit_assoc_item_constraint(self, c, Some((item_def_id, item_segment, span)));
|
prohibit_assoc_item_constraint(self, c, Some((item_def_id, item_segment, span)));
|
||||||
}
|
}
|
||||||
@ -647,7 +623,6 @@ pub fn lower_impl_trait_ref(
|
|||||||
self_ty,
|
self_ty,
|
||||||
trait_ref.path.segments.last().unwrap(),
|
trait_ref.path.segments.last().unwrap(),
|
||||||
true,
|
true,
|
||||||
ty::BoundConstness::NotConst,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,9 +675,17 @@ pub(crate) fn lower_poly_trait_ref(
|
|||||||
&[],
|
&[],
|
||||||
trait_segment,
|
trait_segment,
|
||||||
Some(self_ty),
|
Some(self_ty),
|
||||||
constness,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness
|
||||||
|
&& !self.tcx().is_const_trait(trait_def_id)
|
||||||
|
{
|
||||||
|
self.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait {
|
||||||
|
span: trait_ref.path.span,
|
||||||
|
modifier: constness.as_str(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let bound_vars = tcx.late_bound_vars(trait_ref.hir_ref_id);
|
let bound_vars = tcx.late_bound_vars(trait_ref.hir_ref_id);
|
||||||
debug!(?bound_vars);
|
debug!(?bound_vars);
|
||||||
@ -762,19 +745,11 @@ fn lower_mono_trait_ref(
|
|||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
trait_segment: &hir::PathSegment<'tcx>,
|
trait_segment: &hir::PathSegment<'tcx>,
|
||||||
is_impl: bool,
|
is_impl: bool,
|
||||||
// FIXME(effects): Move all host param things in HIR ty lowering to AST lowering.
|
|
||||||
constness: ty::BoundConstness,
|
|
||||||
) -> ty::TraitRef<'tcx> {
|
) -> ty::TraitRef<'tcx> {
|
||||||
self.complain_about_internal_fn_trait(span, trait_def_id, trait_segment, is_impl);
|
self.complain_about_internal_fn_trait(span, trait_def_id, trait_segment, is_impl);
|
||||||
|
|
||||||
let (generic_args, _) = self.lower_generic_args_of_path(
|
let (generic_args, _) =
|
||||||
span,
|
self.lower_generic_args_of_path(span, trait_def_id, &[], trait_segment, Some(self_ty));
|
||||||
trait_def_id,
|
|
||||||
&[],
|
|
||||||
trait_segment,
|
|
||||||
Some(self_ty),
|
|
||||||
constness,
|
|
||||||
);
|
|
||||||
if let Some(c) = trait_segment.args().constraints.first() {
|
if let Some(c) = trait_segment.args().constraints.first() {
|
||||||
prohibit_assoc_item_constraint(self, c, Some((trait_def_id, trait_segment, span)));
|
prohibit_assoc_item_constraint(self, c, Some((trait_def_id, trait_segment, span)));
|
||||||
}
|
}
|
||||||
@ -1542,7 +1517,6 @@ fn lower_qpath(
|
|||||||
item_def_id: DefId,
|
item_def_id: DefId,
|
||||||
trait_segment: &hir::PathSegment<'tcx>,
|
trait_segment: &hir::PathSegment<'tcx>,
|
||||||
item_segment: &hir::PathSegment<'tcx>,
|
item_segment: &hir::PathSegment<'tcx>,
|
||||||
constness: ty::BoundConstness,
|
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
|
|
||||||
@ -1555,7 +1529,7 @@ fn lower_qpath(
|
|||||||
debug!(?self_ty);
|
debug!(?self_ty);
|
||||||
|
|
||||||
let trait_ref =
|
let trait_ref =
|
||||||
self.lower_mono_trait_ref(span, trait_def_id, self_ty, trait_segment, false, constness);
|
self.lower_mono_trait_ref(span, trait_def_id, self_ty, trait_segment, false);
|
||||||
debug!(?trait_ref);
|
debug!(?trait_ref);
|
||||||
|
|
||||||
let item_args =
|
let item_args =
|
||||||
@ -1918,7 +1892,6 @@ pub fn lower_path(
|
|||||||
def_id,
|
def_id,
|
||||||
&path.segments[path.segments.len() - 2],
|
&path.segments[path.segments.len() - 2],
|
||||||
path.segments.last().unwrap(),
|
path.segments.last().unwrap(),
|
||||||
ty::BoundConstness::NotConst,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Res::PrimTy(prim_ty) => {
|
Res::PrimTy(prim_ty) => {
|
||||||
@ -2151,7 +2124,6 @@ pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
|
|||||||
&[],
|
&[],
|
||||||
&hir::PathSegment::invalid(),
|
&hir::PathSegment::invalid(),
|
||||||
None,
|
None,
|
||||||
ty::BoundConstness::NotConst,
|
|
||||||
);
|
);
|
||||||
tcx.at(span).type_of(def_id).instantiate(tcx, args)
|
tcx.at(span).type_of(def_id).instantiate(tcx, args)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user