Skip to content

Type annotations needed error on definition site #84398

Closed
@vorner

Description

@vorner

Hello

After upgrading nightly rustc, I'm getting a lot of type inference errors on code that was compiling fine previously. Moreover, these are not at the call site, but at the definition site, so there doesn't seem to be any place to put any type annotations, like this:

    --> src/spirit.rs:996:1
     |
996  | / impl<O, C> SpiritBuilder for Builder<O, C>
997  | | where
998  | |     Self::Config: DeserializeOwned + Send + Sync + 'static,
999  | |     Self::Opts: StructOpt + Sync + Send + 'static,
...    |
1108 | |     }
1109 | | }
     | |_^ cannot infer type for type parameter `C`

It spills more kinds of errors that make little sense, but I have the impression these will have a common cause:

error[E0277]: `C` cannot be shared between threads safely
   --> src/spirit.rs:998:45
    |
998 |     Self::Config: DeserializeOwned + Send + Sync + 'static,
    |                                             ^^^^ `C` cannot be shared between threads safely

The problematic code is both released on crates.io (crate spirit, version 0.4.16, but I expect that to be happening through most of the history of the crate), and in master (vorner/spirit@1495c1c).

I think this is a regression, as it was compiling previously.

It compiles fine with older nightly (and stable is fine way back, this particular code is looking mostly the same for some 2 years or more):

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)

Breaks with

rustc 1.53.0-nightly (6df26f897 2021-04-20)
binary: rustc
commit-hash: 6df26f897cffb2d86880544bb451c6b5f8509b2d
commit-date: 2021-04-20
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

(Unfortunately, I haven't been keeping fully up to date recently, so I don't have a smaller range).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions