-
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
Method chain nitpicks #105985
Method chain nitpicks #105985
Conversation
This has a 10000000% chance of us causing a cycle if we're not careful
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| { |
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 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 { |
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 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) |
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.
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 |
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 span (correctly) shouldn't be a primary span, I think.
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.
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.
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.
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...
@bors r+ |
…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
…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
Just fixing some little things I didn't see in review from that method chain PR.
r? @estebank