fixing doctest failures in resurfaced extended information

After repatriating error explanations to the global registry, some lurking
doctest failures surfaced and needed to be chased down. Sadly, a few doctests
needed to be ignored due to a not-yet-understood regression in the doctest
`compile_fail` functionality (filed #43707).
This commit is contained in:
Zack M. Davis 2017-08-06 21:36:06 -07:00
parent 7efeade268
commit 86b7546204
3 changed files with 34 additions and 14 deletions

View File

@ -122,10 +122,8 @@ On the other hand, static and constant pointers can point either to
a known numeric address or to the address of a symbol. a known numeric address or to the address of a symbol.
``` ```
static MY_STATIC: u32 = 42;
static MY_STATIC_ADDR: &'static u32 = &MY_STATIC; static MY_STATIC_ADDR: &'static u32 = &MY_STATIC;
// ... and also
static MY_STATIC_ADDR2: *const u32 = &MY_STATIC;
const CONST_ADDR: *const u8 = 0x5f3759df as *const u8; const CONST_ADDR: *const u8 = 0x5f3759df as *const u8;
``` ```
@ -160,6 +158,16 @@ Remember: you can't use a function call inside a const's initialization
expression! However, you can totally use it anywhere else: expression! However, you can totally use it anywhere else:
``` ```
enum Test {
V1
}
impl Test {
fn func(&self) -> i32 {
12
}
}
fn main() { fn main() {
const FOO: Test = Test::V1; const FOO: Test = Test::V1;

View File

@ -221,7 +221,7 @@ while break {}
To fix this, add a label specifying which loop is being broken out of: To fix this, add a label specifying which loop is being broken out of:
``` ```
`foo: while break `foo {} 'foo: while break 'foo {}
``` ```
"## "##
} }

View File

@ -42,7 +42,7 @@ The `inline` attribute was malformed.
Erroneous code example: Erroneous code example:
```compile_fail,E0534 ```ignore (compile_fail not working here; see Issue #43707)
#[inline()] // error: expected one argument #[inline()] // error: expected one argument
pub fn something() {} pub fn something() {}
@ -80,7 +80,7 @@ An unknown argument was given to the `inline` attribute.
Erroneous code example: Erroneous code example:
```compile_fail,E0535 ```ignore (compile_fail not working here; see Issue #43707)
#[inline(unknown)] // error: invalid argument #[inline(unknown)] // error: invalid argument
pub fn something() {} pub fn something() {}
@ -190,7 +190,9 @@ A literal was used in an attribute that doesn't support literals.
Erroneous code example: Erroneous code example:
```compile_fail,E0565 ```ignore (compile_fail not working here; see Issue #43707)
#![feature(attr_literals)]
#[inline("always")] // error: unsupported literal #[inline("always")] // error: unsupported literal
pub fn something() {} pub fn something() {}
``` ```
@ -209,7 +211,7 @@ A file wasn't found for an out-of-line module.
Erroneous code example: Erroneous code example:
```compile_fail,E0583 ```ignore (compile_fail not working here; see Issue #43707)
mod file_that_doesnt_exist; // error: file not found for module mod file_that_doesnt_exist; // error: file not found for module
fn main() {} fn main() {}
@ -251,23 +253,33 @@ An inclusive range was used with no end.
Erroneous code example: Erroneous code example:
```compile_fail,E0586 ```compile_fail,E0586
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; #![feature(inclusive_range_syntax)]
let x = &tmp[1...]; // error: inclusive range was used with no end
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1...]; // error: inclusive range was used with no end
}
``` ```
An inclusive range needs an end in order to *include* it. If you just need a An inclusive range needs an end in order to *include* it. If you just need a
start and no end, use a non-inclusive range (with `..`): start and no end, use a non-inclusive range (with `..`):
``` ```
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; fn main() {
let x = &tmp[1..]; // ok! let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..]; // ok!
}
``` ```
Or put an end to your inclusive range: Or put an end to your inclusive range:
``` ```
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; #![feature(inclusive_range_syntax)]
let x = &tmp[1...3]; // ok!
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1...3]; // ok!
}
``` ```
"##, "##,