Skip to content

Commit 4492c19

Browse files
authored
Unrolled build for rust-lang#118989
Rollup merge of rust-lang#118989 - compiler-errors:lint-decorator-2, r=WaffleLapkin Simplify lint decorator derive too See last commit, since this is stacked on top of rust-lang#118727. r? WaffleLapkin
2 parents 5c927ab + 108bec6 commit 4492c19

File tree

4 files changed

+17
-68
lines changed

4 files changed

+17
-68
lines changed

compiler/rustc_errors/src/diagnostic.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ where
9191
#[rustc_diagnostic_item = "DecorateLint"]
9292
pub trait DecorateLint<'a, G: EmissionGuarantee> {
9393
/// Decorate and emit a lint.
94-
fn decorate_lint<'b>(
95-
self,
96-
diag: &'b mut DiagnosticBuilder<'a, G>,
97-
) -> &'b mut DiagnosticBuilder<'a, G>;
94+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, G>);
9895

9996
fn msg(&self) -> DiagnosticMessage;
10097
}

compiler/rustc_lint/src/lints.rs

+11-45
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,8 @@ pub struct BuiltinMissingDebugImpl<'a> {
134134

135135
// Needed for def_path_str
136136
impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> {
137-
fn decorate_lint<'b>(
138-
self,
139-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
140-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
137+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
141138
diag.set_arg("debug", self.tcx.def_path_str(self.def_id));
142-
diag
143139
}
144140

145141
fn msg(&self) -> DiagnosticMessage {
@@ -243,17 +239,13 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
243239
}
244240

245241
impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
246-
fn decorate_lint<'b>(
247-
self,
248-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
249-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
242+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
250243
diag.span_label(self.label, fluent::lint_label);
251244
rustc_session::parse::add_feature_diagnostics(
252245
diag,
253246
self.parse_sess,
254247
sym::async_fn_track_caller,
255248
);
256-
diag
257249
}
258250

259251
fn msg(&self) -> DiagnosticMessage {
@@ -433,10 +425,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
433425
}
434426

435427
impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
436-
fn decorate_lint<'b>(
437-
self,
438-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
439-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
428+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
440429
diag.set_arg("ty", self.ty);
441430
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
442431
if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
@@ -447,7 +436,6 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
447436
);
448437
}
449438
self.sub.add_to_diagnostic(diag);
450-
diag
451439
}
452440

453441
fn msg(&self) -> rustc_errors::DiagnosticMessage {
@@ -1159,10 +1147,7 @@ pub struct NonFmtPanicUnused {
11591147

11601148
// Used because of two suggestions based on one Option<Span>
11611149
impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
1162-
fn decorate_lint<'b>(
1163-
self,
1164-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
1165-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
1150+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
11661151
diag.set_arg("count", self.count);
11671152
diag.note(fluent::lint_note);
11681153
if let Some(span) = self.suggestion {
@@ -1179,7 +1164,6 @@ impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
11791164
Applicability::MachineApplicable,
11801165
);
11811166
}
1182-
diag
11831167
}
11841168

11851169
fn msg(&self) -> rustc_errors::DiagnosticMessage {
@@ -1358,12 +1342,9 @@ pub struct DropTraitConstraintsDiag<'a> {
13581342

13591343
// Needed for def_path_str
13601344
impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
1361-
fn decorate_lint<'b>(
1362-
self,
1363-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
1364-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
1345+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
13651346
diag.set_arg("predicate", self.predicate);
1366-
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
1347+
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id));
13671348
}
13681349

13691350
fn msg(&self) -> rustc_errors::DiagnosticMessage {
@@ -1378,11 +1359,8 @@ pub struct DropGlue<'a> {
13781359

13791360
// Needed for def_path_str
13801361
impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
1381-
fn decorate_lint<'b>(
1382-
self,
1383-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
1384-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
1385-
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
1362+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1363+
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id));
13861364
}
13871365

13881366
fn msg(&self) -> rustc_errors::DiagnosticMessage {
@@ -1655,10 +1633,7 @@ pub struct ImproperCTypes<'a> {
16551633

16561634
// Used because of the complexity of Option<DiagnosticMessage>, DiagnosticMessage, and Option<Span>
16571635
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
1658-
fn decorate_lint<'b>(
1659-
self,
1660-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
1661-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
1636+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
16621637
diag.set_arg("ty", self.ty);
16631638
diag.set_arg("desc", self.desc);
16641639
diag.span_label(self.label, fluent::lint_label);
@@ -1669,7 +1644,6 @@ impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
16691644
if let Some(note) = self.span_note {
16701645
diag.span_note(note, fluent::lint_note);
16711646
}
1672-
diag
16731647
}
16741648

16751649
fn msg(&self) -> rustc_errors::DiagnosticMessage {
@@ -1802,10 +1776,7 @@ pub enum UnusedDefSuggestion {
18021776

18031777
// Needed because of def_path_str
18041778
impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
1805-
fn decorate_lint<'b>(
1806-
self,
1807-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
1808-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
1779+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
18091780
diag.set_arg("pre", self.pre);
18101781
diag.set_arg("post", self.post);
18111782
diag.set_arg("def", self.cx.tcx.def_path_str(self.def_id));
@@ -1816,7 +1787,6 @@ impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
18161787
if let Some(sugg) = self.suggestion {
18171788
diag.subdiagnostic(sugg);
18181789
}
1819-
diag
18201790
}
18211791

18221792
fn msg(&self) -> rustc_errors::DiagnosticMessage {
@@ -1889,15 +1859,11 @@ pub struct AsyncFnInTraitDiag {
18891859
}
18901860

18911861
impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
1892-
fn decorate_lint<'b>(
1893-
self,
1894-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
1895-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
1862+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
18961863
diag.note(fluent::lint_note);
18971864
if let Some(sugg) = self.sugg {
18981865
diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect);
18991866
}
1900-
diag
19011867
}
19021868

19031869
fn msg(&self) -> rustc_errors::DiagnosticMessage {

compiler/rustc_macros/src/diagnostics/diagnostic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ impl<'a> LintDiagnosticDerive<'a> {
175175
fn decorate_lint<'__b>(
176176
self,
177177
#diag: &'__b mut rustc_errors::DiagnosticBuilder<'__a, ()>
178-
) -> &'__b mut rustc_errors::DiagnosticBuilder<'__a, ()> {
178+
) {
179179
use rustc_errors::IntoDiagnosticArg;
180-
#implementation
180+
#implementation;
181181
}
182182

183183
fn msg(&self) -> rustc_errors::DiagnosticMessage {

compiler/rustc_mir_transform/src/errors.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,7 @@ pub(crate) struct UnsafeOpInUnsafeFn {
180180

181181
impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
182182
#[track_caller]
183-
fn decorate_lint<'b>(
184-
self,
185-
diag: &'b mut DiagnosticBuilder<'a, ()>,
186-
) -> &'b mut DiagnosticBuilder<'a, ()> {
183+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
187184
let handler = diag.handler().expect("lint should not yet be emitted");
188185
let desc = handler.eagerly_translate_to_string(self.details.label(), [].into_iter());
189186
diag.set_arg("details", desc);
@@ -198,8 +195,6 @@ impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
198195
Applicability::MaybeIncorrect,
199196
);
200197
}
201-
202-
diag
203198
}
204199

205200
fn msg(&self) -> DiagnosticMessage {
@@ -213,19 +208,14 @@ pub(crate) enum AssertLint<P> {
213208
}
214209

215210
impl<'a, P: std::fmt::Debug> DecorateLint<'a, ()> for AssertLint<P> {
216-
fn decorate_lint<'b>(
217-
self,
218-
diag: &'b mut DiagnosticBuilder<'a, ()>,
219-
) -> &'b mut DiagnosticBuilder<'a, ()> {
211+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
220212
let span = self.span();
221213
let assert_kind = self.panic();
222214
let message = assert_kind.diagnostic_message();
223215
assert_kind.add_args(&mut |name, value| {
224216
diag.set_arg(name, value);
225217
});
226218
diag.span_label(span, message);
227-
228-
diag
229219
}
230220

231221
fn msg(&self) -> DiagnosticMessage {
@@ -284,10 +274,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> {
284274

285275
// Needed for def_path_str
286276
impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
287-
fn decorate_lint<'b>(
288-
self,
289-
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
290-
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
277+
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
291278
diag.span_label(self.yield_sp, fluent::_subdiag::label);
292279
if let Some(reason) = self.reason {
293280
diag.subdiagnostic(reason);
@@ -296,7 +283,6 @@ impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
296283
diag.set_arg("pre", self.pre);
297284
diag.set_arg("def_path", self.tcx.def_path_str(self.def_id));
298285
diag.set_arg("post", self.post);
299-
diag
300286
}
301287

302288
fn msg(&self) -> rustc_errors::DiagnosticMessage {

0 commit comments

Comments
 (0)