diff options
| author | bors <bors@rust-lang.org> | 2021-12-09 00:55:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-09 00:55:49 +0000 |
| commit | 3c857f48ce12d1f98f3ea6d48eb9e33d8d60c985 (patch) | |
| tree | 5db0b310af238377cfbde5bdd3ac75aad19dbb06 /src/test | |
| parent | e6b883c74f49f32cb5d1cbad3457f2b8805a4a38 (diff) | |
| parent | 40c6606b789122f1584a4e06556b858d543bef6b (diff) | |
Auto merge of #91677 - matthiaskrgr:rollup-yiczced, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #91245 (suggest casting between i/u32 and char) - #91337 (Add a suggestion if `macro_rules` is misspelled) - #91534 (Make rustdoc headings black, and markdown blue) - #91637 (Add test for packed drops in generators) - #91667 (Fix indent of itemTypes in search.js) Failed merges: - #91568 (Pretty print break and continue without redundant space) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/rustdoc-gui/headers-color.goml | 15 | ||||
| -rw-r--r-- | src/test/ui/cast/cast-int-to-char.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/cast/cast-int-to-char.stderr | 53 | ||||
| -rw-r--r-- | src/test/ui/match/match-type-err-first-arm.stderr | 5 | ||||
| -rw-r--r-- | src/test/ui/packed/packed-struct-drop-aligned.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/parser/misspelled-macro-rules.fixed | 13 | ||||
| -rw-r--r-- | src/test/ui/parser/misspelled-macro-rules.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/parser/misspelled-macro-rules.stderr | 10 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/macro-brackets.stderr | 5 |
9 files changed, 146 insertions, 5 deletions
diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index 7002812bb62..03b10e3f78d 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -18,7 +18,10 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use assert-css: ("#method\.must_use", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, ALL) goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".section-header a", {"color": "rgb(197, 197, 197)"}, ALL) +assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL) // Dark theme local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} @@ -34,7 +37,10 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use assert-css: ("#method\.must_use", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, ALL) goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".section-header a", {"color": "rgb(221, 221, 221)"}, ALL) +assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: (".section-header a", {"color": "rgb(210, 153, 29)"}, ALL) // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} @@ -52,4 +58,7 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use assert-css: ("#method\.must_use", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, ALL) goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".section-header a", {"color": "rgb(0, 0, 0)"}, ALL) +assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: (".section-header a", {"color": "rgb(56, 115, 173)"}, ALL) diff --git a/src/test/ui/cast/cast-int-to-char.rs b/src/test/ui/cast/cast-int-to-char.rs new file mode 100644 index 00000000000..379956968bd --- /dev/null +++ b/src/test/ui/cast/cast-int-to-char.rs @@ -0,0 +1,9 @@ +fn foo<T>(_t: T) {} + +fn main() { + foo::<u32>('0'); //~ ERROR + foo::<i32>('0'); //~ ERROR + foo::<u64>('0'); //~ ERROR + foo::<i64>('0'); //~ ERROR + foo::<char>(0u32); //~ ERROR +} diff --git a/src/test/ui/cast/cast-int-to-char.stderr b/src/test/ui/cast/cast-int-to-char.stderr new file mode 100644 index 00000000000..55b9462db8d --- /dev/null +++ b/src/test/ui/cast/cast-int-to-char.stderr @@ -0,0 +1,53 @@ +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:4:16 + | +LL | foo::<u32>('0'); + | ^^^ expected `u32`, found `char` + | +help: you can cast a `char` to a `u32`, since a `char` always occupies 4 bytes + | +LL | foo::<u32>('0' as u32); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:5:16 + | +LL | foo::<i32>('0'); + | ^^^ expected `i32`, found `char` + | +help: you can cast a `char` to an `i32`, since a `char` always occupies 4 bytes + | +LL | foo::<i32>('0' as i32); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:6:16 + | +LL | foo::<u64>('0'); + | ^^^ expected `u64`, found `char` + | +help: you can cast a `char` to a `u64`, since a `char` always occupies 4 bytes + | +LL | foo::<u64>('0' as u64); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:7:16 + | +LL | foo::<i64>('0'); + | ^^^ expected `i64`, found `char` + | +help: you can cast a `char` to an `i64`, since a `char` always occupies 4 bytes + | +LL | foo::<i64>('0' as i64); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:8:17 + | +LL | foo::<char>(0u32); + | ^^^^ expected `char`, found `u32` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/match/match-type-err-first-arm.stderr b/src/test/ui/match/match-type-err-first-arm.stderr index fd489afa84d..1cfe7ce1ed7 100644 --- a/src/test/ui/match/match-type-err-first-arm.stderr +++ b/src/test/ui/match/match-type-err-first-arm.stderr @@ -6,6 +6,11 @@ LL | fn test_func1(n: i32) -> i32 { LL | match n { LL | 12 => 'b', | ^^^ expected `i32`, found `char` + | +help: you can cast a `char` to an `i32`, since a `char` always occupies 4 bytes + | +LL | 12 => 'b' as i32, + | ++++++ error[E0308]: `match` arms have incompatible types --> $DIR/match-type-err-first-arm.rs:18:14 diff --git a/src/test/ui/packed/packed-struct-drop-aligned.rs b/src/test/ui/packed/packed-struct-drop-aligned.rs index fab3bbedac6..b95cdbbbaad 100644 --- a/src/test/ui/packed/packed-struct-drop-aligned.rs +++ b/src/test/ui/packed/packed-struct-drop-aligned.rs @@ -1,6 +1,10 @@ // run-pass +#![feature(generators)] +#![feature(generator_trait)] use std::cell::Cell; use std::mem; +use std::ops::Generator; +use std::pin::Pin; struct Aligned<'a> { drop_count: &'a Cell<usize> @@ -19,15 +23,35 @@ impl<'a> Drop for Aligned<'a> { } } +#[repr(transparent)] +struct NotCopy(u8); + #[repr(packed)] -struct Packed<'a>(u8, Aligned<'a>); +struct Packed<'a>(NotCopy, Aligned<'a>); fn main() { let drop_count = &Cell::new(0); { - let mut p = Packed(0, Aligned { drop_count }); + let mut p = Packed(NotCopy(0), Aligned { drop_count }); p.1 = Aligned { drop_count }; assert_eq!(drop_count.get(), 1); } assert_eq!(drop_count.get(), 2); + + let drop_count = &Cell::new(0); + let mut g = || { + let mut p = Packed(NotCopy(0), Aligned { drop_count }); + let _ = &p; + p.1 = Aligned { drop_count }; + assert_eq!(drop_count.get(), 1); + // Test that a generator drop function moves a value from a packed + // struct to a separate local before dropping it. We move out the + // first field to generate and open drop for the second field. + drop(p.0); + yield; + }; + Pin::new(&mut g).resume(()); + assert_eq!(drop_count.get(), 1); + drop(g); + assert_eq!(drop_count.get(), 2); } diff --git a/src/test/ui/parser/misspelled-macro-rules.fixed b/src/test/ui/parser/misspelled-macro-rules.fixed new file mode 100644 index 00000000000..62be913d85f --- /dev/null +++ b/src/test/ui/parser/misspelled-macro-rules.fixed @@ -0,0 +1,13 @@ +// Regression test for issue #91227. + +// run-rustfix + +#![allow(unused_macros)] + +macro_rules! thing { +//~^ ERROR: expected one of +//~| HELP: perhaps you meant to define a macro + () => {} +} + +fn main() {} diff --git a/src/test/ui/parser/misspelled-macro-rules.rs b/src/test/ui/parser/misspelled-macro-rules.rs new file mode 100644 index 00000000000..4290e6e5e4c --- /dev/null +++ b/src/test/ui/parser/misspelled-macro-rules.rs @@ -0,0 +1,13 @@ +// Regression test for issue #91227. + +// run-rustfix + +#![allow(unused_macros)] + +marco_rules! thing { +//~^ ERROR: expected one of +//~| HELP: perhaps you meant to define a macro + () => {} +} + +fn main() {} diff --git a/src/test/ui/parser/misspelled-macro-rules.stderr b/src/test/ui/parser/misspelled-macro-rules.stderr new file mode 100644 index 00000000000..56df7123819 --- /dev/null +++ b/src/test/ui/parser/misspelled-macro-rules.stderr @@ -0,0 +1,10 @@ +error: expected one of `(`, `[`, or `{`, found `thing` + --> $DIR/misspelled-macro-rules.rs:7:14 + | +LL | marco_rules! thing { + | ----------- ^^^^^ expected one of `(`, `[`, or `{` + | | + | help: perhaps you meant to define a macro: `macro_rules` + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/macro-brackets.stderr b/src/test/ui/proc-macro/macro-brackets.stderr index 9aaf612eb54..d3516375291 100644 --- a/src/test/ui/proc-macro/macro-brackets.stderr +++ b/src/test/ui/proc-macro/macro-brackets.stderr @@ -3,6 +3,11 @@ error[E0308]: mismatched types | LL | id![static X: u32 = 'a';]; | ^^^ expected `u32`, found `char` + | +help: you can cast a `char` to a `u32`, since a `char` always occupies 4 bytes + | +LL | id![static X: u32 = 'a' as u32;]; + | ++++++ error: aborting due to previous error |
