about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-211/+309
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07Auto merge of #90348 - Amanieu:asm_feature_gates, r=joshtriplettbors-4/+58
Add features gates for experimental asm features This PR splits off parts of `asm!` into separate features because they are not ready for stabilization. Specifically this adds: - `asm_const` for `const` operands. - `asm_sym` for `sym` operands. - `asm_experimental_arch` for architectures other than x86, x86_64, arm, aarch64 and riscv. r? `@nagisa`
2021-11-07Add features gates for experimental asm featuresAmanieu d'Antras-4/+58
2021-11-06Auto merge of #90661 - matthiaskrgr:rollup-1umbdlx, r=matthiaskrgrbors-85/+79
Rollup of 6 pull requests Successful merges: - #90487 (Add a chapter on reading Rustdoc output) - #90508 (Apply adjustments for field expression even if inaccessible) - #90627 (Suggest dereference of `Box` when inner type is expected) - #90642 (use matches!() macro in more places) - #90646 (type error go brrrrrrrr) - #90649 (Run reveal_all on MIR when inlining is activated.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-06Rollup merge of #90649 - cjgillot:reveal-all-2, r=lcnrMatthias Krüger-1/+1
Run reveal_all on MIR when inlining is activated. Fix logic error in https://github.com/rust-lang/rust/pull/85254 which prevented the pass from running when needed. Fixes https://github.com/rust-lang/rust/issues/78442 r? ``@lcnr``
2021-11-06Rollup merge of #90646 - BoxyUwU:funky_ice, r=estebankMatthias Krüger-2/+7
type error go brrrrrrrr Fixes #90444 when we relate something like: `fn(fn((), (), u32))` with `fn(fn((), (), ()))` we relate the inner fn ptrs: `fn((), (), u32)` with `fn((), (), ())` yielding a `TypeError::ArgumentSorts(_, 2)` which we then use as the `TypeError` for the `fn(fn(..))` which later causes the ICE as the `2` does not correspond to any input or output types in `fn(_)` r? `@estebank`
2021-11-06Rollup merge of #90642 - matthiaskrgr:clippy_matches, r=cjgillotMatthias Krüger-79/+47
use matches!() macro in more places
2021-11-06Rollup merge of #90627 - camelid:suggest-box-deref, r=davidtwcoMatthias Krüger-0/+18
Suggest dereference of `Box` when inner type is expected For example: enum Ty { Unit, List(Box<Ty>), } fn foo(x: Ty) -> Ty { match x { Ty::Unit => Ty::Unit, Ty::List(elem) => foo(elem), } } Before, the only suggestion was to rewrap `inner` with `Ty::Wrapper`, which is unhelpful and confusing: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ | | | expected enum `Ty`, found struct `Box` | help: try using a variant of the expected enum: `Ty::List(elem)` | = note: expected enum `Ty` found struct `Box<Ty>` Now, rustc will first suggest dereferencing the `Box`, which is most likely what the user intended: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ expected enum `Ty`, found struct `Box` | = note: expected enum `Ty` found struct `Box<Ty>` help: try dereferencing the `Box` | 9 | Ty::List(elem) => foo(*elem), | + help: try using a variant of the expected enum | 9 | Ty::List(elem) => foo(Ty::List(elem)), | ~~~~~~~~~~~~~~ r? ``@davidtwco``
2021-11-06Rollup merge of #90508 - nbdd0121:issue-90483, r=davidtwcoMatthias Krüger-3/+6
Apply adjustments for field expression even if inaccessible The adjustments are used later by ExprUseVisitor to build Place projections and without adjustments it can produce invalid result. Fix #90483 ``@rustbot`` label: T-compiler
2021-11-06Auto merge of #90655 - the8472:drain-dot-dot, r=jyn514bors-6/+6
Replace some uses of vec.drain(..) with vec.into_iter() IntoIter should optimize better than Drain
2021-11-06Suggest dereference of `Box` when inner type is expectedNoah Lev-0/+18
For example: enum Ty { Unit, List(Box<Ty>), } fn foo(x: Ty) -> Ty { match x { Ty::Unit => Ty::Unit, Ty::List(elem) => foo(elem), } } Before, the only suggestion was to rewrap `elem` with `Ty::List`, which is unhelpful and confusing: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ | | | expected enum `Ty`, found struct `Box` | help: try using a variant of the expected enum: `Ty::List(elem)` | = note: expected enum `Ty` found struct `Box<Ty>` Now, rustc will first suggest dereferencing the `Box`, which is most likely what the user intended: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ expected enum `Ty`, found struct `Box` | = note: expected enum `Ty` found struct `Box<Ty>` help: try dereferencing the `Box` | 9 | Ty::List(elem) => foo(*elem), | + help: try using a variant of the expected enum | 9 | Ty::List(elem) => foo(Ty::List(elem)), | ~~~~~~~~~~~~~~
2021-11-06Replace some uses of vec.drain(..) with vec.into_iter()The8472-6/+6
IntoIter should optimize better than Drain
2021-11-06Auto merge of #90559 - rusticstuff:optimize-bidi-detection, r=davidtwcobors-16/+46
Optimize bidi character detection. Should fix most of the performance regression of the bidi character detection (#90514), to be confirmed with a perf run.
2021-11-06use matches!() macro in more placesMatthias Krüger-79/+47
2021-11-06Run reveal_all on MIR more often.Camille GILLOT-1/+1
2021-11-06Auto merge of #90641 - matthiaskrgr:mut, r=cjgillotbors-1/+1
pointee_info_at() does not need mutable access
2021-11-06type error go brrrrrrrrEllen-2/+7
2021-11-06Auto merge of #90617 - tmiasko:time-trace-threads, r=wesleywiserbors-56/+128
Initialize LLVM time trace profiler on each code generation thread In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread. cc `@tmandry` r? `@wesleywiser`
2021-11-06Auto merge of #89970 - jackh726:gats_diagnostics, r=nikomatsakisbors-8/+388
Implementation of GATs outlives lint See #87479 for background. Closes #87479 The basic premise of this lint/error is to require the user to write where clauses on a GAT when those bounds can be implied or proven from any function on the trait returning that GAT. ## Intuitive Explanation (Attempt) ## Let's take this trait definition as an example: ```rust trait Iterable { type Item<'x>; fn iter<'a>(&'a self) -> Self::Item<'a>; } ``` Let's focus on the `iter` function. The first thing to realize is that we know that `Self: 'a` because of `&'a self`. If an impl wants `Self::Item` to contain any data with references, then those references must be derived from `&'a self`. Thus, they must live only as long as `'a`. Furthermore, because of the `Self: 'a` implied bound, they must live only as long as `Self`. Since it's `'a` is used in place of `'x`, it is reasonable to assume that any value of `Self::Item<'x>`, and thus `'x`, will only be able to live as long as `Self`. Therefore, we require this bound on `Item` in the trait. As another example: ```rust trait Deserializer<T> { type Out<'x>; fn deserialize<'a>(&self, input: &'a T) -> Self::Out<'a>; } ``` The intuition is similar here, except rather than a `Self: 'a` implied bound, we have a `T: 'a` implied bound. Thus, the data on `Self::Out<'a>` is derived from `&'a T`, and thus it is reasonable to expect that the lifetime `'x` will always be less than `T`. ## Implementation Algorithm ## * Given a GAT `<P0 as Trait<P1..Pi>>::G<Pi...Pn>` declared as `trait T<A1..Ai> for A0 { type G<Ai...An>; }` used in return type of one associated function `F` * Given env `E` (including implied bounds) for `F` * For each lifetime parameter `'a` in `P0...Pn`: * For each other type parameter `Pi != 'a` in `P0...Pn`: // FIXME: this include of lifetime parameters too * If `E => (P: 'a)`: * Require where clause `Ai: 'a` ## Follow-up questions ## * What should we do when we don't pass params exactly? For this example: ```rust trait Des { type Out<'x, D>; fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>; } ``` Should we be requiring a `D: 'x` clause? We pass `Wrap<T>` as `D` and `'z` as `'x`, and should be able to prove that `Wrap<T>: 'z`. r? `@nikomatsakis`
2021-11-05Review commentsjackh726-14/+41
2021-11-06Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakisbors-12/+39
Normalize obligations for closure confirmation Based on #90017 Fixes #74261 Fixes #71955 Fixes #88459 r? `@nikomatsakis`
2021-11-06pointee_info_at() does not need mutable accessMatthias Krüger-1/+1
2021-11-05Rollup merge of #90626 - rusticstuff:be-more-accepting, r=jyn514Matthias Krüger-0/+1
Properly register text_direction_codepoint_in_comment lint. This makes it known to the compiler so it can be configured like with `#![allow(text_direction_codepoint_in_comment)]`. Fixes #90614.
2021-11-05Rollup merge of #90623 - cuviper:llvm-12, r=nikicMatthias Krüger-27/+24
Remove more checks for LLVM < 12 We already updated the minimum to 12 in #90175, but we missed a few `get_version()` checks.
2021-11-05Rollup merge of #90597 - nikomatsakis:issue-90465, r=wesleywiserMatthias Krüger-78/+153
Warn for variables that are no longer captured r? `@wesleywiser` cc `@rust-lang/wg-rfc-2229` Fixes #90465
2021-11-05Update LLVM comments around NoAliasMutRefJosh Stone-5/+8
2021-11-05Properly register text_direction_codepoint_in_comment lint.Hans Kratz-0/+1
2021-11-05Update the documented default of -Zmutable-noaliasJosh Stone-1/+1
2021-11-05Move outline-atomics to aarch64-linux target definitionsJosh Stone-6/+9
2021-11-05Remove some minor checks for LLVM < 12Josh Stone-15/+6
2021-11-05Initialize LLVM time trace profiler on each code generation threadTomasz Miąsko-56/+128
In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread.
2021-11-05apply suggestions from code reviewNiko Matsakis-19/+21
2021-11-05error_codes: uniformly comment error codesBen Boeckel-20/+19
2021-11-05Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkovbors-11/+11
clippy::perf fixes
2021-11-05Rollup merge of #90544 - ehuss:demote-locator-warn, r=petrochenkovYuki Okushi-2/+2
Demote metadata load warning to "info". There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means). If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully #88368 will improve that error message). If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details. There is more discussion of this particular warning at https://github.com/rust-lang/rust/issues/89795#issuecomment-940798190. Fixes #90525
2021-11-05Rollup merge of #90537 - adamgemmell:dev/aarch64-target-feature, r=AmanieuYuki Okushi-8/+18
Update aarch64 `target_feature` list for LLVM 12. Many of these feature are now available on all valid LLVM versions. I've also added a few new ones to the list. r? `@Amanieu`
2021-11-05Rollup merge of #90507 - TaKO8Ki:suggest-extern-crate-alloc, r=jackh726Yuki Okushi-9/+23
Suggest `extern crate alloc` when using undeclared module `alloc` closes #90136
2021-11-04handle case of a variable not capturedNiko Matsakis-8/+22
2021-11-04rework diagnostic reporting to be more structuredNiko Matsakis-77/+108
2021-11-05Use one match instead of a staggered match.Hans Kratz-11/+2
2021-11-04Remove now unused feature from rustc_parseHans Kratz-1/+0
2021-11-04Optimize literal, doc comment lint as well, extract function.Hans Kratz-49/+54
2021-11-04Auto merge of #90536 - crlf0710:fix_vtable_hrtb, r=jackh726bors-1/+4
Erase regions within `vtable_trait_first_method_offset` Fixes #90177 . r? `@jackh726`
2021-11-04clippy::perf fixesMatthias Krüger-11/+11
2021-11-04introduce an enum for tracking the 2229 migration causesNiko Matsakis-15/+43
2021-11-04Create subslice as that leads to a smaller code size.Hans Kratz-3/+4
2021-11-04Optimize bidi character detection.Hans Kratz-6/+40
2021-11-04Auto merge of #90518 - calebcartwright:rustc-ast-docs, r=wesleywiserbors-3/+2
update rustc_ast crate descriptions in documentation I noticed this the other day and figured I'd suggest a refresh. It seems like a relic from the days of `libsyntax` that got missed as things were split out into separate crates, since the current documentation text references elements that were moved into their own respective crates (e.g. `rustc_parse`)
2021-11-04Auto merge of #90179 - Nilstrieb:lifetime-elision-mismatch-hint, r=estebankbors-8/+86
Add beginner friendly lifetime elision hint to E0623 Address #90170 Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't. Example: ``` error[E0623]: lifetime mismatch --> $DIR/issue-90170-elision-mismatch.rs:2:35 | LL | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) { | --------- --------- these two types are declared with different lifetimes... LL | core::mem::swap(&mut slice_a, &mut slice_b); | ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here | = note: each elided lifetime in input position becomes a distinct lifetime help: explicitly declare a lifetime and assign it to both | LL | fn foo<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) { | ++++ ++ ++ ``` for ```rust fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) { core::mem::swap(&mut slice_a, &mut slice_b); } ```
2021-11-03Demote metadata load warning to "info".Eric Huss-2/+2