Skip to content

fix: resolve compilation errors for link module #212

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

demurgos
Copy link

@demurgos demurgos commented Jun 1, 2025

The link module is currently located in the ./src/disabled directory. The content of this directory is not mounted as a module in the crate source, so it is not compiled by default. Over time, the code structure, language features and dependencies changed, but the link module was not kept up to date and now the module no longer compiles.

This commit fixes compilation errors for the existing link module. This was achieved by temporarily adding mod disabled { mod link; } in the root module and addressing all the errors reported by the compiler. While this commit is part of an overall effort of adding support for Link headers, this specific commit restricts its code changes purely to compilation errors. In particular, it does not introduce any change in behavior, and the module remains disabled.

Here is the detailed list of changes:

  • The try! macro was replaced with the try operator ? because try is a reserved keyword since Rust 2018. An alternative would have been to use r#try, however ? is more idiomatic in Rust 2018. There are no compat concerns, all Rust versions supported by headers support the edition 2018.
  • Update Header impl for Link to use the latest function signature.
  • Rephrase comment in Header::decode impl for Link (fix typo, improve clarity)
  • Use standard Result type, the code was previously relying on a local type alias for Result<T, crate::Error>.
  • Reformat with Rustfmt
  • Replace ::Error::Header with Error::invalid()
  • Remove useless semicolon in test_link_fmt_delimited
  • Replace Header::parse_header with crate::common::test_decode
  • Add module level documentation
  • Update doc tests for Link

Note: to compile, the code requires adding the dependency language_tags version 0.3.


This commit is a step towards #211.

The `link` module is currently located in the `./src/disabled` directory. The content of this directory is not mounted as a module in the crate source, so it is not compiled by default. Over time, the code structure, language features and dependencies changed, but the `link` module was not kept up to date and now the module no longer compiles.

This commit fixes compilation errors for the existing `link` module. This was achieved by temporarily adding `mod disabled { mod link; }` in the root module and addressing all the errors reported by the compiler. While this commit is part of an overall effort of adding support for `Link` headers, this specific commit restricts its code changes purely to compilation errors. In particular, it does not introduce any change in behavior, and the module remains disabled.

Here is the detailed list of changes:
- The `try!` macro was replaced with the try operator `?` because `try` is a reserved keyword since Rust 2018. An alternative would have been to use `r#try`, however `?` is more idiomatic in Rust 2018. There are no compat concerns, all Rust versions supported by `headers` support the edition 2018.
- Update `Header` impl for `Link` to use the latest function signature.
- Rephrase comment in `Header::decode` impl for `Link` (fix typo, improve clarity)
- Use standard `Result` type, the code was previously relying on a local type alias for `Result<T, crate::Error>`.
- Reformat with Rustfmt
- Replace `::Error::Header` with `Error::invalid()`
- Remove useless semicolon in `test_link_fmt_delimited`
- Replace `Header::parse_header` with `crate::common::test_decode`
- Add module level documentation
- Update doc tests for `Link`

Note: to compile, the code requires adding the dependency `language_tags` version `0.3`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant