Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4662

Rust const string calls function at compile time

VotersStop watchingWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.11.0
    • 0.12.0
    • Rust - Compiler
    • None
    • C:\Users\jake>rustup show
      Default host: x86_64-pc-windows-msvc

      stable-x86_64-pc-windows-msvc (default)
      rustc 1.30.0 (da5f414c2 2018-10-24)

    Description

      For this thrift:

      const string broker_playback_message = "mmi.developer.playback"

      Generates:

      // thrift -gen rs -out ../rust/thrift/src const_string.thrift

      pub const BROKER_PLAYBACK_MESSAGE: String = "mmi.developer.playback".to_owned();

      Fails to compile:

      error[E0015]: calls in constants are limited to tuple structs and tuple variants
      note: a limited form of compile-time function evaluation is available on a nightly compiler via `const fn`

      Fix:

      Probably want to output:

      pub const BROKER_PLAYBACK_MESSAGE: &str = "mmi.developer.playback";

       

      Looking at render_const_value() it looks like byte arrays will have the same issue.

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            allengeorge Allen George
            jeikabu J W
            Votes:
            0 Vote for this issue
            Watchers:
            2 Stop watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment