diff options
Diffstat (limited to 'tests/rustdoc/inline_cross')
38 files changed, 815 insertions, 47 deletions
diff --git a/tests/rustdoc/inline_cross/assoc-const-equality.rs b/tests/rustdoc/inline_cross/assoc-const-equality.rs new file mode 100644 index 000000000..1d3ce9e31 --- /dev/null +++ b/tests/rustdoc/inline_cross/assoc-const-equality.rs @@ -0,0 +1,8 @@ +// aux-crate:assoc_const_equality=assoc-const-equality.rs +// edition:2021 + +#![crate_name = "user"] + +// @has user/fn.accept.html +// @has - '//pre[@class="rust item-decl"]' 'fn accept(_: impl Trait<K = 0>)' +pub use assoc_const_equality::accept; diff --git a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs index db2491b87..74ceb697a 100644 --- a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -42,3 +42,15 @@ pub use aux::Main; // @has main/trait.Aid.html // @has - '//*[@id="associatedtype.Result"]' "type Result<'inter: 'src>" pub use aux::Aid; + +// Below, ensure that we correctly display generic parameters and where-clauses on +// associated types inside trait *impls*. More particularly, check that we don't render +// any bounds (here `Self::Alias<T>: ...`) as item bounds unlike all the trait test cases above. + +// @has main/struct.Implementor.html +// @has - '//*[@id="associatedtype.Alias"]' \ +// "type Alias<T: Eq> = T \ +// where \ +// String: From<T>, \ +// <Implementor as Implementee>::Alias<T>: From<<Implementor as Implementee>::Alias<T>>" +pub use aux::Implementor; diff --git a/tests/rustdoc/inline_cross/async-fn.rs b/tests/rustdoc/inline_cross/async-fn.rs new file mode 100644 index 000000000..95e175aab --- /dev/null +++ b/tests/rustdoc/inline_cross/async-fn.rs @@ -0,0 +1,19 @@ +// Regression test for issue #115760. +// Check that we render the correct return type of free and +// associated async functions reexported from external crates. + +// aux-crate:async_fn=async-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub async fn load() -> i32" +pub use async_fn::load; + +// @has user/trait.Load.html +// @has - '//*[@id="tymethod.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Load; + +// @has user/struct.Loader.html +// @has - '//*[@id="method.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Loader; diff --git a/tests/rustdoc/inline_cross/attributes.rs b/tests/rustdoc/inline_cross/attributes.rs new file mode 100644 index 000000000..c0b75c48f --- /dev/null +++ b/tests/rustdoc/inline_cross/attributes.rs @@ -0,0 +1,7 @@ +// aux-crate:attributes=attributes.rs +// edition:2021 +#![crate_name = "user"] + +// @has 'user/struct.NonExhaustive.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[non_exhaustive]' +pub use attributes::NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc-const-equality.rs b/tests/rustdoc/inline_cross/auxiliary/assoc-const-equality.rs new file mode 100644 index 000000000..6a25dcea6 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/assoc-const-equality.rs @@ -0,0 +1,7 @@ +#![feature(associated_const_equality)] + +pub fn accept(_: impl Trait<K = 0>) {} + +pub trait Trait { + const K: i32; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs index 6644c8e41..551e97a2f 100644 --- a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -44,3 +44,20 @@ pub trait Helper { pub trait Aid<'src> { type Result<'inter: 'src>; } + +pub trait Implementee { + type Alias<T: Eq> + where + String: From<T>; +} + +pub struct Implementor; + +impl Implementee for Implementor { + type Alias<T: Eq> = T + where + String: From<T>, + // We will check that this bound doesn't get turned into an item bound since + // associated types in impls are not allowed to have any. + Self::Alias<T>: From<Self::Alias<T>>; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs new file mode 100644 index 000000000..564ca7d67 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs @@ -0,0 +1,17 @@ +// edition: 2021 + +pub async fn load() -> i32 { + 0 +} + +pub trait Load { + async fn run(&self) -> i32; +} + +pub struct Loader; + +impl Load for Loader { + async fn run(&self) -> i32 { + 1 + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/attributes.rs b/tests/rustdoc/inline_cross/auxiliary/attributes.rs new file mode 100644 index 000000000..c6f155d4b --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/attributes.rs @@ -0,0 +1,2 @@ +#[non_exhaustive] +pub struct NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs new file mode 100644 index 000000000..b0c21ffae --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs @@ -0,0 +1,16 @@ +#![feature(effects, const_trait_impl)] + +#[const_trait] +pub trait Resource {} + +pub const fn load<R: ~const Resource>() -> i32 { + 0 +} + +pub const fn lock<R: Resource>() {} + +#[allow(non_upper_case_globals)] +pub trait Clash<const host: u64> {} + +#[allow(non_upper_case_globals)] +pub const fn clash<T: Clash<host>, const host: u64>() {} diff --git a/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs new file mode 100644 index 000000000..1e31f1892 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs @@ -0,0 +1,45 @@ +pub type BoxedStr = Box<str>; +pub type IntMap = std::collections::HashMap<i64, u64>; + +pub struct TyPair<T, U = T>(T, U); + +pub type T0 = TyPair<i32>; +pub type T1 = TyPair<i32, u32>; +pub type T2<K> = TyPair<i32, K>; +pub type T3<Q> = TyPair<Q, Q>; + +pub struct CtPair<const C: u32, const D: u32 = C>; + +pub type C0 = CtPair<43, 43>; +pub type C1 = CtPair<0, 1>; +pub type C2 = CtPair<{1 + 2}, 3>; + +pub struct Re<'a, U = &'a ()>(&'a (), U); + +pub type R0<'q> = Re<'q>; +pub type R1<'q> = Re<'q, &'q ()>; +pub type R2<'q> = Re<'q, &'static ()>; +pub type H0 = fn(for<'a> fn(Re<'a>)); +pub type H1 = for<'b> fn(for<'a> fn(Re<'a, &'b ()>)); +pub type H2 = for<'a> fn(for<'b> fn(Re<'a, &'b ()>)); + +pub struct Proj<T: Basis, U = <T as Basis>::Assoc>(T, U); +pub trait Basis { type Assoc; } +impl Basis for () { type Assoc = bool; } + +pub type P0 = Proj<()>; +pub type P1 = Proj<(), bool>; +pub type P2 = Proj<(), ()>; + +pub struct Alpha<T = for<'any> fn(&'any ())>(T); + +pub type A0 = Alpha; +pub type A1 = Alpha<for<'arbitrary> fn(&'arbitrary ())>; + +pub struct Multi<A = u64, B = u64>(A, B); + +pub type M0 = Multi<u64, ()>; + +pub trait Trait<'a, T = &'a ()> {} + +pub type F = dyn for<'a> Trait<'a>; diff --git a/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs b/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs index 9ac2e3d96..df8853007 100644 --- a/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs @@ -1,3 +1,5 @@ +// ignore-tidy-linelength + pub type Ty0 = dyn for<'any> FnOnce(&'any str) -> bool; pub type Ty1<'obj> = dyn std::fmt::Display + 'obj; @@ -6,12 +8,79 @@ pub type Ty2 = dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>; pub type Ty3<'s> = &'s dyn ToString; -pub fn func0(_: &(dyn Fn() + '_)) {} - -pub fn func1<'func>(_: &(dyn Fn() + 'func)) {} - pub trait Container<'r> { type Item<'a, 'ctx>; } -pub trait Shape<'a> {} +// Trait-object types inside of a container type that has lifetime bounds ("wrapped"). + +pub fn late_bound_wrapped_elided(_: &(dyn Fn() + '_)) {} +pub fn late_bound_wrapped_late0<'f>(_: &mut (dyn Fn() + 'f)) {} +pub fn late_bound_wrapped_defaulted0<'f>(_: &'f mut dyn Fn()) {} +pub type EarlyBoundWrappedDefaulted0<'x> = std::cell::Ref<'x, dyn Trait>; +pub type EarlyBoundWrappedDefaulted1<'x> = &'x dyn Trait; +pub type EarlyBoundWrappedEarly<'x, 'y> = std::cell::Ref<'x, dyn Trait + 'y>; +pub type EarlyBoundWrappedStatic<'x> = std::cell::Ref<'x, dyn Trait + 'static>; +pub fn late_bound_wrapped_defaulted1<'l>(_: std::cell::Ref<'l, dyn Trait>) {} +pub fn late_bound_wrapped_late1<'l, 'm>(_: std::cell::Ref<'l, dyn Trait + 'm>) {} +pub fn late_bound_wrapped_early<'e, 'l>(_: std::cell::Ref<'l, dyn Trait + 'e>) where 'e: {} // `'e` is early-bound +pub fn elided_bound_wrapped_defaulted(_: std::cell::Ref<'_, dyn Trait>) {} +pub type StaticBoundWrappedDefaulted0 = std::cell::Ref<'static, dyn Trait>; +pub type StaticBoundWrappedDefaulted1 = &'static dyn Trait; +pub type AmbiguousBoundWrappedEarly0<'r, 's> = AmbiguousBoundWrapper<'s, 'r, dyn Trait + 's>; +pub type AmbiguousBoundWrappedEarly1<'r, 's> = AmbiguousBoundWrapper<'s, 'r, dyn Trait + 'r>; +pub type AmbiguousBoundWrappedStatic<'q> = AmbiguousBoundWrapper<'q, 'q, dyn Trait + 'static>; + +// Trait-object types inside of a container type that doesn't have lifetime bounds ("wrapped"). + +pub type NoBoundsWrappedDefaulted = Box<dyn Trait>; +pub type NoBoundsWrappedEarly<'e> = Box<dyn Trait + 'e>; +pub fn no_bounds_wrapped_late<'l>(_: Box<dyn Trait + 'l>) {} +pub fn no_bounds_wrapped_elided(_: Box<dyn Trait + '_>) {} + +// Trait-object types outside of a container (“bare”). + +pub type BareNoBoundsDefaulted = dyn Trait; +pub type BareNoBoundsEarly<'p> = dyn Trait + 'p; +pub type BareEarlyBoundDefaulted0<'u> = dyn EarlyBoundTrait0<'u>; +pub type BareEarlyBoundDefaulted1 = dyn for<'any> EarlyBoundTrait0<'any>; +pub type BareEarlyBoundDefaulted2<'w> = dyn EarlyBoundTrait1<'static, 'w>; +pub type BareEarlyBoundEarly<'i, 'j> = dyn EarlyBoundTrait0<'i> + 'j; +pub type BareEarlyBoundStatic<'i> = dyn EarlyBoundTrait0<'i> + 'static; +pub type BareStaticBoundDefaulted = dyn StaticBoundTrait; +pub type BareHigherRankedBoundDefaulted0 = dyn HigherRankedBoundTrait0; +pub type BareHigherRankedBoundDefaulted1<'r> = dyn HigherRankedBoundTrait1<'r>; +pub type BareAmbiguousBoundEarly0<'m, 'n> = dyn AmbiguousBoundTrait<'m, 'n> + 'm; +pub type BareAmbiguousBoundEarly1<'m, 'n> = dyn AmbiguousBoundTrait<'m, 'n> + 'n; +pub type BareAmbiguousBoundStatic<'o> = dyn AmbiguousBoundTrait<'o, 'o> + 'static; + +// Trait and container definitions. + +pub trait Trait {} // no bounds +pub trait EarlyBoundTrait0<'b>: 'b {} +pub trait EarlyBoundTrait1<'unused, 'c>: 'c {} +pub trait StaticBoundTrait: 'static {} +pub trait HigherRankedBoundTrait0 where for<'a> Self: 'a {} +pub trait HigherRankedBoundTrait1<'e> where for<'l> Self: 'e + 'l {} +pub trait AmbiguousBoundTrait<'a, 'b>: 'a + 'b {} + +pub struct AmbiguousBoundWrapper<'a, 'b, T: ?Sized + 'a + 'b>(&'a T, &'b T); + +// Trait objects inside of another trait object, a trait bound or an associated type. + +pub trait Inner {} +pub trait Outer<T: ?Sized> {} +pub trait Base { + type Type<T: ?Sized>; +} +impl Base for () { + type Type<T: ?Sized> = (); +} + +pub type NestedTraitObjects = dyn Outer<dyn Inner>; + +pub fn apit_rpit(o: impl Outer<dyn Inner>) -> impl Outer<dyn Inner> { + o +} + +pub type AssocTy = <() as Base>::Type<dyn Inner>; diff --git a/tests/rustdoc/inline_cross/auxiliary/fn-type.rs b/tests/rustdoc/inline_cross/auxiliary/fn-type.rs new file mode 100644 index 000000000..dacda516b --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/fn-type.rs @@ -0,0 +1 @@ +pub type F = for<'z, 'a, '_unused> fn(&'z for<'b> fn(&'b str), &'a ()) -> &'a (); diff --git a/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs b/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs new file mode 100644 index 000000000..0fc7a7aae --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs @@ -0,0 +1,22 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From<T>; + +pub trait Trait<T: ?Sized> { + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +impl Trait<str> for Implementor { + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs b/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs new file mode 100644 index 000000000..65f72a3b9 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs @@ -0,0 +1,21 @@ +use std::fmt::Debug; + +pub fn sized(x: impl Sized) -> impl Sized { + x +} + +pub fn sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a { + x +} + +pub fn maybe_sized(x: &impl ?Sized) -> &impl ?Sized { + x +} + +pub fn debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized) { + x +} + +pub fn maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't) { + x +} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs index 19433c968..fa61312eb 100644 --- a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs +++ b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -15,7 +15,7 @@ pub fn func4<T: Iterator<Item = impl Clone>>(_x: T) {} pub fn func5( _f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>, - _a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>, + _a: impl for<'beta, 'alpha, '_gamma> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>, ) {} pub trait Other { @@ -33,9 +33,3 @@ pub struct Foo; impl Foo { pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {} } - -pub struct Bar; - -impl Bar { - pub async fn async_foo(&self) {} -} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs b/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs new file mode 100644 index 000000000..732612ff0 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs @@ -0,0 +1,9 @@ +// compile-flags: -Cmetadata=aux + +pub struct Foo; + +impl Foo { + pub fn new<F>(f: F) -> Foo where F: FnMut() -> i32 { + loop {} + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs b/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs new file mode 100644 index 000000000..8531d5f1a --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs @@ -0,0 +1,3 @@ +pub mod fmt { + pub struct Error; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs b/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs new file mode 100644 index 000000000..b92b16653 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs @@ -0,0 +1,5 @@ +extern crate issue_23207_1; + +pub mod fmt { + pub use issue_23207_1::fmt::Error; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs b/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs new file mode 100644 index 000000000..077bdc33e --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs @@ -0,0 +1,10 @@ +// compile-flags: -Cmetadata=aux + +pub const fn foo() {} +pub const unsafe fn bar() {} + +pub struct Foo; + +impl Foo { + pub const unsafe fn baz() {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs b/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs new file mode 100644 index 000000000..a9b8796c0 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs @@ -0,0 +1,10 @@ +// compile-flags: -Cmetadata=aux + +pub struct Foo; + +#[doc(hidden)] +mod bar { + trait Bar {} + + impl Bar for ::Foo {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs b/tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs new file mode 100644 index 000000000..9170be168 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs @@ -0,0 +1,10 @@ +#![feature(non_lifetime_binders)] + +pub trait Trait<T> {} + +pub fn f(_: impl for<T> Trait<T>) {} + +pub fn g<T>(_: T) +where + T: for<U> Trait<U>, +{} diff --git a/tests/rustdoc/inline_cross/auxiliary/repr.rs b/tests/rustdoc/inline_cross/auxiliary/repr.rs index 4a6648a64..35f08c11b 100644 --- a/tests/rustdoc/inline_cross/auxiliary/repr.rs +++ b/tests/rustdoc/inline_cross/auxiliary/repr.rs @@ -10,7 +10,7 @@ pub struct ReprSimd { } #[repr(transparent)] pub struct ReprTransparent { - field: u8, + pub field: u8, } #[repr(isize)] pub enum ReprIsize { @@ -20,3 +20,23 @@ pub enum ReprIsize { pub enum ReprU8 { Bla, } + +#[repr(transparent)] // private +pub struct ReprTransparentPrivField { + field: u32, // non-1-ZST field +} + +#[repr(transparent)] // public +pub struct ReprTransparentPriv1ZstFields { + marker0: Marker, + pub main: u64, // non-1-ZST field + marker1: Marker, +} + +#[repr(transparent)] // private +pub struct ReprTransparentPrivFieldPub1ZstFields { + main: [u16; 0], // non-1-ZST field + pub marker: Marker, +} + +pub struct Marker; // 1-ZST diff --git a/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs new file mode 100644 index 000000000..08a3f5176 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs @@ -0,0 +1,33 @@ +pub trait Trait { + fn create() -> impl Iterator<Item = u64> { + std::iter::empty() + } +} + +pub struct Basic; +pub struct Intermediate; +pub struct Advanced; + +impl Trait for Basic { + // method provided by the trait +} + +impl Trait for Intermediate { + fn create() -> std::ops::Range<u64> { // concrete return type + 0..1 + } +} + +impl Trait for Advanced { + fn create() -> impl Iterator<Item = u64> { // opaque return type + std::iter::repeat(0) + } +} + +// Regression test for issue #113929: + +pub trait Def { + fn def<T>() -> impl Default {} +} + +impl Def for () {} diff --git a/tests/rustdoc/inline_cross/const-effect-param.rs b/tests/rustdoc/inline_cross/const-effect-param.rs new file mode 100644 index 000000000..1d003e28f --- /dev/null +++ b/tests/rustdoc/inline_cross/const-effect-param.rs @@ -0,0 +1,29 @@ +// Regression test for issue #116629. +// Check that we don't render host effect parameters & arguments. + +// aux-crate:const_effect_param=const-effect-param.rs +// edition: 2021 +#![crate_name = "user"] + +// Don't render the host param on `load` and the host arg `host` passed to `Resource`. +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn load<R>() -> i32\ +// where \ +// R: Resource" +pub use const_effect_param::load; + +// Don't render the host arg `true` passed to `Resource`. +// @has user/fn.lock.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn lock<R>()\ +// where \ +// R: Resource" +pub use const_effect_param::lock; + +// Regression test for an issue introduced in PR #116670. +// Don't hide the const param `host` since it actually isn't the host effect param. +// @has user/fn.clash.html +// @has - '//pre[@class="rust item-decl"]' \ +// "pub const fn clash<T, const host: u64>()\ +// where \ +// T: Clash<host>" +pub use const_effect_param::clash; diff --git a/tests/rustdoc/inline_cross/const-fn-27362.rs b/tests/rustdoc/inline_cross/const-fn-27362.rs new file mode 100644 index 000000000..39b904662 --- /dev/null +++ b/tests/rustdoc/inline_cross/const-fn-27362.rs @@ -0,0 +1,13 @@ +// aux-build:issue-27362-aux.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/27362 +#![crate_name="issue_27362"] + +extern crate issue_27362_aux; + +pub use issue_27362_aux::*; + +// @matches issue_27362/fn.foo.html '//pre' "pub const fn foo()" +// @matches issue_27362/fn.bar.html '//pre' "pub const unsafe fn bar()" +// @matches issue_27362/struct.Foo.html '//h4[@class="code-header"]' "const unsafe fn baz()" diff --git a/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs new file mode 100644 index 000000000..4e9596db5 --- /dev/null +++ b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs @@ -0,0 +1,12 @@ +// aux-build:issue-23207-1.rs +// aux-build:issue-23207-2.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/23207 +#![crate_name="issue_23207"] + +extern crate issue_23207_2; + +// @has issue_23207/fmt/index.html +// @count - '//*[@class="struct"]' 1 +pub use issue_23207_2::fmt; diff --git a/tests/rustdoc/inline_cross/default-generic-args.rs b/tests/rustdoc/inline_cross/default-generic-args.rs new file mode 100644 index 000000000..c9a87a199 --- /dev/null +++ b/tests/rustdoc/inline_cross/default-generic-args.rs @@ -0,0 +1,104 @@ +#![crate_name = "user"] +// aux-crate:default_generic_args=default-generic-args.rs +// edition:2021 + +// @has user/type.BoxedStr.html +// @has - '//*[@class="rust item-decl"]//code' "Box<str>" +pub use default_generic_args::BoxedStr; + +// @has user/type.IntMap.html +// @has - '//*[@class="rust item-decl"]//code' "HashMap<i64, u64>" +pub use default_generic_args::IntMap; + +// @has user/type.T0.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32>" +pub use default_generic_args::T0; + +// @has user/type.T1.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32, u32>" +pub use default_generic_args::T1; + +// @has user/type.T2.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32, K>" +pub use default_generic_args::T2; + +// @has user/type.T3.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<Q>" +pub use default_generic_args::T3; + +// @has user/type.C0.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<43>" +pub use default_generic_args::C0; + +// @has user/type.C1.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<0, 1>" +pub use default_generic_args::C1; + +// @has user/type.C2.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<default_generic_args::::C2::{constant#0}, 3>" +pub use default_generic_args::C2; + +// @has user/type.R0.html +// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +pub use default_generic_args::R0; + +// @has user/type.R1.html +// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +pub use default_generic_args::R1; + +// @has user/type.R2.html +// Check that we consider regions: +// @has - '//*[@class="rust item-decl"]//code' "Re<'q, &'static ()>" +pub use default_generic_args::R2; + +// @has user/type.H0.html +// Check that we handle higher-ranked regions correctly: +// @has - '//*[@class="rust item-decl"]//code' "fn(_: for<'a> fn(_: Re<'a>))" +pub use default_generic_args::H0; + +// @has user/type.H1.html +// Check that we don't conflate distinct universially quantified regions (#1): +// @has - '//*[@class="rust item-decl"]//code' "for<'b> fn(_: for<'a> fn(_: Re<'a, &'b ()>))" +pub use default_generic_args::H1; + +// @has user/type.H2.html +// Check that we don't conflate distinct universially quantified regions (#2): +// @has - '//*[@class="rust item-decl"]//code' "for<'a> fn(_: for<'b> fn(_: Re<'a, &'b ()>))" +pub use default_generic_args::H2; + +// @has user/type.P0.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<()>" +pub use default_generic_args::P0; + +// @has user/type.P1.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<(), bool>" +pub use default_generic_args::P1; + +// @has user/type.P2.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<(), ()>" +pub use default_generic_args::P2; + +// @has user/type.A0.html +// Ensure that we elide generic arguments that are alpha-equivalent to their respective +// generic parameter (modulo substs) (#1): +// @has - '//*[@class="rust item-decl"]//code' "Alpha" +pub use default_generic_args::A0; + +// @has user/type.A1.html +// Ensure that we elide generic arguments that are alpha-equivalent to their respective +// generic parameter (modulo substs) (#1): +// @has - '//*[@class="rust item-decl"]//code' "Alpha" +pub use default_generic_args::A1; + +// @has user/type.M0.html +// Test that we don't elide `u64` even if it coincides with `A`'s default precisely because +// `()` is not the default of `B`. Mindlessly eliding `u64` would lead to `M<()>` which is a +// different type (`M<(), u64>` versus `M<u64, ()>`). +// @has - '//*[@class="rust item-decl"]//code' "Multi<u64, ()>" +pub use default_generic_args::M0; + +// @has user/type.F.html +// FIXME: Ideally, we would elide `&'a ()` but `'a` is an escaping bound var which we can't reason +// about at the moment since we don't keep track of bound vars. +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait<'a, &'a ()>" +pub use default_generic_args::F; diff --git a/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs new file mode 100644 index 000000000..b246e94e0 --- /dev/null +++ b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs @@ -0,0 +1,11 @@ +// aux-build:issue-29584.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/29584 +#![crate_name="issue_29584"] + +extern crate issue_29584; + +// @has issue_29584/struct.Foo.html +// @!hasraw - 'impl Bar for' +pub use issue_29584::Foo; diff --git a/tests/rustdoc/inline_cross/dyn_trait.rs b/tests/rustdoc/inline_cross/dyn_trait.rs index 649d98f71..9871be79c 100644 --- a/tests/rustdoc/inline_cross/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/dyn_trait.rs @@ -1,31 +1,145 @@ #![crate_name = "user"] +// In each test case, we include the trailing semicolon to ensure that nothing extra comes +// after the type like an unwanted outlives-bound. + // aux-crate:dyn_trait=dyn_trait.rs // edition:2021 // @has user/type.Ty0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> FnOnce(&'any str) -> bool + 'static" -// FIXME(fmease): Hide default lifetime bound `'static` +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> FnOnce(&'any str) -> bool;" pub use dyn_trait::Ty0; // @has user/type.Ty1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Display + 'obj" +// @has - '//*[@class="rust item-decl"]//code' "dyn Display + 'obj;" pub use dyn_trait::Ty1; // @has user/type.Ty2.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>" +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>;" pub use dyn_trait::Ty2; // @has user/type.Ty3.html -// @has - '//*[@class="rust item-decl"]//code' "&'s (dyn ToString + 's)" -// FIXME(fmease): Hide default lifetime bound, render "&'s dyn ToString" +// @has - '//*[@class="rust item-decl"]//code' "&'s dyn ToString;" pub use dyn_trait::Ty3; -// @has user/fn.func0.html -// @has - '//pre[@class="rust item-decl"]' "func0(_: &dyn Fn())" -// FIXME(fmease): Show placeholder-lifetime bound, render "func0(_: &(dyn Fn() + '_))" -pub use dyn_trait::func0; +// Below we check if we correctly elide trait-object lifetime bounds if they coincide with their +// default (known as "object lifetime default" or "default trait object lifetime"). + +// @has user/fn.lbwel.html +// @has - '//pre[@class="rust item-decl"]' "lbwel(_: &dyn Fn())" +pub use dyn_trait::late_bound_wrapped_elided as lbwel; +// @has user/fn.lbwl0.html +// has - '//pre[@class="rust item-decl"]' "lbwl0<'f>(_: &mut (dyn Fn() + 'f))" +pub use dyn_trait::late_bound_wrapped_late0 as lbwl0; +// @has user/fn.lbwd0.html +// has - '//pre[@class="rust item-decl"]' "lbwd0<'f>(_: &'f mut dyn Fn())" +pub use dyn_trait::late_bound_wrapped_defaulted0 as lbwd0; +// @has user/type.EarlyBoundWrappedDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait>;" +pub use dyn_trait::EarlyBoundWrappedDefaulted0; +// @has user/type.EarlyBoundWrappedDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "&'x dyn Trait;" +pub use dyn_trait::EarlyBoundWrappedDefaulted1; +// @has user/type.EarlyBoundWrappedEarly.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'y>" +pub use dyn_trait::EarlyBoundWrappedEarly; +// @has user/type.EarlyBoundWrappedStatic.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'static>" +pub use dyn_trait::EarlyBoundWrappedStatic; +// @has user/fn.lbwd1.html +// @has - '//pre[@class="rust item-decl"]' "lbwd1<'l>(_: Ref<'l, dyn Trait>)" +pub use dyn_trait::late_bound_wrapped_defaulted1 as lbwd1; +// @has user/fn.lbwl1.html +// @has - '//pre[@class="rust item-decl"]' "lbwl1<'l, 'm>(_: Ref<'l, dyn Trait + 'm>)" +pub use dyn_trait::late_bound_wrapped_late1 as lbwl1; +// @has user/fn.lbwe.html +// @has - '//pre[@class="rust item-decl"]' "lbwe<'e, 'l>(_: Ref<'l, dyn Trait + 'e>)" +pub use dyn_trait::late_bound_wrapped_early as lbwe; +// @has user/fn.ebwd.html +// @has - '//pre[@class="rust item-decl"]' "ebwd(_: Ref<'_, dyn Trait>)" +pub use dyn_trait::elided_bound_wrapped_defaulted as ebwd; +// @has user/type.StaticBoundWrappedDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'static, dyn Trait>;" +pub use dyn_trait::StaticBoundWrappedDefaulted0; +// @has user/type.StaticBoundWrappedDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "&'static dyn Trait;" +pub use dyn_trait::StaticBoundWrappedDefaulted1; +// @has user/type.AmbiguousBoundWrappedEarly0.html +// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 's>;" +pub use dyn_trait::AmbiguousBoundWrappedEarly0; +// @has user/type.AmbiguousBoundWrappedEarly1.html +// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 'r>;" +pub use dyn_trait::AmbiguousBoundWrappedEarly1; +// @has user/type.AmbiguousBoundWrappedStatic.html +// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'q, 'q, dyn Trait + 'static>;" +pub use dyn_trait::AmbiguousBoundWrappedStatic; + +// @has user/type.NoBoundsWrappedDefaulted.html +// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait>;" +pub use dyn_trait::NoBoundsWrappedDefaulted; +// @has user/type.NoBoundsWrappedEarly.html +// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait + 'e>;" +pub use dyn_trait::NoBoundsWrappedEarly; +// @has user/fn.nbwl.html +// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box<dyn Trait + 'l>)" +pub use dyn_trait::no_bounds_wrapped_late as nbwl; +// @has user/fn.nbwel.html +// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box<dyn Trait + '_>)" +// NB: It might seem counterintuitive to display the explicitly elided lifetime `'_` here instead of +// eliding it but this behavior is correct: The default is `'static` here which != `'_`. +pub use dyn_trait::no_bounds_wrapped_elided as nbwel; + +// @has user/type.BareNoBoundsDefaulted.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait;" +pub use dyn_trait::BareNoBoundsDefaulted; +// @has user/type.BareNoBoundsEarly.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait + 'p;" +pub use dyn_trait::BareNoBoundsEarly; +// @has user/type.BareEarlyBoundDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'u>;" +pub use dyn_trait::BareEarlyBoundDefaulted0; +// @has user/type.BareEarlyBoundDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> EarlyBoundTrait0<'any>;" +pub use dyn_trait::BareEarlyBoundDefaulted1; +// @has user/type.BareEarlyBoundDefaulted2.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait1<'static, 'w>;" +pub use dyn_trait::BareEarlyBoundDefaulted2; +// @has user/type.BareEarlyBoundEarly.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'j;" +pub use dyn_trait::BareEarlyBoundEarly; +// @has user/type.BareEarlyBoundStatic.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'static;" +pub use dyn_trait::BareEarlyBoundStatic; +// @has user/type.BareStaticBoundDefaulted.html +// @has - '//*[@class="rust item-decl"]//code' "dyn StaticBoundTrait;" +pub use dyn_trait::BareStaticBoundDefaulted; +// @has user/type.BareHigherRankedBoundDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait0;" +pub use dyn_trait::BareHigherRankedBoundDefaulted0; +// @has user/type.BareHigherRankedBoundDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait1<'r>;" +pub use dyn_trait::BareHigherRankedBoundDefaulted1; +// @has user/type.BareAmbiguousBoundEarly0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'm;" +pub use dyn_trait::BareAmbiguousBoundEarly0; +// @has user/type.BareAmbiguousBoundEarly1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'n;" +pub use dyn_trait::BareAmbiguousBoundEarly1; +// @has user/type.BareAmbiguousBoundStatic.html +// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'o, 'o> + 'static;" +pub use dyn_trait::BareAmbiguousBoundStatic; + +// Regression test for issue #115179: + +// @has user/type.NestedTraitObjects.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Outer<dyn Inner>;" +pub use dyn_trait::NestedTraitObjects; + +// @has user/fn.apit_rpit.html +// @has - '//pre[@class="rust item-decl"]' \ +// "apit_rpit(o: impl Outer<dyn Inner>) -> impl Outer<dyn Inner>" +pub use dyn_trait::apit_rpit; -// @has user/fn.func1.html -// @has - '//pre[@class="rust item-decl"]' "func1<'func>(_: &(dyn Fn() + 'func))" -pub use dyn_trait::func1; +// @has user/type.AssocTy.html +// @has - '//*[@class="rust item-decl"]//code' "<() as Base>::Type<dyn Inner>" +pub use dyn_trait::AssocTy; diff --git a/tests/rustdoc/inline_cross/fn-type.rs b/tests/rustdoc/inline_cross/fn-type.rs new file mode 100644 index 000000000..e65790d3b --- /dev/null +++ b/tests/rustdoc/inline_cross/fn-type.rs @@ -0,0 +1,12 @@ +// Make sure that we print the higher-ranked parameters of cross-crate function pointer types. +// They should be rendered exactly as the user wrote it, i.e., in source order and with unused +// parameters present, not stripped. + +// aux-crate:fn_type=fn-type.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/type.F.html +// @has - '//*[@class="rust item-decl"]//code' \ +// "for<'z, 'a, '_unused> fn(_: &'z for<'b> fn(_: &'b str), _: &'a ()) -> &'a ();" +pub use fn_type::F; diff --git a/tests/rustdoc/inline_cross/generic-const-items.rs b/tests/rustdoc/inline_cross/generic-const-items.rs new file mode 100644 index 000000000..70cf7af88 --- /dev/null +++ b/tests/rustdoc/inline_cross/generic-const-items.rs @@ -0,0 +1,26 @@ +#![crate_name = "user"] + +// aux-crate:generic_const_items=generic-const-items.rs +// edition:2021 + +// @has 'user/constant.K.html' +// @has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From<T>;" +pub use generic_const_items::K; + +// @has user/trait.Trait.html +// @has - '//*[@id="associatedconstant.C"]' \ +// "const C<'a>: &'a T \ +// where \ +// T: 'a + Eq" +pub use generic_const_items::Trait; + +// @has user/struct.Implementor.html +// @has - '//h3[@class="code-header"]' 'impl Trait<str> for Implementor' +// @has - '//*[@id="associatedconstant.C"]' \ +// "const C<'a>: &'a str = \"C\" \ +// where \ +// str: 'a" +pub use generic_const_items::Implementor; diff --git a/tests/rustdoc/inline_cross/impl-sized.rs b/tests/rustdoc/inline_cross/impl-sized.rs new file mode 100644 index 000000000..82bdce474 --- /dev/null +++ b/tests/rustdoc/inline_cross/impl-sized.rs @@ -0,0 +1,27 @@ +#![crate_name = "user"] + +// aux-crate:impl_sized=impl-sized.rs +// edition:2021 + +// @has user/fn.sized.html +// @has - '//pre[@class="rust item-decl"]' "sized(x: impl Sized) -> impl Sized" +pub use impl_sized::sized; + +// @has user/fn.sized_outlives.html +// @has - '//pre[@class="rust item-decl"]' \ +// "sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a" +pub use impl_sized::sized_outlives; + +// @has user/fn.maybe_sized.html +// @has - '//pre[@class="rust item-decl"]' "maybe_sized(x: &impl ?Sized) -> &impl ?Sized" +pub use impl_sized::maybe_sized; + +// @has user/fn.debug_maybe_sized.html +// @has - '//pre[@class="rust item-decl"]' \ +// "debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized)" +pub use impl_sized::debug_maybe_sized; + +// @has user/fn.maybe_sized_outlives.html +// @has - '//pre[@class="rust item-decl"]' \ +// "maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't)" +pub use impl_sized::maybe_sized_outlives; diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index b6a1552bc..3a2f5d160 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -4,7 +4,7 @@ extern crate impl_trait_aux; // @has impl_trait/fn.func.html -// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" +// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func; @@ -29,19 +29,11 @@ pub use impl_trait_aux::func4; // @has impl_trait/fn.func5.html // @has - '//pre[@class="rust item-decl"]' "func5(" // @has - '//pre[@class="rust item-decl"]' "_f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>," -// @has - '//pre[@class="rust item-decl"]' "_a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(_: &'beta ())>" +// @has - '//pre[@class="rust item-decl"]' "_a: impl for<'beta, 'alpha, '_gamma> Auxiliary<'alpha, Item<'beta> = fn(_: &'beta ())>" // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func5; -// @has impl_trait/fn.async_fn.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn async_fn()" -pub use impl_trait_aux::async_fn; - // @has impl_trait/struct.Foo.html -// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" +// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" // @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; - -// @has impl_trait/struct.Bar.html -// @has - '//*[@id="method.async_foo"]' "pub async fn async_foo(" -pub use impl_trait_aux::Bar; diff --git a/tests/rustdoc/inline_cross/implementors-js.rs b/tests/rustdoc/inline_cross/implementors-js.rs index c79f05d8d..c17d52d0f 100644 --- a/tests/rustdoc/inline_cross/implementors-js.rs +++ b/tests/rustdoc/inline_cross/implementors-js.rs @@ -4,13 +4,13 @@ extern crate implementors_inline; -// @!has implementors/implementors_js/trait.MyTrait.js -// @has implementors/implementors_inline/my_trait/trait.MyTrait.js -// @!has implementors/implementors_inline/prelude/trait.MyTrait.js +// @!has trait.impl/implementors_js/trait.MyTrait.js +// @has trait.impl/implementors_inline/my_trait/trait.MyTrait.js +// @!has trait.impl/implementors_inline/prelude/trait.MyTrait.js // @has implementors_inline/my_trait/trait.MyTrait.html -// @has - '//script/@src' '../../implementors/implementors_inline/my_trait/trait.MyTrait.js' +// @has - '//script/@src' '../../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' // @has implementors_js/trait.MyTrait.html -// @has - '//script/@src' '../implementors/implementors_inline/my_trait/trait.MyTrait.js' +// @has - '//script/@src' '../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' /// When re-exporting this trait, the HTML will be inlined, /// but, vitally, the JavaScript will be located only at the /// one canonical path. diff --git a/tests/rustdoc/inline_cross/non_lifetime_binders.rs b/tests/rustdoc/inline_cross/non_lifetime_binders.rs new file mode 100644 index 000000000..9d3085c3e --- /dev/null +++ b/tests/rustdoc/inline_cross/non_lifetime_binders.rs @@ -0,0 +1,13 @@ +// aux-crate:non_lifetime_binders=non_lifetime_binders.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.f.html +// @has - '//pre[@class="rust item-decl"]' "f(_: impl for<T> Trait<T>)" +pub use non_lifetime_binders::f; + +// @has user/fn.g.html +// @has - '//pre[@class="rust item-decl"]' "g<T>(_: T)\ +// where \ +// T: for<U> Trait<U>" +pub use non_lifetime_binders::g; diff --git a/tests/rustdoc/inline_cross/repr.rs b/tests/rustdoc/inline_cross/repr.rs index 9e107cee9..2f3d8f003 100644 --- a/tests/rustdoc/inline_cross/repr.rs +++ b/tests/rustdoc/inline_cross/repr.rs @@ -9,21 +9,32 @@ extern crate repr; // @has 'foo/struct.ReprC.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' -#[doc(inline)] pub use repr::ReprC; // @has 'foo/struct.ReprSimd.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' -#[doc(inline)] pub use repr::ReprSimd; // @has 'foo/struct.ReprTransparent.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' -#[doc(inline)] pub use repr::ReprTransparent; // @has 'foo/enum.ReprIsize.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' -#[doc(inline)] pub use repr::ReprIsize; // @has 'foo/enum.ReprU8.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' -#[doc(inline)] pub use repr::ReprU8; + +// Regression test for <https://github.com/rust-lang/rust/issues/90435>. +// Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one +// field is public in case all fields are 1-ZST fields. + +// @has 'foo/struct.ReprTransparentPrivField.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPrivField; + +// @has 'foo/struct.ReprTransparentPriv1ZstFields.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPriv1ZstFields; + +// @has 'foo/struct.ReprTransparentPrivFieldPub1ZstFields.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPrivFieldPub1ZstFields; diff --git a/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs new file mode 100644 index 000000000..8e9ef9020 --- /dev/null +++ b/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs @@ -0,0 +1,35 @@ +#![crate_name = "user"] +// aux-crate:rpitit=ret-pos-impl-trait-in-trait.rs +// edition:2021 + +// Test that we can correctly render cross-crate RPITITs. +// In particular, check that we don't render the internal associated type generated by +// their desugaring. We count the number of associated items and ensure that it is exactly one. +// This is more robust than checking for the absence of the associated type. + +// @has user/trait.Trait.html +// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' +// The class "method" is used for all three kinds of associated items at the time of writing. +// @count - '//*[@id="main-content"]//section[@class="method"]' 1 +pub use rpitit::Trait; + +// @has user/struct.Basic.html +// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +pub use rpitit::Basic; + +// @has user/struct.Intermediate.html +// @has - '//*[@id="method.create"]' 'fn create() -> Range<u64>' +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +pub use rpitit::Intermediate; + +// @has user/struct.Advanced.html +// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +pub use rpitit::Advanced; + +// Regression test for issue #113929: + +// @has user/trait.Def.html +// @has - '//*[@id="method.def"]' 'fn def<T>() -> impl Default' +pub use rpitit::Def; diff --git a/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs new file mode 100644 index 000000000..bcbb2e9f4 --- /dev/null +++ b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs @@ -0,0 +1,12 @@ +// aux-build:issue-21801.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/21801 +#![crate_name="issue_21801"] + +extern crate issue_21801; + +// @has issue_21801/struct.Foo.html +// @has - '//*[@id="method.new"]' \ +// 'fn new<F>(f: F) -> Foowhere F: FnMut() -> i32' +pub use issue_21801::Foo; |