Add test
This commit is contained in:
parent
dc628b4f67
commit
befe9cac91
2 changed files with 25 additions and 27 deletions
|
@ -1761,7 +1761,7 @@ fn get_real_types(
|
||||||
cx: &DocContext<'_>,
|
cx: &DocContext<'_>,
|
||||||
) -> FxHashSet<Type> {
|
) -> FxHashSet<Type> {
|
||||||
let arg_s = arg.to_string();
|
let arg_s = arg.to_string();
|
||||||
let mut res = Vec::new();
|
let mut res = FxHashSet::default();
|
||||||
if arg.is_full_generic() {
|
if arg.is_full_generic() {
|
||||||
if let Some(where_pred) = generics.where_predicates.iter().find(|g| {
|
if let Some(where_pred) = generics.where_predicates.iter().find(|g| {
|
||||||
match g {
|
match g {
|
||||||
|
@ -1778,11 +1778,11 @@ fn get_real_types(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if let Some(ty) = x.get_type(cx) {
|
if let Some(ty) = x.get_type(cx) {
|
||||||
let mut adds = get_real_types(generics, &ty, cx);
|
let adds = get_real_types(generics, &ty, cx);
|
||||||
if !adds.is_empty() {
|
if !adds.is_empty() {
|
||||||
res.extend(adds);
|
res.extend(adds);
|
||||||
} else if !ty.is_full_generic() {
|
} else if !ty.is_full_generic() {
|
||||||
res.push(ty);
|
res.insert(ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1796,26 +1796,26 @@ fn get_real_types(
|
||||||
}) {
|
}) {
|
||||||
for bound in bound.get_bounds().unwrap_or_else(|| &[]) {
|
for bound in bound.get_bounds().unwrap_or_else(|| &[]) {
|
||||||
if let Some(ty) = bound.get_trait_type() {
|
if let Some(ty) = bound.get_trait_type() {
|
||||||
let mut adds = get_real_types(generics, &ty, cx);
|
let adds = get_real_types(generics, &ty, cx);
|
||||||
if !adds.is_empty() {
|
if !adds.is_empty() {
|
||||||
res.extend(adds);
|
res.extend(adds);
|
||||||
} else if !ty.is_full_generic() {
|
} else if !ty.is_full_generic() {
|
||||||
res.push(ty.clone());
|
res.insert(ty.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.push(arg.clone());
|
res.insert(arg.clone());
|
||||||
if let Some(gens) = arg.generics() {
|
if let Some(gens) = arg.generics() {
|
||||||
for gen in gens.iter() {
|
for gen in gens.iter() {
|
||||||
if gen.is_full_generic() {
|
if gen.is_full_generic() {
|
||||||
let mut adds = get_real_types(generics, gen, cx);
|
let adds = get_real_types(generics, gen, cx);
|
||||||
if !adds.is_empty() {
|
if !adds.is_empty() {
|
||||||
res.extend(adds);
|
res.extend(adds);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.push(gen.clone());
|
res.insert(gen.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1832,36 +1832,30 @@ pub fn get_all_types(
|
||||||
decl: &FnDecl,
|
decl: &FnDecl,
|
||||||
cx: &DocContext<'_>,
|
cx: &DocContext<'_>,
|
||||||
) -> (Vec<Type>, Vec<Type>) {
|
) -> (Vec<Type>, Vec<Type>) {
|
||||||
let mut all_types = Vec::new();
|
let mut all_types = FxHashSet::default();
|
||||||
for arg in decl.inputs.values.iter() {
|
for arg in decl.inputs.values.iter() {
|
||||||
if arg.type_.is_self_type() {
|
if arg.type_.is_self_type() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut args = get_real_types(generics, &arg.type_, cx);
|
let args = get_real_types(generics, &arg.type_, cx);
|
||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
all_types.extend(args);
|
all_types.extend(args);
|
||||||
} else {
|
} else {
|
||||||
all_types.push(arg.type_.clone());
|
all_types.insert(arg.type_.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME: use a HashSet instead?
|
|
||||||
all_types.sort_unstable_by(|a, b| a.to_string().partial_cmp(&b.to_string()).unwrap());
|
|
||||||
all_types.dedup();
|
|
||||||
|
|
||||||
let mut ret_types = match decl.output {
|
let ret_types = match decl.output {
|
||||||
FunctionRetTy::Return(ref return_type) => {
|
FunctionRetTy::Return(ref return_type) => {
|
||||||
let mut ret = get_real_types(generics, &return_type, cx);
|
let mut ret = get_real_types(generics, &return_type, cx);
|
||||||
if ret.is_empty() {
|
if ret.is_empty() {
|
||||||
ret.push(return_type.clone());
|
ret.insert(return_type.clone());
|
||||||
}
|
}
|
||||||
ret
|
ret.into_iter().collect()
|
||||||
}
|
}
|
||||||
_ => Vec::new(),
|
_ => Vec::new(),
|
||||||
};
|
};
|
||||||
// FIXME: use a HashSet instead?
|
(all_types.into_iter().collect(), ret_types)
|
||||||
ret_types.sort_unstable_by(|a, b| a.to_string().partial_cmp(&b.to_string()).unwrap());
|
|
||||||
ret_types.dedup();
|
|
||||||
(all_types, ret_types)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
|
|
|
@ -756,16 +756,20 @@ if (!DOMTokenList.prototype.remove) {
|
||||||
|
|
||||||
if (obj && obj.type && obj.type.length > OUTPUT_DATA) {
|
if (obj && obj.type && obj.type.length > OUTPUT_DATA) {
|
||||||
var ret = obj.type[OUTPUT_DATA];
|
var ret = obj.type[OUTPUT_DATA];
|
||||||
//if (obj.name === "xo") {
|
|
||||||
// debugger;
|
|
||||||
//}
|
|
||||||
if (!obj.type[OUTPUT_DATA].length) {
|
if (!obj.type[OUTPUT_DATA].length) {
|
||||||
ret = [ret];
|
ret = [ret];
|
||||||
}
|
}
|
||||||
for (var x = 0; x < ret.length; ++x) {
|
for (var x = 0; x < ret.length; ++x) {
|
||||||
var tmp = checkType(ret[x], val, literalSearch);
|
var r = ret[x];
|
||||||
if (literalSearch === true && tmp === true) {
|
if (typeof r === "string") {
|
||||||
return true;
|
r = [r];
|
||||||
|
}
|
||||||
|
var tmp = checkType(r, val, literalSearch);
|
||||||
|
if (literalSearch === true) {
|
||||||
|
if (tmp === true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
lev_distance = Math.min(tmp, lev_distance);
|
lev_distance = Math.min(tmp, lev_distance);
|
||||||
if (lev_distance === 0) {
|
if (lev_distance === 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue