Closed
Description
Crate 1:
// This must be a `struct` (of any kind), but not `enum` or `type`
pub struct S;
Crate 2:
extern crate crate1;
trait Tr {
const C: u8;
}
impl Tr for crate1::S {
const C: u8 = 0;
}
fn main() {
match 0u8 {
// This must be a pattern, but not expression
crate1::S::C => {}, // error: no associated item named `C` found for type `crate1::S` in the current scope
_ => {},
}
}
The reason is related to #30361, structs from other crates are defined as DefStruct
and local structs are defined as DefTy
.
Associated item resolution in patterns somehow works with with DefTy
, but not with DefStruct
.
I audited the use of both definitions in type checker, but still wasn't able to figure out what exactly happens.
Metadata
Metadata
Assignees
Labels
No labels