-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Always make tuple elements a coercion site #147834
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
base: master
Are you sure you want to change the base?
Conversation
|
|
|
|
||
| /// Returns a list of tuple type arguments, or `None` if `self` isn't a tuple. | ||
| #[inline] | ||
| pub fn tuple(self) -> Option<&'tcx List<Ty<'tcx>>> { |
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.
| pub fn tuple(self) -> Option<&'tcx List<Ty<'tcx>>> { | |
| pub fn opt_tuple_fields(self) -> Option<&'tcx List<Ty<'tcx>>> { |
seems like it does the same thing as tuple_fields it just doesnt panic
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.
That is indeed the case, is there a problem with that? In the code I wrote I found this a lot more convenient than checking the type first.
tests/ui/tuple/coercion.rs
Outdated
| // This one can't work without a redesign on the coercion system. | ||
| // We currently only eagerly add never-to-any coercions, not any others. | ||
| // Thus, because we don't have an expectation when typechecking `&[]`, | ||
| // we don't add a coercion => this doesn't work. | ||
| let y = (&[],); | ||
| let _: (&[u8],) = y; //~ error: mismatched types |
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.
can you split the failing cases out to a different test so that the working stuff can be marked // @check-pass . It's also nice because this change probably needs an FCP because we start allowing more code to compile so having a simple "this is the test that now passes" is nice
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.
I've split the tests
|
@bors try @rust-timer queue should crater this as it is theoretically breaking, though I don't actually expect any breakage here 🤔 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Always make tuple elements a coercion site
|
When we stabilize the never type do we intend to change how NeverToAny coercions work? Will we continue unconditionally coercing |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (f77b5bc): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.4%, secondary -1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.1%, secondary -3.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 473.373s -> 475.58s (0.47%) |
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
I don't expect / haven't heard of any desire to make any changes with how we insert NeverToAny coercions. |
f43cd30 to
5e6e9dc
Compare
5e6e9dc to
74c8722
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
Previously we only used
check_expr_coercible_to_typeif we had an expectation (usingcheck_expr_with_expectation(NoExpectation)otherwise). Normally that'd be fine, because without an expectation we can't insert a coercion anyway. However, for the case of never-to-any coercion specifically, we do insert it eagerly, so this prevents some code from compiling, for example:With this PR we are always using
check_expr_coercible_to_type(using an infer var if there is no expectation), which allows slightly more code to compile.Fixes #112856
r? BoxyUwU