Giter Club home page Giter Club logo

capsule-feature-error's Introduction

Configuration flags are not forwarded to rust compiler. To test this I created this repo. The following test script:

use crate::error::Error;
use core::result::Result;

const RESULT: Result<(), Error> = if cfg!(myfeature) {
    Ok(())
} else {
    panic!("myfeature not found in command line args");
};

pub fn main() -> Result<(), Error> {
    return RESULT;
}

Compiled with the following command:

capsule build --release -- --features myfeature

Or with:

capsule build --release

Results in the same kind error:

$ capsule build --release -- --features myfeature
Building contract capsule-feature-error
RUSTFLAGS=--remap-path-prefix=/home/user=~ --remap-path-prefix=/home/user/capsule-feature-error=
$ cross build -p capsule-feature-error --release --features myfeature
   Compiling capsule-feature-error v0.1.0 (/home/user/capsule-feature-error/contracts/capsule-feature-error)
error[E0080]: evaluation of constant value failed
 --> contracts/capsule-feature-error/src/entry.rs:7:5
  |
7 |     panic!("myfeature not found in command line args");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'myfeature not found in command line args', contracts/capsule-feature-error/src/entry.rs:7:5
  |
  = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (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 `capsule-feature-error` due to previous error
error: command exited with non-zero code `cross build -p capsule-feature-error --release --features myfeature`: 101

Keep up the great work ๐Ÿ’ช Phroi

PS: inverting Ok(()) and panic!("myfeature not found in command line args"); compile just fine.

capsule-feature-error's People

Contributors

phroi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.