This removes the `namegen` thunk that was in `common.rs`. I also take the opportunity to refactor a few uses where we had a `str -> ident -> str` chain that seemed somewhat redundant to me.
Also cleans up some warnings that made their way in already.
Mostly just low-haning fruit, i.e. function arguments that were @ even
though & would work just as well.
Reduces librustc.so size by 200k when compiling without -O, by 100k when
compiling with -O.
Mostly just low-haning fruit, i.e. function arguments that were @ even
though & would work just as well.
Reduces librustc.so size by 200k when compiling without -O, by 100k when
compiling with -O.
r? @brson (or @graydon if available) rustpkg/api.rs provides functions intended for package scripts to call.
It will probably need more functionality added to it later, but this is
a start.
Added a test case checking that a package script can use the API.
Closes#6401
This allows macros to both be conditionally defined, and expand
to items with #[cfg]'s.
This seems to have a performance improvement, e.g. for `std`:
```
# Before
time: 1.660 s expansion
time: 0.125 s configuration
# After
time: 0.080 s configuration 1
time: 1.127 s expansion
time: 0.132 s configuration 2
```
And for `extra`:
```
# Before
time: 0.593 s expansion
time: 0.062 s configuration
# After
time: 0.047 s configuration 1
time: 0.147 s expansion
time: 0.058 s configuration 2
```
(This seems a little peculiar, but it is possibly because the expansion AST traversal is very slow, so removing as much as possible as early as possible has big benefits.)
This PR contains no real code changes. Just some documentation additions in the form of comments and some internal reordering of functions within debuginfo.rs.
rustpkg/api.rs provides functions intended for package scripts to call.
It will probably need more functionality added to it later, but this is
a start.
Added a test case checking that a package script can use the API.
Closes#6401
Fix#7322.
I started out with a band-aid approach to special-case the duplicate module error using `is_duplicate_module`, but thought this would be better in the long term.
The "first definition of ..." error string reported by add_child() looks
different from similar messages reported by other functions. Fix this.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
add_child() is responsible for reporting errors about type, value, and
module duplicate definitions. Although it checks for all three, it uses
namespace_to_str() to convert a Namespace value into a string before
printing an error like:
error: duplicate definition of type `foo`
^^^^
note: first definition of type foo here:
^^^^
Unfortunately, this string can only be one of "type" or
"value" (corresponding to TypeNS and ValueNS respectively), and it
reports duplicate modules as duplicate types.
To alleviate the problem, define a special NamespaceError enum to define
more specialized errors, and use it instead of attempting to reuse the
Namespace enum.
Reported-by: Corey Richardson <corey@octayn.net>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>