auto merge of #17653 : kaini/rust/master, r=alexcrichton
Fixes that unit-like structs cannot be used if they are re-exported and used in another crate. (ICE)
The relevant changes are in `rustc::metadata::{decoder, encoder}` and `rustc::middle::ty`.
A test case is included.
The problem is that the expressoin `UnitStruct` is an `ExprPath` to an `DefFn`, which is of expr kind `RvalueDatumExpr`, but for unit-struct ctors the expr kind should be `RvalueDpsExpr`. I fixed this (in a I guess clean way) by introducing `CtorFn` in the metadata and including a `is_ctor` flag in `DefFn`.
This commit is contained in:
commit
8ab6fce95e
19 changed files with 81 additions and 32 deletions
|
|
@ -73,12 +73,8 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
|
|||
record_extern_fqn(cx, did, clean::TypeTrait);
|
||||
clean::TraitItem(build_external_trait(cx, tcx, did))
|
||||
}
|
||||
def::DefFn(did, style) => {
|
||||
def::DefFn(did, style, false) => {
|
||||
// If this function is a tuple struct constructor, we just skip it
|
||||
if csearch::get_tuple_struct_definition_if_ctor(&tcx.sess.cstore,
|
||||
did).is_some() {
|
||||
return None
|
||||
}
|
||||
record_extern_fqn(cx, did, clean::TypeFunction);
|
||||
clean::FunctionItem(build_external_function(cx, tcx, did, style))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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