Skip to content

Commit 7c45c50

Browse files
cjgillotMark-Simulacrum
authored andcommitted
Avoid ICE in rustdoc.
1 parent 903561f commit 7c45c50

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Diff for: src/librustdoc/clean/auto_trait.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ where
354354
ty_to_bounds
355355
.into_iter()
356356
.flat_map(|(ty, mut bounds)| {
357-
if let Some(data) = ty_to_fn.get(&ty) {
358-
let (poly_trait, output) =
359-
(data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned().map(Box::new));
357+
if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) {
360358
let mut new_path = poly_trait.trait_.clone();
361359
let last_segment = new_path.segments.pop().expect("segments were empty");
362360

@@ -374,8 +372,9 @@ where
374372
GenericArgs::Parenthesized { inputs, output } => (inputs, output),
375373
};
376374

375+
let output = output.as_ref().cloned().map(Box::new);
377376
if old_output.is_some() && old_output != output {
378-
panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, data.1);
377+
panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, output);
379378
}
380379

381380
let new_params = GenericArgs::Parenthesized { inputs: old_input, output };
@@ -385,7 +384,10 @@ where
385384
.push(PathSegment { name: last_segment.name, args: new_params });
386385

387386
bounds.insert(GenericBound::TraitBound(
388-
PolyTrait { trait_: new_path, generic_params: poly_trait.generic_params },
387+
PolyTrait {
388+
trait_: new_path,
389+
generic_params: poly_trait.generic_params.clone(),
390+
},
389391
hir::TraitBoundModifier::None,
390392
));
391393
}

Diff for: src/test/rustdoc/fn-bound.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::iter::Peekable;
2+
3+
pub struct Span<F: Fn(&i32)> {
4+
inner: Peekable<ConditionalIterator<F>>,
5+
}
6+
7+
struct ConditionalIterator<F> {
8+
f: F,
9+
}
10+
11+
impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> {
12+
type Item = ();
13+
14+
fn next(&mut self) -> Option<Self::Item> {
15+
todo!()
16+
}
17+
}

0 commit comments

Comments
 (0)