Skip to content

Commit

Permalink
rustdoc-json: Add test for Self type
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Aug 15, 2024
1 parent c416a6f commit b694cf4
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/rustdoc-json/traits/self.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pub struct Foo;

// Check that Self is represented uniformly between inherent impls, trait impls,
// and trait definitions, even though it uses both SelfTyParam and SelfTyAlias
// internally.
//
// Each assertion matches 3 times, and should be the same each time.

impl Foo {
//@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"'

Check failure on line 10 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][1].borrowed_ref.type.generic' '"Self"' '"Self"' '"Self"'

Check failure on line 11 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][1].borrowed_ref.lifetime' null null null

Check failure on line 12 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][1].borrowed_ref.mutable' false false false

Check failure on line 13 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
pub fn by_ref(&self) {}

//@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"'

Check failure on line 16 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][1].borrowed_ref.type.generic' '"Self"' '"Self"' '"Self"'

Check failure on line 17 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][1].borrowed_ref.lifetime' null null null

Check failure on line 18 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][1].borrowed_ref.mutable' true true true

Check failure on line 19 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
pub fn by_exclusive_ref(&mut self) {}

//@ ismany '$.index[*][?(@.name=="by_value")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"'

Check failure on line 22 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
//@ ismany '$.index[*][?(@.name=="by_value")].inner.function.decl.inputs[0][1].generic' '"Self"' '"Self"' '"Self"'

Check failure on line 23 in tests/rustdoc-json/traits/self.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
pub fn by_value(self) {}

//@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"'
//@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][1].borrowed_ref.type.generic' '"Self"' '"Self"' '"Self"'
//@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][1].borrowed_ref.lifetime' \"\'a\" \"\'a\" \"\'a\"
//@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][1].borrowed_ref.mutable' false false false
pub fn with_lifetime<'a>(&'a self) {}

//@ ismany '$.index[*][?(@.name=="build")].inner.function.decl.output.generic' '"Self"' '"Self"' '"Self"'
pub fn build() -> Self {
Self
}
}

pub struct Bar;

pub trait SelfParams {
fn by_ref(&self);
fn by_exclusive_ref(&mut self);
fn by_value(self);
fn with_lifetime<'a>(&'a self);
fn build() -> Self;
}

impl SelfParams for Bar {
fn by_ref(&self) {}
fn by_exclusive_ref(&mut self) {}
fn by_value(self) {}
fn with_lifetime<'a>(&'a self) {}
fn build() -> Self {
Self;
}
}

0 comments on commit b694cf4

Please sign in to comment.