Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 15 pull requests #132551

Closed
wants to merge 37 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fead1d5
Add LowerExp and UpperExp implementations
rick-de-water Oct 7, 2024
9fe9041
Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`
eduardosm Oct 22, 2024
720d618
unicode_data.rs: show command for generating file
RalfJung Nov 2, 2024
34432f7
const_with_hasher test: actually construct a usable HashMap
RalfJung Nov 2, 2024
5266623
remove const_hash feature leftovers
RalfJung Nov 2, 2024
8837fc7
make codegen help output more consistent
senekor Nov 2, 2024
afe1902
coverage: Regression test for inlining into an uninstrumented crate
Zalathar Nov 1, 2024
f341a19
NFC add known bug nr to test
matthiaskrgr Nov 2, 2024
b919675
Added regression test for 117446
ranger-ross Nov 2, 2024
82f8b8f
Use opt functions to not ICE in fallback suggestion
compiler-errors Nov 2, 2024
c7b07d5
Rustdoc: added brief colon explanation
zedddie16 Oct 31, 2024
c613122
PassWrapper: adapt for llvm/llvm-project@5445edb5d
durin42 Nov 2, 2024
16394e9
Do not format generic consts
compiler-errors Nov 2, 2024
7745b06
add and update some crashtests
cyrgani Nov 2, 2024
586766e
compiler: Replace rustc_target with _abi in _borrowck
workingjubilee Nov 3, 2024
bb0cd56
compiler: Replace rustc_target with _abi in _hir
workingjubilee Nov 3, 2024
4046e36
compiler: Replace rustc_target with _abi in _trait_selection
workingjubilee Nov 3, 2024
31cbde0
compiler: Add rustc_abi to _monomorphize
workingjubilee Nov 3, 2024
ab6994f
compiler: Add rustc_abi to _sanitizers
workingjubilee Nov 3, 2024
1aae8b9
Register const preds for Deref adjustments in HIR typeck
compiler-errors Nov 3, 2024
721787c
Make sure to enforce ~const DerefMut on mutability fixup
compiler-errors Nov 3, 2024
8ed8f22
Fix minicore, add tests based off of it
compiler-errors Oct 29, 2024
34bd495
Rollup merge of #129329 - eduardosm:rc-from-mut-slice, r=dtolnay
workingjubilee Nov 3, 2024
68920c9
Rollup merge of #131377 - rick-de-water:nonzero-exp, r=dtolnay
workingjubilee Nov 3, 2024
ffc2382
Rollup merge of #132275 - compiler-errors:deref-effects, r=fee1-dead
workingjubilee Nov 3, 2024
b5f7956
Rollup merge of #132393 - zedddie16:issue-131865-fix, r=tgross35
workingjubilee Nov 3, 2024
731cca7
Rollup merge of #132437 - Zalathar:inline-mixed-regression, r=jieyouxu
workingjubilee Nov 3, 2024
cc193c8
Rollup merge of #132499 - RalfJung:unicode_data.rs, r=tgross35
workingjubilee Nov 3, 2024
7700920
Rollup merge of #132503 - RalfJung:const-hash-map, r=Amanieu
workingjubilee Nov 3, 2024
32f785f
Rollup merge of #132520 - matthiaskrgr:knobu, r=jieyouxu
workingjubilee Nov 3, 2024
ff53426
Rollup merge of #132522 - senekor:consistenst-codegen-help, r=compile…
workingjubilee Nov 3, 2024
9f7fb6b
Rollup merge of #132523 - ranger-ross:test-issue-117446, r=compiler-e…
workingjubilee Nov 3, 2024
78cf1b8
Rollup merge of #132528 - compiler-errors:fallback-sugg-opt, r=jieyouxu
workingjubilee Nov 3, 2024
4dd3e5f
Rollup merge of #132537 - durin42:llvm-20-prelinklto, r=DianQK
workingjubilee Nov 3, 2024
881a8fb
Rollup merge of #132540 - compiler-errors:gc, r=calebcartwright
workingjubilee Nov 3, 2024
f04c1d6
Rollup merge of #132543 - cyrgani:master, r=compiler-errors
workingjubilee Nov 3, 2024
eb2185c
Rollup merge of #132550 - workingjubilee:rustc-abi-selects-borrowck-f…
workingjubilee Nov 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix minicore, add tests based off of it
compiler-errors committed Nov 3, 2024
commit 8ed8f22d8d1f844792a4a70b787d182f299202b7
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
//@ known-bug: #110395
//@ failure-status: 101
//@ normalize-stderr-test: ".*note: .*\n\n" -> ""
//@ normalize-stderr-test: "thread 'rustc' panicked.*:\n.*\n" -> ""
//@ rustc-env:RUST_BACKTRACE=0
// FIXME(effects) check-pass
//@ compile-flags: -Znext-solver

#![crate_type = "lib"]
#![feature(no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs, staged_api)]
#![feature(fundamental, marker_trait_attr)]
#![feature(const_trait_impl, effects)]
#![feature(
no_core,
lang_items,
unboxed_closures,
auto_traits,
intrinsics,
rustc_attrs,
fundamental,
marker_trait_attr,
const_trait_impl,
effects
)]
#![allow(internal_features, incomplete_features)]
#![no_std]
#![no_core]
#![stable(feature = "minicore", since = "1.0.0")]

#[lang = "sized"]
trait Sized {}
pub trait Sized {}
#[lang = "copy"]
trait Copy {}
pub trait Copy {}

impl Copy for bool {}
impl Copy for u8 {}
impl<T: ?Sized> Copy for &T {}

#[lang = "add"]
#[const_trait]
trait Add<Rhs = Self> {
pub trait Add<Rhs = Self> {
type Output;

fn add(self, rhs: Rhs) -> Self::Output;
@@ -43,10 +49,9 @@ const fn bar() {
let x = 42_i32 + 43_i32;
}


#[lang = "Try"]
#[const_trait]
trait Try: FromResidual<Self::Residual> {
pub trait Try: FromResidual<Self::Residual> {
type Output;
type Residual;

@@ -57,9 +62,8 @@ trait Try: FromResidual<Self::Residual> {
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
}

// FIXME
// #[const_trait]
trait FromResidual<R = <Self as /* FIXME: ~const */ Try>::Residual> {
#[const_trait]
pub trait FromResidual<R = <Self as Try>::Residual> {
#[lang = "from_residual"]
fn from_residual(residual: R) -> Self;
}
@@ -74,102 +78,59 @@ enum ControlFlow<B, C = ()> {
#[const_trait]
#[lang = "fn"]
#[rustc_paren_sugar]
trait Fn<Args: Tuple>: ~const FnMut<Args> {
pub trait Fn<Args: Tuple>: ~const FnMut<Args> {
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
}

#[const_trait]
#[lang = "fn_mut"]
#[rustc_paren_sugar]
trait FnMut<Args: Tuple>: ~const FnOnce<Args> {
pub trait FnMut<Args: Tuple>: ~const FnOnce<Args> {
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
}

#[const_trait]
#[lang = "fn_once"]
#[rustc_paren_sugar]
trait FnOnce<Args: Tuple> {
pub trait FnOnce<Args: Tuple> {
#[lang = "fn_once_output"]
type Output;

extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}

struct ConstFnMutClosure<CapturedData, Function> {
data: CapturedData,
func: Function,
}

#[lang = "tuple_trait"]
trait Tuple {}

macro_rules! impl_fn_mut_tuple {
($($var:ident)*) => {
impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const
FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
where
Function: ~const Fn(($(&mut $var),*), ClosureArguments) -> ClosureReturnValue,
Function: ~const Destruct,
{
type Output = ClosureReturnValue;

extern "rust-call" fn call_once(mut self, args: ClosureArguments) -> Self::Output {
self.call_mut(args)
}
}
impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const
FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
where
Function: ~const Fn(($(&mut $var),*), ClosureArguments)-> ClosureReturnValue,
Function: ~const Destruct,
{
extern "rust-call" fn call_mut(&mut self, args: ClosureArguments) -> Self::Output {
#[allow(non_snake_case)]
let ($($var),*) = &mut self.data;
(self.func)(($($var),*), args)
}
}
};
}
//impl_fn_mut_tuple!(A);
//impl_fn_mut_tuple!(A B);
//impl_fn_mut_tuple!(A B C);
//impl_fn_mut_tuple!(A B C D);
//impl_fn_mut_tuple!(A B C D E);
pub trait Tuple {}

#[lang = "legacy_receiver"]
trait LegacyReceiver {}
pub trait LegacyReceiver {}

impl<T: ?Sized> LegacyReceiver for &T {}

impl<T: ?Sized> LegacyReceiver for &mut T {}

#[lang = "destruct"]
#[const_trait]
trait Destruct {}
pub trait Destruct {}

#[lang = "freeze"]
unsafe auto trait Freeze {}
pub unsafe auto trait Freeze {}

#[lang = "drop"]
#[const_trait]
trait Drop {
pub trait Drop {
fn drop(&mut self);
}

/*
#[const_trait]
trait Residual<O> {
pub trait Residual<O> {
type TryType: ~const Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>;
}
*/

const fn size_of<T>() -> usize {
42
}

impl Copy for u8 {}

impl usize {
#[rustc_allow_incoherent_impl]
const fn repeat_u8(x: u8) -> usize {
@@ -190,15 +151,14 @@ fn panic_fmt() {}

#[lang = "index"]
#[const_trait]
trait Index<Idx: ?Sized> {
pub trait Index<Idx: ?Sized> {
type Output: ?Sized;

fn index(&self, index: Idx) -> &Self::Output;
}


#[const_trait]
unsafe trait SliceIndex<T: ?Sized> {
pub unsafe trait SliceIndex<T: ?Sized> {
type Output: ?Sized;
fn index(self, slice: &T) -> &Self::Output;
}
@@ -214,51 +174,45 @@ where
index.index(self)
}
}
/* FIXME

impl<T, I, const N: usize> const Index<I> for [T; N]
where
[T]: ~const Index<I>,
{
type Output = <[T] as Index<I>>::Output;

#[inline]
// FIXME: make `Self::Output` act like `<Self as ~const Index<I>>::Output`
fn index(&self, index: I) -> &<[T] as Index<I>>::Output {
Index::index(self as &[T], index)
}
}
*/

#[lang = "unsize"]
trait Unsize<T: ?Sized> {
}
pub trait Unsize<T: ?Sized> {}

#[lang = "coerce_unsized"]
trait CoerceUnsized<T: ?Sized> {
}
pub trait CoerceUnsized<T: ?Sized> {}

impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}


#[lang = "deref"]
// #[const_trait] FIXME
trait Deref {
#[const_trait]
pub trait Deref {
#[lang = "deref_target"]
type Target: ?Sized;

fn deref(&self) -> &Self::Target;
}


impl<T: ?Sized> /* const */ Deref for &T {
impl<T: ?Sized> const Deref for &T {
type Target = T;

fn deref(&self) -> &T {
*self
}
}

impl<T: ?Sized> /* const */ Deref for &mut T {
impl<T: ?Sized> const Deref for &mut T {
type Target = T;

fn deref(&self) -> &T {
@@ -291,7 +245,6 @@ impl<T> Option<T> {

use Option::*;

/*
const fn as_deref<T>(opt: &Option<T>) -> Option<&T::Target>
where
T: ~const Deref,
@@ -301,15 +254,14 @@ where
Option::None => Option::None,
}
}
*/

#[const_trait]
trait Into<T>: Sized {
pub trait Into<T>: Sized {
fn into(self) -> T;
}

#[const_trait]
trait From<T>: Sized {
pub trait From<T>: Sized {
fn from(value: T) -> Self;
}

@@ -344,7 +296,7 @@ fn from_str(s: &str) -> Result<bool, ()> {

#[lang = "eq"]
#[const_trait]
trait PartialEq<Rhs: ?Sized = Self> {
pub trait PartialEq<Rhs: ?Sized = Self> {
fn eq(&self, other: &Rhs) -> bool;
fn ne(&self, other: &Rhs) -> bool {
!self.eq(other)
@@ -366,10 +318,9 @@ impl PartialEq for str {
}
}


#[lang = "not"]
#[const_trait]
trait Not {
pub trait Not {
type Output;
fn not(self) -> Self::Output;
}
@@ -381,9 +332,6 @@ impl const Not for bool {
}
}

impl Copy for bool {}
impl<'a> Copy for &'a str {}

#[lang = "pin"]
#[fundamental]
#[repr(transparent)]
@@ -404,23 +352,21 @@ impl<'a, T: ?Sized> Pin<&'a T> {
}
}


impl<P: Deref> Pin<P> {
/* const */ fn as_ref(&self) -> Pin<&P::Target>
const fn as_ref(&self) -> Pin<&P::Target>
where
P: /* ~const */ Deref,
P: ~const Deref,
{
unsafe { Pin::new_unchecked(&*self.pointer) }
}
}


impl<'a, T: ?Sized> Pin<&'a mut T> {
const unsafe fn get_unchecked_mut(self) -> &'a mut T {
self.pointer
}
}
/* FIXME lol

impl<T> Option<T> {
const fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> {
match Pin::get_ref(self).as_ref() {
@@ -438,16 +384,15 @@ impl<T> Option<T> {
}
}
}
*/

impl<P: /* ~const */ Deref> /* const */ Deref for Pin<P> {
impl<P: ~const Deref> const Deref for Pin<P> {
type Target = P::Target;
fn deref(&self) -> &P::Target {
Pin::get_ref(Pin::as_ref(self))
}
}

impl<T> /* const */ Deref for Option<T> {
impl<T> const Deref for Option<T> {
type Target = T;
fn deref(&self) -> &T {
loop {}
@@ -499,23 +444,22 @@ impl<T: ?Sized> Deref for Ref<'_, T> {

#[lang = "clone"]
#[rustc_trivial_field_reads]
#[const_trait]
trait Clone: Sized {
// FIXME: #[const_trait]
pub trait Clone: Sized {
fn clone(&self) -> Self;
fn clone_from(&mut self, source: &Self)
where
Self: ~const Destruct,
// FIXME: Self: ~const Destruct,
{
*self = source.clone()
}
}

#[lang = "structural_peq"]
trait StructuralPartialEq {}
pub trait StructuralPartialEq {}

const fn drop<T: ~const Destruct>(_: T) {}
// FIXME: const fn drop<T: ~const Destruct>(_: T) {}

#[rustc_const_stable_indirect]
#[rustc_intrinsic_must_be_overridden]
#[rustc_intrinsic]
const fn const_eval_select<ARG: Tuple, F, G, RET>(
@@ -529,10 +473,3 @@ where
{
loop {}
}

fn test_const_eval_select() {
const fn const_fn() {}
fn rt_fn() {}

const_eval_select((), const_fn, rt_fn);
}
21 changes: 21 additions & 0 deletions tests/ui/traits/const-traits/effects/minicore-deref-fail.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ aux-build:minicore.rs
//@ compile-flags: --crate-type=lib -Znext-solver

#![feature(no_core, const_trait_impl, effects)]
//~^ WARN the feature `effects` is incomplete
#![no_std]
#![no_core]

extern crate minicore;
use minicore::*;

struct Ty;
impl Deref for Ty {
type Target = ();
fn deref(&self) -> &Self::Target { &() }
}

const fn foo() {
*Ty;
//~^ ERROR the trait bound `Ty: ~const minicore::Deref` is not satisfied
}
18 changes: 18 additions & 0 deletions tests/ui/traits/const-traits/effects/minicore-deref-fail.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/minicore-deref-fail.rs:4:39
|
LL | #![feature(no_core, const_trait_impl, effects)]
| ^^^^^^^
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default

error[E0277]: the trait bound `Ty: ~const minicore::Deref` is not satisfied
--> $DIR/minicore-deref-fail.rs:19:5
|
LL | *Ty;
| ^^^

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
23 changes: 23 additions & 0 deletions tests/ui/traits/const-traits/effects/minicore-works.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//@ aux-build:minicore.rs
//@ compile-flags: --crate-type=lib -Znext-solver
//@ check-pass

#![feature(no_core)]
#![no_std]
#![no_core]
#![feature(const_trait_impl, effects)]
//~^ WARN the feature `effects` is incomplete and may not be safe

extern crate minicore;
use minicore::*;

struct Custom;
impl const Add for Custom {
type Output = ();
fn add(self, _other: Self) {}
}

const fn test_op() {
let _x = Add::add(1, 2);
let _y = Custom + Custom;
}
11 changes: 11 additions & 0 deletions tests/ui/traits/const-traits/effects/minicore-works.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/minicore-works.rs:8:30
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted

13 changes: 0 additions & 13 deletions tests/ui/traits/const-traits/effects/minicore.stderr

This file was deleted.