diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-08-06 19:42:52 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-08-06 19:43:48 +0200 |
| commit | a6cfabc88a79fe039a9c3d0c541f6517fb9767e2 (patch) | |
| tree | c6f070496709125804f0e3547d28873e72ad1d9d /src | |
| parent | 55f46419afd2e49acfc6be176ad4aeadaa5686d7 (diff) | |
| download | rust-a6cfabc88a79fe039a9c3d0c541f6517fb9767e2.tar.gz rust-a6cfabc88a79fe039a9c3d0c541f6517fb9767e2.zip | |
Avoid ICE in rustdoc.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 12 | ||||
| -rw-r--r-- | src/test/rustdoc/fn-bound.rs | 17 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 71f070f2678..6697952293e 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -354,9 +354,7 @@ where ty_to_bounds .into_iter() .flat_map(|(ty, mut bounds)| { - if let Some(data) = ty_to_fn.get(&ty) { - let (poly_trait, output) = - (data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned().map(Box::new)); + if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) { let mut new_path = poly_trait.trait_.clone(); let last_segment = new_path.segments.pop().expect("segments were empty"); @@ -374,8 +372,9 @@ where GenericArgs::Parenthesized { inputs, output } => (inputs, output), }; + let output = output.as_ref().cloned().map(Box::new); if old_output.is_some() && old_output != output { - panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, data.1); + panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, output); } let new_params = GenericArgs::Parenthesized { inputs: old_input, output }; @@ -385,7 +384,10 @@ where .push(PathSegment { name: last_segment.name, args: new_params }); bounds.insert(GenericBound::TraitBound( - PolyTrait { trait_: new_path, generic_params: poly_trait.generic_params }, + PolyTrait { + trait_: new_path, + generic_params: poly_trait.generic_params.clone(), + }, hir::TraitBoundModifier::None, )); } diff --git a/src/test/rustdoc/fn-bound.rs b/src/test/rustdoc/fn-bound.rs new file mode 100644 index 00000000000..7b44ee7b4b5 --- /dev/null +++ b/src/test/rustdoc/fn-bound.rs @@ -0,0 +1,17 @@ +use std::iter::Peekable; + +pub struct Span<F: Fn(&i32)> { + inner: Peekable<ConditionalIterator<F>>, +} + +struct ConditionalIterator<F> { + f: F, +} + +impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> { + type Item = (); + + fn next(&mut self) -> Option<Self::Item> { + todo!() + } +} |
