implement `From<Vec<char>>` and `From<&'a [char]>` for `String`
Though there are ways to convert a slice or vec of chars into a string,
it would be nice to be able to just do `String::from(&['a', 'b', 'c'])`,
so this PR implements `From<Vec<char>>` and `From<&'a [char]>` for
String.
rustc_trans: apply the debug location for the MIR Assert panic call.
Helps `libcore` build with MIR trans and debuginfo; libcore has the body of `panic`, which resulted in:
```
inlinable function call in a function with debug info must have a !dbg location
call void @_ZN4core9panicking5panic17h585bd70cda921012E({ %str_slice, %str_slice, i32 }* @panic_loc12745)
LLVM ERROR: Broken function found, compilation aborted!
```
tcp-stress-test: Pull out thread count as a constant
This PR factors out the number of concurrent threads used in `tcp-stress-test.rs` to a constant at the top of the file.
We at @NixOS had to lower our thread count as the chrooted-builds don't allow that many threads.
This change will make it easier to lower/increase the count in the future (I actually forgot to change the second `1000` when I was working on this). Another benefit is the removal of magic numbers in the test suite.
This is related to https://github.com/rust-lang/rust/issues/35107
Move caching of inlined HIR into CrateStore
So far we've had separate HIR-inlining caches for each codegen unit and the caching for things inlined during constant evaluation had some holes. Consequently, things would be inlined multiple times if they were used from different codegen units, etc, leading to
- wasted memory,
- multiple `NodeId`s per `DefId` and,
- for things inlined during constant evaluation, no way to map a `NodeId` back to it's original `DefId`.
This PR moves all caching into the CrateStore, solving all of the above problems. It also fixes some bugs in the inlining code, like cyclic in the parent-chains in the HIR map and some `NodeId`'s being translated to more or less random values. There are assertions in place now that should prevent this kind of thing in the future.
This PR based on top of #35090, which contains some necessary fixes.
Use "x86-64" as the target CPU for NetBSD and Bitrig on amd64.
Using "generic" disables a number of features that are present on all
x86_64 cpus, the "x86-64" target cpu is the common denominator for that
arch.
Refs #20777
Methods `Fn(Mut,Once)::call(mut,once)` are gated with two feature gates, remove one of them
Methods `Fn::call`, `FnMut::call_mut` and `FnOnce::call_once` are gated with usual library feature `fn_traits` and also hardcoded in the compiler and gated once more with feature `unboxed_closures`
This patch removes the `unboxed_closures`feature gate from these methods (`unboxed_closures` is still used for other things though), now they are gated only with `fn_traits`.
All unnecessary `#![feature(unboxed_closures)]`s are removed, many of them are old and were already unnecessary before the change this PR does.
LLVM upgrade
As discussed in https://internals.rust-lang.org/t/need-help-with-emscripten-port/3154/46 I'm trying to update the used LLVM checkout in Rust.
I basically took @shepmaster's code and applied it on top (though I did the commits manually, the [original commits have better descriptions](https://github.com/rust-lang/rust/compare/master...avr-rust:avr-support).
With these changes I was able to build rustc. `make check` throws one last error on `run-pass/issue-28950.rs`. Output: https://gist.github.com/badboy/bcdd3bbde260860b6159aa49070a9052
I took the metadata changes as is and they seem to work, though it now uses the module in another step. I'm not sure if this is the best and correct way.
Things to do:
* [x] ~~Make `run-pass/issue-28950.rs` pass~~ unrelated
* [x] Find out how the `PositionIndependentExecutable` setting is now used
* [x] Is the `llvm::legacy` still the right way to do these things?
cc @brson @alexcrichton
trans: Avoid weak linkage for closures when linking with MinGW.
This PR proposes one possible solution to #34793, the problem that prevents https://github.com/servo/servo/pull/12393 from landing. It applies the same strategy, that we already use for monomorphizations, to closures, that is, instead of emitting symbols with `weak_odr` linkage in order to avoid symbol conflicts, we emit them with `internal` linkage, with the side effect that we have to copy code instead of just linking to it, if more than one codegen unit is involved.
With this PR, the compiler will only apply this strategy for targets where we would actually run into a problem when using `weak_odr` linkage, in other words nothing will change for platforms except for MinGW.
The solution implemented here has one restriction that could be lifted with some more effort, but it does not seem to be worth the trouble since it will go away once we use only MIR-trans: If someone compiles code
1. on MinGW,
2. with more than one codegen unit,
3. *not* using MIR-trans,
4. and runs into a closure inlined from another crate
then the compiler will abort and suggest to compile either with just one codegen unit or `-Zorbit`.
What's nice about this is that I lays a foundation for also doing the same for generics: using weak linkage where possible and thus enabling some more space optimizations that the linker can do.
~~This PR also contains a test case for compiling a program that contains more than 2^15 closures. It's a huge, generated file with almost 100K LOCs. I did not commit the script for generating the file but could do so. Alternatively, maybe someone wants to come up with a way of doing this with macros.~~
The test file is implemented via macros now (thanks @alexcrichton!)
Opinions?
Fixes#34793.
cc @rust-lang/compiler
This adds a question and answer to the Q&A section of the Copy
docs. Specifically, it asks the question I asked while reading
the docs, and gives its answer.
typeck: use a TypeVisitor in ctp
Use a TypeVisitor in ctp instead of `ty::walk`
This fixes a few cases where a region could be projected out of a trait while not being constrained by the type parameters, violating rust-lang/rfcs#447 and breaking soundness. As such, this is a [breaking-change].
Fixes#35139
r? @eddyb