diff options
Diffstat (limited to 'gcc/rust/checks')
14 files changed, 28 insertions, 33 deletions
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder-struct.h b/gcc/rust/checks/errors/borrowck/rust-bir-builder-struct.h index 18ddc19..94fcecd 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-builder-struct.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder-struct.h @@ -250,10 +250,6 @@ protected: void visit (HIR::ImplTraitType &type) override { rust_unreachable (); } void visit (HIR::TraitObjectType &type) override { rust_unreachable (); } void visit (HIR::ParenthesisedType &type) override { rust_unreachable (); } - void visit (HIR::ImplTraitTypeOneBound &type) override - { - rust_unreachable (); - } void visit (HIR::TupleType &type) override { rust_unreachable (); } void visit (HIR::NeverType &type) override { rust_unreachable (); } void visit (HIR::RawPointerType &type) override { rust_unreachable (); } diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h index 1332ecf..32a4cd7 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h @@ -815,6 +815,7 @@ protected: // Subset helpers. case TyTy::PLACEHOLDER: case TyTy::INFER: case TyTy::PARAM: + case TyTy::OPAQUE: rust_unreachable (); } rust_unreachable (); diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h index a1621b7..67ca90b 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h @@ -485,6 +485,7 @@ private: case TyTy::PROJECTION: // TODO: DUNNO case TyTy::CLOSURE: // TODO: DUNNO case TyTy::DYNAMIC: // TODO: dunno + case TyTy::OPAQUE: return false; } rust_unreachable (); diff --git a/gcc/rust/checks/errors/borrowck/rust-function-collector.h b/gcc/rust/checks/errors/borrowck/rust-function-collector.h index 5de503d..cdb20e8 100644 --- a/gcc/rust/checks/errors/borrowck/rust-function-collector.h +++ b/gcc/rust/checks/errors/borrowck/rust-function-collector.h @@ -180,7 +180,6 @@ public: void visit (HIR::ImplTraitType &type) override {} void visit (HIR::TraitObjectType &type) override {} void visit (HIR::ParenthesisedType &type) override {} - void visit (HIR::ImplTraitTypeOneBound &type) override {} void visit (HIR::TupleType &type) override {} void visit (HIR::NeverType &type) override {} void visit (HIR::RawPointerType &type) override {} diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc index dcc768f..a537c42 100644 --- a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc +++ b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc @@ -243,10 +243,12 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings, static_cast<const TyTy::TupleType *> (ty)->get_fields ()) recursive_check (param.get_tyty ()); return; - case TyTy::PLACEHOLDER: - return recursive_check ( - // FIXME: Can we use `resolve` here? Is that what we should do? - static_cast<const TyTy::PlaceholderType *> (ty)->resolve ()); + case TyTy::PLACEHOLDER: { + const auto p = static_cast<const TyTy::PlaceholderType *> (ty); + if (!p->can_resolve ()) + return; + return recursive_check (p->resolve ()); + } case TyTy::PROJECTION: return recursive_check ( static_cast<const TyTy::ProjectionType *> (ty)->get ()); @@ -269,6 +271,8 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings, // We shouldn't have inference types here, ever case TyTy::INFER: return; + case TyTy::OPAQUE: + return; case TyTy::ERROR: return; } diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc index 97b3528..4904322 100644 --- a/gcc/rust/checks/errors/rust-const-checker.cc +++ b/gcc/rust/checks/errors/rust-const-checker.cc @@ -847,10 +847,6 @@ ConstChecker::visit (ParenthesisedType &) {} void -ConstChecker::visit (ImplTraitTypeOneBound &) -{} - -void ConstChecker::visit (TupleType &) {} diff --git a/gcc/rust/checks/errors/rust-const-checker.h b/gcc/rust/checks/errors/rust-const-checker.h index 9a618b8..00f57988 100644 --- a/gcc/rust/checks/errors/rust-const-checker.h +++ b/gcc/rust/checks/errors/rust-const-checker.h @@ -191,7 +191,6 @@ private: virtual void visit (ImplTraitType &type) override; virtual void visit (TraitObjectType &type) override; virtual void visit (ParenthesisedType &type) override; - virtual void visit (ImplTraitTypeOneBound &type) override; virtual void visit (TupleType &type) override; virtual void visit (NeverType &type) override; virtual void visit (RawPointerType &type) override; diff --git a/gcc/rust/checks/errors/rust-feature.h b/gcc/rust/checks/errors/rust-feature.h index e2082c5..9edae6d 100644 --- a/gcc/rust/checks/errors/rust-feature.h +++ b/gcc/rust/checks/errors/rust-feature.h @@ -19,7 +19,7 @@ #ifndef RUST_FEATURE_H #define RUST_FEATURE_H -#include "rust-session-manager.h" +#include "rust-edition.h" #include "optional.h" namespace Rust { @@ -66,7 +66,7 @@ private: Feature (Name name, State state, const char *name_str, const char *rustc_since, tl::optional<unsigned> issue_number = tl::nullopt, - const tl::optional<CompileOptions::Edition> &edition = tl::nullopt, + const tl::optional<Edition> &edition = tl::nullopt, const char *description = "") : m_state (state), m_name (name), m_name_str (name_str), m_rustc_since (rustc_since), m_issue (issue_number), edition (edition), @@ -78,7 +78,7 @@ private: std::string m_name_str; std::string m_rustc_since; tl::optional<unsigned> m_issue; - tl::optional<CompileOptions::Edition> edition; + tl::optional<Edition> edition; std::string m_description; // TODO: Switch to optional? static const std::map<std::string, Name> name_hash_map; diff --git a/gcc/rust/checks/errors/rust-hir-pattern-analysis.cc b/gcc/rust/checks/errors/rust-hir-pattern-analysis.cc index 79416b5..257f4cd 100644 --- a/gcc/rust/checks/errors/rust-hir-pattern-analysis.cc +++ b/gcc/rust/checks/errors/rust-hir-pattern-analysis.cc @@ -685,10 +685,6 @@ PatternChecker::visit (ParenthesisedType &) {} void -PatternChecker::visit (ImplTraitTypeOneBound &) -{} - -void PatternChecker::visit (TupleType &) {} diff --git a/gcc/rust/checks/errors/rust-hir-pattern-analysis.h b/gcc/rust/checks/errors/rust-hir-pattern-analysis.h index 9c43d41..2171340 100644 --- a/gcc/rust/checks/errors/rust-hir-pattern-analysis.h +++ b/gcc/rust/checks/errors/rust-hir-pattern-analysis.h @@ -164,7 +164,6 @@ private: virtual void visit (ImplTraitType &type) override; virtual void visit (TraitObjectType &type) override; virtual void visit (ParenthesisedType &type) override; - virtual void visit (ImplTraitTypeOneBound &type) override; virtual void visit (TupleType &type) override; virtual void visit (NeverType &type) override; virtual void visit (RawPointerType &type) override; diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.cc b/gcc/rust/checks/errors/rust-unsafe-checker.cc index fadfd9d..8aa59ee 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.cc +++ b/gcc/rust/checks/errors/rust-unsafe-checker.cc @@ -957,10 +957,6 @@ UnsafeChecker::visit (ParenthesisedType &) {} void -UnsafeChecker::visit (ImplTraitTypeOneBound &) -{} - -void UnsafeChecker::visit (TupleType &) {} diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.h b/gcc/rust/checks/errors/rust-unsafe-checker.h index 8dc6ab7..63098fe 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.h +++ b/gcc/rust/checks/errors/rust-unsafe-checker.h @@ -172,7 +172,6 @@ private: virtual void visit (ImplTraitType &type) override; virtual void visit (TraitObjectType &type) override; virtual void visit (ParenthesisedType &type) override; - virtual void visit (ImplTraitTypeOneBound &type) override; virtual void visit (TupleType &type) override; virtual void visit (NeverType &type) override; virtual void visit (RawPointerType &type) override; diff --git a/gcc/rust/checks/lints/rust-lint-marklive.cc b/gcc/rust/checks/lints/rust-lint-marklive.cc index 4b524d7..af7535a 100644 --- a/gcc/rust/checks/lints/rust-lint-marklive.cc +++ b/gcc/rust/checks/lints/rust-lint-marklive.cc @@ -22,6 +22,8 @@ #include "rust-lint-marklive.h" #include "options.h" #include "rust-hir-full.h" +#include "rust-hir-map.h" +#include "rust-hir-path.h" #include "rust-name-resolver.h" #include "rust-immutable-name-resolution-context.h" #include "rust-system.h" @@ -99,15 +101,21 @@ MarkLive::visit (HIR::PathInExpression &expr) { // We should iterate every path segment in order to mark the struct which // is used in expression like Foo::bar(), we should mark the Foo alive. - expr.iterate_path_segments ([&] (HIR::PathExprSegment &seg) -> bool { - return visit_path_segment (seg); - }); + if (!expr.is_lang_item ()) + expr.iterate_path_segments ([&] (HIR::PathExprSegment &seg) -> bool { + return visit_path_segment (seg); + }); // after iterate the path segments, we should mark functions and associated // functions alive. NodeId ast_node_id = expr.get_mappings ().get_nodeid (); NodeId ref_node_id = UNKNOWN_NODEID; - find_ref_node_id (ast_node_id, ref_node_id); + + if (expr.is_lang_item ()) + ref_node_id + = Analysis::Mappings::get ().get_lang_item_node (expr.get_lang_item ()); + else + find_ref_node_id (ast_node_id, ref_node_id); // node back to HIR tl::optional<HirId> hid = mappings.lookup_node_to_hir (ref_node_id); @@ -279,7 +287,7 @@ MarkLive::find_ref_node_id (NodeId ast_node_id, NodeId &ref_node_id) { if (flag_name_resolution_2_0) { - auto nr_ctx + auto &nr_ctx = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); nr_ctx.lookup (ast_node_id).map ([&ref_node_id] (NodeId resolved) { diff --git a/gcc/rust/checks/lints/rust-lint-scan-deadcode.h b/gcc/rust/checks/lints/rust-lint-scan-deadcode.h index e6ef1392..0fc203b 100644 --- a/gcc/rust/checks/lints/rust-lint-scan-deadcode.h +++ b/gcc/rust/checks/lints/rust-lint-scan-deadcode.h @@ -93,7 +93,8 @@ public: { HirId field_hir_id = field.get_mappings ().get_hirid (); if (should_warn (field_hir_id) - && !field.get_visibility ().is_public ()) + && !field.get_visibility ().is_public () + && field.get_field_name ().as_string ().at (0) != '_') { rust_warning_at (field.get_locus (), 0, "field is never read: %qs", |