Skip to content

Commit c0056c0

Browse files
committed
legacy_ctor_visibility -> error
1 parent e8b190a commit c0056c0

File tree

6 files changed

+13
-79
lines changed

6 files changed

+13
-79
lines changed

src/doc/rustc/src/lints/listing/deny-by-default.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
4545
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
4646
```
4747

48-
## legacy-constructor-visibility
49-
50-
[RFC 1506](https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md) modified some
51-
visibility rules, and changed the visibility of struct constructors. Some
52-
example code that triggers this lint:
53-
54-
```rust,ignore
55-
mod m {
56-
pub struct S(u8);
57-
58-
fn f() {
59-
// this is trying to use S from the 'use' line, but because the `u8` is
60-
// not pub, it is private
61-
::S;
62-
}
63-
}
64-
65-
use m::S;
66-
```
67-
68-
This will produce:
69-
70-
```text
71-
error: private struct constructors are not usable through re-exports in outer modules
72-
--> src/main.rs:5:9
73-
|
74-
5 | ::S;
75-
| ^^^
76-
|
77-
= note: `#[deny(legacy_constructor_visibility)]` on by default
78-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
79-
= note: for more information, see issue #39207 <https://github.com/rust-lang/rust/issues/39207>
80-
```
81-
82-
8348
## legacy-directory-ownership
8449

8550
The legacy_directory_ownership warning is issued when

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,6 @@ declare_lint! {
218218
};
219219
}
220220

221-
declare_lint! {
222-
pub LEGACY_CONSTRUCTOR_VISIBILITY,
223-
Deny,
224-
"detects use of struct constructors that would be invisible with new visibility rules",
225-
@future_incompatible = FutureIncompatibleInfo {
226-
reference: "issue #39207 <https://github.com/rust-lang/rust/issues/39207>",
227-
edition: None,
228-
};
229-
}
230-
231221
declare_lint! {
232222
pub MISSING_FRAGMENT_SPECIFIER,
233223
Deny,
@@ -560,7 +550,6 @@ declare_lint_pass! {
560550
SAFE_PACKED_BORROWS,
561551
PATTERNS_IN_FNS_WITHOUT_BODY,
562552
LEGACY_DIRECTORY_OWNERSHIP,
563-
LEGACY_CONSTRUCTOR_VISIBILITY,
564553
MISSING_FRAGMENT_SPECIFIER,
565554
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
566555
LATE_BOUND_LIFETIME_ARGUMENTS,

src/librustc_lint/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) {
334334
"converted into hard error, see https://github.com/rust-lang/rust/issues/57742");
335335
store.register_removed("incoherent_fundamental_impls",
336336
"converted into hard error, see https://github.com/rust-lang/rust/issues/46205");
337+
store.register_removed("legacy_constructor_visibility",
338+
"converted into hard error, see https://github.com/rust-lang/rust/issues/39207");
337339
}
338340

339341
fn register_internals(store: &mut lint::LintStore) {

src/librustc_resolve/late.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,25 +1539,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
15391539
if is_expected(partial_res.base_res()) || partial_res.base_res() == Res::Err {
15401540
partial_res
15411541
} else {
1542-
// Add a temporary hack to smooth the transition to new struct ctor
1543-
// visibility rules. See #38932 for more details.
1544-
let mut res = None;
1545-
if let Res::Def(DefKind::Struct, def_id) = partial_res.base_res() {
1546-
if let Some((ctor_res, ctor_vis))
1547-
= self.r.struct_constructors.get(&def_id).cloned() {
1548-
if is_expected(ctor_res) &&
1549-
self.r.is_accessible_from(ctor_vis, self.parent_scope.module) {
1550-
let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY;
1551-
self.r.lint_buffer.buffer_lint(lint, id, span,
1552-
"private struct constructors are not usable through \
1553-
re-exports in outer modules",
1554-
);
1555-
res = Some(PartialRes::new(ctor_res));
1556-
}
1557-
}
1558-
}
1559-
1560-
res.unwrap_or_else(|| report_errors(self, Some(partial_res.base_res())))
1542+
report_errors(self, Some(partial_res.base_res()))
15611543
}
15621544
}
15631545
Some(partial_res) if source.defer_to_typeck() => {

src/test/ui/privacy/legacy-ctor-visibility.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// ignore-tidy-linelength
2-
3-
#![allow(unused)]
4-
51
use m::S;
62

73
mod m {
@@ -11,8 +7,7 @@ mod m {
117
use S;
128
fn f() {
139
S(10);
14-
//~^ ERROR private struct constructors are not usable through re-exports in outer modules
15-
//~| WARN this was previously accepted
10+
//~^ ERROR expected function, tuple struct or tuple variant, found struct `S`
1611
}
1712
}
1813
}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
error: private struct constructors are not usable through re-exports in outer modules
2-
--> $DIR/legacy-ctor-visibility.rs:13:13
1+
error[E0423]: expected function, tuple struct or tuple variant, found struct `S`
2+
--> $DIR/legacy-ctor-visibility.rs:9:13
33
|
4-
LL | S(10);
5-
| ^
6-
|
7-
= note: `#[deny(legacy_constructor_visibility)]` on by default
8-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9-
= note: for more information, see issue #39207 <https://github.com/rust-lang/rust/issues/39207>
4+
LL | / fn f() {
5+
LL | | S(10);
6+
| | ^ help: a function with a similar name exists: `f`
7+
LL | |
8+
LL | | }
9+
| |_________- similarly named function `f` defined here
1010

1111
error: aborting due to previous error
1212

13+
For more information about this error, try `rustc --explain E0423`.

0 commit comments

Comments
 (0)