Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions tests/ui/parallel-rustc/assert-found_cycle-issue-115223.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Test for #115223, which causes a deadlock bug without finding the cycle
//@ build-pass
#![crate_name = "foo"]

use std::ops;

pub struct Foo;

impl Foo {
pub fn foo(&mut self) {}
}

pub struct Bar {
foo: Foo,
}

impl ops::Deref for Bar {
type Target = Foo;

fn deref(&self) -> &Foo {
&self.foo
}
}

impl ops::DerefMut for Bar {
fn deref_mut(&mut self) -> &mut Foo {
&mut self.foo
}
}

fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/parallel-rustc/default-trait-shadow-cycle-issue-151358.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Test for #151358, assertion failed: !worker_thread.is_null()
//~^ ERROR cycle detected when looking up span for `Default`
//
//@ compile-flags: -Z threads=2
//@ compare-output-by-lines

trait Default {}
use std::num::NonZero;
fn main() {
NonZero();
todo!();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0391]: cycle detected when looking up span for `Default`
|
= note: ...which immediately requires looking up span for `Default` again
= note: cycle used when perform lints prior to AST lowering
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
127 changes: 127 additions & 0 deletions tests/ui/parallel-rustc/generic-const-exprs-deadlock-issue-120757.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Test for #120757, deadlock due to query cycle

#![feature(generic_const_exprs)]

trait TensorDimension {
const DIM: usize;
const ISSCALAR: bool = Self::DIM == 0;
fn is_scalar(&self) -> bool {
Self::ISSCALAR
}
}

trait TensorSize: TensorDimension {
fn size(&self) -> [usize; Self::DIM];
fn inbounds(&self, index: [usize; Self::DIM]) -> bool {
index.iter().zip(self.size().iter()).all(|(i, s)| i < s)
}
}

trait Broadcastable: TensorSize + Sized {
type Element;
fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>;
fn lazy_updim<const NEWDIM: usize>(
&self,
size: [usize; NEWDIM],
) -> LazyUpdim<Self, { Self::DIM }, NEWDIM> {
assert!(
NEWDIM >= Self::DIM,
"Updimmed tensor cannot have fewer indices than the initial one."
);
LazyUpdim { size, reference: &self }
}
fn bmap<T, F: Fn(Self::Element) -> T>(&self, foo: F) -> BMap<T, Self, F, { Self::DIM }> {
BMap { reference: self, closure: foo }
}
}

struct LazyUpdim<'a, T: Broadcastable, const OLDDIM: usize, const DIM: usize> {
size: [usize; DIM],
reference: &'a T,
}

impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T, { T::DIM }, DIM> {
const DIM: usize = DIM;
}
impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> {
fn size(&self) -> [usize; DIM] {
//~^ ERROR method not compatible with trait
self.size
}
}
impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> {
type Element = T::Element;
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
//~^ ERROR method not compatible with trait
assert!(DIM >= T::DIM);
if !self.inbounds(index) {
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
return None;
}
let size = self.size();
//~^ ERROR unconstrained generic constant

let newindex: [usize; T::DIM] = Default::default();
//~^ ERROR the trait bound `[usize; T::DIM]: Default` is not satisfied
self.reference.bget(newindex)
}
}

struct BMap<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> {
reference: &'a T,
closure: F,
}

impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorDimension
for BMap<'a, R, T, F, DIM>
{
const DIM: usize = DIM;
}
impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSize
for BMap<'a, R, T, F, DIM>
{
fn size(&self) -> [usize; DIM] {
//~^ ERROR method not compatible with trait
self.reference.size()
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
}
}
impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcastable
for BMap<'a, R, T, F, DIM>
{
type Element = R;
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
//~^ ERROR method not compatible with trait
self.reference.bget(index).map(ns_window)
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
//~| ERROR cannot find value `ns_window` in this scope
}
}

impl<T> TensorDimension for Vec<T> {
const DIM: usize = 1;
}
impl<T> TensorSize for Vec<T> {
fn size(&self) -> [usize; 1] {
//~^ ERROR method not compatible with trait
[self.len()]
}
}
impl<T: Clone> Broadcastable for Vec<T> {
type Element = T;
fn bget(&self, index: [usize; 1]) -> Option<T> {
//~^ ERROR method not compatible with trait
self.get(index[0]).cloned()
}
}

fn main() {
let v = vec![1, 2, 3];
let bv = v.lazy_updim([3, 4]);
let bbv = bv.bmap(|x| x * x);

println!("The size of v is {:?}", bbv.bget([0, 2]).expect("Out of bounds."));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
error[E0425]: cannot find value `ns_window` in this scope
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:97:40
|
LL | self.reference.bget(index).map(ns_window)
| ^^^^^^^^^ not found in this scope

error[E0308]: method not compatible with trait
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:47:5
|
LL | fn size(&self) -> [usize; DIM] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error[E0308]: method not compatible with trait
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:54:5
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error[E0308]: method not compatible with trait
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:84:5
|
LL | fn size(&self) -> [usize; DIM] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error[E0308]: method not compatible with trait
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:95:5
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error[E0308]: method not compatible with trait
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:108:5
|
LL | fn size(&self) -> [usize; 1] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1`
|
= note: expected constant `Self::DIM`
found constant `1`

error[E0308]: method not compatible with trait
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:115:5
|
LL | fn bget(&self, index: [usize; 1]) -> Option<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1`
|
= note: expected constant `Self::DIM`
found constant `1`

error: unconstrained generic constant
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:57:13
|
LL | if !self.inbounds(index) {
| ^^^^
|
note: required by a bound in `TensorSize::inbounds`
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:15:39
|
LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool {
| ^^^^^^^^^ required by this bound in `TensorSize::inbounds`
help: try adding a `where` bound
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
| ++++++++++++++++++++++

error[E0308]: mismatched types
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:57:27
|
LL | if !self.inbounds(index) {
| ^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error: unconstrained generic constant
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:62:25
|
LL | let size = self.size();
| ^^^^
|
note: required by a bound in `TensorSize::size`
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:14:31
|
LL | fn size(&self) -> [usize; Self::DIM];
| ^^^^^^^^^ required by this bound in `TensorSize::size`
help: try adding a `where` bound
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
| ++++++++++++++++++++++

error[E0277]: the trait bound `[usize; T::DIM]: Default` is not satisfied
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:65:41
|
LL | let newindex: [usize; T::DIM] = Default::default();
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[usize; T::DIM]`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> where [usize; T::DIM]: Default {
| ++++++++++++++++++++++++++++++

error: unconstrained generic constant
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:86:24
|
LL | self.reference.size()
| ^^^^
|
note: required by a bound in `TensorSize::size`
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:14:31
|
LL | fn size(&self) -> [usize; Self::DIM];
| ^^^^^^^^^ required by this bound in `TensorSize::size`
help: try adding a `where` bound
|
LL | fn size(&self) -> [usize; DIM] where [(); Self::DIM]: {
| ++++++++++++++++++++++

error[E0308]: mismatched types
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:86:9
|
LL | self.reference.size()
| ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM`
|
= note: expected constant `DIM`
found constant `Self::DIM`

error: unconstrained generic constant
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:97:9
|
LL | self.reference.bget(index).map(ns_window)
| ^^^^^^^^^^^^^^
|
note: required by a bound in `Broadcastable::bget`
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:22:35
|
LL | fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>;
| ^^^^^^^^^ required by this bound in `Broadcastable::bget`
help: try adding a `where` bound
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
| ++++++++++++++++++++++

error[E0308]: mismatched types
--> $DIR/generic-const-exprs-deadlock-issue-120757.rs:97:29
|
LL | self.reference.bget(index).map(ns_window)
| ^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error: aborting due to 15 previous errors

Some errors have detailed explanations: E0277, E0308, E0425.
For more information about an error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Test for #134978, deadlock detected as we're unable to find a query cycle to break

#![feature(generic_const_exprs)]

pub struct Struct<const N: usize>;

impl<const N: usize> Struct<N> {
pub const OK: usize = 0;
}

fn main() {
function::<0>();
}

fn function<const NUM_CARDS: usize>()
where
[(); Struct::<{ NUM_CARDS + 0 }>::OK]:,
//~^ ERROR cycle detected when building an abstract representation
{
}
Loading
Loading