Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `legacy_constructor_visibility` compatibility lint #39207
Comments
petrochenkov
added
the
A-lint
label
Feb 19, 2017
brson
added
the
B-unstable
label
Mar 1, 2017
jminer
added a commit
to jminer/clear-coat
that referenced
this issue
May 23, 2017
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
fabric-and-ink
referenced this issue
Jun 14, 2018
Merged
Declare DebruijnIndex via newtype_index macro #51248
Centril
added
T-lang
C-future-compatibility
labels
Dec 23, 2018
Centril
removed
the
C-tracking-issue
label
Jan 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
petrochenkov commentedJan 20, 2017
•
edited
What is this lint about
#38932 introduces new rules for privacy of tuple struct constructors. Constructor is a function automatically created by a tuple struct having the same name as the struct itself.
See RFC 1506 for more details.
With these new rules constructor function of a public
struct S(....)is defined as private if at least one of the fields is private.More precisely,
visibility(constructor_fn) = min(visibility(struct), visibility(field_1), ..., visibility(field_N))(this definition takes RFC 1422 into account).This change is done to make a struct with private fields being a tuple struct an implementation detail. So libraries can freely change it into non-tuple struct and back, and nothing breaks.
This change is mostly backward compatible due to some ad-hoc privacy checks existing previously (e.g.
error[E0450]: cannot invoke tuple struct constructor with private fields), however there's one pattern that is broken by it:legacy_constructor_visibilitylint tries to detect this patterns and make name resolution succeed with a warning to keep backward compatibility. However, this detection is pretty hacky and not entirely precise, so it will need to go away eventually.How to fix this warning/error
Use the constructor from its original location X and not through reexports in modules outer to X.
Current status
legacy_constructor_visibilitylint as deny-by-defaultlegacy_constructor_visibilitylint a hard error