Skip to content

Commit 9a51d01

Browse files
authored
Unrolled build for rust-lang#122841
Rollup merge of rust-lang#122841 - matthiaskrgr:moretests, r=wesleywiser add 2 more tests for issues fixed by rust-lang#122749 Fixes rust-lang#121807 Fixes rust-lang#122098
2 parents 0ad927c + bdafec3 commit 9a51d01

4 files changed

+177
-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`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// test for #122098 ICE snapshot_vec.rs: index out of bounds: the len is 4 but the index is 4
2+
3+
trait LendingIterator {
4+
type Item<'q>: 'a;
5+
//~^ ERROR use of undeclared lifetime name `'a`
6+
7+
fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
8+
//~^ ERROR the size for values of type `Self` cannot be known at compilation time
9+
}
10+
11+
struct Query<'q> {}
12+
//~^ ERROR lifetime parameter `'q` is never used
13+
14+
impl<'static> Query<'q> {
15+
//~^ ERROR invalid lifetime parameter name: `'static`
16+
//~^^ ERROR use of undeclared lifetime name `'q`
17+
pub fn new() -> Self {}
18+
}
19+
20+
fn data() {
21+
LendingIterator::for_each(Query::new(&data), Box::new);
22+
//~^ ERROR this function takes 0 arguments but 1 argument was supplied
23+
}
24+
25+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:4:20
3+
|
4+
LL | type Item<'q>: 'a;
5+
| ^^ undeclared lifetime
6+
|
7+
help: consider introducing lifetime `'a` here
8+
|
9+
LL | type Item<'a, 'q>: 'a;
10+
| +++
11+
help: consider introducing lifetime `'a` here
12+
|
13+
LL | trait LendingIterator<'a> {
14+
| ++++
15+
16+
error[E0262]: invalid lifetime parameter name: `'static`
17+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:6
18+
|
19+
LL | impl<'static> Query<'q> {
20+
| ^^^^^^^ 'static is a reserved lifetime name
21+
22+
error[E0261]: use of undeclared lifetime name `'q`
23+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:21
24+
|
25+
LL | impl<'static> Query<'q> {
26+
| - ^^ undeclared lifetime
27+
| |
28+
| help: consider introducing lifetime `'q` here: `'q,`
29+
30+
error[E0392]: lifetime parameter `'q` is never used
31+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:11:14
32+
|
33+
LL | struct Query<'q> {}
34+
| ^^ unused lifetime parameter
35+
|
36+
= help: consider removing `'q`, referring to it in a field, or using a marker such as `PhantomData`
37+
38+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
39+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:7:17
40+
|
41+
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
42+
| ^^^^^^^^ doesn't have a size known at compile-time
43+
|
44+
= help: unsized fn params are gated as an unstable feature
45+
help: consider further restricting `Self`
46+
|
47+
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) where Self: Sized {}
48+
| +++++++++++++++++
49+
help: function arguments must have a statically known size, borrowed types always have a known size
50+
|
51+
LL | fn for_each(mut &self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
52+
| +
53+
54+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
55+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:21:31
56+
|
57+
LL | LendingIterator::for_each(Query::new(&data), Box::new);
58+
| ^^^^^^^^^^ -----
59+
| |
60+
| unexpected argument of type `&fn() {data}`
61+
| help: remove the extra argument
62+
|
63+
note: associated function defined here
64+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:17:12
65+
|
66+
LL | pub fn new() -> Self {}
67+
| ^^^
68+
69+
error: aborting due to 6 previous errors
70+
71+
Some errors have detailed explanations: E0061, E0261, E0262, E0277, E0392.
72+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)