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

Fix stack overflow when finding blanket impls #56722

Merged
merged 10 commits into from
Jan 19, 2019

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Dec 11, 2018

Currently, SelectionContext tries to prevent stack overflow by keeping
track of the current recursion depth. However, this depth tracking is
only used when performing normal section (which includes confirmation).
No such tracking is performed for evaluate_obligation_recursively, which
can allow a stack overflow to occur.

To fix this, this commit tracks the current predicate evaluation depth.
This is done separately from the existing obligation depth tracking:
an obligation overflow can occur across multiple calls to 'select' (e.g.
when fulfilling a trait), while a predicate evaluation overflow can only
happen as a result of a deep recursive call stack.

Fixes #56701

I've re-used tcx.sess.recursion_limit when checking for predication evaluation overflows. This is such a weird corner case that I don't believe it's necessary to have a separate setting controlling the maximum depth.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 11, 2018
@Aaron1011
Copy link
Member Author

@nikomatsakis: Are there any changes that you'd like me to make?

@nikomatsakis
Copy link
Contributor

@Aaron1011 sorry, I haven't really reviewed this yet. I actually have it on my calendar to do later today (around 4pm if I stick to my schedule =) so I'll let you know! I'm trying hard to catch up, but conferences and other things have left me with quite a backlog. :(

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code makes sense, but I can't escape the feeling that the bug is a failure to incremental the recursion depth in the recursive obligations, and not that we need a distinct recursion tracker for evaluation. Do you have ready access to the stack backtrace that causes the overflow in the example? (I can do a local build, too)

@@ -661,14 +665,15 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
&mut self,
stack: TraitObligationStackList<'o, 'tcx>,
predicates: I,
recursion_depth: usize
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call this the evaluation_depth or something like that?

It also feels like there should be a comment that links to the explanation below of why we have a distinct recursion depth tracking in use here.

@@ -719,7 +742,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
obligation.cause.span,
) {
Some(obligations) => {
self.evaluate_predicates_recursively(previous_stack, obligations.iter())
self.evaluate_predicates_recursively(previous_stack, obligations.iter(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, I feel like the intention here was that the predicates we evaluate recursively would have a recursion depth that was incremented relative to obligation.recursion_depth -- but there are clearly some cases where that's not true. Perhaps that is really the bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right - it should be possible to increment the recursion depth of the obligations before passing them to evaluate_predicates_recursively, and check that recursion depth at the start of evaluate_predicates_recursively.

@Aaron1011
Copy link
Member Author

@Aaron1011
Copy link
Member Author

@nikomatsakis: I've modified the PR to update the depth on nested obligations, instead of passing a separate recursion_depth parameter.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:04a92f3a:start=1545296757612708936,finish=1545296758708392864,duration=1095683928
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:53:36] ..............................i..................................................................... 600/5189
[00:53:39] .................................................................................................... 700/5189
[00:53:44] .................................................................................................... 800/5189
[00:53:49] ......i...............i............................................................................. 900/5189
[00:53:51] ...........................F..iiiii................................................................. 1000/5189
[00:53:54] ........................................................................F........................... 1100/5189
[00:53:56] .........................................................F.......................................... 1200/5189
[00:54:01] .................................................................................................... 1400/5189
[00:54:03] .................................................................................................... 1500/5189
[00:54:06] ................................i................................................................... 1600/5189
[00:54:09] .i.................................................................................................. 1700/5189
[00:54:09] .i.................................................................................................. 1700/5189
[00:54:13] .................................................................................................... 1800/5189
[00:54:16] .................................................................................................... 1900/5189
[00:54:19] ............................................i....................................................... 2000/5189
[00:54:22] ..........................................................................F......................... 2100/5189
[00:54:29] .................................................................................................... 2300/5189
[00:54:33] .................................................................................................... 2400/5189
[00:54:36] .................................................................................................... 2500/5189
[00:54:40] .................................................................................................... 2600/5189
---
[00:56:04] 
[00:56:04] ---- [ui] ui/did_you_mean/recursion_limit.rs stdout ----
[00:56:04] diff of stderr:
[00:56:04] 
[00:56:04] - error[E0275]: overflow evaluating the requirement `K: std::marker::Send`
[00:56:04] + error[E0275]: overflow evaluating the requirement `F: std::marker::Send`
[00:56:04] 3    |
[00:56:04] 3    |
[00:56:04] 4 LL |     is_send::<A>(); //~ ERROR overflow evaluating the requirement
[00:56:04] 5    |     ^^^^^^^^^^^^
[00:56:04] 6    |
[00:56:04] 6    |
[00:56:04] 7    = help: consider adding a `#![recursion_limit="20"]` attribute to your crate
[00:56:04] -    = note: required because it appears within the type `J`
[00:56:04] -    = note: required because it appears within the type `I`
[00:56:04] -    = note: required because it appears within the type `H`
[00:56:04] -    = note: required because it appears within the type `G`
[00:56:04] -    = note: required because it appears within the type `F`
[00:56:04] 13    = note: required because it appears within the type `E`
[00:56:04] 14    = note: required because it appears within the type `D`
[00:56:04] 15    = note: required because it appears within the type `C`
[00:56:04] 
[00:56:04] The actual stderr differed from the expected stderr.
[00:56:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/did_you_mean/recursion_limit/recursion_limit.stderr
[00:56:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/did_you_mean/recursion_limit/recursion_limit.stderr
[00:56:04] To update references, rerun the tests and pass the `--bless` flag
[00:56:04] To only update this specific test, also pass `--test-args did_you_mean/recursion_limit.rs`
[00:56:04] error: 1 errors occurred comparing output.
[00:56:04] status: exit code: 1
[00:56:04] status: exit code: 1
[00:56:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/did_you_mean/recursion_limit.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/did_you_mean/recursion_limit/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux required because it appears within the type `C`\n   = note: required because it appears within the type `B`\n   = note: required because it appears within the type `A`\nnote: required by `is_send`\n  --> /checkout/src/test/ui/did_you_mean/recursion_limit.rs:41:1\n   |\nLL | fn is_send<T:Send>() { }\n   | ^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:56:04] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:04] {"message":"For more information about this error, try `rustc --explain E0275`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0275`.\n"}
[00:56:04] ------------------------------------------
[00:56:04] 
[00:56:04] thread '[ui] ui/did_you_mean/recursion_limit.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3255:9
[00:56:04] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:56:04] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:56:04] 
[00:56:04] ---- [ui] ui/error-codes/E0055.rs stdout ----
[00:56:04] diff of stderr:
[00:56:04] 
[00:56:04] - error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
[00:56:04] -   --> $DIR/E0055.rs:21:13
[00:56:04] + error[E0275]: overflow evaluating the requirement `&Foo: std::marker::Unsize<_>`
[00:56:04] +   --> $DIR/E0055.rs:20:19
[00:56:04] 3    |
[00:56:04] - LL |     ref_foo.foo();
[00:56:04] -    |             ^^^ deref recursion limit reached
[00:56:04] + LL |     let ref_foo = &&Foo;
[00:56:04] 6    |
[00:56:04] 6    |
[00:56:04] 7    = help: consider adding a `#![recursion_limit="4"]` attribute to your crate
[00:56:04] +    = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<*const _>` for `&&Foo`
[00:56:04] 9 error: aborting due to previous error
[00:56:04] 10 
[00:56:04] 
[00:56:04] - For more information about this error, try `rustc --explain E0055`.
[00:56:04] - For more information about this error, try `rustc --explain E0055`.
[00:56:04] + For more information about this error, try `rustc --explain E0275`.
[00:56:04] 12 
[00:56:04] 
[00:56:04] 
[00:56:04] The actual stderr differed from the expected stderr.
[00:56:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0055/E0055.stderr
[00:56:04] To update references, rerun the tests and pass the `--bless` flag
[00:56:04] To only update this specific test, also pass `--test-args error-codes/E0055.rs`
[00:56:04] error: 1 errors occurred comparing output.
[00:56:04] status: exit code: 1
[00:56:04] status: exit code: 1
[00:56:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/error-codes/E0055.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0055/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0055/auxiliary" "-A" "unused"
[00:56:04] ------------------------------------------
[00:56:04] 
[00:56:04] ------------------------------------------
[00:56:04] stderr:
[00:56:04] stderr:
[00:56:04] ------------------------------------------
[00:56:04] {"message":"overflow evaluating the requirement `&Foo: std::marker::Unsize<_>`","code":{"code":"E0275","explanation":"\nThis error occurs when there was a recursive trait requirement that overflowed\nbefore it could be evaluated. Often this means that there is unbounded\nrecursion in resolving some type bounds.\n\nFor example, in the following code:\n\n```compile_fail,E0275\ntrait Foo {}\n\nstruct Bar<T>(T);\n\nimpl<T> Foo for T where Bar<T>: Foo {}\n```\n\nTo determine if a `T` is `Foo`, we need to check if `Bar<T>` is `Foo`. However,\nto do this check, we need to determine that `Bar<Bar<T>>` is `Foo`. To\ndetermine this, we check if `Bar<Bar<Bar<T>>>` is `Foo`, and so on. This is\nclearly a recursive requirement that can't be resolved directly.\n\nConsider changing your trait bounds so that they're less self-referential.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0055.rs","byte_start":588,"byte_end":593,"line_start":20,"line_end":20,"column_start":19,"column_end":24,"is_primary":true,"text":[{"text":"    let ref_foo = &&Foo;","highlight_start":19,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider adding a `#![recursion_limit=\"4\"]` attribute to your crate","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `std::ops::CoerceUnsized<*const _>` for `&&Foo`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0275]: overflow evaluating the requirement ar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: std::marker::Sized`
[00:56:04] 2   --> $DIR/E0275.rs:15:1
[00:56:04] 3    |
[00:56:04] 4 LL | impl<T> Foo for T where Bar<T>: Foo {} //~ ERROR E0275
[00:56:04] 5    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:56:04] 6    |
[00:56:04] 6    |
[00:56:04] 7    = help: consider adding a `#![recursion_limit="128"]` attribute to your crate
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bal of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<T>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the i<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<T>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<T>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<T>>>`\n   = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<T>>`\n   = note: required because of the >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<Nrequirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] -    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] 53    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] 54    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] 55    = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
[00:56:04] 
[00:56:04] The actual stderr differed from the expected stderr.
[00:56:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-20413/issue-20413.stderr
[00:56:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-20413/issue-20413.stderr
[00:56:04] To update references, rerun the tests and pass the `--bless` flag
[00:56:04] To only update this specific test, also pass `--test-args issues/issue-20413.rs`
[00:56:04] error: 1 errors occurred comparing output.
[00:56:04] status: exit code: 1
[00:56:04] status: exit code: 1
[00:56:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-20413.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-20413/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-20413/auxiliary" "-A" "unused"
[00:56:04] ------------------------------------------
[00:56:04] 
[00:56:04] ------------------------------------------
[00:56:04] stderr:
[00:56:04] stderr:
[00:56:04] ------------------------------------------
[00:56:04] {"message":"parameter `T` is never used","code":{"code":"E0392","explanation":"\nThis error indicates that a type or lifetime parameter has been declared\nbut not actually used. Here is an example that demonstrates the error:\n\n```compile_fail,E0392\nenum Foo<T> {\n    Bar,\n}\n```\n\nIf the type parameter was included by mistake, this error can be fixed\nby simply removing the type parameter, as shown below:\n\n```\nenum Foo {\n    Bar,\n}\n```\n\nAlternatively, if the type parameter was intentionally inserted, it must be\nused. A simple fix is shown below:\n\n```\nenum Foo<T> {\n    Bar(T),\n}\n```\n\nThis error may also commonly be found when working with unsafe code. For\nexample, when using raw pointers one may wish to specify the lifetime for\nwhich the pointed-at data is valid. An initial attempt (below) causes this\nerror:\n\n```compile_fail,E0392\nstruct Foo<'a, T> {\n    x: *const T,\n}\n```\n\nWe want to express the constraint that Foo should not outlive `'a`, because\nthe data pointed to by `T` is only valid for that lifetime. The problem is\nthat there are no actual uses of `'a`. It's possible to work around this\nby adding a PhantomData type to the struct, using it to tell the compiler\nto act as if the struct contained a borrowed reference `&'a T`:\n\n```\nuse std::marker::PhantomData;\n\nstruct Foo<'a, T: 'a> {\n    x: *const T,\n    phantom: PhantomData<&'a T>\n}\n```\n\n[PhantomData] can also be used to express information about unused type\nparameters.\n\n[PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<T>>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<T>>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<T>>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required because of the requirements on the impl of `Foo` for `NoData<NoData<T>>`","code":null,"level":"note","spans":[],"children":[],"reData<NoData<T>>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<T>>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<T>>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<T>>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<NoData<T>>`\n   = note: required because of the requirements on the impl of `Foo` for `NoData<T>`\nnote: required by `Foo`\n  --> /checkout/src/test/ui/issues/issue-20413.rs:11:1\n   |\nLL | trait Foo {\n   | ^^^^^^^^^\n\n"}
[00:56:04] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:56:04] {"message":"Some errors occurred: E0275, E0392.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0275, E0392.\n"}
[00:56:04] {"message":"For more information about an error, try `rustc --explain E0275`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0275`.\n"}
[00:56:04] ------------------------------------------
[00:56:04] 
[00:56:04] thread '[ui] ui/issues/issue-20413.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3255:9
[00:56:04] 
---
[00:56:04] test result: FAILED. 5162 passed; 4 failed; 23 ignored; 0 measured; 0 filtered out
[00:56:04] 
[00:56:04] 
[00:56:04] 
[00:56:04] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:56:04] 
[00:56:04] 
[00:56:04] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:56:04] Build completed unsuccessfully in 0:03:38
[00:56:04] Build completed unsuccessfully in 0:03:38
[00:56:04] Makefile:58: recipe for target 'check' failed
[00:56:04] make: *** [check] Error 1
2544612 ./obj
2544572 ./obj/build
1884656 ./obj/build/x86_64-unknown-linux-gnu
1119484 ./src
---
152196 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu
152192 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release
149800 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps
144288 ./obj/build/bootstrap/debug/incremental/bootstrap-2x7szixskz2uj
144284 ./obj/build/bootstrap/debug/incremental/bootstrap-2x7szixskz2uj/s-f7rfkouowc-17fd8za-3g9jcdhvsk79m
143776 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/release
124324 ./obj/bui:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:18560972
travis_time:start:18560972
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0f60d65c
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Aaron1011
Copy link
Member Author

It looks as though the new overflow check is getting hit before the old one, resulting in slightly worse error messages on overflow. I'll investigate more later today.

@nikomatsakis nikomatsakis added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2019
@nikomatsakis
Copy link
Contributor

@Aaron1011 did you ever get a chance to investigate?

@Aaron1011
Copy link
Member Author

Aaron1011 commented Jan 3, 2019

@nikomatsakis: Sorry for the delay.

I ended up chaging the recursion_limit for several of the tests. I believe these changes are justified, given that recursion_limit is now tracking additional steps (specifically, the interleaved evaluate_predicate_recursively calls:

  • src/test/run-pass/weird-exprs.rs: I've increased recursion_limit from 128 to 256. This is necessary to keep punch_card compiling, due to the additional depth evaluate_predicate_recursively. Given that the recursion_limit attribute was needed in the first place, I don't think this is a huge issue.
  • src/test/ui/did_you_mean/recursion_limit.stderr: The error occurs earlier in the evaluation of the Send bounds. This is due to the additional depth from evaluate_predicate_recursively pushing the depth over the limit sooner. Since it's still essentially the same error, I think this is OK.
  • src/test/ui/error-codes/E0055.rs: With this PR, a recursion_limit of 2 is no longer enough for compilation to reach let foo_ref = ... - overflow occurs while checking some standard library types. Given that such an incredibly low recursion_limit should never really be used in practice, I believe my adjustment is justified. Structurally, the code is essentially the same - it just uses a higher recursion_limit (and a therefore greater number of chained references) to trigger the overflow.
  • src/librustc_typeck/diagnostics.rs - The same as above.
  • src/test/ui/error-codes/E0275.stderr: Overflow simply occurs slightly earlier in the expansion of the infinite type Bar<Bar<...>>. Since it's not actually possible to construct such a type, I don't see this an issue.
    src/test/ui/issues/issue-20413.stderr: This is the same as the previous case.

I don't think that's it's possible to avoid these UI changes without significantly complicating the implementation. Since they only represent slight modifications to existing error messages, I think it should be fine.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:075f841a:start=1546486231213881997,finish=1546486233360981727,duration=2147099730
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:06:38] 
[01:06:38] running 118 tests
[01:07:01] .iiiii...i.....i..i...i..i.i..i.ii..i.....i..i....i..........iiii..........i...ii...i.......ii.i.i.i 100/118
[01:07:05] ......iii.i.....ii
[01:07:05] 
[01:07:05]  finished in 26.883
[01:07:05] travis_fold:end:test_debuginfo

---
[01:33:21] 
[01:33:21] failures:
[01:33:21] 
[01:33:21] ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0055 (line 1223) stdout ----
[01:33:21] error[E0275]: overflow evaluating the requirement `&Foo: std::marker::Unsize<_>`
[01:33:21]   --> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:1234:19
[01:33:21]    |
[01:33:21] 12 |     let ref_foo = &&Foo;
[01:33:21]    |
[01:33:21]    |
[01:33:21]    = help: consider adding a `#![recursion_limit="4"]` attribute to your crate
[01:33:21]    = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<*const _>` for `&&Foo`
[01:33:21] 
[01:33:21] thread '/checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0055 (line 1223)' panicked at 'Some expected error codes were not found: ["E0055"]', src/librustdoc/test.rs:321:9
[01:33:21] 
[01:33:21] 
[01:33:21] failures:
[01:33:21]     /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0055 (line 1223)
---
[01:33:21] 
[01:33:21] 
[01:33:21] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:33:21] Build completed unsuccessfully in 0:37:30
[01:33:21] Makefile:48: recipe for target 'check' failed
[01:33:21] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1159943d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Jan  3 05:04:03 UTC 2019

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice -- I made a few suggestions, one of which may affect some of the tests in question.


match obligation.predicate {
ty::Predicate::Trait(ref t) => {
debug_assert!(!t.has_escaping_bound_vars());
let obligation = obligation.with(t.clone());
let mut obligation = obligation.with(t.clone());
obligation.recursion_depth += 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to increase the recursion depth here -- this is just translating the predicate from one form to another.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is necessary here. Consider the following call stack:

  1. evaluate_predicate_recursively
  2. evaluate_trait_predicate_recursively
  3. evaluate_stack
  4. evaluate_candidate
  5. evaluate_predicates_recursively
  6. evaluate_predicate_recursively

Here, we've recursed back to evaluate_predicate_recursively without ever incrementing the recursion depth. To ensure that repeatedly recursing through the ty::Predicate::Trait match arm doesn't lead to a stack overflow, we need to increment the depth here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that there should be an increase in between steps 4 and 5. In particular, the "nested obligations" returned by evaluate_candidate ought to be at a recursion level one higher than the candidate that spawned them.

src/librustc/traits/select.rs Show resolved Hide resolved
src/librustc/traits/select.rs Show resolved Hide resolved
@@ -813,10 +827,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
ty::Predicate::Projection(ref data) => {
let project_obligation = obligation.with(data.clone());
match project::poly_project_and_unify_type(self, &project_obligation) {
Ok(Some(subobligations)) => {
Ok(Some(mut subobligations)) => {
self.add_depth(subobligations.iter_mut(), obligation.recursion_depth);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@@ -1155,6 +1170,38 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
.insert(trait_ref, WithDepNode::new(dep_node, result));
}

// Due to caching of projection results, it's possible for a subobligation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really think this is the reason why. It's more that things like subtype and wf don't take the "current recursion depth" as input and seem to just produce obligations at recursion depth 0, right? I would describe this function as a "workaround" for that scenario (which strikes me as odd but prob not worth changing in this PR)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the ty::Predicate::Projection match arm, where we call poly_project_and_unify_type. If the projection result is cached, the subobligations will have an 'old' recursion_depth.

I'll update the comment to mention that several different factors create the need to ensure that our recursion_depth doesn't decrease.

@bors
Copy link
Contributor

bors commented Jan 3, 2019

☔ The latest upstream changes (presumably #55517) made this pull request unmergeable. Please resolve the merge conflicts.

Currently, SelectionContext tries to prevent stack overflow by keeping
track of the current recursion depth. However, this depth tracking is
only used when performing normal section (which includes confirmation).
No such tracking is performed for evaluate_obligation_recursively, which
can allow a stack overflow to occur.

To fix this, this commit tracks the current predicate evaluation depth.
This is done separately from the existing obligation depth tracking:
an obligation overflow can occur across multiple calls to 'select' (e.g.
when fulfilling a trait), while a predicate evaluation overflow can only
happen as a result of a deep recursive call stack.

Fixes rust-lang#56701
@Aaron1011
Copy link
Member Author

@nikomatsakis: Are there any other changes you'd like me to make?

@nikomatsakis
Copy link
Contributor

@Aaron1011 will look shortly, trying to keep up with reviews, sorry =)

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I noted below, I still think this increment is unnecessary, and I'd prefer to remove it, as it is somewhat confusing (although I imagine it does no harm). If you think I'm wrong though, definitely let me know.

@nikomatsakis
Copy link
Contributor

Er, huh, I can't figure out the GH display.

@nikomatsakis
Copy link
Contributor

I am referring specifically to this comment, but let's take the replies out of that comment thread, since that is always kind of confusing.

An example of where confirm_candidate returns nested obligations with recursion depth one higher than what it started with:

let cause = obligation.derived_cause(BuiltinDerivedObligation);
self.collect_predicates_for_types(
obligation.param_env,
cause,
obligation.recursion_depth + 1,
trait_def,
nested,
)

@Aaron1011
Copy link
Member Author

@nikomatsakis: You were right! I've removed the uncessary increment (which also made some of the UI tests more closely resemble the current output).

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 18, 2019

📌 Commit 9b68dcd has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 18, 2019
@bors
Copy link
Contributor

bors commented Jan 19, 2019

⌛ Testing commit 9b68dcd with merge af73e64...

bors added a commit that referenced this pull request Jan 19, 2019
…sakis

Fix stack overflow when finding blanket impls

Currently, SelectionContext tries to prevent stack overflow by keeping
track of the current recursion depth. However, this depth tracking is
only used when performing normal section (which includes confirmation).
No such tracking is performed for evaluate_obligation_recursively, which
can allow a stack overflow to occur.

To fix this, this commit tracks the current predicate evaluation depth.
This is done separately from the existing obligation depth tracking:
an obligation overflow can occur across multiple calls to 'select' (e.g.
when fulfilling a trait), while a predicate evaluation overflow can only
happen as a result of a deep recursive call stack.

Fixes #56701

I've re-used `tcx.sess.recursion_limit` when checking for predication evaluation overflows. This is such a weird corner case that I don't believe it's necessary to have a separate setting controlling the maximum depth.
@bors
Copy link
Contributor

bors commented Jan 19, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: nikomatsakis
Pushing af73e64 to master...

@bors bors merged commit 9b68dcd into rust-lang:master Jan 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo doc stack overflow (1.31)
4 participants