1
Fork 0

Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #90771 (Fix trait object error code)
 - #90840 (relate lifetime in `TypeOutlives` bounds on drop impls)
 - #90853 (rustdoc: Use an empty Vec instead of Option<Vec>)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-11-14 01:06:05 +00:00
commit 589ad6a5b7
7 changed files with 46 additions and 18 deletions

View file

@ -117,7 +117,7 @@ crate struct RenderType {
#[derive(Debug)]
crate struct IndexItemFunctionType {
inputs: Vec<TypeWithKind>,
output: Option<Vec<TypeWithKind>>,
output: Vec<TypeWithKind>,
}
impl Serialize for IndexItemFunctionType {
@ -126,21 +126,16 @@ impl Serialize for IndexItemFunctionType {
S: Serializer,
{
// If we couldn't figure out a type, just write `null`.
let mut iter = self.inputs.iter();
if match self.output {
Some(ref output) => iter.chain(output.iter()).any(|i| i.ty.name.is_none()),
None => iter.any(|i| i.ty.name.is_none()),
} {
let has_missing = self.inputs.iter().chain(self.output.iter()).any(|i| i.ty.name.is_none());
if has_missing {
serializer.serialize_none()
} else {
let mut seq = serializer.serialize_seq(None)?;
seq.serialize_element(&self.inputs)?;
if let Some(output) = &self.output {
if output.len() > 1 {
seq.serialize_element(&output)?;
} else {
seq.serialize_element(&output[0])?;
}
match self.output.as_slice() {
[] => {}
[one] => seq.serialize_element(one)?,
all => seq.serialize_element(all)?,
}
seq.end()
}