diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/rustdoc-json/impls | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc-json/impls')
-rw-r--r-- | tests/rustdoc-json/impls/auto.rs | 18 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/auxiliary/foreign_struct.rs | 1 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/auxiliary/foreign_trait.rs | 1 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/blanket_with_local.rs | 18 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/foreign_for_local.rs | 18 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/import_from_private.rs | 22 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/local_for_foreign.rs | 18 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/local_for_local.rs | 15 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/local_for_local_primitive.rs | 21 | ||||
-rw-r--r-- | tests/rustdoc-json/impls/local_for_primitive.rs | 7 |
10 files changed, 139 insertions, 0 deletions
diff --git a/tests/rustdoc-json/impls/auto.rs b/tests/rustdoc-json/impls/auto.rs new file mode 100644 index 000000000..50d852414 --- /dev/null +++ b/tests/rustdoc-json/impls/auto.rs @@ -0,0 +1,18 @@ +#![feature(no_core, auto_traits, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +pub auto trait Bar {} + +/// has span +impl Foo { + pub fn baz(&self) {} +} + +// Testing spans, so all tests below code +// @is "$.index[*][?(@.kind=='impl' && @.inner.synthetic==true)].span" null +// @is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]" +// @is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]" +pub struct Foo; diff --git a/tests/rustdoc-json/impls/auxiliary/foreign_struct.rs b/tests/rustdoc-json/impls/auxiliary/foreign_struct.rs new file mode 100644 index 000000000..832d0fce5 --- /dev/null +++ b/tests/rustdoc-json/impls/auxiliary/foreign_struct.rs @@ -0,0 +1 @@ +pub struct ForeignStruct; diff --git a/tests/rustdoc-json/impls/auxiliary/foreign_trait.rs b/tests/rustdoc-json/impls/auxiliary/foreign_trait.rs new file mode 100644 index 000000000..2c81bee61 --- /dev/null +++ b/tests/rustdoc-json/impls/auxiliary/foreign_trait.rs @@ -0,0 +1 @@ +pub trait ForeignTrait {} diff --git a/tests/rustdoc-json/impls/blanket_with_local.rs b/tests/rustdoc-json/impls/blanket_with_local.rs new file mode 100644 index 000000000..2fb4a84b9 --- /dev/null +++ b/tests/rustdoc-json/impls/blanket_with_local.rs @@ -0,0 +1,18 @@ +// Test for the ICE in rust/83718 +// A blanket impl plus a local type together shouldn't result in mismatched ID issues + +// @has "$.index[*][?(@.name=='Load')]" +pub trait Load { + // @has "$.index[*][?(@.name=='load')]" + fn load() {} + // @has "$.index[*][?(@.name=='write')]" + fn write(self) {} +} + +impl<P> Load for P { + fn load() {} + fn write(self) {} +} + +// @has "$.index[*][?(@.name=='Wrapper')]" +pub struct Wrapper {} diff --git a/tests/rustdoc-json/impls/foreign_for_local.rs b/tests/rustdoc-json/impls/foreign_for_local.rs new file mode 100644 index 000000000..290c2d571 --- /dev/null +++ b/tests/rustdoc-json/impls/foreign_for_local.rs @@ -0,0 +1,18 @@ +// aux-build: foreign_trait.rs +extern crate foreign_trait; + +/// ForeignTrait id hack +pub use foreign_trait::ForeignTrait as _; +// @set ForeignTrait = "$.index[*][?(@.docs=='ForeignTrait id hack')].inner.id" + +pub struct LocalStruct; +// @set LocalStruct = "$.index[*][?(@.name=='LocalStruct')].id" + +/// foreign for local +impl foreign_trait::ForeignTrait for LocalStruct {} + +// @set impl = "$.index[*][?(@.docs=='foreign for local')].id" +// @is "$.index[*][?(@.docs=='foreign for local')].inner.for.inner.id" $LocalStruct +// @is "$.index[*][?(@.docs=='foreign for local')].inner.trait.id" $ForeignTrait + +// @has "$.index[*][?(@.name=='LocalStruct')].inner.impls[*]" $impl diff --git a/tests/rustdoc-json/impls/import_from_private.rs b/tests/rustdoc-json/impls/import_from_private.rs new file mode 100644 index 000000000..fa88b6113 --- /dev/null +++ b/tests/rustdoc-json/impls/import_from_private.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/100252 + +#![feature(no_core)] +#![no_core] + +mod bar { + // @set baz = "$.index[*][?(@.kind=='struct')].id" + pub struct Baz; + // @set impl = "$.index[*][?(@.kind=='impl')].id" + impl Baz { + // @set doit = "$.index[*][?(@.kind=='function')].id" + pub fn doit() {} + } +} + +// @set import = "$.index[*][?(@.kind=='import')].id" +pub use bar::Baz; + +// @is "$.index[*][?(@.kind=='module')].inner.items[*]" $import +// @is "$.index[*][?(@.kind=='import')].inner.id" $baz +// @is "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl +// @is "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit diff --git a/tests/rustdoc-json/impls/local_for_foreign.rs b/tests/rustdoc-json/impls/local_for_foreign.rs new file mode 100644 index 000000000..74f2f08b5 --- /dev/null +++ b/tests/rustdoc-json/impls/local_for_foreign.rs @@ -0,0 +1,18 @@ +// aux-build: foreign_struct.rs +extern crate foreign_struct; + +/// ForeignStruct id hack +pub use foreign_struct::ForeignStruct as _; +// @set ForeignStruct = "$.index[*][?(@.docs=='ForeignStruct id hack')].inner.id" + +pub trait LocalTrait {} +// @set LocalTrait = "$.index[*][?(@.name=='LocalTrait')].id" + +/// local for foreign +impl LocalTrait for foreign_struct::ForeignStruct {} + +// @set impl = "$.index[*][?(@.docs=='local for foreign')].id" +// @is "$.index[*][?(@.docs=='local for foreign')].inner.trait.id" $LocalTrait +// @is "$.index[*][?(@.docs=='local for foreign')].inner.for.inner.id" $ForeignStruct + +// @is "$.index[*][?(@.name=='LocalTrait')].inner.implementations[*]" $impl diff --git a/tests/rustdoc-json/impls/local_for_local.rs b/tests/rustdoc-json/impls/local_for_local.rs new file mode 100644 index 000000000..93dedb7ec --- /dev/null +++ b/tests/rustdoc-json/impls/local_for_local.rs @@ -0,0 +1,15 @@ +#![feature(no_core)] +#![no_core] + +// @set struct = "$.index[*][?(@.name=='Struct')].id" +pub struct Struct; +// @set trait = "$.index[*][?(@.name=='Trait')].id" +pub trait Trait {} +// @set impl = "$.index[*][?(@.docs=='impl')].id" +/// impl +impl Trait for Struct {} + +// @is "$.index[*][?(@.name=='Struct')].inner.impls[*]" $impl +// @is "$.index[*][?(@.name=='Trait')].inner.implementations[*]" $impl +// @is "$.index[*][?(@.docs=='impl')].inner.trait.id" $trait +// @is "$.index[*][?(@.docs=='impl')].inner.for.inner.id" $struct diff --git a/tests/rustdoc-json/impls/local_for_local_primitive.rs b/tests/rustdoc-json/impls/local_for_local_primitive.rs new file mode 100644 index 000000000..38e7e2658 --- /dev/null +++ b/tests/rustdoc-json/impls/local_for_local_primitive.rs @@ -0,0 +1,21 @@ +#![feature(no_core)] +#![feature(rustdoc_internals)] +#![no_core] + +// @set Local = "$.index[*][?(@.name=='Local')].id" +pub trait Local {} + +// @is "$.index[*][?(@.docs=='Local for bool')].inner.trait.id" $Local +// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.kind" '"primitive"' +// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.inner" '"bool"' +/// Local for bool +impl Local for bool {} + +// @set impl = "$.index[*][?(@.docs=='Local for bool')].id" +// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl + +// FIXME(#101695): Test bool's `impls` include "Local for bool" +// @has "$.index[*][?(@.name=='bool')]" +#[doc(primitive = "bool")] +/// Boolean docs +mod prim_bool {} diff --git a/tests/rustdoc-json/impls/local_for_primitive.rs b/tests/rustdoc-json/impls/local_for_primitive.rs new file mode 100644 index 000000000..7702a526f --- /dev/null +++ b/tests/rustdoc-json/impls/local_for_primitive.rs @@ -0,0 +1,7 @@ +// @set local = "$.index[*][?(@.name=='Local')]" +pub trait Local {} + +// @set impl = "$.index[*][?(@.docs=='local for bool')].id" +// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl +/// local for bool +impl Local for bool {} |