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

requirement solver overflow involving proptest::sugar::NamedArguments #123493

Closed
SohumB opened this issue Apr 5, 2024 · 5 comments · Fixed by #123618
Closed

requirement solver overflow involving proptest::sugar::NamedArguments #123493

SohumB opened this issue Apr 5, 2024 · 5 comments · Fixed by #123618
Assignees
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SohumB
Copy link

SohumB commented Apr 5, 2024

I have a full repro in https://github.com/SohumB/proptest_sugar_rustc_overflow, but the short version is, it seems like some cases of code that look like an omitted type should be inferrable:

fn _foo<Error: Debug>() {
    todo!()
}

pub fn foo() {
    _foo();
}

while certain dependencies, leading to proptest, are in the compile pathway (I could only get it to reproduce via a weird dependency chain via a workspace and a couple of public crates), can lead rustc to an overflow:

error[E0275]: overflow evaluating the requirement `proptest::sugar::NamedArguments<(_, _, _), &(..., ..., ...)>: Debug`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`pipeline`)
  = note: required for `proptest::sugar::NamedArguments<((_, _, _), _, _), &((_, _, _), _, _)>` to implement `Debug`
  = note: 126 redundant requirements hidden
  = note: required for `NamedArguments<((((((((((..., ..., ...), ..., ...), ..., ...), ..., ...), ..., ...), ..., ...), ..., ...), ..., ...), ..., ...), ..., ...), ...>` to implement `Debug`
  = note: the full name for the type has been written to '/home/sohum/versioned/xdi/ice_repro/target/debug/deps/pipeline-00f02624ad986c54.long-type-16626873074358915367.txt'
  = note: consider using `--verbose` to print the full type name to the console

If the dependency chain is altered in any way that I could divine, the expected error is output:

error[E0283]: type annotations needed
 --> foo/src/lib.rs:9:5
  |
9 |     _foo();
  |     ^^^^ cannot infer type of the type parameter `Error` declared on the function `_foo`
  |
  = note: cannot satisfy `_: Debug`
note: required by a bound in `_foo`
 --> foo/src/lib.rs:4:16
  |
4 | fn _foo<Error: Debug>() {
  |                ^^^^^ required by this bound in `_foo`
help: consider specifying the generic argument
  |
9 |     _foo::<Error>();
  |         +++++++++

Meta

I've reproduced this bug both in nightly-2024-04-05 and in nightly-2024-03-12.

rustc --version --verbose:

rustc 1.79.0-nightly (385fa9d84 2024-04-04)
binary: rustc
commit-hash: 385fa9d845dd326c6bbfd58c22244215e431948a
commit-date: 2024-04-04
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2
@SohumB SohumB added the C-bug Category: This is a bug. label Apr 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 5, 2024
@jieyouxu jieyouxu added S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. labels Apr 5, 2024
@dtolnay
Copy link
Member

dtolnay commented Apr 7, 2024

Bisects to nightly-2023-10-07. In nightly-2023-10-06, we get "the expected error" shown above.

cae0791...9607540

@dtolnay
Copy link
Member

dtolnay commented Apr 7, 2024

Looks like #114811, because 94bc9c7 reproduces the issue, but the previous commit on master (31be8cc) does not.

@dtolnay dtolnay added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Apr 7, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 7, 2024
@dtolnay dtolnay added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 7, 2024
@compiler-errors
Copy link
Member

compiler-errors commented Apr 8, 2024

Minimal:

trait Hello {}

struct Foo<'a, T: ?Sized>(&'a T);

impl<'a, T: ?Sized> Hello for Foo<'a, &'a T> where Foo<'a, T>: Hello {}

fn hello<T: ?Sized + Hello>() {}

fn main() {
    hello::<_>();
}

@compiler-errors
Copy link
Member

I'll put up a fix in a sec

@apiraino
Copy link
Contributor

apiraino commented Apr 8, 2024

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 8, 2024
@apiraino apiraino removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 8, 2024
@bors bors closed this as completed in 86b791a Apr 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 14, 2024
Rollup merge of rust-lang#123618 - compiler-errors:overflow-ambig, r=spastorino

Discard overflow obligations in `impl_may_apply`

Hacky fix for rust-lang#123493. Throws away obligations that are overflowing in `impl_may_apply` when we recompute if an impl applies, since those will lead to fatal overflow if processed during fulfillment.

Something about rust-lang#114811 (I think it's the predicate reordering) caused us to evaluate predicates differently in error reporting leading to fatal overflow, though I believe the underlying overflow is possible to hit since this code was rewritten to use fulfillment.

Fixes rust-lang#123493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants