Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a673ad6

Browse files
committed
Auto merge of rust-lang#111639 - Nilstrieb:rollup-vg149lm, r=Nilstrieb
Rollup of 10 pull requests Successful merges: - rust-lang#111428 (refactor(resolve): clean up the early error return caused by non-call) - rust-lang#111449 (Recover `impl<T ?Sized>` correctly) - rust-lang#111572 (Document that `missing_copy_implementations` and `missing_debug_implementations` only apply to public items.) - rust-lang#111602 (Suppress "erroneous constant used" for constants tainted by errors) - rust-lang#111605 (fixup version placeholder for `cfi_encoding` feature) - rust-lang#111607 (Add clubby789 to the bootstrap review rotation) - rust-lang#111614 (Add more interesting nonsense to weird-exprs.rs) - rust-lang#111617 (Fixed typo) - rust-lang#111620 (Add eholk back to compiler-contributors reviewers) - rust-lang#111621 (Fix release date of 1.58.1 in release notes.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 72b2716 + 5c0b8f1 commit a673ad6

Some content is hidden

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

51 files changed

+197
-282
lines changed

RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ and related tools.
14811481
[is_power_of_two_usize]: https://doc.rust-lang.org/stable/core/num/struct.NonZeroUsize.html#method.is_power_of_two
14821482
[stdarch/1266]: https://github.com/rust-lang/stdarch/pull/1266
14831483

1484-
Version 1.58.1 (2022-01-19)
1484+
Version 1.58.1 (2022-01-20)
14851485
===========================
14861486

14871487
* Fix race condition in `std::fs::remove_dir_all` ([CVE-2022-21658])

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ impl<'tcx> ConstEvalErr<'tcx> {
169169
// See <https://github.com/rust-lang/rust/pull/63152>.
170170
let mut err = struct_error(tcx, &self.error.to_string());
171171
self.decorate(&mut err, decorate);
172-
ErrorHandled::Reported(err.emit())
172+
ErrorHandled::Reported(err.emit().into())
173173
}
174174
_ => {
175175
// Report as hard error.
176176
let mut err = struct_error(tcx, message);
177177
err.span_label(self.span, self.error.to_string());
178178
self.decorate(&mut err, decorate);
179-
ErrorHandled::Reported(err.emit())
179+
ErrorHandled::Reported(err.emit().into())
180180
}
181181
}
182182
}

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
382382
rustc_span::DUMMY_SP,
383383
"This is likely a const item that is missing from its impl",
384384
);
385-
throw_inval!(AlreadyReported(guar));
385+
throw_inval!(AlreadyReported(guar.into()));
386386
} else {
387387
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us,
388388
// so this should be unreachable.

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use either::{Either, Left, Right};
77
use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
88
use rustc_index::IndexVec;
99
use rustc_middle::mir;
10-
use rustc_middle::mir::interpret::{ErrorHandled, InterpError};
10+
use rustc_middle::mir::interpret::{ErrorHandled, InterpError, ReportedErrorInfo};
1111
use rustc_middle::ty::layout::{
1212
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers,
1313
TyAndLayout,
@@ -470,7 +470,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
470470
};
471471
// do not continue if typeck errors occurred (can only occur in local crate)
472472
if let Some(err) = body.tainted_by_errors {
473-
throw_inval!(AlreadyReported(err));
473+
throw_inval!(AlreadyReported(ReportedErrorInfo::tainted_by_errors(err)));
474474
}
475475
Ok(body)
476476
}
@@ -517,7 +517,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
517517
Ok(None) => throw_inval!(TooGeneric),
518518

519519
// FIXME(eddyb) this could be a bit more specific than `AlreadyReported`.
520-
Err(error_reported) => throw_inval!(AlreadyReported(error_reported)),
520+
Err(error_reported) => throw_inval!(AlreadyReported(error_reported.into())),
521521
}
522522
}
523523

@@ -905,7 +905,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
905905
query(self.tcx.at(span.unwrap_or_else(|| self.cur_span()))).map_err(|err| {
906906
match err {
907907
ErrorHandled::Reported(err) => {
908-
if let Some(span) = span {
908+
if !err.is_tainted_by_errors() && let Some(span) = span {
909909
// To make it easier to figure out where this error comes from, also add a note at the current location.
910910
self.tcx.sess.span_note_without_error(span, "erroneous constant used");
911911
}

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
595595
// FIXME(generic_const_exprs): `ConstKind::Expr` should be able to be evaluated
596596
ty::ConstKind::Expr(_) => throw_inval!(TooGeneric),
597597
ty::ConstKind::Error(reported) => {
598-
throw_inval!(AlreadyReported(reported))
598+
throw_inval!(AlreadyReported(reported.into()))
599599
}
600600
ty::ConstKind::Unevaluated(uv) => {
601601
let instance = self.resolve(uv.def, uv.substs)?;

compiler/rustc_feature/src/active.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ declare_features! (
338338
/// Allow conditional compilation depending on rust version
339339
(active, cfg_version, "1.45.0", Some(64796), None),
340340
/// Allows to use the `#[cfi_encoding = ""]` attribute.
341-
(active, cfi_encoding, "1.69.0", Some(89653), None),
341+
(active, cfi_encoding, "CURRENT_RUSTC_VERSION", Some(89653), None),
342342
/// Allows `for<...>` on closures and generators.
343343
(active, closure_lifetime_binder, "1.64.0", Some(97362), None),
344344
/// Allows `#[track_caller]` on closures and generators.

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ impl<'tcx> InferCtxt<'tcx> {
15341534
if let Some(ct) = tcx.thir_abstract_const(unevaluated.def)? {
15351535
let ct = tcx.expand_abstract_consts(ct.subst(tcx, substs));
15361536
if let Err(e) = ct.error_reported() {
1537-
return Err(ErrorHandled::Reported(e));
1537+
return Err(ErrorHandled::Reported(e.into()));
15381538
} else if ct.has_non_region_infer() || ct.has_non_region_param() {
15391539
return Err(ErrorHandled::TooGeneric);
15401540
} else {

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
611611

612612
declare_lint! {
613613
/// The `missing_copy_implementations` lint detects potentially-forgotten
614-
/// implementations of [`Copy`].
614+
/// implementations of [`Copy`] for public types.
615615
///
616616
/// [`Copy`]: https://doc.rust-lang.org/std/marker/trait.Copy.html
617617
///
@@ -729,7 +729,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
729729

730730
declare_lint! {
731731
/// The `missing_debug_implementations` lint detects missing
732-
/// implementations of [`fmt::Debug`].
732+
/// implementations of [`fmt::Debug`] for public types.
733733
///
734734
/// [`fmt::Debug`]: https://doc.rust-lang.org/std/fmt/trait.Debug.html
735735
///

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,49 @@ use std::{any::Any, backtrace::Backtrace, fmt};
1515
pub enum ErrorHandled {
1616
/// Already reported an error for this evaluation, and the compilation is
1717
/// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`.
18-
Reported(ErrorGuaranteed),
18+
Reported(ReportedErrorInfo),
1919
/// Don't emit an error, the evaluation failed because the MIR was generic
2020
/// and the substs didn't fully monomorphize it.
2121
TooGeneric,
2222
}
2323

2424
impl From<ErrorGuaranteed> for ErrorHandled {
25-
fn from(err: ErrorGuaranteed) -> ErrorHandled {
26-
ErrorHandled::Reported(err)
25+
#[inline]
26+
fn from(error: ErrorGuaranteed) -> ErrorHandled {
27+
ErrorHandled::Reported(error.into())
28+
}
29+
}
30+
31+
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
32+
pub struct ReportedErrorInfo {
33+
error: ErrorGuaranteed,
34+
is_tainted_by_errors: bool,
35+
}
36+
37+
impl ReportedErrorInfo {
38+
#[inline]
39+
pub fn tainted_by_errors(error: ErrorGuaranteed) -> ReportedErrorInfo {
40+
ReportedErrorInfo { is_tainted_by_errors: true, error }
41+
}
42+
43+
/// Returns true if evaluation failed because MIR was tainted by errors.
44+
#[inline]
45+
pub fn is_tainted_by_errors(self) -> bool {
46+
self.is_tainted_by_errors
47+
}
48+
}
49+
50+
impl From<ErrorGuaranteed> for ReportedErrorInfo {
51+
#[inline]
52+
fn from(error: ErrorGuaranteed) -> ReportedErrorInfo {
53+
ReportedErrorInfo { is_tainted_by_errors: false, error }
54+
}
55+
}
56+
57+
impl Into<ErrorGuaranteed> for ReportedErrorInfo {
58+
#[inline]
59+
fn into(self) -> ErrorGuaranteed {
60+
self.error
2761
}
2862
}
2963

@@ -89,7 +123,7 @@ fn print_backtrace(backtrace: &Backtrace) {
89123

90124
impl From<ErrorGuaranteed> for InterpErrorInfo<'_> {
91125
fn from(err: ErrorGuaranteed) -> Self {
92-
InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into()
126+
InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err.into())).into()
93127
}
94128
}
95129

@@ -125,7 +159,7 @@ pub enum InvalidProgramInfo<'tcx> {
125159
/// Resolution can fail if we are in a too generic context.
126160
TooGeneric,
127161
/// Abort in case errors are already reported.
128-
AlreadyReported(ErrorGuaranteed),
162+
AlreadyReported(ReportedErrorInfo),
129163
/// An error occurred during layout computation.
130164
Layout(layout::LayoutError<'tcx>),
131165
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
@@ -144,7 +178,7 @@ impl fmt::Display for InvalidProgramInfo<'_> {
144178
use InvalidProgramInfo::*;
145179
match self {
146180
TooGeneric => write!(f, "encountered overly generic constant"),
147-
AlreadyReported(ErrorGuaranteed { .. }) => {
181+
AlreadyReported(_) => {
148182
write!(
149183
f,
150184
"an error has already been reported elsewhere (this should not usually be printed)"

compiler/rustc_middle/src/mir/interpret/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ use crate::ty::{self, Instance, Ty, TyCtxt};
120120
pub use self::error::{
121121
struct_error, CheckInAllocMsg, ErrorHandled, EvalToAllocationRawResult, EvalToConstValueResult,
122122
EvalToValTreeResult, InterpError, InterpErrorInfo, InterpResult, InvalidProgramInfo,
123-
MachineStopType, ResourceExhaustionInfo, ScalarSizeMismatch, UndefinedBehaviorInfo,
124-
UninitBytesAccess, UnsupportedOpInfo,
123+
MachineStopType, ReportedErrorInfo, ResourceExhaustionInfo, ScalarSizeMismatch,
124+
UndefinedBehaviorInfo, UninitBytesAccess, UnsupportedOpInfo,
125125
};
126126

127127
pub use self::value::{get_slice_bytes, ConstAlloc, ConstValue, Scalar};

0 commit comments

Comments
 (0)