From: Owen Avery <[email protected]>
Also removes some dead code in flatten, since I saw it while working on
this PR and it's too small to be its own patch.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc
(Early::resolve_glob_import): Handle glob imports that appear
after other imports in a use declaration.
* resolve/rust-early-name-resolver-2.0.h
(Early::ImportMappings::insert): Remove member functions, as
they're both broken and unused.
* resolve/rust-toplevel-name-resolver-2.0.cc (flatten): Remove
redundant break statement.
gcc/testsuite/ChangeLog:
* rust/compile/glob_import_brace.rs: New test.
Signed-off-by: Owen Avery <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github: https://github.com/Rust-GCC/gccrs/commit/c539964b8cc842e871d77b45150df6a5882335fb
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4707
gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 7 ++++---
gcc/rust/resolve/rust-early-name-resolver-2.0.h | 11 -----------
.../resolve/rust-toplevel-name-resolver-2.0.cc | 1 -
gcc/testsuite/rust/compile/glob_import_brace.rs | 14 ++++++++++++++
4 files changed, 18 insertions(+), 15 deletions(-)
create mode 100644 gcc/testsuite/rust/compile/glob_import_brace.rs
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 1c87804a7..12f29ceed 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -99,14 +99,15 @@ Early::resolve_glob_import (NodeId use_dec_id, TopLevel::ImportKind &&glob)
if (!result)
return false;
+ auto &imports = import_mappings.new_or_access (use_dec_id);
+
// here, we insert the module's NodeId into the import_mappings and will look
// up the module proper in `FinalizeImports`
// The namespace does not matter here since we are dealing with a glob
// FIXME: Does the namespace not matter? Is that valid?
// TODO: Ugly
- import_mappings.insert (use_dec_id,
- ImportPair (std::move (glob),
- ImportData::Glob (resolved->definition)));
+ imports.emplace_back (
+ ImportPair (std::move (glob), ImportData::Glob (resolved->definition)));
return true;
}
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.h b/gcc/rust/resolve/rust-early-name-resolver-2.0.h
index 235595e8d..7ea9e9f2c 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.h
@@ -157,17 +157,6 @@ public:
return iter.first->second;
}
- void insert (NodeId path_id, std::vector<ImportPair> &&pairs)
- {
- mappings.insert ({{path_id}, std::move (pairs)});
- }
-
- // Same as `insert`, but with just one node
- void insert (NodeId path_id, ImportPair &&pair)
- {
- mappings.insert ({{path_id}, {pair}});
- }
-
std::vector<ImportPair> &get (NodeId use_id) { return mappings[use_id]; }
private:
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index cb354fdee..117bb32fb 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -440,7 +440,6 @@ flatten (
flatten_glob (*glob, glob_paths, ctx);
break;
}
- break;
}
}
diff --git a/gcc/testsuite/rust/compile/glob_import_brace.rs b/gcc/testsuite/rust/compile/glob_import_brace.rs
new file mode 100644
index 000000000..22e44664a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/glob_import_brace.rs
@@ -0,0 +1,14 @@
+#![feature(no_core)]
+#![no_core]
+
+mod a {}
+
+mod b {
+ pub struct X;
+
+ mod c {
+ use crate::{a::*, b::*};
+
+ type Y = X;
+ }
+}
base-commit: e9c46c174c3d5d21d572b40c658f7abb67d4cd55
--
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.