Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 25ff9b6

Browse files
Use bool in favor of Option<()> for diagnostics
1 parent 4d5b3b1 commit 25ff9b6

File tree

48 files changed

+106
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+106
-121
lines changed

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
8686
// Multiple different abi names may actually be the same ABI
8787
// If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
8888
let source_map = self.tcx.sess.source_map();
89-
let equivalent = (source_map.span_to_snippet(*prev_sp)
90-
!= source_map.span_to_snippet(*abi_span))
91-
.then_some(());
89+
let equivalent = source_map.span_to_snippet(*prev_sp)
90+
!= source_map.span_to_snippet(*abi_span);
9291

9392
self.dcx().emit_err(AbiSpecifiedMultipleTimes {
9493
abi_span: *abi_span,

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub struct AbiSpecifiedMultipleTimes {
184184
#[label]
185185
pub prev_span: Span,
186186
#[note]
187-
pub equivalent: Option<()>,
187+
pub equivalent: bool,
188188
}
189189

190190
#[derive(Diagnostic)]

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -963,14 +963,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
963963
self_ty,
964964
items,
965965
}) => {
966-
let error =
967-
|annotation_span, annotation, only_trait: bool| errors::InherentImplCannot {
968-
span: self_ty.span,
969-
annotation_span,
970-
annotation,
971-
self_ty: self_ty.span,
972-
only_trait: only_trait.then_some(()),
973-
};
966+
let error = |annotation_span, annotation, only_trait| errors::InherentImplCannot {
967+
span: self_ty.span,
968+
annotation_span,
969+
annotation,
970+
self_ty: self_ty.span,
971+
only_trait,
972+
};
974973

975974
self.with_in_trait_impl(None, |this| {
976975
this.visibility_not_permitted(
@@ -1195,7 +1194,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11951194
} else if where_clauses.after.has_where_token {
11961195
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
11971196
span: where_clauses.after.span,
1198-
help: self.session.is_nightly_build().then_some(()),
1197+
help: self.session.is_nightly_build(),
11991198
});
12001199
}
12011200
}

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pub struct InherentImplCannot<'a> {
484484
#[label(ast_passes_type)]
485485
pub self_ty: Span,
486486
#[note(ast_passes_only_trait)]
487-
pub only_trait: Option<()>,
487+
pub only_trait: bool,
488488
}
489489

490490
#[derive(Diagnostic)]
@@ -528,7 +528,7 @@ pub struct WhereClauseAfterTypeAlias {
528528
#[primary_span]
529529
pub span: Span,
530530
#[help]
531-
pub help: Option<()>,
531+
pub help: bool,
532532
}
533533

534534
#[derive(Diagnostic)]

compiler/rustc_attr/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ pub fn find_deprecation(
846846
sess.dcx().emit_err(
847847
session_diagnostics::DeprecatedItemSuggestion {
848848
span: mi.span,
849-
is_nightly: sess.is_nightly_build().then_some(()),
849+
is_nightly: sess.is_nightly_build(),
850850
details: (),
851851
},
852852
);

compiler/rustc_attr/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub(crate) struct DeprecatedItemSuggestion {
342342
pub span: Span,
343343

344344
#[help]
345-
pub is_nightly: Option<()>,
345+
pub is_nightly: bool,
346346

347347
#[note]
348348
pub details: (),

compiler/rustc_const_eval/src/check_consts/ops.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
384384
ccx.dcx().create_err(errors::UnallowedHeapAllocations {
385385
span,
386386
kind: ccx.const_kind(),
387-
teach: ccx.tcx.sess.teach(E0010).then_some(()),
387+
teach: ccx.tcx.sess.teach(E0010),
388388
})
389389
}
390390
}
@@ -444,16 +444,16 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
444444
if let hir::ConstContext::Static(_) = ccx.const_kind() {
445445
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
446446
span,
447-
opt_help: Some(()),
447+
opt_help: true,
448448
kind: ccx.const_kind(),
449-
teach: ccx.tcx.sess.teach(E0492).then_some(()),
449+
teach: ccx.tcx.sess.teach(E0492),
450450
})
451451
} else {
452452
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
453453
span,
454-
opt_help: None,
454+
opt_help: false,
455455
kind: ccx.const_kind(),
456-
teach: ccx.tcx.sess.teach(E0492).then_some(()),
456+
teach: ccx.tcx.sess.teach(E0492),
457457
})
458458
}
459459
}
@@ -481,12 +481,12 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
481481
hir::BorrowKind::Raw => ccx.tcx.dcx().create_err(errors::UnallowedMutableRaw {
482482
span,
483483
kind: ccx.const_kind(),
484-
teach: ccx.tcx.sess.teach(E0764).then_some(()),
484+
teach: ccx.tcx.sess.teach(E0764),
485485
}),
486486
hir::BorrowKind::Ref => ccx.dcx().create_err(errors::UnallowedMutableRefs {
487487
span,
488488
kind: ccx.const_kind(),
489-
teach: ccx.tcx.sess.teach(E0764).then_some(()),
489+
teach: ccx.tcx.sess.teach(E0764),
490490
}),
491491
}
492492
}

compiler/rustc_const_eval/src/errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub(crate) struct UnallowedMutableRefs {
151151
pub span: Span,
152152
pub kind: ConstContext,
153153
#[note(const_eval_teach_note)]
154-
pub teach: Option<()>,
154+
pub teach: bool,
155155
}
156156

157157
#[derive(Diagnostic)]
@@ -161,7 +161,7 @@ pub(crate) struct UnallowedMutableRaw {
161161
pub span: Span,
162162
pub kind: ConstContext,
163163
#[note(const_eval_teach_note)]
164-
pub teach: Option<()>,
164+
pub teach: bool,
165165
}
166166
#[derive(Diagnostic)]
167167
#[diag(const_eval_non_const_fmt_macro_call, code = E0015)]
@@ -196,7 +196,7 @@ pub(crate) struct UnallowedHeapAllocations {
196196
pub span: Span,
197197
pub kind: ConstContext,
198198
#[note(const_eval_teach_note)]
199-
pub teach: Option<()>,
199+
pub teach: bool,
200200
}
201201

202202
#[derive(Diagnostic)]
@@ -214,10 +214,10 @@ pub(crate) struct InteriorMutableDataRefer {
214214
#[label]
215215
pub span: Span,
216216
#[help]
217-
pub opt_help: Option<()>,
217+
pub opt_help: bool,
218218
pub kind: ConstContext,
219219
#[note(const_eval_teach_note)]
220-
pub teach: Option<()>,
220+
pub teach: bool,
221221
}
222222

223223
#[derive(Diagnostic)]

compiler/rustc_expand/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ pub(crate) struct IncompleteParse<'a> {
281281
pub macro_path: &'a ast::Path,
282282
pub kind_name: &'a str,
283283
#[note(expand_macro_expands_to_match_arm)]
284-
pub expands_to_match_arm: Option<()>,
284+
pub expands_to_match_arm: bool,
285285

286286
#[suggestion(
287287
expand_suggestion_add_semi,

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ pub(crate) fn ensure_complete_parse<'a>(
10311031
label_span: span,
10321032
macro_path,
10331033
kind_name,
1034-
expands_to_match_arm: expands_to_match_arm.then_some(()),
1034+
expands_to_match_arm,
10351035
add_semicolon,
10361036
});
10371037
}

0 commit comments

Comments
 (0)