trans: Make names of internal symbols independent of CGU translation order
Every codegen unit gets its own local counter for generating new symbol names. This makes bitcode and object files reproducible at the binary level even when incremental compilation is used.
The PR also solves a rare ICE resulting from a naming conflict between a user defined name and a generated one. E.g. try compiling the following program with 1.12.1 stable:
```rust
pub fn str7233() -> &'static str { "foo" }
```
This results in:
> error: internal compiler error: ../src/librustc_trans/common.rs:979: symbol `str7233` is already defined
Running into this is not very likely but it's also easily avoidable.
Fix a error of 'book/deref-coercions.html'
The original sentence is:
> This example has two conversions: `Rc<String>` to `String` and then `String` to `&str`.
But it should be
> This example has two conversions: `Rc<String>` to `String` and then `String` to `str`.
or
> This example has two conversions: `&Rc<String>` to `&String` and then `&String` to `&str`.
I think the latter is more clearly.
r? @steveklabnik
Use `SmallVector` in `CombineFields::instantiate`.
This avoids 4% of malloc calls when compiling
rustc-benchmarks/issue-32278-big-array-of-strings, and 1--2% for other
benchmarks. A small win, but an easy one.
This avoids 4% of malloc calls when compiling
rustc-benchmarks/issue-32278-big-array-of-strings, and 1--2% for other
benchmarks. A small win, but an easy one.
Fix typo that resulted in comparison-to-self
This line was introduced in commit 843db01bd9, rebased from eddyb's c5f6f84d59b853b6a3485380721b71b479ece337.
I don't know whether this fixes anything in practice, but it seems like the changed version was what was intended originally.
r? @eddyb
libcore documentation for builtin macros
Fixes: #36272
Additionally I've edited docstring for `include!` a bit. (related PR #36404)
Unfortunately it seems there is no sane way to reexport empty macros definitions for their docstrings. To avoid copying the whole documentation for builtin macros I've only copied description and added links to `std` macro pages.
Implement `From<Cow<str>> for String` and `From<Cow<[T]>> for Vec<T>`.
Motivation: the `selectors` crate is generic over a string type, in order to support all of `String`, `string_cache::Atom`, and `gecko_string_cache::Atom`. Multiple trait bounds are used for the various operations done with these strings. One of these operations is creating a string (as efficiently as possible, re-using an existing memory allocation if possible) from `Cow<str>`.
The `std::convert::From` trait seems natural for this, but the relevant implementation was missing before this PR. To work around this I’ve added a `FromCowStr` trait in `selectors`, but with trait coherence that means one of `selectors` or `string_cache` needs to depend on the other to implement this trait. Using a trait from `std` would solve this.
The `Vec<T>` implementation is just added for consistency. I also tried a more general `impl<'a, O, B: ?Sized + ToOwned<Owned=O>> From<Cow<'a, B>> for O`, but (the compiler thinks?) it conflicts with `From<T> for T` the impl (after moving all of `collections::borrow` into `core::borrow` to work around trait coherence).
Avoid some allocations in the macro parser
These three commits reduce the number of heap allocations done when compiling rustc-benchmarks/html5ever-2016-08-25 by 20%, from 16.5M to 13.3M. This speeds up (debug) compilation of it with a stage1 compiler by about 7%.
Given a file like:
```rust
enum Test {
Variant,
Variant2 {a: u32},
}
fn main(){
let x = Test::Variant("Hello");
let y = Test::Variant2("World");
}
```
The errors now look this way:
```bash
error[E0423]: `Test::Variant2` is the name of a struct or struct variant, but this expression uses it like a function name
--> file3.rs:10:13
|
10 | let y = Test::Variant2("Hello");
| ^^^^^^^^^^^^^^ struct called like a function
|
= help: did you mean to write: `Test::Variant2 { /* fields */ }`?
error: `Test::Variant` is being called, but it is not a function
--> file3.rs:9:13
|
9 | let x = Test::Variant("World");
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: did you mean to write: `Test::Variant`?
note: defined here
--> file3.rs:2:5
|
2 | Variant,
| ^^^^^^^
error: aborting due to previous error
```
Fix line stepping in debugger.
Attribute drop code to block's closing brace, instead of the line where the allocation was done.
Attribute function epilogues to function body's closing brace, rather than the function header.
Fixes#37032
r? @michaelwoerister
The DirEntryExt::ino() implementation was omitted from the first
iteration of this patch, because a dependency needed to be
configured. The fix is straightforward enough.