File tree Expand file tree Collapse file tree 5 files changed +94
-3
lines changed
rustc_hir_analysis/src/check Expand file tree Collapse file tree 5 files changed +94
-3
lines changed Original file line number Diff line number Diff line change 1+ An externally implementable item is not compatible with its declaration.
2+
3+ Erroneous code example:
4+
5+ ``` rust,edition2021,compile_fail,E0805
6+ #![feature(eii)]
7+
8+ #[eii(foo)]
9+ fn x();
10+
11+ #[foo]
12+ fn y(a: u64) -> u64 {
13+ //~^ ERROR E0806
14+ a
15+ }
16+
17+
18+ fn main() {}
19+ ```
20+
21+ To fix this, ` y ` 's signature must match that of ` x ` :
22+
23+ ``` rust,edition2021
24+ #![feature(eii)]
25+
26+ #[eii(foo)]
27+ fn x();
28+
29+ #[foo]
30+ fn y() {}
31+
32+
33+ fn main() {}
34+ ```
35+
36+ One common way this can be triggered is by using the wrong
37+ signature for ` #[panic_handler] ` .
38+ The signature is provided by ` core ` .
39+
40+ ``` rust,edition2021,ignore
41+ #![no_std]
42+
43+ #[panic_handler]
44+ fn on_panic() -> ! {
45+ //~^ ERROR E0806
46+
47+ loop {}
48+ }
49+
50+ fn main() {}
51+ ```
52+
53+ Should be:
54+
55+ ``` rust,edition2021,ignore
56+ #![no_std]
57+
58+ #[panic_handler]
59+ fn on_panic(info: &core::panic::PanicInfo<'_>) -> ! {
60+ loop {}
61+ }
62+
63+ fn main() {}
64+ ```
Original file line number Diff line number Diff line change @@ -548,6 +548,7 @@ E0802: 0802,
548548E0803 : 0803 ,
549549E0804 : 0804 ,
550550E0805 : 0805 ,
551+ E0806 : 0806 ,
551552 ) ;
552553 )
553554}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::borrow::Cow;
22use std:: iter;
33
44use rustc_data_structures:: fx:: FxIndexSet ;
5- use rustc_errors:: { Applicability , E0805 , struct_span_code_err} ;
5+ use rustc_errors:: { Applicability , E0806 , struct_span_code_err} ;
66use rustc_hir:: def_id:: { DefId , LocalDefId } ;
77use rustc_hir:: { self as hir, FnSig , HirId , ItemKind } ;
88use rustc_infer:: infer:: { self , InferCtxt , TyCtxtInferExt } ;
@@ -182,7 +182,7 @@ fn compare_number_of_method_arguments<'tcx>(
182182 let mut err = struct_span_code_err ! (
183183 tcx. dcx( ) ,
184184 impl_span,
185- E0805 ,
185+ E0806 ,
186186 "`{external_impl_name}` has {} but #[{eii_name}] requires it to have {}" ,
187187 potentially_plural_count( external_impl_number_args, "parameter" ) ,
188188 declaration_number_args
@@ -329,7 +329,7 @@ fn report_eii_mismatch<'tcx>(
329329 let mut diag = struct_span_code_err ! (
330330 tcx. dcx( ) ,
331331 impl_err_span,
332- E0805 ,
332+ E0806 ,
333333 "function `{}` has a type that is incompatible with the declaration of `#[{eii_name}]`" ,
334334 external_impl_name
335335 ) ;
Original file line number Diff line number Diff line change 1+ #![ feature( eii) ]
2+
3+ #[ eii( foo) ]
4+ fn x ( ) ;
5+
6+ #[ foo]
7+ fn y ( a : u64 ) -> u64 {
8+ //~^ ERROR E0806
9+ a
10+ }
11+
12+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0806]: `y` has 1 parameter but #[foo] requires it to have 0
2+ --> $DIR/E0806.rs:7:9
3+ |
4+ LL | fn x();
5+ | ------- requires 0 parameters
6+ LL |
7+ LL | #[foo]
8+ | ------ required because of this attribute
9+ LL | fn y(a: u64) -> u64 {
10+ | ^^^ expected 0 parameters, found 1
11+
12+ error: aborting due to 1 previous error
13+
14+ For more information about this error, try `rustc --explain E0806`.
You can’t perform that action at this time.
0 commit comments