Skip to content

Add more span suggestions #89391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr>]) -> &'hir [hir::Expr<'hir>] {
Expand Down Expand Up @@ -864,6 +864,13 @@ 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
.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,
)
.emit();
}
None
Expand Down
Empty file modified compiler/rustc_codegen_gcc/build.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/build_sysroot/prepare_sysroot_src.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/cargo.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/clean_all.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/prepare.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/prepare_build.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/rustup.sh
100755 → 100644
Empty file.
Empty file modified compiler/rustc_codegen_gcc/test.sh
100755 → 100644
Empty file.
6 changes: 6 additions & 0 deletions compiler/rustc_passes/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
&format!("consider removing the `{}`", name),
String::new(),
Applicability::MaybeIncorrect,
)
.emit();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 167 files
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide
Submodule rustc-dev-guide updated 64 files
+0 −4 .github/workflows/date-check.yml
+2 −2 ci/date-check/Cargo.toml
+1 −1 examples/rustc-driver-example.rs
+1 −1 examples/rustc-driver-getting-diagnostics.rs
+2 −2 examples/rustc-driver-interacting-with-the-ast.rs
+0 −3 src/SUMMARY.md
+29 −31 src/about-this-guide.md
+1 −1 src/appendix/glossary.md
+0 −1 src/appendix/humorust.md
+1 −1 src/backend/backend-agnostic.md
+6 −6 src/backend/implicit-caller-location.md
+3 −2 src/backend/libs-and-metadata.md
+6 −6 src/backend/monomorph.md
+2 −2 src/backend/updating-llvm.md
+4 −4 src/borrow_check.md
+14 −14 src/borrow_check/moves_and_initialization/move_paths.md
+16 −16 src/borrow_check/region_inference.md
+8 −8 src/borrow_check/region_inference/constraint_propagation.md
+6 −6 src/borrow_check/region_inference/lifetime_parameters.md
+1 −1 src/borrow_check/region_inference/member_constraints.md
+3 −3 src/borrow_check/two_phase_borrows.md
+1 −1 src/borrow_check/type_check.md
+81 −73 src/building/bootstrapping.md
+1 −1 src/building/build-install-distribution-artifacts.md
+1 −1 src/building/compiler-documenting.md
+1 −6 src/building/how-to-build-and-run.md
+1 −1 src/building/new-target.md
+6 −12 src/building/suggested.md
+3 −3 src/closure.md
+134 −1 src/compiler-debugging.md
+3 −3 src/compiletest.md
+2 −2 src/const-eval.md
+0 −65 src/constants.md
+24 −43 src/contributing.md
+3 −9 src/diagnostics.md
+1 −1 src/diagnostics/diagnostic-items.md
+1 −1 src/diagnostics/lintstore.md
+1 −1 src/early-late-bound.md
+24 −26 src/getting-started.md
+2 −2 src/git.md
+12 −7 src/hir.md
+34 −32 src/llvm-coverage-instrumentation.md
+1 −1 src/macro-expansion.md
+11 −11 src/mir/dataflow.md
+2 −2 src/mir/debugging.md
+0 −195 src/mir/drop-elaboration.md
+3 −7 src/mir/index.md
+10 −11 src/mir/optimizations.md
+3 −4 src/mir/passes.md
+1 −2 src/mir/visitor.md
+8 −8 src/miri.md
+6 −6 src/overview.md
+3 −15 src/parallel-rustc.md
+6 −9 src/profiling.md
+10 −10 src/profiling/with_perf.md
+12 −8 src/rustdoc-internals.md
+10 −121 src/rustdoc.md
+18 −65 src/sanitizers.md
+4 −62 src/tests/adding.md
+6 −2 src/tests/intro.md
+5 −16 src/tests/running.md
+0 −204 src/tracing.md
+1 −1 src/ty.md
+1 −1 src/walkthrough.md
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 57 files
+1 −47 clang/docs/ReleaseNotes.rst
+8 −8 clang/include/clang/Sema/Initialization.h
+3 −12 clang/lib/AST/ExprConstant.cpp
+14 −17 clang/lib/Analysis/ThreadSafety.cpp
+8 −11 clang/lib/CodeGen/CGExprCXX.cpp
+1 −1 clang/lib/Sema/Sema.cpp
+1 −1 clang/lib/Sema/SemaCoroutine.cpp
+0 −9 clang/lib/Sema/SemaDeclCXX.cpp
+1 −1 clang/lib/Sema/SemaExpr.cpp
+3 −2 clang/lib/Sema/SemaExprCXX.cpp
+2 −1 clang/lib/Sema/SemaLambda.cpp
+2 −1 clang/lib/Sema/SemaObjCProperty.cpp
+4 −4 clang/lib/Sema/SemaStmt.cpp
+0 −37 clang/test/CodeGen/nrvo-tracking.cpp
+0 −34 clang/test/CodeGenCXX/copy-elision.cpp
+0 −42 clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+0 −9 llvm/docs/ReleaseNotes.rst
+1 −1 llvm/include/llvm/Analysis/InlineCost.h
+0 −1 llvm/include/llvm/IR/Metadata.h
+2 −6 llvm/include/llvm/ProfileData/InstrProf.h
+4 −12 llvm/include/llvm/ProfileData/InstrProfReader.h
+2 −7 llvm/lib/Analysis/InlineAdvisor.cpp
+1 −2 llvm/lib/CodeGen/RegAllocFast.cpp
+0 −10 llvm/lib/IR/DebugInfoMetadata.cpp
+1 −8 llvm/lib/IR/LLVMContextImpl.cpp
+0 −5 llvm/lib/IR/Mangler.cpp
+18 −22 llvm/lib/Passes/PassBuilder.cpp
+1 −2 llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+31 −68 llvm/lib/ProfileData/InstrProf.cpp
+18 −45 llvm/lib/ProfileData/InstrProfReader.cpp
+2 −10 llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+0 −3 llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
+13 −39 llvm/lib/Target/Mips/MipsBranchExpansion.cpp
+0 −49 llvm/lib/Target/Mips/MipsInstrInfo.cpp
+0 −7 llvm/lib/Target/Mips/MipsInstrInfo.h
+1 −62 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+1 −4 llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+1 −1 llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
+0 −132 llvm/lib/Target/RISCV/RISCVInstrFormats.td
+0 −102 llvm/lib/Target/RISCV/RISCVInstrInfo.td
+0 −12 llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+2 −6 llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
+0 −32 llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-xor-tbz-tbnz.mir
+0 −56 llvm/test/CodeGen/AArch64/GlobalISel/rbs-matrixindex-regclass-crash.mir
+0 −12 llvm/test/CodeGen/Mips/llvm-ir/select-dbl.ll
+0 −12 llvm/test/CodeGen/Mips/llvm-ir/select-flt.ll
+0 −15 llvm/test/CodeGen/X86/stdcall.ll
+2 −1 llvm/test/CodeGen/X86/vectorcall.ll
+0 −17 llvm/test/MC/RISCV/insn-invalid.s
+0 −77 llvm/test/MC/RISCV/insn.s
+1 −1 llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
+0 −120 llvm/test/Transforms/Inline/exponential-deferred-inlining.ll
+0 −119 llvm/test/Transforms/PhaseOrdering/X86/merge-functions.ll
+0 −20 llvm/test/tools/llvm-profdata/large-binary-id-size.test
+0 −47 llvm/test/tools/llvm-profdata/malformed-not-space-for-another-header.test
+0 −45 llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test
+1 −1 llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
6 changes: 4 additions & 2 deletions src/test/ui/error-codes/E0025.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/error-codes/E0268.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/error-codes/E0697.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
static || {}; //~ ERROR E0697
}
9 changes: 9 additions & 0 deletions src/test/ui/error-codes/E0697.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0697]: closures cannot be static
--> $DIR/E0697.rs:2:5
|
LL | static || {};
| ^^^^^^^^^ help: consider removing the: `static`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0697`.
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer