Skip to content

Commit

Permalink
Rollup merge of rust-lang#127459 - its-the-shrimp:rustdocjson_add_ali…
Browse files Browse the repository at this point in the history
…as_tests, r=aDotInTheVoid

rustdoc-json: add type/trait alias tests

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

Updates rust-lang#81359
  • Loading branch information
jieyouxu authored Jul 8, 2024
2 parents 73593b9 + 8e7314f commit 76be8f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/rustdoc-json/trait_alias.rs
Original file line number Diff line number Diff line change
@@ -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"
}
15 changes: 15 additions & 0 deletions tests/rustdoc-json/type_alias.rs
Original file line number Diff line number Diff line change
@@ -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]
}

0 comments on commit 76be8f1

Please sign in to comment.