struct constructor of an alias ty under mgca produces error
@khyperia is already working on this.
Since Aug 10, 2026.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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:
relevant PR: https://github.com/rust-lang/rust/pull/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 https://github.com/rust-lang/rust/blob/8a2fbe3ea881ec68b9f06510fd1a1484cdf5bb6b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L1049 ... 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.