]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_resolve/late.rs
Rollup merge of #66197 - Centril:transparent-ast, r=varkor
[rust.git] / src / librustc_resolve / late.rs
index 004d86cee8ded00b520759ab5e5e1daa44f30585..8d11c7224c7044b9e1432004b96097373728c88c 100644 (file)
@@ -30,6 +30,8 @@
 use std::collections::BTreeSet;
 use std::mem::replace;
 
+use rustc_error_codes::*;
+
 mod diagnostics;
 
 type Res = def::Res<NodeId>;
@@ -730,8 +732,7 @@ fn resolve_item(&mut self, item: &Item) {
 
         match item.kind {
             ItemKind::TyAlias(_, ref generics) |
-            ItemKind::OpaqueTy(_, ref generics) |
-            ItemKind::Fn(_, _, ref generics, _) => {
+            ItemKind::Fn(_, ref generics, _) => {
                 self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes),
                                             |this| visit::walk_item(this, item));
             }
@@ -1085,18 +1086,6 @@ fn resolve_implementation(&mut self,
 
                                                 this.visit_ty(ty);
                                             }
-                                            ImplItemKind::OpaqueTy(ref bounds) => {
-                                                // If this is a trait impl, ensure the type
-                                                // exists in trait
-                                                this.check_trait_item(impl_item.ident,
-                                                                      TypeNS,
-                                                                      impl_item.span,
-                                                    |n, s| TypeNotMemberOfTrait(n, s));
-
-                                                for bound in bounds {
-                                                    this.visit_param_bound(bound);
-                                                }
-                                            }
                                             ImplItemKind::Macro(_) =>
                                                 panic!("unexpanded macro in resolve!"),
                                         }
@@ -1539,25 +1528,7 @@ fn smart_resolve_path_fragment(&mut self,
                 if is_expected(partial_res.base_res()) || partial_res.base_res() == Res::Err {
                     partial_res
                 } else {
-                    // Add a temporary hack to smooth the transition to new struct ctor
-                    // visibility rules. See #38932 for more details.
-                    let mut res = None;
-                    if let Res::Def(DefKind::Struct, def_id) = partial_res.base_res() {
-                        if let Some((ctor_res, ctor_vis))
-                                = self.r.struct_constructors.get(&def_id).cloned() {
-                            if is_expected(ctor_res) &&
-                               self.r.is_accessible_from(ctor_vis, self.parent_scope.module) {
-                                let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY;
-                                self.r.lint_buffer.buffer_lint(lint, id, span,
-                                    "private struct constructors are not usable through \
-                                     re-exports in outer modules",
-                                );
-                                res = Some(PartialRes::new(ctor_res));
-                            }
-                        }
-                    }
-
-                    res.unwrap_or_else(|| report_errors(self, Some(partial_res.base_res())))
+                    report_errors(self, Some(partial_res.base_res()))
                 }
             }
             Some(partial_res) if source.defer_to_typeck() => {
@@ -1783,7 +1754,9 @@ fn resolve_qpath(
 
     fn with_resolved_label(&mut self, label: Option<Label>, id: NodeId, f: impl FnOnce(&mut Self)) {
         if let Some(label) = label {
-            self.diagnostic_metadata.unused_labels.insert(id, label.ident.span);
+            if label.ident.as_str().as_bytes()[1] != b'_' {
+                self.diagnostic_metadata.unused_labels.insert(id, label.ident.span);
+            }
             self.with_label_rib(NormalRibKind, |this| {
                 let ident = label.ident.modern_and_legacy();
                 this.label_ribs.last_mut().unwrap().bindings.insert(ident, id);
@@ -1876,7 +1849,7 @@ fn resolve_expr(&mut self, expr: &Expr, parent: Option<&Expr>) {
                                     None
                                 }
                             });
-                            find_best_match_for_name(names, &*ident.as_str(), None)
+                            find_best_match_for_name(names, &ident.as_str(), None)
                         });
                         self.r.record_partial_res(expr.id, PartialRes::new(Res::Err));
                         self.r.report_error(