From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/rustdoc/synthetic_auto/basic.rs | 8 +++++ tests/rustdoc/synthetic_auto/complex.rs | 42 ++++++++++++++++++++++ tests/rustdoc/synthetic_auto/crate-local.rs | 9 +++++ .../issue-72213-projection-lifetime.rs | 25 +++++++++++++ tests/rustdoc/synthetic_auto/lifetimes.rs | 19 ++++++++++ tests/rustdoc/synthetic_auto/manual.rs | 14 ++++++++ tests/rustdoc/synthetic_auto/negative.rs | 13 +++++++ tests/rustdoc/synthetic_auto/nested.rs | 19 ++++++++++ tests/rustdoc/synthetic_auto/no-redundancy.rs | 16 +++++++++ tests/rustdoc/synthetic_auto/overflow.rs | 35 ++++++++++++++++++ tests/rustdoc/synthetic_auto/project.rs | 34 ++++++++++++++++++ tests/rustdoc/synthetic_auto/self-referential.rs | 29 +++++++++++++++ tests/rustdoc/synthetic_auto/static-region.rs | 10 ++++++ 13 files changed, 273 insertions(+) create mode 100644 tests/rustdoc/synthetic_auto/basic.rs create mode 100644 tests/rustdoc/synthetic_auto/complex.rs create mode 100644 tests/rustdoc/synthetic_auto/crate-local.rs create mode 100644 tests/rustdoc/synthetic_auto/issue-72213-projection-lifetime.rs create mode 100644 tests/rustdoc/synthetic_auto/lifetimes.rs create mode 100644 tests/rustdoc/synthetic_auto/manual.rs create mode 100644 tests/rustdoc/synthetic_auto/negative.rs create mode 100644 tests/rustdoc/synthetic_auto/nested.rs create mode 100644 tests/rustdoc/synthetic_auto/no-redundancy.rs create mode 100644 tests/rustdoc/synthetic_auto/overflow.rs create mode 100644 tests/rustdoc/synthetic_auto/project.rs create mode 100644 tests/rustdoc/synthetic_auto/self-referential.rs create mode 100644 tests/rustdoc/synthetic_auto/static-region.rs (limited to 'tests/rustdoc/synthetic_auto') diff --git a/tests/rustdoc/synthetic_auto/basic.rs b/tests/rustdoc/synthetic_auto/basic.rs new file mode 100644 index 000000000..7c6a38865 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/basic.rs @@ -0,0 +1,8 @@ +// @has basic/struct.Foo.html +// @has - '//h3[@class="code-header"]' 'impl Send for Foowhere T: Send' +// @has - '//h3[@class="code-header"]' 'impl Sync for Foowhere T: Sync' +// @count - '//*[@id="implementations-list"]//*[@class="impl has-srclink"]' 0 +// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]' 5 +pub struct Foo { + field: T, +} diff --git a/tests/rustdoc/synthetic_auto/complex.rs b/tests/rustdoc/synthetic_auto/complex.rs new file mode 100644 index 000000000..43393c21f --- /dev/null +++ b/tests/rustdoc/synthetic_auto/complex.rs @@ -0,0 +1,42 @@ +mod foo { + pub trait MyTrait<'a> { + type MyItem: ?Sized; + } + + pub struct Inner<'a, Q, R: ?Sized> { + field: Q, + field3: &'a u8, + my_foo: Foo, + field2: R, + } + + pub struct Outer<'a, T, K: ?Sized> { + my_inner: Inner<'a, T, K>, + } + + pub struct Foo { + myfield: T, + } +} + +// @has complex/struct.NotOuter.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'a, T, K: ?Sized> Send for Outer<'a, T, K>where K: for<'b> Fn((&'b bool, &'a u8)) \ +// -> &'b i8, T: MyTrait<'a>, >::MyItem: Copy, 'a: 'static" + +pub use foo::{Foo, Inner as NotInner, MyTrait as NotMyTrait, Outer as NotOuter}; + +unsafe impl Send for Foo +where + T: NotMyTrait<'static>, +{ +} + +unsafe impl<'a, Q, R: ?Sized> Send for NotInner<'a, Q, R> +where + Q: NotMyTrait<'a>, + >::MyItem: Copy, + R: for<'b> Fn((&'b bool, &'a u8)) -> &'b i8, + Foo: Send, +{ +} diff --git a/tests/rustdoc/synthetic_auto/crate-local.rs b/tests/rustdoc/synthetic_auto/crate-local.rs new file mode 100644 index 000000000..ed01f63f9 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/crate-local.rs @@ -0,0 +1,9 @@ +#![feature(auto_traits)] + +pub auto trait Banana {} + +// @has crate_local/struct.Peach.html +// @has - '//h3[@class="code-header"]' 'impl Banana for Peach' +// @has - '//h3[@class="code-header"]' 'impl Send for Peach' +// @has - '//h3[@class="code-header"]' 'impl Sync for Peach' +pub struct Peach; diff --git a/tests/rustdoc/synthetic_auto/issue-72213-projection-lifetime.rs b/tests/rustdoc/synthetic_auto/issue-72213-projection-lifetime.rs new file mode 100644 index 000000000..6f66b8e55 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/issue-72213-projection-lifetime.rs @@ -0,0 +1,25 @@ +// Regression test for issue #72213 +// Tests that we don't ICE when we have projection predicates +// in our initial ParamEnv + +pub struct Lines<'a, L> +where + L: Iterator, +{ + words: std::iter::Peekable>, +} + +pub struct Words<'a, L> { + _m: std::marker::PhantomData<&'a L>, +} + +impl<'a, L> Iterator for Words<'a, L> +where + L: Iterator, +{ + type Item = (); + + fn next(&mut self) -> Option { + unimplemented!() + } +} diff --git a/tests/rustdoc/synthetic_auto/lifetimes.rs b/tests/rustdoc/synthetic_auto/lifetimes.rs new file mode 100644 index 000000000..33170a844 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/lifetimes.rs @@ -0,0 +1,19 @@ +pub struct Inner<'a, T: 'a> { + field: &'a T, +} + +unsafe impl<'a, T> Send for Inner<'a, T> +where + 'a: 'static, + T: for<'b> Fn(&'b bool) -> &'a u8, +{} + +// @has lifetimes/struct.Foo.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Send for Foo<'c, K>where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static" +// +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Sync for Foo<'c, K>where K: Sync" +pub struct Foo<'c, K: 'c> { + inner_field: Inner<'c, K>, +} diff --git a/tests/rustdoc/synthetic_auto/manual.rs b/tests/rustdoc/synthetic_auto/manual.rs new file mode 100644 index 000000000..77c04ad2a --- /dev/null +++ b/tests/rustdoc/synthetic_auto/manual.rs @@ -0,0 +1,14 @@ +// @has manual/struct.Foo.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl Sync for Foowhere T: Sync' +// +// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl Send for Foo' +// +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]' 1 +// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]' 4 +pub struct Foo { + field: T, +} + +unsafe impl Send for Foo {} diff --git a/tests/rustdoc/synthetic_auto/negative.rs b/tests/rustdoc/synthetic_auto/negative.rs new file mode 100644 index 000000000..2c2c848a5 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/negative.rs @@ -0,0 +1,13 @@ +pub struct Inner { + field: *mut T, +} + +// @has negative/struct.Outer.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl !Send for Outer" +// +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl !Sync for Outer" +pub struct Outer { + inner_field: Inner, +} diff --git a/tests/rustdoc/synthetic_auto/nested.rs b/tests/rustdoc/synthetic_auto/nested.rs new file mode 100644 index 000000000..423bf115a --- /dev/null +++ b/tests/rustdoc/synthetic_auto/nested.rs @@ -0,0 +1,19 @@ +pub struct Inner { + field: T, +} + +unsafe impl Send for Inner +where + T: Copy, +{ +} + +// @has nested/struct.Foo.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl Send for Foowhere T: Copy' +// +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl Sync for Foowhere T: Sync' +pub struct Foo { + inner_field: Inner, +} diff --git a/tests/rustdoc/synthetic_auto/no-redundancy.rs b/tests/rustdoc/synthetic_auto/no-redundancy.rs new file mode 100644 index 000000000..59f336233 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/no-redundancy.rs @@ -0,0 +1,16 @@ +pub struct Inner { + field: T, +} + +unsafe impl Send for Inner +where + T: Copy + Send, +{ +} + +// @has no_redundancy/struct.Outer.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl Send for Outerwhere T: Send + Copy" +pub struct Outer { + inner_field: Inner, +} diff --git a/tests/rustdoc/synthetic_auto/overflow.rs b/tests/rustdoc/synthetic_auto/overflow.rs new file mode 100644 index 000000000..35a487c76 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/overflow.rs @@ -0,0 +1,35 @@ +// Tests that we don't fail with an overflow error for certain +// strange types +// See https://github.com/rust-lang/rust/pull/72936#issuecomment-643676915 + +pub trait Interner { + type InternedType; +} + +struct RustInterner<'tcx> { + foo: &'tcx () +} + +impl<'tcx> Interner for RustInterner<'tcx> { + type InternedType = Box>; +} + +enum TyData { + FnDef(I::InternedType) +} + +struct VariableKind(I::InternedType); + +// @has overflow/struct.BoundVarsCollector.html +// @has - '//h3[@class="code-header"]' "impl<'tcx> Send for BoundVarsCollector<'tcx>" +pub struct BoundVarsCollector<'tcx> { + val: VariableKind> +} + +fn is_send() {} + +struct MyInterner<'tcx> { + val: &'tcx () +} + +fn main() {} diff --git a/tests/rustdoc/synthetic_auto/project.rs b/tests/rustdoc/synthetic_auto/project.rs new file mode 100644 index 000000000..558ff2add --- /dev/null +++ b/tests/rustdoc/synthetic_auto/project.rs @@ -0,0 +1,34 @@ +pub struct Inner<'a, T: 'a> { + field: &'a T, +} + +trait MyTrait { + type MyItem; +} + +trait OtherTrait {} + +unsafe impl<'a, T> Send for Inner<'a, T> +where + 'a: 'static, + T: MyTrait, +{ +} +unsafe impl<'a, T> Sync for Inner<'a, T> +where + 'a: 'static, + T: MyTrait, + ::MyItem: OtherTrait, +{ +} + +// @has project/struct.Foo.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Send for Foo<'c, K>where K: MyTrait, 'c: 'static" +// +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Sync for Foo<'c, K>where K: MyTrait, ::MyItem: OtherTrait, \ +// 'c: 'static," +pub struct Foo<'c, K: 'c> { + inner_field: Inner<'c, K>, +} diff --git a/tests/rustdoc/synthetic_auto/self-referential.rs b/tests/rustdoc/synthetic_auto/self-referential.rs new file mode 100644 index 000000000..c6ae96de7 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/self-referential.rs @@ -0,0 +1,29 @@ +// Some unusual code minimized from +// https://github.com/sile/handy_async/tree/7b619b762c06544fc67792c8ff8ebc24a88fdb98 + +pub trait Pattern { + type Value; +} + +pub struct Constrain(A, B, C); + +impl Pattern for Constrain + where A: Pattern, + B: Pattern, + C: Pattern, +{ + type Value = A::Value; +} + +pub struct Wrapper(T); + +impl Pattern for Wrapper { + type Value = T; +} + + +// @has self_referential/struct.WriteAndThen.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl Send for WriteAndThenwhere ::Value: Send" +pub struct WriteAndThen(pub P1::Value,pub > as Pattern>::Value) + where P1: Pattern; diff --git a/tests/rustdoc/synthetic_auto/static-region.rs b/tests/rustdoc/synthetic_auto/static-region.rs new file mode 100644 index 000000000..1a76cb919 --- /dev/null +++ b/tests/rustdoc/synthetic_auto/static-region.rs @@ -0,0 +1,10 @@ +pub trait OwnedTrait<'a> { + type Reader; +} + +// @has static_region/struct.Owned.html +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl Send for Ownedwhere >::Reader: Send" +pub struct Owned where T: OwnedTrait<'static> { + marker: >::Reader, +} -- cgit v1.2.3