-
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
Properly deal with missing/placeholder types inside GACs #125457
Properly deal with missing/placeholder types inside GACs #125457
Conversation
compiler/rustc_hir_typeck/src/lib.rs
Outdated
@@ -236,9 +236,17 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti | |||
&& let ty::AssocKind::Const = item.kind | |||
&& let ty::ImplContainer = item.container | |||
&& let Some(trait_item) = item.trait_item_def_id | |||
// We don't want to call `tcx.compare_impl_const` here to avoid cycle errors. This is a | |||
// very naive check to prevent us from messing up the generic param instantiation below. | |||
&& tcx.generics_of(def_id).own_counts() == tcx.generics_of(trait_item).own_counts() |
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 we use https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.check_args_compatible ? Perhaps after rebasing the const onto the impl?
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, similar to what we do when we have a mismatch between GAT params in a trait and impl
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.
Thanks for the pointer, I'll check!
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.
relevant callsite:
rust/compiler/rustc_trait_selection/src/traits/project.rs
Lines 2108 to 2115 in 9c8a58f
if !tcx.check_args_compatible(assoc_ty.item.def_id, args) { | |
let err = Ty::new_error_with_message( | |
tcx, | |
obligation.cause.span, | |
"impl item and trait item have different parameters", | |
); | |
Progress { term: err.into(), obligations: nested } | |
} else { |
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.
Applied. Great idea, thanks!
ecb118e
to
39d9b84
Compare
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.
r=me if ci is green
@bors r=compiler-errors rollup |
☀️ Test successful - checks-actions |
Finished benchmarking commit (7c54789): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.634s -> 673.551s (-0.01%) |
Fixes #124833.
r? oli-obk (#123130)