Skip to content

Commit 959c2bf

Browse files
committed
Auto merge of rust-lang#139508 - Zalathar:rollup-ldbvvyf, r=compiler-errors
Rollup of 19 pull requests Successful merges: - rust-lang#138676 (Implement overflow for infinite implied lifetime bounds) - rust-lang#139024 (Make error message for missing fields with `..` and without `..` more consistent) - rust-lang#139098 (Tell LLVM about impossible niche tags) - rust-lang#139124 (compiler: report error when trait object type param reference self) - rust-lang#139321 (Update to new rinja version (askama)) - rust-lang#139346 (Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`) - rust-lang#139386 (make it possible to use stage0 libtest on compiletest) - rust-lang#139421 (Fix trait upcasting to dyn type with no principal when there are projections) - rust-lang#139468 (Don't call `Span::with_parent` on the good path in `has_stashed_diagnostic`) - rust-lang#139476 (rm `RegionInferenceContext::var_infos`) - rust-lang#139481 (Add job summary links to post-merge report) - rust-lang#139485 (compiletest: Stricter parsing for diagnostic kinds) - rust-lang#139490 (Update some comment/docs related to "extern intrinsic" removal) - rust-lang#139491 (Update books) - rust-lang#139496 (Revert r-a changes of rust-lang#139455) - rust-lang#139500 (document panic behavior of Vec::resize and Vec::resize_with) - rust-lang#139501 (Fix stack overflow in exhaustiveness due to recursive HIR opaque hidden types) - rust-lang#139504 (add missing word in doc comment) - rust-lang#139507 (compiletest: Trim whitespace from environment variable names) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c6c1796 + 7d32832 commit 959c2bf

File tree

99 files changed

+1573
-333
lines changed

Some content is hidden

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

99 files changed

+1573
-333
lines changed

Diff for: Cargo.lock

+54-5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,48 @@ version = "0.7.6"
186186
source = "registry+https://github.com/rust-lang/crates.io-index"
187187
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
188188

189+
[[package]]
190+
name = "askama"
191+
version = "0.13.0"
192+
source = "registry+https://github.com/rust-lang/crates.io-index"
193+
checksum = "9a4e46abb203e00ef226442d452769233142bbfdd79c3941e84c8e61c4112543"
194+
dependencies = [
195+
"askama_derive",
196+
"itoa",
197+
"percent-encoding",
198+
"serde",
199+
"serde_json",
200+
]
201+
202+
[[package]]
203+
name = "askama_derive"
204+
version = "0.13.0"
205+
source = "registry+https://github.com/rust-lang/crates.io-index"
206+
checksum = "54398906821fd32c728135f7b351f0c7494ab95ae421d41b6f5a020e158f28a6"
207+
dependencies = [
208+
"askama_parser",
209+
"basic-toml",
210+
"memchr",
211+
"proc-macro2",
212+
"quote",
213+
"rustc-hash 2.1.1",
214+
"serde",
215+
"serde_derive",
216+
"syn 2.0.100",
217+
]
218+
219+
[[package]]
220+
name = "askama_parser"
221+
version = "0.13.0"
222+
source = "registry+https://github.com/rust-lang/crates.io-index"
223+
checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f"
224+
dependencies = [
225+
"memchr",
226+
"serde",
227+
"serde_derive",
228+
"winnow 0.7.4",
229+
]
230+
189231
[[package]]
190232
name = "autocfg"
191233
version = "1.4.0"
@@ -1345,8 +1387,8 @@ name = "generate-copyright"
13451387
version = "0.1.0"
13461388
dependencies = [
13471389
"anyhow",
1390+
"askama",
13481391
"cargo_metadata 0.18.1",
1349-
"rinja",
13501392
"serde",
13511393
"serde_json",
13521394
"thiserror 1.0.69",
@@ -3069,9 +3111,7 @@ version = "0.3.5"
30693111
source = "registry+https://github.com/rust-lang/crates.io-index"
30703112
checksum = "3dc4940d00595430b3d7d5a01f6222b5e5b51395d1120bdb28d854bb8abb17a5"
30713113
dependencies = [
3072-
"humansize",
30733114
"itoa",
3074-
"percent-encoding",
30753115
"rinja_derive",
30763116
]
30773117

@@ -4628,6 +4668,7 @@ name = "rustdoc"
46284668
version = "0.0.0"
46294669
dependencies = [
46304670
"arrayvec",
4671+
"askama",
46314672
"base64",
46324673
"expect-test",
46334674
"indexmap",
@@ -4636,7 +4677,6 @@ dependencies = [
46364677
"pulldown-cmark 0.9.6",
46374678
"pulldown-cmark-escape",
46384679
"regex",
4639-
"rinja",
46404680
"rustdoc-json-types",
46414681
"serde",
46424682
"serde_json",
@@ -5426,7 +5466,7 @@ dependencies = [
54265466
"serde",
54275467
"serde_spanned",
54285468
"toml_datetime",
5429-
"winnow",
5469+
"winnow 0.5.40",
54305470
]
54315471

54325472
[[package]]
@@ -6437,6 +6477,15 @@ dependencies = [
64376477
"memchr",
64386478
]
64396479

6480+
[[package]]
6481+
name = "winnow"
6482+
version = "0.7.4"
6483+
source = "registry+https://github.com/rust-lang/crates.io-index"
6484+
checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36"
6485+
dependencies = [
6486+
"memchr",
6487+
]
6488+
64406489
[[package]]
64416490
name = "winsplit"
64426491
version = "0.1.0"

Diff for: bootstrap.example.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# - A new option
2929
# - A change in the default values
3030
#
31-
# If the change-id does not match the version currently in use, x.py will
31+
# If the change-id does not match the version currently in use, x.py will
3232
# display the changes made to the bootstrap.
3333
# To suppress these warnings, you can set change-id = "ignore".
3434
#change-id = <latest change id in src/bootstrap/src/utils/change_tracker.rs>
@@ -442,6 +442,9 @@
442442
# What custom diff tool to use for displaying compiletest tests.
443443
#compiletest-diff-tool = <none>
444444

445+
# Whether to use the precompiled stage0 libtest with compiletest.
446+
#compiletest-use-stage0-libtest = true
447+
445448
# Indicates whether ccache is used when building certain artifacts (e.g. LLVM).
446449
# Set to `true` to use the first `ccache` in PATH, or set an absolute path to use
447450
# a specific version.

Diff for: compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
406406
// started MIR borrowchecking with, so the region
407407
// constraints have already been taken. Use the data from
408408
// our `mbcx` instead.
409-
|vid| mbcx.regioncx.var_infos[vid].origin,
410-
|vid| mbcx.regioncx.var_infos[vid].universe,
409+
|vid| RegionVariableOrigin::Nll(mbcx.regioncx.definitions[vid].origin),
410+
|vid| mbcx.regioncx.definitions[vid].universe,
411411
)
412412
}
413413
}

Diff for: compiler/rustc_borrowck/src/diagnostics/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use rustc_errors::{Applicability, Diag, EmissionGuarantee, MultiSpan, listify};
88
use rustc_hir::def::{CtorKind, Namespace};
99
use rustc_hir::{self as hir, CoroutineKind, LangItem};
1010
use rustc_index::IndexSlice;
11-
use rustc_infer::infer::{
12-
BoundRegionConversionTime, NllRegionVariableOrigin, RegionVariableOrigin,
13-
};
11+
use rustc_infer::infer::{BoundRegionConversionTime, NllRegionVariableOrigin};
1412
use rustc_infer::traits::SelectionError;
1513
use rustc_middle::bug;
1614
use rustc_middle::mir::{
@@ -633,9 +631,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
633631
) {
634632
let predicate_span = path.iter().find_map(|constraint| {
635633
let outlived = constraint.sub;
636-
if let Some(origin) = self.regioncx.var_infos.get(outlived)
637-
&& let RegionVariableOrigin::Nll(NllRegionVariableOrigin::Placeholder(_)) =
638-
origin.origin
634+
if let Some(origin) = self.regioncx.definitions.get(outlived)
635+
&& let NllRegionVariableOrigin::Placeholder(_) = origin.origin
639636
&& let ConstraintCategory::Predicate(span) = constraint.category
640637
{
641638
Some(span)

Diff for: compiler/rustc_borrowck/src/polonius/dump.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ fn emit_mermaid_nll_regions<'tcx>(
334334
writeln!(out, "flowchart TD")?;
335335

336336
// Emit the region nodes.
337-
for region in regioncx.var_infos.indices() {
337+
for region in regioncx.definitions.indices() {
338338
write!(out, "{}[\"", region.as_usize())?;
339339
render_region(region, regioncx, out)?;
340340
writeln!(out, "\"]")?;
@@ -387,7 +387,7 @@ fn emit_mermaid_nll_sccs<'tcx>(
387387
// Gather and emit the SCC nodes.
388388
let mut nodes_per_scc: IndexVec<_, _> =
389389
regioncx.constraint_sccs().all_sccs().map(|_| Vec::new()).collect();
390-
for region in regioncx.var_infos.indices() {
390+
for region in regioncx.definitions.indices() {
391391
let scc = regioncx.constraint_sccs().scc(region);
392392
nodes_per_scc[scc].push(region);
393393
}

Diff for: compiler/rustc_borrowck/src/region_infer/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,11 @@ impl RegionTracker {
139139
}
140140

141141
pub struct RegionInferenceContext<'tcx> {
142-
pub var_infos: VarInfos,
143-
144142
/// Contains the definition for every region variable. Region
145143
/// variables are identified by their index (`RegionVid`). The
146144
/// definition contains information about where the region came
147145
/// from as well as its final inferred value.
148-
definitions: IndexVec<RegionVid, RegionDefinition<'tcx>>,
146+
pub(crate) definitions: IndexVec<RegionVid, RegionDefinition<'tcx>>,
149147

150148
/// The liveness constraints added to each region. For most
151149
/// regions, these start out empty and steadily grow, though for
@@ -453,7 +451,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
453451
Rc::new(member_constraints.into_mapped(|r| constraint_sccs.scc(r)));
454452

455453
let mut result = Self {
456-
var_infos,
457454
definitions,
458455
liveness_constraints,
459456
constraints,

Diff for: compiler/rustc_codegen_ssa/src/mir/operand.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_middle::mir::{self, ConstValue};
99
use rustc_middle::ty::Ty;
1010
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1111
use rustc_middle::{bug, span_bug};
12+
use rustc_session::config::OptLevel;
1213
use tracing::{debug, instrument};
1314

1415
use super::place::{PlaceRef, PlaceValue};
@@ -496,6 +497,18 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
496497
_ => (tag_imm, bx.cx().immediate_backend_type(tag_op.layout)),
497498
};
498499

500+
// Layout ensures that we only get here for cases where the discriminant
501+
// value and the variant index match, since that's all `Niche` can encode.
502+
// But for emphasis and debugging, let's double-check one anyway.
503+
debug_assert_eq!(
504+
self.layout
505+
.ty
506+
.discriminant_for_variant(bx.tcx(), untagged_variant)
507+
.unwrap()
508+
.val,
509+
u128::from(untagged_variant.as_u32()),
510+
);
511+
499512
let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32();
500513

501514
// We have a subrange `niche_start..=niche_end` inside `range`.
@@ -537,6 +550,21 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
537550
relative_discr,
538551
bx.cx().const_uint(tag_llty, relative_max as u64),
539552
);
553+
554+
// Thanks to parameter attributes and load metadata, LLVM already knows
555+
// the general valid range of the tag. It's possible, though, for there
556+
// to be an impossible value *in the middle*, which those ranges don't
557+
// communicate, so it's worth an `assume` to let the optimizer know.
558+
if niche_variants.contains(&untagged_variant)
559+
&& bx.cx().sess().opts.optimize != OptLevel::No
560+
{
561+
let impossible =
562+
u64::from(untagged_variant.as_u32() - niche_variants.start().as_u32());
563+
let impossible = bx.cx().const_uint(tag_llty, impossible);
564+
let ne = bx.icmp(IntPredicate::IntNE, relative_discr, impossible);
565+
bx.assume(ne);
566+
}
567+
540568
(is_niche, cast_tag, niche_variants.start().as_u32() as u128)
541569
};
542570

@@ -553,7 +581,9 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
553581
);
554582

555583
// In principle we could insert assumes on the possible range of `discr`, but
556-
// currently in LLVM this seems to be a pessimization.
584+
// currently in LLVM this isn't worth it because the original `tag` will
585+
// have either a `range` parameter attribute or `!range` metadata,
586+
// or come from a `transmute` that already `assume`d it.
557587

558588
discr
559589
}

0 commit comments

Comments
 (0)