Rollup merge of #127459 - its-the-shrimp:rustdocjson_add_alias_tests, r=aDotInTheVoid

rustdoc-json: add type/trait alias tests

Not sure if this tests everything there is to test in them though.

Updates #81359
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-07-08 13:04:34 +08:00 committed by GitHub
commit 76be8f1048
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,18 @@
// ignore-tidy-linelength
#![feature(trait_alias)]
// @set StrLike = "$.index[*][?(@.name=='StrLike')].id"
// @is "$.index[*][?(@.name=='StrLike')].visibility" \"public\"
// @has "$.index[*][?(@.name=='StrLike')].inner.trait_alias"
// @is "$.index[*][?(@.name=='StrLike')].span.filename" $FILE
pub trait StrLike = AsRef<str>;
// @is "$.index[*][?(@.name=='f')].inner.function.decl.output.impl_trait[0].trait_bound.trait.id" $StrLike
pub fn f() -> impl StrLike {
"heya"
}
// @!is "$.index[*][?(@.name=='g')].inner.function.decl.output.impl_trait[0].trait_bound.trait.id" $StrLike
pub fn g() -> impl AsRef<str> {
"heya"
}

View File

@ -0,0 +1,15 @@
// @set IntVec = "$.index[*][?(@.name=='IntVec')].id"
// @is "$.index[*][?(@.name=='IntVec')].visibility" \"public\"
// @has "$.index[*][?(@.name=='IntVec')].inner.type_alias"
// @is "$.index[*][?(@.name=='IntVec')].span.filename" $FILE
pub type IntVec = Vec<u32>;
// @is "$.index[*][?(@.name=='f')].inner.function.decl.output.resolved_path.id" $IntVec
pub fn f() -> IntVec {
vec![0; 32]
}
// @!is "$.index[*][?(@.name=='g')].inner.function.decl.output.resolved_path.id" $IntVec
pub fn g() -> Vec<u32> {
vec![0; 32]
}