Skip to content

Commit

Permalink
Unrolled build for rust-lang#122841
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Mar 22, 2024
2 parents 0ad927c + bdafec3 commit 9a51d01
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/ui/borrowck/ice-mutability-error-slicing-121807.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//@ edition:2015
// test for ICE #121807 begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>'
// fixed by #122749

trait MemoryUnit { // ERROR: not all trait items implemented, missing: `read_word`
extern "C" fn read_word(&mut self) -> u8;
extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
//~^ WARN anonymous parameters are deprecated and will be removed in the next edition
//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
//~^^^ ERROR associated type `Assoc` not found for `Self`
}

struct ROM {}

impl MemoryUnit for ROM {
//~^ ERROR not all trait items implemented, missing: `read_word`
extern "C" fn read_dword(&'s self) -> u16 {
//~^ ERROR use of undeclared lifetime name `'s`
//~^^ ERROR method `read_dword` has a `&self` declaration in the impl, but not in the trait
let a16 = self.read_word() as u16;
let b16 = self.read_word() as u16;

(b16 << 8) | a16
}
}

pub fn main() {}
53 changes: 53 additions & 0 deletions tests/ui/borrowck/ice-mutability-error-slicing-121807.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
error[E0261]: use of undeclared lifetime name `'s`
--> $DIR/ice-mutability-error-slicing-121807.rs:17:31
|
LL | extern "C" fn read_dword(&'s self) -> u16 {
| ^^ undeclared lifetime
|
help: consider introducing lifetime `'s` here
|
LL | extern "C" fn read_dword<'s>(&'s self) -> u16 {
| ++++
help: consider introducing lifetime `'s` here
|
LL | impl<'s> MemoryUnit for ROM {
| ++++

warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/ice-mutability-error-slicing-121807.rs:7:30
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ^^^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: Self::Assoc<'_>`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
= note: `#[warn(anonymous_parameters)]` on by default

error[E0220]: associated type `Assoc` not found for `Self`
--> $DIR/ice-mutability-error-slicing-121807.rs:7:36
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ^^^^^ associated type `Assoc` not found

error[E0185]: method `read_dword` has a `&self` declaration in the impl, but not in the trait
--> $DIR/ice-mutability-error-slicing-121807.rs:17:5
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ------------------------------------------------- trait method declared without `&self`
...
LL | extern "C" fn read_dword(&'s self) -> u16 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&self` used in impl

error[E0046]: not all trait items implemented, missing: `read_word`
--> $DIR/ice-mutability-error-slicing-121807.rs:15:1
|
LL | extern "C" fn read_word(&mut self) -> u8;
| ----------------------------------------- `read_word` from trait
...
LL | impl MemoryUnit for ROM {
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `read_word` in implementation

error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0046, E0185, E0220, E0261.
For more information about an error, try `rustc --explain E0046`.
25 changes: 25 additions & 0 deletions tests/ui/inference/ice-ifer-var-leaked-out-of-rollback-122098.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// test for #122098 ICE snapshot_vec.rs: index out of bounds: the len is 4 but the index is 4

trait LendingIterator {
type Item<'q>: 'a;
//~^ ERROR use of undeclared lifetime name `'a`

fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
//~^ ERROR the size for values of type `Self` cannot be known at compilation time
}

struct Query<'q> {}
//~^ ERROR lifetime parameter `'q` is never used

impl<'static> Query<'q> {
//~^ ERROR invalid lifetime parameter name: `'static`
//~^^ ERROR use of undeclared lifetime name `'q`
pub fn new() -> Self {}
}

fn data() {
LendingIterator::for_each(Query::new(&data), Box::new);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:4:20
|
LL | type Item<'q>: 'a;
| ^^ undeclared lifetime
|
help: consider introducing lifetime `'a` here
|
LL | type Item<'a, 'q>: 'a;
| +++
help: consider introducing lifetime `'a` here
|
LL | trait LendingIterator<'a> {
| ++++

error[E0262]: invalid lifetime parameter name: `'static`
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:6
|
LL | impl<'static> Query<'q> {
| ^^^^^^^ 'static is a reserved lifetime name

error[E0261]: use of undeclared lifetime name `'q`
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:21
|
LL | impl<'static> Query<'q> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'q` here: `'q,`

error[E0392]: lifetime parameter `'q` is never used
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:11:14
|
LL | struct Query<'q> {}
| ^^ unused lifetime parameter
|
= help: consider removing `'q`, referring to it in a field, or using a marker such as `PhantomData`

error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:7:17
|
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
| ^^^^^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) where Self: Sized {}
| +++++++++++++++++
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | fn for_each(mut &self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
| +

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:21:31
|
LL | LendingIterator::for_each(Query::new(&data), Box::new);
| ^^^^^^^^^^ -----
| |
| unexpected argument of type `&fn() {data}`
| help: remove the extra argument
|
note: associated function defined here
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:17:12
|
LL | pub fn new() -> Self {}
| ^^^

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0061, E0261, E0262, E0277, E0392.
For more information about an error, try `rustc --explain E0061`.

0 comments on commit 9a51d01

Please sign in to comment.