Skip to content

Commit 00f2459

Browse files
committed
Auto merge of rust-lang#137688 - fmease:rollup-gbeuj9j, r=fmease
Rollup of 10 pull requests Successful merges: - rust-lang#134585 (remove `MaybeUninit::uninit_array`) - rust-lang#136187 (Use less CString in the examples of CStr.) - rust-lang#137201 (Teach structured errors to display short `Ty<'_>`) - rust-lang#137620 (Fix `attr` cast for espidf) - rust-lang#137631 (Avoid collecting associated types for undefined trait) - rust-lang#137635 (Don't suggest constraining unstable associated types) - rust-lang#137642 (Rustc dev guide subtree update) - rust-lang#137660 (Update gcc submodule) - rust-lang#137670 (revert accidental change in get_closest_merge_commit) - rust-lang#137671 (Make -Z unpretty=mir suggest -Z dump-mir as well for discoverability) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ac91805 + 46eb43e commit 00f2459

File tree

87 files changed

+700
-328
lines changed

Some content is hidden

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

87 files changed

+700
-328
lines changed

compiler/rustc_ast_passes/src/errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ pub(crate) struct WhereClauseBeforeTypeAlias {
535535
}
536536

537537
#[derive(Subdiagnostic)]
538-
539538
pub(crate) enum WhereClauseBeforeTypeAliasSugg {
540539
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
541540
Remove {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
287287
None => "value".to_owned(),
288288
};
289289
if needs_note {
290-
let ty = self.infcx.tcx.short_string(ty, err.long_ty_path());
291290
if let Some(local) = place.as_local() {
292291
let span = self.body.local_decls[local].source_info.span;
293292
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
596596
self.suggest_cloning(err, place_ty, expr, None);
597597
}
598598

599-
let ty = self.infcx.tcx.short_string(place_ty, err.long_ty_path());
600599
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
601600
is_partial_move: false,
602-
ty,
601+
ty: place_ty,
603602
place: &place_desc,
604603
span,
605604
});
@@ -629,10 +628,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
629628
self.suggest_cloning(err, place_ty, expr, Some(use_spans));
630629
}
631630

632-
let ty = self.infcx.tcx.short_string(place_ty, err.long_ty_path());
633631
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
634632
is_partial_move: false,
635-
ty,
633+
ty: place_ty,
636634
place: &place_desc,
637635
span: use_span,
638636
});
@@ -833,10 +831,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
833831
self.suggest_cloning(err, bind_to.ty, expr, None);
834832
}
835833

836-
let ty = self.infcx.tcx.short_string(bind_to.ty, err.long_ty_path());
837834
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
838835
is_partial_move: false,
839-
ty,
836+
ty: bind_to.ty,
840837
place: place_desc,
841838
span: binding_span,
842839
});

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ impl Display for RegionName {
194194
}
195195

196196
impl rustc_errors::IntoDiagArg for RegionName {
197-
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
198-
self.to_string().into_diag_arg()
197+
fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> rustc_errors::DiagArgValue {
198+
self.to_string().into_diag_arg(path)
199199
}
200200
}
201201

compiler/rustc_borrowck/src/session_diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,17 @@ pub(crate) enum OnClosureNote<'a> {
459459
}
460460

461461
#[derive(Subdiagnostic)]
462-
pub(crate) enum TypeNoCopy<'a> {
462+
pub(crate) enum TypeNoCopy<'a, 'tcx> {
463463
#[label(borrowck_ty_no_impl_copy)]
464464
Label {
465465
is_partial_move: bool,
466-
ty: String,
466+
ty: Ty<'tcx>,
467467
place: &'a str,
468468
#[primary_span]
469469
span: Span,
470470
},
471471
#[note(borrowck_ty_no_impl_copy)]
472-
Note { is_partial_move: bool, ty: String, place: &'a str },
472+
Note { is_partial_move: bool, ty: Ty<'tcx>, place: &'a str },
473473
}
474474

475475
#[derive(Diagnostic)]

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl fmt::Display for CguReuse {
211211
}
212212

213213
impl IntoDiagArg for CguReuse {
214-
fn into_diag_arg(self) -> DiagArgValue {
214+
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
215215
DiagArgValue::Str(Cow::Owned(self.to_string()))
216216
}
217217
}

compiler/rustc_codegen_ssa/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a> CopyPath<'a> {
161161
struct DebugArgPath<'a>(pub &'a Path);
162162

163163
impl IntoDiagArg for DebugArgPath<'_> {
164-
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
164+
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> rustc_errors::DiagArgValue {
165165
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
166166
}
167167
}
@@ -1087,7 +1087,7 @@ pub enum ExpectedPointerMutability {
10871087
}
10881088

10891089
impl IntoDiagArg for ExpectedPointerMutability {
1090-
fn into_diag_arg(self) -> DiagArgValue {
1090+
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
10911091
match self {
10921092
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
10931093
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),

compiler/rustc_const_eval/src/const_eval/error.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ impl MachineStopType for ConstEvalErrKind {
4949
| WriteThroughImmutablePointer => {}
5050
AssertFailure(kind) => kind.add_args(adder),
5151
Panic { msg, line, col, file } => {
52-
adder("msg".into(), msg.into_diag_arg());
53-
adder("file".into(), file.into_diag_arg());
54-
adder("line".into(), line.into_diag_arg());
55-
adder("col".into(), col.into_diag_arg());
52+
adder("msg".into(), msg.into_diag_arg(&mut None));
53+
adder("file".into(), file.into_diag_arg(&mut None));
54+
adder("line".into(), line.into_diag_arg(&mut None));
55+
adder("col".into(), col.into_diag_arg(&mut None));
5656
}
5757
}
5858
}

compiler/rustc_const_eval/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ impl ReportErrorExt for ResourceExhaustionInfo {
967967
}
968968

969969
impl rustc_errors::IntoDiagArg for InternKind {
970-
fn into_diag_arg(self) -> DiagArgValue {
970+
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
971971
DiagArgValue::Str(Cow::Borrowed(match self {
972972
InternKind::Static(Mutability::Not) => "static",
973973
InternKind::Static(Mutability::Mut) => "static_mut",

compiler/rustc_errors/src/diagnostic.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,17 @@ where
148148
/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to
149149
/// implement this.
150150
pub trait IntoDiagArg {
151-
fn into_diag_arg(self) -> DiagArgValue;
151+
/// Convert `Self` into a `DiagArgValue` suitable for rendering in a diagnostic.
152+
///
153+
/// It takes a `path` where "long values" could be written to, if the `DiagArgValue` is too big
154+
/// for displaying on the terminal. This path comes from the `Diag` itself. When rendering
155+
/// values that come from `TyCtxt`, like `Ty<'_>`, they can use `TyCtxt::short_string`. If a
156+
/// value has no shortening logic that could be used, the argument can be safely ignored.
157+
fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue;
152158
}
153159

154160
impl IntoDiagArg for DiagArgValue {
155-
fn into_diag_arg(self) -> DiagArgValue {
161+
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
156162
self
157163
}
158164
}
@@ -395,7 +401,7 @@ impl DiagInner {
395401
}
396402

397403
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg) {
398-
self.args.insert(name.into(), arg.into_diag_arg());
404+
self.args.insert(name.into(), arg.into_diag_arg(&mut self.long_ty_path));
399405
}
400406

401407
/// Fields used for Hash, and PartialEq trait.

0 commit comments

Comments
 (0)