Skip to content

tests/ui: A New Order [1/N] #141793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions tests/ui/autoderef-full-lval.rs

This file was deleted.

35 changes: 35 additions & 0 deletions tests/ui/autoref-autoderef/autoderef-box-no-add.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! Tests that auto-dereferencing does not allow addition of `Box<isize>` values.
//!
//! This test ensures that `Box<isize>` fields in structs (`Clam` and `Fish`) are not
//! automatically dereferenced to `isize` during addition operations, as `Box<isize>`
//! does not implement the `Add` trait.

struct Clam {
x: Box<isize>,
y: Box<isize>,
}

struct Fish {
a: Box<isize>,
}

fn main() {
let a: Clam = Clam {
x: Box::new(1),
y: Box::new(2),
};
let b: Clam = Clam {
x: Box::new(10),
y: Box::new(20),
};
let z: isize = a.x + b.y;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", z);
assert_eq!(z, 21);
let forty: Fish = Fish { a: Box::new(40) };
let two: Fish = Fish { a: Box::new(2) };
let answer: isize = forty.a + two.a;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", answer);
assert_eq!(answer, 42);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
--> $DIR/autoderef-full-lval.rs:15:24
--> $DIR/autoderef-box-no-add.rs:25:24
|
LL | let z: isize = a.x + b.y;
| --- ^ --- Box<isize>
Expand All @@ -13,7 +13,7 @@ note: the foreign item type `Box<isize>` doesn't implement `Add`
= note: not implement `Add`

error[E0369]: cannot add `Box<isize>` to `Box<isize>`
--> $DIR/autoderef-full-lval.rs:21:33
--> $DIR/autoderef-box-no-add.rs:31:33
|
LL | let answer: isize = forty.a + two.a;
| ------- ^ ----- Box<isize>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Tests that bare functions implement the `FnMut` trait.
//!
//! See <https://github.com/rust-lang/rust/issues/15448>.

//@ run-pass

fn call_f<F:FnMut()>(mut f: F) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Test that valid large numeric literals do not trigger the `overflowing_literals` lint.

//@ run-pass
// Catch mistakes in the overflowing literals lint.

#![deny(overflowing_literals)]

pub fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
fn main() {

// Testing that method lookup does not automatically borrow
// vectors to slices then automatically create a self reference.
//! Test that method resolution does not autoderef `Vec`
//! into a slice or perform additional autorefs.

fn main() {
let mut a = vec![0];
a.test_mut(); //~ ERROR no method named `test_mut` found
a.test(); //~ ERROR no method named `test` found
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
--> $DIR/vec-autoderef-autoref.rs:6:7
|
LL | a.test_mut();
| ^^^^^^^^
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
help: there is a method `get_mut` with a similar name, but with different arguments
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL

error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
--> $DIR/vec-autoderef-autoref.rs:7:7
|
LL | a.test();
| ^^^^ method not found in `Vec<{integer}>`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^

error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
--> $DIR/vec-autoderef-autoref.rs:9:11
|
LL | ([1]).test();
| ^^^^ method not found in `[{integer}; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^

error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
--> $DIR/vec-autoderef-autoref.rs:10:12
|
LL | (&[1]).test();
| ^^^^ method not found in `&[{integer}; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Check that a bare string literal is typed as a `&'static str` and is usable.

//@ run-pass

pub fn main() {
Expand Down
Loading