mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
Rollup merge of #108373 - tshepang:where-clause-on-main, r=compiler-errors
hir-analysis: make where-clause-on-main diagnostic translatable
This commit is contained in:
commit
60014e4848
@ -127,5 +127,8 @@ hir_analysis_auto_deref_reached_recursion_limit = reached the recursion limit wh
|
|||||||
.label = deref recursion limit reached
|
.label = deref recursion limit reached
|
||||||
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)
|
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)
|
||||||
|
|
||||||
|
hir_analysis_where_clause_on_main = `main` function is not allowed to have a `where` clause
|
||||||
|
.label = `main` cannot have a `where` clause
|
||||||
|
|
||||||
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
|
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
|
||||||
.label = `main` function is not allowed to be `#[track_caller]`
|
.label = `main` function is not allowed to be `#[track_caller]`
|
||||||
|
@ -316,6 +316,15 @@ pub struct AutoDerefReachedRecursionLimit<'a> {
|
|||||||
pub crate_name: Symbol,
|
pub crate_name: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_where_clause_on_main, code = "E0646")]
|
||||||
|
pub(crate) struct WhereClauseOnMain {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[label]
|
||||||
|
pub generics_span: Option<Span>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(hir_analysis_track_caller_on_main)]
|
#[diag(hir_analysis_track_caller_on_main)]
|
||||||
pub(crate) struct TrackCallerOnMain {
|
pub(crate) struct TrackCallerOnMain {
|
||||||
|
@ -271,16 +271,10 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||||||
} else if !main_fn_predicates.predicates.is_empty() {
|
} else if !main_fn_predicates.predicates.is_empty() {
|
||||||
// generics may bring in implicit predicates, so we skip this check if generics is present.
|
// generics may bring in implicit predicates, so we skip this check if generics is present.
|
||||||
let generics_where_clauses_span = main_fn_where_clauses_span(tcx, main_def_id);
|
let generics_where_clauses_span = main_fn_where_clauses_span(tcx, main_def_id);
|
||||||
let mut diag = struct_span_err!(
|
tcx.sess.emit_err(errors::WhereClauseOnMain {
|
||||||
tcx.sess,
|
span: generics_where_clauses_span.unwrap_or(main_span),
|
||||||
generics_where_clauses_span.unwrap_or(main_span),
|
generics_span: generics_where_clauses_span,
|
||||||
E0646,
|
});
|
||||||
"`main` function is not allowed to have a `where` clause"
|
|
||||||
);
|
|
||||||
if let Some(generics_where_clauses_span) = generics_where_clauses_span {
|
|
||||||
diag.span_label(generics_where_clauses_span, "`main` cannot have a `where` clause");
|
|
||||||
}
|
|
||||||
diag.emit();
|
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user