You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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.
The text was updated successfully, but these errors were encountered:
All structs and their constructors are defined as `DefStruct`.
`DefTy` is splitted into `DefEnum` and `DefTyAlias`.
Ad hoc flag `bool is_structure` is removed from `DefVariant`, it was required in one place in resolve and could be obtained by other means.
Flag `bool is_ctor` is removed from `DefFn`, it wasn't really used for constructors outside of metadata decoding.
Observable effects:
More specific error messages are selected in some cases.
Two name resolution bugs fixed (#30992 and FIXME in compile-fail/empty-struct-braces-expr.rs).
Fixes#30992Closes#30361
Crate 1:
Crate 2:
The reason is related to #30361, structs from other crates are defined as
DefStruct
and local structs are defined asDefTy
.Associated item resolution in patterns somehow works with with
DefTy
, but not withDefStruct
.I audited the use of both definitions in type checker, but still wasn't able to figure out what exactly happens.
The text was updated successfully, but these errors were encountered: