Fixes ICE when using reexported unit-like structs
Fixes that unit-like structs cannot be used if they are reexported and used in another crate. The compiler fails with an ICE, because unit-like structs are exported as DefFn and the expression `UnitStruct` is interpreted as function pointer instead of a call to the constructor. To resolve this ambiguity tuple-like struct constructors are now exported as CtorFn. When `rustc::metadata::decoder` finds a CtorFn it sets a new flag `is_ctor` in DefFn to true. Relevant changes are in `rustc::metadata::{encoder, decoder}` and in `rustc::middle::ty`. Closes #12660 and #16973.
This commit is contained in:
parent
d2f8d4c505
commit
065a5b0424
19 changed files with 81 additions and 32 deletions
|
@ -2078,7 +2078,7 @@ fn resolve_type(cx: &DocContext, path: Path,
|
|||
|
||||
fn register_def(cx: &DocContext, def: def::Def) -> ast::DefId {
|
||||
let (did, kind) = match def {
|
||||
def::DefFn(i, _) => (i, TypeFunction),
|
||||
def::DefFn(i, _, _) => (i, TypeFunction),
|
||||
def::DefTy(i, false) => (i, TypeTypedef),
|
||||
def::DefTy(i, true) => (i, TypeEnum),
|
||||
def::DefTrait(i) => (i, TypeTrait),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue