Skip to content

Commit d3e24bd

Browse files
authored
Rollup merge of #71350 - GuillaumeGomez:error-code-explanation-extra-check, r=oli-obk
Error code explanation extra check r? @Mark-Simulacrum
2 parents 10e47f5 + 5cdea2d commit d3e24bd

File tree

25 files changed

+231
-84
lines changed

25 files changed

+231
-84
lines changed

src/librustc_error_codes/error_codes/E0060.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ External C functions are allowed to be variadic. However, a variadic function
22
takes a minimum number of arguments. For example, consider C's variadic `printf`
33
function:
44

5-
```
5+
```compile_fail,E0060
66
use std::os::raw::{c_char, c_int};
77
88
extern "C" {
99
fn printf(_: *const c_char, ...) -> c_int;
1010
}
11+
12+
unsafe { printf(); } // error!
1113
```
1214

1315
Using this declaration, it must be called with at least one argument, so

src/librustc_error_codes/error_codes/E0130.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ A pattern was declared as an argument in a foreign function declaration.
22

33
Erroneous code example:
44

5-
```compile_fail
5+
```compile_fail,E0130
66
extern {
77
fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
88
// function declarations

src/librustc_error_codes/error_codes/E0198.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ A negative implementation was marked as unsafe.
22

33
Erroneous code example:
44

5-
```compile_fail
5+
```compile_fail,E0198
66
struct Foo;
77
88
unsafe impl !Clone for Foo { } // error!
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
Inherent associated types were part of [RFC 195] but are not yet implemented.
22
See [the tracking issue][iss8995] for the status of this implementation.
33

4+
Erroneous code example:
5+
6+
```compile_fail,E0202
7+
struct Foo;
8+
9+
impl Foo {
10+
type Bar = isize; // error!
11+
}
12+
```
13+
414
[RFC 195]: https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md
515
[iss8995]: https://github.com/rust-lang/rust/issues/8995

src/librustc_error_codes/error_codes/E0230.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ message for when a particular trait isn't implemented on a type placed in a
33
position that needs that trait. For example, when the following code is
44
compiled:
55

6-
```compile_fail
6+
```compile_fail,E0230
77
#![feature(rustc_attrs)]
88
9-
fn foo<T: Index<u8>>(x: T){}
10-
11-
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
12-
trait Index<Idx> { /* ... */ }
13-
14-
foo(true); // `bool` does not implement `Index<u8>`
9+
#[rustc_on_unimplemented = "error on `{Self}` with params `<{A},{B}>`"] // error
10+
trait BadAnnotation<A> {}
1511
```
1612

1713
There will be an error about `bool` not implementing `Index<u8>`, followed by a

src/librustc_error_codes/error_codes/E0231.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ message for when a particular trait isn't implemented on a type placed in a
33
position that needs that trait. For example, when the following code is
44
compiled:
55

6-
```compile_fail
6+
```compile_fail,E0231
77
#![feature(rustc_attrs)]
88
9-
fn foo<T: Index<u8>>(x: T){}
10-
11-
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
12-
trait Index<Idx> { /* ... */ }
13-
14-
foo(true); // `bool` does not implement `Index<u8>`
9+
#[rustc_on_unimplemented = "error on `{Self}` with params `<{A},{}>`"] // error!
10+
trait BadAnnotation<A> {}
1511
```
1612

1713
there will be an error about `bool` not implementing `Index<u8>`, followed by a

src/librustc_error_codes/error_codes/E0232.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ message for when a particular trait isn't implemented on a type placed in a
33
position that needs that trait. For example, when the following code is
44
compiled:
55

6-
```compile_fail
6+
```compile_fail,E0232
77
#![feature(rustc_attrs)]
88
9-
fn foo<T: Index<u8>>(x: T){}
10-
11-
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
12-
trait Index<Idx> { /* ... */ }
13-
14-
foo(true); // `bool` does not implement `Index<u8>`
9+
#[rustc_on_unimplemented(lorem="")] // error!
10+
trait BadAnnotation {}
1511
```
1612

1713
there will be an error about `bool` not implementing `Index<u8>`, followed by a

src/librustc_error_codes/error_codes/E0281.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You tried to supply a type which doesn't implement some trait in a location
44
which expected that trait. This error typically occurs when working with
55
`Fn`-based types. Erroneous code example:
66

7-
```compile-fail
7+
```compile_fail
88
fn foo<F: Fn(usize)>(x: F) { }
99
1010
fn main() {

src/librustc_error_codes/error_codes/E0364.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ attempted to `pub use` a type or value that was not itself public.
33

44
Erroneous code example:
55

6-
```compile_fail
7-
mod foo {
8-
const X: u32 = 1;
9-
}
10-
11-
pub use foo::X;
6+
```compile_fail,E0364
7+
mod a {
8+
fn foo() {}
129
13-
fn main() {}
10+
mod a {
11+
pub use super::foo; // error!
12+
}
13+
}
1414
```
1515

1616
The solution to this problem is to ensure that the items that you are
1717
re-exporting are themselves marked with `pub`:
1818

1919
```
20-
mod foo {
21-
pub const X: u32 = 1;
22-
}
23-
24-
pub use foo::X;
20+
mod a {
21+
pub fn foo() {} // ok!
2522
26-
fn main() {}
23+
mod a {
24+
pub use super::foo;
25+
}
26+
}
2727
```
2828

2929
See the [Use Declarations][use-declarations] section of the reference for

src/librustc_error_codes/error_codes/E0378.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ or a newtype wrapper around a pointer.
33

44
Erroneous code example:
55

6-
```compile-fail,E0378
6+
```compile_fail,E0378
77
#![feature(dispatch_from_dyn)]
88
use std::ops::DispatchFromDyn;
99

0 commit comments

Comments
 (0)