Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
845da88
refactor: remove Ord bound from BinaryHeap::new etc
aatifsyed Nov 28, 2025
fcf2426
fix: BinaryHeap<T: Ord>::peek_mut
aatifsyed Nov 28, 2025
9156b54
Update to_uppercase docs to avoid ß->SS example
guilhermeljs Jan 9, 2026
c10f0dd
Add comment to clarify that 'ffi' is a single Unicode code point mappin…
guilhermeljs Jan 10, 2026
6b5a1a5
Switch from ffi to ſt ligature for better visual clarity
guilhermeljs Jan 12, 2026
c98b90e
std: Change UEFI env vars to volatile storage
nicholasbishop Jan 12, 2026
cafe917
On unmet trait bound, mention if trait is unstable
estebank Jan 12, 2026
89713fc
Mention `Range` when `Step` trait bound is unmet
estebank Jan 12, 2026
45edce2
Update rustc_on_unimplemented message for `Step`
estebank Jan 13, 2026
37afa31
Remove all usage of FeedConstTy::No
mu001999 Jan 10, 2026
6d837ae
Remove FeedConstTy
mu001999 Jan 11, 2026
bf423e7
Bless tests
mu001999 Jan 11, 2026
d95613a
Fix review comments
mu001999 Jan 12, 2026
4708985
Update run-make test output
estebank Jan 13, 2026
9b7f612
Update main label
estebank Jan 13, 2026
e259373
std: move `errno` and related functions into `sys::io`
joboet Jan 6, 2026
0f25fca
update import in UI test
joboet Jan 6, 2026
d1c2e5c
Add test for issue 151048
mu001999 Jan 13, 2026
8afa95d
Avoid should-fail in two ui tests
bjorn3 Jan 13, 2026
15112ee
Avoid should-fail in a codegen-llvm test
bjorn3 Jan 13, 2026
27e09ce
Update ui-fulldeps --stage 2 tests
estebank Jan 13, 2026
814647f
Change some `matches!(.., .. if ..)` with let-chains
estebank Dec 26, 2025
c4820e6
resolve: Refactor away the side table `decl_parent_modules`
petrochenkov Jan 9, 2026
5435e81
also handle ENOTTY ioctl errors when checking pidfd -> pid support
the8472 Jan 13, 2026
1fe705c
Mention the type in the label, to avoid confusion at the cost of redu…
estebank Jan 13, 2026
15d8e9e
Recognize potential `impl<const N: usize>` to `impl<N>` mistake
estebank Jan 13, 2026
3aa3178
Remove `Deref`/`DerefMut` impl for `Providers`.
nnethercote Jan 13, 2026
e7299e8
Rollup merge of #149408 - aatifsyed/binary-heap-no-ord, r=tgross35,dt…
JonathanBrouwer Jan 14, 2026
84e4804
Rollup merge of #150406 - matches-let-chain, r=Kivooeo,oli-obk,BoxyUw…
JonathanBrouwer Jan 14, 2026
c35c6aa
Rollup merge of #150723 - move_pal_error, r=@tgross35
JonathanBrouwer Jan 14, 2026
634b594
Rollup merge of #150877 - declmod, r=nnethercote
JonathanBrouwer Jan 14, 2026
f3ca16b
Rollup merge of #150902 - docs-150888-to_uppercase, r=Noratrieb,worki…
JonathanBrouwer Jan 14, 2026
09a00e9
Rollup merge of #150962 - rm/feed_const_ty, r=BoxyUwU
JonathanBrouwer Jan 14, 2026
51f17dd
Rollup merge of #151034 - bishop-fix-nv, r=joboet
JonathanBrouwer Jan 14, 2026
d4c6cf4
Rollup merge of #151036 - issue-151026, r=mati865
JonathanBrouwer Jan 14, 2026
b4931b9
Rollup merge of #151067 - ui_test_no_should_fail, r=lqd
JonathanBrouwer Jan 14, 2026
2c56a5d
Rollup merge of #151072 - fix-pidfd-ioctl, r=jhpratt
JonathanBrouwer Jan 14, 2026
c45ca8a
Rollup merge of #151077 - issue-84327, r=fmease
JonathanBrouwer Jan 14, 2026
09a1243
Rollup merge of #151096 - rm-providers-deref, r=oli-obk
JonathanBrouwer Jan 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove FeedConstTy
  • Loading branch information
mu001999 committed Jan 13, 2026
commit 6d837ae9c7660ce82d63af3b622c0fbb976b09cb
8 changes: 3 additions & 5 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ use rustc_trait_selection::traits::{
use tracing::{debug, instrument};

use crate::errors;
use crate::hir_ty_lowering::{
FeedConstTy, HirTyLowerer, InherentAssocCandidate, RegionInferReason,
};
use crate::hir_ty_lowering::{HirTyLowerer, InherentAssocCandidate, RegionInferReason};

pub(crate) mod dump;
mod generics_of;
Expand Down Expand Up @@ -1499,7 +1497,7 @@ fn const_param_default<'tcx>(

let ct = icx
.lowerer()
.lower_const_arg(default_ct, FeedConstTy::with_type_of(tcx, def_id, identity_args));
.lower_const_arg(default_ct, tcx.type_of(def_id).instantiate(tcx, identity_args));
ty::EarlyBinder::bind(ct)
}

Expand Down Expand Up @@ -1557,7 +1555,7 @@ fn const_of_item<'tcx>(
let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id);
let ct = icx
.lowerer()
.lower_const_arg(ct_arg, FeedConstTy::with_type_of(tcx, def_id.to_def_id(), identity_args));
.lower_const_arg(ct_arg, tcx.type_of(def_id.to_def_id()).instantiate(tcx, identity_args));
if let Err(e) = icx.check_tainted_by_errors()
&& !ct.references_error()
{
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use tracing::{debug, instrument};

use crate::errors;
use crate::hir_ty_lowering::{
AssocItemQSelf, FeedConstTy, GenericsArgsErrExtend, HirTyLowerer, ImpliedBoundsContext,
AssocItemQSelf, GenericsArgsErrExtend, HirTyLowerer, ImpliedBoundsContext,
OverlappingAsssocItemConstraints, PredicateFilter, RegionInferReason,
};

Expand Down Expand Up @@ -543,7 +543,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let term = match term {
hir::Term::Ty(ty) => self.lower_ty(ty).into(),
hir::Term::Const(ct) => {
// Provide the resolved type of the associated constant
let ty = projection_term.map_bound(|alias| {
tcx.type_of(alias.def_id).instantiate(tcx, alias.args)
});
Expand All @@ -554,7 +553,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
constraint.hir_id,
);

self.lower_const_arg(ct, FeedConstTy::WithTy(ty)).into()
self.lower_const_arg(ct, ty).into()
}
};

Expand Down
89 changes: 21 additions & 68 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,35 +253,6 @@ impl AssocItemQSelf {
}
}

/// In some cases, [`hir::ConstArg`]s that are being used in the type system
/// through const generics need to have their type "fed" to them
/// using the query system.
///
/// Use this enum with `<dyn HirTyLowerer>::lower_const_arg` to instruct it with the
/// desired behavior.
#[derive(Debug, Clone, Copy)]
pub enum FeedConstTy<'tcx> {
/// Feed the type to the (anno) const arg.
WithTy(Ty<'tcx>),
/// Don't feed the type.
No,
}

impl<'tcx> FeedConstTy<'tcx> {
/// The `DefId` belongs to the const param that we are supplying
/// this (anon) const arg to.
///
/// The list of generic args is used to instantiate the parameters
/// used by the type of the const param specified by `DefId`.
pub fn with_type_of(
tcx: TyCtxt<'tcx>,
def_id: DefId,
generic_args: &[ty::GenericArg<'tcx>],
) -> Self {
Self::WithTy(tcx.type_of(def_id).instantiate(tcx, generic_args))
}
}

#[derive(Debug, Clone, Copy)]
enum LowerTypeRelativePathMode {
Type(PermitVariants),
Expand Down Expand Up @@ -733,7 +704,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// Ambig portions of `ConstArg` are handled in the match arm below
.lower_const_arg(
ct.as_unambig_ct(),
FeedConstTy::with_type_of(tcx, param.def_id, preceding_args),
tcx.type_of(param.def_id).instantiate(tcx, preceding_args),
)
.into(),
(&GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => {
Expand Down Expand Up @@ -1322,7 +1293,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
constraint.hir_id,
);

self.lower_const_arg(ct, FeedConstTy::WithTy(ty)).into()
self.lower_const_arg(ct, ty).into()
}
};
if term.references_error() {
Expand Down Expand Up @@ -2347,16 +2318,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

/// Lower a [`hir::ConstArg`] to a (type-level) [`ty::Const`](Const).
#[instrument(skip(self), level = "debug")]
pub fn lower_const_arg(
&self,
const_arg: &hir::ConstArg<'tcx>,
feed: FeedConstTy<'tcx>,
) -> Const<'tcx> {
pub fn lower_const_arg(&self, const_arg: &hir::ConstArg<'tcx>, ty: Ty<'tcx>) -> Const<'tcx> {
let tcx = self.tcx();

if let FeedConstTy::WithTy(anon_const_type) = feed
&& let hir::ConstArgKind::Anon(anon) = &const_arg.kind
{
if let hir::ConstArgKind::Anon(anon) = &const_arg.kind {
// FIXME(generic_const_parameter_types): Ideally we remove these errors below when
// we have the ability to intermix typeck of anon const const args with the parent
// bodies typeck.
Expand All @@ -2366,7 +2331,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// hir typeck was using equality but mir borrowck wound up using subtyping as that could
// result in a non-infer in hir typeck but a region variable in borrowck.
if tcx.features().generic_const_parameter_types()
&& (anon_const_type.has_free_regions() || anon_const_type.has_erased_regions())
&& (ty.has_free_regions() || ty.has_erased_regions())
{
let e = self.dcx().span_err(
const_arg.span,
Expand All @@ -2378,7 +2343,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// We must error if the instantiated type has any inference variables as we will
// use this type to feed the `type_of` and query results must not contain inference
// variables otherwise we will ICE.
if anon_const_type.has_non_region_infer() {
if ty.has_non_region_infer() {
let e = self.dcx().span_err(
const_arg.span,
"anonymous constants with inferred types are not yet supported",
Expand All @@ -2388,7 +2353,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
// We error when the type contains unsubstituted generics since we do not currently
// give the anon const any of the generics from the parent.
if anon_const_type.has_non_region_param() {
if ty.has_non_region_param() {
let e = self.dcx().span_err(
const_arg.span,
"anonymous constants referencing generics are not yet supported",
Expand All @@ -2397,12 +2362,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
return ty::Const::new_error(tcx, e);
}

tcx.feed_anon_const_type(anon.def_id, ty::EarlyBinder::bind(anon_const_type));
tcx.feed_anon_const_type(anon.def_id, ty::EarlyBinder::bind(ty));
}

let hir_id = const_arg.hir_id;
match const_arg.kind {
hir::ConstArgKind::Tup(exprs) => self.lower_const_arg_tup(exprs, feed, const_arg.span),
hir::ConstArgKind::Tup(exprs) => self.lower_const_arg_tup(exprs, ty, const_arg.span),
hir::ConstArgKind::Path(hir::QPath::Resolved(maybe_qself, path)) => {
debug!(?maybe_qself, ?path);
let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
Expand All @@ -2426,31 +2391,23 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
hir::ConstArgKind::TupleCall(qpath, args) => {
self.lower_const_arg_tuple_call(hir_id, qpath, args, const_arg.span)
}
hir::ConstArgKind::Array(array_expr) => self.lower_const_arg_array(array_expr, feed),
hir::ConstArgKind::Array(array_expr) => self.lower_const_arg_array(array_expr, ty),
hir::ConstArgKind::Anon(anon) => self.lower_const_arg_anon(anon),
hir::ConstArgKind::Infer(()) => self.ct_infer(None, const_arg.span),
hir::ConstArgKind::Error(e) => ty::Const::new_error(tcx, e),
hir::ConstArgKind::Literal(kind) if let FeedConstTy::WithTy(anon_const_type) = feed => {
self.lower_const_arg_literal(&kind, anon_const_type, const_arg.span)
}
hir::ConstArgKind::Literal(..) => {
let e = self.dcx().span_err(const_arg.span, "literal of unknown type");
ty::Const::new_error(tcx, e)
hir::ConstArgKind::Literal(kind) => {
self.lower_const_arg_literal(&kind, ty, const_arg.span)
}
}
}

fn lower_const_arg_array(
&self,
array_expr: &'tcx hir::ConstArgArrayExpr<'tcx>,
feed: FeedConstTy<'tcx>,
ty: Ty<'tcx>,
) -> Const<'tcx> {
let tcx = self.tcx();

let FeedConstTy::WithTy(ty) = feed else {
return Const::new_error_with_message(tcx, array_expr.span, "unsupported const array");
};

let ty::Array(elem_ty, _) = ty.kind() else {
return Const::new_error_with_message(
tcx,
Expand All @@ -2462,7 +2419,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let elems = array_expr
.elems
.iter()
.map(|elem| self.lower_const_arg(elem, FeedConstTy::WithTy(*elem_ty)))
.map(|elem| self.lower_const_arg(elem, *elem_ty))
.collect::<Vec<_>>();

let valtree = ty::ValTree::from_branches(tcx, elems);
Expand Down Expand Up @@ -2545,7 +2502,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.iter()
.zip(args)
.map(|(field_def, arg)| {
self.lower_const_arg(arg, FeedConstTy::with_type_of(tcx, field_def.did, adt_args))
self.lower_const_arg(arg, tcx.type_of(field_def.did).instantiate(tcx, adt_args))
})
.collect::<Vec<_>>();

Expand All @@ -2564,15 +2521,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_const_arg_tup(
&self,
exprs: &'tcx [&'tcx hir::ConstArg<'tcx>],
feed: FeedConstTy<'tcx>,
ty: Ty<'tcx>,
span: Span,
) -> Const<'tcx> {
let tcx = self.tcx();

let FeedConstTy::WithTy(ty) = feed else {
return Const::new_error_with_message(tcx, span, "const tuple lack type information");
};

let ty::Tuple(tys) = ty.kind() else {
let e = tcx.dcx().span_err(span, format!("expected `{}`, found const tuple", ty));
return Const::new_error(tcx, e);
Expand All @@ -2581,7 +2534,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let exprs = exprs
.iter()
.zip(tys.iter())
.map(|(expr, ty)| self.lower_const_arg(expr, FeedConstTy::WithTy(ty)))
.map(|(expr, ty)| self.lower_const_arg(expr, ty))
.collect::<Vec<_>>();

let valtree = ty::ValTree::from_branches(tcx, exprs);
Expand Down Expand Up @@ -2668,7 +2621,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

self.lower_const_arg(
expr.expr,
FeedConstTy::with_type_of(tcx, field_def.did, adt_args),
tcx.type_of(field_def.did).instantiate(tcx, adt_args),
)
}
None => {
Expand Down Expand Up @@ -3030,7 +2983,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
}
hir::TyKind::Array(ty, length) => {
let length = self.lower_const_arg(length, FeedConstTy::WithTy(tcx.types.usize));
let length = self.lower_const_arg(length, tcx.types.usize);
Ty::new_array_with_const_len(tcx, self.lower_ty(ty), length)
}
hir::TyKind::Infer(()) => {
Expand Down Expand Up @@ -3070,8 +3023,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// Keep this list of types in sync with the list of types that
// the `RangePattern` trait is implemented for.
ty::Int(_) | ty::Uint(_) | ty::Char => {
let start = self.lower_const_arg(start, FeedConstTy::WithTy(ty));
let end = self.lower_const_arg(end, FeedConstTy::WithTy(ty));
let start = self.lower_const_arg(start, ty);
let end = self.lower_const_arg(end, ty);
Ok(ty::PatternKind::Range { start, end })
}
_ => Err(self
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::traits;

pub use crate::collect::suggest_impl_trait;
use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
use crate::hir_ty_lowering::HirTyLowerer;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

Expand Down Expand Up @@ -301,8 +301,8 @@ pub fn lower_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
pub fn lower_const_arg_for_rustdoc<'tcx>(
tcx: TyCtxt<'tcx>,
hir_ct: &hir::ConstArg<'tcx>,
feed: FeedConstTy<'tcx>,
ty: Ty<'tcx>,
) -> Const<'tcx> {
let env_def_id = tcx.hir_get_parent_item(hir_ct.hir_id);
collect::ItemCtxt::new(tcx, env_def_id.def_id).lowerer().lower_const_arg(hir_ct, feed)
collect::ItemCtxt::new(tcx, env_def_id.def_id).lowerer().lower_const_arg(hir_ct, ty)
}
7 changes: 2 additions & 5 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{ExprKind, HirId, QPath, find_attr, is_range_literal};
use rustc_hir_analysis::NoVariantNamed;
use rustc_hir_analysis::hir_ty_lowering::{FeedConstTy, HirTyLowerer as _};
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _;
use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, RegionVariableOrigin};
use rustc_infer::traits::query::NoSolution;
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase};
Expand Down Expand Up @@ -1749,10 +1749,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let count_span = count.span;
let count = self.try_structurally_resolve_const(
count_span,
self.normalize(
count_span,
self.lower_const_arg(count, FeedConstTy::WithTy(tcx.types.usize)),
),
self.normalize(count_span, self.lower_const_arg(count, tcx.types.usize)),
);

if let Some(count) = count.try_to_target_usize(tcx) {
Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use rustc_hir_analysis::hir_ty_lowering::generics::{
check_generic_arg_count_for_call, lower_generic_args,
};
use rustc_hir_analysis::hir_ty_lowering::{
ExplicitLateBound, FeedConstTy, GenericArgCountMismatch, GenericArgCountResult,
GenericArgsLowerer, GenericPathSegment, HirTyLowerer, IsMethodCall, RegionInferReason,
ExplicitLateBound, GenericArgCountMismatch, GenericArgCountResult, GenericArgsLowerer,
GenericPathSegment, HirTyLowerer, IsMethodCall, RegionInferReason,
};
use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse};
use rustc_infer::infer::{DefineOpaqueTypes, InferResult};
Expand Down Expand Up @@ -525,9 +525,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(crate) fn lower_const_arg(
&self,
const_arg: &'tcx hir::ConstArg<'tcx>,
feed: FeedConstTy<'tcx>,
ty: Ty<'tcx>,
) -> ty::Const<'tcx> {
let ct = self.lowerer().lower_const_arg(const_arg, feed);
let ct = self.lowerer().lower_const_arg(const_arg, ty);
self.register_wf_obligation(
ct.into(),
self.tcx.hir_span(const_arg.hir_id),
Expand Down Expand Up @@ -1228,7 +1228,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Ambiguous parts of `ConstArg` are handled in the match arms below
.lower_const_arg(
ct.as_unambig_ct(),
FeedConstTy::with_type_of(self.fcx.tcx, param.def_id, preceding_args),
self.fcx
.tcx
.type_of(param.def_id)
.instantiate(self.fcx.tcx, preceding_args),
)
.into(),
(&GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => {
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_hir_typeck/src/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_hir_analysis::hir_ty_lowering::generics::{
check_generic_arg_count_for_call, lower_generic_args,
};
use rustc_hir_analysis::hir_ty_lowering::{
FeedConstTy, GenericArgsLowerer, HirTyLowerer, IsMethodCall, RegionInferReason,
GenericArgsLowerer, HirTyLowerer, IsMethodCall, RegionInferReason,
};
use rustc_infer::infer::{
BoundRegionConversionTime, DefineOpaqueTypes, InferOk, RegionVariableOrigin,
Expand Down Expand Up @@ -447,7 +447,10 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
// We handle the ambig portions of `ConstArg` in the match arms below
.lower_const_arg(
ct.as_unambig_ct(),
FeedConstTy::with_type_of(self.cfcx.tcx, param.def_id, preceding_args),
self.cfcx
.tcx
.type_of(param.def_id)
.instantiate(self.cfcx.tcx, preceding_args),
)
.into(),
(GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => {
Expand Down
Loading