Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc-json: add type/trait alias tests #127459

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
compiler-errors marked this conversation as resolved.
Show resolved Hide resolved
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]
}
Loading