Skip to content

Commit f4fb94a

Browse files
cjgillotMark-Simulacrum
authored andcommitted
Synthetize a trait ref when none is available.
1 parent 7c45c50 commit f4fb94a

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ where
348348
fn make_final_bounds(
349349
&self,
350350
ty_to_bounds: FxHashMap<Type, FxHashSet<GenericBound>>,
351-
ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)>,
351+
ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)>,
352352
lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<GenericBound>>,
353353
) -> Vec<WherePredicate> {
354354
ty_to_bounds
355355
.into_iter()
356356
.flat_map(|(ty, mut bounds)| {
357-
if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) {
357+
if let Some((ref poly_trait, ref output)) = ty_to_fn.get(&ty) {
358358
let mut new_path = poly_trait.trait_.clone();
359359
let last_segment = new_path.segments.pop().expect("segments were empty");
360360

@@ -473,7 +473,7 @@ where
473473
let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default();
474474
let mut ty_to_traits: FxHashMap<Type, FxHashSet<Path>> = Default::default();
475475

476-
let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = Default::default();
476+
let mut ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)> = Default::default();
477477

478478
for p in clean_where_predicates {
479479
let (orig_p, p) = (p, p.clean(self.cx));
@@ -537,8 +537,8 @@ where
537537
if is_fn {
538538
ty_to_fn
539539
.entry(ty.clone())
540-
.and_modify(|e| *e = (Some(poly_trait.clone()), e.1.clone()))
541-
.or_insert(((Some(poly_trait.clone())), None));
540+
.and_modify(|e| *e = (poly_trait.clone(), e.1.clone()))
541+
.or_insert(((poly_trait.clone()), None));
542542

543543
ty_to_bounds.entry(ty.clone()).or_default();
544544
} else {
@@ -561,7 +561,13 @@ where
561561
.and_modify(|e| {
562562
*e = (e.0.clone(), Some(rhs.ty().unwrap().clone()))
563563
})
564-
.or_insert((None, Some(rhs.ty().unwrap().clone())));
564+
.or_insert((
565+
PolyTrait {
566+
trait_: trait_.clone(),
567+
generic_params: Vec::new(),
568+
},
569+
Some(rhs.ty().unwrap().clone()),
570+
));
565571
continue;
566572
}
567573

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ pub struct Span<F: Fn(&i32)> {
44
inner: Peekable<ConditionalIterator<F>>,
55
}
66

7-
struct ConditionalIterator<F> {
7+
pub struct ConditionalIterator<F> {
88
f: F,
99
}
1010

11+
12+
// @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header in-band"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>'
1113
impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> {
1214
type Item = ();
1315

0 commit comments

Comments
 (0)