Auto merge of #143183 - GuillaumeGomez:rollup-g60lr91, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#142078 (Add SIMD funnel shift and round-to-even intrinsics)
 - rust-lang/rust#142214 (`tests/ui`: A New Order [9/N])
 - rust-lang/rust#142417 (`tests/ui`: A New Order [12/N])
 - rust-lang/rust#143030 (Fix suggestion spans inside macros for the `unused_must_use` lint)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-06-29 13:02:15 +00:00
commit 5e749eb66f
52 changed files with 640 additions and 252 deletions

View file

@ -496,7 +496,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
| sym::simd_flog
| sym::simd_flog10
| sym::simd_flog2
| sym::simd_round => {
| sym::simd_round
| sym::simd_round_ties_even => {
intrinsic_args!(fx, args => (a); intrinsic);
if !a.layout().ty.is_simd() {
@ -527,6 +528,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
(sym::simd_flog2, types::F64) => "log2",
(sym::simd_round, types::F32) => "roundf",
(sym::simd_round, types::F64) => "round",
(sym::simd_round_ties_even, types::F32) => "rintf",
(sym::simd_round_ties_even, types::F64) => "rint",
_ => unreachable!("{:?}", intrinsic),
};
fx.lib_call(

View file

@ -780,6 +780,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
sym::simd_fsin => "sin",
sym::simd_fsqrt => "sqrt",
sym::simd_round => "round",
sym::simd_round_ties_even => "rint",
sym::simd_trunc => "trunc",
_ => return_error!(InvalidMonomorphization::UnrecognizedIntrinsic { span, name }),
};
@ -827,6 +828,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
| sym::simd_fsin
| sym::simd_fsqrt
| sym::simd_round
| sym::simd_round_ties_even
| sym::simd_trunc
) {
return simd_simple_float_intrinsic(name, in_elem, in_ty, in_len, bx, span, args);

View file

@ -1537,6 +1537,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
sym::simd_fsin => "llvm.sin",
sym::simd_fsqrt => "llvm.sqrt",
sym::simd_round => "llvm.round",
sym::simd_round_ties_even => "llvm.rint",
sym::simd_trunc => "llvm.trunc",
_ => return_error!(InvalidMonomorphization::UnrecognizedIntrinsic { span, name }),
};
@ -1563,6 +1564,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
| sym::simd_fsqrt
| sym::simd_relaxed_fma
| sym::simd_round
| sym::simd_round_ties_even
| sym::simd_trunc
) {
return simd_simple_float_intrinsic(name, in_elem, in_ty, in_len, bx, span, args);
@ -2309,7 +2311,13 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
// Unary integer intrinsics
if matches!(
name,
sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_ctpop | sym::simd_cttz
sym::simd_bswap
| sym::simd_bitreverse
| sym::simd_ctlz
| sym::simd_ctpop
| sym::simd_cttz
| sym::simd_funnel_shl
| sym::simd_funnel_shr
) {
let vec_ty = bx.cx.type_vector(
match *in_elem.kind() {
@ -2330,6 +2338,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
sym::simd_ctlz => "llvm.ctlz",
sym::simd_ctpop => "llvm.ctpop",
sym::simd_cttz => "llvm.cttz",
sym::simd_funnel_shl => "llvm.fshl",
sym::simd_funnel_shr => "llvm.fshr",
_ => unreachable!(),
};
let int_size = in_elem.int_size_and_signed(bx.tcx()).0.bits();
@ -2350,6 +2360,11 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
// simple unary argument cases
Ok(bx.call_intrinsic(llvm_intrinsic, &[vec_ty], &[args[0].immediate()]))
}
sym::simd_funnel_shl | sym::simd_funnel_shr => Ok(bx.call_intrinsic(
llvm_intrinsic,
&[vec_ty],
&[args[0].immediate(), args[1].immediate(), args[2].immediate()],
)),
_ => unreachable!(),
};
}

View file

@ -594,8 +594,9 @@ pub(crate) fn check_intrinsic_type(
| sym::simd_ceil
| sym::simd_floor
| sym::simd_round
| sym::simd_round_ties_even
| sym::simd_trunc => (1, 0, vec![param(0)], param(0)),
sym::simd_fma | sym::simd_relaxed_fma => {
sym::simd_fma | sym::simd_relaxed_fma | sym::simd_funnel_shl | sym::simd_funnel_shr => {
(1, 0, vec![param(0), param(0), param(0)], param(0))
}
sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)),

View file

@ -183,6 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
let mut op_warned = false;
if let Some(must_use_op) = must_use_op {
let span = expr.span.find_oldest_ancestor_in_same_ctxt();
cx.emit_span_lint(
UNUSED_MUST_USE,
expr.span,
@ -191,11 +192,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
label: expr.span,
suggestion: if expr_is_from_block {
UnusedOpSuggestion::BlockTailExpr {
before_span: expr.span.shrink_to_lo(),
after_span: expr.span.shrink_to_hi(),
before_span: span.shrink_to_lo(),
after_span: span.shrink_to_hi(),
}
} else {
UnusedOpSuggestion::NormalExpr { span: expr.span.shrink_to_lo() }
UnusedOpSuggestion::NormalExpr { span: span.shrink_to_lo() }
},
},
);
@ -508,9 +509,10 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
);
}
MustUsePath::Def(span, def_id, reason) => {
let span = span.find_oldest_ancestor_in_same_ctxt();
cx.emit_span_lint(
UNUSED_MUST_USE,
*span,
span,
UnusedDef {
pre: descr_pre,
post: descr_post,

View file

@ -1977,6 +1977,8 @@ symbols! {
simd_fmin,
simd_fsin,
simd_fsqrt,
simd_funnel_shl,
simd_funnel_shr,
simd_gather,
simd_ge,
simd_gt,
@ -2004,6 +2006,7 @@ symbols! {
simd_relaxed_fma,
simd_rem,
simd_round,
simd_round_ties_even,
simd_saturating_add,
simd_saturating_sub,
simd_scatter,

View file

@ -126,6 +126,40 @@ pub unsafe fn simd_shl<T>(lhs: T, rhs: T) -> T;
#[rustc_nounwind]
pub unsafe fn simd_shr<T>(lhs: T, rhs: T) -> T;
/// Funnel Shifts vector left elementwise, with UB on overflow.
///
/// Concatenates `a` and `b` elementwise (with `a` in the most significant half),
/// creating a vector of the same length, but with each element being twice as
/// wide. Then shift this vector left elementwise by `shift`, shifting in zeros,
/// and extract the most significant half of each of the elements. If `a` and `b`
/// are the same, this is equivalent to an elementwise rotate left operation.
///
/// `T` must be a vector of integers.
///
/// # Safety
///
/// Each element of `shift` must be less than `<int>::BITS`.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_funnel_shl<T>(a: T, b: T, shift: T) -> T;
/// Funnel Shifts vector right elementwise, with UB on overflow.
///
/// Concatenates `a` and `b` elementwise (with `a` in the most significant half),
/// creating a vector of the same length, but with each element being twice as
/// wide. Then shift this vector right elementwise by `shift`, shifting in zeros,
/// and extract the least significant half of each of the elements. If `a` and `b`
/// are the same, this is equivalent to an elementwise rotate right operation.
///
/// `T` must be a vector of integers.
///
/// # Safety
///
/// Each element of `shift` must be less than `<int>::BITS`.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_funnel_shr<T>(a: T, b: T, shift: T) -> T;
/// "Ands" vectors elementwise.
///
/// `T` must be a vector of integers.
@ -678,6 +712,14 @@ pub unsafe fn simd_floor<T>(x: T) -> T;
#[rustc_nounwind]
pub unsafe fn simd_round<T>(x: T) -> T;
/// Rounds each element to the closest integer-valued float.
/// Ties are resolved by rounding to the number with an even least significant digit
///
/// `T` must be a vector of floats.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_round_ties_even<T>(x: T) -> T;
/// Returns the integer part of each element as an integer-valued float.
/// In other words, non-integer values are truncated towards zero.
///

View file

@ -36,6 +36,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
| "ceil"
| "floor"
| "round"
| "round_ties_even"
| "trunc"
| "fsqrt"
| "fsin"
@ -71,6 +72,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
"ceil" => Op::Round(rustc_apfloat::Round::TowardPositive),
"floor" => Op::Round(rustc_apfloat::Round::TowardNegative),
"round" => Op::Round(rustc_apfloat::Round::NearestTiesToAway),
"round_ties_even" => Op::Round(rustc_apfloat::Round::NearestTiesToEven),
"trunc" => Op::Round(rustc_apfloat::Round::TowardZero),
"ctlz" => Op::Numeric(sym::ctlz),
"ctpop" => Op::Numeric(sym::ctpop),

View file

@ -569,6 +569,10 @@ fn simd_round() {
f32x4::from_array([0.9, 1.001, 2.0, -4.5]).round(),
f32x4::from_array([1.0, 1.0, 2.0, -5.0])
);
assert_eq!(
unsafe { intrinsics::simd_round_ties_even(f32x4::from_array([0.9, 1.001, 2.0, -4.5])) },
f32x4::from_array([1.0, 1.0, 2.0, -4.0])
);
assert_eq!(
f32x4::from_array([0.9, 1.001, 2.0, -4.5]).trunc(),
f32x4::from_array([0.0, 1.0, 2.0, -4.0])
@ -586,6 +590,10 @@ fn simd_round() {
f64x4::from_array([0.9, 1.001, 2.0, -4.5]).round(),
f64x4::from_array([1.0, 1.0, 2.0, -5.0])
);
assert_eq!(
unsafe { intrinsics::simd_round_ties_even(f64x4::from_array([0.9, 1.001, 2.0, -4.5])) },
f64x4::from_array([1.0, 1.0, 2.0, -4.0])
);
assert_eq!(
f64x4::from_array([0.9, 1.001, 2.0, -4.5]).trunc(),
f64x4::from_array([0.0, 1.0, 2.0, -4.0])

View file

@ -1,3 +1,7 @@
//! Check that the default global Rust allocator produces non-null Box allocations for ZSTs.
//!
//! See https://github.com/rust-lang/rust/issues/11998
//@ run-pass
pub fn main() {

View file

@ -0,0 +1,21 @@
//! Regression test for issue #22077
//! lifetime parameters must be constrained in associated type definitions
trait Fun {
type Output;
fn call<'x>(&'x self) -> Self::Output;
}
struct Holder {
x: String,
}
impl<'a> Fun for Holder {
//~^ ERROR E0207
type Output = &'a str;
fn call<'b>(&'b self) -> &'b str {
&self.x[..]
}
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-rps-in-assoc-type.rs:11:6
--> $DIR/unconstrained-lifetime-assoc-type.rs:13:6
|
LL | impl<'a> Fun for Holder {
| ^^ unconstrained lifetime parameter

View file

@ -1,3 +1,5 @@
//! Test that #[inline] attribute cannot be applied to enum variants
enum Foo {
#[inline]
//~^ ERROR attribute should be applied

View file

@ -1,5 +1,5 @@
error[E0518]: attribute should be applied to function or closure
--> $DIR/inline-disallow-on-variant.rs:2:5
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
|
LL | #[inline]
| ^^^^^^^^^

View file

@ -0,0 +1,6 @@
//! Test that #[inline(always)] can be applied to main function
//@ run-pass
#[inline(always)]
fn main() {}

View file

@ -1,8 +0,0 @@
fn assert_sizeof() -> ! {
unsafe {
::std::mem::transmute::<f64, [u8; 8]>(panic!())
//~^ ERROR mismatched types
}
}
fn main() { }

View file

@ -1,10 +0,0 @@
//@ run-pass
#![allow(dead_code)]
#![allow(unreachable_code)]
use std::ops::Add;
fn wsucc<T:Add<Output=T> + Copy>(n: T) -> T { n + { return n } }
pub fn main() { }

View file

@ -1,18 +0,0 @@
// Hide irrelevant E0277 errors (#50333)
trait T {}
struct A;
impl T for A {}
impl A {
fn new() -> Self {
Self {}
}
}
fn main() {
let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
//~^ ERROR mismatched types
let ts: Vec<&dyn T> = vec![&a, &b, &c];
// There is no E0277 error above, as `a`, `b` and `c` are `TyErr`
}

View file

@ -1,5 +0,0 @@
// Since we're not compiling a test runner this function should be elided
// and the build will fail because main doesn't exist
#[test]
fn main() {
} //~ ERROR `main` function not found in crate `elided_test`

View file

@ -1,9 +0,0 @@
error[E0601]: `main` function not found in crate `elided_test`
--> $DIR/elided-test.rs:5:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/elided-test.rs`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0601`.

View file

@ -1,20 +0,0 @@
//@ run-pass
pub fn main() {
if 1 == 2 {
assert!((false));
} else if 2 == 3 {
assert!((false));
} else if 3 == 4 { assert!((false)); } else { assert!((true)); }
if 1 == 2 { assert!((false)); } else if 2 == 2 { assert!((true)); }
if 1 == 2 {
assert!((false));
} else if 2 == 2 {
if 1 == 1 {
assert!((true));
} else { if 2 == 1 { assert!((false)); } else { assert!((false)); } }
}
if 1 == 2 {
assert!((false));
} else { if 1 == 2 { assert!((false)); } else { assert!((true)); } }
}

View file

@ -0,0 +1,19 @@
//! Test early return within binary operation expressions
//@ run-pass
#![allow(dead_code)]
#![allow(unreachable_code)]
use std::ops::Add;
/// Function that performs addition with an early return in the right operand
fn add_with_early_return<T: Add<Output = T> + Copy>(n: T) -> T {
n + { return n }
}
pub fn main() {
// Test with different numeric types to ensure generic behavior works
let _result1 = add_with_early_return(42i32);
let _result2 = add_with_early_return(3.14f64);
}

View file

@ -0,0 +1,32 @@
//! Test for unconstrained type parameters in inherent implementations
struct MyType;
struct MyType1<T>(T);
trait Bar {
type Out;
}
impl<T> MyType {
//~^ ERROR the type parameter `T` is not constrained
// T is completely unused - this should fail
}
impl<T> MyType1<T> {
// OK: T is used in the self type `MyType1<T>`
}
impl<T, U> MyType1<T> {
//~^ ERROR the type parameter `U` is not constrained
// T is used in self type, but U is unconstrained - this should fail
}
impl<T, U> MyType1<T>
where
T: Bar<Out = U>,
{
// OK: T is used in self type, U is constrained through the where clause
}
fn main() {}

View file

@ -1,14 +1,14 @@
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps-inherent.rs:9:6
--> $DIR/unconstrained-type-params-inherent-impl.rs:11:6
|
LL | impl<T> MyType {
| ^ unconstrained type parameter
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps-inherent.rs:17:8
--> $DIR/unconstrained-type-params-inherent-impl.rs:20:9
|
LL | impl<T,U> MyType1<T> {
| ^ unconstrained type parameter
LL | impl<T, U> MyType1<T> {
| ^ unconstrained type parameter
error: aborting due to 2 previous errors

View file

@ -1,18 +0,0 @@
// Test that lifetime parameters must be constrained if they appear in
// an associated type def'n. Issue #22077.
trait Fun {
type Output;
fn call<'x>(&'x self) -> Self::Output;
}
struct Holder { x: String }
impl<'a> Fun for Holder { //~ ERROR E0207
type Output = &'a str;
fn call<'b>(&'b self) -> &'b str {
&self.x[..]
}
}
fn main() { }

View file

@ -1,25 +0,0 @@
struct MyType;
struct MyType1<T>(T);
trait Bar {
type Out;
}
impl<T> MyType {
//~^ ERROR the type parameter `T` is not constrained
}
impl<T> MyType1<T> {
// OK, T is used in `Foo<T>`.
}
impl<T,U> MyType1<T> {
//~^ ERROR the type parameter `U` is not constrained
}
impl<T,U> MyType1<T> where T: Bar<Out=U> {
// OK, T is used in `Foo<T>`.
}
fn main() { }

View file

@ -1,3 +0,0 @@
fn main() {
let _f = 10i32.abs; //~ ERROR attempted to take value of method
}

View file

@ -1,14 +0,0 @@
error[E0615]: attempted to take value of method `abs` on type `i32`
--> $DIR/implicit-method-bind.rs:2:20
|
LL | let _f = 10i32.abs;
| ^^^ method, not a field
|
help: use parentheses to call the method
|
LL | let _f = 10i32.abs();
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.

View file

@ -1,3 +1,5 @@
//! Test that duplicate use bindings in same namespace produce error
mod foo {
pub use self::bar::X;
use self::bar::X;

View file

@ -1,5 +1,5 @@
error[E0252]: the name `X` is defined multiple times
--> $DIR/double-type-import.rs:3:9
--> $DIR/duplicate-use-bindings.rs:5:9
|
LL | pub use self::bar::X;
| ------------ previous import of the type `X` here

View file

@ -1,4 +0,0 @@
//@ run-pass
#[inline(always)]
fn main() {}

View file

@ -0,0 +1,60 @@
// Makes sure the suggestions of the `unused_must_use` lint are not inside
//
// See <https://github.com/rust-lang/rust/issues/143025>
//@ check-pass
//@ run-rustfix
#![expect(unused_macros)]
#![warn(unused_must_use)]
fn main() {
{
macro_rules! cmp {
($a:tt, $b:tt) => {
$a == $b
};
}
// FIXME(Urgau): For some unknown reason the spans we get are not
// recorded to be from any expansions, preventing us from either
// suggesting in front of the macro or not at all.
// cmp!(1, 1);
}
{
macro_rules! cmp {
($a:ident, $b:ident) => {
$a == $b
}; //~^ WARN unused comparison that must be used
}
let a = 1;
let b = 1;
let _ = cmp!(a, b);
//~^ SUGGESTION let _
}
{
macro_rules! cmp {
($a:expr, $b:expr) => {
$a == $b
}; //~^ WARN unused comparison that must be used
}
let _ = cmp!(1, 1);
//~^ SUGGESTION let _
}
{
macro_rules! cmp {
($a:tt, $b:tt) => {
$a.eq(&$b)
};
}
let _ = cmp!(1, 1);
//~^ WARN unused return value
//~| SUGGESTION let _
}
}

View file

@ -0,0 +1,60 @@
// Makes sure the suggestions of the `unused_must_use` lint are not inside
//
// See <https://github.com/rust-lang/rust/issues/143025>
//@ check-pass
//@ run-rustfix
#![expect(unused_macros)]
#![warn(unused_must_use)]
fn main() {
{
macro_rules! cmp {
($a:tt, $b:tt) => {
$a == $b
};
}
// FIXME(Urgau): For some unknown reason the spans we get are not
// recorded to be from any expansions, preventing us from either
// suggesting in front of the macro or not at all.
// cmp!(1, 1);
}
{
macro_rules! cmp {
($a:ident, $b:ident) => {
$a == $b
}; //~^ WARN unused comparison that must be used
}
let a = 1;
let b = 1;
cmp!(a, b);
//~^ SUGGESTION let _
}
{
macro_rules! cmp {
($a:expr, $b:expr) => {
$a == $b
}; //~^ WARN unused comparison that must be used
}
cmp!(1, 1);
//~^ SUGGESTION let _
}
{
macro_rules! cmp {
($a:tt, $b:tt) => {
$a.eq(&$b)
};
}
cmp!(1, 1);
//~^ WARN unused return value
//~| SUGGESTION let _
}
}

View file

@ -0,0 +1,48 @@
warning: unused comparison that must be used
--> $DIR/must-use-macros.rs:28:17
|
LL | $a == $b
| ^^^^^^^^ the comparison produces a value
...
LL | cmp!(a, b);
| ---------- in this macro invocation
|
note: the lint level is defined here
--> $DIR/must-use-macros.rs:9:9
|
LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^
= note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = cmp!(a, b);
| +++++++
warning: unused comparison that must be used
--> $DIR/must-use-macros.rs:41:17
|
LL | $a == $b
| ^^^^^^^^ the comparison produces a value
...
LL | cmp!(1, 1);
| ---------- in this macro invocation
|
= note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = cmp!(1, 1);
| +++++++
warning: unused return value of `std::cmp::PartialEq::eq` that must be used
--> $DIR/must-use-macros.rs:56:9
|
LL | cmp!(1, 1);
| ^^^^^^^^^^
|
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = cmp!(1, 1);
| +++++++
warning: 3 warnings emitted

View file

@ -7,7 +7,10 @@ LL | write!(&mut example, "{}", 42);
= note: this `Result` may be an `Err` variant, which should be handled
= note: `-W unused-must-use` implied by `-W unused`
= help: to override `-W unused` add `#[allow(unused_must_use)]`
= note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = write!(&mut example, "{}", 42);
| +++++++
warning: 1 warning emitted

View file

@ -1,30 +0,0 @@
// Tests to make sure that parens are needed for method calls without arguments.
// outputs text to make sure either an anonymous function is provided or
// open-close '()' parens are given
struct Point {
x: isize,
y: isize
}
impl Point {
fn new() -> Point {
Point{x:0, y:0}
}
fn get_x(&self) -> isize {
self.x
}
}
fn main() {
let point: Point = Point::new();
let px: isize = point
.get_x;//~ ERROR attempted to take value of method `get_x` on type `Point`
// Ensure the span is useful
let ys = &[1,2,3,4,5,6,7];
let a = ys.iter()
.map(|x| x)
.filter(|&&x| x == 1)
.filter_map; //~ ERROR attempted to take value of method `filter_map` on type
}

View file

@ -1,25 +0,0 @@
error[E0615]: attempted to take value of method `get_x` on type `Point`
--> $DIR/method-missing-call.rs:22:26
|
LL | .get_x;
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
LL | .get_x();
| ++
error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-missing-call.rs:27:20: 27:23}>, {closure@$DIR/method-missing-call.rs:28:23: 28:28}>`
--> $DIR/method-missing-call.rs:29:16
|
LL | .filter_map;
| ^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
LL | .filter_map(_);
| +++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0615`.

View file

@ -0,0 +1,33 @@
//! Test taking a method value without parentheses
struct Point {
x: isize,
y: isize,
}
impl Point {
fn new() -> Point {
Point { x: 0, y: 0 }
}
fn get_x(&self) -> isize {
self.x
}
}
fn main() {
// Test with primitive type method
let _f = 10i32.abs; //~ ERROR attempted to take value of method
// Test with custom type method
let point: Point = Point::new();
let px: isize = point.get_x; //~ ERROR attempted to take value of method `get_x` on type `Point`
// Test with method chains - ensure the span is useful
let ys = &[1, 2, 3, 4, 5, 6, 7];
let a = ys
.iter()
.map(|x| x)
.filter(|&&x| x == 1)
.filter_map; //~ ERROR attempted to take value of method `filter_map` on type
}

View file

@ -0,0 +1,36 @@
error[E0615]: attempted to take value of method `abs` on type `i32`
--> $DIR/method-value-without-call.rs:20:20
|
LL | let _f = 10i32.abs;
| ^^^ method, not a field
|
help: use parentheses to call the method
|
LL | let _f = 10i32.abs();
| ++
error[E0615]: attempted to take value of method `get_x` on type `Point`
--> $DIR/method-value-without-call.rs:24:27
|
LL | let px: isize = point.get_x;
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
LL | let px: isize = point.get_x();
| ++
error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-value-without-call.rs:30:14: 30:17}>, {closure@$DIR/method-value-without-call.rs:31:17: 31:22}>`
--> $DIR/method-value-without-call.rs:32:10
|
LL | .filter_map;
| ^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
LL | .filter_map(_);
| +++
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0615`.

View file

@ -0,0 +1,25 @@
//! Regression test for issue #50333: elide irrelevant E0277 errors on tuple mismatch
// Hide irrelevant E0277 errors (#50333)
trait T {}
struct A;
impl T for A {}
impl A {
fn new() -> Self {
Self {}
}
}
fn main() {
// This creates a tuple type mismatch: 2-element tuple destructured into 3 variables
let (a, b, c) = (A::new(), A::new());
//~^ ERROR mismatched types
// This line should NOT produce an E0277 error about `Sized` trait bounds,
// because `a`, `b`, and `c` are `TyErr` due to the mismatch above
let _ts: Vec<&dyn T> = vec![&a, &b, &c];
}

View file

@ -1,7 +1,7 @@
error[E0308]: mismatched types
--> $DIR/elide-errors-on-mismatched-tuple.rs:14:9
--> $DIR/elide-on-tuple-mismatch.rs:19:9
|
LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
LL | let (a, b, c) = (A::new(), A::new());
| ^^^^^^^^^ -------------------- this expression has type `(A, A)`
| |
| expected a tuple with 2 elements, found one with 3 elements

View file

@ -1,3 +1,5 @@
//! Test parsing of multiple references with various whitespace arrangements
//@ run-pass
#![allow(dead_code)]

View file

@ -85,6 +85,9 @@ fn main() {
let r = simd_round(h);
assert_eq!(x, r);
let r = simd_round_ties_even(h);
assert_eq!(z, r);
let r = simd_trunc(h);
assert_eq!(z, r);
}

View file

@ -43,6 +43,10 @@ fn main() {
simd_shl(y, y);
simd_shr(x, x);
simd_shr(y, y);
simd_funnel_shl(x, x, x);
simd_funnel_shl(y, y, y);
simd_funnel_shr(x, x, x);
simd_funnel_shr(y, y, y);
simd_and(x, x);
simd_and(y, y);
simd_or(x, x);
@ -73,6 +77,10 @@ fn main() {
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
simd_shr(0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
simd_funnel_shl(0, 0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
simd_funnel_shr(0, 0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
simd_and(0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
simd_or(0, 0);
@ -95,6 +103,10 @@ fn main() {
//~^ ERROR unsupported operation on `f32x4` with element `f32`
simd_shr(z, z);
//~^ ERROR unsupported operation on `f32x4` with element `f32`
simd_funnel_shl(z, z, z);
//~^ ERROR unsupported operation on `f32x4` with element `f32`
simd_funnel_shr(z, z, z);
//~^ ERROR unsupported operation on `f32x4` with element `f32`
simd_and(z, z);
//~^ ERROR unsupported operation on `f32x4` with element `f32`
simd_or(z, z);

View file

@ -1,147 +1,171 @@
error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:64:9
--> $DIR/generic-arithmetic-2.rs:68:9
|
LL | simd_add(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:66:9
--> $DIR/generic-arithmetic-2.rs:70:9
|
LL | simd_sub(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:68:9
--> $DIR/generic-arithmetic-2.rs:72:9
|
LL | simd_mul(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:70:9
--> $DIR/generic-arithmetic-2.rs:74:9
|
LL | simd_div(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:72:9
--> $DIR/generic-arithmetic-2.rs:76:9
|
LL | simd_shl(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:74:9
--> $DIR/generic-arithmetic-2.rs:78:9
|
LL | simd_shr(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_funnel_shl` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:80:9
|
LL | simd_funnel_shl(0, 0, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_funnel_shr` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:82:9
|
LL | simd_funnel_shr(0, 0, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:76:9
--> $DIR/generic-arithmetic-2.rs:84:9
|
LL | simd_and(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:78:9
--> $DIR/generic-arithmetic-2.rs:86:9
|
LL | simd_or(0, 0);
| ^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:80:9
--> $DIR/generic-arithmetic-2.rs:88:9
|
LL | simd_xor(0, 0);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:83:9
--> $DIR/generic-arithmetic-2.rs:91:9
|
LL | simd_neg(0);
| ^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:85:9
--> $DIR/generic-arithmetic-2.rs:93:9
|
LL | simd_bswap(0);
| ^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:87:9
--> $DIR/generic-arithmetic-2.rs:95:9
|
LL | simd_bitreverse(0);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:89:9
--> $DIR/generic-arithmetic-2.rs:97:9
|
LL | simd_ctlz(0);
| ^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:91:9
--> $DIR/generic-arithmetic-2.rs:99:9
|
LL | simd_cttz(0);
| ^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:94:9
--> $DIR/generic-arithmetic-2.rs:102:9
|
LL | simd_shl(z, z);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:96:9
--> $DIR/generic-arithmetic-2.rs:104:9
|
LL | simd_shr(z, z);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_funnel_shl` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:106:9
|
LL | simd_funnel_shl(z, z, z);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_funnel_shr` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:108:9
|
LL | simd_funnel_shr(z, z, z);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:98:9
--> $DIR/generic-arithmetic-2.rs:110:9
|
LL | simd_and(z, z);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:100:9
--> $DIR/generic-arithmetic-2.rs:112:9
|
LL | simd_or(z, z);
| ^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:102:9
--> $DIR/generic-arithmetic-2.rs:114:9
|
LL | simd_xor(z, z);
| ^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:104:9
--> $DIR/generic-arithmetic-2.rs:116:9
|
LL | simd_bswap(z);
| ^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:106:9
--> $DIR/generic-arithmetic-2.rs:118:9
|
LL | simd_bitreverse(z);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:108:9
--> $DIR/generic-arithmetic-2.rs:120:9
|
LL | simd_ctlz(z);
| ^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:110:9
--> $DIR/generic-arithmetic-2.rs:122:9
|
LL | simd_ctpop(z);
| ^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:112:9
--> $DIR/generic-arithmetic-2.rs:124:9
|
LL | simd_cttz(z);
| ^^^^^^^^^^^^
error: aborting due to 24 previous errors
error: aborting due to 28 previous errors
For more information about this error, try `rustc --explain E0511`.

View file

@ -83,6 +83,80 @@ fn main() {
all_eq!(simd_shr(simd_shl(y1, y2), y2), y1);
all_eq!(simd_shr(simd_shl(y2, y1), y1), y2);
all_eq!(
simd_funnel_shl(x1, x2, x1),
i32x4([
(1 << 1) | (2 >> 31),
(2 << 2) | (3 >> 30),
(3 << 3) | (4 >> 29),
(4 << 4) | (5 >> 28)
])
);
all_eq!(
simd_funnel_shl(x2, x1, x1),
i32x4([
(2 << 1) | (1 >> 31),
(3 << 2) | (2 >> 30),
(4 << 3) | (3 >> 29),
(5 << 4) | (4 >> 28)
])
);
all_eq!(
simd_funnel_shl(y1, y2, y1),
U32::<4>([
(1 << 1) | (2 >> 31),
(2 << 2) | (3 >> 30),
(3 << 3) | (4 >> 29),
(4 << 4) | (5 >> 28)
])
);
all_eq!(
simd_funnel_shl(y2, y1, y1),
U32::<4>([
(2 << 1) | (1 >> 31),
(3 << 2) | (2 >> 30),
(4 << 3) | (3 >> 29),
(5 << 4) | (4 >> 28)
])
);
all_eq!(
simd_funnel_shr(x1, x2, x1),
i32x4([
(1 << 31) | (2 >> 1),
(2 << 30) | (3 >> 2),
(3 << 29) | (4 >> 3),
(4 << 28) | (5 >> 4)
])
);
all_eq!(
simd_funnel_shr(x2, x1, x1),
i32x4([
(2 << 31) | (1 >> 1),
(3 << 30) | (2 >> 2),
(4 << 29) | (3 >> 3),
(5 << 28) | (4 >> 4)
])
);
all_eq!(
simd_funnel_shr(y1, y2, y1),
U32::<4>([
(1 << 31) | (2 >> 1),
(2 << 30) | (3 >> 2),
(3 << 29) | (4 >> 3),
(4 << 28) | (5 >> 4)
])
);
all_eq!(
simd_funnel_shr(y2, y1, y1),
U32::<4>([
(2 << 31) | (1 >> 1),
(3 << 30) | (2 >> 2),
(4 << 29) | (3 >> 3),
(5 << 28) | (4 >> 4)
])
);
// ensure we get logical vs. arithmetic shifts correct
let (a, b, c, d) = (-12, -123, -1234, -12345);
all_eq!(simd_shr(i32x4([a, b, c, d]), x1), i32x4([a >> 1, b >> 2, c >> 3, d >> 4]));

View file

@ -0,0 +1,8 @@
//! Test that #[test] functions are elided when not running tests, causing missing main error
#[test]
fn main() {
// This function would normally serve as main, but since it's marked with #[test],
// it gets elided when not running tests
}
//~^ ERROR `main` function not found in crate `test_function_elided_no_main`

View file

@ -0,0 +1,9 @@
error[E0601]: `main` function not found in crate `test_function_elided_no_main`
--> $DIR/test-function-elided-no-main.rs:7:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/test-function-elided-no-main.rs`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0601`.

View file

@ -1,3 +1,11 @@
//! Comprehensive test for type parameter constraints in trait implementations
//!
//! This tests various scenarios of type parameter usage in trait implementations:
//! - Properly constrained parameters through trait bounds
//! - Unconstrained parameters that should cause compilation errors
//! - Complex constraint scenarios with `where` clauses and associated types
//! - Conflicting implementations detection
trait Foo<A> {
fn get(&self, A: &A) {}
}
@ -7,34 +15,34 @@ trait Bar {
}
impl<T> Foo<T> for [isize; 0] {
// OK, T is used in `Foo<T>`.
// OK: T is used in the trait bound `Foo<T>`
}
impl<T, U> Foo<T> for [isize; 1] {
//~^ ERROR the type parameter `U` is not constrained
// T is constrained by `Foo<T>`, but U is completely unused
}
impl<T, U> Foo<T> for [isize; 2]
where
T: Bar<Out = U>,
{
// OK, `U` is now constrained by the output type parameter.
// OK: T is constrained by `Foo<T>`, U is constrained by the where clause
}
impl<T: Bar<Out = U>, U> Foo<T> for [isize; 3] {
// OK, same as above but written differently.
// OK: Same as above but using bound syntax instead of where clause
}
impl<T, U> Foo<T> for U {
//~^ ERROR conflicting implementations of trait `Foo<_>` for type `[isize; 0]`
// This conflicts with the first impl when U = [isize; 0]
}
impl<T, U> Bar for T {
//~^ ERROR the type parameter `U` is not constrained
type Out = U;
// Using `U` in an associated type within the impl is not good enough!
// Using U only in associated type definition is insufficient for constraint
}
impl<T, U> Bar for T
@ -43,7 +51,7 @@ where
{
//~^^^^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates
//~| ERROR conflicting implementations of trait `Bar`
// This crafty self-referential attempt is still no good.
// Self-referential constraint doesn't properly constrain U
}
impl<T, U, V> Foo<T> for T
@ -53,9 +61,7 @@ where
//~^^^^ ERROR the type parameter `U` is not constrained
//~| ERROR the type parameter `V` is not constrained
//~| ERROR conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]`
// Here, `V` is bound by an output type parameter, but the inputs
// are not themselves constrained.
// V is bound through output type, but U and V are not properly constrained as inputs
}
impl<T, U, V> Foo<(T, U)> for T
@ -63,7 +69,7 @@ where
(T, U): Bar<Out = V>,
{
//~^^^^ ERROR conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]`
// As above, but both T and U ARE constrained.
// Both T and U are constrained through `Foo<(T, U)>`, but creates conflicting impl
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `Foo<_>` for type `[isize; 0]`
--> $DIR/impl-unused-tps.rs:28:1
--> $DIR/constrained-type-params-trait-impl.rs:37:1
|
LL | impl<T> Foo<T> for [isize; 0] {
| ----------------------------- first implementation here
@ -8,7 +8,7 @@ LL | impl<T, U> Foo<T> for U {
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]`
error[E0119]: conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]`
--> $DIR/impl-unused-tps.rs:49:1
--> $DIR/constrained-type-params-trait-impl.rs:57:1
|
LL | impl<T> Foo<T> for [isize; 0] {
| ----------------------------- first implementation here
@ -19,7 +19,7 @@ LL | | (T, U): Bar<Out = V>,
| |_________________________^ conflicting implementation for `[isize; 0]`
error[E0119]: conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]`
--> $DIR/impl-unused-tps.rs:61:1
--> $DIR/constrained-type-params-trait-impl.rs:67:1
|
LL | impl<T> Foo<T> for [isize; 0] {
| ----------------------------- first implementation here
@ -30,37 +30,37 @@ LL | | (T, U): Bar<Out = V>,
| |_________________________^ conflicting implementation for `[isize; 0]`
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps.rs:13:9
--> $DIR/constrained-type-params-trait-impl.rs:21:9
|
LL | impl<T, U> Foo<T> for [isize; 1] {
| ^ unconstrained type parameter
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps.rs:32:9
--> $DIR/constrained-type-params-trait-impl.rs:42:9
|
LL | impl<T, U> Bar for T {
| ^ unconstrained type parameter
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps.rs:40:9
--> $DIR/constrained-type-params-trait-impl.rs:48:9
|
LL | impl<T, U> Bar for T
| ^ unconstrained type parameter
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps.rs:49:9
--> $DIR/constrained-type-params-trait-impl.rs:57:9
|
LL | impl<T, U, V> Foo<T> for T
| ^ unconstrained type parameter
error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-unused-tps.rs:49:12
--> $DIR/constrained-type-params-trait-impl.rs:57:12
|
LL | impl<T, U, V> Foo<T> for T
| ^ unconstrained type parameter
error[E0119]: conflicting implementations of trait `Bar`
--> $DIR/impl-unused-tps.rs:40:1
--> $DIR/constrained-type-params-trait-impl.rs:48:1
|
LL | impl<T, U> Bar for T {
| -------------------- first implementation here

View file

@ -0,0 +1,10 @@
//! Regression test for issue #35849: transmute with panic in diverging function
fn assert_sizeof() -> ! {
unsafe {
::std::mem::transmute::<f64, [u8; 8]>(panic!())
//~^ ERROR mismatched types
}
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/diverging-fn-tail-35849.rs:3:9
--> $DIR/diverging-fn-transmute.rs:5:9
|
LL | fn assert_sizeof() -> ! {
| - expected `!` because of return type