From 9a7db566d7b7bb534c5dc3bcfbd2ddd51d99a8d5 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 1 Jul 2025 02:45:14 +0500 Subject: moved tests --- tests/ui/codegen/output-slot-init-vs-noninit.rs | 68 ++++++++++++++++++++++ tests/ui/codegen/remark-flag-functionality.rs | 28 +++++++++ tests/ui/codegen/shift-right-operand-mutation.rs | 12 ++++ tests/ui/codegen/sret-aliasing-rules.rs | 23 ++++++++ tests/ui/macros/macro-paren-span-diagnostic.rs | 21 +++++++ tests/ui/macros/macro-paren-span-diagnostic.stderr | 9 +++ tests/ui/optimization-remark.rs | 28 --------- tests/ui/out-pointer-aliasing.rs | 23 -------- tests/ui/output-slot-variants.rs | 68 ---------------------- tests/ui/over-constrained-vregs.rs | 12 ---- tests/ui/panic-while-printing.rs | 25 -------- tests/ui/panic_implementation-closures.rs | 10 ---- tests/ui/panics/panic-during-display-formatting.rs | 25 ++++++++ tests/ui/panics/panic-handler-closures.rs | 10 ++++ tests/ui/paren-span.rs | 21 ------- tests/ui/paren-span.stderr | 9 --- tests/ui/parser/ufcs-return-unused-parens.fixed | 17 ++++++ tests/ui/parser/ufcs-return-unused-parens.rs | 17 ++++++ tests/ui/parser/ufcs-return-unused-parens.stderr | 19 ++++++ tests/ui/partialeq_help.rs | 12 ---- tests/ui/partialeq_help.stderr | 35 ----------- tests/ui/path-lookahead.fixed | 17 ------ tests/ui/path-lookahead.rs | 17 ------ tests/ui/path-lookahead.stderr | 19 ------ .../ui/traits/partialeq-ref-mismatch-diagnostic.rs | 12 ++++ .../partialeq-ref-mismatch-diagnostic.stderr | 35 +++++++++++ 26 files changed, 296 insertions(+), 296 deletions(-) create mode 100644 tests/ui/codegen/output-slot-init-vs-noninit.rs create mode 100644 tests/ui/codegen/remark-flag-functionality.rs create mode 100644 tests/ui/codegen/shift-right-operand-mutation.rs create mode 100644 tests/ui/codegen/sret-aliasing-rules.rs create mode 100644 tests/ui/macros/macro-paren-span-diagnostic.rs create mode 100644 tests/ui/macros/macro-paren-span-diagnostic.stderr delete mode 100644 tests/ui/optimization-remark.rs delete mode 100644 tests/ui/out-pointer-aliasing.rs delete mode 100644 tests/ui/output-slot-variants.rs delete mode 100644 tests/ui/over-constrained-vregs.rs delete mode 100644 tests/ui/panic-while-printing.rs delete mode 100644 tests/ui/panic_implementation-closures.rs create mode 100644 tests/ui/panics/panic-during-display-formatting.rs create mode 100644 tests/ui/panics/panic-handler-closures.rs delete mode 100644 tests/ui/paren-span.rs delete mode 100644 tests/ui/paren-span.stderr create mode 100644 tests/ui/parser/ufcs-return-unused-parens.fixed create mode 100644 tests/ui/parser/ufcs-return-unused-parens.rs create mode 100644 tests/ui/parser/ufcs-return-unused-parens.stderr delete mode 100644 tests/ui/partialeq_help.rs delete mode 100644 tests/ui/partialeq_help.stderr delete mode 100644 tests/ui/path-lookahead.fixed delete mode 100644 tests/ui/path-lookahead.rs delete mode 100644 tests/ui/path-lookahead.stderr create mode 100644 tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs create mode 100644 tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr diff --git a/tests/ui/codegen/output-slot-init-vs-noninit.rs b/tests/ui/codegen/output-slot-init-vs-noninit.rs new file mode 100644 index 00000000000..97757e74fc4 --- /dev/null +++ b/tests/ui/codegen/output-slot-init-vs-noninit.rs @@ -0,0 +1,68 @@ +//@ run-pass + +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unknown_lints)] + +#![allow(dead_assignment)] +#![allow(unused_variables)] + +struct A { a: isize, b: isize } +struct Abox { a: Box, b: Box } + +fn ret_int_i() -> isize { 10 } + +fn ret_ext_i() -> Box { Box::new(10) } + +fn ret_int_rec() -> A { A {a: 10, b: 10} } + +fn ret_ext_rec() -> Box { Box::new(A {a: 10, b: 10}) } + +fn ret_ext_mem() -> Abox { Abox {a: Box::new(10), b: Box::new(10) } } + +fn ret_ext_ext_mem() -> Box { Box::new(Abox{a: Box::new(10), b: Box::new(10) }) } + +pub fn main() { + let mut int_i: isize; + let mut ext_i: Box; + let mut int_rec: A; + let mut ext_rec: Box; + let mut ext_mem: Abox; + let mut ext_ext_mem: Box; + int_i = ret_int_i(); // initializing + + int_i = ret_int_i(); // non-initializing + + int_i = ret_int_i(); // non-initializing + + ext_i = ret_ext_i(); // initializing + + ext_i = ret_ext_i(); // non-initializing + + ext_i = ret_ext_i(); // non-initializing + + int_rec = ret_int_rec(); // initializing + + int_rec = ret_int_rec(); // non-initializing + + int_rec = ret_int_rec(); // non-initializing + + ext_rec = ret_ext_rec(); // initializing + + ext_rec = ret_ext_rec(); // non-initializing + + ext_rec = ret_ext_rec(); // non-initializing + + ext_mem = ret_ext_mem(); // initializing + + ext_mem = ret_ext_mem(); // non-initializing + + ext_mem = ret_ext_mem(); // non-initializing + + ext_ext_mem = ret_ext_ext_mem(); // initializing + + ext_ext_mem = ret_ext_ext_mem(); // non-initializing + + ext_ext_mem = ret_ext_ext_mem(); // non-initializing + +} diff --git a/tests/ui/codegen/remark-flag-functionality.rs b/tests/ui/codegen/remark-flag-functionality.rs new file mode 100644 index 00000000000..165fc63c007 --- /dev/null +++ b/tests/ui/codegen/remark-flag-functionality.rs @@ -0,0 +1,28 @@ +//@ build-pass +//@ ignore-pass +//@ revisions: all inline merge1 merge2 +//@ compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 +// +// Check that remarks can be enabled individually or with "all": +// +//@ [all] compile-flags: -Cremark=all +//@ [inline] compile-flags: -Cremark=inline +// +// Check that values of -Cremark flag are accumulated: +// +//@ [merge1] compile-flags: -Cremark=all -Cremark=giraffe +//@ [merge2] compile-flags: -Cremark=inline -Cremark=giraffe +//@ dont-check-compiler-stderr +//@ dont-require-annotations: NOTE + +#[no_mangle] +#[inline(never)] +pub fn f() { +} + +#[no_mangle] +pub fn g() { + f(); +} + +//~? NOTE inline (missed): 'f' not inlined into 'g' diff --git a/tests/ui/codegen/shift-right-operand-mutation.rs b/tests/ui/codegen/shift-right-operand-mutation.rs new file mode 100644 index 00000000000..016a667e937 --- /dev/null +++ b/tests/ui/codegen/shift-right-operand-mutation.rs @@ -0,0 +1,12 @@ +//@ run-pass + +#![allow(unused_must_use)] +// Regression test for issue #152. +pub fn main() { + let mut b: usize = 1_usize; + while b < std::mem::size_of::() { + 0_usize << b; + b <<= 1_usize; + println!("{}", b); + } +} diff --git a/tests/ui/codegen/sret-aliasing-rules.rs b/tests/ui/codegen/sret-aliasing-rules.rs new file mode 100644 index 00000000000..0dfaa19fadb --- /dev/null +++ b/tests/ui/codegen/sret-aliasing-rules.rs @@ -0,0 +1,23 @@ +//@ run-pass + +#[derive(Copy, Clone)] +pub struct Foo { + f1: isize, + _f2: isize, +} + +#[inline(never)] +pub fn foo(f: &mut Foo) -> Foo { + let ret = *f; + f.f1 = 0; + ret +} + +pub fn main() { + let mut f = Foo { + f1: 8, + _f2: 9, + }; + f = foo(&mut f); + assert_eq!(f.f1, 8); +} diff --git a/tests/ui/macros/macro-paren-span-diagnostic.rs b/tests/ui/macros/macro-paren-span-diagnostic.rs new file mode 100644 index 00000000000..c8cb63d5190 --- /dev/null +++ b/tests/ui/macros/macro-paren-span-diagnostic.rs @@ -0,0 +1,21 @@ +// Be smart about span of parenthesized expression in macro. + +macro_rules! paren { + ($e:expr) => (($e)) + // ^^^^ do not highlight here +} + +mod m { + pub struct S { + x: i32 + } + pub fn make() -> S { + S { x: 0 } + } +} + +fn main() { + let s = m::make(); + paren!(s.x); //~ ERROR field `x` of struct `S` is private + // ^^^ highlight here +} diff --git a/tests/ui/macros/macro-paren-span-diagnostic.stderr b/tests/ui/macros/macro-paren-span-diagnostic.stderr new file mode 100644 index 00000000000..da2f57033a4 --- /dev/null +++ b/tests/ui/macros/macro-paren-span-diagnostic.stderr @@ -0,0 +1,9 @@ +error[E0616]: field `x` of struct `S` is private + --> $DIR/paren-span.rs:19:14 + | +LL | paren!(s.x); + | ^ private field + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/tests/ui/optimization-remark.rs b/tests/ui/optimization-remark.rs deleted file mode 100644 index 165fc63c007..00000000000 --- a/tests/ui/optimization-remark.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ build-pass -//@ ignore-pass -//@ revisions: all inline merge1 merge2 -//@ compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 -// -// Check that remarks can be enabled individually or with "all": -// -//@ [all] compile-flags: -Cremark=all -//@ [inline] compile-flags: -Cremark=inline -// -// Check that values of -Cremark flag are accumulated: -// -//@ [merge1] compile-flags: -Cremark=all -Cremark=giraffe -//@ [merge2] compile-flags: -Cremark=inline -Cremark=giraffe -//@ dont-check-compiler-stderr -//@ dont-require-annotations: NOTE - -#[no_mangle] -#[inline(never)] -pub fn f() { -} - -#[no_mangle] -pub fn g() { - f(); -} - -//~? NOTE inline (missed): 'f' not inlined into 'g' diff --git a/tests/ui/out-pointer-aliasing.rs b/tests/ui/out-pointer-aliasing.rs deleted file mode 100644 index 0dfaa19fadb..00000000000 --- a/tests/ui/out-pointer-aliasing.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ run-pass - -#[derive(Copy, Clone)] -pub struct Foo { - f1: isize, - _f2: isize, -} - -#[inline(never)] -pub fn foo(f: &mut Foo) -> Foo { - let ret = *f; - f.f1 = 0; - ret -} - -pub fn main() { - let mut f = Foo { - f1: 8, - _f2: 9, - }; - f = foo(&mut f); - assert_eq!(f.f1, 8); -} diff --git a/tests/ui/output-slot-variants.rs b/tests/ui/output-slot-variants.rs deleted file mode 100644 index 97757e74fc4..00000000000 --- a/tests/ui/output-slot-variants.rs +++ /dev/null @@ -1,68 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#![allow(unused_assignments)] -#![allow(unknown_lints)] - -#![allow(dead_assignment)] -#![allow(unused_variables)] - -struct A { a: isize, b: isize } -struct Abox { a: Box, b: Box } - -fn ret_int_i() -> isize { 10 } - -fn ret_ext_i() -> Box { Box::new(10) } - -fn ret_int_rec() -> A { A {a: 10, b: 10} } - -fn ret_ext_rec() -> Box { Box::new(A {a: 10, b: 10}) } - -fn ret_ext_mem() -> Abox { Abox {a: Box::new(10), b: Box::new(10) } } - -fn ret_ext_ext_mem() -> Box { Box::new(Abox{a: Box::new(10), b: Box::new(10) }) } - -pub fn main() { - let mut int_i: isize; - let mut ext_i: Box; - let mut int_rec: A; - let mut ext_rec: Box; - let mut ext_mem: Abox; - let mut ext_ext_mem: Box; - int_i = ret_int_i(); // initializing - - int_i = ret_int_i(); // non-initializing - - int_i = ret_int_i(); // non-initializing - - ext_i = ret_ext_i(); // initializing - - ext_i = ret_ext_i(); // non-initializing - - ext_i = ret_ext_i(); // non-initializing - - int_rec = ret_int_rec(); // initializing - - int_rec = ret_int_rec(); // non-initializing - - int_rec = ret_int_rec(); // non-initializing - - ext_rec = ret_ext_rec(); // initializing - - ext_rec = ret_ext_rec(); // non-initializing - - ext_rec = ret_ext_rec(); // non-initializing - - ext_mem = ret_ext_mem(); // initializing - - ext_mem = ret_ext_mem(); // non-initializing - - ext_mem = ret_ext_mem(); // non-initializing - - ext_ext_mem = ret_ext_ext_mem(); // initializing - - ext_ext_mem = ret_ext_ext_mem(); // non-initializing - - ext_ext_mem = ret_ext_ext_mem(); // non-initializing - -} diff --git a/tests/ui/over-constrained-vregs.rs b/tests/ui/over-constrained-vregs.rs deleted file mode 100644 index 016a667e937..00000000000 --- a/tests/ui/over-constrained-vregs.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass - -#![allow(unused_must_use)] -// Regression test for issue #152. -pub fn main() { - let mut b: usize = 1_usize; - while b < std::mem::size_of::() { - 0_usize << b; - b <<= 1_usize; - println!("{}", b); - } -} diff --git a/tests/ui/panic-while-printing.rs b/tests/ui/panic-while-printing.rs deleted file mode 100644 index 6505a69fef7..00000000000 --- a/tests/ui/panic-while-printing.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass -//@ needs-unwind - -#![feature(internal_output_capture)] - -use std::fmt; -use std::fmt::{Display, Formatter}; -use std::io::set_output_capture; -use std::sync::{Arc, Mutex}; - -pub struct A; - -impl Display for A { - fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result { - panic!(); - } -} - -fn main() { - set_output_capture(Some(Arc::new(Mutex::new(Vec::new())))); - assert!(std::panic::catch_unwind(|| { - eprintln!("{}", A); - }) - .is_err()); -} diff --git a/tests/ui/panic_implementation-closures.rs b/tests/ui/panic_implementation-closures.rs deleted file mode 100644 index b161859bf9c..00000000000 --- a/tests/ui/panic_implementation-closures.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ build-pass (FIXME(62277): could be check-pass?) - -#![crate_type = "rlib"] -#![no_std] - -#[panic_handler] -pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { - |x: u8| x; - loop {} -} diff --git a/tests/ui/panics/panic-during-display-formatting.rs b/tests/ui/panics/panic-during-display-formatting.rs new file mode 100644 index 00000000000..6505a69fef7 --- /dev/null +++ b/tests/ui/panics/panic-during-display-formatting.rs @@ -0,0 +1,25 @@ +//@ run-pass +//@ needs-unwind + +#![feature(internal_output_capture)] + +use std::fmt; +use std::fmt::{Display, Formatter}; +use std::io::set_output_capture; +use std::sync::{Arc, Mutex}; + +pub struct A; + +impl Display for A { + fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result { + panic!(); + } +} + +fn main() { + set_output_capture(Some(Arc::new(Mutex::new(Vec::new())))); + assert!(std::panic::catch_unwind(|| { + eprintln!("{}", A); + }) + .is_err()); +} diff --git a/tests/ui/panics/panic-handler-closures.rs b/tests/ui/panics/panic-handler-closures.rs new file mode 100644 index 00000000000..b161859bf9c --- /dev/null +++ b/tests/ui/panics/panic-handler-closures.rs @@ -0,0 +1,10 @@ +//@ build-pass (FIXME(62277): could be check-pass?) + +#![crate_type = "rlib"] +#![no_std] + +#[panic_handler] +pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { + |x: u8| x; + loop {} +} diff --git a/tests/ui/paren-span.rs b/tests/ui/paren-span.rs deleted file mode 100644 index c8cb63d5190..00000000000 --- a/tests/ui/paren-span.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Be smart about span of parenthesized expression in macro. - -macro_rules! paren { - ($e:expr) => (($e)) - // ^^^^ do not highlight here -} - -mod m { - pub struct S { - x: i32 - } - pub fn make() -> S { - S { x: 0 } - } -} - -fn main() { - let s = m::make(); - paren!(s.x); //~ ERROR field `x` of struct `S` is private - // ^^^ highlight here -} diff --git a/tests/ui/paren-span.stderr b/tests/ui/paren-span.stderr deleted file mode 100644 index da2f57033a4..00000000000 --- a/tests/ui/paren-span.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0616]: field `x` of struct `S` is private - --> $DIR/paren-span.rs:19:14 - | -LL | paren!(s.x); - | ^ private field - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0616`. diff --git a/tests/ui/parser/ufcs-return-unused-parens.fixed b/tests/ui/parser/ufcs-return-unused-parens.fixed new file mode 100644 index 00000000000..440b22edd7d --- /dev/null +++ b/tests/ui/parser/ufcs-return-unused-parens.fixed @@ -0,0 +1,17 @@ +//@ run-pass +//@ run-rustfix + +#![allow(dead_code)] +#![warn(unused_parens)] + +// Parser test for #37765 + +fn with_parens(arg: T) -> String { + return ::to_string(&arg); //~WARN unnecessary parentheses around `return` value +} + +fn no_parens(arg: T) -> String { + return ::to_string(&arg); +} + +fn main() {} diff --git a/tests/ui/parser/ufcs-return-unused-parens.rs b/tests/ui/parser/ufcs-return-unused-parens.rs new file mode 100644 index 00000000000..7eaacd6bba7 --- /dev/null +++ b/tests/ui/parser/ufcs-return-unused-parens.rs @@ -0,0 +1,17 @@ +//@ run-pass +//@ run-rustfix + +#![allow(dead_code)] +#![warn(unused_parens)] + +// Parser test for #37765 + +fn with_parens(arg: T) -> String { + return (::to_string(&arg)); //~WARN unnecessary parentheses around `return` value +} + +fn no_parens(arg: T) -> String { + return ::to_string(&arg); +} + +fn main() {} diff --git a/tests/ui/parser/ufcs-return-unused-parens.stderr b/tests/ui/parser/ufcs-return-unused-parens.stderr new file mode 100644 index 00000000000..2cc786fd947 --- /dev/null +++ b/tests/ui/parser/ufcs-return-unused-parens.stderr @@ -0,0 +1,19 @@ +warning: unnecessary parentheses around `return` value + --> $DIR/path-lookahead.rs:10:12 + | +LL | return (::to_string(&arg)); + | ^ ^ + | +note: the lint level is defined here + --> $DIR/path-lookahead.rs:5:9 + | +LL | #![warn(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - return (::to_string(&arg)); +LL + return ::to_string(&arg); + | + +warning: 1 warning emitted + diff --git a/tests/ui/partialeq_help.rs b/tests/ui/partialeq_help.rs deleted file mode 100644 index 34b88b8a866..00000000000 --- a/tests/ui/partialeq_help.rs +++ /dev/null @@ -1,12 +0,0 @@ -fn foo(a: &T, b: T) { - a == b; //~ ERROR E0277 -} - -fn foo2(a: &T, b: T) where { - a == b; //~ ERROR E0277 -} - -fn main() { - foo(&1, 1); - foo2(&1, 1); -} diff --git a/tests/ui/partialeq_help.stderr b/tests/ui/partialeq_help.stderr deleted file mode 100644 index f5de1308e87..00000000000 --- a/tests/ui/partialeq_help.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0277]: can't compare `&T` with `T` - --> $DIR/partialeq_help.rs:2:7 - | -LL | a == b; - | ^^ no implementation for `&T == T` - | - = help: the trait `PartialEq` is not implemented for `&T` -help: consider dereferencing here - | -LL | *a == b; - | + -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn foo(a: &T, b: T) where &T: PartialEq { - | ++++++++++++++++++++++ - -error[E0277]: can't compare `&T` with `T` - --> $DIR/partialeq_help.rs:6:7 - | -LL | a == b; - | ^^ no implementation for `&T == T` - | - = help: the trait `PartialEq` is not implemented for `&T` -help: consider dereferencing here - | -LL | *a == b; - | + -help: consider extending the `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn foo2(a: &T, b: T) where &T: PartialEq { - | ++++++++++++++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/path-lookahead.fixed b/tests/ui/path-lookahead.fixed deleted file mode 100644 index 440b22edd7d..00000000000 --- a/tests/ui/path-lookahead.fixed +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -//@ run-rustfix - -#![allow(dead_code)] -#![warn(unused_parens)] - -// Parser test for #37765 - -fn with_parens(arg: T) -> String { - return ::to_string(&arg); //~WARN unnecessary parentheses around `return` value -} - -fn no_parens(arg: T) -> String { - return ::to_string(&arg); -} - -fn main() {} diff --git a/tests/ui/path-lookahead.rs b/tests/ui/path-lookahead.rs deleted file mode 100644 index 7eaacd6bba7..00000000000 --- a/tests/ui/path-lookahead.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -//@ run-rustfix - -#![allow(dead_code)] -#![warn(unused_parens)] - -// Parser test for #37765 - -fn with_parens(arg: T) -> String { - return (::to_string(&arg)); //~WARN unnecessary parentheses around `return` value -} - -fn no_parens(arg: T) -> String { - return ::to_string(&arg); -} - -fn main() {} diff --git a/tests/ui/path-lookahead.stderr b/tests/ui/path-lookahead.stderr deleted file mode 100644 index 2cc786fd947..00000000000 --- a/tests/ui/path-lookahead.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: unnecessary parentheses around `return` value - --> $DIR/path-lookahead.rs:10:12 - | -LL | return (::to_string(&arg)); - | ^ ^ - | -note: the lint level is defined here - --> $DIR/path-lookahead.rs:5:9 - | -LL | #![warn(unused_parens)] - | ^^^^^^^^^^^^^ -help: remove these parentheses - | -LL - return (::to_string(&arg)); -LL + return ::to_string(&arg); - | - -warning: 1 warning emitted - diff --git a/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs new file mode 100644 index 00000000000..34b88b8a866 --- /dev/null +++ b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs @@ -0,0 +1,12 @@ +fn foo(a: &T, b: T) { + a == b; //~ ERROR E0277 +} + +fn foo2(a: &T, b: T) where { + a == b; //~ ERROR E0277 +} + +fn main() { + foo(&1, 1); + foo2(&1, 1); +} diff --git a/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr new file mode 100644 index 00000000000..f5de1308e87 --- /dev/null +++ b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr @@ -0,0 +1,35 @@ +error[E0277]: can't compare `&T` with `T` + --> $DIR/partialeq_help.rs:2:7 + | +LL | a == b; + | ^^ no implementation for `&T == T` + | + = help: the trait `PartialEq` is not implemented for `&T` +help: consider dereferencing here + | +LL | *a == b; + | + +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn foo(a: &T, b: T) where &T: PartialEq { + | ++++++++++++++++++++++ + +error[E0277]: can't compare `&T` with `T` + --> $DIR/partialeq_help.rs:6:7 + | +LL | a == b; + | ^^ no implementation for `&T == T` + | + = help: the trait `PartialEq` is not implemented for `&T` +help: consider dereferencing here + | +LL | *a == b; + | + +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn foo2(a: &T, b: T) where &T: PartialEq { + | ++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5