Skip to content

Commit 31448ba

Browse files
committed
Auto merge of #108450 - matthiaskrgr:rollup-rqvfgu3, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #108354 (Update `fuchsia-test-runner.py` and docs) - #108404 (support `x fmt` for sub and outside of rust directories) - #108407 (docs: use intra-doc links for `Vec::get(_mut)`) - #108410 (rustdoc: avoid including `<li>` tags in item table short desc) - #108412 (Fix GUI test navigation bug) - #108433 (Wrap missing provider message correctly) - #108434 (Migrate `rustc_hir_analysis` to session diagnostic [Part One]) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents dcca6a3 + 2aad179 commit 31448ba

File tree

13 files changed

+276
-103
lines changed

13 files changed

+276
-103
lines changed

Diff for: compiler/rustc_hir_analysis/locales/en-US.ftl

+23
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,26 @@ hir_analysis_where_clause_on_main = `main` function is not allowed to have a `wh
132132
133133
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
134134
.label = `main` function is not allowed to be `#[track_caller]`
135+
136+
hir_analysis_start_not_track_caller = `start` is not allowed to be `#[track_caller]`
137+
.label = `start` is not allowed to be `#[track_caller]`
138+
139+
hir_analysis_start_not_async = `start` is not allowed to be `async`
140+
.label = `start` is not allowed to be `async`
141+
142+
hir_analysis_start_function_where = start function is not allowed to have a `where` clause
143+
.label = start function cannot have a `where` clause
144+
145+
hir_analysis_start_function_parameters = start function is not allowed to have type parameters
146+
.label = start function cannot have type parameters
147+
148+
hir_analysis_main_function_return_type_generic = `main` function return type is not allowed to have generic parameters
149+
150+
hir_analysis_main_function_async = `main` function is not allowed to be `async`
151+
.label = `main` function is not allowed to be `async`
152+
153+
hir_analysis_main_function_generic_parameters = `main` function is not allowed to have generic parameters
154+
.label = `main` cannot have generic parameters
155+
156+
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
157+
.label = C-variadic function must have a compatible calling convention

Diff for: compiler/rustc_hir_analysis/src/errors.rs

+67
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,70 @@ pub(crate) struct TrackCallerOnMain {
333333
#[label]
334334
pub annotated: Span,
335335
}
336+
337+
#[derive(Diagnostic)]
338+
#[diag(hir_analysis_start_not_track_caller)]
339+
pub(crate) struct StartTrackCaller {
340+
#[primary_span]
341+
pub span: Span,
342+
#[label]
343+
pub start: Span,
344+
}
345+
346+
#[derive(Diagnostic)]
347+
#[diag(hir_analysis_start_not_async, code = "E0752")]
348+
pub(crate) struct StartAsync {
349+
#[primary_span]
350+
#[label]
351+
pub span: Span,
352+
}
353+
354+
#[derive(Diagnostic)]
355+
#[diag(hir_analysis_start_function_where, code = "E0647")]
356+
pub(crate) struct StartFunctionWhere {
357+
#[primary_span]
358+
#[label]
359+
pub span: Span,
360+
}
361+
362+
#[derive(Diagnostic)]
363+
#[diag(hir_analysis_start_function_parameters, code = "E0132")]
364+
pub(crate) struct StartFunctionParameters {
365+
#[primary_span]
366+
#[label]
367+
pub span: Span,
368+
}
369+
370+
#[derive(Diagnostic)]
371+
#[diag(hir_analysis_main_function_return_type_generic, code = "E0131")]
372+
pub(crate) struct MainFunctionReturnTypeGeneric {
373+
#[primary_span]
374+
pub span: Span,
375+
}
376+
377+
#[derive(Diagnostic)]
378+
#[diag(hir_analysis_main_function_async, code = "E0752")]
379+
pub(crate) struct MainFunctionAsync {
380+
#[primary_span]
381+
pub span: Span,
382+
#[label]
383+
pub asyncness: Option<Span>,
384+
}
385+
386+
#[derive(Diagnostic)]
387+
#[diag(hir_analysis_main_function_generic_parameters, code = "E0131")]
388+
pub(crate) struct MainFunctionGenericParameters {
389+
#[primary_span]
390+
pub span: Span,
391+
#[label]
392+
pub label_span: Option<Span>,
393+
}
394+
395+
#[derive(Diagnostic)]
396+
#[diag(hir_analysis_variadic_function_compatible_convention, code = "E0045")]
397+
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
398+
#[primary_span]
399+
#[label]
400+
pub span: Span,
401+
pub conventions: &'a str,
402+
}

Diff for: compiler/rustc_hir_analysis/src/lib.rs

+17-63
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ mod outlives;
9898
pub mod structured_errors;
9999
mod variance;
100100

101-
use rustc_errors::{struct_span_err, ErrorGuaranteed};
101+
use rustc_errors::ErrorGuaranteed;
102102
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
103103
use rustc_hir as hir;
104104
use rustc_hir::Node;
@@ -123,7 +123,6 @@ use bounds::Bounds;
123123
fluent_messages! { "../locales/en-US.ftl" }
124124

125125
fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
126-
const ERROR_HEAD: &str = "C-variadic function must have a compatible calling convention";
127126
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `win64`, `sysv64` or `efiapi`";
128127
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
129128
const UNSTABLE_EXPLAIN: &str =
@@ -155,8 +154,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi
155154
(true, false) => CONVENTIONS_UNSTABLE,
156155
};
157156

158-
let mut err = struct_span_err!(tcx.sess, span, E0045, "{}, like {}", ERROR_HEAD, conventions);
159-
err.span_label(span, ERROR_HEAD).emit();
157+
tcx.sess.emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
160158
}
161159

162160
fn require_same_types<'tcx>(
@@ -258,15 +256,10 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
258256
let main_fn_predicates = tcx.predicates_of(main_def_id);
259257
if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() {
260258
let generics_param_span = main_fn_generics_params_span(tcx, main_def_id);
261-
let msg = "`main` function is not allowed to have generic \
262-
parameters";
263-
let mut diag =
264-
struct_span_err!(tcx.sess, generics_param_span.unwrap_or(main_span), E0131, "{}", msg);
265-
if let Some(generics_param_span) = generics_param_span {
266-
let label = "`main` cannot have generic parameters";
267-
diag.span_label(generics_param_span, label);
268-
}
269-
diag.emit();
259+
tcx.sess.emit_err(errors::MainFunctionGenericParameters {
260+
span: generics_param_span.unwrap_or(main_span),
261+
label_span: generics_param_span,
262+
});
270263
error = true;
271264
} else if !main_fn_predicates.predicates.is_empty() {
272265
// generics may bring in implicit predicates, so we skip this check if generics is present.
@@ -280,17 +273,8 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
280273

281274
let main_asyncness = tcx.asyncness(main_def_id);
282275
if let hir::IsAsync::Async = main_asyncness {
283-
let mut diag = struct_span_err!(
284-
tcx.sess,
285-
main_span,
286-
E0752,
287-
"`main` function is not allowed to be `async`"
288-
);
289276
let asyncness_span = main_fn_asyncness_span(tcx, main_def_id);
290-
if let Some(asyncness_span) = asyncness_span {
291-
diag.span_label(asyncness_span, "`main` function is not allowed to be `async`");
292-
}
293-
diag.emit();
277+
tcx.sess.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span });
294278
error = true;
295279
}
296280

@@ -308,9 +292,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
308292
let return_ty = main_fnsig.output();
309293
let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span);
310294
if !return_ty.bound_vars().is_empty() {
311-
let msg = "`main` function return type is not allowed to have generic \
312-
parameters";
313-
struct_span_err!(tcx.sess, return_ty_span, E0131, "{}", msg).emit();
295+
tcx.sess.emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span });
314296
error = true;
315297
}
316298
let return_ty = return_ty.skip_binder();
@@ -367,56 +349,28 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
367349
if let hir::ItemKind::Fn(sig, generics, _) = &it.kind {
368350
let mut error = false;
369351
if !generics.params.is_empty() {
370-
struct_span_err!(
371-
tcx.sess,
372-
generics.span,
373-
E0132,
374-
"start function is not allowed to have type parameters"
375-
)
376-
.span_label(generics.span, "start function cannot have type parameters")
377-
.emit();
352+
tcx.sess.emit_err(errors::StartFunctionParameters { span: generics.span });
378353
error = true;
379354
}
380355
if generics.has_where_clause_predicates {
381-
struct_span_err!(
382-
tcx.sess,
383-
generics.where_clause_span,
384-
E0647,
385-
"start function is not allowed to have a `where` clause"
386-
)
387-
.span_label(
388-
generics.where_clause_span,
389-
"start function cannot have a `where` clause",
390-
)
391-
.emit();
356+
tcx.sess.emit_err(errors::StartFunctionWhere {
357+
span: generics.where_clause_span,
358+
});
392359
error = true;
393360
}
394361
if let hir::IsAsync::Async = sig.header.asyncness {
395362
let span = tcx.def_span(it.owner_id);
396-
struct_span_err!(
397-
tcx.sess,
398-
span,
399-
E0752,
400-
"`start` is not allowed to be `async`"
401-
)
402-
.span_label(span, "`start` is not allowed to be `async`")
403-
.emit();
363+
tcx.sess.emit_err(errors::StartAsync { span: span });
404364
error = true;
405365
}
406366

407367
let attrs = tcx.hir().attrs(start_id);
408368
for attr in attrs {
409369
if attr.has_name(sym::track_caller) {
410-
tcx.sess
411-
.struct_span_err(
412-
attr.span,
413-
"`start` is not allowed to be `#[track_caller]`",
414-
)
415-
.span_label(
416-
start_span,
417-
"`start` is not allowed to be `#[track_caller]`",
418-
)
419-
.emit();
370+
tcx.sess.emit_err(errors::StartTrackCaller {
371+
span: attr.span,
372+
start: start_span,
373+
});
420374
error = true;
421375
}
422376
}

Diff for: compiler/rustc_middle/src/ty/query.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ macro_rules! define_callbacks {
328328

329329
Providers {
330330
$($name: |_, key| bug!(
331-
"`tcx.{}({:?})` is not supported for {} crate;\n
332-
hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported.\n
331+
"`tcx.{}({:?})` is not supported for {} crate;\n\
332+
hint: Queries can be either made to the local crate, or the external crate. \
333+
This error means you tried to use it for one that's not supported.\n\
333334
If that's not the case, {} was likely never assigned to a provider function.\n",
334335
stringify!($name),
335336
key,

Diff for: library/alloc/src/vec/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ mod spec_extend;
378378
/// Currently, `Vec` does not guarantee the order in which elements are dropped.
379379
/// The order has changed in the past and may change again.
380380
///
381-
/// [`get`]: ../../std/vec/struct.Vec.html#method.get
382-
/// [`get_mut`]: ../../std/vec/struct.Vec.html#method.get_mut
381+
/// [`get`]: slice::get
382+
/// [`get_mut`]: slice::get_mut
383383
/// [`String`]: crate::string::String
384384
/// [`&str`]: type@str
385385
/// [`shrink_to_fit`]: Vec::shrink_to_fit

Diff for: src/bootstrap/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
218218
WalkBuilder::new(first)
219219
}
220220
} else {
221-
WalkBuilder::new(first)
221+
WalkBuilder::new(src.join(first))
222222
};
223223

224224
for path in &paths[1..] {
@@ -229,7 +229,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
229229
walker.add(path);
230230
}
231231
} else {
232-
walker.add(path);
232+
walker.add(src.join(path));
233233
}
234234
}
235235

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.3
1+
0.14.4

0 commit comments

Comments
 (0)