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

Rustdoc: Methods from Deref should not be const #90855

Closed
fee1-dead opened this issue Nov 13, 2021 · 1 comment · Fixed by #91291
Closed

Rustdoc: Methods from Deref should not be const #90855

fee1-dead opened this issue Nov 13, 2021 · 1 comment · Fixed by #91291
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@fee1-dead
Copy link
Member

Screenshot:

image

Considering that rustdoc doesn't care about const_trait_impl, methods from Deref cannot be called in const contexts. Therefore it is best to hide the const modifiers when showing methods from Deref.

@fee1-dead fee1-dead added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Nov 13, 2021
@GuillaumeGomez
Copy link
Member

For more information:

const S: String = String::new();
const Y: usize = S.len();

fn main() {}

gives:

error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
 --> src/main.rs:2:18
  |
2 | const Y: usize = S.len();
  |                  ^^^^^^^

error[E0493]: destructors cannot be evaluated at compile-time
 --> src/main.rs:2:18
  |
2 | const Y: usize = S.len();
  |                  ^     - value is dropped here
  |                  |
  |                  constants cannot evaluate destructors

It is linked to #67792. So for now, let's remove this display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants