Skip to content

Commit a36ca6c

Browse files
committed
Merge branch 'master' of https://github.com/AndyJado/rust
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;

0 commit comments

Comments
 (0)