diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-08-08 21:09:09 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-08-08 21:09:09 +0200 |
| commit | eab3b05b622890228e001feff5f5751196cc12ed (patch) | |
| tree | 23c51c3a6ed0e744005772e30534709885f05c55 | |
| parent | a6cfabc88a79fe039a9c3d0c541f6517fb9767e2 (diff) | |
| download | rust-eab3b05b622890228e001feff5f5751196cc12ed.tar.gz rust-eab3b05b622890228e001feff5f5751196cc12ed.zip | |
Synthetize a trait ref when none is available.
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 18 | ||||
| -rw-r--r-- | src/test/rustdoc/fn-bound.rs | 4 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 6697952293e..af33c1a6ada 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -348,13 +348,13 @@ where fn make_final_bounds( &self, ty_to_bounds: FxHashMap<Type, FxHashSet<GenericBound>>, - ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)>, + ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)>, lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<GenericBound>>, ) -> Vec<WherePredicate> { ty_to_bounds .into_iter() .flat_map(|(ty, mut bounds)| { - if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) { + if let 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"); @@ -473,7 +473,7 @@ where let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); let mut ty_to_traits: FxHashMap<Type, FxHashSet<Path>> = Default::default(); - let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = Default::default(); + let mut ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)> = Default::default(); for p in clean_where_predicates { let (orig_p, p) = (p, p.clean(self.cx)); @@ -537,8 +537,8 @@ where if is_fn { ty_to_fn .entry(ty.clone()) - .and_modify(|e| *e = (Some(poly_trait.clone()), e.1.clone())) - .or_insert(((Some(poly_trait.clone())), None)); + .and_modify(|e| *e = (poly_trait.clone(), e.1.clone())) + .or_insert(((poly_trait.clone()), None)); ty_to_bounds.entry(ty.clone()).or_default(); } else { @@ -561,7 +561,13 @@ where .and_modify(|e| { *e = (e.0.clone(), Some(rhs.ty().unwrap().clone())) }) - .or_insert((None, Some(rhs.ty().unwrap().clone()))); + .or_insert(( + PolyTrait { + trait_: trait_.clone(), + generic_params: Vec::new(), + }, + Some(rhs.ty().unwrap().clone()), + )); continue; } diff --git a/src/test/rustdoc/fn-bound.rs b/src/test/rustdoc/fn-bound.rs index 7b44ee7b4b5..d5d5838d375 100644 --- a/src/test/rustdoc/fn-bound.rs +++ b/src/test/rustdoc/fn-bound.rs @@ -4,10 +4,12 @@ pub struct Span<F: Fn(&i32)> { inner: Peekable<ConditionalIterator<F>>, } -struct ConditionalIterator<F> { +pub struct ConditionalIterator<F> { f: F, } + +// @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header in-band"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>' impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> { type Item = (); |
