Change `String` to `&'static str` in `ParseResult::Failure`.
This avoids 770,000 allocations when compiling the `html5ever`
benchmark, reducing instruction counts by up to 2%.
save-analysis: use a fallback when access levels couldn't be computed
Fixing an RLS regression I introduced in https://github.com/rust-lang/rust/pull/57343😢
I missed a case where we get [called back with analysis when type checking fails](9d54812829/src/librustc_driver/driver.rs (L1264)). Since privacy checking normally is done afterwards, when we execute the `privacy_access_levels` query inside the save_analysis callback we'll calculate it for the first time and since typeck info isn't complete, we'll crash there.
Double-checked locally and it seems to have fixed the problem.
r? @nikomatsakis
Don't actually create a full MIR stack frame when not needed
r? @dotdash
This should significantly reduce overhead during const propagation and reduce overhead *after* copy propagation (cc https://github.com/rust-lang/rust/issues/36673)
...while still keeping ambiguity errors future-proofing for uniform paths.
This corner case is not going to be stabilized for 1.32 and needs some more general experiments about retrofitting 2018 import rules to 2015 edition
Rollup of 26 pull requests
Successful merges:
- #56425 (Redo the docs for Vec::set_len)
- #56906 (Issue #56905)
- #57042 (Don't call `FieldPlacement::count` when count is too large)
- #57175 (Stabilize `let` bindings and destructuring in constants and const fn)
- #57192 (Change std::error::Error trait documentation to talk about `source` instead of `cause`)
- #57296 (Fixed the link to the ? operator)
- #57368 (Use CMAKE_{C,CXX}_COMPILER_LAUNCHER for ccache)
- #57400 (Rustdoc: update Source Serif Pro and replace Heuristica italic)
- #57417 (rustdoc: use text-based doctest parsing if a macro is wrapping main)
- #57433 (Add link destination for `read-ownership`)
- #57434 (Remove `CrateNum::Invalid`.)
- #57441 (Supporting backtrace for x86_64-fortanix-unknown-sgx.)
- #57450 (actually take a slice in this example)
- #57459 (Reference tracking issue for inherent associated types in diagnostic)
- #57463 (docs: Fix some 'second-edition' links)
- #57466 (Remove outdated comment)
- #57493 (use structured suggestion when casting a reference)
- #57498 (make note of one more normalization that Paths do)
- #57499 (note that FromStr does not work for borrowed types)
- #57505 (Remove submodule step from README)
- #57510 (Add a profiles section to the manifest)
- #57511 (Fix undefined behavior)
- #57519 (Correct RELEASES.md for 1.32.0)
- #57522 (don't unwrap unexpected tokens in `format!`)
- #57530 (Fixing a typographical error.)
- #57535 (Stabilise irrefutable if-let and while-let patterns)
Failed merges:
r? @ghost
Correct RELEASES.md for 1.32.0
The `into_to_from_bytes` feature was stabilized for `i128` and `u128` just like for the other integer types, but they seem to have been missed.
Fix undefined behavior
From the [`MaybeUninit::get_mut` docs](https://doc.rust-lang.org/std/mem/union.MaybeUninit.html):
> It is up to the caller to guarantee that the the MaybeUninit really is in an initialized state, otherwise this will immediately cause undefined behavior.
r? @joshtriplett
Reference tracking issue for inherent associated types in diagnostic
This makes it clearer that associated types in inherent impls are an intended feature, like the diagnostic for equality constraints in where clauses. (This is more helpful, because the lack of associated types is a confusing omission and it lets users more easily track the state of the feature.)
Supporting backtrace for x86_64-fortanix-unknown-sgx.
# Overview
Implementing following functions required by `libstd/sys_common` to support `backtrace`:
```
1. unwind_backtrace
2. trace_fn
3. resolve_symname
```
# Description:
The changes here are quite similar to the Cloudabi target `src/libstd/sys/cloudabi/backtrace.rs`
The first 2 functions are implemented via calls to libunwind.a that is linked to the `x86_64-fortanix-unknown-sgx` (#56979), we have not implemented functionality needed by `resolve_symname` (or `dladdr`) to reduce SGX TCB. Rather, we print the function address (relative to enclave image base) in `resolve_symname` which can be later translated to correct symbol name (say, via `addr2line`).
# Note:
For `x86_64-fortanix-unknown-sgx`, the `RUST_BACKTRACE` environment has to be set from within the program running in an enclave.
cc: @jethrogb
r? @alexcrichton
rustdoc: use text-based doctest parsing if a macro is wrapping main
This is a "forward-port" of https://github.com/rust-lang/rust/pull/57019, intended to get https://github.com/rust-lang/rust/issues/56898 on nightly, since it's now fixed on beta (and already worked on stable).
To recap:
* The libsyntax-based doctest parsing now checks to see whether there is a top-level macro invocation in the doctest while it's checking for `fn main` and an `extern crate` statement.
* If it finds a macro invocation and *didn't* find `fn main`, then it performs the older text-based scan to allow doctests like the ones in `allocator_api` to still compile.
A "proper" fix will involve changing how `make_test` works to call it later in the `run_test` function, after the initial steps of compilation have completed. I've filed [a separate issue](https://github.com/rust-lang/rust/issues/57415) for that, though.
Rustdoc: update Source Serif Pro and replace Heuristica italic
When Source Serif Pro was used to replace Heuristica in #15530, the italic variant was not ready yet, but now it is. This PR updates the Source Serif Pro font files to the [latest release](https://github.com/adobe-fonts/source-serif-pro/releases/tag/2.007R-ro%2F1.007R-it) which includes an italic variant, and replaces Heuristica italic with Source Serif Pro italic.
Fixes#57363.
Use CMAKE_{C,CXX}_COMPILER_LAUNCHER for ccache
CMake 3.4 and newer which is the required minimum version for LLVM
supports CMAKE_{C,CXX}_COMPILER_LAUNCHER for settting the compiler
launcher such as ccache which doesn't require shifting arguments.
Fixed the link to the ? operator
I'm working on updating all broken links, but figured I'd break up the pull requests so they are easier to review, versus just one big pull request.
Stabilize `let` bindings and destructuring in constants and const fn
r? @Centril
This PR stabilizes the following features in constants and `const` functions:
* irrefutable destructuring patterns (e.g. `const fn foo((x, y): (u8, u8)) { ... }`)
* `let` bindings (e.g. `let x = 1;`)
* mutable `let` bindings (e.g. `let mut x = 1;`)
* assignment (e.g. `x = y`) and assignment operator (e.g. `x += y`) expressions, even where the assignment target is a projection (e.g. a struct field or index operation like `x[3] = 42`)
* expression statements (e.g. `3;`)
This PR does explicitly *not* stabilize:
* mutable references (i.e. `&mut T`)
* dereferencing mutable references
* refutable patterns (e.g. `Some(x)`)
* operations on `UnsafeCell` types (as that would need raw pointers and mutable references and such, not because it is explicitly forbidden. We can't explicitly forbid it as such values are OK as long as they aren't mutated.)
* We are not stabilizing `let` bindings in constants that use `&&` and `||` short circuiting operations. These are treated as `&` and `|` inside `const` and `static` items right now. If we stopped treating them as `&` and `|` after stabilizing `let` bindings, we'd break code like `let mut x = false; false && { x = true; false };`. So to use `let` bindings in constants you need to change `&&` and `||` to `&` and `|` respectively.
Don't call `FieldPlacement::count` when count is too large
Sidestep ICE in `FieldPlacement::count` by not calling it when count will not fit in host's usize.
(I briefly played with trying to fix this by changing `FieldPlacement::count` to return a `u64`. However, based on how `FieldPlacement` is used, it seems like this would be a largely pointless pursuit... I'm open to counter-arguments, however.)
Fix#57038
Issue #56905
Adding a map to TypeckTables to get the list of all the Upvars
given a closureID. This is help us get rid of the recurring
pattern in the codebase of iterating over the free vars
using with_freevars.