Skip to content

Advent of tests/ui (misc cleanups and improvements) [4/N] #140036

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 3 commits into from
Apr 21, 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
18 changes: 0 additions & 18 deletions tests/ui/amdgpu-require-explicit-cpu.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/auto-instantiate.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Smoke test for overloaded compound assignments cross-crate.

//@ run-pass
//@ aux-build:augmented_assignments.rs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Check that overloaded compound assignment operators respect usual borrowck rules and emit
//! reasonable diagnostics.

use std::ops::AddAssign;

#[derive(Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/augmented-assignments.rs:17:5
--> $DIR/augmented-assignments.rs:20:5
|
LL | let mut x = Int(1);
| ----- binding `x` declared here
Expand All @@ -10,7 +10,7 @@ LL | x;
| ^ move out of `x` occurs here

error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
--> $DIR/augmented-assignments.rs:24:5
--> $DIR/augmented-assignments.rs:27:5
|
LL | y
| ^ cannot borrow as mutable
Expand Down
28 changes: 28 additions & 0 deletions tests/ui/inference/auto-instantiate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Check that type parameters in generic function arg position and in "nested" return type position
//! can be inferred on an invocation of the generic function.
//!
//! See <https://github.com/rust-lang/rust/issues/45>.

//@ run-pass

#![allow(dead_code)]
#[derive(Debug)]
struct Pair<T, U> {
a: T,
b: U,
}

struct Triple {
x: isize,
y: isize,
z: isize,
}

fn f<T, U>(x: T, y: U) -> Pair<T, U> {
return Pair { a: x, b: y };
}

pub fn main() {
println!("{}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
println!("{}", f(5, 6).a);
}
Comment on lines +25 to +28
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: this test is also kinda exercising a bunch of things tho -- e.g. I think it also exercises {integer} -> isize coercion. That return Pair { a: x, b: y }; can also be materially different from Pair { a: x, b: y } in terms of which HIR typeck path we take. lmw if u have a better wording for the intention of this test.

4 changes: 4 additions & 0 deletions tests/ui/target-cpu/explicit-target-cpu.avr_nocpu.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: target requires explicitly specifying a cpu with `-C target-cpu`

error: aborting due to 1 previous error

37 changes: 37 additions & 0 deletions tests/ui/target-cpu/explicit-target-cpu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! Check that certain target *requires* the user to specify a target CPU via `-C target-cpu`.

//@ revisions: amdgcn_nocpu amdgcn_cpu

//@[amdgcn_nocpu] compile-flags: --target=amdgcn-amd-amdhsa
//@[amdgcn_nocpu] needs-llvm-components: amdgpu
//@[amdgcn_nocpu] build-fail

//@[amdgcn_cpu] compile-flags: --target=amdgcn-amd-amdhsa
//@[amdgcn_cpu] needs-llvm-components: amdgpu
//@[amdgcn_cpu] compile-flags: -Ctarget-cpu=gfx900
//@[amdgcn_cpu] build-pass

//@ revisions: avr_nocpu avr_cpu

//@[avr_nocpu] compile-flags: --target=avr-none
//@[avr_nocpu] needs-llvm-components: avr
//@[avr_nocpu] build-fail

//@[avr_cpu] compile-flags: --target=avr-none
//@[avr_cpu] needs-llvm-components: avr
//@[avr_cpu] compile-flags: -Ctarget-cpu=atmega328p
//@[avr_cpu] build-pass

#![crate_type = "rlib"]

// FIXME(#140038): this can't use `minicore` yet because `minicore` doesn't currently propagate the
// `-C target-cpu` for targets that *require* a `target-cpu` being specified.
#![feature(no_core, lang_items)]
#![no_core]

#[lang="sized"]
trait Sized {}

pub fn foo() {}

//[amdgcn_nocpu,avr_nocpu]~? ERROR target requires explicitly specifying a cpu with `-C target-cpu`
Loading