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

impl functions should use visibility of original struct / enum #24

Closed
Arnavion opened this issue Sep 15, 2017 · 3 comments
Closed

impl functions should use visibility of original struct / enum #24

Arnavion opened this issue Sep 15, 2017 · 3 comments
Labels
bug This is a BUG. The fix may be released in a patch version even if considered breaking

Comments

@Arnavion
Copy link

The functions like augment_clap and from_subcommand are currently generated without any explicit visibility. This means if the struct / enum is inside a mod then the functions are private to the mod, even if the struct itself is pub.

Instead these functions should use the visibility of the struct / enum.

@TeXitoi
Copy link
Owner

TeXitoi commented Oct 25, 2017

These functions are considered implementation details. Why would you need access to them?

@Arnavion
Copy link
Author

I don't need access to them. The codegen of your crate does.

#![feature(proc_macro)]

extern crate structopt;
extern crate structopt_derive;

mod options {
	#[derive(Debug, ::structopt_derive::StructOpt)]
	pub struct Options {
		#[structopt(subcommand)]
		pub subcommand: ::subcommands::SubCommand,
	}
}

mod subcommands {
	#[derive(Debug, ::structopt_derive::StructOpt)]
	pub enum SubCommand {
		#[structopt(name = "foo", about = "foo")]
		Foo {
			#[structopt(help = "foo", required = true)]
			bars: Vec<String>,
		},
	}
}

fn main() {
}
error[E0624]: method `from_subcommand` is private
 --> src\main.rs:7:18
  |
7 |  #[derive(Debug, ::structopt_derive::StructOpt)]
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0624]: method `augment_clap` is private
 --> src\main.rs:7:18
  |
7 |  #[derive(Debug, ::structopt_derive::StructOpt)]
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@TeXitoi
Copy link
Owner

TeXitoi commented Oct 25, 2017

Ha, great, a compilation bug with an example. I didn't get the problem on the read of the issue.

Thanks.

@TeXitoi TeXitoi added the bug This is a BUG. The fix may be released in a patch version even if considered breaking label Oct 25, 2017
@TeXitoi TeXitoi closed this as completed in 6322034 Nov 1, 2017
TeXitoi added a commit that referenced this issue Nov 1, 2017
TeXitoi added a commit that referenced this issue Nov 1, 2017
Eijebong pushed a commit to Eijebong/structopt that referenced this issue Jan 2, 2019
* edge/core pixels optimization

* added debug_asserts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a BUG. The fix may be released in a patch version even if considered breaking
Projects
None yet
Development

No branches or pull requests

2 participants