Skip to content

Commit 9d1fd97

Browse files
cjgillotMark-Simulacrum
authored andcommitted
Avoid ICE in rustdoc.
1 parent 5643d53 commit 9d1fd97

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
351351
ty_to_bounds
352352
.into_iter()
353353
.flat_map(|(ty, mut bounds)| {
354-
if let Some(data) = ty_to_fn.get(&ty) {
355-
let (poly_trait, output) =
356-
(data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned().map(Box::new));
354+
if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) {
357355
let mut new_path = poly_trait.trait_.clone();
358356
let last_segment = new_path.segments.pop().expect("segments were empty");
359357

@@ -371,8 +369,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
371369
GenericArgs::Parenthesized { inputs, output } => (inputs, output),
372370
};
373371

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

378377
let new_params = GenericArgs::Parenthesized { inputs: old_input, output };
@@ -382,7 +381,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
382381
.push(PathSegment { name: last_segment.name, args: new_params });
383382

384383
bounds.insert(GenericBound::TraitBound(
385-
PolyTrait { trait_: new_path, generic_params: poly_trait.generic_params },
384+
PolyTrait {
385+
trait_: new_path,
386+
generic_params: poly_trait.generic_params.clone(),
387+
},
386388
hir::TraitBoundModifier::None,
387389
));
388390
}

src/test/rustdoc/fn-bound.rs

Lines changed: 17 additions & 0 deletions
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)