From 207d3e0aad016a01d7257adf53d08a0ac88ac2c5 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Thu, 30 Sep 2021 08:02:38 +0100 Subject: [PATCH 1/9] more span suggestions --- compiler/rustc_ast_lowering/src/expr.rs | 6 ++++++ compiler/rustc_passes/src/loops.rs | 6 ++++++ src/test/ui/error-codes/E0268.stderr | 5 ++++- src/test/ui/error-codes/E0697.rs | 3 +++ src/test/ui/error-codes/E0697.stderr | 9 +++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/error-codes/E0697.rs create mode 100644 src/test/ui/error-codes/E0697.stderr diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 6ee1dbe4ae3ee..f26d2f501ec6b 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -864,6 +864,12 @@ impl<'hir> LoweringContext<'_, 'hir> { None => { if movability == Movability::Static { struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static") + .span_suggestion( + fn_decl_span, + "consider removing the", + "static".into(), + rustc_errors::Applicability::MachineApplicable, + ) .emit(); } None diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs index 4bfac1b72983e..2bbb63396e1f3 100644 --- a/compiler/rustc_passes/src/loops.rs +++ b/compiler/rustc_passes/src/loops.rs @@ -233,6 +233,12 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> { Normal | AnonConst => { struct_span_err!(self.sess, span, E0268, "`{}` outside of a loop", name) .span_label(span, format!("cannot `{}` outside of a loop", name)) + .span_suggestion( + span, + "consider removing the", + name.into(), + rustc_errors::Applicability::MachineApplicable, + ) .emit(); } } diff --git a/src/test/ui/error-codes/E0268.stderr b/src/test/ui/error-codes/E0268.stderr index c926f9e487494..2e32d20ee47b7 100644 --- a/src/test/ui/error-codes/E0268.stderr +++ b/src/test/ui/error-codes/E0268.stderr @@ -2,7 +2,10 @@ error[E0268]: `break` outside of a loop --> $DIR/E0268.rs:2:5 | LL | break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ + | | + | cannot `break` outside of a loop + | help: consider removing the: `break` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0697.rs b/src/test/ui/error-codes/E0697.rs new file mode 100644 index 0000000000000..f1afa63aac0d3 --- /dev/null +++ b/src/test/ui/error-codes/E0697.rs @@ -0,0 +1,3 @@ +fn main() { + static || {}; //~ ERROR E0697 +} diff --git a/src/test/ui/error-codes/E0697.stderr b/src/test/ui/error-codes/E0697.stderr new file mode 100644 index 0000000000000..720b56c0b3637 --- /dev/null +++ b/src/test/ui/error-codes/E0697.stderr @@ -0,0 +1,9 @@ +error[E0697]: closures cannot be static + --> $DIR/E0697.rs:2:5 + | +LL | static || {}; + | ^^^^^^^^^ help: remove the: `static` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0697`. From 41118a196c9ea3607546c0458dfa73bec880d6a0 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Thu, 30 Sep 2021 08:24:17 +0100 Subject: [PATCH 2/9] add some more error codes --- compiler/rustc_typeck/src/check/pat.rs | 1 + src/test/ui/error-codes/E0025.stderr | 6 ++++-- src/test/ui/error-codes/E0697.stderr | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index ec06e0b11264d..980cea21774a9 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1435,6 +1435,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .span_label(span, format!("multiple uses of `{}` in pattern", ident)) .span_label(other_field, format!("first use of `{}`", ident)) + .span_suggestion(span, "consider removing one usage of", ident.to_string(), rustc_errors::Applicability::MachineApplicable) .emit(); } diff --git a/src/test/ui/error-codes/E0025.stderr b/src/test/ui/error-codes/E0025.stderr index dfec6d0276a59..52a646cf515c6 100644 --- a/src/test/ui/error-codes/E0025.stderr +++ b/src/test/ui/error-codes/E0025.stderr @@ -2,8 +2,10 @@ error[E0025]: field `a` bound multiple times in the pattern --> $DIR/E0025.rs:8:21 | LL | let Foo { a: x, a: y, b: 0 } = x; - | ---- ^^^^ multiple uses of `a` in pattern - | | + | ---- ^^^^ + | | | + | | multiple uses of `a` in pattern + | | help: consider removing one usage of: ``a`` | first use of `a` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0697.stderr b/src/test/ui/error-codes/E0697.stderr index 720b56c0b3637..5c862e48e75e0 100644 --- a/src/test/ui/error-codes/E0697.stderr +++ b/src/test/ui/error-codes/E0697.stderr @@ -2,7 +2,7 @@ error[E0697]: closures cannot be static --> $DIR/E0697.rs:2:5 | LL | static || {}; - | ^^^^^^^^^ help: remove the: `static` + | ^^^^^^^^^ help: consider removing the: `static` error: aborting due to previous error From 1480e98cc39d3c5783fee53ddfecb42568c3febe Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 4 Oct 2021 16:54:44 +0100 Subject: [PATCH 3/9] fix --- compiler/rustc_typeck/src/check/pat.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 980cea21774a9..147cd3d68f638 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1435,7 +1435,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .span_label(span, format!("multiple uses of `{}` in pattern", ident)) .span_label(other_field, format!("first use of `{}`", ident)) - .span_suggestion(span, "consider removing one usage of", ident.to_string(), rustc_errors::Applicability::MachineApplicable) + .span_suggestion( + span, + "consider removing one usage of", + ident.to_string(), + rustc_errors::Applicability::MaybeIncorrect, + ) .emit(); } From 7ee6c1c6feddbbf3db53a4830cd0f386b5428f88 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 2 Oct 2021 10:18:58 +0100 Subject: [PATCH 4/9] Update compiler/rustc_ast_lowering/src/expr.rs Co-authored-by: Esteban Kuber --- compiler/rustc_ast_lowering/src/expr.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index f26d2f501ec6b..fea50292b6584 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -865,9 +865,9 @@ impl<'hir> LoweringContext<'_, 'hir> { if movability == Movability::Static { struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static") .span_suggestion( - fn_decl_span, - "consider removing the", - "static".into(), + fn_decl_span.with_lo(fn_decl_span.lo() + BytePos("static ".len())), + "remove the `static` keyword to define a regular closure", + "".into(), rustc_errors::Applicability::MachineApplicable, ) .emit(); From 21d14696612e8cd1372c5abf77822fb4ea235303 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 2 Oct 2021 10:19:42 +0100 Subject: [PATCH 5/9] Update compiler/rustc_passes/src/loops.rs Co-authored-by: Esteban Kuber --- compiler/rustc_passes/src/loops.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs index 2bbb63396e1f3..a0ba796cdad69 100644 --- a/compiler/rustc_passes/src/loops.rs +++ b/compiler/rustc_passes/src/loops.rs @@ -235,9 +235,9 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> { .span_label(span, format!("cannot `{}` outside of a loop", name)) .span_suggestion( span, - "consider removing the", - name.into(), - rustc_errors::Applicability::MachineApplicable, + &format!("consider removing the `{}`", name), + String::new(), + Applicability::MaybeIncorrect, ) .emit(); } From f970a4dd63889b1dfbb83bb919bea6d744b2610d Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 4 Oct 2021 16:55:24 +0100 Subject: [PATCH 6/9] remove --- compiler/rustc_typeck/src/check/pat.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 147cd3d68f638..ec06e0b11264d 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1435,12 +1435,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .span_label(span, format!("multiple uses of `{}` in pattern", ident)) .span_label(other_field, format!("first use of `{}`", ident)) - .span_suggestion( - span, - "consider removing one usage of", - ident.to_string(), - rustc_errors::Applicability::MaybeIncorrect, - ) .emit(); } From 546bdb7ce9470bdc624b45fb212ca8b88f18515a Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Mon, 4 Oct 2021 18:34:00 +0100 Subject: [PATCH 7/9] add use --- compiler/rustc_typeck/src/check/pat.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index ec06e0b11264d..0f12af41c6b63 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1,6 +1,7 @@ use crate::check::FnCtxt; use rustc_ast as ast; +use crate::path::BytePos; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; From 9c011c8c395fdcc8f10542d00d1eeb67dcd73ad6 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:42:52 +0000 Subject: [PATCH 8/9] fixes --- Cargo.lock | 4 ++-- compiler/rustc_ast_lowering/src/expr.rs | 5 +++-- compiler/rustc_typeck/src/check/pat.rs | 1 - src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- src/llvm-project | 2 +- src/tools/rust-analyzer | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bf9527f47d12..eba2ff82fb8a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2451,9 +2451,9 @@ checksum = "dd20eec3dbe4376829cb7d80ae6ac45e0a766831dca50202ff2d40db46a8a024" [[package]] name = "os_info" -version = "3.0.7" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac91020bfed8cc3f8aa450d4c3b5fa1d3373fc091c8a92009f3b27749d5a227" +checksum = "b89dd55b8d8d97dabd0d1adc625d188378fcf87632825bfe9c956acc9a11a72a" dependencies = [ "log", "serde", diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index fea50292b6584..959e66fbf70ef 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -12,7 +12,7 @@ use rustc_hir::definitions::DefPathData; use rustc_span::hygiene::ExpnId; use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned}; use rustc_span::symbol::{sym, Ident, Symbol}; -use rustc_span::DUMMY_SP; +use rustc_span::{hygiene::ForLoopLoc, BytePos, DUMMY_SP}; impl<'hir> LoweringContext<'_, 'hir> { fn lower_exprs(&mut self, exprs: &[AstP]) -> &'hir [hir::Expr<'hir>] { @@ -865,7 +865,8 @@ impl<'hir> LoweringContext<'_, 'hir> { if movability == Movability::Static { struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static") .span_suggestion( - fn_decl_span.with_lo(fn_decl_span.lo() + BytePos("static ".len())), + fn_decl_span + .with_lo(fn_decl_span.lo() + BytePos("static ".len() as u32)), "remove the `static` keyword to define a regular closure", "".into(), rustc_errors::Applicability::MachineApplicable, diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 0f12af41c6b63..ec06e0b11264d 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1,7 +1,6 @@ use crate::check::FnCtxt; use rustc_ast as ast; -use crate::path::BytePos; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; diff --git a/src/doc/book b/src/doc/book index 8a0bb3c96e719..fcb5e0ea68112 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 8a0bb3c96e71927b80fa2286d7a5a5f2547c6aa4 +Subproject commit fcb5e0ea68112d85a1d29a7a7335978ef2a02181 diff --git a/src/doc/edition-guide b/src/doc/edition-guide index beea0a3cdc388..2d9b1b9da706d 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit beea0a3cdc3885375342fd010f9ad658e6a5e09a +Subproject commit 2d9b1b9da706de24650fdc5c3b0182f55c82115d diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 8c395bdd8073d..4c76da9ddb465 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 8c395bdd8073deb20ca67e1ed4b14a3a7e315a37 +Subproject commit 4c76da9ddb4650203c129fceffdea95a3466c205 diff --git a/src/doc/nomicon b/src/doc/nomicon index c05c452b36358..fe6227eb3c853 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit c05c452b36358821bf4122f9c418674edd1d713d +Subproject commit fe6227eb3c8533200c52dffa42ef1b6f2f02c40e diff --git a/src/doc/reference b/src/doc/reference index 06f9e61931bcf..0e5ed7a4bec06 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 06f9e61931bcf58b91dfe6c924057e42ce273ee1 +Subproject commit 0e5ed7a4bec065f0cc18c35d1c904639e095314d diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 1ca6a7bd1d73e..9d4132b56c499 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 1ca6a7bd1d73edc4a3e6c7d6a40f5d4b66c1e517 +Subproject commit 9d4132b56c4999cd3ce1aeca5f1b2f2cb0d11c24 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 9bf0028b55779..9198465b6ca8b 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 9bf0028b557798ddd07a6f652e4d0c635d3d6620 +Subproject commit 9198465b6ca8bed669df0cbb67c0e6d0b140803c diff --git a/src/llvm-project b/src/llvm-project index 6b3dbcc81a470..cba558df777a0 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 6b3dbcc81a470e5da84576d63fcfc19e3b1154cd +Subproject commit cba558df777a045b5657d56c29944e9e8fd3a776 diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index 68319187d6370..f1d7f98ed07b9 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit 68319187d63707fa36d7c215ed0e444e87d9652a +Subproject commit f1d7f98ed07b9934286b9c4809dd4d7a47537879 From eb07972b266f024bad2d3090bf86d68e4f9d0a75 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:53:47 +0000 Subject: [PATCH 9/9] rebase --- compiler/rustc_codegen_gcc/build.sh | 0 compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh | 0 compiler/rustc_codegen_gcc/build_sysroot/prepare_sysroot_src.sh | 0 compiler/rustc_codegen_gcc/cargo.sh | 0 compiler/rustc_codegen_gcc/clean_all.sh | 0 compiler/rustc_codegen_gcc/prepare.sh | 0 compiler/rustc_codegen_gcc/prepare_build.sh | 0 compiler/rustc_codegen_gcc/rustup.sh | 0 compiler/rustc_codegen_gcc/test.sh | 0 9 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 compiler/rustc_codegen_gcc/build.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/build_sysroot/prepare_sysroot_src.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/cargo.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/clean_all.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/prepare.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/prepare_build.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/rustup.sh mode change 100755 => 100644 compiler/rustc_codegen_gcc/test.sh diff --git a/compiler/rustc_codegen_gcc/build.sh b/compiler/rustc_codegen_gcc/build.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh b/compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/build_sysroot/prepare_sysroot_src.sh b/compiler/rustc_codegen_gcc/build_sysroot/prepare_sysroot_src.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/cargo.sh b/compiler/rustc_codegen_gcc/cargo.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/clean_all.sh b/compiler/rustc_codegen_gcc/clean_all.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/prepare.sh b/compiler/rustc_codegen_gcc/prepare.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/prepare_build.sh b/compiler/rustc_codegen_gcc/prepare_build.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/rustup.sh b/compiler/rustc_codegen_gcc/rustup.sh old mode 100755 new mode 100644 diff --git a/compiler/rustc_codegen_gcc/test.sh b/compiler/rustc_codegen_gcc/test.sh old mode 100755 new mode 100644