Skip to content

Rustdoc: Methods from Deref should not be const #90855

@fee1-dead

Description

@fee1-dead
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.

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
A-rustdoc-uiArea: Rustdoc UI (generated HTML)
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
on Nov 13, 2021
GuillaumeGomez

GuillaumeGomez commented on Nov 27, 2021

@GuillaumeGomez
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @GuillaumeGomez@fee1-dead

      Issue actions

        Rustdoc: Methods from `Deref` should not be `const` · Issue #90855 · rust-lang/rust