-
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
Merge check_mod_impl_wf
and check_mod_type_wf
#121154
Conversation
@bors try @rust-timer queue |
rustbot has assigned @compiler-errors. Use r? to explicitly pick a reviewer |
This comment has been minimized.
This comment has been minimized.
Merge `check_mod_impl_wf` and `check_mod_type_wf` This still causes some funny diagnostics, but I'm not sure they can be fixed without a larger change, which I'd like to avoid here.
// Check impls constrain their parameters | ||
let res = | ||
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_impl_wf(module)); | ||
tcx.hir().par_for_each_module(|module| { | ||
let _ = tcx.ensure().check_mod_type_wf(module); | ||
}); | ||
|
||
for &trait_def_id in tcx.all_local_trait_impls(()).keys() { | ||
let _ = tcx.ensure().coherent_trait(trait_def_id); | ||
} | ||
// these queries are executed for side-effects (error reporting): | ||
let _ = tcx.ensure().crate_inherent_impls(()); | ||
let _ = tcx.ensure().crate_inherent_impls_overlap_check(()); | ||
res | ||
})?; | ||
}); |
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.
Just removing this early abort causes annoying diagnostics that are hard to make good. So what I did instead was to inline the check_mod_impl_wf
checks directly into the individual check_well_formed
of impl items and early abort per item. So that only items with errors in impl_wf
checks don't get their type_wf
run, but other items do
compiler/rustc_resolve/src/late.rs
Outdated
if let GenericParamKind::Lifetime = param.kind { | ||
// Record lifetime res, so lowering knows there is something fishy. | ||
self.record_lifetime_param(param.id, LifetimeRes::Error); | ||
} | ||
let rib = match param.kind { | ||
GenericParamKind::Lifetime => { | ||
// Record lifetime res, so lowering knows there is something fishy. | ||
self.record_lifetime_param(param.id, LifetimeRes::Error); | ||
continue; | ||
} | ||
GenericParamKind::Type { .. } => &mut function_type_rib, | ||
GenericParamKind::Const { .. } => &mut function_value_rib, | ||
}; | ||
|
||
self.r.record_partial_res(param.id, PartialRes::new(Res::Err)); | ||
rib.bindings.insert(ident, Res::Err); |
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.
Without this change we'd get a "duplicate generic param T" error followed by an "unused generic param T" error for
struct Foo<T, T>(T);
The latter error makes no sense, so I turned the second T
into a Res::Err
, which hides follow-up errors
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.
Add as a comment too.
compiler/rustc_traits/src/codegen.rs
Outdated
if impl_source.has_infer() { | ||
infcx.tcx.dcx().has_errors().unwrap(); | ||
return Err(CodegenObligationError::FulfillmentError); | ||
} |
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.
Unused lifetimes on an impl get replaced with inference vars, but never resolved, causing the return value of a query to contain inference vars, which is
- bad
- ICEs in stable hashing (good!)
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 put this comment as a comment in the code?
error[E0282]: type annotations needed | ||
--> $DIR/issue-87340.rs:11:23 | ||
| | ||
LL | fn f() -> Self::I {} | ||
| ^^ cannot infer type for type parameter `T` |
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.
annoying to prevent, but I'll figure it out, preferably in a follow-up PR
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (24e3e17): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 638.252s -> 637.587s (-0.10%) |
ade1cd7
to
13d26b3
Compare
☔ The latest upstream changes (presumably #121327) made this pull request unmergeable. Please resolve the merge conflicts. |
13d26b3
to
15c5aba
Compare
☔ The latest upstream changes (presumably #121356) made this pull request unmergeable. Please resolve the merge conflicts. |
15c5aba
to
e58e32c
Compare
☔ The latest upstream changes (presumably #121400) made this pull request unmergeable. Please resolve the merge conflicts. |
e58e32c
to
fbe7943
Compare
Merge `collect_mod_item_types` query into `check_well_formed` follow-up to rust-lang#121154 r? `@ghost`
☔ The latest upstream changes (presumably #119106) made this pull request unmergeable. Please resolve the merge conflicts. |
fbe7943
to
5c27d71
Compare
☔ The latest upstream changes (presumably #121870) made this pull request unmergeable. Please resolve the merge conflicts. |
Merge `collect_mod_item_types` query into `check_well_formed` follow-up to rust-lang#121154 this removes more potential parallel-compiler bottlenecks and moves diagnostics for the same items next to each other, instead of grouping diagnostics by analysis kind
Finished benchmarking commit (8c9a75b): 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)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 647.185s -> 648.501s (0.20%) |
Merge `collect_mod_item_types` query into `check_well_formed` follow-up to rust-lang#121154 this removes more potential parallel-compiler bottlenecks and moves diagnostics for the same items next to each other, instead of grouping diagnostics by analysis kind
Merge `collect_mod_item_types` query into `check_well_formed` follow-up to rust-lang#121154 this removes more potential parallel-compiler bottlenecks and moves diagnostics for the same items next to each other, instead of grouping diagnostics by analysis kind
Merge `collect_mod_item_types` query into `check_well_formed` follow-up to rust-lang/rust#121154 this removes more potential parallel-compiler bottlenecks and moves diagnostics for the same items next to each other, instead of grouping diagnostics by analysis kind
Silence some follow-up errors on trait impls in case the trait has conflicting or otherwise incoherent impls fixes rust-lang#123292 Also removes a bunch of extra diagnostics that were introduced in rust-lang#121154 and rust-lang#120558
Silence some follow-up errors on trait impls in case the trait has conflicting or otherwise incoherent impls fixes rust-lang#123292 Also removes a bunch of extra diagnostics that were introduced in rust-lang#121154 and rust-lang#120558
Silence some follow-up errors on trait impls in case the trait has conflicting or otherwise incoherent impls fixes rust-lang#123292 Also removes a bunch of extra diagnostics that were introduced in rust-lang#121154 and rust-lang#120558
Silence some follow-up errors on trait impls in case the trait has conflicting or otherwise incoherent impls fixes #123292 Also removes a bunch of extra diagnostics that were introduced in rust-lang/rust#121154 and rust-lang/rust#120558
This still causes some funny diagnostics, but I'm not sure they can be fixed without a larger change, which I'd like to avoid here.
Reducing the number of times we iterate over the same items at this high level helps avoid parallel-compiler bottlenecks.