Conversation
Implements `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types which remove at most one occurrence of a prefix/suffix while always returning a string/slice (rather than Option), enabling easy method chaining.
Be more consistent with the otherwise top-down organization of this file.
Introduce `MacroTcbCtx` that holds everything relevant to transcription. This allows for the following changes: * Split `transcribe_sequence` and `transcribe_metavar` out of the heavily nested `transcribe` * Split `metavar_expr_concat` out of `transcribe_metavar_expr` This is a nonfunctional change.
We only called it it one place, which isn't generic and can be replaced with a field access.
Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types. Implements `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types, which remove at most one occurrence of a prefix/suffix while always returning a string/slice (rather than Option), enabling easy method chaining. ## Tracking issue rust-lang#142312 ## API ```rust impl str { pub fn trim_prefix<P: Pattern>(&self, prefix: P) -> &str; pub fn trim_suffix<P: Pattern>(&self, suffix: P) -> &str where for<'a> P::Searcher<'a>: ReverseSearcher<'a>; } impl<T> [T] { pub fn trim_prefix<P: SlicePattern<Item = T> + ?Sized>(&self, prefix: &P) -> &[T] where T: PartialEq; pub fn trim_suffix<P: SlicePattern<Item = T> + ?Sized>(&self, suffix: &P) -> &[T] where T: PartialEq; } ``` ## Examples ```rust // Method chaining assert_eq!(" <https://example.com/> ".trim().trim_prefix('<').trim_suffix('>').trim(), "https://example.com/"); // Slices let v = &[10, 40, 30]; assert_eq!(v.trim_prefix(&[10]), &[40, 30][..]); ``` ## ACP Originally proposed in rust-lang/libs-team#597
Rework #[cold] attribute parser r? `@oli-obk`
…docs, r=oli-obk Fix missing docs in `rustc_attr_parsing`
… r=oli-obk Better template for `#[repr]` attributes
…ailure, r=lolbinarycat Fix random failure when JS code is executed when the whole file was not read yet Very randomly (and rarely), when I arrived on a page with `?search=something` in the URL, I got this error:  Moving the `initSearch` function at the bottom to ensure everything has been loaded fixes the issue. PS: Sorry for the noise. Pushed to the wrong branch and rust-lang#142496 closed. ><
Ensure copy* intrinsics also perform the static self-init checks fixes rust-lang#142532 r? `@RalfJung`
…petrochenkov Refactor Translator My main motivation was to simplify the usage of `SilentEmitter` for users like rustfmt. A few refactoring opportunities arose along the way. * Replace `Translate` trait with `Translator` struct * Replace `Emitter: Translate` with `Emitter::translator` * Split `SilentEmitter` into `FatalOnlyEmitter` and `SilentEmitter`
…r=petrochenkov mbe: Refactor transcription Introduce `MacroTcbCtx` that holds everything relevant to transcription. This allows for the following changes: * Split `transcribe_sequence` and `transcribe_metavar` out of the heavily nested `transcribe` * Split `metavar_expr_concat` out of `transcribe_metavar_expr` This is a nonfunctional change.
…aumeGomez rustdoc: Remove `FormatRenderer::cache` We only called it it one place, which isn't generic and can be replaced with a field access.
|
Ah you answered right before me, don't mind me either then 😆 |
|
☀️ Test successful - checks-actions |
|
📌 Perf builds for each rolled up PR:
previous master: 5526a2f47c In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 5526a2f (parent) -> 15c701f (this PR) Test differencesShow 184 test diffsStage 1
Stage 2
Additionally, 180 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 15c701fbc995eb6c5b3a86021c18185f8eee020d --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (15c701f): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -3.0%, secondary 2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.8%, secondary 0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 1.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 692.994s -> 690.617s (-0.34%) |
|
Good chance it's #142713 based on regressions in macro expansion |
|
^ The above has identical regression results |
|
@tgross35 any thoughts on how to win back the performance lost here? |
|
I have been doing some experiments at #142815, but unfortunately haven't had any luck. I'm going to keep trying a few things but am a bit pessimistic here - the PR was only refactoring, which is making me think that using early return from smaller functions is just getting us worse codegen than the huge match statement. |
|
I still don't really know how to interpret perf results well, but is it possible the clap_derive regression is a bit spurious? The graphs on the diff seem to indicate more time spent in the backend, which doesn't make any sense for a frontend-only refactoring, and it seems to have come back down from the blip here https://perf.rust-lang.org/index.html?start=2025-06-20&end=2025-06-21&benchmark=clap_derive-4.5.32&profile=opt&scenario=full&stat=instructions%3Au&kind=raw. The tt muncher benchmarks seem more legit, and make sense with the change. I'd like to recommend triaging as accepted here; ignoring Clap, this is only a pretty small regression on a heavily recursive macro. Unfortunately I'm not having any luck getting perf back since #142815 isn't really successful. Still trying one last thing out at #142990. |
|
Yea, The |
Indeed; #142713 can stand on its own as a cleanup of messy code, but I have some more significant changes to metavariable expressions based on it. Since |
|
Ok. If you plan to make more changes in this area, then the perf impact will probably change anyway, so I think we can accept this and keep an eye on perf for future changes. @rustbot label: +perf-regression-triaged |
Rollup of 9 pull requests Successful merges: - rust-lang#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.) - rust-lang#142491 (Rework #[cold] attribute parser) - rust-lang#142494 (Fix missing docs in `rustc_attr_parsing`) - rust-lang#142495 (Better template for `#[repr]` attributes) - rust-lang#142497 (Fix random failure when JS code is executed when the whole file was not read yet) - rust-lang#142575 (Ensure copy* intrinsics also perform the static self-init checks) - rust-lang#142650 (Refactor Translator) - rust-lang#142713 (mbe: Refactor transcription) - rust-lang#142755 (rustdoc: Remove `FormatRenderer::cache`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - rust-lang#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.) - rust-lang#142491 (Rework #[cold] attribute parser) - rust-lang#142494 (Fix missing docs in `rustc_attr_parsing`) - rust-lang#142495 (Better template for `#[repr]` attributes) - rust-lang#142497 (Fix random failure when JS code is executed when the whole file was not read yet) - rust-lang#142575 (Ensure copy* intrinsics also perform the static self-init checks) - rust-lang#142650 (Refactor Translator) - rust-lang#142713 (mbe: Refactor transcription) - rust-lang#142755 (rustdoc: Remove `FormatRenderer::cache`) r? `@ghost` `@rustbot` modify labels: rollup
Successful merges:
trim_prefixandtrim_suffixmethods for bothsliceandstrtypes. #142331 (Addtrim_prefixandtrim_suffixmethods for bothsliceandstrtypes.)rustc_attr_parsing#142494 (Fix missing docs inrustc_attr_parsing)#[repr]attributes #142495 (Better template for#[repr]attributes)FormatRenderer::cache#142755 (rustdoc: RemoveFormatRenderer::cache)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup