Rollup merge of #98420 - davidtwco:translation-lint-fixes-and-more-migration, r=compiler-errors
translation: lint fix + more migration - Unfortunately, the diagnostic lints are very broken and trigger much more often than they should. This PR corrects the conditional which checks if the function call being made is to a diagnostic function so that it returns in every intended case. - The `rustc_lint_diagnostics` attribute is used by the diagnostic translation/struct migration lints to identify calls where non-translatable diagnostics or diagnostics outwith impls are being created. Any function used in creating a diagnostic should be annotated with this attribute so this PR adds the attribute to many more functions. - Port the diagnostics from the `rustc_privacy` crate and enable the lints for that crate. r? ``@compiler-errors``
This commit is contained in:
commit
400f435c2d
14 changed files with 189 additions and 48 deletions
|
@ -406,9 +406,12 @@ impl LateLintPass<'_> for Diagnostics {
|
|||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
let Some((span, def_id, substs)) = typeck_results_of_method_fn(cx, expr) else { return };
|
||||
debug!(?span, ?def_id, ?substs);
|
||||
if let Ok(Some(instance)) = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, substs) &&
|
||||
!cx.tcx.has_attr(instance.def_id(), sym::rustc_lint_diagnostics)
|
||||
{
|
||||
let has_attr = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, substs)
|
||||
.ok()
|
||||
.and_then(|inst| inst)
|
||||
.map(|inst| cx.tcx.has_attr(inst.def_id(), sym::rustc_lint_diagnostics))
|
||||
.unwrap_or(false);
|
||||
if !has_attr {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue