Skip to content

struct constructor of an alias ty under mgca produces error #160844

Description

@khyperia

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.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions