diff options
| author | bors <bors@rust-lang.org> | 2022-01-06 15:30:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-06 15:30:46 +0000 |
| commit | cfa4ac66c194046f631ce076c75516ecfdeb77ee (patch) | |
| tree | 10ace45fd5a86349c627f743747c097c5cdb7256 /src/test | |
| parent | a77cc64af491a31db224109a76b9b81cd26cd07c (diff) | |
| parent | 26a90e4cd780175dd2d9dbf061eccd53eb9a2489 (diff) | |
| download | rust-cfa4ac66c194046f631ce076c75516ecfdeb77ee.tar.gz rust-cfa4ac66c194046f631ce076c75516ecfdeb77ee.zip | |
Auto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #92058 (Make Run button visible on hover) - #92288 (Fix a pair of mistyped test cases in `std::net::ip`) - #92349 (Fix rustdoc::private_doc_tests lint for public re-exported items) - #92360 (Some cleanups around check_argument_types) - #92389 (Regression test for borrowck ICE #92015) - #92404 (Fix font size for [src] links in headers) - #92443 (Rustdoc: resolve associated traits for non-generic primitive types) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/rustdoc-gui/run-on-hover.goml | 7 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src-font-size.goml | 12 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/test_docs/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/intra-doc/non-path-primitives.rs | 1 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr | 10 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/private-public-item-doc-test.rs | 11 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/private-public-item-doc-test.stderr | 18 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/public-reexported-item-doc-test.rs | 16 | ||||
| -rw-r--r-- | src/test/rustdoc/intra-doc/prim-associated-traits.rs | 46 | ||||
| -rw-r--r-- | src/test/ui/borrowck/issue-92015.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/borrowck/issue-92015.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/c-variadic/variadic-unreachable-arg-error.rs | 14 |
12 files changed, 145 insertions, 9 deletions
diff --git a/src/test/rustdoc-gui/run-on-hover.goml b/src/test/rustdoc-gui/run-on-hover.goml new file mode 100644 index 00000000000..b8efa8e302f --- /dev/null +++ b/src/test/rustdoc-gui/run-on-hover.goml @@ -0,0 +1,7 @@ +// Example code blocks sometimes have a "Run" button to run them on the +// Playground. That button is hidden until the user hovers over the code block. +// This test checks that it is hidden, and that it shows on hover. +goto: file://|DOC_PATH|/test_docs/fn.foo.html +assert-css: (".test-arrow", {"visibility": "hidden"}) +move-cursor-to: ".example-wrap" +assert-css: (".test-arrow", {"visibility": "visible"}) diff --git a/src/test/rustdoc-gui/src-font-size.goml b/src/test/rustdoc-gui/src-font-size.goml new file mode 100644 index 00000000000..b0b2f122afd --- /dev/null +++ b/src/test/rustdoc-gui/src-font-size.goml @@ -0,0 +1,12 @@ +// This test ensures that the "[src]" have the same font size as their headers +// to avoid having some weird height difference in the background when the element +// is selected. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +show-text: true +// Check the impl headers. +assert-css: (".impl.has-srclink .srclink", {"font-size": "17px"}, ALL) +// The ".6" part is because the font-size is actually "1.1em". +assert-css: (".impl.has-srclink .code-header.in-band", {"font-size": "17.6px"}, ALL) +// Check the impl items. +assert-css: (".impl-items .has-srclink .srclink", {"font-size": "16px"}, ALL) +assert-css: (".impl-items .has-srclink .code-header", {"font-size": "16px"}, ALL) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 9b37703dded..f75de949292 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -1,5 +1,6 @@ //! The point of this crate is to be able to have enough different "kinds" of //! documentation generated so we can test each different features. +#![doc(html_playground_url="https://play.rust-lang.org/")] #![crate_name = "test_docs"] #![feature(rustdoc_internals)] diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs b/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs index 75159979e88..587cbad6848 100644 --- a/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs +++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs @@ -28,7 +28,6 @@ //! [unit::eq] //~ ERROR unresolved //! [tuple::eq] //~ ERROR unresolved //! [fn::eq] //~ ERROR unresolved -//! [never::eq] //~ ERROR unresolved // FIXME(#78800): This breaks because it's a blanket impl // (I think? Might break for other reasons too.) diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr index 610c8305605..4828a304463 100644 --- a/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr +++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr @@ -53,17 +53,11 @@ error: unresolved link to `fn::eq` LL | //! [fn::eq] | ^^^^^^ the builtin type `fn` has no associated item named `eq` -error: unresolved link to `never::eq` - --> $DIR/non-path-primitives.rs:31:6 - | -LL | //! [never::eq] - | ^^^^^^^^^ the builtin type `never` has no associated item named `eq` - error: unresolved link to `reference::deref` - --> $DIR/non-path-primitives.rs:35:6 + --> $DIR/non-path-primitives.rs:34:6 | LL | //! [reference::deref] | ^^^^^^^^^^^^^^^^ the builtin type `reference` has no associated item named `deref` -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors diff --git a/src/test/rustdoc-ui/private-public-item-doc-test.rs b/src/test/rustdoc-ui/private-public-item-doc-test.rs new file mode 100644 index 00000000000..7cc62b38cc2 --- /dev/null +++ b/src/test/rustdoc-ui/private-public-item-doc-test.rs @@ -0,0 +1,11 @@ +#![deny(rustdoc::private_doc_tests)] + +mod foo { + /// private doc test + /// + /// ``` + /// assert!(false); + /// ``` + //~^^^^^ ERROR documentation test in private item + pub fn bar() {} +} diff --git a/src/test/rustdoc-ui/private-public-item-doc-test.stderr b/src/test/rustdoc-ui/private-public-item-doc-test.stderr new file mode 100644 index 00000000000..f50dbd1844e --- /dev/null +++ b/src/test/rustdoc-ui/private-public-item-doc-test.stderr @@ -0,0 +1,18 @@ +error: documentation test in private item + --> $DIR/private-public-item-doc-test.rs:4:5 + | +LL | / /// private doc test +LL | | /// +LL | | /// ``` +LL | | /// assert!(false); +LL | | /// ``` + | |___________^ + | +note: the lint level is defined here + --> $DIR/private-public-item-doc-test.rs:1:9 + | +LL | #![deny(rustdoc::private_doc_tests)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/rustdoc-ui/public-reexported-item-doc-test.rs b/src/test/rustdoc-ui/public-reexported-item-doc-test.rs new file mode 100644 index 00000000000..b86a53305a1 --- /dev/null +++ b/src/test/rustdoc-ui/public-reexported-item-doc-test.rs @@ -0,0 +1,16 @@ +// check-pass + +#![deny(rustdoc::private_doc_tests)] + +pub fn foo() {} + +mod private { + /// re-exported doc test + /// + /// ``` + /// assert!(true); + /// ``` + pub fn bar() {} +} + +pub use private::bar; diff --git a/src/test/rustdoc/intra-doc/prim-associated-traits.rs b/src/test/rustdoc/intra-doc/prim-associated-traits.rs new file mode 100644 index 00000000000..8639a24f7f3 --- /dev/null +++ b/src/test/rustdoc/intra-doc/prim-associated-traits.rs @@ -0,0 +1,46 @@ +#![feature(never_type)] +use std::str::FromStr; + +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f64.html#method.from_str"]' 'f64::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f32.html#method.from_str"]' 'f32::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.isize.html#method.from_str"]' 'isize::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i8.html#method.from_str"]' 'i8::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i16.html#method.from_str"]' 'i16::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i32.html#method.from_str"]' 'i32::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i64.html#method.from_str"]' 'i64::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i128.html#method.from_str"]' 'i128::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.usize.html#method.from_str"]' 'usize::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u8.html#method.from_str"]' 'u8::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u16.html#method.from_str"]' 'u16::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u32.html#method.from_str"]' 'u32::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u64.html#method.from_str"]' 'u64::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u128.html#method.from_str"]' 'u128::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.char.html#method.from_str"]' 'char::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.bool.html#method.from_str"]' 'bool::from_str()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.str.html#method.eq"]' 'str::eq()' +// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.never.html#method.eq"]' 'never::eq()' +/// [`f64::from_str()`] [`f32::from_str()`] [`isize::from_str()`] [`i8::from_str()`] +/// [`i16::from_str()`] [`i32::from_str()`] [`i64::from_str()`] [`i128::from_str()`] +/// [`u16::from_str()`] [`u32::from_str()`] [`u64::from_str()`] [`u128::from_str()`] +/// [`usize::from_str()`] [`u8::from_str()`] [`char::from_str()`] [`bool::from_str()`] +/// [`str::eq()`] [`never::eq()`] +pub struct Number { + pub f_64: f64, + pub f_32: f32, + pub i_size: isize, + pub i_8: i8, + pub i_16: i16, + pub i_32: i32, + pub i_64: i64, + pub i_128: i128, + pub u_size: usize, + pub u_8: u8, + pub u_16: u16, + pub u_32: u32, + pub u_64: u64, + pub u_128: u128, + pub ch: char, + pub boolean: bool, + pub string: str, + pub n: !, +} diff --git a/src/test/ui/borrowck/issue-92015.rs b/src/test/ui/borrowck/issue-92015.rs new file mode 100644 index 00000000000..16d651717ff --- /dev/null +++ b/src/test/ui/borrowck/issue-92015.rs @@ -0,0 +1,7 @@ +// Regression test for #92105. +// ICE when mutating immutable reference from last statement of a block. + +fn main() { + let foo = Some(&0).unwrap(); + *foo = 1; //~ ERROR cannot assign +} diff --git a/src/test/ui/borrowck/issue-92015.stderr b/src/test/ui/borrowck/issue-92015.stderr new file mode 100644 index 00000000000..32a65d3b5bb --- /dev/null +++ b/src/test/ui/borrowck/issue-92015.stderr @@ -0,0 +1,11 @@ +error[E0594]: cannot assign to `*foo`, which is behind a `&` reference + --> $DIR/issue-92015.rs:6:5 + | +LL | let foo = Some(&0).unwrap(); + | --- help: consider changing this to be a mutable reference: `&mut i32` +LL | *foo = 1; + | ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/c-variadic/variadic-unreachable-arg-error.rs b/src/test/ui/c-variadic/variadic-unreachable-arg-error.rs new file mode 100644 index 00000000000..f60f6f3e808 --- /dev/null +++ b/src/test/ui/c-variadic/variadic-unreachable-arg-error.rs @@ -0,0 +1,14 @@ +// check-pass + +#![feature(c_variadic)] + +extern "C" { + fn foo(f: isize, x: u8, ...); +} + +fn main() { + unsafe { + // FIXME: Ideally we could give an unreachable warning + foo(1, loop {}, 1usize); + } +} |
