Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned#152865
Conversation
|
|
0f12c2c to
cd2ab84
Compare
|
Reminder, once the PR becomes ready for a review, use |
…lignment is not mentioned (e.g. ':10' instead of ':<10', ':>10', or ':^1')
cd2ab84 to
d6ff921
Compare
|
@rustbot ready |
|
Great, thanks! |
Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes rust-lang#152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
Rollup of 14 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151740 (Fix short backtraces from stripped executables) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #152908 (Enable rust.remap-debuginfo in the dist profile) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152921 (Add build.rustdoc option to bootstrap config) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing)
Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes rust-lang#152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
Rollup of 15 pull requests Successful merges: - #149366 (GVN: consider constants of primitive types as deterministic) - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152657 (std: move `exit` out of PAL) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #152908 (Enable rust.remap-debuginfo in the dist profile) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152921 (Add build.rustdoc option to bootstrap config) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing)
Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes rust-lang#152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
Rollup of 14 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152657 (std: move `exit` out of PAL) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #152908 (Enable rust.remap-debuginfo in the dist profile) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152921 (Add build.rustdoc option to bootstrap config) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing)
Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes rust-lang#152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
Rollup of 13 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #152908 (Enable rust.remap-debuginfo in the dist profile) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152921 (Add build.rustdoc option to bootstrap config) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing)
Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes rust-lang#152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
Rollup of 15 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #152908 (Enable rust.remap-debuginfo in the dist profile) - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing) - #152953 (Fix typo in armv7a-vex-v5.md)
Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes rust-lang#152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
…uwer Rollup of 14 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing) - #152953 (Fix typo in armv7a-vex-v5.md)
…uwer Rollup of 14 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing) - #152953 (Fix typo in armv7a-vex-v5.md)
Rollup merge of #152865 - asder8215:path_display, r=joboet Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned Fixes #152804. `Path`'s `Display` uses `ByteStr`'s `Display`, which is where the problem was occurring. The issue was coming from `ByteStr` implementation of `fmt()` in this particular area: ```rust let Some(align) = f.align() else { return fmt_nopad(self, f); }; let nchars: usize = self .utf8_chunks() .map(|chunk| { chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } }) .sum(); let padding = f.width().unwrap_or(0).saturating_sub(nchars); let fill = f.fill(); let (lpad, rpad) = match align { fmt::Alignment::Left => (0, padding), fmt::Alignment::Right => (padding, 0), fmt::Alignment::Center => { let half = padding / 2; (half, half + padding % 2) } }; ``` The docs for the align implies that `Alignment::Left`, `Alignment::Right`, `Alignment::Center` comes from `:<`, `:>`, and `:^` respectively with `align()` returning `None` if neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like: ```rust assert_eq!(format!("{:10}", Path::new("/foo/bar").display()), "/foo/bar "); ``` We shouldn't write to `f` and return from there when there's no alignment; we should also include any potential padding/filling bytes here. r? @joboet
|
@rust-timer build 96b04ea |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (96b04ea): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never 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 2.6%, secondary 6.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.3%, secondary 13.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 481.835s -> 481.254s (-0.12%) |
|
I'm assuming LLVM optimizes away dead for loops for l_pad in I'm wondering if this is something that we can optimize in the code? |
|
Note that the regressions are all in doc builds, not sure why |
…uwer Rollup of 14 pull requests Successful merges: - rust-lang/rust#150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - rust-lang/rust#151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - rust-lang/rust#151871 (don't use env with infer vars) - rust-lang/rust#152591 (Simplify internals of `{Rc,Arc}::default`) - rust-lang/rust#152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - rust-lang/rust#147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls) - rust-lang/rust#152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - rust-lang/rust#152767 (fix typo in `carryless_mul` macro invocation) - rust-lang/rust#152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - rust-lang/rust#152871 (Fix warnings in rs{begin,end}.rs files) - rust-lang/rust#152879 (Remove `impl IntoQueryParam<P> for &'a P`.) - rust-lang/rust#152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - rust-lang/rust#152937 (remove unneeded reboxing) - rust-lang/rust#152953 (Fix typo in armv7a-vex-v5.md)
…uwer Rollup of 14 pull requests Successful merges: - rust-lang/rust#150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - rust-lang/rust#151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - rust-lang/rust#151871 (don't use env with infer vars) - rust-lang/rust#152591 (Simplify internals of `{Rc,Arc}::default`) - rust-lang/rust#152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - rust-lang/rust#147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls) - rust-lang/rust#152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - rust-lang/rust#152767 (fix typo in `carryless_mul` macro invocation) - rust-lang/rust#152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - rust-lang/rust#152871 (Fix warnings in rs{begin,end}.rs files) - rust-lang/rust#152879 (Remove `impl IntoQueryParam<P> for &'a P`.) - rust-lang/rust#152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - rust-lang/rust#152937 (remove unneeded reboxing) - rust-lang/rust#152953 (Fix typo in armv7a-vex-v5.md)
Fixes #152804.
Path'sDisplayusesByteStr'sDisplay, which is where the problem was occurring.The issue was coming from
ByteStrimplementation offmt()in this particular area:The docs for the align implies that
Alignment::Left,Alignment::Right,Alignment::Centercomes from:<,:>, and:^respectively withalign()returningNoneif neither of those symbols are used in the formatted string. However, while padding is taken care of in the aligned cases, we could still have padding for things that don't use alignment like:We shouldn't write to
fand return from there when there's no alignment; we should also include any potential padding/filling bytes here.r? @joboet