Skip to content

Prevent the use of uppercase letters in HeaderName::from_static #1050

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

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

rylev
Copy link
Contributor

@rylev rylev commented Aug 30, 2022

Hopefully preventing issues like that in #1048 once and for all.

This is the error you now get if you try to use an uppercase letter in a headername:

error[E0080]: evaluation of constant value failed
   --> sdk/core/src/headers/mod.rs:204:13
    |
176 |         ensure_no_uppercase(s);
    |         ---------------------- inside `headers::HeaderName::from_static` at sdk/core/src/headers/mod.rs:176:9
...
204 |             panic!("header names must not contain any uppercase letters");
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |             |
    |             the evaluated program panicked at 'header names must not contain any uppercase letters', sdk/core/src/headers/mod.rs:204:13
    |             inside `ensure_no_uppercase` at /home/rylevick/.rustup/toolchains/1.63.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic.rs:57:9
...
265 | pub const ACCEPT: HeaderName = HeaderName::from_static("Accept");
    |                                --------------------------------- inside `headers::ACCEPT` at sdk/core/src/headers/mod.rs:265:32
    |
    = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0080`.
error: could not compile `azure_core` due to previous error

@rylev rylev requested a review from bmc-msft August 30, 2022 14:02
Copy link
Contributor

@bmc-msft bmc-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be used in HeaderName::from_cow as well?

@rylev
Copy link
Contributor Author

rylev commented Aug 30, 2022

We could but the error message is ever so slightly worse so I'm not so sure if it's the right move.

@bmc-msft bmc-msft merged commit d704026 into Azure:main Aug 30, 2022
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.

2 participants