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

Open
oblique opened this issue May 20, 2024 · 4 comments
Open

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

oblique opened this issue May 20, 2024 · 4 comments
Labels
C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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
Contributor

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.35 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
Contributor

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
stevenengler added a commit to stevenengler/shadow that referenced this issue May 23, 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
stevenengler added a commit to shadow/shadow that referenced this issue May 24, 2024
Previously shadow wouldn't compile on nightly due to a rust compiler
type inference change that breaks existing rust code, and they intend to
stabilize this change in a couple of months. For us that breakage occurs
in the time crate, so this PR upgrades all dependencies (including the
time library) to fix the build error.

rust-lang/rust#99969 (comment)

rust-lang/rust#125319
vincentdephily added a commit to vincentdephily/emlop that referenced this issue May 29, 2024
Fixes build on nightly.
rust-lang/rust#125319
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. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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

No branches or pull requests

6 participants