Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2c99ace

Browse files
committedJan 14, 2018
Add error code for unstable feature errors
1 parent 3f92e8d commit 2c99ace

File tree

121 files changed

+346
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+346
-297
lines changed
 

‎src/libsyntax/diagnostic_list.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,31 @@ fn main() {
317317
```
318318
"##,
319319

320+
E0658: r##"
321+
An unstable feature was used.
322+
323+
Erroneous code example:
324+
325+
```compile_fail,E658
326+
let x = ::std::u128::MAX; // error: use of unstable library feature 'i128'
327+
```
328+
329+
If you're using a stable or a beta version of rustc, you won't be able to use
330+
any unstable features. In order to do so, please switch to a nightly version of
331+
rustc (by using rustup).
332+
333+
If you're using a nightly version of rustc, just add the corresponding feature
334+
to be able to use it:
335+
336+
```
337+
#![feature(i128)]
338+
339+
fn main() {
340+
let x = ::std::u128::MAX; // ok!
341+
}
342+
```
343+
"##,
344+
320345
}
321346

322347
register_diagnostics! {

‎src/libsyntax/diagnostics/macros.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ macro_rules! struct_span_err {
105105
})
106106
}
107107

108+
#[macro_export]
109+
macro_rules! stringify_error_code {
110+
($code:ident) => ({
111+
__diagnostic_used!($code);
112+
$crate::errors::DiagnosticId::Error(stringify!($code).to_owned())
113+
})
114+
}
115+
108116
#[macro_export]
109117
macro_rules! type_error_struct {
110118
($session:expr, $span:expr, $typ:expr, $code:ident, $($message:tt)*) => ({

0 commit comments

Comments
 (0)