Skip to content

Commit

Permalink
test: avoid running rustfix on leaked writeln macro internals test
Browse files Browse the repository at this point in the history
This test contains conflicting MaybeIncorrect suggestions which will
cause the fixed file to not compile.
  • Loading branch information
jieyouxu committed Apr 10, 2024
1 parent 4606485 commit 420e3f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 44 deletions.
37 changes: 0 additions & 37 deletions tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.fixed

This file was deleted.

18 changes: 13 additions & 5 deletions tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
//@ run-rustfix
#![allow(dead_code)]
// Check that we don't leak stdlib implementation details through suggestions.
// Also check that the suggestion provided tries as hard as it can to see through local macros.
//
// FIXME(jieyouxu): this test is NOT run-rustfix because this test contains conflicting
// MaybeIncorrect suggestions:
//
// 1. `return ... ;`
// 2. `?`
//
// when the suggestions are applied to the same file, it becomes uncompilable.

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

fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
pub fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
if true {
writeln!(w, "`;?` here ->")?;
} else {
Expand All @@ -34,4 +42,4 @@ fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
Ok(())
}

fn main() {}
pub fn main() {}
12 changes: 10 additions & 2 deletions tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-112007-leaked-writeln-macro-internals.rs:9:9
--> $DIR/issue-112007-leaked-writeln-macro-internals.rs:17:9
|
LL | / if true {
LL | | writeln!(w, "`;?` here ->")?;
Expand All @@ -21,9 +21,13 @@ help: you might have meant to return this value
|
LL | return writeln!(w, "but not here");
| ++++++ +
help: use the `?` operator to extract the `Result<(), std::fmt::Error>` value, propagating a `Result::Err` value to the caller
|
LL | writeln!(w, "but not here")?
| +

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

error: aborting due to 2 previous errors

Expand Down

0 comments on commit 420e3f1

Please sign in to comment.