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

Method chain nitpicks #105985

Merged
merged 5 commits into from
Dec 22, 2022
Merged

Conversation

compiler-errors
Copy link
Member

Just fixing some little things I didn't see in review from that method chain PR.

r? @estebank

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 21, 2022
if a == b || matches!(a.kind(), ty::Infer(_)) || matches!(b.kind(), ty::Infer(_)) {
return Ok(a);
}
relate::super_relate_tys(self, a, b).or_else(|e| {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will treat int/float infer variables equal to non-int/floats, which is probably incorrect.

call_hir_id: HirId,
) {
let tcx = self.tcx;
let hir = tcx.hir();
if let Some(Node::Expr(expr)) = hir.find(arg_hir_id) {
let parent_id = hir.get_parent_item(arg_hir_id);
let typeck_results: &TypeckResults<'tcx> = match &self.typeck_results {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very likely to cause a cycle if used incorrectly, since these function argument obligations are always going to come from the same body as we're checking.

@@ -3182,37 +3179,29 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let mut type_diffs = vec![];

if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref()
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instantiating identity substitutions will cause us to collect unnecesary type errors that wouldn't show up after substitution -- see the UI test that changed.

|
LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>`
LL | .iter()
| ------ `Iterator::Item` is `&{integer}` here
LL | .map(|x| x * 2)
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here
| -------------- `Iterator::Item` changed to `{integer}` here
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This span (correctly) shouldn't be a primary span, I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea behind these where "this is where the type was correct, and this is where it wasn't" for the primary spans, but it works either way.

Copy link
Member Author

@compiler-errors compiler-errors Dec 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I'm not sure if I understand why it was counting this as an incorrect span in the first place 😅

Or perhaps I just misunderstood the logic -- from what I read, it seemed to only count something as a primary span if it was the "source" of a type error...

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 21, 2022

📌 Commit 85a9d85 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 21, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 22, 2022
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#105837 (Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity)
 - rust-lang#105932 (Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15)
 - rust-lang#105960 (Various cleanups)
 - rust-lang#105985 (Method chain nitpicks)
 - rust-lang#105996 (Test that async blocks are `UnwindSafe`)
 - rust-lang#106012 (Clarify that raw retags are not permitted in Mir)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 66544b5 into rust-lang:master Dec 22, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 22, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#105837 (Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity)
 - rust-lang#105932 (Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15)
 - rust-lang#105960 (Various cleanups)
 - rust-lang#105985 (Method chain nitpicks)
 - rust-lang#105996 (Test that async blocks are `UnwindSafe`)
 - rust-lang#106012 (Clarify that raw retags are not permitted in Mir)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@compiler-errors compiler-errors deleted the method-chain-nitpicks branch August 11, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants