forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#98005 - compiler-errors:impossible-bounds, …
…r=Mark-Simulacrum Add some tests for impossible bounds Adds test for rust-lang#93008 Adds test for rust-lang#94680 Closes rust-lang#94999 Closes rust-lang#95640
- Loading branch information
Showing
7 changed files
with
150 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
// compile-flags: -Zmir-opt-level=4 | ||
// build-pass | ||
// compile-flags: -Zmir-opt-level=3 --crate-type=lib | ||
|
||
pub fn bar<T>(s: &'static mut ()) | ||
#![feature(trivial_bounds)] | ||
#![allow(trivial_bounds)] | ||
|
||
trait Foo { | ||
fn test(self); | ||
} | ||
fn baz<T>() | ||
where | ||
&'static mut (): Clone, //~ ERROR the trait bound | ||
&'static str: Foo, | ||
{ | ||
<&'static mut () as Clone>::clone(&s); | ||
"Foo".test() | ||
} | ||
|
||
fn main() {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// check-pass | ||
|
||
fn main() { | ||
println!("{:?}", { | ||
type T = (); | ||
|
||
pub fn cloneit(it: &'_ mut T) -> (&'_ mut T, &'_ mut T) | ||
where | ||
for<'any> &'any mut T: Clone, | ||
{ | ||
(it.clone(), it) | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// check-pass | ||
|
||
trait Identity<Q> { | ||
type T; | ||
} | ||
|
||
impl<Q, T> Identity<Q> for T { | ||
type T = T; | ||
} | ||
|
||
trait Holds { | ||
type Q; | ||
} | ||
|
||
struct S; | ||
struct X(S); | ||
|
||
struct XHelper; | ||
|
||
impl Holds for X { | ||
type Q = XHelper; | ||
} | ||
|
||
impl<Q> Clone for X | ||
where | ||
<S as Identity<Q>>::T: Clone, | ||
X: Holds<Q = Q>, | ||
{ | ||
fn clone(&self) -> Self { | ||
Self(self.0.clone()) | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// build-pass | ||
// compile-flags:-Zmir-opt-level=3 | ||
|
||
struct D; | ||
|
||
trait Tr { | ||
type It; | ||
fn foo(self) -> Option<Self::It>; | ||
} | ||
|
||
impl<'a> Tr for &'a D { | ||
type It = (); | ||
fn foo(self) -> Option<()> { | ||
None | ||
} | ||
} | ||
|
||
fn run<F>(f: F) | ||
where | ||
for<'a> &'a D: Tr, | ||
F: Fn(<&D as Tr>::It), | ||
{ | ||
let d = &D; | ||
while let Some(i) = d.foo() { | ||
f(i); | ||
} | ||
} | ||
|
||
fn main() { | ||
run(|_| {}); | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/ui/trait-bounds/select-param-env-instead-of-blanket.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// known-bug | ||
// build-fail | ||
// failure-status: 101 | ||
// compile-flags:--crate-type=lib -Zmir-opt-level=3 | ||
// rustc-env:RUST_BACKTRACE=0 | ||
|
||
// normalize-stderr-test "thread 'rustc' panicked.*" -> "thread 'rustc' panicked" | ||
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" | ||
// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" | ||
// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" | ||
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" | ||
// normalize-stderr-test "note: compiler flags.*\n\n" -> "" | ||
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" | ||
// normalize-stderr-test "query stack during panic:\n" -> "" | ||
// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" | ||
// normalize-stderr-test "end of query stack\n" -> "" | ||
// normalize-stderr-test "#.*\n" -> "" | ||
|
||
// This is a known bug that @compiler-errors tried to fix in #94238, | ||
// but the solution was probably not correct. | ||
|
||
pub trait Factory<T> { | ||
type Item; | ||
} | ||
|
||
pub struct IntFactory; | ||
|
||
impl<T> Factory<T> for IntFactory { | ||
type Item = usize; | ||
} | ||
|
||
pub fn foo<T>() | ||
where | ||
IntFactory: Factory<T>, | ||
{ | ||
let mut x: <IntFactory as Factory<T>>::Item = bar::<T>(); | ||
} | ||
|
||
#[inline] | ||
pub fn bar<T>() -> <IntFactory as Factory<T>>::Item { | ||
0usize | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/trait-bounds/select-param-env-instead-of-blanket.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error: internal compiler error: no errors encountered even though `delay_span_bug` issued | ||
|
||
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:11 ~ select_param_env_instead_of_blanket[b1a3]::foo), const_param_did: None }) (end of phase transition to Optimized) at bb0[1]: | ||
encountered `Assign((_1, const 0_usize))` with incompatible types: | ||
left-hand side has type: <IntFactory as Factory<T>>::Item | ||
right-hand side has type: usize | ||
--> $DIR/select-param-env-instead-of-blanket.rs:41:5 | ||
| | ||
LL | let mut x: <IntFactory as Factory<T>>::Item = bar::<T>(); | ||
| ---------- in this inlined function call | ||
... | ||
LL | 0usize | ||
| ^^^^^^ | ||
| | ||
= note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:128:36 | ||
|
||
thread 'rustc' panicked | ||
|