Skip to content

Error code E0116 causes high volume of incorrect compiler errors #125814

Closed
@anthonydandrea

Description

@anthonydandrea

Hello! When an E0116 is present in a codebase, it causes a very large slew of other unrelated and incorrect errors to get printed to the terminal. Even though it's a beginner Rust mistake, this is extremely hard to diagnose in any codebase.

Possible solutions might be:

  1. If E0116 is found, just print that, and skip printing any other errors (preferred)

  2. If E0116 is found, print it at the very end (not preferable, as there may be hundreds of errors which print first)

Code

fn main() {
    let x = "hello";
    x.split(" ");
}

impl Vec<usize> {}

Meta

rustc --version --verbose:

rustc 1.78.0 (9b00956e5 2024-04-29) (built from a source tarball)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2

Error output

   Compiling playground v0.0.1 (/playground)
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> src/main.rs:6:1
  |
6 | impl Vec<usize> {}
  | ^^^^^^^^^^^^^^^ impl for type defined outside of crate.
  |
  = note: define and implement a trait or new type instead

error[E0599]: no method named `split` found for reference `&str` in the current scope
 --> src/main.rs:3:7
  |
3 |     x.split(" ");
  |       ^^^^^ method not found in `&str`

Some errors have detailed explanations: E0116, E0599.
For more information about an error, try `rustc --explain E0116`.
error: could not compile `playground` (bin "playground") due to 2 previous errors
Backtrace

<backtrace>

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions