Fix rebase + address comments

This commit is contained in:
Vadim Petrochenkov 2016-08-18 15:43:24 +03:00
parent 5f9ef3c8b2
commit c2ca1530db
9 changed files with 18 additions and 14 deletions

View File

@ -136,7 +136,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
ty::TyStruct(def, _) | ty::TyUnion(def, _) => {
self.insert_def_id(def.struct_variant().field_named(name).did);
}
_ => span_bug!(lhs.span, "named field access on non-struct"),
_ => span_bug!(lhs.span, "named field access on non-struct/union"),
}
}

View File

@ -565,7 +565,7 @@ pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
def.struct_variant().field_named(field.node).did
}
_ => span_bug!(e.span,
"stability::check_expr: named field access on non-struct")
"stability::check_expr: named field access on non-struct/union")
}
}
hir::ExprTupField(ref base_e, ref field) => {
@ -601,7 +601,7 @@ pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
_ => {
span_bug!(e.span,
"stability::check_expr: struct construction \
of non-struct, type {:?}",
of non-struct/union, type {:?}",
type_);
}
}

View File

@ -112,7 +112,7 @@ pub enum TypeVariants<'tcx> {
/// That is, even after substitution it is possible that there are type
/// variables. This happens when the `TyEnum` corresponds to an enum
/// definition and not a concrete use of it. This is true for `TyStruct`
/// as well.
/// and `TyUnion` as well.
TyEnum(AdtDef<'tcx>, &'tcx Substs<'tcx>),
/// A structure type, defined with `struct`.

View File

@ -475,8 +475,7 @@ impl LateLintPass for MissingCopyImplementations {
return;
}
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
(def, cx.tcx.mk_union(def,
cx.tcx.mk_substs(Substs::empty())))
(def, cx.tcx.mk_union(def, Substs::empty(cx.tcx)))
}
hir::ItemEnum(_, ref ast_generics) => {
if ast_generics.is_parameterized() {

View File

@ -166,7 +166,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
for (ty, _) in self.autoderef(span, rcvr_ty) {
match ty.sty {
ty::TyStruct(def, substs) | ty::TyUnion(def, substs) => {
if let Some(field) = def.struct_variant().find_field_named(item_name) {
if let Some(field) = def.struct_variant().
find_field_named(item_name) {
let snippet = tcx.sess.codemap().span_to_snippet(expr.span);
let expr_string = match snippet {
Ok(expr_string) => expr_string,
@ -179,8 +180,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if self.is_fn_ty(&field_ty, span) {
err.span_note(span, &format!(
"use `({0}.{1})(...)` if you meant to call the function \
stored in the `{1}` field",
"use `({0}.{1})(...)` if you meant to call the \
function stored in the `{1}` field",
expr_string, item_name));
} else {
err.span_note(span, &format!(

View File

@ -1587,6 +1587,11 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let substs = mk_item_substs(&ccx.icx(generics), item.span, def_id);
ccx.tcx.mk_struct(def, substs)
}
ItemUnion(ref un, ref generics) => {
let def = convert_union_def(ccx, item, un);
let substs = mk_item_substs(&ccx.icx(generics), item.span, def_id);
ccx.tcx.mk_union(def, substs)
}
ItemDefaultImpl(..) |
ItemTrait(..) |
ItemImpl(..) |

View File

@ -227,7 +227,7 @@ fn build_union<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
clean::Union {
struct_type: doctree::Plain,
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
generics: (t.generics, &predicates).clean(cx),
fields: variant.fields.clean(cx),
fields_stripped: false,
}

View File

@ -133,6 +133,7 @@ impl ItemType {
pub fn name_space(&self) -> NameSpace {
match *self {
ItemType::Struct |
ItemType::Union |
ItemType::Enum |
ItemType::Module |
ItemType::Typedef |

View File

@ -2565,10 +2565,8 @@ fn render_union(w: &mut fmt::Formatter, it: &clean::Item,
if structhead {"union "} else {""},
it.name.as_ref().unwrap())?;
if let Some(g) = g {
write!(w, "{}", g)?
}
if let Some(g) = g {
write!(w, "{}", WhereClause(g))?
write!(w, "{}", g)?;
write!(w, "{}", WhereClause(g))?;
}
write!(w, " {{\n{}", tab)?;