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

Contradictory E0423 (constructor not visible due to private fields) when attributes are not in scope #66853

Closed
boxofrox opened this issue Nov 28, 2019 · 2 comments

Comments

@boxofrox
Copy link

Example at https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0a4268fac37b445aada5d32934c465ae.

I'm upgrading a 2015 project to 2018 and ran into a wall of errors. I started with the E0423 (as seen in the example), but couldn't figure out why Rust thought this struct had private fields.

error[E0423]: expected function, found struct `Sequence`
 --> src/main.rs:7:19
  |
7 |     let payload = Sequence(data.iter());
  |                   ^^^^^^^^ constructor is not visible here due to private fields
help: possible better candidates are found in other modules, you can import them into scope
  |
1 | use ring::io::der::Tag::Sequence;
  |
1 | use serde_yaml::Value::Sequence;
  |
1 | use weedle::term::Sequence;
  |
1 | use weedle::types::NonAnyType::Sequence;
#[derive(Serialize)]
#[serde(bound(serialize = "T : Clone + Iterator, T::Item : Serialize"))]
pub struct Sequence<T>(#[serde(serialize_with = "serialize_iter")] pub T);

pub T is pub. Since I was getting nowhere with that error, I moved on to the missing serde imports, which fixed the E0423 error.

I'm reporting this, because the error is unexpected to a perpetual newbie such as myself. If Rust cannot make sense of the attributes, I would expect Rust to ignore them as if they weren't there, and recognize the pub T, so the E0423 wasn't erroneously reported.

@petrochenkov
Copy link
Contributor

This is a nightly-only regression and it should be fixed by #66669.

@boxofrox
Copy link
Author

boxofrox commented Nov 29, 2019

I'm not sure I follow what a "nightly-only regression" is. The playground example reports E0423 on stable.

That aside, I thought I tested the nightly compiler on the playground example, but apparently I misclicked, because the nightly compiler doesn't report E0423. Looks like #66669 will fix this issue. My apologies for the noise.

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

No branches or pull requests

2 participants