Skip to content

Commit 5ed61a4

Browse files
committed
Auto merge of #114197 - matthiaskrgr:rollup-iluf7u4, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #113773 (Don't attempt to compute layout of type referencing error) - #114107 (Prevent people from assigning me as a PR reviewer) - #114124 (tests/ui/proc-macro/*: Migrate FIXMEs to check-pass) - #114171 (Fix switch-stdout test for none unix/windows platforms) - #114172 (Fix issue_15149 test for the SGX target) - #114173 (btree/map.rs: remove "Basic usage" text) - #114174 (doc: replace wrong punctuation mark) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4734ac0 + c6c1008 commit 5ed61a4

File tree

23 files changed

+69
-78
lines changed

23 files changed

+69
-78
lines changed

Diff for: compiler/rustc_const_eval/src/const_eval/error.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ where
138138
err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
139139
ErrorHandled::TooGeneric
140140
}
141-
err_inval!(AlreadyReported(error_reported)) => ErrorHandled::Reported(error_reported),
141+
err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar),
142+
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
143+
ErrorHandled::Reported(guar.into())
144+
}
142145
err_inval!(Layout(layout_error @ LayoutError::SizeOverflow(_))) => {
143146
// We must *always* hard error on these, even if the caller wants just a lint.
144147
// The `message` makes little sense here, this is a more serious error than the

Diff for: compiler/rustc_hir_typeck/src/intrinsicck.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
122122
} else {
123123
err.note(format!("source type: `{}` ({})", from, skeleton_string(from, sk_from)))
124124
.note(format!("target type: `{}` ({})", to, skeleton_string(to, sk_to)));
125-
let mut should_delay_as_bug = false;
126-
if let Err(LayoutError::Unknown(bad_from)) = sk_from && bad_from.references_error() {
127-
should_delay_as_bug = true;
128-
}
129-
if let Err(LayoutError::Unknown(bad_to)) = sk_to && bad_to.references_error() {
130-
should_delay_as_bug = true;
131-
}
132-
if should_delay_as_bug {
125+
if let Err(LayoutError::ReferencesError(_)) = sk_from {
126+
err.delay_as_bug();
127+
} else if let Err(LayoutError::ReferencesError(_)) = sk_to {
133128
err.delay_as_bug();
134129
}
135130
}

Diff for: compiler/rustc_middle/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ middle_drop_check_overflow =
5252
overflow while adding drop-check rules for {$ty}
5353
.note = overflowed on {$overflow_ty}
5454
55+
middle_layout_references_error =
56+
the type has an unknown layout
57+
5558
middle_limit_invalid =
5659
`limit` must be a non-negative integer
5760
.label = {$error_str}

Diff for: compiler/rustc_middle/src/error.rs

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ pub enum LayoutError<'tcx> {
132132

133133
#[diag(middle_cycle)]
134134
Cycle,
135+
136+
#[diag(middle_layout_references_error)]
137+
ReferencesError,
135138
}
136139

137140
#[derive(Diagnostic)]

Diff for: compiler/rustc_middle/src/ty/layout.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir::def_id::DefId;
1010
use rustc_index::IndexVec;
1111
use rustc_session::config::OptLevel;
1212
use rustc_span::symbol::{sym, Symbol};
13-
use rustc_span::{Span, DUMMY_SP};
13+
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
1414
use rustc_target::abi::call::FnAbi;
1515
use rustc_target::abi::*;
1616
use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy, Target};
@@ -212,6 +212,7 @@ pub enum LayoutError<'tcx> {
212212
Unknown(Ty<'tcx>),
213213
SizeOverflow(Ty<'tcx>),
214214
NormalizationFailure(Ty<'tcx>, NormalizationError<'tcx>),
215+
ReferencesError(ErrorGuaranteed),
215216
Cycle,
216217
}
217218

@@ -224,6 +225,7 @@ impl<'tcx> LayoutError<'tcx> {
224225
SizeOverflow(_) => middle_values_too_big,
225226
NormalizationFailure(_, _) => middle_cannot_be_normalized,
226227
Cycle => middle_cycle,
228+
ReferencesError(_) => middle_layout_references_error,
227229
}
228230
}
229231

@@ -237,6 +239,7 @@ impl<'tcx> LayoutError<'tcx> {
237239
E::NormalizationFailure { ty, failure_ty: e.get_type_for_failure() }
238240
}
239241
Cycle => E::Cycle,
242+
ReferencesError(_) => E::ReferencesError,
240243
}
241244
}
242245
}
@@ -257,6 +260,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
257260
e.get_type_for_failure()
258261
),
259262
LayoutError::Cycle => write!(f, "a cycle occurred during layout computation"),
263+
LayoutError::ReferencesError(_) => write!(f, "the type has an unknown layout"),
260264
}
261265
}
262266
}
@@ -323,7 +327,8 @@ impl<'tcx> SizeSkeleton<'tcx> {
323327
Err(
324328
e @ LayoutError::Cycle
325329
| e @ LayoutError::SizeOverflow(_)
326-
| e @ LayoutError::NormalizationFailure(..),
330+
| e @ LayoutError::NormalizationFailure(..)
331+
| e @ LayoutError::ReferencesError(_),
327332
) => return Err(e),
328333
};
329334

Diff for: compiler/rustc_transmute/src/layout/tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub(crate) mod rustc {
195195
impl<'tcx> From<&LayoutError<'tcx>> for Err {
196196
fn from(err: &LayoutError<'tcx>) -> Self {
197197
match err {
198-
LayoutError::Unknown(..) => Self::UnknownLayout,
198+
LayoutError::Unknown(..) | LayoutError::ReferencesError(..) => Self::UnknownLayout,
199199
err => unimplemented!("{:?}", err),
200200
}
201201
}

Diff for: compiler/rustc_ty_utils/src/layout.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ fn layout_of_uncached<'tcx>(
9696
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
9797
ty: Ty<'tcx>,
9898
) -> Result<Layout<'tcx>, &'tcx LayoutError<'tcx>> {
99+
// Types that reference `ty::Error` pessimistically don't have a meaningful layout.
100+
// The only side-effect of this is possibly worse diagnostics in case the layout
101+
// was actually computable (like if the `ty::Error` showed up only in a `PhantomData`).
102+
if let Err(guar) = ty.error_reported() {
103+
return Err(error(cx, LayoutError::ReferencesError(guar)));
104+
}
105+
99106
let tcx = cx.tcx;
100107
let param_env = cx.param_env;
101108
let dl = cx.data_layout();
@@ -564,11 +571,15 @@ fn layout_of_uncached<'tcx>(
564571
return Err(error(cx, LayoutError::Unknown(ty)));
565572
}
566573

567-
ty::Bound(..) | ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) | ty::Infer(_) => {
574+
ty::Bound(..)
575+
| ty::GeneratorWitness(..)
576+
| ty::GeneratorWitnessMIR(..)
577+
| ty::Infer(_)
578+
| ty::Error(_) => {
568579
bug!("Layout::compute: unexpected type `{}`", ty)
569580
}
570581

571-
ty::Placeholder(..) | ty::Param(_) | ty::Error(_) => {
582+
ty::Placeholder(..) | ty::Param(_) => {
572583
return Err(error(cx, LayoutError::Unknown(ty)));
573584
}
574585
})

Diff for: library/alloc/src/collections/btree/map.rs

-54
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,6 @@ impl<K, V> BTreeMap<K, V> {
613613
///
614614
/// # Examples
615615
///
616-
/// Basic usage:
617-
///
618616
/// ```
619617
/// use std::collections::BTreeMap;
620618
///
@@ -636,8 +634,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
636634
///
637635
/// # Examples
638636
///
639-
/// Basic usage:
640-
///
641637
/// ```
642638
/// use std::collections::BTreeMap;
643639
///
@@ -661,8 +657,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
661657
///
662658
/// # Examples
663659
///
664-
/// Basic usage:
665-
///
666660
/// ```
667661
/// # #![feature(allocator_api)]
668662
/// # #![feature(btreemap_alloc)]
@@ -688,8 +682,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
688682
///
689683
/// # Examples
690684
///
691-
/// Basic usage:
692-
///
693685
/// ```
694686
/// use std::collections::BTreeMap;
695687
///
@@ -744,8 +736,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
744736
///
745737
/// # Examples
746738
///
747-
/// Basic usage:
748-
///
749739
/// ```
750740
/// use std::collections::BTreeMap;
751741
///
@@ -830,8 +820,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
830820
///
831821
/// # Examples
832822
///
833-
/// Basic usage:
834-
///
835823
/// ```
836824
/// use std::collections::BTreeMap;
837825
///
@@ -917,8 +905,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
917905
///
918906
/// # Examples
919907
///
920-
/// Basic usage:
921-
///
922908
/// ```
923909
/// use std::collections::BTreeMap;
924910
///
@@ -943,8 +929,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
943929
///
944930
/// # Examples
945931
///
946-
/// Basic usage:
947-
///
948932
/// ```
949933
/// use std::collections::BTreeMap;
950934
///
@@ -982,8 +966,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
982966
///
983967
/// # Examples
984968
///
985-
/// Basic usage:
986-
///
987969
/// ```
988970
/// use std::collections::BTreeMap;
989971
///
@@ -1017,8 +999,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
1017999
///
10181000
/// # Examples
10191001
///
1020-
/// Basic usage:
1021-
///
10221002
/// ```
10231003
/// #![feature(map_try_insert)]
10241004
///
@@ -1051,8 +1031,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
10511031
///
10521032
/// # Examples
10531033
///
1054-
/// Basic usage:
1055-
///
10561034
/// ```
10571035
/// use std::collections::BTreeMap;
10581036
///
@@ -1078,8 +1056,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
10781056
///
10791057
/// # Examples
10801058
///
1081-
/// Basic usage:
1082-
///
10831059
/// ```
10841060
/// use std::collections::BTreeMap;
10851061
///
@@ -1208,8 +1184,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
12081184
///
12091185
/// # Examples
12101186
///
1211-
/// Basic usage:
1212-
///
12131187
/// ```
12141188
/// use std::collections::BTreeMap;
12151189
/// use std::ops::Bound::Included;
@@ -1251,8 +1225,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
12511225
///
12521226
/// # Examples
12531227
///
1254-
/// Basic usage:
1255-
///
12561228
/// ```
12571229
/// use std::collections::BTreeMap;
12581230
///
@@ -1283,8 +1255,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
12831255
///
12841256
/// # Examples
12851257
///
1286-
/// Basic usage:
1287-
///
12881258
/// ```
12891259
/// use std::collections::BTreeMap;
12901260
///
@@ -1336,8 +1306,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
13361306
///
13371307
/// # Examples
13381308
///
1339-
/// Basic usage:
1340-
///
13411309
/// ```
13421310
/// use std::collections::BTreeMap;
13431311
///
@@ -2388,8 +2356,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
23882356
///
23892357
/// # Examples
23902358
///
2391-
/// Basic usage:
2392-
///
23932359
/// ```
23942360
/// use std::collections::BTreeMap;
23952361
///
@@ -2420,8 +2386,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
24202386
///
24212387
/// # Examples
24222388
///
2423-
/// Basic usage:
2424-
///
24252389
/// ```
24262390
/// use std::collections::BTreeMap;
24272391
///
@@ -2453,8 +2417,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
24532417
///
24542418
/// # Examples
24552419
///
2456-
/// Basic usage:
2457-
///
24582420
/// ```
24592421
/// use std::collections::BTreeMap;
24602422
///
@@ -2474,8 +2436,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
24742436
///
24752437
/// # Examples
24762438
///
2477-
/// Basic usage:
2478-
///
24792439
/// ```
24802440
/// use std::collections::BTreeMap;
24812441
///
@@ -2495,8 +2455,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
24952455
///
24962456
/// # Examples
24972457
///
2498-
/// Basic usage:
2499-
///
25002458
/// ```
25012459
/// use std::collections::BTreeMap;
25022460
///
@@ -2521,8 +2479,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25212479
///
25222480
/// # Examples
25232481
///
2524-
/// Basic usage:
2525-
///
25262482
/// ```
25272483
/// use std::collections::BTreeMap;
25282484
///
@@ -2546,8 +2502,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25462502
///
25472503
/// # Examples
25482504
///
2549-
/// Basic usage:
2550-
///
25512505
/// ```
25522506
/// use std::collections::BTreeMap;
25532507
///
@@ -2578,8 +2532,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25782532
///
25792533
/// # Examples
25802534
///
2581-
/// Basic usage:
2582-
///
25832535
/// ```
25842536
/// #![feature(btree_cursors)]
25852537
///
@@ -2619,8 +2571,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26192571
///
26202572
/// # Examples
26212573
///
2622-
/// Basic usage:
2623-
///
26242574
/// ```
26252575
/// #![feature(btree_cursors)]
26262576
///
@@ -2673,8 +2623,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26732623
///
26742624
/// # Examples
26752625
///
2676-
/// Basic usage:
2677-
///
26782626
/// ```
26792627
/// #![feature(btree_cursors)]
26802628
///
@@ -2714,8 +2662,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
27142662
///
27152663
/// # Examples
27162664
///
2717-
/// Basic usage:
2718-
///
27192665
/// ```
27202666
/// #![feature(btree_cursors)]
27212667
///

Diff for: library/core/src/borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/// Types express that they can be borrowed as some type `T` by implementing
2323
/// `Borrow<T>`, providing a reference to a `T` in the trait’s
2424
/// [`borrow`] method. A type is free to borrow as several different types.
25-
/// If it wishes to mutably borrow as the type allowing the underlying data
25+
/// If it wishes to mutably borrow as the type, allowing the underlying data
2626
/// to be modified, it can additionally implement [`BorrowMut<T>`].
2727
///
2828
/// Further, when providing implementations for additional traits, it needs

Diff for: library/std/tests/process_spawning.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(target_env="sgx"))]
2+
13
use std::env;
24
use std::fs;
35
use std::process;

0 commit comments

Comments
 (0)