diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-06-30 22:44:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-30 22:44:46 +0200 |
| commit | bbdb21efbf0dfb882dac8899f35db05c4856e654 (patch) | |
| tree | 424c08daf8df02086eb59c71501626cf7f40b82f /src | |
| parent | db004d4f55aea68a2ccf2377c3a02dfb28a7b592 (diff) | |
| parent | 162b5a347590a7dbc77d3281595b1bfaba98e3b1 (diff) | |
| download | rust-bbdb21efbf0dfb882dac8899f35db05c4856e654.tar.gz rust-bbdb21efbf0dfb882dac8899f35db05c4856e654.zip | |
Rollup merge of #42957 - GuillaumeGomez:add-e0619, r=nikomatsakis
Add E0619 error explanation r? @eddyb
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/intrinsic.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/E0619.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/E0622.rs (renamed from src/test/compile-fail/invalid-intrinsic.rs) | 2 |
4 files changed, 23 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 3acfbd1d844..96643ae72ab 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -37,7 +37,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match it.node { hir::ForeignItemFn(..) => {} _ => { - struct_span_err!(tcx.sess, it.span, E0619, + struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function") .span_label(it.span, "expected a function") .emit(); diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 1b17faccc87..37f6f3753d7 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4726,6 +4726,26 @@ let x = &[1_usize, 2] as &[usize]; // ok! ``` "##, +E0622: r##" +An intrinsic was declared without being a function. + +Erroneous code example: + +```compile_fail,E0622 +#![feature(intrinsics)] +extern "rust-intrinsic" { + pub static breakpoint : unsafe extern "rust-intrinsic" fn(); + // error: intrinsic must be a function +} + +fn main() { unsafe { breakpoint(); } } +``` + +An intrinsic is a function available for use in a given programming language +whose implementation is handled specially by the compiler. In order to fix this +error, just declare a function. +"##, + } register_diagnostics! { diff --git a/src/test/compile-fail/E0619.rs b/src/test/compile-fail/E0619.rs index 8ef90d89931..a5a5ff7218d 100644 --- a/src/test/compile-fail/E0619.rs +++ b/src/test/compile-fail/E0619.rs @@ -16,3 +16,4 @@ fn main() { _ => {} } } + diff --git a/src/test/compile-fail/invalid-intrinsic.rs b/src/test/compile-fail/E0622.rs index c42d78c323e..f2bde5b0364 100644 --- a/src/test/compile-fail/invalid-intrinsic.rs +++ b/src/test/compile-fail/E0622.rs @@ -11,6 +11,6 @@ #![feature(intrinsics)] extern "rust-intrinsic" { pub static breakpoint : unsafe extern "rust-intrinsic" fn(); - //~^ ERROR intrinsic must be a function + //~^ ERROR intrinsic must be a function [E0622] } fn main() { unsafe { breakpoint(); } } |
