Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f820b75

Browse files
committedApr 8, 2025·
Auto merge of #139525 - Zalathar:rollup-5t5xsrw, r=Zalathar
Rollup of 10 pull requests Successful merges: - #138676 (Implement overflow for infinite implied lifetime bounds) - #139024 (Make error message for missing fields with `..` and without `..` more consistent) - #139098 (Tell LLVM about impossible niche tags) - #139124 (compiler: report error when trait object type param reference self) - #139321 (Update to new rinja version (askama)) - #139346 (Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`) - #139386 (make it possible to use stage0 libtest on compiletest) - #139421 (Fix trait upcasting to dyn type with no principal when there are projections) - #139464 (Allow for reparsing failure when reparsing a pasted metavar.) - #139490 (Update some comment/docs related to "extern intrinsic" removal) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e5fefc3 + 42fdd7d commit f820b75

File tree

52 files changed

+1003
-184
lines changed

Some content is hidden

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

52 files changed

+1003
-184
lines changed
 

‎Cargo.lock‎

Lines changed: 54 additions & 5 deletions
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"

‎bootstrap.example.toml‎

Lines changed: 4 additions & 1 deletion
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.

‎compiler/rustc_codegen_ssa/src/mir/operand.rs‎

Lines changed: 31 additions & 1 deletion
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
}

‎compiler/rustc_hir_analysis/messages.ftl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ hir_analysis_self_in_impl_self =
486486
`Self` is not valid in the self type of an impl block
487487
.note = replace `Self` with a different type
488488
489+
hir_analysis_self_in_type_alias = `Self` is not allowed in type aliases
490+
.label = `Self` is only available in impls, traits, and concrete type definitions
491+
489492
hir_analysis_self_ty_not_captured = `impl Trait` must mention the `Self` type of the trait in `use<...>`
490493
.label = `Self` type parameter is implicitly captured by this `impl Trait`
491494
.note = currently, all type parameters are required to be mentioned in the precise captures list

0 commit comments

Comments
 (0)
Please sign in to comment.