-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #94861 - aDotInTheVoid:rdj-trait-tests, r=CraftSpider
rustdoc-json: More tests, and better jsondocck errors Helps with #81359 r? `@CraftSpider` `@rustbot` modify labels: +A-rustdoc-json +T-rustdoc +A-testsuite
- Loading branch information
Showing
6 changed files
with
155 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![feature(no_core)] | ||
#![no_core] | ||
|
||
// @set foo = generic_args.json "$.index[*][?(@.name=='Foo')].id" | ||
pub trait Foo {} | ||
|
||
// @is - "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" | ||
// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 | ||
// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' | ||
// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' | ||
// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 | ||
// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" '$foo' | ||
// @count - "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 | ||
// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' | ||
// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' | ||
// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' | ||
pub fn generics<F: Foo>(f: F) {} | ||
|
||
// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" | ||
// @count - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 | ||
// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' | ||
// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $foo | ||
// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 | ||
// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' | ||
// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' | ||
// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 | ||
// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $foo | ||
pub fn impl_trait(f: impl Foo) {} | ||
|
||
// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 1 | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' | ||
// @count - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 1 | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' | ||
// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 1 | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' | ||
// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 | ||
// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo | ||
pub fn where_clase<F>(f: F) | ||
where | ||
F: Foo, | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![feature(no_core)] | ||
#![no_core] | ||
|
||
// @count generic_returns.json "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 | ||
|
||
// @set foo = - "$.index[*][?(@.name=='Foo')].id" | ||
pub trait Foo {} | ||
|
||
// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] | ||
// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' | ||
// @count - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 | ||
// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.inner.id" $foo | ||
pub fn get_foo() -> impl Foo { | ||
Fooer {} | ||
} | ||
|
||
struct Fooer {} | ||
|
||
impl Foo for Fooer {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![feature(no_core)] | ||
#![no_core] | ||
|
||
// @is longest.json "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" | ||
// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' | ||
// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' | ||
// @count - "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 | ||
// @is - "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] | ||
|
||
// @count - "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' | ||
|
||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' | ||
|
||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' | ||
|
||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false | ||
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' | ||
|
||
pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str { | ||
if l.len() > r.len() { l } else { r } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![feature(no_core)] | ||
#![no_core] | ||
|
||
// @count outlives.json "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3 | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" [] | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\" | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\" | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"' | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" [] | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"] | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null | ||
// @count - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1 | ||
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"' | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\" | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false | ||
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}' | ||
pub fn foo<'a, 'b: 'a, T: 'b>(_: &'a &'b T) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![feature(no_core)] | ||
#![feature(lang_items)] | ||
#![no_core] | ||
|
||
// @set loud_id = supertrait.json "$.index[*][?(@.name=='Loud')].id" | ||
pub trait Loud {} | ||
|
||
// @set very_loud_id = - "$.index[*][?(@.name=='VeryLoud')].id" | ||
// @count - "$.index[*][?(@.name=='VeryLoud')].inner.bounds[*]" 1 | ||
// @is - "$.index[*][?(@.name=='VeryLoud')].inner.bounds[0].trait_bound.trait.inner.id" $loud_id | ||
pub trait VeryLoud: Loud {} | ||
|
||
// @set sounds_good_id = - "$.index[*][?(@.name=='SoundsGood')].id" | ||
pub trait SoundsGood {} | ||
|
||
// @count - "$.index[*][?(@.name=='MetalBand')].inner.bounds[*]" 2 | ||
// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[0].trait_bound.trait.inner.id" $very_loud_id | ||
// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.inner.id" $sounds_good_id | ||
pub trait MetalBand: VeryLoud + SoundsGood {} | ||
|
||
// @count - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[*]" 2 | ||
// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[1].trait_bound.trait.inner.id" $very_loud_id | ||
// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.inner.id" $sounds_good_id | ||
pub trait DnabLatem: SoundsGood + VeryLoud {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters