Skip to content

Commit 36e530c

Browse files
committed
Auto merge of #100793 - matthiaskrgr:rollup-dy7rfdh, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #100186 (Mention `as_mut` alongside `as_ref` in borrowck error message) - #100383 (Mitigate stale data reads on SGX platform) - #100507 (suggest `once_cell::Lazy` for non-const statics) - #100617 (Suggest the right help message for as_ref) - #100667 (Migrate "invalid variable declaration" errors to SessionDiagnostic) - #100709 (Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic`) - #100723 (Add the diagnostic translation lints to crates that don't emit them) - #100729 (Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`) - #100750 (improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn`) - #100763 (triagebot: Autolabel `A-rustdoc-json`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e1b28cd + 60edec9 commit 36e530c

File tree

63 files changed

+476
-138
lines changed

Some content is hidden

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

63 files changed

+476
-138
lines changed

compiler/rustc_apfloat/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3434
#![no_std]
3535
#![forbid(unsafe_code)]
36+
#![deny(rustc::untranslatable_diagnostic)]
37+
#![deny(rustc::diagnostic_outside_of_impl)]
3638

3739
#[macro_use]
3840
extern crate alloc;

compiler/rustc_arena/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#![feature(rustc_attrs)]
2020
#![cfg_attr(test, feature(test))]
2121
#![feature(strict_provenance)]
22+
#![deny(rustc::untranslatable_diagnostic)]
23+
#![deny(rustc::diagnostic_outside_of_impl)]
2224

2325
use smallvec::SmallVec;
2426

compiler/rustc_ast/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#![feature(slice_internals)]
2020
#![feature(stmt_expr_attributes)]
2121
#![recursion_limit = "256"]
22+
#![deny(rustc::untranslatable_diagnostic)]
23+
#![deny(rustc::diagnostic_outside_of_impl)]
2224

2325
#[macro_use]
2426
extern crate rustc_macros;

compiler/rustc_ast_pretty/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
#![feature(associated_type_bounds)]
24
#![feature(box_patterns)]
35
#![feature(with_negative_coherence)]

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,14 +1086,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10861086
),
10871087
);
10881088
}
1089-
if is_option_or_result && maybe_reinitialized_locations_is_empty {
1090-
err.span_suggestion_verbose(
1091-
fn_call_span.shrink_to_lo(),
1092-
"consider calling `.as_ref()` to borrow the type's contents",
1093-
"as_ref().",
1094-
Applicability::MachineApplicable,
1095-
);
1096-
}
10971089
// Avoid pointing to the same function in multiple different
10981090
// error messages.
10991091
if span != DUMMY_SP && self.fn_self_span_reported.insert(self_arg.span) {
@@ -1102,6 +1094,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11021094
&format!("this function takes ownership of the receiver `self`, which moves {}", place_name)
11031095
);
11041096
}
1097+
if is_option_or_result && maybe_reinitialized_locations_is_empty {
1098+
err.span_label(
1099+
var_span,
1100+
"help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents",
1101+
);
1102+
}
11051103
}
11061104
// Other desugarings takes &self, which cannot cause a move
11071105
_ => {}

compiler/rustc_const_eval/src/transform/check_consts/ops.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Concrete error types for all operations which may be invalid in a certain const context.
22
33
use hir::def_id::LocalDefId;
4+
use hir::ConstContext;
45
use rustc_errors::{
56
error_code, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
67
};
@@ -331,6 +332,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
331332
ccx.const_kind(),
332333
));
333334

335+
if let ConstContext::Static(_) = ccx.const_kind() {
336+
err.note("consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell");
337+
}
338+
334339
err
335340
}
336341
}

compiler/rustc_data_structures/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#![feature(vec_into_raw_parts)]
2929
#![allow(rustc::default_hash_types)]
3030
#![allow(rustc::potential_query_instability)]
31+
#![deny(rustc::untranslatable_diagnostic)]
32+
#![deny(rustc::diagnostic_outside_of_impl)]
3133

3234
#[macro_use]
3335
extern crate tracing;

compiler/rustc_error_codes/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![deny(rustdoc::invalid_codeblock_attributes)]
2+
#![deny(rustc::untranslatable_diagnostic)]
3+
#![deny(rustc::diagnostic_outside_of_impl)]
24
//! This library is used to gather all error codes into one place,
35
//! the goal being to make their maintenance easier.
46

compiler/rustc_error_messages/locales/en-US/parser.ftl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ parser_incorrect_use_of_await =
3232
parser_in_in_typo =
3333
expected iterable, found keyword `in`
3434
.suggestion = remove the duplicated `in`
35+
36+
parser_invalid_variable_declaration =
37+
invalid variable declaration
38+
39+
parser_switch_mut_let_order =
40+
switch the order of `mut` and `let`
41+
parser_missing_let_before_mut = missing keyword
42+
parser_use_let_not_auto = write `let` instead of `auto` to introduce a new variable
43+
parser_use_let_not_var = write `let` instead of `var` to introduce a new variable

compiler/rustc_error_messages/locales/en-US/typeck.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ typeck_unused_extern_crate =
131131
typeck_extern_crate_not_idiomatic =
132132
`extern crate` is not idiomatic in the new edition
133133
.suggestion = convert it to a `{$msg_code}`
134+
135+
typeck_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`

0 commit comments

Comments
 (0)