unsure whether to file this under min_generic_const_args, adt_const_params, inherent_associated_types, or something else ;-;
discovered when investigating how to progress with inherent_associated_types
//@ check-pass
#![feature(min_generic_const_args, adt_const_params)]
#![expect(incomplete_features)]
use std::marker::ConstParamTy;
#[derive(PartialEq, Eq, ConstParamTy)]
struct Struct {}
fn f<const S: Struct>() {}
trait Trait {
type Assoc;
fn g();
}
impl Trait for () {
type Assoc = Struct;
fn g() {
let _ = Self::Assoc {}; // ok!
f::<core::direct_const_arg!(Struct {})>(); // ok!
f::<core::direct_const_arg!(Self::Assoc {})>(); // kaboom
}
}
fn main() {}
error: struct expression with invalid base path
--> src/main.rs:22:37
|
22 | f::<core::direct_const_arg!(Self::Assoc {})>();
| ^^^^^^^^^^^^^^
pardon the wonky setup, it can probably be minimized a bit, just wanting to avoid more_qualified_paths. I think (I am unsure) that this should compile.
relevant line of code:
|
let e = tcx.dcx().span_err(span, "struct expression with invalid base path"); |
relevant PR: #149114
Speculation on my part:
The easiest way to resolve this is to have ResolvedStructPath have its res: Result<Res, ErrorGuaranteed> field ripped out if at all possible. I haven't quite investigated why it exists, I thiiink it's only used in two places: this spot in mGCA direct arg lowering (hence me filing this issue), and fn_ctxt/checks.rs check_struct_path
|
let variant = match def { |
... removing it would be real nice to make inherent_associated_types easier to implement.
Anyway, just filing an issue to track it for now, will fully investigate later.
unsure whether to file this under min_generic_const_args, adt_const_params, inherent_associated_types, or something else ;-;
discovered when investigating how to progress with inherent_associated_types
pardon the wonky setup, it can probably be minimized a bit, just wanting to avoid more_qualified_paths. I think (I am unsure) that this should compile.
relevant line of code:
rust/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Line 2679 in 8a2fbe3
relevant PR: #149114
Speculation on my part:
The easiest way to resolve this is to have
ResolvedStructPathhave itsres: Result<Res, ErrorGuaranteed>field ripped out if at all possible. I haven't quite investigated why it exists, I thiiink it's only used in two places: this spot in mGCA direct arg lowering (hence me filing this issue), andfn_ctxt/checks.rscheck_struct_pathrust/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Line 1049 in 8a2fbe3
Anyway, just filing an issue to track it for now, will fully investigate later.