-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tuples containing references no longer pass PartialEq bounds check for all lifetimes of the other reference #112895
Comments
searched nightlies: from nightly-2023-03-01 to nightly-2023-06-21 bisected with cargo-bisect-rustc v0.6.5Host triple: aarch64-unknown-linux-gnu cargo bisect-rustc --start=2023-03-01 This probably regressed in #109470. |
I don't know if this predicate should have held in the first place 🤔 fn test<'a>() where (&'a str, u32): for<'b> PartialEq<(&'b str, u32)> {}
fn main() {
test();
}
I think code demonstrates that |
The previous behavior is unsound, demonstrated by this code which passed in 1.69 and fails in 1.70: trait Lengthen<T> {
fn lengthen(self) -> T;
}
impl<'a> Lengthen<&'a str> for &'a str {
fn lengthen(self) -> &'a str { self }
}
trait Gat {
type Gat<'a>: for<'b> Lengthen<Self::Gat<'b>>;
fn lengthen(s: Self::Gat<'_>) -> Self::Gat<'static> {
s.lengthen()
}
}
impl Gat for () {
type Gat<'a> = &'a str;
}
fn main() {
let s = "hello, garbage".to_string();
let borrow: &'static str = <() as Gat>::lengthen(&s);
drop(s);
println!("{borrow}");
} |
fwiw this could possible pass if the |
I think there are two actionable steps there:
|
(1.) is not feasible, I think. See the crater results for #112899 But yeah, we should add a test for the unsoundness I shared above. |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
Breaking code via breaking inference is, strictly speaking, a permitted breakage. |
Is there a way to measure the impact of that crater run on the ecosystemt? Breakage in serde or chrono would be surely a more serious problem than a breakage in a toy application and with untrained eye I can't tell if the breakage is disastrous or just a little beyond acceptable. Improving the |
The stdlib's implementations are largely unrelated to the edition mechanism: the editions mostly introduce syntactic changes, not library changes, with the one blurriness being with macros which interact with syntax. What really needs to improve is the algorithm for deducing types, then it would be easier for the stdlib to carry more powerful implementations without fear of breaking inference. |
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…fee1-dead Rollup of 9 pull requests Successful merges: - rust-lang#111119 (style-guide: Add chapter about formatting for nightly-only syntax) - rust-lang#112791 (llvm ffi: Expose `CallInst->setTailCallKind`) - rust-lang#113145 (style-guide: Document newline rules for assignment operators) - rust-lang#113163 (Add a regression test for rust-lang#112895) - rust-lang#113332 (resolve: Use `Interned` for some interned structures) - rust-lang#113334 (Revert the lexing of `c"…"` string literals) - rust-lang#113350 (Fix the issue of wrong diagnosis for extern pub fn) - rust-lang#113371 (Fix submodule handling when the current branch is named after a tag) - rust-lang#113384 (style-guide: Clarify grammar for small patterns (not a semantic change)) r? `@ghost` `@rustbot` modify labels: rollup
Code
I tried this code:
It used to compile on 1.69, so I expected it to compile under 1.70, but it failed with the following error
The same happens for structs that contain a reference and derive
PartialEq
.(godbolt link)
Version it worked on
1.69
Version with regression
1.70
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
The text was updated successfully, but these errors were encountered: