Skip to content

Commit c2ca153

Browse files
committed
Fix rebase + address comments
1 parent 5f9ef3c commit c2ca153

File tree

9 files changed

+18
-14
lines changed

9 files changed

+18
-14
lines changed

src/librustc/middle/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
136136
ty::TyStruct(def, _) | ty::TyUnion(def, _) => {
137137
self.insert_def_id(def.struct_variant().field_named(name).did);
138138
}
139-
_ => span_bug!(lhs.span, "named field access on non-struct"),
139+
_ => span_bug!(lhs.span, "named field access on non-struct/union"),
140140
}
141141
}
142142

src/librustc/middle/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
565565
def.struct_variant().field_named(field.node).did
566566
}
567567
_ => span_bug!(e.span,
568-
"stability::check_expr: named field access on non-struct")
568+
"stability::check_expr: named field access on non-struct/union")
569569
}
570570
}
571571
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,
601601
_ => {
602602
span_bug!(e.span,
603603
"stability::check_expr: struct construction \
604-
of non-struct, type {:?}",
604+
of non-struct/union, type {:?}",
605605
type_);
606606
}
607607
}

src/librustc/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub enum TypeVariants<'tcx> {
112112
/// That is, even after substitution it is possible that there are type
113113
/// variables. This happens when the `TyEnum` corresponds to an enum
114114
/// definition and not a concrete use of it. This is true for `TyStruct`
115-
/// as well.
115+
/// and `TyUnion` as well.
116116
TyEnum(AdtDef<'tcx>, &'tcx Substs<'tcx>),
117117

118118
/// A structure type, defined with `struct`.

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ impl LateLintPass for MissingCopyImplementations {
475475
return;
476476
}
477477
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
478-
(def, cx.tcx.mk_union(def,
479-
cx.tcx.mk_substs(Substs::empty())))
478+
(def, cx.tcx.mk_union(def, Substs::empty(cx.tcx)))
480479
}
481480
hir::ItemEnum(_, ref ast_generics) => {
482481
if ast_generics.is_parameterized() {

src/librustc_typeck/check/method/suggest.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
166166
for (ty, _) in self.autoderef(span, rcvr_ty) {
167167
match ty.sty {
168168
ty::TyStruct(def, substs) | ty::TyUnion(def, substs) => {
169-
if let Some(field) = def.struct_variant().find_field_named(item_name) {
169+
if let Some(field) = def.struct_variant().
170+
find_field_named(item_name) {
170171
let snippet = tcx.sess.codemap().span_to_snippet(expr.span);
171172
let expr_string = match snippet {
172173
Ok(expr_string) => expr_string,
@@ -179,8 +180,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
179180

180181
if self.is_fn_ty(&field_ty, span) {
181182
err.span_note(span, &format!(
182-
"use `({0}.{1})(...)` if you meant to call the function \
183-
stored in the `{1}` field",
183+
"use `({0}.{1})(...)` if you meant to call the \
184+
function stored in the `{1}` field",
184185
expr_string, item_name));
185186
} else {
186187
err.span_note(span, &format!(

src/librustc_typeck/collect.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,11 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
15871587
let substs = mk_item_substs(&ccx.icx(generics), item.span, def_id);
15881588
ccx.tcx.mk_struct(def, substs)
15891589
}
1590+
ItemUnion(ref un, ref generics) => {
1591+
let def = convert_union_def(ccx, item, un);
1592+
let substs = mk_item_substs(&ccx.icx(generics), item.span, def_id);
1593+
ccx.tcx.mk_union(def, substs)
1594+
}
15901595
ItemDefaultImpl(..) |
15911596
ItemTrait(..) |
15921597
ItemImpl(..) |

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn build_union<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
227227

228228
clean::Union {
229229
struct_type: doctree::Plain,
230-
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
230+
generics: (t.generics, &predicates).clean(cx),
231231
fields: variant.fields.clean(cx),
232232
fields_stripped: false,
233233
}

src/librustdoc/html/item_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ impl ItemType {
133133
pub fn name_space(&self) -> NameSpace {
134134
match *self {
135135
ItemType::Struct |
136+
ItemType::Union |
136137
ItemType::Enum |
137138
ItemType::Module |
138139
ItemType::Typedef |

src/librustdoc/html/render.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,10 +2565,8 @@ fn render_union(w: &mut fmt::Formatter, it: &clean::Item,
25652565
if structhead {"union "} else {""},
25662566
it.name.as_ref().unwrap())?;
25672567
if let Some(g) = g {
2568-
write!(w, "{}", g)?
2569-
}
2570-
if let Some(g) = g {
2571-
write!(w, "{}", WhereClause(g))?
2568+
write!(w, "{}", g)?;
2569+
write!(w, "{}", WhereClause(g))?;
25722570
}
25732571

25742572
write!(w, " {{\n{}", tab)?;

0 commit comments

Comments
 (0)