We are heading towards deeper integration with the region inference
system in infcx; in particular, prior to the creation of the
`RegionInferenceContext`, it will be the "owner" of the set of region
variables.
examples in Cow::into_owned don't need to wrap result in Cows
This totally confused me until i triple-checked the actual return value and opened the examples in the playground myself.
r? @rust-lang/docs
Add context to E0084, E0517, E0518
A small diagnostic enhancement to get my feet wet. Please scrutinize!
This modifies errors E0084, E0517, and E0518 to include both the annotation and the annotated item. All of these errors already had labels; I moved the label to the other span, and rephrased it as necessary.
Fixes#45886
avoid the pprust infrastructure in macro expansion
This changes macro expansion to format the path of a macro directly
instead of usng the pprust infrastructure. The pprust infrastructure
tries to perform line-breaking in a slow fashion, which is undesired
when formatting the path of a macro.
This should to speed up expansion by a fair amount (I saw 20% on a
profiler on `rustc_mir`, and 50% of the time marked as "expansion" in
the profiler/time-passes is actually spent loading dependencies).
r? @jseyfried
check_unsafety: fix unused unsafe block duplication
The duplicate error message is later removed by error message
deduplication, but it still appears on beta and is still a bug.
r? @eddyb
Enable TrapUnreachable in LLVM.
This patch enables LLVM's TrapUnreachable flag, which tells it to translate `unreachable` instructions into hardware trap instructions, rather than allowing control flow to "fall through" into whatever code happens to follow it in memory.
This follows up on https://github.com/rust-lang/rust/issues/28728#issuecomment-332581533. For example, for @zackw's testcase [here](https://github.com/rust-lang/rust/issues/42009#issue-228745924), the output function contains a `ud2` instead of no code, so it won't "fall through" into whatever happens to be next in memory.
(I'm also working on the problem of LLVM optimizing away infinite loops, but the patch here is useful independently.)
I tested this patch on a few different codebases, and the code size increase ranged from 0.0% to 0.1%.
Fix a bug where the rustfmt tarball was not being produced
r? @alexcrichton
This makes rustfmt a dep of 'extended', which seems to be necessary for the rustfmt dist step to actually get run.
Implement `impl Trait` in argument position (RFC1951, Universal quantification)
Implements the remainder of #44721, part of #34511.
**Note**: This PR currently allows argument position `impl Trait` in trait functions. The machinery is there to prevent this if we want to, but it currently does not.
Rename `hir::TyImplTrait` to `hir::TyImplTraitExistential` and add `hir::TyImplTraitUniversal(DefId, TyParamBounds)`. The `DefId` is needed to extract the index of the parameter in `ast_ty_to_ty`.
Introduce an `ImplTraitContext` enum to lowering to keep track of the kind and allowedness of `impl Trait` in that position. This new argument is passed through many places, all ending up in `lower_ty`.
Modify `generics_of` and `explicit_predicates_of` to collect the `impl Trait` args into anonymous synthetic generic parameters and to extend the predicates with the appropriate bounds.
Add a comparison of the 'syntheticness' of type parameters, that is, prevent the following.
```rust
trait Foo {
fn foo(&self, &impl Debug);
}
impl Foo for Bar {
fn foo<U: Debug>(&self, x: &U) { ... }
}
```
And vice versa.
Incedentally, supress `unused type parameter` errors if the type being compared is already a `TyError`.
**TODO**: I have tried to annotate open questions with **FIXME**s. The most notable ones that haven't been resolved are the names of the `impl Trait` types and the questions surrounding the new `compare_synthetic_generics` method.
1. For now, the names used for `impl Trait` parameters are `keywords::Invalid.name()`. I would like them to be `impl ...` if possible, but I haven't figured out a way to do that yet.
2. For `compare_synthetic_generics` I have tried to outline the open questions in the [function itself](3fc9e3705f/src/librustc_typeck/check/compare_method.rs (L714-L725))
r? @nikomatsakis