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

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 5, 2024
added
S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.
E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
and removed
S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.
on Apr 5, 2024
dtolnay

dtolnay commented on Apr 7, 2024

@dtolnay
Member

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

cae0791...9607540

dtolnay

dtolnay commented on Apr 7, 2024

@dtolnay
Member

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

added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Apr 7, 2024
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 7, 2024
compiler-errors

compiler-errors commented on Apr 8, 2024

@compiler-errors
Member

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

compiler-errors commented on Apr 8, 2024

@compiler-errors
Member

I'll put up a fix in a sec

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Participants

    @SohumB@dtolnay@compiler-errors@apiraino@jieyouxu

    Issue actions

      requirement solver overflow involving `proptest::sugar::NamedArguments` · Issue #123493 · rust-lang/rust