From 4547b622d8d29df964fa2914213088b148c498fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:32 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- src/test/rustdoc-json/enums/auxiliary/color.rs | 5 ++++ .../enums/doc_link_to_foreign_variant.rs | 11 ++++++++ src/test/rustdoc-json/enums/use_glob.rs | 18 +++++++++++++ src/test/rustdoc-json/enums/use_variant.rs | 15 +++++++++++ src/test/rustdoc-json/enums/use_variant_foreign.rs | 9 +++++++ src/test/rustdoc-json/fns/pattern_arg.rs | 7 +++++ src/test/rustdoc-json/fns/return_type_alias.rs | 10 ++++++++ src/test/rustdoc-json/impls/import_from_private.rs | 2 +- .../auxiliary/enum_variant_in_trait_method.rs | 8 ++++++ .../intra-doc-links/foreign_variant.rs | 13 ++++++++++ .../reexport/auxiliary/trait_with_docs.rs | 2 ++ .../reexport/synthesize_trait_with_docs.rs | 10 ++++++++ src/test/rustdoc-json/traits/trait_alias.rs | 30 ++++++++++++++++++++++ src/test/rustdoc-json/traits/uses_extern_trait.rs | 6 ++--- 14 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc-json/enums/auxiliary/color.rs create mode 100644 src/test/rustdoc-json/enums/doc_link_to_foreign_variant.rs create mode 100644 src/test/rustdoc-json/enums/use_glob.rs create mode 100644 src/test/rustdoc-json/enums/use_variant.rs create mode 100644 src/test/rustdoc-json/enums/use_variant_foreign.rs create mode 100644 src/test/rustdoc-json/fns/pattern_arg.rs create mode 100644 src/test/rustdoc-json/fns/return_type_alias.rs create mode 100644 src/test/rustdoc-json/intra-doc-links/auxiliary/enum_variant_in_trait_method.rs create mode 100644 src/test/rustdoc-json/intra-doc-links/foreign_variant.rs create mode 100644 src/test/rustdoc-json/reexport/auxiliary/trait_with_docs.rs create mode 100644 src/test/rustdoc-json/reexport/synthesize_trait_with_docs.rs create mode 100644 src/test/rustdoc-json/traits/trait_alias.rs (limited to 'src/test/rustdoc-json') 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 + +#![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, _): (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 + +/// @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 +// 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 +// 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 +// ignore-tidy-linelength + +#![feature(trait_alias)] + +// @set Orig = "$.index[*][?(@.name == 'Orig')].id" +// @is "$.index[*][?(@.name == 'Orig')].kind" '"trait"' +pub trait Orig {} + +// @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; + +pub struct Struct; + +impl Orig 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(_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')]" -- cgit v1.2.3