Skip to content

Commit c9788fd

Browse files
committed
Remove no longer necessary ctor checks in rustc_privacy
1 parent 8b060e2 commit c9788fd

File tree

3 files changed

+5
-69
lines changed

3 files changed

+5
-69
lines changed

src/librustc_privacy/diagnostics.rs

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -115,45 +115,6 @@ pub enum Foo {
115115
```
116116
"##,
117117

118-
E0450: r##"
119-
A tuple constructor was invoked while some of its fields are private. Erroneous
120-
code example:
121-
122-
```compile_fail
123-
mod Bar {
124-
pub struct Foo(isize);
125-
}
126-
127-
let f = Bar::Foo(0); // error: cannot invoke tuple struct constructor with
128-
// private fields
129-
```
130-
131-
To solve this issue, please ensure that all of the fields of the tuple struct
132-
are public. Alternatively, provide a `new()` method to the tuple struct to
133-
construct it from a given inner value. Example:
134-
135-
```
136-
mod Bar {
137-
pub struct Foo(pub isize); // we set its field to public
138-
}
139-
140-
let f = Bar::Foo(0); // ok!
141-
142-
// or:
143-
mod bar {
144-
pub struct Foo(isize);
145-
146-
impl Foo {
147-
pub fn new(x: isize) -> Foo {
148-
Foo(x)
149-
}
150-
}
151-
}
152-
153-
let f = bar::Foo::new(1);
154-
```
155-
"##,
156-
157118
E0451: r##"
158119
A struct constructor with private fields was invoked. Erroneous code example:
159120
@@ -204,3 +165,7 @@ let f = Bar::Foo::new(); // ok!
204165
"##,
205166

206167
}
168+
169+
register_diagnostics! {
170+
// E0450, moved into resolve
171+
}

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern crate syntax_pos;
2727

2828
use rustc::dep_graph::DepNode;
2929
use rustc::hir::{self, PatKind};
30-
use rustc::hir::def::{self, Def, CtorKind};
30+
use rustc::hir::def::{self, Def};
3131
use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
3232
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
3333
use rustc::hir::itemlikevisit::DeepVisitor;
@@ -478,33 +478,6 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivacyVisitor<'a, 'tcx> {
478478
}
479479
}
480480
}
481-
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
482-
if let Def::StructCtor(_, CtorKind::Fn) = path.def {
483-
let adt_def = self.tcx.expect_variant_def(path.def);
484-
let private_indexes = adt_def.fields.iter().enumerate().filter(|&(_, field)| {
485-
!field.vis.is_accessible_from(self.curitem, self.tcx)
486-
}).map(|(i, _)| i).collect::<Vec<_>>();
487-
488-
if !private_indexes.is_empty() {
489-
let mut error = struct_span_err!(self.tcx.sess, expr.span, E0450,
490-
"cannot invoke tuple struct constructor \
491-
with private fields");
492-
error.span_label(expr.span,
493-
&format!("cannot construct with a private field"));
494-
495-
if let Some(node_id) = self.tcx.hir.as_local_node_id(adt_def.did) {
496-
let node = self.tcx.hir.find(node_id);
497-
if let Some(hir::map::NodeStructCtor(vdata)) = node {
498-
for i in private_indexes {
499-
error.span_label(vdata.fields()[i].span,
500-
&format!("private field declared here"));
501-
}
502-
}
503-
}
504-
error.emit();
505-
}
506-
}
507-
}
508481
_ => {}
509482
}
510483

src/librustdoc/html/markdown.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,6 @@ mod tests {
660660
t("no_run", false, true, false, true, false, false, Vec::new());
661661
t("test_harness", false, false, false, true, true, false, Vec::new());
662662
t("compile_fail", false, true, false, true, false, true, Vec::new());
663-
t("E0450", false, false, false, true, false, false,
664-
vec!["E0450".to_owned()]);
665663
t("{.no_run .example}", false, true, false, true, false, false, Vec::new());
666664
t("{.sh .should_panic}", true, false, false, true, false, false, Vec::new());
667665
t("{.example .rust}", false, false, false, true, false, false, Vec::new());

0 commit comments

Comments
 (0)