Auto merge of #32202 - arielb1:slice-patterns, r=nikomatsakis
Implement RFC495 semantics for slice patterns non-MIR translation is still not supported for these and will happily ICE. This is a [breaking-change] for many uses of slice_patterns. [RFC 495 text](https://github.com/rust-lang/rfcs/blob/master/text/0495-array-pattern-changes.md)
This commit is contained in:
commit
bb4b3fb7f9
77 changed files with 940 additions and 738 deletions
|
|
@ -22,6 +22,7 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::hir::print as pprust;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::ty::subst;
|
||||
use rustc::util::common::slice_pat;
|
||||
|
||||
use rustc_const_eval::lookup_const_by_id;
|
||||
|
||||
|
|
@ -197,10 +198,10 @@ fn build_struct<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
let variant = tcx.lookup_adt_def(did).struct_variant();
|
||||
|
||||
clean::Struct {
|
||||
struct_type: match &*variant.fields {
|
||||
[] => doctree::Unit,
|
||||
[_] if variant.kind == ty::VariantKind::Tuple => doctree::Newtype,
|
||||
[..] if variant.kind == ty::VariantKind::Tuple => doctree::Tuple,
|
||||
struct_type: match slice_pat(&&*variant.fields) {
|
||||
&[] => doctree::Unit,
|
||||
&[_] if variant.kind == ty::VariantKind::Tuple => doctree::Newtype,
|
||||
&[..] if variant.kind == ty::VariantKind::Tuple => doctree::Tuple,
|
||||
_ => doctree::Plain,
|
||||
},
|
||||
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use std::iter::repeat;
|
|||
|
||||
use rustc::middle::cstore::LOCAL_CRATE;
|
||||
use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
|
||||
use rustc::util::common::slice_pat;
|
||||
use syntax::abi::Abi;
|
||||
use rustc::hir;
|
||||
|
||||
|
|
@ -474,9 +475,9 @@ impl fmt::Display for clean::Type {
|
|||
decl.decl)
|
||||
}
|
||||
clean::Tuple(ref typs) => {
|
||||
match &**typs {
|
||||
[] => primitive_link(f, clean::PrimitiveTuple, "()"),
|
||||
[ref one] => {
|
||||
match slice_pat(&&**typs) {
|
||||
&[] => primitive_link(f, clean::PrimitiveTuple, "()"),
|
||||
&[ref one] => {
|
||||
primitive_link(f, clean::PrimitiveTuple, "(")?;
|
||||
write!(f, "{},", one)?;
|
||||
primitive_link(f, clean::PrimitiveTuple, ")")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue