Refactor path lowering

And add a new diagnostic for non-`Fn` parenthesized generic args.

Path lowering started to look like a mess, with each function carrying additional parameters for the diagnostic callback (since paths can occur both in type and in expression/pattern position, and their diagnostic handling is different) and the segment index, for the diagnostics report. So I refactored it from stateless functions on `TyLoweringContext` into stateful struct, `PathLoweringContext`, that tracks the process of lowering a path from resolution til assoc types selection.
This commit is contained in:
Chayim Refael Friedman 2025-02-10 11:33:02 +02:00
parent 8ea61356a9
commit 55c04ab371
18 changed files with 1220 additions and 1132 deletions

View file

@ -647,18 +647,21 @@ pub mod ops {
#[lang = "fn"]
#[fundamental]
#[rustc_paren_sugar]
pub trait Fn<Args: Tuple>: FnMut<Args> {
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
}
#[lang = "fn_mut"]
#[fundamental]
#[rustc_paren_sugar]
pub trait FnMut<Args: Tuple>: FnOnce<Args> {
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
}
#[lang = "fn_once"]
#[fundamental]
#[rustc_paren_sugar]
pub trait FnOnce<Args: Tuple> {
#[lang = "fn_once_output"]
type Output;
@ -736,12 +739,14 @@ pub mod ops {
#[lang = "async_fn"]
#[fundamental]
#[rustc_paren_sugar]
pub trait AsyncFn<Args: Tuple>: AsyncFnMut<Args> {
extern "rust-call" fn async_call(&self, args: Args) -> Self::CallRefFuture<'_>;
}
#[lang = "async_fn_mut"]
#[fundamental]
#[rustc_paren_sugar]
pub trait AsyncFnMut<Args: Tuple>: AsyncFnOnce<Args> {
#[lang = "call_ref_future"]
type CallRefFuture<'a>: Future<Output = Self::Output>
@ -752,6 +757,7 @@ pub mod ops {
#[lang = "async_fn_once"]
#[fundamental]
#[rustc_paren_sugar]
pub trait AsyncFnOnce<Args: Tuple> {
#[lang = "async_fn_once_output"]
type Output;