Skip to content

Commit 10fa3c4

Browse files
committed
Auto merge of rust-lang#140336 - matthiaskrgr:rollup-kxo6ljw, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#140215 (transmutability: Support char, NonZeroXxx) - rust-lang#140226 (Update wasm-component-ld to 0.5.13) - rust-lang#140317 (Remove redundant check) - rust-lang#140318 (Simply try to unpeel AsyncFnKindHelper goal in `emit_specialized_closure_kind_error`) - rust-lang#140320 (replace `GenericArg` with `Term` where applicable) - rust-lang#140325 (Grammar fixes for BufRead::has_data_left docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5ae50d3 + 153eeb0 commit 10fa3c4

File tree

40 files changed

+573
-316
lines changed

40 files changed

+573
-316
lines changed

Cargo.lock

+26-61
Original file line numberDiff line numberDiff line change
@@ -4918,15 +4918,6 @@ dependencies = [
49184918
"color-eyre",
49194919
]
49204920

4921-
[[package]]
4922-
name = "spdx"
4923-
version = "0.10.8"
4924-
source = "registry+https://github.com/rust-lang/crates.io-index"
4925-
checksum = "58b69356da67e2fc1f542c71ea7e654a361a79c938e4424392ecf4fa065d2193"
4926-
dependencies = [
4927-
"smallvec",
4928-
]
4929-
49304921
[[package]]
49314922
name = "spdx-expression"
49324923
version = "0.5.2"
@@ -5746,9 +5737,9 @@ dependencies = [
57465737

57475738
[[package]]
57485739
name = "wasi-preview1-component-adapter-provider"
5749-
version = "29.0.1"
5740+
version = "31.0.0"
57505741
source = "registry+https://github.com/rust-lang/crates.io-index"
5751-
checksum = "dcd9f21bbde82ba59e415a8725e6ad0d0d7e9e460b1a3ccbca5bdee952c1a324"
5742+
checksum = "86fabda09a0d89ffd1615b297b4a5d4b4d99df9598aeb24685837e63019e927b"
57525743

57535744
[[package]]
57545745
name = "wasm-bindgen"
@@ -5810,17 +5801,17 @@ dependencies = [
58105801

58115802
[[package]]
58125803
name = "wasm-component-ld"
5813-
version = "0.5.12"
5804+
version = "0.5.13"
58145805
source = "registry+https://github.com/rust-lang/crates.io-index"
5815-
checksum = "580305a8e3f1b7a79859a8db897de643533b2851c5eb080fe5800233f16dec88"
5806+
checksum = "a60a07a994a3538b57d8c5f8caba19f4793fb4c7156276e5e90e90acbb829e20"
58165807
dependencies = [
58175808
"anyhow",
58185809
"clap",
58195810
"lexopt",
58205811
"libc",
58215812
"tempfile",
58225813
"wasi-preview1-component-adapter-provider",
5823-
"wasmparser 0.223.1",
5814+
"wasmparser 0.229.0",
58245815
"wat",
58255816
"windows-sys 0.59.0",
58265817
"winsplit",
@@ -5847,39 +5838,24 @@ dependencies = [
58475838

58485839
[[package]]
58495840
name = "wasm-encoder"
5850-
version = "0.223.1"
5851-
source = "registry+https://github.com/rust-lang/crates.io-index"
5852-
checksum = "7a0a96fdeaee8fbeb4bd917fb8157d48c0d61c3b1f4ee4c363c8e8d68b2f4fe8"
5853-
dependencies = [
5854-
"leb128",
5855-
"wasmparser 0.223.1",
5856-
]
5857-
5858-
[[package]]
5859-
name = "wasm-encoder"
5860-
version = "0.228.0"
5841+
version = "0.229.0"
58615842
source = "registry+https://github.com/rust-lang/crates.io-index"
5862-
checksum = "05d30290541f2d4242a162bbda76b8f2d8b1ac59eab3568ed6f2327d52c9b2c4"
5843+
checksum = "38ba1d491ecacb085a2552025c10a675a6fddcbd03b1fc9b36c536010ce265d2"
58635844
dependencies = [
58645845
"leb128fmt",
5865-
"wasmparser 0.228.0",
5846+
"wasmparser 0.229.0",
58665847
]
58675848

58685849
[[package]]
58695850
name = "wasm-metadata"
5870-
version = "0.223.1"
5851+
version = "0.229.0"
58715852
source = "registry+https://github.com/rust-lang/crates.io-index"
5872-
checksum = "e2e7e37883181704d96b89dbd8f1291be13694c71cd0663aebb94b46d235a377"
5853+
checksum = "78fdb7d29a79191ab363dc90c1ddd3a1e880ffd5348d92d48482393a9e6c5f4d"
58735854
dependencies = [
58745855
"anyhow",
58755856
"indexmap",
5876-
"serde",
5877-
"serde_derive",
5878-
"serde_json",
5879-
"spdx",
5880-
"url",
5881-
"wasm-encoder 0.223.1",
5882-
"wasmparser 0.223.1",
5857+
"wasm-encoder 0.229.0",
5858+
"wasmparser 0.229.0",
58835859
]
58845860

58855861
[[package]]
@@ -5903,9 +5879,9 @@ dependencies = [
59035879

59045880
[[package]]
59055881
name = "wasmparser"
5906-
version = "0.223.1"
5882+
version = "0.229.0"
59075883
source = "registry+https://github.com/rust-lang/crates.io-index"
5908-
checksum = "664b980991ed9a8c834eb528a8979ab1109edcf52dc05dd5751e2cc3fb31035d"
5884+
checksum = "0cc3b1f053f5d41aa55640a1fa9b6d1b8a9e4418d118ce308d20e24ff3575a8c"
59095885
dependencies = [
59105886
"bitflags",
59115887
"hashbrown",
@@ -5914,35 +5890,24 @@ dependencies = [
59145890
"serde",
59155891
]
59165892

5917-
[[package]]
5918-
name = "wasmparser"
5919-
version = "0.228.0"
5920-
source = "registry+https://github.com/rust-lang/crates.io-index"
5921-
checksum = "4abf1132c1fdf747d56bbc1bb52152400c70f336870f968b85e89ea422198ae3"
5922-
dependencies = [
5923-
"bitflags",
5924-
"indexmap",
5925-
"semver",
5926-
]
5927-
59285893
[[package]]
59295894
name = "wast"
5930-
version = "228.0.0"
5895+
version = "229.0.0"
59315896
source = "registry+https://github.com/rust-lang/crates.io-index"
5932-
checksum = "9e5aae124478cb51439f6587f074a3a5e835afd22751c59a87b2e2a882727c97"
5897+
checksum = "63fcaff613c12225696bb163f79ca38ffb40e9300eff0ff4b8aa8b2f7eadf0d9"
59335898
dependencies = [
59345899
"bumpalo",
59355900
"leb128fmt",
59365901
"memchr",
59375902
"unicode-width 0.2.0",
5938-
"wasm-encoder 0.228.0",
5903+
"wasm-encoder 0.229.0",
59395904
]
59405905

59415906
[[package]]
59425907
name = "wat"
5943-
version = "1.228.0"
5908+
version = "1.229.0"
59445909
source = "registry+https://github.com/rust-lang/crates.io-index"
5945-
checksum = "7ec29c89a8d055df988de7236483bf569988ac3d6905899f6af5ef920f9385ad"
5910+
checksum = "4189bad08b70455a9e9e67dc126d2dcf91fac143a80f1046747a5dde6d4c33e0"
59465911
dependencies = [
59475912
"wast",
59485913
]
@@ -6401,9 +6366,9 @@ dependencies = [
64016366

64026367
[[package]]
64036368
name = "wit-component"
6404-
version = "0.223.1"
6369+
version = "0.229.0"
64056370
source = "registry+https://github.com/rust-lang/crates.io-index"
6406-
checksum = "3fc2fcc52a79f6f010a89c867e53e06d4227f86c58984add3e37f32b8e7af5f0"
6371+
checksum = "7f550067740e223bfe6c4878998e81cdbe2529dd9a793dc49248dd6613394e8b"
64076372
dependencies = [
64086373
"anyhow",
64096374
"bitflags",
@@ -6412,17 +6377,17 @@ dependencies = [
64126377
"serde",
64136378
"serde_derive",
64146379
"serde_json",
6415-
"wasm-encoder 0.223.1",
6380+
"wasm-encoder 0.229.0",
64166381
"wasm-metadata",
6417-
"wasmparser 0.223.1",
6382+
"wasmparser 0.229.0",
64186383
"wit-parser",
64196384
]
64206385

64216386
[[package]]
64226387
name = "wit-parser"
6423-
version = "0.223.1"
6388+
version = "0.229.0"
64246389
source = "registry+https://github.com/rust-lang/crates.io-index"
6425-
checksum = "263fde17f1fbe55a413f16eb59094bf751795c6da469a05c3d45ea6c77df6b40"
6390+
checksum = "459c6ba62bf511d6b5f2a845a2a736822e38059c1cfa0b644b467bbbfae4efa6"
64266391
dependencies = [
64276392
"anyhow",
64286393
"id-arena",
@@ -6433,7 +6398,7 @@ dependencies = [
64336398
"serde_derive",
64346399
"serde_json",
64356400
"unicode-xid",
6436-
"wasmparser 0.223.1",
6401+
"wasmparser 0.229.0",
64376402
]
64386403

64396404
[[package]]

compiler/rustc_hir_analysis/src/check/check.rs

-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
730730
.is_ok()
731731
{
732732
check_impl_items_against_trait(tcx, def_id, impl_trait_header);
733-
check_on_unimplemented(tcx, def_id);
734733
}
735734
}
736735
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,13 @@ fn compare_method_predicate_entailment<'tcx>(
379379
// Annoyingly, asking for the WF predicates of an array (with an unevaluated const (only?))
380380
// will give back the well-formed predicate of the same array.
381381
let mut wf_args_seen: FxHashSet<_> = wf_args.iter().copied().collect();
382-
while let Some(arg) = wf_args.pop() {
382+
while let Some(term) = wf_args.pop() {
383383
let Some(obligations) = rustc_trait_selection::traits::wf::obligations(
384384
infcx,
385385
param_env,
386386
impl_m_def_id,
387387
0,
388-
arg,
388+
term,
389389
impl_m_span,
390390
) else {
391391
continue;
@@ -402,9 +402,9 @@ fn compare_method_predicate_entailment<'tcx>(
402402
| ty::ClauseKind::TypeOutlives(..)
403403
| ty::ClauseKind::Projection(..),
404404
) => ocx.register_obligation(obligation),
405-
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
406-
if wf_args_seen.insert(arg) {
407-
wf_args.push(arg)
405+
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
406+
if wf_args_seen.insert(term) {
407+
wf_args.push(term)
408408
}
409409
}
410410
_ => {}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
7676
)
7777
}
7878

79-
fn register_wf_obligation(
80-
&self,
81-
span: Span,
82-
loc: Option<WellFormedLoc>,
83-
arg: ty::GenericArg<'tcx>,
84-
) {
79+
fn register_wf_obligation(&self, span: Span, loc: Option<WellFormedLoc>, term: ty::Term<'tcx>) {
8580
let cause = traits::ObligationCause::new(
8681
span,
8782
self.body_def_id,
@@ -91,7 +86,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
9186
self.tcx(),
9287
cause,
9388
self.param_env,
94-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg))),
89+
ty::ClauseKind::WellFormed(term),
9590
));
9691
}
9792
}
@@ -1486,7 +1481,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14861481
tcx.def_span(param.def_id),
14871482
matches!(param.kind, GenericParamDefKind::Type { .. })
14881483
.then(|| WellFormedLoc::Ty(param.def_id.expect_local())),
1489-
default,
1484+
default.as_term().unwrap(),
14901485
);
14911486
}
14921487
}

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,12 @@ fn check_predicates<'tcx>(
374374

375375
// Include the well-formed predicates of the type parameters of the impl.
376376
for arg in tcx.impl_trait_ref(impl1_def_id).unwrap().instantiate_identity().args {
377+
let Some(term) = arg.as_term() else {
378+
continue;
379+
};
377380
let infcx = &tcx.infer_ctxt().build(TypingMode::non_body_analysis());
378381
let obligations =
379-
wf::obligations(infcx, tcx.param_env(impl1_def_id), impl1_def_id, 0, arg, span)
382+
wf::obligations(infcx, tcx.param_env(impl1_def_id), impl1_def_id, 0, term, span)
380383
.unwrap();
381384

382385
assert!(!obligations.has_infer());

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+15-28
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use rustc_infer::infer::{DefineOpaqueTypes, InferResult};
2222
use rustc_lint::builtin::SELF_CONSTRUCTOR_FROM_OUTER_ITEM;
2323
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
2424
use rustc_middle::ty::{
25-
self, AdtKind, CanonicalUserType, GenericArgKind, GenericArgsRef, GenericParamDefKind,
26-
IsIdentity, Ty, TyCtxt, TypeFoldable, TypeVisitable, TypeVisitableExt, UserArgs, UserSelfTy,
25+
self, AdtKind, CanonicalUserType, GenericArgsRef, GenericParamDefKind, IsIdentity, Ty, TyCtxt,
26+
TypeFoldable, TypeVisitable, TypeVisitableExt, UserArgs, UserSelfTy,
2727
};
2828
use rustc_middle::{bug, span_bug};
2929
use rustc_session::lint;
@@ -573,7 +573,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
573573
/// Registers an obligation for checking later, during regionck, that `arg` is well-formed.
574574
pub(crate) fn register_wf_obligation(
575575
&self,
576-
arg: ty::GenericArg<'tcx>,
576+
term: ty::Term<'tcx>,
577577
span: Span,
578578
code: traits::ObligationCauseCode<'tcx>,
579579
) {
@@ -583,16 +583,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
583583
self.tcx,
584584
cause,
585585
self.param_env,
586-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg))),
586+
ty::ClauseKind::WellFormed(term),
587587
));
588588
}
589589

590590
/// Registers obligations that all `args` are well-formed.
591591
pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span) {
592-
for arg in args.iter().filter(|arg| {
593-
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
594-
}) {
595-
self.register_wf_obligation(arg, span, ObligationCauseCode::WellFormed(None));
592+
for term in args.iter().filter_map(ty::GenericArg::as_term) {
593+
self.register_wf_obligation(term, span, ObligationCauseCode::WellFormed(None));
596594
}
597595
}
598596

@@ -1320,27 +1318,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13201318
infer_args: bool,
13211319
) -> ty::GenericArg<'tcx> {
13221320
let tcx = self.fcx.tcx();
1323-
match param.kind {
1324-
GenericParamDefKind::Lifetime => self
1325-
.fcx
1326-
.re_infer(
1327-
self.span,
1328-
rustc_hir_analysis::hir_ty_lowering::RegionInferReason::Param(param),
1329-
)
1330-
.into(),
1331-
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
1332-
if !infer_args && let Some(default) = param.default_value(tcx) {
1333-
// If we have a default, then it doesn't matter that we're not inferring
1334-
// the type/const arguments: We provide the default where any is missing.
1335-
return default.instantiate(tcx, preceding_args);
1336-
}
1337-
// If no type/const arguments were provided, we have to infer them.
1338-
// This case also occurs as a result of some malformed input, e.g.,
1339-
// a lifetime argument being given instead of a type/const parameter.
1340-
// Using inference instead of `Error` gives better error messages.
1341-
self.fcx.var_for_def(self.span, param)
1342-
}
1321+
if !infer_args && let Some(default) = param.default_value(tcx) {
1322+
// If we have a default, then it doesn't matter that we're not inferring
1323+
// the type/const arguments: We provide the default where any is missing.
1324+
return default.instantiate(tcx, preceding_args);
13431325
}
1326+
// If no type/const arguments were provided, we have to infer them.
1327+
// This case also occurs as a result of some malformed input, e.g.,
1328+
// a lifetime argument being given instead of a type/const parameter.
1329+
// Using inference instead of `Error` gives better error messages.
1330+
self.fcx.var_for_def(self.span, param)
13441331
}
13451332
}
13461333

compiler/rustc_hir_typeck/src/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
863863
Resolver { fcx, span, body, nested_goals, should_normalize }
864864
}
865865

866-
fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
866+
fn report_error(&self, p: impl Into<ty::Term<'tcx>>) -> ErrorGuaranteed {
867867
if let Some(guar) = self.fcx.tainted_by_errors() {
868868
guar
869869
} else {
@@ -887,7 +887,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
887887
new_err: impl Fn(TyCtxt<'tcx>, ErrorGuaranteed) -> T,
888888
) -> T
889889
where
890-
T: Into<ty::GenericArg<'tcx>> + TypeSuperFoldable<TyCtxt<'tcx>> + Copy,
890+
T: Into<ty::Term<'tcx>> + TypeSuperFoldable<TyCtxt<'tcx>> + Copy,
891891
{
892892
let tcx = self.fcx.tcx;
893893
// We must deeply normalize in the new solver, since later lints expect

compiler/rustc_infer/src/infer/mod.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ use rustc_middle::traits::solve::Goal;
3131
use rustc_middle::ty::error::{ExpectedFound, TypeError};
3232
use rustc_middle::ty::{
3333
self, BoundVarReplacerDelegate, ConstVid, FloatVid, GenericArg, GenericArgKind, GenericArgs,
34-
GenericArgsRef, GenericParamDefKind, InferConst, IntVid, PseudoCanonicalInput, Ty, TyCtxt,
35-
TyVid, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable, TypeVisitableExt, TypingEnv,
36-
TypingMode, fold_regions,
34+
GenericArgsRef, GenericParamDefKind, InferConst, IntVid, PseudoCanonicalInput, Term, TermKind,
35+
Ty, TyCtxt, TyVid, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable,
36+
TypeVisitableExt, TypingEnv, TypingMode, fold_regions,
3737
};
3838
use rustc_span::{Span, Symbol};
3939
use snapshot::undo_log::InferCtxtUndoLogs;
@@ -1401,6 +1401,16 @@ impl<'tcx> TyOrConstInferVar {
14011401
}
14021402
}
14031403

1404+
/// Tries to extract an inference variable from a type or a constant, returns `None`
1405+
/// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
1406+
/// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
1407+
pub fn maybe_from_term(term: Term<'tcx>) -> Option<Self> {
1408+
match term.unpack() {
1409+
TermKind::Ty(ty) => Self::maybe_from_ty(ty),
1410+
TermKind::Const(ct) => Self::maybe_from_const(ct),
1411+
}
1412+
}
1413+
14041414
/// Tries to extract an inference variable from a type, returns `None`
14051415
/// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`).
14061416
fn maybe_from_ty(ty: Ty<'tcx>) -> Option<Self> {

0 commit comments

Comments
 (0)