Skip to content
Open
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
3 changes: 2 additions & 1 deletion compiler/rustc_query_impl/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub(crate) struct Cycle {
#[subdiagnostic]
pub cycle_usage: Option<CycleUsage>,
#[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"
"for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> \
and <https://rustc-dev-guide.rust-lang.org/query.html>"
)]
pub note_span: (),
}
Expand Down
17 changes: 12 additions & 5 deletions compiler/rustc_query_impl/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,23 @@ pub(crate) fn create_cycle_error<'tcx>(
StackCount::Multiple { stack_bottom: stack_bottom.clone() }
};

let mut prev = span;
for i in 1..frames.len() {
let frame = &frames[i];
let span = frame.tagged_key.catch_default_span(tcx, frames[(i + 1) % frames.len()].span);
cycle_stack
.push(crate::error::CycleStack { span, desc: frame.tagged_key.catch_description(tcx) });
cycle_stack.push(crate::error::CycleStack {
span: if span == prev { DUMMY_SP } else { span },
desc: frame.tagged_key.catch_description(tcx),
});
prev = span;
}

let cycle_usage = usage.as_ref().map(|usage| crate::error::CycleUsage {
span: usage.tagged_key.catch_default_span(tcx, usage.span),
usage: usage.tagged_key.catch_description(tcx),
let cycle_usage = usage.as_ref().map(|usage| {
let cycle_span = usage.tagged_key.catch_default_span(tcx, usage.span);
crate::error::CycleUsage {
span: if cycle_span != span { cycle_span } else { DUMMY_SP },
usage: usage.tagged_key.catch_description(tcx),
}
});

let is_all_def_kind = |def_kind| {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/layout_cycle.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ note: cycle used when const-evaluating + checking `core::mem::SizedTypePropertie
|
LL | const SIZE: usize = intrinsics::size_of::<Self>();
| ^^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ note: cycle used when checking that `Bar` is well-formed
|
LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
| ^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-consts/defaults-cyclic-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ note: cycle used when optimizing promoted MIR for `main`
|
LL | assert_eq!(<() as Tr>::A, 0);
| ^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,16 @@ error[E0391]: cycle detected when checking if `IMPL_REF_BAR` is a trivial const
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires building MIR for `IMPL_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires building MIR for `IMPL_REF_BAR`...
note: ...which requires checking if `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR` is a trivial const...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
LL | const BAR: u32 = IMPL_REF_BAR;
| ^^^^^^^^^^^^^^
note: ...which requires building MIR for `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
LL | const BAR: u32 = IMPL_REF_BAR;
| ^^^^^^^^^^^^^^
= note: ...which requires building MIR for `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR`...
= note: ...which again requires checking if `IMPL_REF_BAR` is a trivial const, completing the cycle
note: cycle used when simplifying constant for the type system `IMPL_REF_BAR`
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: cycle used when simplifying constant for the type system `IMPL_REF_BAR`
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,10 @@ note: ...which requires simplifying constant for the type system `FooDefault::BA
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^
= note: ...which requires const-evaluating + checking `FooDefault::BAR`...
= note: ...which again requires caching mir of `FooDefault::BAR` for CTFE, completing the cycle
note: cycle used when const-evaluating + checking `FooDefault::BAR`
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^
= 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
= note: cycle used when const-evaluating + checking `FooDefault::BAR`
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,16 @@ note: ...which requires simplifying constant for the type system `<impl at $DIR/
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^
note: ...which requires caching mir of `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR` for CTFE...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^
= note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`...
= note: ...which requires caching mir of `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR` for CTFE...
note: ...which requires elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:22
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^
= note: ...which again requires simplifying constant for the type system `TRAIT_REF_BAR`, completing the cycle
note: cycle used when simplifying constant for the type system `TRAIT_REF_BAR`
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: cycle used when simplifying constant for the type system `TRAIT_REF_BAR`
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ LL | trait Baz: Foo + Bar<Self::Item> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which immediately requires computing the super traits of `Baz` with associated type name `Item` again
note: cycle used when computing the super predicates of `Baz`
--> $DIR/ambiguous-associated-type2.rs:7:1
|
LL | trait Baz: Foo + Bar<Self::Item> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: cycle used when computing the super predicates of `Baz`
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: cycle used when computing normalized predicates of `B`
|
LL | trait B: A<T: B> {}
| ^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ error[E0391]: cycle detected when resolving lifetimes for `IntFactory::stream`
LL | fn stream(self) -> impl IntFactory<stream(..): Send>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires computing function signature of `IntFactory::stream`...
--> $DIR/impl-trait-in-trait.rs:4:5
|
LL | fn stream(self) -> impl IntFactory<stream(..): Send>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires looking up late bound vars inside `IntFactory::stream`...
--> $DIR/impl-trait-in-trait.rs:4:5
|
LL | fn stream(self) -> impl IntFactory<stream(..): Send>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing function signature of `IntFactory::stream`...
= note: ...which requires looking up late bound vars inside `IntFactory::stream`...
= note: ...which again requires resolving lifetimes for `IntFactory::stream`, completing the cycle
note: cycle used when listing captured lifetimes for opaque `IntFactory::stream::{opaque#0}`
--> $DIR/impl-trait-in-trait.rs:4:24
|
LL | fn stream(self) -> impl IntFactory<stream(..): Send>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
18 changes: 3 additions & 15 deletions tests/ui/associated-types/impl-wf-cycle-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@ LL | | where
LL | | T: Fn(Self::ToMatch),
| |_________________________^
|
note: ...which requires computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>`...
--> $DIR/impl-wf-cycle-4.rs:5:1
|
LL | / impl<T> Filter for T
LL | | where
LL | | T: Fn(Self::ToMatch),
| |_________________________^
= note: ...which requires computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>`...
= note: ...which again requires computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type, completing the cycle
note: cycle used when checking that `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` is well-formed
--> $DIR/impl-wf-cycle-4.rs:5:1
|
LL | / impl<T> Filter for T
LL | | where
LL | | T: Fn(Self::ToMatch),
| |_________________________^
= 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
= note: cycle used when checking that `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` is well-formed
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
8 changes: 2 additions & 6 deletions tests/ui/associated-types/issue-20825.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ LL | pub trait Processor: Subscriber<Input = Self::Input> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which immediately requires computing the super traits of `Processor` with associated type name `Input` again
note: cycle used when computing the super predicates of `Processor`
--> $DIR/issue-20825.rs:5:1
|
LL | pub trait Processor: Subscriber<Input = Self::Input> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: cycle used when computing the super predicates of `Processor`
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^
|
= note: ...which immediately requires building specialization graph of trait `Trait` again
note: cycle used when coherence checking all impls of trait `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:8:1
|
LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^
= 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
= note: cycle used when coherence checking all impls of trait `Trait`
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
14 changes: 3 additions & 11 deletions tests/ui/const-generics/generic_const_exprs/closures.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ error[E0391]: cycle detected when building an abstract representation for `test:
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
| ^^^^^^^^^^^^^
|
note: ...which requires building THIR for `test::{constant#0}`...
--> $DIR/closures.rs:3:35
|
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
| ^^^^^^^^^^^^^
note: ...which requires type-checking `test::{constant#0}`...
--> $DIR/closures.rs:3:35
|
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
| ^^^^^^^^^^^^^
= note: ...which requires building THIR for `test::{constant#0}`...
= note: ...which requires type-checking `test::{constant#0}`...
= note: ...which again requires building an abstract representation for `test::{constant#0}`, completing the cycle
note: cycle used when checking that `test` is well-formed
--> $DIR/closures.rs:3:1
|
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/not_wf_param_in_rpitit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ note: cycle used when checking that `Trait` is well-formed
|
LL | trait Trait<const N: dyn Trait = bar> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 2 previous errors

Expand Down
17 changes: 4 additions & 13 deletions tests/ui/consts/const-size_of-cycle.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ error[E0391]: cycle detected when evaluating type-level constant
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`...
--> $DIR/const-size_of-cycle.rs:2:17
|
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`...
note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`...
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
note: ...which requires simplifying constant for the type system `core::mem::SizedTypeProperties::SIZE`...
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
note: ...which requires const-evaluating + checking `core::mem::SizedTypeProperties::SIZE`...
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
= note: ...which requires const-evaluating + checking `core::mem::SizedTypeProperties::SIZE`...
note: ...which requires computing layout of `Foo`...
--> $DIR/const-size_of-cycle.rs:1:1
|
Expand All @@ -27,12 +22,8 @@ note: ...which requires normalizing `[u8; std::mem::size_of::<Foo>()]`...
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires evaluating type-level constant, completing the cycle
note: cycle used when checking that `Foo` is well-formed
--> $DIR/const-size_of-cycle.rs:2:17
|
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: cycle used when checking that `Foo` is well-formed
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/issue-103790.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ note: cycle used when checking that `S` is well-formed
|
LL | struct S<const S: (), const S: S = { S }>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 3 previous errors

Expand Down
8 changes: 2 additions & 6 deletions tests/ui/consts/issue-36163.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ error[E0391]: cycle detected when simplifying constant for the type system `Foo:
LL | B = A,
| ^
|
note: ...which requires const-evaluating + checking `Foo::B::{constant#0}`...
--> $DIR/issue-36163.rs:4:9
|
LL | B = A,
| ^
= note: ...which requires const-evaluating + checking `Foo::B::{constant#0}`...
note: ...which requires simplifying constant for the type system `A`...
--> $DIR/issue-36163.rs:1:1
|
Expand All @@ -25,7 +21,7 @@ note: cycle used when checking that `Foo` is well-formed
|
LL | enum Foo {
| ^^^^^^^^
= 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
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

Expand Down
Loading
Loading