-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Emit specific message for time<=0.3.35 #129343
Conversation
rustbot has assigned @compiler-errors. Use |
This PR is missing a test because it relies on cargo paths and synthesizing that in a make will still be ugly. I verified with a minimal local project:
The output is the one in the PR description. |
if component == "registry" | ||
&& let Some(next) = components.next() | ||
&& let std::path::Component::Normal(next) = next | ||
&& next == "src" | ||
&& let Some(next) = components.next() | ||
&& let std::path::Component::Normal(next) = next | ||
&& next.to_string_lossy().starts_with("index.") | ||
&& let Some(next) = components.next() | ||
&& let std::path::Component::Normal(next) = next | ||
&& let next = next.to_string_lossy() | ||
&& next.starts_with("time-0.") | ||
&& let Some(version) = next.split('-').skip(1).next() | ||
&& let mut segments = version.split('.') | ||
&& let Some(major) = segments.next() | ||
&& major == "0" | ||
&& let Some(minor) = segments.next() | ||
&& minor == "3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coding an error message like this based off of path matching can likely be written using regex instead. This let chain is inscrutable to the point that I'd rather we not merge this if it can't be rewritten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, alternatively, I'd rather we not do path parsing here and just match on a combination of crate name and some other condition we can deduce from the program itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like, are we even always going to be compiling time
from a crates.io registry? Does this work correctly for vendored deps? This certainly doesn't work for non-cargo build tools, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern matching on a path sounds more brittle. This check is horrible, I agree, but it at least handles paths across windows/unix correctly, and by being this specific in the number of checks we're less likely to wrongly trigger if someone just happens to put code in a directory called time-0.blah
. I think we can likely split some of the elements into one or two closures to make the chain easier to read, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already incredibly brittle. See that comment I just left. I'd rather we not make this hack rely on some special structure of the crates.io registry, or even depending on cargo
itself (this is rustc
after all), or not go with this at all if that's impossible.
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
I also don't see why this isn't something that cargo should be detecting any time that a registry dependency fails to compile. Any time we have a registry dep fail to compile, it should probably be saying something like "hey, try updating the version of crate xyz you depend on", since the fact that it was both published to the registry but now fails to compile suggests that there's probably something that happened in the mean time. These "somethings" could include:
There are many reasons why a crate compiles on rust 1.x but not 1.x+1 that we regularly accept for one reason or the other, and I still don't think that we should or need to have a crate-specific hack for time in this case. Especially unless we're "timeboxing" such a hack to be removed once the only important difference -- that is, the impact of the regression -- has subsided. |
If you disagree, though, then I guess you probably should compiler-nominate this for team discussion, because I would opt to not approve this now, but I'd rather not be the single blocker for this hack. |
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
Outdated
Show resolved
Hide resolved
I agree, our user experience around updates doesn't live up to the bar we set for ourselves.
If it was up to me, we'd have 1.80.2 without the new |
i'll let someone else review this after the team decides on the action here r? compiler |
I appreciate the efforts to help mitigate the fallout from the inference regression, but I'm also not very comfortable adding another crate-specific hack. If anything, we ought to be removing crate-specific hacks. I would prefer if T-compiler worked with T-libs-api and T-release to create a postmortem for the time regression to make our release process more robust. To help catch these inference regressions happen before they happen in the future, instead of adding hacks for mitigations after the fact. Since this has been nominated for T-compiler decision, I'll wait for that decision and respect that decision, even though I would prefer not having this hack myself. |
In any case, I'll write up a summary for T-compiler triage meeting. |
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
Outdated
Show resolved
Hide resolved
Summary for T-compilerThis PR (#129343) proposes to special-case an inference error diagnostic note for the
Nominating for T-compiler discussion to decide if we want to merge this crate-specific diagnostic note. |
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
Outdated
Show resolved
Hide resolved
I don't agree with this framing. Cargo does not use the lock files from packages on crates.io by default. So if you pull anything from crates.io with cargo, it'll simply use the newest (semver compatible) version of the People working in projects with a Cargo.lock with an old
That would be a breaking change too. That would break anyone who uses the new impls in 1.80.0 when they update their compiler again, but without a "cargo update" solution. |
Discussed in t-compiler triage on zulip. This change is a bit controversial, we don't like hard-coding stuff for specific crates but it seems it's not the first time1 and after all it's just a diagnostic message. That we pinky promise to remove in around six months or so. I hereby @apiraino take responsability to remind t-compiler in case the revert is forgotten 🙂 @rustbot label -I-compiler-nominated Footnotes
|
@bors r- |
@bors r=jieyouxu |
Emit specific message for time<=0.3.35 ``` error[E0282]: type annotations needed for `Box<_>` --> /home/gh-estebank/.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 | = note: this is an inference error on `time` caused by a change in Rust 1.80.0; update `time` to version `>=0.3.36` ``` Partially mitigate the fallout from rust-lang#127343. Although the biggest benefit of this would have been if we had had this in 1.80 before it became stable, the long-tail of that change will be felt for a *long* time, so better late than never. We can also emit an even more targeted error instead of this inference failure.
…kingjubilee Rollup of 14 pull requests Successful merges: - rust-lang#128192 (rustc_target: Add various aarch64 features) - rust-lang#129170 (Add an ability to convert between `Span` and `visit::Location`) - rust-lang#129343 (Emit specific message for time<=0.3.35) - rust-lang#129378 (Clean up cfg-gating of ProcessPrng extern) - rust-lang#129401 (Partially stabilize `feature(new_uninit)`) - rust-lang#129467 (derive(SmartPointer): assume pointee from the single generic and better error messages) - rust-lang#129494 (format code in tests/ui/threads-sendsync) - rust-lang#129617 (Update books) - rust-lang#129673 (Add fmt::Debug to sync::Weak<T, A>) - rust-lang#129683 (copysign with sign being a NaN can have non-portable results) - rust-lang#129689 (Move `'tcx` lifetime off of impl and onto methods for `CrateMetadataRef`) - rust-lang#129695 (Fix path to run clippy on rustdoc) - rust-lang#129712 (Correct trusty targets to be tier 3) - rust-lang#129715 (Update `compiler_builtins` to `0.1.123`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129343 - estebank:time-version, r=jieyouxu Emit specific message for time<=0.3.35 ``` error[E0282]: type annotations needed for `Box<_>` --> /home/gh-estebank/.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 | = note: this is an inference error on `time` caused by a change in Rust 1.80.0; update `time` to version `>=0.3.36` ``` Partially mitigate the fallout from rust-lang#127343. Although the biggest benefit of this would have been if we had had this in 1.80 before it became stable, the long-tail of that change will be felt for a *long* time, so better late than never. We can also emit an even more targeted error instead of this inference failure.
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
[beta] backports - Emit specific message for `time<0.3.35` inference failure rust-lang#129343 - Use a reduced recursion limit in the MIR inliner's cycle breaker rust-lang#129714 - rustdoc: do not run doctests with invalid langstrings rust-lang#128838 r? cuviper
Revert "Rollup merge of rust-lang#129343 - estebank:time-version, r=jieyouxu" This reverts commit 26f75a6, reversing changes made to 2572e0e.
Revert "Rollup merge of rust-lang#129343 - estebank:time-version, r=jieyouxu" This reverts commit 26f75a6, reversing changes made to 2572e0e.
Partially mitigate the fallout from #127343. Although the biggest benefit of this would have been if we had had this in 1.80 before it became stable, the long-tail of that change will be felt for a long time, so better late than never.
We can also emit an even more targeted error instead of this inference failure.