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

Type inference regression on nightly-2024-05-20 #125319

Closed
oblique opened this issue May 20, 2024 · 7 comments · Fixed by neondatabase/neon#8142
Closed

Type inference regression on nightly-2024-05-20 #125319

oblique opened this issue May 20, 2024 · 7 comments · Fixed by neondatabase/neon#8142
Labels
A-inference Area: Type inference C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@oblique
Copy link

oblique commented May 20, 2024

Code

I tried this code:

[package]
name = "regression"
version = "0.1.0"
edition = "2021"

[dependencies]
time = { version = "=0.3.34", features = ["parsing"] }
fn main() {}

I expected to see this happen: Compile successfully.

Instead, this happened: Compilation failed with the following.

error[E0282]: type annotations needed for `Box<_>`
  --> /home/oblique/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.34/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
help: consider giving `items` an explicit type, where the placeholders `_` are specified
   |
83 |     let items: Box<_> = format_items
   |              ++++++++

For more information about this error, try `rustc --explain E0282`.
error: could not compile `time` (lib) due to 1 previous error

Version it worked on

It most recently worked on:

rustc --version --verbose:

rustc 1.80.0-nightly (b1ec1bd65 2024-05-18)
binary: rustc
commit-hash: b1ec1bd65f89c1375d2cf2fb733a87ef390276d3
commit-date: 2024-05-18
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

Version with regression

rustc --version --verbose:

rustc 1.80.0-nightly (d84b90375 2024-05-19)
binary: rustc
commit-hash: d84b9037541f45dc2c52a41d723265af211c0497
commit-date: 2024-05-19
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

@rustbot modify labels: +regression-from-stable-to-nightly-regression-untriaged

@oblique oblique added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels May 20, 2024
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 20, 2024
@lukas-code
Copy link
Member

Regression in #99969.

This code used to infer _ as [char], but now it is ambiguous between [char] and str. (playground)

fn main() {
    let _: Box<_> = ['a'].into_iter().collect();
}

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged T-libs-api

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed regression-untriaged Untriaged performance or correctness regression. labels May 20, 2024
@kpreid
Copy link
Contributor

kpreid commented May 20, 2024

Per #99969 (comment) this is a known breakage, which can be addressed by updating your project's time dependency to version 0.3.36 or later.

@oblique
Copy link
Author

oblique commented May 20, 2024

Does this mean it will be enabled by 2024 edition?

iddm added a commit to iddm/serde_with that referenced this issue May 21, 2024
It fixes an issue when the crate couldn't be built using nightly due to time dependency.

See <rust-lang/rust#125319>.
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 21, 2024
@workingjubilee
Copy link
Member

A type inference regression is permitted breakage according to Rust RFC 1122.

This is not even a change in type inference though, it's rather because of type inference. In particular, when we add an impl and that means now 2 possible impls resolve, instead of 1, it can break things. Customarily, if the library teams expect a breakage may be particularly widespread, rejecting it is discussed and there is a formal decision to accept it or not. However it's not clear to me from the FCP's comments (or lack thereof) if T-libs-api discussed this breakage before/during the FCP, beyond the chatter that occurred there? #99969 (comment)

@rust-lang/libs-api Can I just assume that if T-libs-api FCPs a new impl of something like From or FromIterator, and then a team member r+'s landing something that they said "maybe a crater run" about, that you have discussed the breakage possibility and said "worth it"? It may be helpful if you just formally note "probably will break someone relying on a particularly strained .into() somewhere, but that seems fine" on the FCP.

Spicy option: r+ it the moment it hits the final comment period so we might actually get any such reports in the 10 day period.

Shnatsel added a commit to Shnatsel/cyclonedx-rust-cargo that referenced this issue May 21, 2024
Signed-off-by: Sergey "Shnatsel" Davidoff <shnatsel@gmail.com>
iddm added a commit to iddm/serde_with that referenced this issue May 22, 2024
It fixes an issue when the crate couldn't be built using nightly due to time dependency.

See <rust-lang/rust#125319>.
oblique added a commit to oblique/lumina that referenced this issue May 22, 2024
bors added a commit to rust-lang/cargo that referenced this issue May 22, 2024
[beta-1.79] fix(toml): Don't warn on lints.rust.unexpected_cfgs.check-cfg

Beta backports:
- #13913 (sort of): removes just the lint warning (in a different way to be minimal) so we reduce warning noise for people using this key on nightly

In order to make CI pass, the following PRs are also cherry-picked:
- #13865
- #13834 (only `time` due to rust-lang/rust#125319)
- #13901
- #13931
- #13920
- #13890
- disable link check (not a cherry pick)
stevenengler added a commit to stevenengler/shadow that referenced this issue May 22, 2024
Previously shadow wouldn't compile on nightly due to a rust type inference
change that breaks older rust code, and they intend to stabilize this change.
For us that breakage occurs in the time crate, so this PR upgrades all
dependencies (including the time library) to fix the build errors.

rust-lang/rust#99969 (comment)

rust-lang/rust#125319
stevenengler added a commit to stevenengler/shadow that referenced this issue May 22, 2024
Previously shadow wouldn't compile on nightly due to a rust type inference
change that breaks existing rust code, and they intend to stabilize this
change. For us that breakage occurs in the time crate, so this PR upgrades all
dependencies (including the time library) to fix the build errors.

rust-lang/rust#99969 (comment)

rust-lang/rust#125319
fl0rek pushed a commit to eigerco/lumina that referenced this issue May 23, 2024
@dtolnay
Copy link
Member

dtolnay commented Jul 2, 2024

We discussed this regression in today's libs-api team meeting, and are inclined not to revert.

1.80 is in beta already so we'll start seeing fallout in the beta crater runs. The team will re-evaluate if the beta crater runs look disastrous with many crates other than time impacted.

@dtolnay dtolnay closed this as completed Jul 2, 2024
conradludgate added a commit to neondatabase/neon that referenced this issue Jul 9, 2024
## Problem

`cargo +nightly check` fails

## Summary of changes

Updates `measured`, `time`, and `crc32c`.

* `measured`: updated to fix
rust-lang/rust#125763.
* `time`: updated to fix rust-lang/rust#125319
* `crc32c`: updated to remove some nightly feature detection with a
removed nightly feature
skyzh pushed a commit to neondatabase/neon that referenced this issue Jul 15, 2024
## Problem

`cargo +nightly check` fails

## Summary of changes

Updates `measured`, `time`, and `crc32c`.

* `measured`: updated to fix
rust-lang/rust#125763.
* `time`: updated to fix rust-lang/rust#125319
* `crc32c`: updated to remove some nightly feature detection with a
removed nightly feature
AiyionPrime added a commit to vorausrobotik/opcua that referenced this issue Jul 17, 2024
By setting time 0.3.36 as minimally required version in accordance to
rust-lang/rust#125319 (comment)
sgoll added a commit to LeanderGlanda/open62541-crate that referenced this issue Jul 26, 2024
omertuc added a commit to omertuc/recert-1 that referenced this issue Aug 1, 2024
# Background

Recert uses the `simple_asn1` crate in order to calculate the SKID on
RSA keys

# Problem

The `simple_asn1` crate depends on the `time` crate, which recently
encountered a regression [1] due to [2] that caused the `simple_asn1`
crate to fail to compile with our locked version (0.3.30) of the `time`
crate.

# Solution

Updated the `time` crate to version 0.3.36, which contains a fix for the
regression. Re-ran vendoring.

[1] time-rs/time#681
[2] rust-lang/rust#125319
a-kenji added a commit to friedow/centerpiece that referenced this issue Aug 10, 2024
`rustc --version`: `v1.80.0` has a type inference regression.
This causes compilation of `centerpiece` to fail, because we use an
affected version of the `time` crate.

This updates the time crate to a released version with a fix.

Reference:
- NixOS/nixpkgs#332957
- rust-lang/rust#125319
- rust-lang/rust#99969
a-kenji added a commit to friedow/centerpiece that referenced this issue Aug 11, 2024
`rustc --version`: `v1.80.0` has a type inference regression. This
causes compilation of `centerpiece` to fail, because we use an affected
version of the `time` crate.

This updates the time crate to a released version with a fix.

Reference:
- NixOS/nixpkgs#332957
- rust-lang/rust#125319
- rust-lang/rust#99969
@dtolnay dtolnay removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants