summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc-json
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /src/test/rustdoc-json
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/rustdoc-json')
-rw-r--r--src/test/rustdoc-json/enums/auxiliary/color.rs5
-rw-r--r--src/test/rustdoc-json/enums/doc_link_to_foreign_variant.rs11
-rw-r--r--src/test/rustdoc-json/enums/use_glob.rs18
-rw-r--r--src/test/rustdoc-json/enums/use_variant.rs15
-rw-r--r--src/test/rustdoc-json/enums/use_variant_foreign.rs9
-rw-r--r--src/test/rustdoc-json/fns/pattern_arg.rs7
-rw-r--r--src/test/rustdoc-json/fns/return_type_alias.rs10
-rw-r--r--src/test/rustdoc-json/impls/import_from_private.rs2
-rw-r--r--src/test/rustdoc-json/intra-doc-links/auxiliary/enum_variant_in_trait_method.rs8
-rw-r--r--src/test/rustdoc-json/intra-doc-links/foreign_variant.rs13
-rw-r--r--src/test/rustdoc-json/reexport/auxiliary/trait_with_docs.rs2
-rw-r--r--src/test/rustdoc-json/reexport/synthesize_trait_with_docs.rs10
-rw-r--r--src/test/rustdoc-json/traits/trait_alias.rs30
-rw-r--r--src/test/rustdoc-json/traits/uses_extern_trait.rs6
14 files changed, 141 insertions, 5 deletions
diff --git a/src/test/rustdoc-json/enums/auxiliary/color.rs b/src/test/rustdoc-json/enums/auxiliary/color.rs
new file mode 100644
index 000000000..7188f7938
--- /dev/null
+++ b/src/test/rustdoc-json/enums/auxiliary/color.rs
@@ -0,0 +1,5 @@
+pub enum Color {
+ Red,
+ Green,
+ Blue,
+}
diff --git a/src/test/rustdoc-json/enums/doc_link_to_foreign_variant.rs b/src/test/rustdoc-json/enums/doc_link_to_foreign_variant.rs
new file mode 100644
index 000000000..470b195a2
--- /dev/null
+++ b/src/test/rustdoc-json/enums/doc_link_to_foreign_variant.rs
@@ -0,0 +1,11 @@
+// aux-build: color.rs
+
+//! The purpose of this test it to have a link to [a foreign variant](Red).
+
+extern crate color;
+use color::Color::Red;
+
+// @set red = "$.index[*][?(@.inner.is_crate == true)].links.Red"
+
+// @!has "$.index[*][?(@.name == 'Red')]"
+// @!has "$.index[*][?(@.name == 'Color')]"
diff --git a/src/test/rustdoc-json/enums/use_glob.rs b/src/test/rustdoc-json/enums/use_glob.rs
new file mode 100644
index 000000000..62b8b832a
--- /dev/null
+++ b/src/test/rustdoc-json/enums/use_glob.rs
@@ -0,0 +1,18 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/104942>
+
+#![feature(no_core)]
+#![no_core]
+
+// @set Color = "$.index[*][?(@.name == 'Color')].id"
+pub enum Color {
+ Red,
+ Green,
+ Blue,
+}
+
+// @set use_Color = "$.index[*][?(@.kind == 'import')].id"
+// @is "$.index[*][?(@.kind == 'import')].inner.id" $Color
+// @is "$.index[*][?(@.kind == 'import')].inner.glob" true
+pub use Color::*;
+
+// @ismany "$.index[*][?(@.name == 'use_glob')].inner.items[*]" $Color $use_Color
diff --git a/src/test/rustdoc-json/enums/use_variant.rs b/src/test/rustdoc-json/enums/use_variant.rs
new file mode 100644
index 000000000..5f0d2b9b1
--- /dev/null
+++ b/src/test/rustdoc-json/enums/use_variant.rs
@@ -0,0 +1,15 @@
+#![feature(no_core)]
+#![no_core]
+
+// @set AlwaysNone = "$.index[*][?(@.name == 'AlwaysNone')].id"
+pub enum AlwaysNone {
+ // @set None = "$.index[*][?(@.name == 'None')].id"
+ None,
+}
+// @is "$.index[*][?(@.name == 'AlwaysNone')].inner.variants[*]" $None
+
+// @set use_None = "$.index[*][?(@.kind == 'import')].id"
+// @is "$.index[*][?(@.kind == 'import')].inner.id" $None
+pub use AlwaysNone::None;
+
+// @ismany "$.index[*][?(@.name == 'use_variant')].inner.items[*]" $AlwaysNone $use_None
diff --git a/src/test/rustdoc-json/enums/use_variant_foreign.rs b/src/test/rustdoc-json/enums/use_variant_foreign.rs
new file mode 100644
index 000000000..11bb6ce1f
--- /dev/null
+++ b/src/test/rustdoc-json/enums/use_variant_foreign.rs
@@ -0,0 +1,9 @@
+// aux-build: color.rs
+
+extern crate color;
+
+// @is "$.index[*][?(@.inner.name == 'Red')].kind" '"import"'
+pub use color::Color::Red;
+
+// @!has "$.index[*][?(@.name == 'Red')]"
+// @!has "$.index[*][?(@.name == 'Color')]"
diff --git a/src/test/rustdoc-json/fns/pattern_arg.rs b/src/test/rustdoc-json/fns/pattern_arg.rs
new file mode 100644
index 000000000..32b7da0fa
--- /dev/null
+++ b/src/test/rustdoc-json/fns/pattern_arg.rs
@@ -0,0 +1,7 @@
+// @is "$.index[*][?(@.name=='fst')].inner.decl.inputs[0][0]" '"(x, _)"'
+pub fn fst<X, Y>((x, _): (X, Y)) -> X {
+ x
+}
+
+// @is "$.index[*][?(@.name=='drop_int')].inner.decl.inputs[0][0]" '"_"'
+pub fn drop_int(_: i32) {}
diff --git a/src/test/rustdoc-json/fns/return_type_alias.rs b/src/test/rustdoc-json/fns/return_type_alias.rs
new file mode 100644
index 000000000..2578bb49a
--- /dev/null
+++ b/src/test/rustdoc-json/fns/return_type_alias.rs
@@ -0,0 +1,10 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/104851>
+
+/// @set foo = "$.index[*][?(@.name=='Foo')].id"
+pub type Foo = i32;
+
+// @is "$.index[*][?(@.name=='demo')].inner.decl.output.kind" '"resolved_path"'
+// @is "$.index[*][?(@.name=='demo')].inner.decl.output.inner.id" $foo
+pub fn demo() -> Foo {
+ 42
+}
diff --git a/src/test/rustdoc-json/impls/import_from_private.rs b/src/test/rustdoc-json/impls/import_from_private.rs
index 856f7c701..fa88b6113 100644
--- a/src/test/rustdoc-json/impls/import_from_private.rs
+++ b/src/test/rustdoc-json/impls/import_from_private.rs
@@ -8,7 +8,7 @@ mod bar {
pub struct Baz;
// @set impl = "$.index[*][?(@.kind=='impl')].id"
impl Baz {
- // @set doit = "$.index[*][?(@.kind=='method')].id"
+ // @set doit = "$.index[*][?(@.kind=='function')].id"
pub fn doit() {}
}
}
diff --git a/src/test/rustdoc-json/intra-doc-links/auxiliary/enum_variant_in_trait_method.rs b/src/test/rustdoc-json/intra-doc-links/auxiliary/enum_variant_in_trait_method.rs
new file mode 100644
index 000000000..bfe85f59e
--- /dev/null
+++ b/src/test/rustdoc-json/intra-doc-links/auxiliary/enum_variant_in_trait_method.rs
@@ -0,0 +1,8 @@
+pub trait Trait {
+ /// [`Enum::Variant`]
+ fn method() {}
+}
+
+pub enum Enum {
+ Variant,
+}
diff --git a/src/test/rustdoc-json/intra-doc-links/foreign_variant.rs b/src/test/rustdoc-json/intra-doc-links/foreign_variant.rs
new file mode 100644
index 000000000..e29682313
--- /dev/null
+++ b/src/test/rustdoc-json/intra-doc-links/foreign_variant.rs
@@ -0,0 +1,13 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/105025>
+// aux-build: enum_variant_in_trait_method.rs
+
+extern crate enum_variant_in_trait_method;
+
+pub struct Local;
+
+/// local impl
+impl enum_variant_in_trait_method::Trait for Local {}
+
+// @!has "$.index[*][?(@.name == 'Trait')]"
+// @!has "$.index[*][?(@.name == 'method')]"
+// @count "$.index[*][?(@.docs == 'local impl')].inner.items[*]" 0
diff --git a/src/test/rustdoc-json/reexport/auxiliary/trait_with_docs.rs b/src/test/rustdoc-json/reexport/auxiliary/trait_with_docs.rs
new file mode 100644
index 000000000..1e87966b2
--- /dev/null
+++ b/src/test/rustdoc-json/reexport/auxiliary/trait_with_docs.rs
@@ -0,0 +1,2 @@
+/// The Docs
+pub trait HasDocs {}
diff --git a/src/test/rustdoc-json/reexport/synthesize_trait_with_docs.rs b/src/test/rustdoc-json/reexport/synthesize_trait_with_docs.rs
new file mode 100644
index 000000000..25a7c08d6
--- /dev/null
+++ b/src/test/rustdoc-json/reexport/synthesize_trait_with_docs.rs
@@ -0,0 +1,10 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/105022>
+// aux-build: trait_with_docs.rs
+
+extern crate trait_with_docs;
+
+pub struct Local;
+
+impl trait_with_docs::HasDocs for Local {}
+
+// @!has "$.index[*][?(@.name == 'HasDocs')]"
diff --git a/src/test/rustdoc-json/traits/trait_alias.rs b/src/test/rustdoc-json/traits/trait_alias.rs
new file mode 100644
index 000000000..35db9296c
--- /dev/null
+++ b/src/test/rustdoc-json/traits/trait_alias.rs
@@ -0,0 +1,30 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/104923>
+// ignore-tidy-linelength
+
+#![feature(trait_alias)]
+
+// @set Orig = "$.index[*][?(@.name == 'Orig')].id"
+// @is "$.index[*][?(@.name == 'Orig')].kind" '"trait"'
+pub trait Orig<T> {}
+
+// @set Alias = "$.index[*][?(@.name == 'Alias')].id"
+// @is "$.index[*][?(@.name == 'Alias')].kind" '"trait_alias"'
+// @is "$.index[*][?(@.name == 'Alias')].inner.generics" '{"params": [], "where_predicates": []}'
+// @count "$.index[*][?(@.name == 'Alias')].inner.params[*]" 1
+// @is "$.index[*][?(@.name == 'Alias')].inner.params[0].trait_bound.trait.id" $Orig
+// @is "$.index[*][?(@.name == 'Alias')].inner.params[0].trait_bound.trait.args.angle_bracketed.args[0].type.inner" '"i32"'
+pub trait Alias = Orig<i32>;
+
+pub struct Struct;
+
+impl Orig<i32> for Struct {}
+
+// @is "$.index[*][?(@.name=='takes_alias')].inner.decl.inputs[0][1].kind" '"impl_trait"'
+// @is "$.index[*][?(@.name=='takes_alias')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $Alias
+// @is "$.index[*][?(@.name=='takes_alias')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $Alias
+pub fn takes_alias(_: impl Alias) {}
+// FIXME: Should the trait be mentioned in both the decl and generics?
+
+fn main() {
+ takes_alias(Struct);
+}
diff --git a/src/test/rustdoc-json/traits/uses_extern_trait.rs b/src/test/rustdoc-json/traits/uses_extern_trait.rs
index 430dd1543..55a51f739 100644
--- a/src/test/rustdoc-json/traits/uses_extern_trait.rs
+++ b/src/test/rustdoc-json/traits/uses_extern_trait.rs
@@ -1,7 +1,5 @@
#![no_std]
pub fn drop_default<T: core::default::Default>(_x: T) {}
-// FIXME(adotinthevoid): Theses shouldn't be here
-// @has "$.index[*][?(@.name=='Debug')]"
-// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[*]"
-// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt
+// @!has "$.index[*][?(@.name=='Debug')]"
+// @!has "$.index[*][?(@.name=='Default')]"