about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-06-27const checks: avoid 'top-level scope' terminologyRalf Jung-35/+19
2025-06-27Rollup merge of #143084 - RalfJung:const-eval-recursive-static-write, r=oli-obkGuillaume Gomez-19/+41
const-eval: error when initializing a static writes to that static Fixes https://github.com/rust-lang/rust/issues/142404 by also calling the relevant hook for writes, not just reads. To avoid erroring during the actual write of the initial value, we neuter the hook when popping the final stack frame. Calling the hook during writes requires changing its signature since we cannot pass in the entire interpreter any more. While doing this I also realized a gap in https://github.com/rust-lang/rust/pull/142575 for zero-sized copies on the read side, so I fixed that and added a test. r? `@oli-obk`
2025-06-27Rollup merge of #143065 - compiler-errors:enum-recovery, r=oli-obkGuillaume Gomez-16/+30
Improve recovery when users write `where:` Improve recovery of `where:`. Fixes https://github.com/rust-lang/rust/issues/143023 The erroneous suggestion was because we were seeing `:` then a type, which the original impl thought must be a struct field. Make this a bit more accurate by checking for a non-reserved ident (which should be a field name). Also, make a custom parser error for `where:` so we can continue parsing after the colon.
2025-06-27Rollup merge of #143060 - xizheyin:simplify-diag, r=oli-obkGuillaume Gomez-11/+5
Only args in main diag are saved and restored without removing the newly added ones cc rust-lang/rust#142724 Here's a more simplified approach, since we'll be storing and restoring the main diagnostic's arg, removing args newly added isn't needed in the derive subdiagnostic implementation. `remove_arg` is helpful only for manual implementation of subdiagnostic. r? ``@oli-obk``
2025-06-27Rollup merge of #143051 - Stypox:tracing-validity, r=RalfJungGuillaume Gomez-4/+11
Add tracing to `validate_operand` This PR adds a tracing call to keep track of how much time is spent in `validate_operand` and `const_validate_operand`. Let me know if more fine-grained tracing is needed (e.g. adding tracing to `validate_operand_internal` too, which is just called from those two functions). I also fixed the rustdoc of `validate_operand` and `const_validate_operand` since it was referencing an older name for the `val` parameter which was renamed in cbdcbf0d6a586792c5e0a0b8965a3179bac56120. Here is some tracing output when Miri is run on `src/tools/miri/tests/pass/hello.rs`, visualizable in [ui.perfetto.dev](https://ui.perfetto.dev/): [trace-1750932222218210.json](https://github.com/user-attachments/files/20924000/trace-1750932222218210.json) **Note: obtaining tracing output depends on https://github.com/rust-lang/miri/pull/4406, but this PR is standalone and can be merged without waiting for https://github.com/rust-lang/miri/pull/4406.** r? `@RalfJung`
2025-06-27Rollup merge of #143020 - RalfJung:codegen_fn_attrs, r=oli-obkGuillaume Gomez-1/+3
codegen_fn_attrs: make comment more precise Follow-up to https://github.com/rust-lang/rust/pull/142854. r? ``@oli-obk`` or ``@workingjubilee``
2025-06-27Rollup merge of #142818 - JonathanBrouwer:used_new_parser, r=jdonszelmannGuillaume Gomez-99/+114
Port `#[used]` to new attribute parsing infrastructure Ports `used` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 r? ``@jdonszelmann``
2025-06-27Rollup merge of #142721 - Stypox:tracing-layout-of, r=RalfJungGuillaume Gomez-21/+36
Add tracing to `InterpCx::layout_of()` This PR adds tracing calls to `instantiate_from_frame_and_normalize_erasing_regions` and to `InterpCx::layout_of()`. The latter is done by shadowing `LayoutOf`'s trait method with an inherent method on `InterpCx`. <details><summary>Previous attempt by overriding the `layout_of` query (includes downloadable `.diff` patch)</summary> This PR is meant for Miri, but requires a few changes in `rustc` code, hence why it's here. It adds tracing capabilities to the `layout_of` function in `tcx` by overriding the `layout_of` query (under `local_providers`) with a wrapper that opens a tracing span and then calls the actual `layout_of`. To make this possible, I had to make `rustc_ty_utils::layout::layout_of` public. I added an assert to ensure the `providers.layout_of` value I am replacing is actually `rustc_ty_utils::layout::layout_of`, just in case. I also considered taking the previous value in `providers.layout_of` and calling that one instead, to avoid making `layout_of` public. But then the closure would not be castable to a function pointer anymore (`providers.layout_of` is a function pointer), because it would depend on the local variable storing the previous value of `providers.layout_of`. Using a global variable would work but would rely on `unsafe` or on `Mutex`es, so I wanted to avoid it. Here is some tracing output when Miri is run on `src/tools/miri/tests/pass/hello.rs`, visualizable in https://ui.perfetto.dev: [trace-1750338860374637.json](https://github.com/user-attachments/files/20820392/trace-1750338860374637.json) Another place where I could have added tracing calls is to the `rustc_middle::ty::layout::LayoutCx` struct / `spanned_layout_of()` function, however there is no simple way to disable the tracing calls with compile-time boolean constants there (since `LayoutCx::new()` is used everywhere and referenced directly), and in any case it seems like `spanned_layout_of()` just calls `tcx.layout_of()` anyway. For completeness' sake, here is tracing output for when a tracing call is added to `spanned_layout_of()`: [trace-1750340887920584.json](https://github.com/user-attachments/files/20820609/trace-1750340887920584.json) Patch to override `layout_of` query: [tracing-layout_of-query-override.diff.txt](https://github.com/user-attachments/files/20944497/tracing-layout_of-query-override.diff.txt) </details> **Note: obtaining tracing output depends on https://github.com/rust-lang/miri/pull/4406, but this PR is standalone and can be merged without waiting for https://github.com/rust-lang/miri/pull/4406.** r? `@RalfJung`
2025-06-27Rollup merge of #142671 - davidtwco:no-default-bounds-attr, r=lcnrGuillaume Gomez-9/+16
add #![rustc_no_implicit_bounds] Follow-up from rust-lang/rust#137944. Adds a new `rustc_attrs` attribute that stops rustc from adding any default bounds. Useful for tests where default bounds just add noise and make debugging harder. After reviewing all tests with `?Sized`, these tests seem like they could probably benefit from `#![rustc_no_implicit_bounds]`. - Skipping most of `tests/ui/unsized` as these seem to want to test `?Sized` - Skipping tests that used `Box<T>` because it's still bound by `T: MetaSized` - Skipping parsing or other tests that cared about `?Sized` syntactically - Skipping tests for `derive(CoercePointee)` because this appears to check that the pointee type is relaxed with `?Sized` explicitly r? `@lcnr`
2025-06-27Auto merge of #142893 - Mark-Simulacrum:no-const-collect, r=oli-obkbors-6/+8
Stop collecting unmentioned constants This avoids generating useless dead LLVM IR. This appears to have regressed and/or been introduced in rust-lang/rust#53821 (unfortunately a very large PR - I don't see any direct discussion there of this particular change), but as far as I can tell is at least no longer necessary -- or we lack test coverage -- because none of our UI tests indicate diagnostics regressions. The adjusted codegen-units test has comments explicitly noting that these items should *not* be collected ("These are not referenced, so they do not produce mono-items"). I noticed this while looking at libcore LLVM IR we generate, which contained dead code references to the NOOP Waker item, which is never used inside libcore. Producing LLVM IR for it during libcore's compilation, only for that IR to get deleted by LLVM as unused, isn't useful. Note that the IR is generally all marked internal, too.
2025-06-27const-eval: error when initializing a static writes to that staticRalf Jung-19/+41
2025-06-27rustc_codegen_gcc: Fix clippy::manual_is_multiple_ofPhilipp Krones-2/+3
2025-06-27Generate symbols.o for proc-macros toobjorn3-2/+7
To ensure used statics are functioning correctly for proc-macros too.
2025-06-27Add InterpCx::layout_of with tracing, shadowing LayoutOfStypox-20/+29
2025-06-27Update commentsbjorn3-5/+8
2025-06-27Insert checks for enum discriminants when debug assertions are enabledBastian Kersting-2/+553
Similar to the existing nullpointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@.
2025-06-27Add tracing for instantiate_from_frame_and_normalize_erasing_regionsStypox-1/+7
2025-06-27Add tracing to validate_operandStypox-0/+7
2025-06-27Report infer ty errors during hir ty loweringOli Scherer-187/+92
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
2025-06-27Port `#[used]` to new attribute parsing infrastructureJonathan Brouwer-99/+114
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-27codegen_fn_attrs: make comment more preciseRalf Jung-1/+3
2025-06-27Auto merge of #142223 - compiler-errors:perf-wf, r=lcnrbors-3/+94
Fast path for WF goals in new solver Hopefully self-explanatory.
2025-06-27Auto merge of #143074 - compiler-errors:rollup-cv64hdh, r=compiler-errorsbors-561/+684
Rollup of 18 pull requests Successful merges: - rust-lang/rust#137843 (make RefCell unstably const) - rust-lang/rust#140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns) - rust-lang/rust#142549 (small iter.intersperse.fold() optimization) - rust-lang/rust#142637 (Remove some glob imports from the type system) - rust-lang/rust#142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation) - rust-lang/rust#142700 (Remove incorrect comments in `Weak`) - rust-lang/rust#142927 (Add note to `find_const_ty_from_env`) - rust-lang/rust#142967 (Fix RwLock::try_write documentation for WouldBlock condition) - rust-lang/rust#142986 (Port `#[export_name]` to the new attribute parsing infrastructure) - rust-lang/rust#143001 (Rename run always ) - rust-lang/rust#143010 (Update `browser-ui-test` version to `0.20.7`) - rust-lang/rust#143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`) - rust-lang/rust#143033 (Expand const-stabilized API links in relnotes) - rust-lang/rust#143041 (Remove cache for citool) - rust-lang/rust#143056 (Move an ACE test out of the GCI directory) - rust-lang/rust#143059 (Fix 1.88 relnotes) - rust-lang/rust#143067 (Tracking issue number for `iter_macro`) - rust-lang/rust#143073 (Fix some fixmes that were waiting for let chains) Failed merges: - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26Rollup merge of #143073 - yotamofek:pr/fix-let-chains-fixmes, r=compiler-errorsMichael Goulet-9/+8
Fix some fixmes that were waiting for let chains Was inspired by looking at rust-lang/rust#143066 and spotting two fixmes that were missed, so... r? `@compiler-errors` 😅 Yay, let chains!
2025-06-26Rollup merge of #143015 - samueltardieu:pin-macro-diag-item, r=UrgauMichael Goulet-0/+1
Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`
2025-06-26Rollup merge of #142986 - JonathanBrouwer:export_name_parser, r=jdonszelmannMichael Goulet-101/+117
Port `#[export_name]` to the new attribute parsing infrastructure This PR contains two changes, in separate commits for reviewability: - Ports `export_name` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 - Moves the check for mixing export_name/no_mangle to check_attr.rs and improve the error message, which previously had a mix of 2021/2024 edition syntax r? ``@jdonszelmann``
2025-06-26Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwUMichael Goulet-48/+64
Add note to `find_const_ty_from_env` Add a note to `find_const_ty_from_env` to explain why it has an `unwrap` which "often" causes ICEs. Also, uplift it into the new trait solver. This avoids needing to go through the interner to call this method which is otherwise an inherent method in the compiler. I can remove this part if desired. r? `@boxyuwu`
2025-06-26Rollup merge of #142647 - compiler-errors:less-work-in-coherence, r=lcnrMichael Goulet-18/+28
[perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation First compute hard errors without diagnostics, then ambiguities with diagnostics since we need to know if any of them overflowed.
2025-06-26Rollup merge of #142637 - compiler-errors:less-globs, r=lcnrMichael Goulet-208/+259
Remove some glob imports from the type system Namely, remove the glob imports for `BoundRegionConversionTime`, `RegionVariableOrigin`, `SubregionOrigin`, `TyOrConstInferVar`, `RegionResolutionError`, `SelectionError`, `ProjectionCandidate`, `ProjectionCandidateSet`, and some more specific scoped globs (like `Inserted` in the impl overlap graph construction. These glob imports are IMO very low value, since they're not used nearly as often as other globs (like `TyKind`).
2025-06-26Rollup merge of #140942 - RalfJung:const-ref-to-mut, r=oli-obkMichael Goulet-177/+207
const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns This fixes https://github.com/rust-lang/rust/issues/140653 by accepting code such as this: ```rust static FOO: AtomicU32 = AtomicU32::new(0); const C: &'static AtomicU32 = &FOO; ``` This can be written entirely in safe code, so there can't really be anything wrong with it. We also accept the much more questionable following code, since it looks very similar to the interpreter: ```rust static mut FOO2: u32 = 0; const C2: &'static u32 = unsafe { &mut FOO2 }; ``` Using this without causing UB is at least very hard (the details are unclear since it is related to how the aliasing model deals with the staging of const-eval vs runtime code). If a constant like `C2` is used as a pattern, we emit an error: ``` error: constant BAD_PATTERN cannot be used as pattern --> $DIR/const_refs_to_static_fail.rs:30:9 | LL | BAD_PATTERN => {}, | ^^^^^^^^^^^ | = note: constants that reference mutable or external memory cannot be used as pattern ``` (If you somehow manage to build a pattern with constant `C`, you'd get the same error, but that should be impossible: we don't have a type that can be used in patterns and that has interior mutability.) The same treatment is afforded for shared references to `extern static`, for the same reason: the const evaluation is entirely fine with it, we just can't build a pattern for it -- and when using interior mutability, this can be totally sound. We do still not accept anything where there is an `&mut` in the final value of the const, as that should always require unsafe code and it's hard to imagine a sound use-case that would require this.
2025-06-26Fix some fixmes that were waiting for let chainsYotam Ofek-9/+8
2025-06-26Auto merge of #143057 - matthiaskrgr:rollup-bulih8o, r=matthiaskrgrbors-308/+305
Rollup of 8 pull requests Successful merges: - rust-lang/rust#124595 (Suggest cloning `Arc` moved into closure) - rust-lang/rust#139594 (Simplify `ObligationCauseCode::IfExpression`) - rust-lang/rust#141311 (make `tidy-alphabetical` use a natural sort) - rust-lang/rust#141648 ([rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion) - rust-lang/rust#142285 (tests: Do not run afoul of asm.validity.non-exhaustive in input-stats) - rust-lang/rust#142393 (Don't give APITs names with macro expansion placeholder fragments in it) - rust-lang/rust#142884 (StableMIR: Add method to retrieve body of coroutine) - rust-lang/rust#142981 (Make missing lifetime suggestion verbose) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26Better recoveryMichael Goulet-0/+14
2025-06-26Make recovery for enum with struct field a bit more accurateMichael Goulet-1/+2
2025-06-26Add Ident::is_non_reserved_identMichael Goulet-15/+14
2025-06-26Auto merge of #142774 - lcnr:search_graph-2, r=oli-obkbors-163/+73
`evaluate_goal` avoid unnecessary step based on rust-lang/rust#142617. This does not mess with the debug logging for the trait solver and is a very nice cleanup for rust-lang/rust#142735. E.g. for ```rust #[derive(Clone)] struct Wrapper<T>(T); #[derive(Clone)] struct Nested; // using a separate type to avoid the fast paths fn is_clone<T: Clone>() {} fn main() { is_clone::<Wrapper<Nested>>(); } ``` We get the following proof tree with `RUSTC_LOG=rustc_type_ir::search_graph=debug,rustc_next_trait_solver=debug` ``` rustc_next_trait_solver::solve::eval_ctxt::evaluate_root_goal goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Wrapper<Nested> as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, generate_proof_tree=No, span=src/main.rs:7:5: 7:34 (#0), stalled_on=None rustc_type_ir::search_graph::evaluate_goal input=CanonicalQueryInput { canonical: Canonical { value: QueryInput { goal: Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Wrapper<Nested> as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }, typing_mode: Analysis { defining_opaque_types_and_generators: [] } }, step_kind_from_parent=Unknown rustc_next_trait_solver::solve::eval_ctxt::probe::enter source=Impl(DefId(0:10 ~ main[21d2]::{impl#0})) rustc_next_trait_solver::solve::eval_ctxt::add_goal source=ImplWhereBound, goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<_ as std::marker::Sized>, polarity:Positive), bound_vars: [] } } rustc_next_trait_solver::solve::eval_ctxt::add_goal source=ImplWhereBound, goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<_ as std::clone::Clone>, polarity:Positive), bound_vars: [] } } rustc_type_ir::search_graph::evaluate_goal input=CanonicalQueryInput { canonical: Canonical { value: QueryInput { goal: Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Nested as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }, typing_mode: Analysis { defining_opaque_types_and_generators: [] } }, step_kind_from_parent=Unknown 0ms DEBUG rustc_type_ir::search_graph global cache hit, required_depth=0 0ms DEBUG rustc_type_ir::search_graph return=Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) rustc_next_trait_solver::solve::eval_ctxt::probe::enter source=BuiltinImpl(Misc) rustc_next_trait_solver::solve::trait_goals::merge_trait_candidates candidates=[Candidate { source: Impl(DefId(0:10 ~ main[21d2]::{impl#0})), result: Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] } }] 0ms DEBUG rustc_next_trait_solver::solve::trait_goals return=Ok((Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }, Some(Misc))) 0ms DEBUG rustc_type_ir::search_graph insert global cache, evaluation_result=EvaluationResult { encountered_overflow: false, required_depth: 1, heads: CycleHeads { heads: {} }, nested_goals: NestedGoals { nested_goals: {} }, result: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) } 0ms DEBUG rustc_type_ir::search_graph return=Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) ```
2025-06-26clarify and unify 'transient mutable borrow' errorsRalf Jung-51/+22
2025-06-26const-eval: allow constants to refer to mutable/external memory, but reject ↵Ralf Jung-126/+185
such constants as patterns
2025-06-26Add a note and one more fast pathMichael Goulet-0/+23
2025-06-26Shallowly bail from coerce_unsized moreMichael Goulet-0/+25
2025-06-26Assert shallow resolved args in coerceMichael Goulet-19/+22
2025-06-26Only args in main diag are saved and restored without removing the newly ↵xizheyin-11/+5
added ones Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-26Rollup merge of #142981 - compiler-errors:verbose-missing-suggestion, r=estebankMatthias Krüger-6/+1
Make missing lifetime suggestion verbose I keep seeing this suggestion when working on rustc, and it's annoying that it's inline. Part of https://github.com/rust-lang/rust/issues/141973. Feel free to close this if there's another PR already doing this. r? ``@estebank``
2025-06-26Rollup merge of #142884 - makai410:coroutine-body, r=celinvalMatthias Krüger-0/+6
StableMIR: Add method to retrieve body of coroutine It would be handy if we can retrieve body of a coroutine in StableMIR.
2025-06-26Rollup merge of #142393 - compiler-errors:nofield, r=petrochenkovMatthias Krüger-9/+33
Don't give APITs names with macro expansion placeholder fragments in it The `DefCollector` previously called `pprust::ty_to_string` to construct a name for APITs (arg-position impl traits). The `ast::Ty` that was being formatted however has already had its macro calls replaced with "placeholder fragments", which end up rendering like `!()` (or ICEing, in the case of rust-lang/rust#140333, since it led to a placeholder struct field with no name). Instead, collect the name of the APIT *before* we visit its macros and replace them with placeholders in the macro expander. This makes the implementation a bit more involved, but AFAICT there's no better way to do this since we can't do a reverse mapping from placeholder fragment -> original macro call AST. Fixes rust-lang/rust#140333
2025-06-26Rollup merge of #141648 - GuillaumeGomez:redundant_explicit_links-expansion, ↵Matthias Krüger-37/+66
r=lolbinarycat [rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion Fixes https://github.com/rust-lang/rust/issues/141553. The problem was that we change the context for the attributes in some cases to get better error output, preventing us to detect if the attribute comes from expansion. Most of the changes are about keeping track of the "does this span comes from expansion" information. r? ```@Manishearth```
2025-06-26Rollup merge of #141311 - folkertdev:tidy-natural-sort, r=jieyouxuMatthias Krüger-40/+40
make `tidy-alphabetical` use a natural sort The idea here is that these lines should be correctly sorted, even though a naive string comparison would say they are not: ``` foo2 foo10 ``` This is the ["natural sort order"](https://en.wikipedia.org/wiki/Natural_sort_order). There is more discussion in [#t-compiler/help > tidy natural sort](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tidy.20natural.20sort/with/519111079) Unfortunately, no standard sorting tools are smart enough to to this automatically (casting some doubt on whether we should make this change). Here are some sort outputs: ``` > cat foo.txt | sort foo foo1 foo10 foo2 mp mp1e2 np", np1e2", > cat foo.txt | sort -n foo foo1 foo10 foo2 mp mp1e2 np", np1e2", > cat foo.txt | sort -V foo foo1 foo2 foo10 mp mp1e2 np1e2", np", ``` Disappointingly, "numeric" sort does not actually have the behavior we want. It only sorts by numeric value if the line starts with a number. The "version" sort looks promising, but does something very unintuitive if you look at the final 4 values. None of the other options seem to have the desired behavior in all cases: ``` -b, --ignore-leading-blanks ignore leading blanks -d, --dictionary-order consider only blanks and alphanumeric characters -f, --ignore-case fold lower case to upper case characters -g, --general-numeric-sort compare according to general numerical value -i, --ignore-nonprinting consider only printable characters -M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC' -h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G) -n, --numeric-sort compare according to string numerical value -R, --random-sort shuffle, but group identical keys. See shuf(1) --random-source=FILE get random bytes from FILE -r, --reverse reverse the result of comparisons --sort=WORD sort according to WORD: general-numeric -g, human-numeric -h, month -M, numeric -n, random -R, version -V -V, --version-sort natural sort of (version) numbers within text ``` r? ```@Noratrieb``` (it sounded like you know this code?)
2025-06-26Rollup merge of #139594 - compiler-errors:if-cause, r=oli-obkMatthias Krüger-187/+132
Simplify `ObligationCauseCode::IfExpression` This originally started out as an experiment to do less incremental invalidation by deferring the span operations that happen on the good path in `check_expr_if`, but it ended up not helping much (or at least not showing up in our incremental tests). As a side-effect though, I think the code is a lot cleaner and there are modest diagnostics improvements with overlapping spans, so I think it's still worth landing.
2025-06-26Rollup merge of #124595 - estebank:issue-104232, r=davidtwcoMatthias Krüger-29/+27
Suggest cloning `Arc` moved into closure ``` error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-capture-clause-bad.rs:9:20 | LL | let x = "Hello world!".to_string(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait LL | thread::spawn(move || { | ------- value moved into closure here LL | println!("{}", x); | - variable moved due to use in closure LL | }); LL | println!("{}", x); | ^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value before moving it into the closure | LL ~ let value = x.clone(); LL ~ thread::spawn(move || { LL ~ println!("{}", value); | ``` Fix rust-lang/rust#104232.
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-94/+108