Delay evaluating lint primary message until after it would be suppressed

This commit is contained in:
Michael Goulet
2022-10-02 06:30:49 +00:00
parent edadc7ccdd
commit f088e543cb
3 changed files with 23 additions and 1 deletions

View File

@@ -354,7 +354,6 @@ pub fn struct_lint_level<'s, 'd>(
(Level::Deny | Level::Forbid, None) => sess.diagnostic().struct_err_lint(""),
};
err.set_primary_message(msg);
err.set_is_lint();
// If this code originates in a foreign macro, aka something that this crate
@@ -379,6 +378,10 @@ pub fn struct_lint_level<'s, 'd>(
}
}
// Delay evaluating and setting the primary message until after we've
// suppressed the lint due to macros.
err.set_primary_message(msg);
// Lint diagnostics that are covered by the expect level will not be emitted outside
// the compiler. It is therefore not necessary to add any information for the user.
// This will therefore directly call the decorate function which will in turn emit