Fix rebase + address comments
This commit is contained in:
parent
5f9ef3c8b2
commit
c2ca1530db
@ -136,7 +136,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||||||
ty::TyStruct(def, _) | ty::TyUnion(def, _) => {
|
ty::TyStruct(def, _) | ty::TyUnion(def, _) => {
|
||||||
self.insert_def_id(def.struct_variant().field_named(name).did);
|
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"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
def.struct_variant().field_named(field.node).did
|
||||||
}
|
}
|
||||||
_ => span_bug!(e.span,
|
_ => 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) => {
|
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,
|
span_bug!(e.span,
|
||||||
"stability::check_expr: struct construction \
|
"stability::check_expr: struct construction \
|
||||||
of non-struct, type {:?}",
|
of non-struct/union, type {:?}",
|
||||||
type_);
|
type_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ pub enum TypeVariants<'tcx> {
|
|||||||
/// That is, even after substitution it is possible that there are type
|
/// That is, even after substitution it is possible that there are type
|
||||||
/// variables. This happens when the `TyEnum` corresponds to an enum
|
/// variables. This happens when the `TyEnum` corresponds to an enum
|
||||||
/// definition and not a concrete use of it. This is true for `TyStruct`
|
/// 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>),
|
TyEnum(AdtDef<'tcx>, &'tcx Substs<'tcx>),
|
||||||
|
|
||||||
/// A structure type, defined with `struct`.
|
/// A structure type, defined with `struct`.
|
||||||
|
@ -475,8 +475,7 @@ impl LateLintPass for MissingCopyImplementations {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
|
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
|
||||||
(def, cx.tcx.mk_union(def,
|
(def, cx.tcx.mk_union(def, Substs::empty(cx.tcx)))
|
||||||
cx.tcx.mk_substs(Substs::empty())))
|
|
||||||
}
|
}
|
||||||
hir::ItemEnum(_, ref ast_generics) => {
|
hir::ItemEnum(_, ref ast_generics) => {
|
||||||
if ast_generics.is_parameterized() {
|
if ast_generics.is_parameterized() {
|
||||||
|
@ -166,7 +166,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
for (ty, _) in self.autoderef(span, rcvr_ty) {
|
for (ty, _) in self.autoderef(span, rcvr_ty) {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyStruct(def, substs) | ty::TyUnion(def, substs) => {
|
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 snippet = tcx.sess.codemap().span_to_snippet(expr.span);
|
||||||
let expr_string = match snippet {
|
let expr_string = match snippet {
|
||||||
Ok(expr_string) => expr_string,
|
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) {
|
if self.is_fn_ty(&field_ty, span) {
|
||||||
err.span_note(span, &format!(
|
err.span_note(span, &format!(
|
||||||
"use `({0}.{1})(...)` if you meant to call the function \
|
"use `({0}.{1})(...)` if you meant to call the \
|
||||||
stored in the `{1}` field",
|
function stored in the `{1}` field",
|
||||||
expr_string, item_name));
|
expr_string, item_name));
|
||||||
} else {
|
} else {
|
||||||
err.span_note(span, &format!(
|
err.span_note(span, &format!(
|
||||||
|
@ -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);
|
let substs = mk_item_substs(&ccx.icx(generics), item.span, def_id);
|
||||||
ccx.tcx.mk_struct(def, substs)
|
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(..) |
|
ItemDefaultImpl(..) |
|
||||||
ItemTrait(..) |
|
ItemTrait(..) |
|
||||||
ItemImpl(..) |
|
ItemImpl(..) |
|
||||||
|
@ -227,7 +227,7 @@ fn build_union<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
|
|
||||||
clean::Union {
|
clean::Union {
|
||||||
struct_type: doctree::Plain,
|
struct_type: doctree::Plain,
|
||||||
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
|
generics: (t.generics, &predicates).clean(cx),
|
||||||
fields: variant.fields.clean(cx),
|
fields: variant.fields.clean(cx),
|
||||||
fields_stripped: false,
|
fields_stripped: false,
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ impl ItemType {
|
|||||||
pub fn name_space(&self) -> NameSpace {
|
pub fn name_space(&self) -> NameSpace {
|
||||||
match *self {
|
match *self {
|
||||||
ItemType::Struct |
|
ItemType::Struct |
|
||||||
|
ItemType::Union |
|
||||||
ItemType::Enum |
|
ItemType::Enum |
|
||||||
ItemType::Module |
|
ItemType::Module |
|
||||||
ItemType::Typedef |
|
ItemType::Typedef |
|
||||||
|
@ -2565,10 +2565,8 @@ fn render_union(w: &mut fmt::Formatter, it: &clean::Item,
|
|||||||
if structhead {"union "} else {""},
|
if structhead {"union "} else {""},
|
||||||
it.name.as_ref().unwrap())?;
|
it.name.as_ref().unwrap())?;
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
write!(w, "{}", g)?
|
write!(w, "{}", g)?;
|
||||||
}
|
write!(w, "{}", WhereClause(g))?;
|
||||||
if let Some(g) = g {
|
|
||||||
write!(w, "{}", WhereClause(g))?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(w, " {{\n{}", tab)?;
|
write!(w, " {{\n{}", tab)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user