Skip to content

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

Closed
@SohumB

Description

@SohumB

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

Metadata

Metadata

Labels

C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions