Skip to content
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

Rollup of 10 pull requests #129359

Merged
merged 27 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
78caecf
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF plat…
khuey Aug 4, 2024
e587855
Use Span::is_dummy().
khuey Aug 4, 2024
5dc4a19
Fix warning.
khuey Aug 4, 2024
1350a65
Remove a Redundant Conditional Check
veera-sivarajan Aug 8, 2024
c8ae02f
CFI: Erase regions when projecting ADT to its transparent non-1zst field
compiler-errors Aug 17, 2024
25964b5
Reword the "unreachable pattern" explanations
Nadrieril Aug 19, 2024
efb28bd
Add a note with a link to explain empty types
Nadrieril Aug 19, 2024
36eced4
Cap the number of patterns pointed to by the lint
Nadrieril Aug 19, 2024
3c735a0
Add a test.
khuey Aug 20, 2024
4e9725c
Add a comment.
khuey Aug 20, 2024
f30392a
Move the "matches no value" note to be a span label
Nadrieril Aug 20, 2024
e424e7f
Avoid extra `cast()`s after `CStr::as_ptr()`
cuviper Aug 20, 2024
0f5c6ea
Make `ArgAbi::make_indirect_force` more specific
beetrees Aug 21, 2024
25ff9b6
Use bool in favor of Option<()> for diagnostics
compiler-errors Aug 21, 2024
0b2525c
Simplify some redundant field names
compiler-errors Aug 21, 2024
9010708
fix comment on PlaceMention semantics
RalfJung Aug 21, 2024
123bb58
Fix stability attribute of `impl !Error for &str`
tbu- Aug 20, 2024
dea325e
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
matthiaskrgr Aug 21, 2024
48c9864
Rollup merge of #128843 - veera-sivarajan:small-cleanup, r=davidtwco
matthiaskrgr Aug 21, 2024
7da4b2d
Rollup merge of #129179 - compiler-errors:cfi-erase-transparent, r=da…
matthiaskrgr Aug 21, 2024
9bb17d3
Rollup merge of #129281 - Nadrieril:tweak-unreachable-lint-wording, r…
matthiaskrgr Aug 21, 2024
349f299
Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb
matthiaskrgr Aug 21, 2024
e961d6b
Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors
matthiaskrgr Aug 21, 2024
be80216
Rollup merge of #129339 - beetrees:make-indirect-from-ignore, r=RalfJung
matthiaskrgr Aug 21, 2024
937a18d
Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostic…
matthiaskrgr Aug 21, 2024
4137f3b
Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxu
matthiaskrgr Aug 21, 2024
9fd2832
Rollup merge of #129355 - RalfJung:PlaceMention, r=compiler-errors
matthiaskrgr Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use bool in favor of Option<()> for diagnostics
  • Loading branch information
compiler-errors committed Aug 21, 2024
commit 25ff9b6bcbba9e7831eb4d6eba2df6bbcd267c55
5 changes: 2 additions & 3 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
@@ -86,9 +86,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// Multiple different abi names may actually be the same ABI
// If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
let source_map = self.tcx.sess.source_map();
let equivalent = (source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span))
.then_some(());
let equivalent = source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span);

self.dcx().emit_err(AbiSpecifiedMultipleTimes {
abi_span: *abi_span,
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ pub struct AbiSpecifiedMultipleTimes {
#[label]
pub prev_span: Span,
#[note]
pub equivalent: Option<()>,
pub equivalent: bool,
}

#[derive(Diagnostic)]
17 changes: 8 additions & 9 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
@@ -963,14 +963,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
self_ty,
items,
}) => {
let error =
|annotation_span, annotation, only_trait: bool| errors::InherentImplCannot {
span: self_ty.span,
annotation_span,
annotation,
self_ty: self_ty.span,
only_trait: only_trait.then_some(()),
};
let error = |annotation_span, annotation, only_trait| errors::InherentImplCannot {
span: self_ty.span,
annotation_span,
annotation,
self_ty: self_ty.span,
only_trait,
};

self.with_in_trait_impl(None, |this| {
this.visibility_not_permitted(
@@ -1195,7 +1194,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
} else if where_clauses.after.has_where_token {
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
span: where_clauses.after.span,
help: self.session.is_nightly_build().then_some(()),
help: self.session.is_nightly_build(),
});
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
@@ -484,7 +484,7 @@ pub struct InherentImplCannot<'a> {
#[label(ast_passes_type)]
pub self_ty: Span,
#[note(ast_passes_only_trait)]
pub only_trait: Option<()>,
pub only_trait: bool,
}

#[derive(Diagnostic)]
@@ -528,7 +528,7 @@ pub struct WhereClauseAfterTypeAlias {
#[primary_span]
pub span: Span,
#[help]
pub help: Option<()>,
pub help: bool,
}

#[derive(Diagnostic)]
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -846,7 +846,7 @@ pub fn find_deprecation(
sess.dcx().emit_err(
session_diagnostics::DeprecatedItemSuggestion {
span: mi.span,
is_nightly: sess.is_nightly_build().then_some(()),
is_nightly: sess.is_nightly_build(),
details: (),
},
);
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
@@ -342,7 +342,7 @@ pub(crate) struct DeprecatedItemSuggestion {
pub span: Span,

#[help]
pub is_nightly: Option<()>,
pub is_nightly: bool,

#[note]
pub details: (),
14 changes: 7 additions & 7 deletions compiler/rustc_const_eval/src/check_consts/ops.rs
Original file line number Diff line number Diff line change
@@ -384,7 +384,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
ccx.dcx().create_err(errors::UnallowedHeapAllocations {
span,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0010).then_some(()),
teach: ccx.tcx.sess.teach(E0010),
})
}
}
@@ -444,16 +444,16 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
if let hir::ConstContext::Static(_) = ccx.const_kind() {
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
span,
opt_help: Some(()),
opt_help: true,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0492).then_some(()),
teach: ccx.tcx.sess.teach(E0492),
})
} else {
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
span,
opt_help: None,
opt_help: false,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0492).then_some(()),
teach: ccx.tcx.sess.teach(E0492),
})
}
}
@@ -481,12 +481,12 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
hir::BorrowKind::Raw => ccx.tcx.dcx().create_err(errors::UnallowedMutableRaw {
span,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0764).then_some(()),
teach: ccx.tcx.sess.teach(E0764),
}),
hir::BorrowKind::Ref => ccx.dcx().create_err(errors::UnallowedMutableRefs {
span,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0764).then_some(()),
teach: ccx.tcx.sess.teach(E0764),
}),
}
}
10 changes: 5 additions & 5 deletions compiler/rustc_const_eval/src/errors.rs
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ pub(crate) struct UnallowedMutableRefs {
pub span: Span,
pub kind: ConstContext,
#[note(const_eval_teach_note)]
pub teach: Option<()>,
pub teach: bool,
}

#[derive(Diagnostic)]
@@ -161,7 +161,7 @@ pub(crate) struct UnallowedMutableRaw {
pub span: Span,
pub kind: ConstContext,
#[note(const_eval_teach_note)]
pub teach: Option<()>,
pub teach: bool,
}
#[derive(Diagnostic)]
#[diag(const_eval_non_const_fmt_macro_call, code = E0015)]
@@ -196,7 +196,7 @@ pub(crate) struct UnallowedHeapAllocations {
pub span: Span,
pub kind: ConstContext,
#[note(const_eval_teach_note)]
pub teach: Option<()>,
pub teach: bool,
}

#[derive(Diagnostic)]
@@ -214,10 +214,10 @@ pub(crate) struct InteriorMutableDataRefer {
#[label]
pub span: Span,
#[help]
pub opt_help: Option<()>,
pub opt_help: bool,
pub kind: ConstContext,
#[note(const_eval_teach_note)]
pub teach: Option<()>,
pub teach: bool,
}

#[derive(Diagnostic)]
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
@@ -281,7 +281,7 @@ pub(crate) struct IncompleteParse<'a> {
pub macro_path: &'a ast::Path,
pub kind_name: &'a str,
#[note(expand_macro_expands_to_match_arm)]
pub expands_to_match_arm: Option<()>,
pub expands_to_match_arm: bool,

#[suggestion(
expand_suggestion_add_semi,
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
@@ -1031,7 +1031,7 @@ pub(crate) fn ensure_complete_parse<'a>(
label_span: span,
macro_path,
kind_name,
expands_to_match_arm: expands_to_match_arm.then_some(()),
expands_to_match_arm,
add_semicolon,
});
}
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
@@ -1564,7 +1564,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
// * compare the param span to the pred span to detect lone user-written `Sized` bounds
let has_explicit_bounds = bounded_params.is_empty()
|| (*bounded_params).get(&param.index).is_some_and(|&&pred_sp| pred_sp != span);
let const_param_help = (!has_explicit_bounds).then_some(());
let const_param_help = !has_explicit_bounds;

let mut diag = tcx.dcx().create_err(errors::UnusedGenericParameter {
span,
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
@@ -1972,8 +1972,7 @@ fn report_bivariance<'tcx>(
}

let const_param_help =
matches!(param.kind, hir::GenericParamKind::Type { .. } if !has_explicit_bounds)
.then_some(());
matches!(param.kind, hir::GenericParamKind::Type { .. } if !has_explicit_bounds);

let mut diag = tcx.dcx().create_err(errors::UnusedGenericParameter {
span: param.span,
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1606,7 +1606,7 @@ pub(crate) struct UnusedGenericParameter {
#[subdiagnostic]
pub help: UnusedGenericParameterHelp,
#[help(hir_analysis_const_param_help)]
pub const_param_help: Option<()>,
pub const_param_help: bool,
}

#[derive(Diagnostic)]
@@ -1643,9 +1643,9 @@ pub(crate) struct UnconstrainedGenericParameter {
pub param_name: Symbol,
pub param_def_kind: &'static str,
#[note(hir_analysis_const_param_note)]
pub const_param_note: Option<()>,
pub const_param_note: bool,
#[note(hir_analysis_const_param_note2)]
pub const_param_note2: Option<()>,
pub const_param_note2: bool,
}

#[derive(Diagnostic)]
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/impl_wf_check.rs
Original file line number Diff line number Diff line change
@@ -137,8 +137,7 @@ fn enforce_impl_params_are_constrained(
}
};
if err {
let const_param_note =
matches!(param.kind, ty::GenericParamDefKind::Const { .. }).then_some(());
let const_param_note = matches!(param.kind, ty::GenericParamDefKind::Const { .. });
let mut diag = tcx.dcx().create_err(UnconstrainedGenericParameter {
span: tcx.def_span(param.def_id),
param_name: param.name,
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/cast.rs
Original file line number Diff line number Diff line change
@@ -505,7 +505,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
span: self.span,
expr_ty: self.expr_ty,
cast_ty: fcx.ty_to_string(self.cast_ty),
teach: fcx.tcx.sess.teach(E0607).then_some(()),
teach: fcx.tcx.sess.teach(E0607),
});
}
CastError::IntToFatCast(known_metadata) => {
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
@@ -706,7 +706,7 @@ pub(crate) struct CastThinPointerToFatPointer<'tcx> {
pub expr_ty: Ty<'tcx>,
pub cast_ty: String,
#[note(hir_typeck_teach_help)]
pub(crate) teach: Option<()>,
pub(crate) teach: bool,
}

#[derive(Diagnostic)]
@@ -720,7 +720,7 @@ pub(crate) struct PassToVariadicFunction<'tcx, 'a> {
pub sugg_span: Option<Span>,
pub replace: String,
#[help]
pub help: Option<()>,
pub help: bool,
#[note(hir_typeck_teach_help)]
pub(crate) teach: Option<()>,
pub(crate) teach: bool,
}
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
@@ -406,9 +406,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) {
let (sugg_span, replace, help) =
if let Ok(snippet) = sess.source_map().span_to_snippet(span) {
(Some(span), format!("{snippet} as {cast_ty}"), None)
(Some(span), format!("{snippet} as {cast_ty}"), false)
} else {
(None, "".to_string(), Some(()))
(None, "".to_string(), true)
};

sess.dcx().emit_err(errors::PassToVariadicFunction {
@@ -418,7 +418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
help,
replace,
sugg_span,
teach: sess.teach(E0617).then_some(()),
teach: sess.teach(E0617),
});
}

4 changes: 2 additions & 2 deletions compiler/rustc_incremental/src/errors.rs
Original file line number Diff line number Diff line change
@@ -189,10 +189,10 @@ pub struct CreateLock<'a> {
pub lock_err: std::io::Error,
pub session_dir: &'a Path,
#[note(incremental_lock_unsupported)]
pub is_unsupported_lock: Option<()>,
pub is_unsupported_lock: bool,
#[help(incremental_cargo_help_1)]
#[help(incremental_cargo_help_2)]
pub is_cargo: Option<()>,
pub is_cargo: bool,
}

#[derive(Diagnostic)]
4 changes: 2 additions & 2 deletions compiler/rustc_incremental/src/persist/fs.rs
Original file line number Diff line number Diff line change
@@ -486,12 +486,12 @@ fn lock_directory(
// the lock should be exclusive
Ok(lock) => Ok((lock, lock_file_path)),
Err(lock_err) => {
let is_unsupported_lock = flock::Lock::error_unsupported(&lock_err).then_some(());
let is_unsupported_lock = flock::Lock::error_unsupported(&lock_err);
Err(sess.dcx().emit_err(errors::CreateLock {
lock_err,
session_dir,
is_unsupported_lock,
is_cargo: rustc_session::utils::was_invoked_from_cargo().then_some(()),
is_cargo: rustc_session::utils::was_invoked_from_cargo(),
}))
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -1330,7 +1330,7 @@ impl UnreachablePub {
BuiltinUnreachablePub {
what,
suggestion: (vis_span, applicability),
help: exportable.then_some(()),
help: exportable,
},
);
}
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/errors.rs
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ pub struct UnknownToolInScopedLint {
pub tool_name: Symbol,
pub lint_name: String,
#[help]
pub is_nightly_build: Option<()>,
pub is_nightly_build: bool,
}

#[derive(Diagnostic)]
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/expect.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
&& tool_filter.map_or(true, |filter| expectation.lint_tool == Some(filter))
{
let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale });
let note = expectation.is_unfulfilled_lint_expectations.then_some(());
let note = expectation.is_unfulfilled_lint_expectations;
tcx.emit_node_span_lint(
UNFULFILLED_LINT_EXPECTATIONS,
*hir_id,
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
@@ -936,7 +936,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
span: tool_ident.map(|ident| ident.span),
tool_name: tool_name.unwrap(),
lint_name: pprust::path_to_string(&meta_item.path),
is_nightly_build: sess.is_nightly_build().then_some(()),
is_nightly_build: sess.is_nightly_build(),
});
continue;
}
8 changes: 4 additions & 4 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
@@ -257,7 +257,7 @@ pub struct BuiltinUnreachablePub<'a> {
#[suggestion(code = "pub(crate)")]
pub suggestion: (Span, Applicability),
#[help]
pub help: Option<()>,
pub help: bool,
}

#[derive(LintDiagnostic)]
@@ -572,7 +572,7 @@ pub struct Expectation {
#[subdiagnostic]
pub rationale: Option<ExpectationNote>,
#[note]
pub note: Option<()>,
pub note: bool,
}

#[derive(Subdiagnostic)]
@@ -756,15 +756,15 @@ pub enum InvalidReferenceCastingDiag<'tcx> {
#[label]
orig_cast: Option<Span>,
#[note(lint_invalid_reference_casting_note_ty_has_interior_mutability)]
ty_has_interior_mutability: Option<()>,
ty_has_interior_mutability: bool,
},
#[diag(lint_invalid_reference_casting_assign_to_ref)]
#[note(lint_invalid_reference_casting_note_book)]
AssignToRef {
#[label]
orig_cast: Option<Span>,
#[note(lint_invalid_reference_casting_note_ty_has_interior_mutability)]
ty_has_interior_mutability: Option<()>,
ty_has_interior_mutability: bool,
},
#[diag(lint_invalid_reference_casting_bigger_layout)]
#[note(lint_layout)]
2 changes: 0 additions & 2 deletions compiler/rustc_lint/src/reference_casting.rs
Original file line number Diff line number Diff line change
@@ -54,8 +54,6 @@ impl<'tcx> LateLintPass<'tcx> for InvalidReferenceCasting {
&& let Some(ty_has_interior_mutability) =
is_cast_from_ref_to_mut_ptr(cx, init, &mut peel_casts)
{
let ty_has_interior_mutability = ty_has_interior_mutability.then_some(());

cx.emit_span_lint(
INVALID_REFERENCE_CASTING,
expr.span,
Loading
Loading