Skip to content

Commit 420e3f1

Browse files
committed
test: avoid running rustfix on leaked writeln macro internals test
This test contains conflicting MaybeIncorrect suggestions which will cause the fixed file to not compile.
1 parent 4606485 commit 420e3f1

3 files changed

+23
-44
lines changed

tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.fixed

-37
This file was deleted.

tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
//@ run-rustfix
2-
#![allow(dead_code)]
1+
// Check that we don't leak stdlib implementation details through suggestions.
2+
// Also check that the suggestion provided tries as hard as it can to see through local macros.
3+
//
4+
// FIXME(jieyouxu): this test is NOT run-rustfix because this test contains conflicting
5+
// MaybeIncorrect suggestions:
6+
//
7+
// 1. `return ... ;`
8+
// 2. `?`
9+
//
10+
// when the suggestions are applied to the same file, it becomes uncompilable.
311

412
// https://github.com/rust-lang/rust/issues/112007
5-
fn bug_report<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
13+
pub fn bug_report<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
614
if true {
715
writeln!(w, "`;?` here ->")?;
816
} else {
@@ -25,7 +33,7 @@ macro_rules! bar {
2533
}
2634
}
2735

28-
fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
36+
pub fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
2937
if true {
3038
writeln!(w, "`;?` here ->")?;
3139
} else {
@@ -34,4 +42,4 @@ fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
3442
Ok(())
3543
}
3644

37-
fn main() {}
45+
pub fn main() {}

tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-112007-leaked-writeln-macro-internals.rs:9:9
2+
--> $DIR/issue-112007-leaked-writeln-macro-internals.rs:17:9
33
|
44
LL | / if true {
55
LL | | writeln!(w, "`;?` here ->")?;
@@ -21,9 +21,13 @@ help: you might have meant to return this value
2121
|
2222
LL | return writeln!(w, "but not here");
2323
| ++++++ +
24+
help: use the `?` operator to extract the `Result<(), std::fmt::Error>` value, propagating a `Result::Err` value to the caller
25+
|
26+
LL | writeln!(w, "but not here")?
27+
| +
2428

2529
error[E0308]: mismatched types
26-
--> $DIR/issue-112007-leaked-writeln-macro-internals.rs:32:9
30+
--> $DIR/issue-112007-leaked-writeln-macro-internals.rs:40:9
2731
|
2832
LL | / if true {
2933
LL | | writeln!(w, "`;?` here ->")?;
@@ -44,6 +48,10 @@ help: you might have meant to return this value
4448
|
4549
LL | return baz!(w);
4650
| ++++++ +
51+
help: use the `?` operator to extract the `Result<(), std::fmt::Error>` value, propagating a `Result::Err` value to the caller
52+
|
53+
LL | writeln!($w, "but not here")?
54+
| +
4755

4856
error: aborting due to 2 previous errors
4957

0 commit comments

Comments
 (0)