Skip to content

Commit 4b9d803

Browse files
committed
Auto merge of rust-lang#61296 - Centril:rollup-5ad68b0, r=Centril
Rollup of 9 pull requests Successful merges: - rust-lang#60742 (Allow const parameters in array sizes to be unified) - rust-lang#60756 (Add better tests for hidden lifetimes in impl trait) - rust-lang#60928 (Changes the type `mir::Mir` into `mir::Body`) - rust-lang#61024 (tests: Centralize proc macros commonly used for testing) - rust-lang#61157 (BufReader: In Seek impl, remove extra discard_buffer call) - rust-lang#61195 (Special-case `.llvm` in mangler) - rust-lang#61202 (Print PermissionExt::mode() in octal in Documentation Examples) - rust-lang#61259 (Mailmap fixes) - rust-lang#61273 (mention that MaybeUninit is a bit like Option) Failed merges: r? @ghost
2 parents 7212685 + 9121a73 commit 4b9d803

File tree

242 files changed

+1573
-1309
lines changed

Some content is hidden

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

242 files changed

+1573
-1309
lines changed

.mailmap

+16-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# email addresses.
66
#
77

8-
Aaron Todd <[email protected]>
98
Aaron Power <[email protected]> Erin Power <[email protected]>
9+
Aaron Todd <[email protected]>
1010
Abhishek Chanda <[email protected]> Abhishek Chanda <[email protected]>
1111
Adolfo Ochagavía <[email protected]>
1212
Adrien Tétar <[email protected]>
@@ -29,8 +29,8 @@ Ariel Ben-Yehuda <[email protected]> Ariel Ben-Yehuda <[email protected]>
2929
Ariel Ben-Yehuda <[email protected]> arielb1 <[email protected]>
3030
3131
Aydin Kim <[email protected]> aydin.kim <[email protected]>
32-
Bastian Kauschke <[email protected]>
3332
Barosl Lee <[email protected]> Barosl LEE <[email protected]>
33+
Bastian Kauschke <[email protected]>
3434
3535
3636
@@ -46,22 +46,23 @@ Brian Anderson <[email protected]> <[email protected]>
4646
Brian Dawn <[email protected]>
4747
Brian Leibig <[email protected]> Brian Leibig <[email protected]>
4848
Carl-Anton Ingmarsson <[email protected]> <[email protected]>
49+
Carol (Nichols || Goulding) <[email protected]> <[email protected]>
50+
Carol (Nichols || Goulding) <[email protected]> <[email protected]>
4951
Carol (Nichols || Goulding) <[email protected]> <[email protected]>
50-
Carol (Nichols || Goulding) <[email protected]> Carol Nichols <[email protected]>
5152
Carol Willing <[email protected]>
5253
Chris C Cerami <[email protected]> Chris C Cerami <[email protected]>
5354
Chris Pressey <[email protected]>
5455
Chris Thorn <[email protected]> Chris Thorn <[email protected]>
5556
Chris Vittal <[email protected]> Christopher Vittal <[email protected]>
56-
5757
58+
5859
5960
Clinton Ryan <[email protected]>
6061
Corey Richardson <[email protected]> Elaine "See More" Nemo <[email protected]>
6162
Cyryl Płotnicki <[email protected]>
6263
Damien Schoof <[email protected]>
63-
Daniel Ramos <[email protected]>
6464
Daniel J Rollins <[email protected]>
65+
Daniel Ramos <[email protected]>
6566
David Klein <[email protected]>
6667
6768
David Ross <[email protected]>
@@ -70,18 +71,18 @@ Diggory Hardy <[email protected]> Diggory Hardy <[email protected]>
7071
7172
Dzmitry Malyshau <[email protected]>
7273
74+
Eduard-Mihai Burtescu <[email protected]>
7375
Eduardo Bautista <[email protected]> <=>
7476
75-
Eduard-Mihai Burtescu <[email protected]>
7677
7778
Elly Fong-Jones <[email protected]>
7879
7980
8081
Eric Holmes <[email protected]>
8182
8283
83-
8484
85+
8586
8687
Evgeny Sologubov
8788
Falco Hirschenberger <[email protected]> <[email protected]>
@@ -102,9 +103,9 @@ Herman J. Radtke III <[email protected]> Herman J. Radtke III <hermanradtk
102103
Ilyong Cho <[email protected]>
103104
Ivan Ivaschenko <[email protected]>
104105
J. J. Weber <[email protected]>
106+
Jakub Adam Wieczorek <[email protected]> <[email protected]>
105107
Jakub Adam Wieczorek <[email protected]> <[email protected]>
106108
Jakub Adam Wieczorek <[email protected]> <[email protected]>
107-
Jakub Adam Wieczorek <[email protected]> <[email protected]>
108109
109110
110111
James Perry <[email protected]>
@@ -119,6 +120,7 @@ Jethro Beekman <[email protected]>
119120
120121
121122
Jihyun Yu <[email protected]> Jihyun Yu <[email protected]>
123+
João Oliveira <[email protected]> joaoxsouls <[email protected]>
122124
Johann Hofmann <[email protected]> Johann <[email protected]>
123125
124126
John Hodge <[email protected]> John Hodge <[email protected]>
@@ -129,7 +131,8 @@ Jonathan S <[email protected]> Jonathan S <[email protected]>
129131
Jonathan Turner <[email protected]>
130132
131133
Joseph Martin <[email protected]>
132-
João Oliveira <[email protected]> joaoxsouls <[email protected]>
134+
135+
133136
Junyoung Cho <[email protected]>
134137
135138
@@ -145,8 +148,6 @@ Lindsey Kuper <[email protected]> <[email protected]>
145148
Luke Metz <[email protected]>
146149
147150
148-
149-
150151
Marcell Pardavi <[email protected]>
151152
Margaret Meyerhofer <[email protected]> <mmeyerho@andrew>
152153
Mark Rousskov <[email protected]>
@@ -167,12 +168,14 @@ Michael Woerister <michaelwoerister@posteo> <michaelwoerister@gmail>
167168
Mickaël Raybaud-Roig <[email protected]> m-r-r <[email protected]>
168169
169170
Mukilan Thiagarajan <[email protected]>
171+
172+
170173
171174
Nathan Wilson <[email protected]>
172175
Nathaniel Herman <[email protected]> Nathaniel Herman <[email protected]>
173176
174-
Nicole Mazzuca <[email protected]>
175177
Nick Platt <[email protected]>
178+
Nicole Mazzuca <[email protected]>
176179
177180
Oliver Schneider <[email protected]> oli-obk <[email protected]>
178181
Oliver Schneider <[email protected]> Oliver 'ker' Schneider <[email protected]>
@@ -230,8 +233,8 @@ Tim JIANG <[email protected]>
230233
Tim Joseph Dumol <[email protected]>
231234
232235
Ty Overby <[email protected]>
233-
Ulrik Sverdrup <[email protected]> bluss <bluss>
234236
Ulrik Sverdrup <[email protected]> bluss <[email protected]>
237+
Ulrik Sverdrup <[email protected]> bluss <bluss>
235238
Ulrik Sverdrup <[email protected]> Ulrik Sverdrup <root@localhost>
236239
Vadim Petrochenkov <[email protected]>
237240
Vadim Petrochenkov <[email protected]> petrochenkov <[email protected]>

src/libcore/mem.rs

+3
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,9 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
966966
///
967967
/// The compiler then knows to not make any incorrect assumptions or optimizations on this code.
968968
///
969+
/// You can think of `MaybeUninit<T>` as being a bit like `Option<T>` but without
970+
/// any of the run-time tracking and without any of the safety checks.
971+
///
969972
/// ## out-pointers
970973
///
971974
/// You can use `MaybeUninit<T>` to implement "out-pointers": instead of returning data

src/librustc/infer/error_reporting/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
652652
for sp in prior_arms {
653653
err.span_label(*sp, format!(
654654
"this is found to be of type `{}`",
655-
self.resolve_type_vars_if_possible(&last_ty),
655+
self.resolve_vars_if_possible(&last_ty),
656656
));
657657
}
658658
} else if let Some(sp) = prior_arms.last() {
@@ -1278,7 +1278,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12781278
&self,
12791279
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
12801280
) -> Option<(DiagnosticStyledString, DiagnosticStyledString)> {
1281-
let exp_found = self.resolve_type_vars_if_possible(exp_found);
1281+
let exp_found = self.resolve_vars_if_possible(exp_found);
12821282
if exp_found.references_error() {
12831283
return None;
12841284
}
@@ -1291,7 +1291,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12911291
&self,
12921292
exp_found: &ty::error::ExpectedFound<T>,
12931293
) -> Option<(DiagnosticStyledString, DiagnosticStyledString)> {
1294-
let exp_found = self.resolve_type_vars_if_possible(exp_found);
1294+
let exp_found = self.resolve_vars_if_possible(exp_found);
12951295
if exp_found.references_error() {
12961296
return None;
12971297
}

src/librustc/infer/error_reporting/need_type_info.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
2424
});
2525
match ty_opt {
2626
Some(ty) => {
27-
let ty = self.infcx.resolve_type_vars_if_possible(&ty);
27+
let ty = self.infcx.resolve_vars_if_possible(&ty);
2828
ty.walk().any(|inner_ty| {
2929
inner_ty == self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) {
3030
(&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => {
@@ -94,7 +94,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
9494
span: Span,
9595
ty: Ty<'tcx>
9696
) -> DiagnosticBuilder<'gcx> {
97-
let ty = self.resolve_type_vars_if_possible(&ty);
97+
let ty = self.resolve_vars_if_possible(&ty);
9898
let name = self.extract_type_name(&ty, None);
9999

100100
let mut err_span = span;
@@ -166,7 +166,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
166166
span: Span,
167167
ty: Ty<'tcx>
168168
) -> DiagnosticBuilder<'gcx> {
169-
let ty = self.resolve_type_vars_if_possible(&ty);
169+
let ty = self.resolve_vars_if_possible(&ty);
170170
let name = self.extract_type_name(&ty, None);
171171

172172
let mut err = struct_span_err!(self.tcx.sess,

src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
210210
_ => (),
211211
}
212212

213-
let expected_trait_ref = self.infcx.resolve_type_vars_if_possible(&ty::TraitRef {
213+
let expected_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
214214
def_id: trait_def_id,
215215
substs: expected_substs,
216216
});
217-
let actual_trait_ref = self.infcx.resolve_type_vars_if_possible(&ty::TraitRef {
217+
let actual_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
218218
def_id: trait_def_id,
219219
substs: actual_substs,
220220
});

src/librustc/infer/fudge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
7474
let (mut fudger, value) = self.probe(|snapshot| {
7575
match f() {
7676
Ok(value) => {
77-
let value = self.resolve_type_vars_if_possible(&value);
77+
let value = self.resolve_vars_if_possible(&value);
7878

7979
// At this point, `value` could in principle refer
8080
// to inference variables that have been created during

src/librustc/infer/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11741174
/// Process the region constraints and report any errors that
11751175
/// result. After this, no more unification operations should be
11761176
/// done -- or the compiler will panic -- but it is legal to use
1177-
/// `resolve_type_vars_if_possible` as well as `fully_resolve`.
1177+
/// `resolve_vars_if_possible` as well as `fully_resolve`.
11781178
pub fn resolve_regions_and_report_errors(
11791179
&self,
11801180
region_context: DefId,
@@ -1262,7 +1262,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12621262
}
12631263

12641264
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
1265-
self.resolve_type_vars_if_possible(&t).to_string()
1265+
self.resolve_vars_if_possible(&t).to_string()
12661266
}
12671267

12681268
pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String {
@@ -1271,7 +1271,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12711271
}
12721272

12731273
pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String {
1274-
self.resolve_type_vars_if_possible(t).to_string()
1274+
self.resolve_vars_if_possible(t).to_string()
12751275
}
12761276

12771277
/// If `TyVar(vid)` resolves to a type, return that type. Else, return the
@@ -1297,28 +1297,28 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12971297
self.type_variables.borrow_mut().root_var(var)
12981298
}
12991299

1300-
/// Where possible, replaces type/int/float variables in
1300+
/// Where possible, replaces type/const variables in
13011301
/// `value` with their final value. Note that region variables
1302-
/// are unaffected. If a type variable has not been unified, it
1302+
/// are unaffected. If a type/const variable has not been unified, it
13031303
/// is left as is. This is an idempotent operation that does
13041304
/// not affect inference state in any way and so you can do it
13051305
/// at will.
1306-
pub fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
1306+
pub fn resolve_vars_if_possible<T>(&self, value: &T) -> T
13071307
where
13081308
T: TypeFoldable<'tcx>,
13091309
{
13101310
if !value.needs_infer() {
13111311
return value.clone(); // avoid duplicated subst-folding
13121312
}
1313-
let mut r = resolve::OpportunisticTypeResolver::new(self);
1313+
let mut r = resolve::OpportunisticVarResolver::new(self);
13141314
value.fold_with(&mut r)
13151315
}
13161316

13171317
/// Returns first unresolved variable contained in `T`. In the
13181318
/// process of visiting `T`, this will resolve (where possible)
13191319
/// type variables in `T`, but it never constructs the final,
13201320
/// resolved type, so it's more efficient than
1321-
/// `resolve_type_vars_if_possible()`.
1321+
/// `resolve_vars_if_possible()`.
13221322
pub fn unresolved_type_vars<T>(&self, value: &T) -> Option<(Ty<'tcx>, Option<Span>)>
13231323
where
13241324
T: TypeFoldable<'tcx>,
@@ -1389,7 +1389,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13891389
where
13901390
M: FnOnce(String) -> DiagnosticBuilder<'tcx>,
13911391
{
1392-
let actual_ty = self.resolve_type_vars_if_possible(&actual_ty);
1392+
let actual_ty = self.resolve_vars_if_possible(&actual_ty);
13931393
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
13941394

13951395
// Don't report an error if actual type is `Error`.
@@ -1446,7 +1446,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
14461446
ty: Ty<'tcx>,
14471447
span: Span,
14481448
) -> bool {
1449-
let ty = self.resolve_type_vars_if_possible(&ty);
1449+
let ty = self.resolve_vars_if_possible(&ty);
14501450

14511451
// Even if the type may have no inference variables, during
14521452
// type-checking closure types are in local tables only.

src/librustc/infer/opaque_types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
286286

287287
let tcx = self.tcx;
288288

289-
let concrete_ty = self.resolve_type_vars_if_possible(&opaque_defn.concrete_ty);
289+
let concrete_ty = self.resolve_vars_if_possible(&opaque_defn.concrete_ty);
290290

291291
debug!("constrain_opaque_type: concrete_ty={:?}", concrete_ty);
292292

src/librustc/infer/outlives/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> {
168168
debug!("add_implied_bounds()");
169169

170170
for &ty in fn_sig_tys {
171-
let ty = infcx.resolve_type_vars_if_possible(&ty);
171+
let ty = infcx.resolve_vars_if_possible(&ty);
172172
debug!("add_implied_bounds: ty = {}", ty);
173173
let implied_bounds = infcx.implied_outlives_bounds(self.param_env, body_id, ty, span);
174174
self.add_outlives_bounds(Some(infcx), implied_bounds)

src/librustc/infer/outlives/obligations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
177177
sup_type, sub_region, origin
178178
);
179179

180-
let sup_type = self.resolve_type_vars_if_possible(&sup_type);
180+
let sup_type = self.resolve_vars_if_possible(&sup_type);
181181

182182
if let Some(region_bound_pairs) = region_bound_pairs_map.get(&body_id) {
183183
let outlives = &mut TypeOutlives::new(
@@ -215,7 +215,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
215215
implicit_region_bound,
216216
param_env,
217217
);
218-
let ty = self.resolve_type_vars_if_possible(&ty);
218+
let ty = self.resolve_vars_if_possible(&ty);
219219
outlives.type_must_outlive(origin, ty, region);
220220
}
221221
}

src/librustc/infer/resolve.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
use super::{InferCtxt, FixupError, FixupResult, Span, type_variable::TypeVariableOrigin};
22
use crate::mir::interpret::ConstValue;
3-
use crate::ty::{self, Ty, TyCtxt, TypeFoldable, InferConst};
3+
use crate::ty::{self, Ty, Const, TyCtxt, TypeFoldable, InferConst, TypeFlags};
44
use crate::ty::fold::{TypeFolder, TypeVisitor};
55

66
///////////////////////////////////////////////////////////////////////////
7-
// OPPORTUNISTIC TYPE RESOLVER
7+
// OPPORTUNISTIC VAR RESOLVER
88

9-
/// The opportunistic type resolver can be used at any time. It simply replaces
10-
/// type variables that have been unified with the things they have
9+
/// The opportunistic resolver can be used at any time. It simply replaces
10+
/// type/const variables that have been unified with the things they have
1111
/// been unified with (similar to `shallow_resolve`, but deep). This is
1212
/// useful for printing messages etc but also required at various
1313
/// points for correctness.
14-
pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
14+
pub struct OpportunisticVarResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
1515
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
1616
}
1717

18-
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
18+
impl<'a, 'gcx, 'tcx> OpportunisticVarResolver<'a, 'gcx, 'tcx> {
1919
#[inline]
2020
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
21-
OpportunisticTypeResolver { infcx }
21+
OpportunisticVarResolver { infcx }
2222
}
2323
}
2424

25-
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
25+
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gcx, 'tcx> {
2626
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
2727
self.infcx.tcx
2828
}
@@ -31,8 +31,17 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeResolver<'a, 'g
3131
if !t.has_infer_types() {
3232
t // micro-optimize -- if there is nothing in this type that this fold affects...
3333
} else {
34-
let t0 = self.infcx.shallow_resolve(t);
35-
t0.super_fold_with(self)
34+
let t = self.infcx.shallow_resolve(t);
35+
t.super_fold_with(self)
36+
}
37+
}
38+
39+
fn fold_const(&mut self, ct: &'tcx Const<'tcx>) -> &'tcx Const<'tcx> {
40+
if !ct.has_type_flags(TypeFlags::HAS_CT_INFER) {
41+
ct // micro-optimize -- if there is nothing in this const that this fold affects...
42+
} else {
43+
let ct = self.infcx.shallow_resolve(ct);
44+
ct.super_fold_with(self)
3645
}
3746
}
3847
}

0 commit comments

Comments
 (0)