Skip to content

Commit

Permalink
Audit uses of tool_only_span_suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Jul 2, 2020
1 parent ec31b4e commit 84282fd
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/librustc_builtin_macros/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ impl<'a, 'b> Context<'a, 'b> {
("x", "LowerHex"),
("X", "UpperHex"),
] {
// FIXME: rustfix (`run-rustfix`) fails to apply suggestions.
// > "Cannot replace slice of data that was already replaced"
err.tool_only_span_suggestion(
sp,
&format!("use the `{}` trait", name),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// run-rustfix

// In this regression test for #67146, we check that the
// negative outlives bound `!'a` is rejected by the parser.
// This regression was first introduced in PR #57364.

fn main() {}

pub fn f1<T>() {}
//~^ ERROR negative bounds are not supported
pub fn f2<'a, T: Ord>() {}
//~^ ERROR negative bounds are not supported
pub fn f3<'a, T: Ord>() {}
//~^ ERROR negative bounds are not supported
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// run-rustfix

// In this regression test for #67146, we check that the
// negative outlives bound `!'a` is rejected by the parser.
// This regression was first introduced in PR #57364.

fn main() {}

fn f1<T: !'static>() {}
pub fn f1<T: !'static>() {}
//~^ ERROR negative bounds are not supported
fn f2<'a, T: Ord + !'a>() {}
pub fn f2<'a, T: Ord + !'a>() {}
//~^ ERROR negative bounds are not supported
fn f3<'a, T: !'a + Ord>() {}
pub fn f3<'a, T: !'a + Ord>() {}
//~^ ERROR negative bounds are not supported
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error: negative bounds are not supported
--> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:7:8
--> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:12
|
LL | fn f1<T: !'static>() {}
| ^^^^^^^^^^ negative bounds are not supported
LL | pub fn f1<T: !'static>() {}
| ^^^^^^^^^^ negative bounds are not supported

error: negative bounds are not supported
--> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:18
--> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:11:22
|
LL | fn f2<'a, T: Ord + !'a>() {}
| ^^^^^ negative bounds are not supported
LL | pub fn f2<'a, T: Ord + !'a>() {}
| ^^^^^ negative bounds are not supported

error: negative bounds are not supported
--> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:11:12
--> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:13:16
|
LL | fn f3<'a, T: !'a + Ord>() {}
| ^^^^^ negative bounds are not supported
LL | pub fn f3<'a, T: !'a + Ord>() {}
| ^^^^^ negative bounds are not supported

error: aborting due to 3 previous errors

9 changes: 9 additions & 0 deletions src/test/ui/resolve/resolve-conflict-import-vs-import.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// run-rustfix

#[allow(unused_imports)]
use std::mem::transmute;

//~^ ERROR the name `transmute` is defined multiple times

fn main() {
}
3 changes: 3 additions & 0 deletions src/test/ui/resolve/resolve-conflict-import-vs-import.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// run-rustfix

#[allow(unused_imports)]
use std::mem::transmute;
use std::mem::transmute;
//~^ ERROR the name `transmute` is defined multiple times
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0252]: the name `transmute` is defined multiple times
--> $DIR/resolve-conflict-import-vs-import.rs:2:5
--> $DIR/resolve-conflict-import-vs-import.rs:5:5
|
LL | use std::mem::transmute;
| ------------------- previous import of the value `transmute` here
Expand Down

0 comments on commit 84282fd

Please sign in to comment.