Rollup merge of #145057 - ShoyuVanilla:const-trait-tests-cleanup, r=petrochenkov

Clean up some resolved test regressions of const trait removals in std

cc rust-lang/rust#143871
This commit is contained in:
Stuart Cook 2025-08-08 12:52:59 +10:00 committed by GitHub
commit bd7af8a336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 6 additions and 14 deletions

View file

@ -21,7 +21,6 @@ fn test_convert() {
assert!(char::try_from(0xFFFF_FFFF_u32).is_err());
}
/* FIXME(#110395)
#[test]
const fn test_convert_const() {
assert!(u32::from('a') == 0x61);
@ -31,7 +30,6 @@ const fn test_convert_const() {
assert!(char::from(b'a') == 'a');
assert!(char::from(b'\xFF') == '\u{FF}');
}
*/
#[test]
fn test_from_str() {

View file

@ -1,4 +1,3 @@
/* FIXME(#110395)
#[test]
fn convert() {
const fn from(x: i32) -> i32 {
@ -15,4 +14,3 @@ fn convert() {
const BAR: Vec<String> = into(Vec::new());
assert_eq!(BAR, Vec::<String>::new());
}
*/

View file

@ -18,7 +18,9 @@
#![feature(const_deref)]
#![feature(const_destruct)]
#![feature(const_eval_select)]
#![feature(const_from)]
#![feature(const_ops)]
#![feature(const_option_ops)]
#![feature(const_ref_cell)]
#![feature(const_result_trait_fn)]
#![feature(const_trait_impl)]

View file

@ -214,13 +214,11 @@ fn nonzero_const() {
const ONE: Option<NonZero<u8>> = NonZero::new(1);
assert!(ONE.is_some());
/* FIXME(#110395)
const FROM_NONZERO_U8: u8 = u8::from(NONZERO_U8);
assert_eq!(FROM_NONZERO_U8, 5);
const NONZERO_CONVERT: NonZero<u32> = NonZero::<u32>::from(NONZERO_U8);
assert_eq!(NONZERO_CONVERT.get(), 5);
*/
}
#[test]

View file

@ -1,4 +1,3 @@
/* FIXME(#110395)
#[test]
fn from() {
use core::convert::TryFrom;
@ -24,4 +23,3 @@ fn from() {
const I16_FROM_U16: Result<i16, TryFromIntError> = i16::try_from(1u16);
assert_eq!(I16_FROM_U16, Ok(1i16));
}
*/

View file

@ -87,7 +87,6 @@ fn test_and() {
assert_eq!(x.and(Some(2)), None);
assert_eq!(x.and(None::<isize>), None);
/* FIXME(#110395)
const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.and(Some(2));
const B: Option<isize> = FOO.and(None);
@ -99,7 +98,6 @@ fn test_and() {
const D: Option<isize> = BAR.and(None);
assert_eq!(C, None);
assert_eq!(D, None);
*/
}
#[test]

View file

@ -1,10 +1,9 @@
//@ known-bug: #110395
#![feature(const_trait_impl, const_ops)]
pub struct Int(i32);
impl const std::ops::Add for i32 {
//~^ ERROR only traits defined in the current crate can be implemented for primitive types
type Output = Self;
fn add(self, rhs: Self) -> Self {
@ -21,6 +20,7 @@ impl std::ops::Add for Int {
}
impl const std::ops::Add for Int {
//~^ ERROR conflicting implementations of trait
type Output = Self;
fn add(self, rhs: Self) -> Self {

View file

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `Add` for type `Int`
--> $DIR/const-and-non-const-impl.rs:23:1
--> $DIR/const-and-non-const-impl.rs:22:1
|
LL | impl std::ops::Add for Int {
| -------------------------- first implementation here
@ -8,7 +8,7 @@ LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int`
error[E0117]: only traits defined in the current crate can be implemented for primitive types
--> $DIR/const-and-non-const-impl.rs:7:1
--> $DIR/const-and-non-const-impl.rs:5:1
|
LL | impl const std::ops::Add for i32 {
| ^^^^^^^^^^^-------------^^^^^---