Skip to content

Commit a36ca6c

Browse files
committed
merge my local with my fork
2 parents 213915b + 36e530c commit a36ca6c

File tree

117 files changed

+1531
-1354
lines changed

Some content is hidden

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

117 files changed

+1531
-1354
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_codegen_cranelift/src/unsize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub(crate) fn unsized_info<'tcx>(
2929
let old_info =
3030
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
3131
if data_a.principal_def_id() == data_b.principal_def_id() {
32+
// A NOP cast that doesn't actually change anything, should be allowed even with invalid vtables.
3233
return old_info;
3334
}
3435

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
151151
let old_info =
152152
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
153153
if data_a.principal_def_id() == data_b.principal_def_id() {
154+
// A NOP cast that doesn't actually change anything, should be allowed even with invalid vtables.
154155
return old_info;
155156
}
156157

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
298298
self.write_immediate(val, dest)
299299
}
300300
(&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => {
301-
let (old_data, old_vptr) = self.read_immediate(src)?.to_scalar_pair()?;
301+
let val = self.read_immediate(src)?;
302+
if data_a.principal() == data_b.principal() {
303+
// A NOP cast that doesn't actually change anything, should be allowed even with mismatching vtables.
304+
return self.write_immediate(*val, dest);
305+
}
306+
let (old_data, old_vptr) = val.to_scalar_pair()?;
302307
let old_vptr = old_vptr.to_pointer(self)?;
303308
let (ty, old_trait) = self.get_ptr_vtable(old_vptr)?;
304309
if old_trait != data_a.principal() {

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ typeck_lifetimes_or_bounds_mismatch_on_trait =
2424
.generics_label = lifetimes in impl do not match this {$item_kind} in trait
2525
2626
typeck_drop_impl_on_wrong_item =
27-
the `Drop` trait may only be implemented for structs, enums, and unions
28-
.label = must be a struct, enum, or union
27+
the `Drop` trait may only be implemented for local structs, enums, and unions
28+
.label = must be a struct, enum, or union in the current crate
2929
3030
typeck_field_already_declared =
3131
field `{$field_name}` is already declared
@@ -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)`

compiler/rustc_error_messages/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![feature(once_cell)]
22
#![feature(rustc_attrs)]
33
#![feature(type_alias_impl_trait)]
4+
#![deny(rustc::untranslatable_diagnostic)]
5+
#![deny(rustc::diagnostic_outside_of_impl)]
46

57
use fluent_bundle::FluentResource;
68
use fluent_syntax::parser::ParserError;

compiler/rustc_errors/src/diagnostic_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl Drop for DiagnosticBuilderInner<'_> {
566566
),
567567
));
568568
handler.emit_diagnostic(&mut self.diagnostic);
569-
panic!();
569+
panic!("error was constructed but not emitted");
570570
}
571571
}
572572
// `.emit()` was previously called, or maybe we're during `.cancel()`.

compiler/rustc_feature/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//! symbol to the `accepted` or `removed` modules respectively.
1313
1414
#![feature(once_cell)]
15+
#![deny(rustc::untranslatable_diagnostic)]
16+
#![deny(rustc::diagnostic_outside_of_impl)]
1517

1618
mod accepted;
1719
mod active;

compiler/rustc_fs_util/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use std::ffi::CString;
25
use std::fs;
36
use std::io;

compiler/rustc_graphviz/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@
273273
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
274274
test(attr(allow(unused_variables), deny(warnings)))
275275
)]
276+
#![deny(rustc::untranslatable_diagnostic)]
277+
#![deny(rustc::diagnostic_outside_of_impl)]
276278

277279
use LabelText::*;
278280

compiler/rustc_hir/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#![feature(never_type)]
1212
#![feature(rustc_attrs)]
1313
#![recursion_limit = "256"]
14+
#![deny(rustc::untranslatable_diagnostic)]
15+
#![deny(rustc::diagnostic_outside_of_impl)]
1416

1517
#[macro_use]
1618
extern crate rustc_macros;

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![recursion_limit = "256"]
2+
#![deny(rustc::untranslatable_diagnostic)]
3+
#![deny(rustc::diagnostic_outside_of_impl)]
24

35
use rustc_ast as ast;
46
use rustc_ast::util::parser::{self, AssocOp, Fixity};

compiler/rustc_index/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(allow_internal_unstable)]
24
#![feature(bench_black_box)]
35
#![feature(extend_one)]

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20792079
diag.span_suggestion(
20802080
span,
20812081
*msg,
2082-
format!("{}.as_ref()", snippet),
2082+
// HACK: fix issue# 100605, suggesting convert from &Option<T> to Option<&T>, remove the extra `&`
2083+
format!("{}.as_ref()", snippet.trim_start_matches('&')),
20832084
Applicability::MachineApplicable,
20842085
);
20852086
}

compiler/rustc_lexer/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//! lexeme types.
1919
//!
2020
//! [`rustc_parse::lexer`]: ../rustc_parse/lexer/index.html
21+
#![deny(rustc::untranslatable_diagnostic)]
22+
#![deny(rustc::diagnostic_outside_of_impl)]
2123
// We want to be able to build this crate with a stable compiler, so no
2224
// `#![feature]` attributes should be added.
2325

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![feature(min_specialization)]
2+
#![deny(rustc::untranslatable_diagnostic)]
3+
#![deny(rustc::diagnostic_outside_of_impl)]
24

35
#[macro_use]
46
extern crate rustc_macros;

compiler/rustc_llvm/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
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
24

35
// NOTE: This crate only exists to allow linking on mingw targets.

compiler/rustc_log/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
//! debugging, you can make changes inside those crates and quickly run main.rs
3939
//! to read the debug logs.
4040
41+
#![deny(rustc::untranslatable_diagnostic)]
42+
#![deny(rustc::diagnostic_outside_of_impl)]
43+
4144
use std::env::{self, VarError};
4245
use std::fmt::{self, Display};
4346
use std::io;

compiler/rustc_macros/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#![feature(proc_macro_diagnostic)]
55
#![feature(proc_macro_span)]
66
#![allow(rustc::default_hash_types)]
7+
#![deny(rustc::untranslatable_diagnostic)]
8+
#![deny(rustc::diagnostic_outside_of_impl)]
79
#![recursion_limit = "128"]
810

911
use synstructure::decl_derive;

0 commit comments

Comments
 (0)