1
Fork 0

fix library and rustdoc tests

This commit is contained in:
Deadbeef 2023-04-16 11:12:37 +00:00
parent 147e850691
commit 4c6ddc036b
108 changed files with 841 additions and 444 deletions

View file

@ -1,13 +1,16 @@
// Test const functions in the library // Test const functions in the library
pub const MY_VEC: Vec<usize> = Vec::new(); pub const MY_VEC: Vec<usize> = Vec::new();
pub const MY_VEC2: Vec<usize> = Default::default();
// FIXME(#110395)
// pub const MY_VEC2: Vec<usize> = Default::default();
pub const MY_STRING: String = String::new(); pub const MY_STRING: String = String::new();
pub const MY_STRING2: String = Default::default();
pub const MY_BOXED_SLICE: Box<[usize]> = Default::default(); // pub const MY_STRING2: String = Default::default();
pub const MY_BOXED_STR: Box<str> = Default::default();
// pub const MY_BOXED_SLICE: Box<[usize]> = Default::default();
// pub const MY_BOXED_STR: Box<str> = Default::default();
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
@ -23,11 +26,11 @@ pub const SET_IS_EMPTY: bool = SET.is_empty();
#[test] #[test]
fn test_const() { fn test_const() {
assert_eq!(MY_VEC, MY_VEC2); assert_eq!(MY_VEC, /* MY_VEC */ vec![]);
assert_eq!(MY_STRING, MY_STRING2); assert_eq!(MY_STRING, /* MY_STRING2 */ String::default());
assert_eq!(MY_VEC, *MY_BOXED_SLICE); // assert_eq!(MY_VEC, *MY_BOXED_SLICE);
assert_eq!(MY_STRING, *MY_BOXED_STR); // assert_eq!(MY_STRING, *MY_BOXED_STR);
assert_eq!(MAP_LEN, 0); assert_eq!(MAP_LEN, 0);
assert_eq!(SET_LEN, 0); assert_eq!(SET_LEN, 0);

View file

@ -3,7 +3,6 @@
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(btree_drain_filter)] #![feature(btree_drain_filter)]
#![feature(cow_is_borrowed)] #![feature(cow_is_borrowed)]
#![feature(const_convert)]
#![feature(const_cow_is_borrowed)] #![feature(const_cow_is_borrowed)]
#![feature(const_heap)] #![feature(const_heap)]
#![feature(const_mut_refs)] #![feature(const_mut_refs)]
@ -33,7 +32,6 @@
#![feature(slice_partition_dedup)] #![feature(slice_partition_dedup)]
#![feature(string_remove_matches)] #![feature(string_remove_matches)]
#![feature(const_btree_len)] #![feature(const_btree_len)]
#![feature(const_default_impls)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_str_from_utf8)] #![feature(const_str_from_utf8)]
#![feature(panic_update_hook)] #![feature(panic_update_hook)]

View file

@ -306,9 +306,11 @@ fn atomic_compare_exchange() {
ATOMIC.compare_exchange_weak(0, 1, SeqCst, SeqCst).ok(); ATOMIC.compare_exchange_weak(0, 1, SeqCst, SeqCst).ok();
} }
/* FIXME(#110395)
#[test] #[test]
fn atomic_const_from() { fn atomic_const_from() {
const _ATOMIC_U8: AtomicU8 = AtomicU8::from(1); const _ATOMIC_U8: AtomicU8 = AtomicU8::from(1);
const _ATOMIC_BOOL: AtomicBool = AtomicBool::from(true); const _ATOMIC_BOOL: AtomicBool = AtomicBool::from(true);
const _ATOMIC_PTR: AtomicPtr<u32> = AtomicPtr::from(core::ptr::null_mut()); const _ATOMIC_PTR: AtomicPtr<u32> = AtomicPtr::from(core::ptr::null_mut());
} }
*/

View file

@ -89,6 +89,7 @@ fn test_bool_to_option() {
assert_eq!(false.then(|| 0), None); assert_eq!(false.then(|| 0), None);
assert_eq!(true.then(|| 0), Some(0)); assert_eq!(true.then(|| 0), Some(0));
/* FIXME(#110395)
const fn zero() -> i32 { const fn zero() -> i32 {
0 0
} }
@ -102,4 +103,5 @@ fn test_bool_to_option() {
assert_eq!(B, Some(0)); assert_eq!(B, Some(0));
assert_eq!(C, None); assert_eq!(C, None);
assert_eq!(D, Some(0)); assert_eq!(D, Some(0));
*/
} }

View file

@ -468,6 +468,7 @@ fn const_cells() {
const CELL: Cell<i32> = Cell::new(3); const CELL: Cell<i32> = Cell::new(3);
const _: i32 = CELL.into_inner(); const _: i32 = CELL.into_inner();
/* FIXME(#110395)
const UNSAFE_CELL_FROM: UnsafeCell<i32> = UnsafeCell::from(3); const UNSAFE_CELL_FROM: UnsafeCell<i32> = UnsafeCell::from(3);
const _: i32 = UNSAFE_CELL.into_inner(); const _: i32 = UNSAFE_CELL.into_inner();
@ -476,4 +477,5 @@ fn const_cells() {
const CELL_FROM: Cell<i32> = Cell::from(3); const CELL_FROM: Cell<i32> = Cell::from(3);
const _: i32 = CELL.into_inner(); const _: i32 = CELL.into_inner();
*/
} }

View file

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

View file

@ -217,6 +217,7 @@ fn cmp_default() {
assert_eq!(Fool(false), Fool(true)); assert_eq!(Fool(false), Fool(true));
} }
/* FIXME(#110395)
mod const_cmp { mod const_cmp {
use super::*; use super::*;
@ -248,3 +249,4 @@ mod const_cmp {
const _: () = assert!(S(0) < S(1)); const _: () = assert!(S(0) < S(1));
const _: () = assert!(S(1) > S(0)); const _: () = assert!(S(1) > S(0));
} }
*/

View file

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

View file

@ -35,13 +35,14 @@ impl Hasher for MyHasher {
#[test] #[test]
fn test_writer_hasher() { fn test_writer_hasher() {
const fn hash<T: Hash>(t: &T) -> u64 { // FIXME(#110395)
/* const */ fn hash<T: Hash>(t: &T) -> u64 {
let mut s = MyHasher { hash: 0 }; let mut s = MyHasher { hash: 0 };
t.hash(&mut s); t.hash(&mut s);
s.finish() s.finish()
} }
const { /* const {
// FIXME(fee1-dead): assert_eq // FIXME(fee1-dead): assert_eq
assert!(hash(&()) == 0); assert!(hash(&()) == 0);
assert!(hash(&5_u8) == 5); assert!(hash(&5_u8) == 5);
@ -52,7 +53,7 @@ fn test_writer_hasher() {
let s: &str = "a"; let s: &str = "a";
assert!(hash(&s) == 97 + 0xFF); assert!(hash(&s) == 97 + 0xFF);
}; }; */
assert_eq!(hash(&()), 0); assert_eq!(hash(&()), 0);
@ -139,7 +140,8 @@ impl Hash for Custom {
#[test] #[test]
fn test_custom_state() { fn test_custom_state() {
const fn hash<T: Hash>(t: &T) -> u64 { // FIXME(#110395)
/* const */ fn hash<T: Hash>(t: &T) -> u64 {
let mut c = CustomHasher { output: 0 }; let mut c = CustomHasher { output: 0 };
t.hash(&mut c); t.hash(&mut c);
c.finish() c.finish()
@ -147,7 +149,7 @@ fn test_custom_state() {
assert_eq!(hash(&Custom { hash: 5 }), 5); assert_eq!(hash(&Custom { hash: 5 }), 5);
const { assert!(hash(&Custom { hash: 6 }) == 6) }; // const { assert!(hash(&Custom { hash: 6 }) == 6) };
} }
// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten. // FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.

View file

@ -23,6 +23,7 @@ fn hash<T: Hash>(x: &T) -> u64 {
hash_with(SipHasher::new(), x) hash_with(SipHasher::new(), x)
} }
/* FIXME(#110395)
#[test] #[test]
const fn test_const_sip() { const fn test_const_sip() {
let val1 = 0x45; let val1 = 0x45;
@ -36,6 +37,7 @@ const fn test_const_sip() {
assert!(const_hash(&(val1)) != const_hash(&(val2))); assert!(const_hash(&(val1)) != const_hash(&(val2)));
} }
*/
#[test] #[test]
#[allow(unused_must_use)] #[allow(unused_must_use)]

View file

@ -46,11 +46,13 @@ fn unsync_once_cell_drop_empty() {
drop(x); drop(x);
} }
/* FIXME(#110395)
#[test] #[test]
const fn once_cell_const() { const fn once_cell_const() {
let _once_cell: OnceCell<u32> = OnceCell::new(); let _once_cell: OnceCell<u32> = OnceCell::new();
let _once_cell: OnceCell<u32> = OnceCell::from(32); let _once_cell: OnceCell<u32> = OnceCell::from(32);
} }
*/
#[test] #[test]
fn clone() { fn clone() {

View file

@ -8,16 +8,13 @@
#![feature(const_assume)] #![feature(const_assume)]
#![feature(const_align_of_val_raw)] #![feature(const_align_of_val_raw)]
#![feature(const_black_box)] #![feature(const_black_box)]
#![feature(const_bool_to_option)]
#![feature(const_caller_location)] #![feature(const_caller_location)]
#![feature(const_cell_into_inner)] #![feature(const_cell_into_inner)]
#![feature(const_convert)]
#![feature(const_hash)] #![feature(const_hash)]
#![feature(const_heap)] #![feature(const_heap)]
#![feature(const_maybe_uninit_as_mut_ptr)] #![feature(const_maybe_uninit_as_mut_ptr)]
#![feature(const_maybe_uninit_assume_init_read)] #![feature(const_maybe_uninit_assume_init_read)]
#![feature(const_nonnull_new)] #![feature(const_nonnull_new)]
#![feature(const_num_from_num)]
#![feature(const_pointer_byte_offsets)] #![feature(const_pointer_byte_offsets)]
#![feature(const_pointer_is_aligned)] #![feature(const_pointer_is_aligned)]
#![feature(const_ptr_as_ref)] #![feature(const_ptr_as_ref)]

View file

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

View file

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

View file

@ -88,6 +88,7 @@ fn test_and() {
assert_eq!(x.and(Some(2)), None); assert_eq!(x.and(Some(2)), None);
assert_eq!(x.and(None::<isize>), None); assert_eq!(x.and(None::<isize>), None);
/* FIXME(#110395)
const FOO: Option<isize> = Some(1); const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.and(Some(2)); const A: Option<isize> = FOO.and(Some(2));
const B: Option<isize> = FOO.and(None); const B: Option<isize> = FOO.and(None);
@ -99,6 +100,7 @@ fn test_and() {
const D: Option<isize> = BAR.and(None); const D: Option<isize> = BAR.and(None);
assert_eq!(C, None); assert_eq!(C, None);
assert_eq!(D, None); assert_eq!(D, None);
*/
} }
#[test] #[test]
@ -119,6 +121,7 @@ fn test_and_then() {
assert_eq!(x.and_then(plus_one), None); assert_eq!(x.and_then(plus_one), None);
assert_eq!(x.and_then(none), None); assert_eq!(x.and_then(none), None);
/* FIXME(#110395)
const FOO: Option<isize> = Some(1); const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.and_then(plus_one); const A: Option<isize> = FOO.and_then(plus_one);
const B: Option<isize> = FOO.and_then(none); const B: Option<isize> = FOO.and_then(none);
@ -130,6 +133,7 @@ fn test_and_then() {
const D: Option<isize> = BAR.and_then(none); const D: Option<isize> = BAR.and_then(none);
assert_eq!(C, None); assert_eq!(C, None);
assert_eq!(D, None); assert_eq!(D, None);
*/
} }
#[test] #[test]
@ -142,6 +146,7 @@ fn test_or() {
assert_eq!(x.or(Some(2)), Some(2)); assert_eq!(x.or(Some(2)), Some(2));
assert_eq!(x.or(None), None); assert_eq!(x.or(None), None);
/* FIXME(#110395)
const FOO: Option<isize> = Some(1); const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.or(Some(2)); const A: Option<isize> = FOO.or(Some(2));
const B: Option<isize> = FOO.or(None); const B: Option<isize> = FOO.or(None);
@ -153,6 +158,7 @@ fn test_or() {
const D: Option<isize> = BAR.or(None); const D: Option<isize> = BAR.or(None);
assert_eq!(C, Some(2)); assert_eq!(C, Some(2));
assert_eq!(D, None); assert_eq!(D, None);
*/
} }
#[test] #[test]
@ -173,6 +179,7 @@ fn test_or_else() {
assert_eq!(x.or_else(two), Some(2)); assert_eq!(x.or_else(two), Some(2));
assert_eq!(x.or_else(none), None); assert_eq!(x.or_else(none), None);
/* FIXME(#110395)
const FOO: Option<isize> = Some(1); const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.or_else(two); const A: Option<isize> = FOO.or_else(two);
const B: Option<isize> = FOO.or_else(none); const B: Option<isize> = FOO.or_else(none);
@ -184,6 +191,7 @@ fn test_or_else() {
const D: Option<isize> = BAR.or_else(none); const D: Option<isize> = BAR.or_else(none);
assert_eq!(C, Some(2)); assert_eq!(C, Some(2));
assert_eq!(D, None); assert_eq!(D, None);
*/
} }
#[test] #[test]
@ -215,10 +223,12 @@ fn test_unwrap_or() {
let x: Option<isize> = None; let x: Option<isize> = None;
assert_eq!(x.unwrap_or(2), 2); assert_eq!(x.unwrap_or(2), 2);
/* FIXME(#110395)
const A: isize = Some(1).unwrap_or(2); const A: isize = Some(1).unwrap_or(2);
const B: isize = None.unwrap_or(2); const B: isize = None.unwrap_or(2);
assert_eq!(A, 1); assert_eq!(A, 1);
assert_eq!(B, 2); assert_eq!(B, 2);
*/
} }
#[test] #[test]
@ -233,10 +243,12 @@ fn test_unwrap_or_else() {
let x: Option<isize> = None; let x: Option<isize> = None;
assert_eq!(x.unwrap_or_else(two), 2); assert_eq!(x.unwrap_or_else(two), 2);
/* FIXME(#110395)
const A: isize = Some(1).unwrap_or_else(two); const A: isize = Some(1).unwrap_or_else(two);
const B: isize = None.unwrap_or_else(two); const B: isize = None.unwrap_or_else(two);
assert_eq!(A, 1); assert_eq!(A, 1);
assert_eq!(B, 2); assert_eq!(B, 2);
*/
} }
#[test] #[test]
@ -439,14 +451,15 @@ fn option_const() {
const OPTION: Option<usize> = Some(32); const OPTION: Option<usize> = Some(32);
assert_eq!(OPTION, Some(32)); assert_eq!(OPTION, Some(32));
const OPTION_FROM: Option<usize> = Option::from(32); // FIXME(#110395)
assert_eq!(OPTION_FROM, Some(32)); // const OPTION_FROM: Option<usize> = Option::from(32);
// assert_eq!(OPTION_FROM, Some(32));
const REF: Option<&usize> = OPTION.as_ref(); const REF: Option<&usize> = OPTION.as_ref();
assert_eq!(REF, Some(&32)); assert_eq!(REF, Some(&32));
const REF_FROM: Option<&usize> = Option::from(&OPTION); // const REF_FROM: Option<&usize> = Option::from(&OPTION);
assert_eq!(REF_FROM, Some(&32)); // assert_eq!(REF_FROM, Some(&32));
const IS_SOME: bool = OPTION.is_some(); const IS_SOME: bool = OPTION.is_some();
assert!(IS_SOME); assert!(IS_SOME);
@ -474,7 +487,7 @@ const fn option_const_mut() {
None => unreachable!(), None => unreachable!(),
} }
} }
/* FIXME(const-hack)
{ {
let as_mut: Option<&mut usize> = Option::from(&mut option); let as_mut: Option<&mut usize> = Option::from(&mut option);
match as_mut { match as_mut {
@ -482,6 +495,7 @@ const fn option_const_mut() {
None => unreachable!(), None => unreachable!(),
} }
} }
*/
} }
#[test] #[test]

View file

@ -425,14 +425,16 @@ fn duration_const() {
const SECONDS_F32: f32 = Duration::SECOND.as_secs_f32(); const SECONDS_F32: f32 = Duration::SECOND.as_secs_f32();
assert_eq!(SECONDS_F32, 1.0); assert_eq!(SECONDS_F32, 1.0);
const FROM_SECONDS_F32: Duration = Duration::from_secs_f32(1.0); // FIXME(#110395)
assert_eq!(FROM_SECONDS_F32, Duration::SECOND); // const FROM_SECONDS_F32: Duration = Duration::from_secs_f32(1.0);
// assert_eq!(FROM_SECONDS_F32, Duration::SECOND);
const SECONDS_F64: f64 = Duration::SECOND.as_secs_f64(); const SECONDS_F64: f64 = Duration::SECOND.as_secs_f64();
assert_eq!(SECONDS_F64, 1.0); assert_eq!(SECONDS_F64, 1.0);
const FROM_SECONDS_F64: Duration = Duration::from_secs_f64(1.0); // FIXME(#110395)
assert_eq!(FROM_SECONDS_F64, Duration::SECOND); // const FROM_SECONDS_F64: Duration = Duration::from_secs_f64(1.0);
// assert_eq!(FROM_SECONDS_F64, Duration::SECOND);
const MILLIS: u128 = Duration::SECOND.as_millis(); const MILLIS: u128 = Duration::SECOND.as_millis();
assert_eq!(MILLIS, 1_000); assert_eq!(MILLIS, 1_000);
@ -463,6 +465,7 @@ fn duration_const() {
const CHECKED_MUL: Option<Duration> = Duration::SECOND.checked_mul(1); const CHECKED_MUL: Option<Duration> = Duration::SECOND.checked_mul(1);
assert_eq!(CHECKED_MUL, Some(Duration::SECOND)); assert_eq!(CHECKED_MUL, Some(Duration::SECOND));
/* FIXME(#110395)
const MUL_F32: Duration = Duration::SECOND.mul_f32(1.0); const MUL_F32: Duration = Duration::SECOND.mul_f32(1.0);
assert_eq!(MUL_F32, Duration::SECOND); assert_eq!(MUL_F32, Duration::SECOND);
@ -477,6 +480,7 @@ fn duration_const() {
const DIV_F64: Duration = Duration::SECOND.div_f64(1.0); const DIV_F64: Duration = Duration::SECOND.div_f64(1.0);
assert_eq!(DIV_F64, Duration::SECOND); assert_eq!(DIV_F64, Duration::SECOND);
*/
const DIV_DURATION_F32: f32 = Duration::SECOND.div_duration_f32(Duration::SECOND); const DIV_DURATION_F32: f32 = Duration::SECOND.div_duration_f32(Duration::SECOND);
assert_eq!(DIV_DURATION_F32, 1.0); assert_eq!(DIV_DURATION_F32, 1.0);

View file

@ -29,7 +29,7 @@ pub trait Stage {
// //
// @has - '//*[@id="associatedconstant.ARRAY1"]' \ // @has - '//*[@id="associatedconstant.ARRAY1"]' \
// 'const ARRAY1: [u8; { _ }]' // 'const ARRAY1: [u8; { _ }]'
const ARRAY1: [u8; Struct::new(/* ... */) + Self::ABSTRACT * 1_000]; const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)];
// @has - '//*[@id="associatedconstant.VERBOSE"]' \ // @has - '//*[@id="associatedconstant.VERBOSE"]' \
// 'const VERBOSE: [u16; { _ }]' // 'const VERBOSE: [u16; { _ }]'
@ -73,10 +73,14 @@ pub struct Struct { private: () }
impl Struct { impl Struct {
const fn new() -> Self { Self { private: () } } const fn new() -> Self { Self { private: () } }
const fn do_something(self, x: usize) -> usize {
x
} }
}
/* FIXME(const-trait): readd this
impl const std::ops::Add<usize> for Struct { impl const std::ops::Add<usize> for Struct {
type Output = usize; type Output = usize;
fn add(self, _: usize) -> usize { 0 } fn add(self, _: usize) -> usize { 0 }
} }
*/

View file

@ -13,57 +13,57 @@ use std::marker::Destruct;
pub struct S<T>(T); pub struct S<T>(T);
// @!has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' // @!has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const'
// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Clone' // @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn'
// @!has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' // @!has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const'
// @has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Clone' // @has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn'
#[const_trait] #[const_trait]
pub trait Tr<T> { pub trait Tr<T> {
// @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' // @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const'
// @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone' // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn'
// @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' // @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
// @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' // @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn'
fn a<A: ~const Clone + ~const Destruct>() fn a<A: ~const Fn() + ~const Destruct>()
where where
Option<A>: ~const Clone + ~const Destruct, Option<A>: ~const Fn() + ~const Destruct,
{ {
} }
} }
// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' ''
// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Clone' // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn'
// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn'
impl<T: ~const Clone + ~const Destruct> const Tr<T> for T impl<T: ~const Fn() + ~const Destruct> const Tr<T> for T
where where
Option<T>: ~const Clone + ~const Destruct, Option<T>: ~const Fn() + ~const Destruct,
{ {
fn a<A: ~const Clone + ~const Destruct>() fn a<A: ~const Fn() + ~const Destruct>()
where where
Option<A>: ~const Clone + ~const Destruct, Option<A>: ~const Fn() + ~const Destruct,
{ {
} }
} }
// @!has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' // @!has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const'
// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Clone' // @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn'
// @!has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' '~const' // @!has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' '~const'
// @has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' ': Clone' // @has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' ': Fn'
pub const fn foo<F: ~const Clone + ~const Destruct>() pub const fn foo<F: ~const Fn() + ~const Destruct>()
where where
Option<F>: ~const Clone + ~const Destruct, Option<F>: ~const Fn() + ~const Destruct,
{ {
F::a() F::a()
} }
impl<T> S<T> { impl<T> S<T> {
// @!has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' // @!has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const'
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone' // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn'
// @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' // @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const'
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn'
pub const fn foo<B, C: ~const Clone + ~const Destruct>() pub const fn foo<B, C: ~const Fn() + ~const Destruct>()
where where
B: ~const Clone + ~const Destruct, B: ~const Fn() + ~const Destruct,
{ {
B::a() B::a()
} }

View file

@ -1,3 +1,5 @@
// known-bug: #110395
#![feature(generic_const_exprs, adt_const_params, const_trait_impl)] #![feature(generic_const_exprs, adt_const_params, const_trait_impl)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
@ -26,7 +28,6 @@ struct Evaluatable2<const N: usize>;
fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) { fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) {
bar2::<{ std::ops::Add::add(N, N) }>(); bar2::<{ std::ops::Add::add(N, N) }>();
//~^ error: unconstrained generic constant
// FIXME(generic_const_exprs) make this not an error // FIXME(generic_const_exprs) make this not an error
} }

View file

@ -1,10 +1,11 @@
error: unconstrained generic constant error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/unify-op-with-fn-call.rs:28:12 --> $DIR/unify-op-with-fn-call.rs:10:12
| |
LL | bar2::<{ std::ops::Add::add(N, N) }>(); LL | impl const std::ops::Add for Foo {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
= help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:` = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to previous error error: aborting due to previous error

View file

@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | = [0; (i8::MAX + 1u8) as usize]; LL | = [0; (i8::MAX + 1u8) as usize];
| ^^^ expected `i8`, found `u8` | ^^^ expected `i8`, found `u8`
error[E0277]: cannot add `u8` to `i8` in const contexts error[E0277]: cannot add `u8` to `i8`
--> $DIR/const-eval-overflow-3b.rs:16:20 --> $DIR/const-eval-overflow-3b.rs:16:20
| |
LL | = [0; (i8::MAX + 1u8) as usize]; LL | = [0; (i8::MAX + 1u8) as usize];
| ^ no implementation for `i8 + u8` | ^ no implementation for `i8 + u8`
| |
= help: the trait `~const Add<u8>` is not implemented for `i8` = help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`: = help: the following other types implement trait `Add<Rhs>`:
<&'a i8 as Add<i8>> <&'a i8 as Add<i8>>
<&i8 as Add<&i8>> <&i8 as Add<&i8>>

View file

@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | : [u32; (i8::MAX as i8 + 1u8) as usize] LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^^^ expected `i8`, found `u8` | ^^^ expected `i8`, found `u8`
error[E0277]: cannot add `u8` to `i8` in const contexts error[E0277]: cannot add `u8` to `i8`
--> $DIR/const-eval-overflow-4b.rs:9:28 --> $DIR/const-eval-overflow-4b.rs:9:28
| |
LL | : [u32; (i8::MAX as i8 + 1u8) as usize] LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^ no implementation for `i8 + u8` | ^ no implementation for `i8 + u8`
| |
= help: the trait `~const Add<u8>` is not implemented for `i8` = help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`: = help: the following other types implement trait `Add<Rhs>`:
<&'a i8 as Add<i8>> <&'a i8 as Add<i8>>
<&i8 as Add<&i8>> <&i8 as Add<&i8>>

View file

@ -1,6 +1,6 @@
fn main() {} fn main() {}
// unconst and bad, will thus error in miri // unconst and bad, will thus error in miri
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR can't compare const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR pointers cannot
// unconst and bad, will thus error in miri // unconst and bad, will thus error in miri
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR can't compare const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR pointers cannot

View file

@ -1,29 +1,18 @@
error[E0277]: can't compare `*const i32` with `_` in const contexts error: pointers cannot be reliably compared during const eval
--> $DIR/const_raw_ptr_ops.rs:4:43 --> $DIR/const_raw_ptr_ops.rs:4:26
| |
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
| ^^ no implementation for `*const i32 == _` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32` = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
--> $DIR/const_raw_ptr_ops.rs:4:43
|
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
| ^^
error[E0277]: can't compare `*const i32` with `_` in const contexts error: pointers cannot be reliably compared during const eval
--> $DIR/const_raw_ptr_ops.rs:6:44 --> $DIR/const_raw_ptr_ops.rs:6:27
| |
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
| ^^ no implementation for `*const i32 == _` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32` = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
--> $DIR/const_raw_ptr_ops.rs:6:44
|
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
| ^^
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,3 +1,5 @@
// known-bug: #110395
#![feature(const_slice_index)] #![feature(const_slice_index)]
const A: [(); 5] = [(), (), (), (), ()]; const A: [(); 5] = [(), (), (), (), ()];

View file

@ -1,18 +1,11 @@
error[E0080]: evaluation of constant value failed error[E0015]: cannot call non-const fn `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` in constants
--> $SRC_DIR/core/src/slice/index.rs:LL:COL --> $DIR/ub-slice-get-unchecked.rs:9:29
|
= note: overflow executing `unchecked_sub`
|
note: inside `<std::ops::Range<usize> as SliceIndex<[()]>>::get_unchecked`
--> $SRC_DIR/core/src/slice/index.rs:LL:COL
note: inside `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>`
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL
note: inside `B`
--> $DIR/ub-slice-get-unchecked.rs:7:27
| |
LL | const B: &[()] = unsafe { A.get_unchecked(3..1) }; LL | const B: &[()] = unsafe { A.get_unchecked(3..1) };
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0015`.

View file

@ -8,11 +8,33 @@
// Don't promote // Don't promote
const fn nop<T>(x: T) -> T { x } const fn nop<T>(x: T) -> T { x }
// FIXME(const-hack): replace with PartialEq
#[const_trait]
trait MyEq<T> {
fn eq(self, b: T) -> bool;
}
impl const MyEq<bool> for bool {
fn eq(self, b: bool) -> bool {
self == b
}
}
impl const MyEq<NonDet> for bool {
fn eq(self, _: NonDet) -> bool {
true
}
}
const fn eq<A: ~const MyEq<B>, B>(x: A, y: B) -> bool {
x.eq(y)
}
macro_rules! const_assert { macro_rules! const_assert {
($a:expr, $b:expr) => { ($a:expr, $b:expr) => {
{ {
const _: () = assert!($a == $b); const _: () = assert!(eq($a, $b));
assert_eq!(nop($a), nop($b)); assert!(eq(nop($a), nop($b)));
} }
}; };
} }
@ -47,15 +69,6 @@ macro_rules! suite_inner {
#[derive(Debug)] #[derive(Debug)]
struct NonDet; struct NonDet;
impl const PartialEq<NonDet> for bool {
fn eq(&self, _: &NonDet) -> bool {
true
}
fn ne(&self, _: &NonDet) -> bool {
false
}
}
// The result of the `is_sign` methods are not checked for correctness, since LLVM does not // The result of the `is_sign` methods are not checked for correctness, since LLVM does not
// guarantee anything about the signedness of NaNs. See // guarantee anything about the signedness of NaNs. See
// https://github.com/rust-lang/rust/issues/55131. // https://github.com/rust-lang/rust/issues/55131.

View file

@ -7,7 +7,6 @@ const fn f(x: usize) -> usize {
//~| ERROR `for` is not allowed in a `const fn` //~| ERROR `for` is not allowed in a `const fn`
//~| ERROR mutable references are not allowed in constant functions //~| ERROR mutable references are not allowed in constant functions
//~| ERROR cannot call non-const fn //~| ERROR cannot call non-const fn
//~| ERROR the trait bound
sum += i; sum += i;
} }
sum sum

View file

@ -5,7 +5,7 @@ LL | / for i in 0..x {
LL | | LL | |
LL | | LL | |
LL | | LL | |
... | LL | |
LL | | sum += i; LL | | sum += i;
LL | | } LL | | }
| |_____^ | |_____^
@ -33,19 +33,6 @@ LL | for i in 0..x {
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0277]: the trait bound `std::ops::Range<usize>: Iterator` is not satisfied
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^ `std::ops::Range<usize>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<usize>`
note: the trait `Iterator` is implemented for `std::ops::Range<usize>`, but that implementation is not `const`
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^
error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
--> $DIR/const-fn-error.rs:5:14 --> $DIR/const-fn-error.rs:5:14
| |
@ -55,7 +42,7 @@ LL | for i in 0..x {
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 5 previous errors error: aborting due to 4 previous errors
Some errors have detailed explanations: E0015, E0277, E0658. Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`. For more information about an error, try `rustc --explain E0015`.

View file

@ -5,7 +5,6 @@ const _: () = {
for _ in 0..5 {} for _ in 0..5 {}
//~^ error: cannot call //~^ error: cannot call
//~| error: cannot convert //~| error: cannot convert
//~| error: the trait bound
}; };
fn main() {} fn main() {}

View file

@ -9,19 +9,6 @@ note: impl defined here, but it is not `const`
= note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error[E0277]: the trait bound `std::ops::Range<i32>: Iterator` is not satisfied
--> $DIR/const-for.rs:5:14
|
LL | for _ in 0..5 {}
| ^^^^ `std::ops::Range<i32>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<i32>`
note: the trait `Iterator` is implemented for `std::ops::Range<i32>`, but that implementation is not `const`
--> $DIR/const-for.rs:5:14
|
LL | for _ in 0..5 {}
| ^^^^
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
--> $DIR/const-for.rs:5:14 --> $DIR/const-for.rs:5:14
| |
@ -31,7 +18,6 @@ LL | for _ in 0..5 {}
= note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 3 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0015, E0277. For more information about this error, try `rustc --explain E0015`.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
// Demonstrates what's needed to make use of `?` in const contexts. // Demonstrates what's needed to make use of `?` in const contexts.

View file

@ -0,0 +1,20 @@
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
--> $DIR/const-try.rs:15:12
|
LL | impl const FromResidual<Error> for TryMe {
| ^^^^^^^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
--> $DIR/const-try.rs:21:12
|
LL | impl const Try for TryMe {
| ^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 2 previous errors

View file

@ -1,4 +1,4 @@
// run-pass // known-bug: #110395
#![feature(const_type_id)] #![feature(const_type_id)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,76 @@
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/const_cmp_type_id.rs:8:13
|
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
= help: the trait `~const PartialEq` is not implemented for `TypeId`
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/const_cmp_type_id.rs:8:13
|
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constant functions
--> $DIR/const_cmp_type_id.rs:8:13
|
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/const_cmp_type_id.rs:9:13
|
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
= help: the trait `~const PartialEq` is not implemented for `TypeId`
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/const_cmp_type_id.rs:9:13
|
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constant functions
--> $DIR/const_cmp_type_id.rs:9:13
|
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/const_cmp_type_id.rs:10:22
|
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId < TypeId` and `TypeId > TypeId`
|
= help: the trait `~const PartialOrd` is not implemented for `TypeId`
note: the trait `PartialOrd` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/const_cmp_type_id.rs:10:22
|
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constants
--> $DIR/const_cmp_type_id.rs:10:22
|
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![feature(const_fn_trait_ref_impls)] #![feature(const_fn_trait_ref_impls)]
#![feature(fn_traits)] #![feature(fn_traits)]

View file

@ -0,0 +1,15 @@
error[E0635]: unknown feature `const_fn_trait_ref_impls`
--> $DIR/fn_trait_refs.rs:3:12
|
LL | #![feature(const_fn_trait_ref_impls)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0635]: unknown feature `const_cmp`
--> $DIR/fn_trait_refs.rs:8:12
|
LL | #![feature(const_cmp)]
| ^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0635`.

View file

@ -1,6 +1,6 @@
fn id<T>(t: T) -> T { t } fn id<T>(t: T) -> T { t }
fn main() { fn main() {
const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
//~^ ERROR can't compare //~^ ERROR pointers cannot
println!("{}", A); println!("{}", A);
} }

View file

@ -1,16 +1,10 @@
error[E0277]: can't compare `*const ()` with `*const ()` in const contexts error: pointers cannot be reliably compared during const eval
--> $DIR/issue-25826.rs:3:52 --> $DIR/issue-25826.rs:3:30
| |
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
| ^ no implementation for `*const () < *const ()` and `*const () > *const ()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= help: the trait `~const PartialOrd` is not implemented for `*const ()` = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
note: the trait `PartialOrd` is implemented for `*const ()`, but that implementation is not `const`
--> $DIR/issue-25826.rs:3:52
|
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
| ^
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
// //
// This test is complement to the test in issue-73976-polymorphic.rs. // This test is complement to the test in issue-73976-polymorphic.rs.
// In that test we ensure that polymorphic use of type_id and type_name in patterns // In that test we ensure that polymorphic use of type_id and type_name in patterns

View file

@ -0,0 +1,28 @@
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/issue-73976-monomorphic.rs:21:5
|
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
= help: the trait `~const PartialEq` is not implemented for `TypeId`
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/issue-73976-monomorphic.rs:21:5
|
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constant functions
--> $DIR/issue-73976-monomorphic.rs:21:5
|
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.

View file

@ -7,8 +7,9 @@ struct Foo<'a> {
impl<'a> Foo<'a> { impl<'a> Foo<'a> {
const fn spam(&mut self, baz: &mut Vec<u32>) { const fn spam(&mut self, baz: &mut Vec<u32>) {
self.bar[0] = baz.len(); self.bar[0] = baz.len();
//~^ the trait bound `Vec<usize>: ~const Index<_>` is not satisfied //~^ ERROR: cannot call
//~| the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied //~| ERROR: cannot call
//~| ERROR: the trait bound
} }
} }

View file

@ -1,15 +1,10 @@
error[E0277]: the trait bound `Vec<usize>: ~const Index<_>` is not satisfied error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions
--> $DIR/issue-94675.rs:9:9 --> $DIR/issue-94675.rs:9:27
| |
LL | self.bar[0] = baz.len(); LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` | ^^^^^
| |
= help: the trait `~const Index<_>` is not implemented for `Vec<usize>` = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
note: the trait `Index<_>` is implemented for `Vec<usize>`, but that implementation is not `const`
--> $DIR/issue-94675.rs:9:9
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^
error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
--> $DIR/issue-94675.rs:9:9 --> $DIR/issue-94675.rs:9:9
@ -24,6 +19,17 @@ note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that impl
LL | self.bar[0] = baz.len(); LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: aborting due to 2 previous errors error[E0015]: cannot call non-const operator in constant functions
--> $DIR/issue-94675.rs:9:9
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
For more information about this error, try `rustc --explain E0277`. error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,6 +1,6 @@
const fn cmp(x: fn(), y: fn()) -> bool { const fn cmp(x: fn(), y: fn()) -> bool {
unsafe { x == y } unsafe { x == y }
//~^ ERROR can't compare //~^ ERROR pointers cannot
} }
fn main() {} fn main() {}

View file

@ -1,16 +1,10 @@
error[E0277]: can't compare `fn()` with `_` in const contexts error: pointers cannot be reliably compared during const eval
--> $DIR/cmp_fn_pointers.rs:2:16 --> $DIR/cmp_fn_pointers.rs:2:14
| |
LL | unsafe { x == y } LL | unsafe { x == y }
| ^^ no implementation for `fn() == _` | ^^^^^^
| |
= help: the trait `~const PartialEq<_>` is not implemented for `fn()` = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
note: the trait `PartialEq<_>` is implemented for `fn()`, but that implementation is not `const`
--> $DIR/cmp_fn_pointers.rs:2:16
|
LL | unsafe { x == y }
| ^^
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,7 +1,9 @@
#![feature(const_mut_refs)] #![feature(const_mut_refs)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
struct Panic; struct Panic;
impl const Drop for Panic { fn drop(&mut self) { panic!(); } } impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
pub const fn id<T>(x: T) -> T { x } pub const fn id<T>(x: T) -> T { x }
pub const C: () = { pub const C: () = {
let _: &'static _ = &id(&Panic); let _: &'static _ = &id(&Panic);

View file

@ -1,5 +1,5 @@
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:7:26 --> $DIR/promoted_const_call.rs:9:26
| |
LL | let _: &'static _ = &id(&Panic); LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -10,7 +10,7 @@ LL | };
| - temporary value is freed at the end of this statement | - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:7:30 --> $DIR/promoted_const_call.rs:9:30
| |
LL | let _: &'static _ = &id(&Panic); LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^ - temporary value is freed at the end of this statement | ---------- ^^^^^ - temporary value is freed at the end of this statement
@ -19,7 +19,7 @@ LL | let _: &'static _ = &id(&Panic);
| type annotation requires that borrow lasts for `'static` | type annotation requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:13:26 --> $DIR/promoted_const_call.rs:15:26
| |
LL | let _: &'static _ = &id(&Panic); LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -30,7 +30,7 @@ LL | }
| - temporary value is freed at the end of this statement | - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:13:30 --> $DIR/promoted_const_call.rs:15:30
| |
LL | let _: &'static _ = &id(&Panic); LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^ - temporary value is freed at the end of this statement | ---------- ^^^^^ - temporary value is freed at the end of this statement
@ -39,7 +39,7 @@ LL | let _: &'static _ = &id(&Panic);
| type annotation requires that borrow lasts for `'static` | type annotation requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:16:26 --> $DIR/promoted_const_call.rs:18:26
| |
LL | let _: &'static _ = &&(Panic, 0).1; LL | let _: &'static _ = &&(Panic, 0).1;
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -50,7 +50,7 @@ LL | }
| - temporary value is freed at the end of this statement | - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:16:27 --> $DIR/promoted_const_call.rs:18:27
| |
LL | let _: &'static _ = &&(Panic, 0).1; LL | let _: &'static _ = &&(Panic, 0).1;
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(staged_api)] #![feature(staged_api)]

View file

@ -0,0 +1,11 @@
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
--> $DIR/rustc-impl-const-stability.rs:15:12
|
LL | impl const Default for Data {
| ^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to previous error

View file

@ -1,4 +1,4 @@
// run-pass // known-bug: #110395
#![feature(try_trait_v2)] #![feature(try_trait_v2)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,9 @@
error[E0635]: unknown feature `const_convert`
--> $DIR/try-operator.rs:6:12
|
LL | #![feature(const_convert)]
| ^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0635`.

View file

@ -15,13 +15,13 @@ help: Unicode character '' (Minus Sign) looks like '-' (Minus/Hyphen), but it
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻² LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻²
| ~ | ~
error[E0277]: cannot subtract `{integer}` from `{float}` in const contexts error[E0277]: cannot subtract `{integer}` from `{float}`
--> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:1:53 --> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:1:53
| |
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e11; // m³⋅kg⁻¹⋅s⁻² LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e11; // m³⋅kg⁻¹⋅s⁻²
| ^ no implementation for `{float} - {integer}` | ^ no implementation for `{float} - {integer}`
| |
= help: the trait `~const Sub<{integer}>` is not implemented for `{float}` = help: the trait `Sub<{integer}>` is not implemented for `{float}`
= help: the following other types implement trait `Sub<Rhs>`: = help: the following other types implement trait `Sub<Rhs>`:
<&'a f32 as Sub<f32>> <&'a f32 as Sub<f32>>
<&'a f64 as Sub<f64>> <&'a f64 as Sub<f64>>

View file

@ -2,7 +2,7 @@ struct A;
struct B; struct B;
static S: &'static B = &A; static S: &'static B = &A;
//~^ ERROR the trait bound //~^ ERROR cannot perform deref coercion
use std::ops::Deref; use std::ops::Deref;

View file

@ -1,15 +1,24 @@
error[E0277]: the trait bound `A: Deref` is not satisfied error[E0015]: cannot perform deref coercion on `A` in statics
--> $DIR/issue-25901.rs:4:24
|
LL | static S: &'static B = &A;
| ^^ the trait `~const Deref` is not implemented for `A`
|
note: the trait `Deref` is implemented for `A`, but that implementation is not `const`
--> $DIR/issue-25901.rs:4:24 --> $DIR/issue-25901.rs:4:24
| |
LL | static S: &'static B = &A; LL | static S: &'static B = &A;
| ^^ | ^^
|
= note: attempting to deref into `B`
note: deref defined here
--> $DIR/issue-25901.rs:10:5
|
LL | type Target = B;
| ^^^^^^^^^^^
note: impl defined here, but it is not `const`
--> $DIR/issue-25901.rs:9:1
|
LL | impl Deref for A {
| ^^^^^^^^^^^^^^^^
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0015`.

View file

@ -7,13 +7,13 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information = note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable = help: add `#![feature(const_for)]` to the crate attributes to enable
error[E0277]: cannot add `()` to `{integer}` in const contexts error[E0277]: cannot add `()` to `{integer}`
--> $DIR/issue-50582.rs:2:18 --> $DIR/issue-50582.rs:2:18
| |
LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
| ^ no implementation for `{integer} + ()` | ^ no implementation for `{integer} + ()`
| |
= help: the trait `~const Add<()>` is not implemented for `{integer}` = help: the trait `Add<()>` is not implemented for `{integer}`
= help: the following other types implement trait `Add<Rhs>`: = help: the following other types implement trait `Add<Rhs>`:
<&'a f32 as Add<f32>> <&'a f32 as Add<f32>>
<&'a f64 as Add<f64>> <&'a f64 as Add<f64>>

View file

@ -11,5 +11,4 @@ fn main() {
//~| ERROR cannot convert //~| ERROR cannot convert
//~| ERROR mutable references //~| ERROR mutable references
//~| ERROR cannot call //~| ERROR cannot call
//~| ERROR the trait bound
} }

View file

@ -58,19 +58,6 @@ LL | [(); { for _ in 0usize.. {}; 0}];
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0277]: the trait bound `RangeFrom<usize>: Iterator` is not satisfied
--> $DIR/issue-52443.rs:9:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^ `RangeFrom<usize>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `RangeFrom<usize>`
note: the trait `Iterator` is implemented for `RangeFrom<usize>`, but that implementation is not `const`
--> $DIR/issue-52443.rs:9:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^
error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants
--> $DIR/issue-52443.rs:9:21 --> $DIR/issue-52443.rs:9:21
| |
@ -80,7 +67,7 @@ LL | [(); { for _ in 0usize.. {}; 0}];
= note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 7 previous errors; 1 warning emitted error: aborting due to 6 previous errors; 1 warning emitted
Some errors have detailed explanations: E0015, E0277, E0308, E0658. Some errors have detailed explanations: E0015, E0308, E0658.
For more information about an error, try `rustc --explain E0015`. For more information about an error, try `rustc --explain E0015`.

View file

@ -1,3 +1,5 @@
// known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
struct NonConstAdd(i32); struct NonConstAdd(i32);
@ -17,7 +19,6 @@ trait Foo {
impl const Foo for NonConstAdd { impl const Foo for NonConstAdd {
type Bar = NonConstAdd; type Bar = NonConstAdd;
//~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts
} }
#[const_trait] #[const_trait]

View file

@ -1,21 +1,8 @@
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd` in const contexts error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/assoc-type.rs:19:16 --> $DIR/assoc-type.rs:17:22
|
LL | type Bar = NonConstAdd;
| ^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
|
= help: the trait `~const Add` is not implemented for `NonConstAdd`
note: the trait `Add` is implemented for `NonConstAdd`, but that implementation is not `const`
--> $DIR/assoc-type.rs:19:16
|
LL | type Bar = NonConstAdd;
| ^^^^^^^^^^^
note: required by a bound in `Foo::Bar`
--> $DIR/assoc-type.rs:15:15
| |
LL | type Bar: ~const std::ops::Add; LL | type Bar: ~const std::ops::Add;
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar` | ^^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,4 +1,4 @@
// run-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,20 @@
error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/call-const-trait-method-pass.rs:7:12
|
LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/call-const-trait-method-pass.rs:15:12
|
LL | impl const PartialEq for Int {
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 2 previous errors

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#[const_trait] #[const_trait]

View file

@ -0,0 +1,8 @@
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-in-impl.rs:9:16
|
LL | impl<T: ~const PartialEq> const MyPartialEq for T {
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -1,6 +1,6 @@
//! Basic test for calling methods on generic type parameters in `const fn`. //! Basic test for calling methods on generic type parameters in `const fn`.
// check-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,23 @@
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/call-generic-method-chain.rs:9:12
|
LL | impl const PartialEq for S {
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-chain.rs:18:32
|
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-chain.rs:22:40
|
LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,23 @@
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/call-generic-method-dup-bound.rs:7:12
|
LL | impl const PartialEq for S {
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-dup-bound.rs:18:44
|
LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-dup-bound.rs:25:37
|
LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
| ^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -1,8 +1,9 @@
// known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
pub const fn equals_self<T: PartialEq>(t: &T) -> bool { pub const fn equals_self<T: PartialEq>(t: &T) -> bool {
*t == *t *t == *t
//~^ ERROR can't compare // (remove this) ~^ ERROR can't compare
} }
fn main() {} fn main() {}

View file

@ -1,15 +1,28 @@
error[E0277]: can't compare `T` with `_` in const contexts error[E0277]: can't compare `T` with `T` in const contexts
--> $DIR/call-generic-method-fail.rs:4:8 --> $DIR/call-generic-method-fail.rs:5:5
| |
LL | *t == *t LL | *t == *t
| ^^ no implementation for `T == _` | ^^^^^^^^ no implementation for `T == T`
| |
note: the trait `PartialEq<_>` is implemented for `T`, but that implementation is not `const` note: the trait `PartialEq` is implemented for `T`, but that implementation is not `const`
--> $DIR/call-generic-method-fail.rs:4:8 --> $DIR/call-generic-method-fail.rs:5:5
| |
LL | *t == *t LL | *t == *t
| ^^ | ^^^^^^^^
error: aborting due to previous error error[E0015]: cannot call non-const operator in constant functions
--> $DIR/call-generic-method-fail.rs:5:5
|
LL | *t == *t
| ^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: consider further restricting this bound
|
LL | pub const fn equals_self<T: PartialEq + ~const std::cmp::PartialEq>(t: &T) -> bool {
| ++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0277`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,6 +1,6 @@
//! Basic test for calling methods on generic type parameters in `const fn`. //! Basic test for calling methods on generic type parameters in `const fn`.
// check-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,17 @@
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/call-generic-method-pass.rs:9:12
|
LL | impl const PartialEq for S {
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-pass.rs:18:32
|
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -1,9 +1,10 @@
// known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
pub struct Int(i32); pub struct Int(i32);
impl const std::ops::Add for 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; type Output = Self;
fn add(self, rhs: Self) -> Self { fn add(self, rhs: Self) -> Self {
@ -20,7 +21,6 @@ impl std::ops::Add for Int {
} }
impl const std::ops::Add for Int { impl const std::ops::Add for Int {
//~^ ERROR conflicting implementations of trait
type Output = Self; type Output = Self;
fn add(self, rhs: Self) -> Self { fn add(self, rhs: Self) -> Self {

View file

@ -1,25 +1,20 @@
error[E0117]: only traits defined in the current crate can be implemented for primitive types error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/const-and-non-const-impl.rs:5:1 --> $DIR/const-and-non-const-impl.rs:7:12
| |
LL | impl const std::ops::Add for i32 { LL | impl const std::ops::Add for i32 {
| ^^^^^^^^^^^-------------^^^^^--- | ^^^^^^^^^^^^^
| | | |
| | | `i32` is not defined in the current crate
| | `i32` is not defined in the current crate
| impl doesn't use only types from inside the current crate
| |
= note: define and implement a trait or new type instead = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0119]: conflicting implementations of trait `Add` for type `Int` error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/const-and-non-const-impl.rs:22:1 --> $DIR/const-and-non-const-impl.rs:23:12
| |
LL | impl std::ops::Add for Int {
| -------------------------- first implementation here
...
LL | impl const std::ops::Add for Int { LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` | ^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0117, E0119.
For more information about an error, try `rustc --explain E0117`.

View file

@ -1,3 +1,5 @@
// known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#[const_trait] #[const_trait]
@ -14,6 +16,5 @@ const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
} }
const _: () = assert!(need_const_closure(Tr::a) == 42); const _: () = assert!(need_const_closure(Tr::a) == 42);
//~^ ERROR: the trait bound
fn main() {} fn main() {}

View file

@ -1,11 +1,11 @@
error[E0277]: the trait bound `(): ~const Tr` is not satisfied in `fn(()) -> i32 {<() as Tr>::a}` error[E0277]: the trait bound `(): ~const Tr` is not satisfied in `fn(()) -> i32 {<() as Tr>::a}`
--> $DIR/const-closure-trait-method-fail.rs:16:23 --> $DIR/const-closure-trait-method-fail.rs:18:23
| |
LL | const _: () = assert!(need_const_closure(Tr::a) == 42); LL | const _: () = assert!(need_const_closure(Tr::a) == 42);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()`
| |
note: the trait `Tr` is implemented for `()`, but that implementation is not `const` note: the trait `Tr` is implemented for `()`, but that implementation is not `const`
--> $DIR/const-closure-trait-method-fail.rs:16:23 --> $DIR/const-closure-trait-method-fail.rs:18:23
| |
LL | const _: () = assert!(need_const_closure(Tr::a) == 42); LL | const _: () = assert!(need_const_closure(Tr::a) == 42);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,4 @@
// run-pass // check-pass
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -1,50 +1,26 @@
error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:31:23 --> $DIR/const-drop-fail-2.rs:23:25
| |
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` | ^^^^
| |
note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
--> $DIR/const-drop-fail-2.rs:31:23 = note: adding a non-const method body in the future would be a breaking change
|
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `ConstDropImplWithBounds`
--> $DIR/const-drop-fail-2.rs:21:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail-2.rs:33:5 --> $DIR/const-drop-fail-2.rs:29:26
| |
LL | ConstDropImplWithBounds(PhantomData) LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` | ^^^^^^^^
|
note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail-2.rs:33:5
|
LL | ConstDropImplWithBounds(PhantomData)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `ConstDropImplWithBounds`
--> $DIR/const-drop-fail-2.rs:21:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:39:9 --> $DIR/const-drop-fail-2.rs:39:25
| |
LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
| ^^^^^^^^ | ^^^^
| |
note: the implementor must specify the same requirement = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
--> $DIR/const-drop-fail-2.rs:37:1 = note: adding a non-const method body in the future would be a breaking change
|
LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0367.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,4 +1,4 @@
// revisions: stock precise // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_mut_refs)] #![feature(const_mut_refs)]
#![cfg_attr(precise, feature(const_precise_live_drops))] #![cfg_attr(precise, feature(const_precise_live_drops))]
@ -29,15 +29,12 @@ impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
const fn check<T: ~const Destruct>(_: T) {} const fn check<T: ~const Destruct>(_: T) {}
const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
//~^ ERROR the trait bound
ConstDropImplWithBounds(PhantomData) ConstDropImplWithBounds(PhantomData)
//~^ ERROR the trait bound
); );
struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>);
impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
//~^ ERROR `Drop` impl requires `T: ~const A` but the struct it is implemented for does not
fn drop(&mut self) { fn drop(&mut self) {
T::a(); T::a();
} }

View file

@ -0,0 +1,50 @@
error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied
--> $DIR/const-drop-fail-2.rs:31:23
|
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop`
|
note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail-2.rs:31:23
|
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `ConstDropImplWithBounds`
--> $DIR/const-drop-fail-2.rs:21:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied
--> $DIR/const-drop-fail-2.rs:32:5
|
LL | ConstDropImplWithBounds(PhantomData)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop`
|
note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail-2.rs:32:5
|
LL | ConstDropImplWithBounds(PhantomData)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `ConstDropImplWithBounds`
--> $DIR/const-drop-fail-2.rs:21:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not
--> $DIR/const-drop-fail-2.rs:37:9
|
LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
| ^^^^^^^^
|
note: the implementor must specify the same requirement
--> $DIR/const-drop-fail-2.rs:35:1
|
LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0367.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,50 +1,26 @@
error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:31:23 --> $DIR/const-drop-fail-2.rs:23:25
| |
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` | ^^^^
| |
note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
--> $DIR/const-drop-fail-2.rs:31:23 = note: adding a non-const method body in the future would be a breaking change
|
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `ConstDropImplWithBounds`
--> $DIR/const-drop-fail-2.rs:21:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail-2.rs:33:5 --> $DIR/const-drop-fail-2.rs:29:26
| |
LL | ConstDropImplWithBounds(PhantomData) LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` | ^^^^^^^^
|
note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail-2.rs:33:5
|
LL | ConstDropImplWithBounds(PhantomData)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `ConstDropImplWithBounds`
--> $DIR/const-drop-fail-2.rs:21:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:39:9 --> $DIR/const-drop-fail-2.rs:39:25
| |
LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
| ^^^^^^^^ | ^^^^
| |
note: the implementor must specify the same requirement = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
--> $DIR/const-drop-fail-2.rs:37:1 = note: adding a non-const method body in the future would be a breaking change
|
LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0367.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,5 +1,5 @@
error[E0277]: can't drop `NonTrivialDrop` in const contexts error[E0277]: can't drop `NonTrivialDrop` in const contexts
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop`
@ -11,7 +11,7 @@ LL | | }
| |_- in this macro invocation | |_- in this macro invocation
| |
note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@ -24,7 +24,7 @@ LL | | }
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't drop `NonTrivialDrop` in const contexts error[E0277]: can't drop `NonTrivialDrop` in const contexts
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop`
@ -36,7 +36,7 @@ LL | | }
| |_- in this macro invocation | |_- in this macro invocation
| |
note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@ -47,7 +47,7 @@ LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | } LL | | }
| |_- in this macro invocation | |_- in this macro invocation
note: required because it appears within the type `ConstImplWithDropGlue` note: required because it appears within the type `ConstImplWithDropGlue`
--> $DIR/const-drop-fail.rs:16:8 --> $DIR/const-drop-fail.rs:18:8
| |
LL | struct ConstImplWithDropGlue(NonTrivialDrop); LL | struct ConstImplWithDropGlue(NonTrivialDrop);
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,3 +1,5 @@
// known-bug: #110395
// revisions: stock precise // revisions: stock precise
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_mut_refs)] #![feature(const_mut_refs)]
@ -24,8 +26,6 @@ const fn check<T: ~const Destruct>(_: T) {}
macro_rules! check_all { macro_rules! check_all {
($($exp:expr),*$(,)?) => {$( ($($exp:expr),*$(,)?) => {$(
const _: () = check($exp); const _: () = check($exp);
//~^ ERROR can't drop
//~| ERROR can't drop
)*}; )*};
} }

View file

@ -1,5 +1,5 @@
error[E0277]: can't drop `NonTrivialDrop` in const contexts error[E0277]: can't drop `NonTrivialDrop` in const contexts
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop`
@ -11,7 +11,7 @@ LL | | }
| |_- in this macro invocation | |_- in this macro invocation
| |
note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@ -24,7 +24,7 @@ LL | | }
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't drop `NonTrivialDrop` in const contexts error[E0277]: can't drop `NonTrivialDrop` in const contexts
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop`
@ -36,7 +36,7 @@ LL | | }
| |_- in this macro invocation | |_- in this macro invocation
| |
note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const`
--> $DIR/const-drop-fail.rs:26:23 --> $DIR/const-drop-fail.rs:28:23
| |
LL | const _: () = check($exp); LL | const _: () = check($exp);
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@ -47,7 +47,7 @@ LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | } LL | | }
| |_- in this macro invocation | |_- in this macro invocation
note: required because it appears within the type `ConstImplWithDropGlue` note: required because it appears within the type `ConstImplWithDropGlue`
--> $DIR/const-drop-fail.rs:16:8 --> $DIR/const-drop-fail.rs:18:8
| |
LL | struct ConstImplWithDropGlue(NonTrivialDrop); LL | struct ConstImplWithDropGlue(NonTrivialDrop);
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![feature( #![feature(
associated_type_bounds, associated_type_bounds,

View file

@ -0,0 +1,39 @@
error[E0635]: unknown feature `const_cmp`
--> $DIR/const-impl-trait.rs:6:5
|
LL | const_cmp,
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-impl-trait.rs:12:30
|
LL | const fn cmp(a: &impl ~const PartialEq) -> bool {
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-impl-trait.rs:16:30
|
LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct)
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-impl-trait.rs:17:20
|
LL | -> impl ~const PartialEq + ~const Destruct
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-impl-trait.rs:24:29
|
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy;
| ^^^^^^^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/const-impl-trait.rs:28:29
|
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
| ^^^^^^^^^
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0635`.

View file

@ -1,4 +1,5 @@
#[derive_const(Default)] //~ ERROR use of unstable library feature #[derive_const(Default)] //~ ERROR use of unstable library feature
//~^ ERROR not marked with `#[const_trait]`
pub struct S; pub struct S;
fn main() {} fn main() {}

View file

@ -6,6 +6,16 @@ LL | #[derive_const(Default)]
| |
= help: add `#![feature(derive_const)]` to the crate attributes to enable = help: add `#![feature(derive_const)]` to the crate attributes to enable
error: aborting due to previous error error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
--> $DIR/derive-const-gate.rs:1:16
|
LL | #[derive_const(Default)]
| ^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,3 +1,4 @@
// known-bug: #110395
#![feature(derive_const)] #![feature(derive_const)]
pub struct A; pub struct A;
@ -8,7 +9,5 @@ impl Default for A {
#[derive_const(Default)] #[derive_const(Default)]
pub struct S(A); pub struct S(A);
//~^ cannot call non-const fn
//~| the trait bound
fn main() {} fn main() {}

View file

@ -1,38 +1,12 @@
error[E0277]: the trait bound `A: Default` is not satisfied error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
--> $DIR/derive-const-non-const-type.rs:10:14 --> $DIR/derive-const-non-const-type.rs:10:16
| |
LL | #[derive_const(Default)] LL | #[derive_const(Default)]
| ------- in this derive macro expansion | ^^^^^^^
LL | pub struct S(A);
| ^ the trait `~const Default` is not implemented for `A`
| |
note: the trait `Default` is implemented for `A`, but that implementation is not `const` = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
--> $DIR/derive-const-non-const-type.rs:10:14 = note: adding a non-const method body in the future would be a breaking change
|
LL | #[derive_const(Default)]
| ------- in this derive macro expansion
LL | pub struct S(A);
| ^
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `A` with `#[derive(Default)]`
|
LL + #[derive(Default)]
LL | pub struct A;
|
error[E0015]: cannot call non-const fn `<A as Default>::default` in constant functions
--> $DIR/derive-const-non-const-type.rs:10:14
|
LL | #[derive_const(Default)]
| ------- in this derive macro expansion
LL | pub struct S(A);
| ^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors error: aborting due to previous error
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
pub struct A; pub struct A;

View file

@ -0,0 +1,53 @@
error[E0635]: unknown feature `const_cmp`
--> $DIR/derive-const-use.rs:2:30
|
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
| ^^^^^^^^^
error[E0635]: unknown feature `const_default_impls`
--> $DIR/derive-const-use.rs:2:41
|
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
| ^^^^^^^^^^^^^^^^^^^
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
--> $DIR/derive-const-use.rs:6:12
|
LL | impl const Default for A {
| ^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/derive-const-use.rs:10:12
|
LL | impl const PartialEq for A {
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
--> $DIR/derive-const-use.rs:14:16
|
LL | #[derive_const(Default, PartialEq)]
| ^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/derive-const-use.rs:14:25
|
LL | #[derive_const(Default, PartialEq)]
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0635`.

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![feature(derive_const)] #![feature(derive_const)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,20 @@
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/derive-const-with-params.rs:6:16
|
LL | #[derive_const(PartialEq)]
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/derive-const-with-params.rs:6:16
|
LL | #[derive_const(PartialEq)]
| ^^^^^^^^^
|
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -1,4 +1,4 @@
// run-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,11 @@
error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/generic-bound.rs:16:15
|
LL | impl<T> const std::ops::Add for S<T> {
| ^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to previous error

View file

@ -1,4 +1,4 @@
// check-pass // known-bug: #110395
#![feature(const_trait_impl)] #![feature(const_trait_impl)]

View file

@ -0,0 +1,8 @@
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/non-const-op-in-closure-in-const.rs:10:51
|
LL | impl<A, B> const Convert<B> for A where B: ~const From<A> {
| ^^^^^^^
error: aborting due to previous error

View file

@ -11,13 +11,16 @@ pub trait A {
fn a() -> u32; fn a() -> u32;
} }
impl<T: ~const Default> const A for T { #[const_trait]
pub trait Spec {}
impl<T: ~const Spec> const A for T {
default fn a() -> u32 { default fn a() -> u32 {
2 2
} }
} }
impl<T: Default + Sup> A for T { impl<T: Spec + Sup> A for T {
//~^ ERROR: cannot specialize //~^ ERROR: cannot specialize
//~| ERROR: missing `~const` qualifier //~| ERROR: missing `~const` qualifier
fn a() -> u32 { fn a() -> u32 {

View file

@ -1,14 +1,14 @@
error: cannot specialize on const impl with non-const impl error: cannot specialize on const impl with non-const impl
--> $DIR/specializing-constness.rs:20:1 --> $DIR/specializing-constness.rs:23:1
| |
LL | impl<T: Default + Sup> A for T { LL | impl<T: Spec + Sup> A for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing `~const` qualifier for specialization error: missing `~const` qualifier for specialization
--> $DIR/specializing-constness.rs:20:9 --> $DIR/specializing-constness.rs:23:9
| |
LL | impl<T: Default + Sup> A for T { LL | impl<T: Spec + Sup> A for T {
| ^^^^^^^ | ^^^^
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -0,0 +1,9 @@
error[E0635]: unknown feature `const_default_impls`
--> $DIR/std-impl-gate.rs:6:46
|
LL | #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))]
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0635`.

Some files were not shown because too many files have changed in this diff Show more