Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark fmt::formatter<..>::format() const #1566

Merged
merged 1 commit into from
Jul 14, 2024

Conversation

tchaikov
Copy link
Contributor

otherwise the tree does not build with fmt 11, like:

/usr/include/fmt/base.h: In instantiation of ‘static void fmt::v11::detail::value<Context>::format_custom_arg(void*, typename Context::parse_context_type&, Context&) [with T = crispy::native_handle<int, -1>; Formatter = fmt::v11::formatter<crispy::native_handle<int, -1> >; Context = fmt::v11::context; typename Context::parse_context_type = fmt::v11::basic_format_parse_context<char>]’:
/usr/include/fmt/base.h:1373:19:   required from ‘constexpr fmt::v11::detail::value<Context>::value(T&) [with T = const crispy::native_handle<int, -1>; Context = fmt::v11::context]’
 1373 |     custom.format = format_custom_arg<
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1374 |         value_type, typename Context::template formatter_type<value_type>>;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1631:41:   required from ‘constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = context; T = {const crispy::native_handle<int, -1>}; long unsigned int NUM_ARGS = 1; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 15; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]’
 1631 |   return {arg_mapper<Context>().map(val)};
      |                                         ^
/builddir/build/BUILD/contour-terminal-0.4.3.6442-build/contour-0.4.3.6442/src/crispy/logstore.h:111:59:   required from ‘logstore::message_builder& logstore::message_builder::operator()(std::string_view, const Ts& ...) [with Ts = {crispy::native_handle<int, -1>}; std::string_view = std::basic_string_view<char>]’
  111 |         _buffer += fmt::vformat(fmt, fmt::make_format_args(args...));
      |                                      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/builddir/build/BUILD/contour-terminal-0.4.3.6442-build/contour-0.4.3.6442/src/vtpty/UnixPty.cpp:215:13:   required from here
  215 |     ptyLog()("PTY destroying master (file descriptor {}).", _masterFd);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1392:29: error: passing ‘const fmt::v11::formatter<crispy::native_handle<int, -1> >’ as ‘this’ argument discards qualifiers [-fpermissive]
 1392 |     ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /builddir/build/BUILD/contour-terminal-0.4.3.6442-build/contour-0.4.3.6442/src/vtpty/UnixPty.h:8:

Description

Describe your changes in detail

Your issue description (body) goes here

Motivation and Context

Why is this change required? What problem does it solve?

How Has This Been Tested?

  • Please describe how you tested your changes.
  • see how your change affects other areas of the code, etc.

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

If you're unsure about any of these, don't hesitate to ask. We're here to help!

  • I have read the CONTRIBUTING document in my spoken language, and understand the terms
  • I have updated (or added) the documentation accordingly.
  • I have added tests to cover my changes.
  • I have gone through all the steps, and have thoroughly read the instructions

@github-actions github-actions bot added VT: Backend Virtual Terminal Backend (libterminal API) frontend Contour Terminal Emulator (GUI frontend) test Unit tests VT: rasterizer Rendering of the terminal into a pixmap using `terminal_renderer` library fonts font rasterization and text shaping API and platform implementations labels Jul 14, 2024
@tchaikov tchaikov force-pushed the fmt-format-const branch 2 times, most recently from d34e56f to 2fee665 Compare July 14, 2024 11:46
@Yaraslaut
Copy link
Member

Hi @tchaikov, thanks for the PR, it seems like fmt update to 11 is a breaking change, and signature for the format function is equivalent to the std::format, we are planning to switch to std::format after next release (which will happen soon). So if you can change calls to std::format instead of fmt::format we would be happy to merge this changes after next release

@tchaikov
Copy link
Contributor Author

@Yaraslaut , i would like to have atomic changes if possible, and each change should focus on one thing only. so if we are switching to std::format(), probably the first step is to correct the specializations of existing fmt::formatter, and then audit all places and switch to std::format when appropriate, what do you think?

@Yaraslaut
Copy link
Member

let's see then if we can bump fmt version in install-deps scripts

@Yaraslaut
Copy link
Member

Oh, sorry @tchaikov I though that we need to update fmt version, looks like only clang-format is required and then we can merge

mark all `fmt::formatter<..>::format()` with const specifier.

otherwise the tree does not build with fmt 11, like:

```
/usr/include/fmt/base.h: In instantiation of ‘static void fmt::v11::detail::value<Context>::format_custom_arg(void*, typename Context::parse_context_type&, Context&) [with T = crispy::native_handle<int, -1>; Formatter = fmt::v11::formatter<crispy::native_handle<int, -1> >; Context = fmt::v11::context; typename Context::parse_context_type = fmt::v11::basic_format_parse_context<char>]’:
/usr/include/fmt/base.h:1373:19:   required from ‘constexpr fmt::v11::detail::value<Context>::value(T&) [with T = const crispy::native_handle<int, -1>; Context = fmt::v11::context]’
 1373 |     custom.format = format_custom_arg<
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1374 |         value_type, typename Context::template formatter_type<value_type>>;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1631:41:   required from ‘constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = context; T = {const crispy::native_handle<int, -1>}; long unsigned int NUM_ARGS = 1; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 15; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]’
 1631 |   return {arg_mapper<Context>().map(val)};
      |                                         ^
/builddir/build/BUILD/contour-terminal-0.4.3.6442-build/contour-0.4.3.6442/src/crispy/logstore.h:111:59:   required from ‘logstore::message_builder& logstore::message_builder::operator()(std::string_view, const Ts& ...) [with Ts = {crispy::native_handle<int, -1>}; std::string_view = std::basic_string_view<char>]’
  111 |         _buffer += fmt::vformat(fmt, fmt::make_format_args(args...));
      |                                      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/builddir/build/BUILD/contour-terminal-0.4.3.6442-build/contour-0.4.3.6442/src/vtpty/UnixPty.cpp:215:13:   required from here
  215 |     ptyLog()("PTY destroying master (file descriptor {}).", _masterFd);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1392:29: error: passing ‘const fmt::v11::formatter<crispy::native_handle<int, -1> >’ as ‘this’ argument discards qualifiers [-fpermissive]
 1392 |     ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /builddir/build/BUILD/contour-terminal-0.4.3.6442-build/contour-0.4.3.6442/src/vtpty/UnixPty.h:8:
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
@tchaikov
Copy link
Contributor Author

tchaikov commented Jul 14, 2024

v2:

  • reformatted the tree with

    find ./src/ -name "*.cpp" -o -name "*.h" | xargs /usr/bin/clang-format -i
    

@Yaraslaut
Copy link
Member

Thanks @tchaikov I will merge it now

@Yaraslaut Yaraslaut merged commit b8876c5 into contour-terminal:master Jul 14, 2024
61 of 63 checks passed
@topazus
Copy link
Contributor

topazus commented Jul 17, 2024

let's see then if we can bump fmt version in install-deps scripts

It seems that the build failed after the bump to fmt 11 in install-deps scripts. https://github.com/topazus/contour/actions/runs/9969117451/job/27545529480?pr=5

@tchaikov tchaikov deleted the fmt-format-const branch July 17, 2024 09:36
@tchaikov
Copy link
Contributor Author

@topazus hi Felix, we might need to have contour-terminal/boxed-cpp#24 also to build with fmt 11.

@Yaraslaut
Copy link
Member

Thanks for contour-terminal/boxed-cpp#24 @tchaikov , I will try to update #1463 to merge it and then we can bump boxed-cpp version

@Yaraslaut
Copy link
Member

@topazus I enabled auto-merge in #1463, after the merged you can rebase and see if we can update fmt version

@topazus
Copy link
Contributor

topazus commented Jul 17, 2024

Thanks. The build succeeded with the lastest release of boxed-cpp

@topazus topazus mentioned this pull request Aug 2, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fonts font rasterization and text shaping API and platform implementations frontend Contour Terminal Emulator (GUI frontend) test Unit tests VT: Backend Virtual Terminal Backend (libterminal API) VT: rasterizer Rendering of the terminal into a pixmap using `terminal_renderer` library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants