Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8dc1e42
libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]
ryr3 Jul 2, 2020
ec31b4e
Audit uses of `span_suggestion_short`
JohnTitor Jul 2, 2020
84282fd
Audit uses of `tool_only_span_suggestion`
JohnTitor Jul 2, 2020
1b747a0
mir: mark mir construction temporaries as internal
davidtwco Jul 2, 2020
7391bf8
Move A|Rc::as_ptr from feature(weak_into_raw)
CAD97 Jul 2, 2020
2f31426
rustdoc: Restore underline text decoration on hover for FQN in header
rye Jul 5, 2020
5fa19ad
Remove unused RUSTC_DEBUG_ASSERTIONS
tmiasko Jul 6, 2020
7d7f167
libstd: remove some mutable statics in sys::unix
euclio Jul 3, 2020
f226e6b
Add `read_exact_at` and `write_all_at` to WASI's `FileExt`
sunfishcode Jul 3, 2020
6196eaa
Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.
sunfishcode Jul 3, 2020
e46c187
Always resolve type@primitive as a primitive, not a module
jyn514 Jul 6, 2020
fdd39a3
Add rust-analyzer to the build manifest
matklad Jul 6, 2020
c6e7035
Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebank
Manishearth Jul 6, 2020
6f52496
Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
Manishearth Jul 6, 2020
371d3c4
Rollup merge of #73969 - davidtwco:issue-73914-checkedadd-temp-genera…
Manishearth Jul 6, 2020
711476b
Rollup merge of #73974 - CAD97:rc-no-weak, r=dtolnay
Manishearth Jul 6, 2020
678949b
Rollup merge of #74006 - euclio:sys-unix-static-mut, r=SimonSapin
Manishearth Jul 6, 2020
01c688a
Rollup merge of #74067 - rye:rustdoc-fqn-hover-underline, r=Guillaume…
Manishearth Jul 6, 2020
5107383
Rollup merge of #74074 - sunfishcode:windows-openoptionsext-return-ty…
Manishearth Jul 6, 2020
6b5a05c
Rollup merge of #74076 - sunfishcode:wasi-fileext-newmethods, r=alexc…
Manishearth Jul 6, 2020
99eb1cb
Rollup merge of #74078 - jyn514:lut, r=Manishearth
Manishearth Jul 6, 2020
9b08c50
Rollup merge of #74089 - matklad:ship-rust-analyzer-some-more, r=piet…
Manishearth Jul 6, 2020
27fdf1c
Rollup merge of #74090 - tmiasko:rustc-debug-assertions, r=RalfJung
Manishearth Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/librustc_builtin_macros/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,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
7 changes: 5 additions & 2 deletions src/librustc_parse/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,10 +1228,13 @@ impl<'a> Parser<'a> {
if let Some(sp) = unmatched.unclosed_span {
err.span_label(sp, "unclosed delimiter");
}
// Backticks should be removed to apply suggestions.
let mut delim = delim.to_string();
delim.retain(|c| c != '`');
err.span_suggestion_short(
self.prev_token.span.shrink_to_hi(),
&format!("{} may belong here", delim.to_string()),
delim.to_string(),
&format!("`{}` may belong here", delim),
delim,
Applicability::MaybeIncorrect,
);
if unmatched.found_delim.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ impl<'a> Parser<'a> {
// misses a separator.
expect_err
.span_suggestion_short(
sp,
self.sess.source_map().next_point(sp),
&format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/block-expression-remove-semicolon.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// run-rustfix

fn foo() -> i32 {
0
}

fn main() {
let _x: i32 = {
//~^ ERROR mismatched types
foo() //~ HELP consider removing this semicolon
};
}
6 changes: 4 additions & 2 deletions src/test/ui/block-expression-remove-semicolon.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// run-rustfix

fn foo() -> i32 {
0
0
}

fn main() {
let x: i32 = {
let _x: i32 = {
//~^ ERROR mismatched types
foo(); //~ HELP consider removing this semicolon
};
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/block-expression-remove-semicolon.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/block-expression-remove-semicolon.rs:6:18
--> $DIR/block-expression-remove-semicolon.rs:8:19
|
LL | let x: i32 = {
| __________________^
LL | let _x: i32 = {
| ___________________^
LL | |
LL | | foo();
| | - help: consider removing this semicolon
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/block-result/consider-removing-last-semi.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// run-rustfix

pub fn f() -> String { //~ ERROR mismatched types
0u8;
"bla".to_string()
}

pub fn g() -> String { //~ ERROR mismatched types
"this won't work".to_string();
"removeme".to_string()
}

fn main() {}
6 changes: 4 additions & 2 deletions src/test/ui/block-result/consider-removing-last-semi.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
fn f() -> String { //~ ERROR mismatched types
// run-rustfix

pub fn f() -> String { //~ ERROR mismatched types
0u8;
"bla".to_string();
}

fn g() -> String { //~ ERROR mismatched types
pub fn g() -> String { //~ ERROR mismatched types
"this won't work".to_string();
"removeme".to_string();
}
Expand Down
20 changes: 10 additions & 10 deletions src/test/ui/block-result/consider-removing-last-semi.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0308]: mismatched types
--> $DIR/consider-removing-last-semi.rs:1:11
--> $DIR/consider-removing-last-semi.rs:3:15
|
LL | fn f() -> String {
| - ^^^^^^ expected struct `std::string::String`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
LL | pub fn f() -> String {
| - ^^^^^^ expected struct `std::string::String`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
LL | 0u8;
LL | "bla".to_string();
| - help: consider removing this semicolon

error[E0308]: mismatched types
--> $DIR/consider-removing-last-semi.rs:6:11
--> $DIR/consider-removing-last-semi.rs:8:15
|
LL | fn g() -> String {
| - ^^^^^^ expected struct `std::string::String`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
LL | pub fn g() -> String {
| - ^^^^^^ expected struct `std::string::String`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
LL | "this won't work".to_string();
LL | "removeme".to_string();
| - help: consider removing this semicolon
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/coercion/coercion-missing-tail-expected-type.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// #41425 -- error message "mismatched types" has wrong types
// run-rustfix

fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
x + 1
}

fn foo() -> Result<u8, u64> { //~ ERROR mismatched types
Ok(1)
}

fn main() {
let x = plus_one(5);
let _ = foo();
println!("X = {}", x);
}
2 changes: 2 additions & 0 deletions src/test/ui/coercion/coercion-missing-tail-expected-type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// #41425 -- error message "mismatched types" has wrong types
// run-rustfix

fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
x + 1;
Expand All @@ -10,5 +11,6 @@ fn foo() -> Result<u8, u64> { //~ ERROR mismatched types

fn main() {
let x = plus_one(5);
let _ = foo();
println!("X = {}", x);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:3:24
--> $DIR/coercion-missing-tail-expected-type.rs:4:24
|
LL | fn plus_one(x: i32) -> i32 {
| -------- ^^^ expected `i32`, found `()`
Expand All @@ -9,7 +9,7 @@ LL | x + 1;
| - help: consider removing this semicolon

error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:7:13
--> $DIR/coercion-missing-tail-expected-type.rs:8:13
|
LL | fn foo() -> Result<u8, u64> {
| --- ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()`
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/const-generics/unused_braces.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// check-pass
// run-rustfix

#![allow(incomplete_features)]
#![warn(unused_braces)]

#![feature(const_generics)]

struct A<const N: usize>;

fn main() {
let _: A<7>; // ok
let _: A< 7 >; //~ WARN unnecessary braces
let _: A<{ 3 + 5 }>; // ok
}
4 changes: 3 additions & 1 deletion src/test/ui/const-generics/unused_braces.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// check-pass
// run-rustfix

#![allow(incomplete_features)]
#![warn(unused_braces)]

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete

struct A<const N: usize>;

Expand Down
15 changes: 3 additions & 12 deletions src/test/ui/const-generics/unused_braces.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/unused_braces.rs:4:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: unnecessary braces around const expression
--> $DIR/unused_braces.rs:11:14
--> $DIR/unused_braces.rs:13:14
|
LL | let _: A<{ 7 }>;
| ^^^^^ help: remove these braces
|
note: the lint level is defined here
--> $DIR/unused_braces.rs:2:9
--> $DIR/unused_braces.rs:5:9
|
LL | #![warn(unused_braces)]
| ^^^^^^^^^^^^^

warning: 2 warnings emitted
warning: 1 warning emitted

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// run-rustfix

fn main() {
let _x = !1; //~ ERROR cannot be used as a unary operator
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// run-rustfix

fn main() {
let x = ~1; //~ ERROR cannot be used as a unary operator
let _x = ~1; //~ ERROR cannot be used as a unary operator
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: `~` cannot be used as a unary operator
--> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:2:13
--> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:4:14
|
LL | let x = ~1;
| ^ help: use `!` to perform bitwise not
LL | let _x = ~1;
| ^ help: use `!` to perform bitwise not

error: aborting due to previous error

69 changes: 69 additions & 0 deletions src/test/ui/did_you_mean/issue-54109-without-witness.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// run-rustfix

// This test is to check if suggestions can be applied automatically.

#![allow(dead_code, unused_parens)]

fn main() {}

fn test_and() {
let a = true;
let b = false;

let _ = a && b; //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator

if a && b { //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator
println!("both");
}
}

fn test_or() {
let a = true;
let b = false;

let _ = a || b; //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator

if a || b { //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator
println!("both");
}
}

fn test_and_par() {
let a = true;
let b = false;
if (a && b) { //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator
println!("both");
}
}

fn test_or_par() {
let a = true;
let b = false;
if (a || b) { //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator
println!("both");
}
}

fn test_while_and() {
let a = true;
let b = false;
while a && b { //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator
println!("both");
}
}

fn test_while_or() {
let a = true;
let b = false;
while a || b { //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator
println!("both");
}
}
69 changes: 69 additions & 0 deletions src/test/ui/did_you_mean/issue-54109-without-witness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// run-rustfix

// This test is to check if suggestions can be applied automatically.

#![allow(dead_code, unused_parens)]

fn main() {}

fn test_and() {
let a = true;
let b = false;

let _ = a and b; //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator

if a and b { //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator
println!("both");
}
}

fn test_or() {
let a = true;
let b = false;

let _ = a or b; //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator

if a or b { //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator
println!("both");
}
}

fn test_and_par() {
let a = true;
let b = false;
if (a and b) { //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator
println!("both");
}
}

fn test_or_par() {
let a = true;
let b = false;
if (a or b) { //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator
println!("both");
}
}

fn test_while_and() {
let a = true;
let b = false;
while a and b { //~ ERROR `and` is not a logical operator
//~| ERROR `and` is not a logical operator
println!("both");
}
}

fn test_while_or() {
let a = true;
let b = false;
while a or b { //~ ERROR `or` is not a logical operator
//~| ERROR `or` is not a logical operator
println!("both");
}
}
Loading