compiler/rustc_error_codes/src/error_codes/E0211.md MARKDOWN 80 lines View on github.com → Search inside
1#### Note: this error code is no longer emitted by the compiler.23You used a function or type which doesn't fit the requirements for where it was4used. Erroneous code examples:56```compile_fail7#![feature(intrinsics)]8#![allow(internal_features)]910#[rustc_intrinsic]11unsafe fn unreachable(); // error: intrinsic has wrong type1213// or:1415fn main() -> i32 { 0 }16// error: main function expects type: `fn() {main}`: expected (), found i321718// or:1920let x = 1u8;21match x {22    0u8..=3i8 => (),23    // error: mismatched types in range: expected u8, found i824    _ => ()25}2627// or:2829use std::rc::Rc;30struct Foo;3132impl Foo {33    fn x(self: Rc<Foo>) {}34    // error: mismatched self type: expected `Foo`: expected struct35    //        `Foo`, found struct `alloc::rc::Rc`36}37```3839For the first code example, please check the function definition. Example:4041```42#![feature(intrinsics)]43#![allow(internal_features)]4445#[rustc_intrinsic]46unsafe fn unreachable() -> !; // ok!47```4849The second case example is a bit particular: the main function must always50have this definition:5152```compile_fail53fn main();54```5556They never take parameters and never return types.5758For the third example, when you match, all patterns must have the same type59as the type you're matching on. Example:6061```62let x = 1u8;6364match x {65    0u8..=3u8 => (), // ok!66    _ => ()67}68```6970And finally, for the last example, only `Box<Self>`, `&Self`, `Self`,71or `&mut Self` work as explicit self parameters. Example:7273```74struct Foo;7576impl Foo {77    fn x(self: Box<Foo>) {} // ok!78}79```

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.