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

Raw Result in redaction macro #97

Closed
tjkirch opened this issue Jul 9, 2021 · 3 comments · Fixed by #100
Closed

Raw Result in redaction macro #97

tjkirch opened this issue Jul 9, 2021 · 3 comments · Fixed by #100

Comments

@tjkirch
Copy link

tjkirch commented Jul 9, 2021

argh/argh_derive/src/lib.rs

Lines 437 to 438 in 3298908

let method_impl = quote_spanned! { impl_span =>
fn redact_arg_values(__cmd_name: &[&str], __args: &[&str]) -> Result<Vec<String>, argh::EarlyExit> {

(Introduced in #91)

This raw Result can cause type confusion where the user's type Result alias is used instead of std::result::Result, causing compilation failure.

error[E0107]: this type alias takes 1 type argument but 2 type arguments were supplied
   --> main.rs:205:10
    |
205 | #[derive(FromArgs, PartialEq, Debug)]
    |          ^^^^^^^^- help: remove this type argument
    |          |
    |          expected 1 type argument
    |
note: type alias defined here, with 1 type parameter: `T`
   --> main.rs:23:6
    |
23  | type Result<T> = std::result::Result<T, error::Error>;
    |      ^^^^^^ -
    = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

Other places in argh use std::result::Result, and if I change that one spot to std::result::Result as well, argh and my application once again test fine.

@djc
Copy link

djc commented Jul 9, 2021

I'm seeing similar issues with String; we have some places where we shadow String with smartstring::alias::String and this makes argh fail. Note that as a regression from 0.1.4 to 0.1.5, this violates semver, so I'd recommend yanking 0.1.5 unless this can be resolved quickly.

@otavio
Copy link
Contributor

otavio commented Jul 16, 2021

This is indeed a very inconvenient issue. Could this be fixed soon?

otavio added a commit to OSSystems/compress-tools-rs that referenced this issue Jul 16, 2021
The build fails due to an error in the derive crate which causes a
type alias to be used instead of std::result::Result. This fix the error
by using the old known good release.

Refs: google/argh#97
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
tjkirch added a commit to tjkirch/coldsnap that referenced this issue Jul 30, 2021
Note: not including argh 0.1.5 because of:
google/argh#97
erickt pushed a commit that referenced this issue Aug 20, 2021
Fixes: #97
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
@yjh0502
Copy link

yjh0502 commented Aug 29, 2021

Is it possible to publish fixed version to crates.io ?

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 a pull request may close this issue.

4 participants