mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Auto merge of #63937 - Nashenas88:rustdoc_57180, r=GuillaumeGomez
Fix ICE in rustdoc when merging generic and where bounds of an Fn with an output Fixes #57180
This commit is contained in:
commit
a37fe2de69
@ -35,7 +35,7 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
|||||||
match ty {
|
match ty {
|
||||||
clean::Generic(s) => params.entry(s).or_default()
|
clean::Generic(s) => params.entry(s).or_default()
|
||||||
.extend(bounds),
|
.extend(bounds),
|
||||||
t => tybounds.push((t, ty_bounds(bounds))),
|
t => tybounds.push((t, bounds)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WP::RegionPredicate { lifetime, bounds } => {
|
WP::RegionPredicate { lifetime, bounds } => {
|
||||||
@ -45,11 +45,6 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simplify the type parameter bounds on all the generics
|
|
||||||
let mut params = params.into_iter().map(|(k, v)| {
|
|
||||||
(k, ty_bounds(v))
|
|
||||||
}).collect::<BTreeMap<_, _>>();
|
|
||||||
|
|
||||||
// Look for equality predicates on associated types that can be merged into
|
// Look for equality predicates on associated types that can be merged into
|
||||||
// general bound predicates
|
// general bound predicates
|
||||||
equalities.retain(|&(ref lhs, ref rhs)| {
|
equalities.retain(|&(ref lhs, ref rhs)| {
|
||||||
@ -73,7 +68,7 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
|||||||
// And finally, let's reassemble everything
|
// And finally, let's reassemble everything
|
||||||
let mut clauses = Vec::new();
|
let mut clauses = Vec::new();
|
||||||
clauses.extend(lifetimes.into_iter().map(|(lt, bounds)| {
|
clauses.extend(lifetimes.into_iter().map(|(lt, bounds)| {
|
||||||
WP::RegionPredicate { lifetime: lt, bounds: bounds }
|
WP::RegionPredicate { lifetime: lt, bounds }
|
||||||
}));
|
}));
|
||||||
clauses.extend(params.into_iter().map(|(k, v)| {
|
clauses.extend(params.into_iter().map(|(k, v)| {
|
||||||
WP::BoundPredicate {
|
WP::BoundPredicate {
|
||||||
@ -82,10 +77,10 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
clauses.extend(tybounds.into_iter().map(|(ty, bounds)| {
|
clauses.extend(tybounds.into_iter().map(|(ty, bounds)| {
|
||||||
WP::BoundPredicate { ty: ty, bounds: bounds }
|
WP::BoundPredicate { ty, bounds }
|
||||||
}));
|
}));
|
||||||
clauses.extend(equalities.into_iter().map(|(lhs, rhs)| {
|
clauses.extend(equalities.into_iter().map(|(lhs, rhs)| {
|
||||||
WP::EqPredicate { lhs: lhs, rhs: rhs }
|
WP::EqPredicate { lhs, rhs }
|
||||||
}));
|
}));
|
||||||
clauses
|
clauses
|
||||||
}
|
}
|
||||||
@ -122,9 +117,9 @@ pub fn merge_bounds(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PP::Parenthesized { ref mut output, .. } => {
|
PP::Parenthesized { ref mut output, .. } => match output {
|
||||||
assert!(output.is_none());
|
Some(o) => assert_eq!(o, rhs),
|
||||||
if *rhs != clean::Type::Tuple(Vec::new()) {
|
None => if *rhs != clean::Type::Tuple(Vec::new()) {
|
||||||
*output = Some(rhs.clone());
|
*output = Some(rhs.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +132,7 @@ pub fn ty_params(mut params: Vec<clean::GenericParamDef>) -> Vec<clean::GenericP
|
|||||||
for param in &mut params {
|
for param in &mut params {
|
||||||
match param.kind {
|
match param.kind {
|
||||||
clean::GenericParamDefKind::Type { ref mut bounds, .. } => {
|
clean::GenericParamDefKind::Type { ref mut bounds, .. } => {
|
||||||
*bounds = ty_bounds(mem::take(bounds));
|
*bounds = mem::take(bounds);
|
||||||
}
|
}
|
||||||
_ => panic!("expected only type parameters"),
|
_ => panic!("expected only type parameters"),
|
||||||
}
|
}
|
||||||
@ -145,10 +140,6 @@ pub fn ty_params(mut params: Vec<clean::GenericParamDef>) -> Vec<clean::GenericP
|
|||||||
params
|
params
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_bounds(bounds: Vec<clean::GenericBound>) -> Vec<clean::GenericBound> {
|
|
||||||
bounds
|
|
||||||
}
|
|
||||||
|
|
||||||
fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId,
|
fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId,
|
||||||
trait_: DefId) -> bool {
|
trait_: DefId) -> bool {
|
||||||
if child == trait_ {
|
if child == trait_ {
|
||||||
|
16
src/test/rustdoc/auxiliary/issue-57180.rs
Normal file
16
src/test/rustdoc/auxiliary/issue-57180.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// compile-flags: -Cmetadata=aux
|
||||||
|
|
||||||
|
pub trait Trait {
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Struct<F>
|
||||||
|
{
|
||||||
|
_p: ::std::marker::PhantomData<F>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<F: Fn() -> u32>
|
||||||
|
Trait for Struct<F>
|
||||||
|
where
|
||||||
|
F: Fn() -> u32,
|
||||||
|
{
|
||||||
|
}
|
7
src/test/rustdoc/issue-57180.rs
Normal file
7
src/test/rustdoc/issue-57180.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// aux-build:issue-57180.rs
|
||||||
|
|
||||||
|
extern crate issue_57180;
|
||||||
|
use issue_57180::Trait;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user