Skip to content

Commit 5d3d347

Browse files
committed
Auto merge of rust-lang#120281 - fmease:rollup-9nxail8, r=fmease
Rollup of 10 pull requests Successful merges: - rust-lang#119028 (Add more weirdness to weird-exprs.rs) - rust-lang#119805 (Suggest array::from_fn for array initialization) - rust-lang#120188 (compiler: update freebsd and netbsd base specs.) - rust-lang#120215 (Update some deps with `bitflags` v1 dependencies) - rust-lang#120244 (Use `Self` in `NonZero*` implementations.) - rust-lang#120246 (Re-add estebank to review rotation) - rust-lang#120252 (rename `RawTy` to `LoweredTy`) - rust-lang#120255 (correct my mailmap entry) - rust-lang#120270 (A bunch of random modifications) - rust-lang#120280 (Move condition enabling the pass to `is_enabled`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dfe53af + 08bac31 commit 5d3d347

37 files changed

+296
-179
lines changed

.mailmap

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Clement Miao <[email protected]>
129129
Clément Renault <[email protected]>
130130
Cliff Dyer <[email protected]>
131131
Clinton Ryan <[email protected]>
132-
Corey Richardson <[email protected]> Elaine "See More" Nemo <[email protected]>
132+
133133
Crazycolorz5 <[email protected]>
134134
135135
Cyryl Płotnicki <[email protected]>

Cargo.lock

+77-12
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,12 @@ dependencies = [
878878

879879
[[package]]
880880
name = "ctrlc"
881-
version = "3.4.0"
881+
version = "3.4.2"
882882
source = "registry+https://github.com/rust-lang/crates.io-index"
883-
checksum = "2a011bbe2c35ce9c1f143b7af6f94f29a167beb4cd1d29e6740ce836f723120e"
883+
checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b"
884884
dependencies = [
885885
"nix",
886-
"windows-sys 0.48.0",
886+
"windows-sys 0.52.0",
887887
]
888888

889889
[[package]]
@@ -2512,14 +2512,13 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
25122512

25132513
[[package]]
25142514
name = "nix"
2515-
version = "0.26.2"
2515+
version = "0.27.1"
25162516
source = "registry+https://github.com/rust-lang/crates.io-index"
2517-
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
2517+
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
25182518
dependencies = [
2519-
"bitflags 1.3.2",
2519+
"bitflags 2.4.1",
25202520
"cfg-if",
25212521
"libc",
2522-
"static_assertions",
25232522
]
25242523

25252524
[[package]]
@@ -2641,11 +2640,11 @@ dependencies = [
26412640

26422641
[[package]]
26432642
name = "openssl"
2644-
version = "0.10.55"
2643+
version = "0.10.63"
26452644
source = "registry+https://github.com/rust-lang/crates.io-index"
2646-
checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d"
2645+
checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8"
26472646
dependencies = [
2648-
"bitflags 1.3.2",
2647+
"bitflags 2.4.1",
26492648
"cfg-if",
26502649
"foreign-types",
26512650
"libc",
@@ -2673,9 +2672,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
26732672

26742673
[[package]]
26752674
name = "openssl-sys"
2676-
version = "0.9.90"
2675+
version = "0.9.99"
26772676
source = "registry+https://github.com/rust-lang/crates.io-index"
2678-
checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6"
2677+
checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae"
26792678
dependencies = [
26802679
"cc",
26812680
"libc",
@@ -6143,6 +6142,15 @@ dependencies = [
61436142
"windows-targets 0.48.1",
61446143
]
61456144

6145+
[[package]]
6146+
name = "windows-sys"
6147+
version = "0.52.0"
6148+
source = "registry+https://github.com/rust-lang/crates.io-index"
6149+
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
6150+
dependencies = [
6151+
"windows-targets 0.52.0",
6152+
]
6153+
61466154
[[package]]
61476155
name = "windows-targets"
61486156
version = "0.42.2"
@@ -6173,6 +6181,21 @@ dependencies = [
61736181
"windows_x86_64_msvc 0.48.0",
61746182
]
61756183

6184+
[[package]]
6185+
name = "windows-targets"
6186+
version = "0.52.0"
6187+
source = "registry+https://github.com/rust-lang/crates.io-index"
6188+
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
6189+
dependencies = [
6190+
"windows_aarch64_gnullvm 0.52.0",
6191+
"windows_aarch64_msvc 0.52.0",
6192+
"windows_i686_gnu 0.52.0",
6193+
"windows_i686_msvc 0.52.0",
6194+
"windows_x86_64_gnu 0.52.0",
6195+
"windows_x86_64_gnullvm 0.52.0",
6196+
"windows_x86_64_msvc 0.52.0",
6197+
]
6198+
61766199
[[package]]
61776200
name = "windows_aarch64_gnullvm"
61786201
version = "0.42.2"
@@ -6185,6 +6208,12 @@ version = "0.48.0"
61856208
source = "registry+https://github.com/rust-lang/crates.io-index"
61866209
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
61876210

6211+
[[package]]
6212+
name = "windows_aarch64_gnullvm"
6213+
version = "0.52.0"
6214+
source = "registry+https://github.com/rust-lang/crates.io-index"
6215+
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
6216+
61886217
[[package]]
61896218
name = "windows_aarch64_msvc"
61906219
version = "0.42.2"
@@ -6197,6 +6226,12 @@ version = "0.48.0"
61976226
source = "registry+https://github.com/rust-lang/crates.io-index"
61986227
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
61996228

6229+
[[package]]
6230+
name = "windows_aarch64_msvc"
6231+
version = "0.52.0"
6232+
source = "registry+https://github.com/rust-lang/crates.io-index"
6233+
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
6234+
62006235
[[package]]
62016236
name = "windows_i686_gnu"
62026237
version = "0.42.2"
@@ -6209,6 +6244,12 @@ version = "0.48.0"
62096244
source = "registry+https://github.com/rust-lang/crates.io-index"
62106245
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
62116246

6247+
[[package]]
6248+
name = "windows_i686_gnu"
6249+
version = "0.52.0"
6250+
source = "registry+https://github.com/rust-lang/crates.io-index"
6251+
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
6252+
62126253
[[package]]
62136254
name = "windows_i686_msvc"
62146255
version = "0.42.2"
@@ -6221,6 +6262,12 @@ version = "0.48.0"
62216262
source = "registry+https://github.com/rust-lang/crates.io-index"
62226263
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
62236264

6265+
[[package]]
6266+
name = "windows_i686_msvc"
6267+
version = "0.52.0"
6268+
source = "registry+https://github.com/rust-lang/crates.io-index"
6269+
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
6270+
62246271
[[package]]
62256272
name = "windows_x86_64_gnu"
62266273
version = "0.42.2"
@@ -6233,6 +6280,12 @@ version = "0.48.0"
62336280
source = "registry+https://github.com/rust-lang/crates.io-index"
62346281
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
62356282

6283+
[[package]]
6284+
name = "windows_x86_64_gnu"
6285+
version = "0.52.0"
6286+
source = "registry+https://github.com/rust-lang/crates.io-index"
6287+
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
6288+
62366289
[[package]]
62376290
name = "windows_x86_64_gnullvm"
62386291
version = "0.42.2"
@@ -6245,6 +6298,12 @@ version = "0.48.0"
62456298
source = "registry+https://github.com/rust-lang/crates.io-index"
62466299
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
62476300

6301+
[[package]]
6302+
name = "windows_x86_64_gnullvm"
6303+
version = "0.52.0"
6304+
source = "registry+https://github.com/rust-lang/crates.io-index"
6305+
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
6306+
62486307
[[package]]
62496308
name = "windows_x86_64_msvc"
62506309
version = "0.42.2"
@@ -6257,6 +6316,12 @@ version = "0.48.0"
62576316
source = "registry+https://github.com/rust-lang/crates.io-index"
62586317
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
62596318

6319+
[[package]]
6320+
name = "windows_x86_64_msvc"
6321+
version = "0.52.0"
6322+
source = "registry+https://github.com/rust-lang/crates.io-index"
6323+
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
6324+
62606325
[[package]]
62616326
name = "winnow"
62626327
version = "0.4.7"

compiler/rustc_hir_analysis/src/autoderef.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use rustc_trait_selection::traits::StructurallyNormalizeExt;
1212

1313
#[derive(Copy, Clone, Debug)]
1414
pub enum AutoderefKind {
15+
/// A true pointer type, such as `&T` and `*mut T`.
1516
Builtin,
17+
/// A type which must dispatch to a `Deref` implementation.
1618
Overloaded,
1719
}
1820

@@ -83,6 +85,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
8385
(AutoderefKind::Builtin, ty)
8486
}
8587
} else if let Some(ty) = self.overloaded_deref_ty(self.state.cur_ty) {
88+
// The overloaded deref check already normalizes the pointee type.
8689
(AutoderefKind::Overloaded, ty)
8790
} else {
8891
return None;

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn compare_method_predicate_entailment<'tcx>(
254254
// checks. For the comparison to be valid, we need to
255255
// normalize the associated types in the impl/trait methods
256256
// first. However, because function types bind regions, just
257-
// calling `normalize_associated_types_in` would have no effect on
257+
// calling `FnCtxt::normalize` would have no effect on
258258
// any associated types appearing in the fn arguments or return
259259
// type.
260260

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::callee::{self, DeferredCallResolution};
22
use crate::errors::CtorIsPrivate;
33
use crate::method::{self, MethodCallee, SelfSource};
44
use crate::rvalue_scopes;
5-
use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, RawTy};
5+
use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy};
66
use rustc_data_structures::captures::Captures;
77
use rustc_data_structures::fx::FxHashSet;
88
use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed, MultiSpan, StashKey};
@@ -373,14 +373,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
373373
}
374374
}
375375

376-
pub fn handle_raw_ty(&self, span: Span, ty: Ty<'tcx>) -> RawTy<'tcx> {
377-
RawTy { raw: ty, normalized: self.normalize(span, ty) }
378-
}
379-
380-
pub fn to_ty(&self, ast_t: &hir::Ty<'tcx>) -> RawTy<'tcx> {
376+
pub fn to_ty(&self, ast_t: &hir::Ty<'tcx>) -> LoweredTy<'tcx> {
381377
let t = self.astconv().ast_ty_to_ty(ast_t);
382378
self.register_wf_obligation(t.into(), ast_t.span, traits::WellFormed(None));
383-
self.handle_raw_ty(ast_t.span, t)
379+
LoweredTy::from_raw(self, ast_t.span, t)
384380
}
385381

386382
pub fn to_ty_saving_user_provided_ty(&self, ast_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
@@ -396,7 +392,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
396392
ty.normalized
397393
}
398394

399-
pub(super) fn user_args_for_adt(ty: RawTy<'tcx>) -> UserArgs<'tcx> {
395+
pub(super) fn user_args_for_adt(ty: LoweredTy<'tcx>) -> UserArgs<'tcx> {
400396
match (ty.raw.kind(), ty.normalized.kind()) {
401397
(ty::Adt(_, args), _) => UserArgs { args, user_self_ty: None },
402398
(_, ty::Adt(adt, args)) => UserArgs {
@@ -801,7 +797,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
801797
hir_id: hir::HirId,
802798
span: Span,
803799
args: Option<&'tcx [hir::Expr<'tcx>]>,
804-
) -> (Res, Option<RawTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]) {
800+
) -> (Res, Option<LoweredTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]) {
805801
debug!(
806802
"resolve_ty_and_res_fully_qualified_call: qpath={:?} hir_id={:?} span={:?}",
807803
qpath, hir_id, span
@@ -825,7 +821,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
825821
// We manually call `register_wf_obligation` in the success path
826822
// below.
827823
let ty = self.astconv().ast_ty_to_ty_in_path(qself);
828-
(self.handle_raw_ty(span, ty), qself, segment)
824+
(LoweredTy::from_raw(self, span, ty), qself, segment)
829825
}
830826
QPath::LangItem(..) => {
831827
bug!("`resolve_ty_and_res_fully_qualified_call` called on `LangItem`")
@@ -1074,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10741070
pub fn instantiate_value_path(
10751071
&self,
10761072
segments: &'tcx [hir::PathSegment<'tcx>],
1077-
self_ty: Option<RawTy<'tcx>>,
1073+
self_ty: Option<LoweredTy<'tcx>>,
10781074
res: Res,
10791075
span: Span,
10801076
hir_id: hir::HirId,
@@ -1201,8 +1197,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12011197
path_segs.last().is_some_and(|PathSeg(def_id, _)| tcx.generics_of(*def_id).has_self);
12021198

12031199
let (res, self_ctor_args) = if let Res::SelfCtor(impl_def_id) = res {
1204-
let ty =
1205-
self.handle_raw_ty(span, tcx.at(span).type_of(impl_def_id).instantiate_identity());
1200+
let ty = LoweredTy::from_raw(
1201+
self,
1202+
span,
1203+
tcx.at(span).type_of(impl_def_id).instantiate_identity(),
1204+
);
12061205
match ty.normalized.ty_adt_def() {
12071206
Some(adt_def) if adt_def.has_ctor() => {
12081207
let (ctor_kind, ctor_def_id) = adt_def.non_enum_variant().ctor.unwrap();

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::method::MethodCallee;
66
use crate::TupleArgumentsFlag::*;
77
use crate::{errors, Expectation::*};
88
use crate::{
9-
struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, Needs, RawTy,
9+
struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy, Needs,
1010
TupleArgumentsFlag,
1111
};
1212
use itertools::Itertools;
@@ -1792,12 +1792,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17921792
qpath: &QPath<'tcx>,
17931793
path_span: Span,
17941794
hir_id: hir::HirId,
1795-
) -> (Res, RawTy<'tcx>) {
1795+
) -> (Res, LoweredTy<'tcx>) {
17961796
match *qpath {
17971797
QPath::Resolved(ref maybe_qself, path) => {
17981798
let self_ty = maybe_qself.as_ref().map(|qself| self.to_ty(qself).raw);
17991799
let ty = self.astconv().res_to_ty(self_ty, path, hir_id, true);
1800-
(path.res, self.handle_raw_ty(path_span, ty))
1800+
(path.res, LoweredTy::from_raw(self, path_span, ty))
18011801
}
18021802
QPath::TypeRelative(qself, segment) => {
18031803
let ty = self.to_ty(qself);
@@ -1808,7 +1808,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18081808
let ty = result
18091809
.map(|(ty, _, _)| ty)
18101810
.unwrap_or_else(|guar| Ty::new_error(self.tcx(), guar));
1811-
let ty = self.handle_raw_ty(path_span, ty);
1811+
let ty = LoweredTy::from_raw(self, path_span, ty);
18121812
let result = result.map(|(_, kind, def_id)| (kind, def_id));
18131813

18141814
// Write back the new resolution.
@@ -1818,7 +1818,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18181818
}
18191819
QPath::LangItem(lang_item, span) => {
18201820
let (res, ty) = self.resolve_lang_item_path(lang_item, span, hir_id);
1821-
(res, self.handle_raw_ty(path_span, ty))
1821+
(res, LoweredTy::from_raw(self, path_span, ty))
18221822
}
18231823
}
18241824
}

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,22 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
353353
}
354354
}
355355

356-
/// Represents a user-provided type in the raw form (never normalized).
356+
/// The `ty` representation of a user-provided type. Depending on the use-site
357+
/// we want to either use the unnormalized or the normalized form of this type.
357358
///
358359
/// This is a bridge between the interface of `AstConv`, which outputs a raw `Ty`,
359360
/// and the API in this module, which expect `Ty` to be fully normalized.
360361
#[derive(Clone, Copy, Debug)]
361-
pub struct RawTy<'tcx> {
362+
pub struct LoweredTy<'tcx> {
363+
/// The unnormalized type provided by the user.
362364
pub raw: Ty<'tcx>,
363365

364366
/// The normalized form of `raw`, stored here for efficiency.
365367
pub normalized: Ty<'tcx>,
366368
}
369+
370+
impl<'tcx> LoweredTy<'tcx> {
371+
pub fn from_raw(fcx: &FnCtxt<'_, 'tcx>, span: Span, raw: Ty<'tcx>) -> LoweredTy<'tcx> {
372+
LoweredTy { raw, normalized: fcx.normalize(span, raw) }
373+
}
374+
}

compiler/rustc_hir_typeck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use crate::check::check_fn;
4949
use crate::coercion::DynamicCoerceMany;
5050
use crate::diverges::Diverges;
5151
use crate::expectation::Expectation;
52-
use crate::fn_ctxt::RawTy;
52+
use crate::fn_ctxt::LoweredTy;
5353
use crate::gather_locals::GatherLocalsVisitor;
5454
use rustc_data_structures::unord::UnordSet;
5555
use rustc_errors::{struct_span_code_err, ErrorGuaranteed};

compiler/rustc_hir_typeck/src/method/probe.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,13 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
746746
let (xform_self_ty, xform_ret_ty) = self.xform_self_ty(item, impl_ty, impl_args);
747747
debug!("xform_self_ty: {:?}, xform_ret_ty: {:?}", xform_self_ty, xform_ret_ty);
748748

749-
// We can't use normalize_associated_types_in as it will pollute the
749+
// We can't use `FnCtxt::normalize` as it will pollute the
750750
// fcx's fulfillment context after this probe is over.
751+
//
751752
// Note: we only normalize `xform_self_ty` here since the normalization
752753
// of the return type can lead to inference results that prohibit
753754
// valid candidates from being found, see issue #85671
755+
//
754756
// FIXME Postponing the normalization of the return type likely only hides a deeper bug,
755757
// which might be caused by the `param_env` itself. The clauses of the `param_env`
756758
// maybe shouldn't include `Param`s, but rather fresh variables or be canonicalized,

0 commit comments

Comments
 (0)