Skip to content

Commit bdafec3

Browse files
committed
add test for #121807
Fixes #121807
1 parent 35a7845 commit bdafec3

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ edition:2015
2+
// test for ICE #121807 begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>'
3+
// fixed by #122749
4+
5+
trait MemoryUnit { // ERROR: not all trait items implemented, missing: `read_word`
6+
extern "C" fn read_word(&mut self) -> u8;
7+
extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
8+
//~^ WARN anonymous parameters are deprecated and will be removed in the next edition
9+
//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
10+
//~^^^ ERROR associated type `Assoc` not found for `Self`
11+
}
12+
13+
struct ROM {}
14+
15+
impl MemoryUnit for ROM {
16+
//~^ ERROR not all trait items implemented, missing: `read_word`
17+
extern "C" fn read_dword(&'s self) -> u16 {
18+
//~^ ERROR use of undeclared lifetime name `'s`
19+
//~^^ ERROR method `read_dword` has a `&self` declaration in the impl, but not in the trait
20+
let a16 = self.read_word() as u16;
21+
let b16 = self.read_word() as u16;
22+
23+
(b16 << 8) | a16
24+
}
25+
}
26+
27+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error[E0261]: use of undeclared lifetime name `'s`
2+
--> $DIR/ice-mutability-error-slicing-121807.rs:17:31
3+
|
4+
LL | extern "C" fn read_dword(&'s self) -> u16 {
5+
| ^^ undeclared lifetime
6+
|
7+
help: consider introducing lifetime `'s` here
8+
|
9+
LL | extern "C" fn read_dword<'s>(&'s self) -> u16 {
10+
| ++++
11+
help: consider introducing lifetime `'s` here
12+
|
13+
LL | impl<'s> MemoryUnit for ROM {
14+
| ++++
15+
16+
warning: anonymous parameters are deprecated and will be removed in the next edition
17+
--> $DIR/ice-mutability-error-slicing-121807.rs:7:30
18+
|
19+
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
20+
| ^^^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: Self::Assoc<'_>`
21+
|
22+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
23+
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
24+
= note: `#[warn(anonymous_parameters)]` on by default
25+
26+
error[E0220]: associated type `Assoc` not found for `Self`
27+
--> $DIR/ice-mutability-error-slicing-121807.rs:7:36
28+
|
29+
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
30+
| ^^^^^ associated type `Assoc` not found
31+
32+
error[E0185]: method `read_dword` has a `&self` declaration in the impl, but not in the trait
33+
--> $DIR/ice-mutability-error-slicing-121807.rs:17:5
34+
|
35+
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
36+
| ------------------------------------------------- trait method declared without `&self`
37+
...
38+
LL | extern "C" fn read_dword(&'s self) -> u16 {
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&self` used in impl
40+
41+
error[E0046]: not all trait items implemented, missing: `read_word`
42+
--> $DIR/ice-mutability-error-slicing-121807.rs:15:1
43+
|
44+
LL | extern "C" fn read_word(&mut self) -> u8;
45+
| ----------------------------------------- `read_word` from trait
46+
...
47+
LL | impl MemoryUnit for ROM {
48+
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `read_word` in implementation
49+
50+
error: aborting due to 4 previous errors; 1 warning emitted
51+
52+
Some errors have detailed explanations: E0046, E0185, E0220, E0261.
53+
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)