Skip to content

Commit 21c13be

Browse files
Rollup merge of rust-lang#42957 - GuillaumeGomez:add-e0619, r=nikomatsakis
Add E0619 error explanation r? @eddyb
2 parents 6cc33dd + 2c86ff4 commit 21c13be

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/librustc_typeck/check/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
3737
match it.node {
3838
hir::ForeignItemFn(..) => {}
3939
_ => {
40-
struct_span_err!(tcx.sess, it.span, E0619,
40+
struct_span_err!(tcx.sess, it.span, E0621,
4141
"intrinsic must be a function")
4242
.span_label(it.span, "expected a function")
4343
.emit();

src/librustc_typeck/diagnostics.rs

+20
Original file line numberDiff line numberDiff line change
@@ -4726,6 +4726,26 @@ let x = &[1_usize, 2] as &[usize]; // ok!
47264726
```
47274727
"##,
47284728

4729+
E0621: r##"
4730+
An intrinsic was declared without being a function.
4731+
4732+
Erroneous code example:
4733+
4734+
```compile_fail,E0621
4735+
#![feature(intrinsics)]
4736+
extern "rust-intrinsic" {
4737+
pub static breakpoint : unsafe extern "rust-intrinsic" fn();
4738+
// error: intrinsic must be a function
4739+
}
4740+
4741+
fn main() { unsafe { breakpoint(); } }
4742+
```
4743+
4744+
An intrinsic is a function available for use in a given programming language
4745+
whose implementation is handled specially by the compiler. In order to fix this
4746+
error, just declare a function.
4747+
"##,
4748+
47294749
}
47304750

47314751
register_diagnostics! {

src/test/compile-fail/E0619.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ fn main() {
1616
_ => {}
1717
}
1818
}
19+

src/test/compile-fail/invalid-intrinsic.rs renamed to src/test/compile-fail/E0621.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
#![feature(intrinsics)]
1212
extern "rust-intrinsic" {
1313
pub static breakpoint : unsafe extern "rust-intrinsic" fn();
14-
//~^ ERROR intrinsic must be a function
14+
//~^ ERROR intrinsic must be a function [E0621]
1515
}
1616
fn main() { unsafe { breakpoint(); } }

0 commit comments

Comments
 (0)