summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2021-06-14Revert "Allow specifying alignment for functions"Felix S. Klock II-4/+0
This reverts commit 448d07683a6defd567996114793a09c9a8aef5df to address issue 85713 on beta.
2021-06-11Hash attributes for crate_hash.Camille GILLOT-6/+31
2021-05-04Remove assert_matches feature attributes.Mara Bos-1/+0
2021-05-04Remove assert_matches usersMark Rousskov-6/+2
2021-04-30Auto merge of #84719 - Mark-Simulacrum:reduce-query-impl, r=davidtwcobors-14/+21
Move iter_results to dyn FnMut rather than a generic This means that we're no longer generating the iteration/locking code for each invocation site of iter_results, rather just once per query (roughly), which seems much better: this is a 15% win in instruction counts when compiling the rustc_query_impl crate. The code where this is used also is pretty cold, I suspect; the old solution didn't fully monomorphize either.
2021-04-30Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkovbors-5/+22
Implement RFC 1260 with feature_name `imported_main`. This is the second extraction part of #84062 plus additional adjustments. This (mostly) implements RFC 1260. However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure. cc https://github.com/rust-lang/rust/issues/28937 r? `@petrochenkov`
2021-04-29Rollup merge of #84682 - jackh726:transitive_bounds_rebind, r=nikomatsakisJack Huey-0/+4
Don't rebind in `transitive_bounds_that_define_assoc_type` Fixes #83737 Fixes #84604 Also fixes another issue that I don't have a test for, popped up in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/Duplicate.20symbol.20error.20.2384604/near/236570445) r? `````@nikomatsakis`````
2021-04-29Move iter_results to dyn FnMut rather than a genericMark Rousskov-14/+21
This means that we're no longer generating the iteration/locking code for each invocation site of iter_results, rather just once per query. This is a 15% win in instruction counts when compiling the rustc_query_impl crate.
2021-04-29Auto merge of #84233 - jyn514:track-path-prefix, r=michaelwoeristerbors-1/+1
Add TRACKED_NO_CRATE_HASH and use it for `--remap-path-prefix` I verified locally that this fixes https://github.com/rust-lang/rust/issues/66955. r? `@Aaron1011` (feel free to reassign)
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-5/+22
2021-04-28Add HAS_RE_LATE_BOUND if there are bound varsJack Huey-0/+4
2021-04-28Auto merge of #84562 - richkadel:issue-83601, r=tmandrybors-0/+4
Adds feature-gated `#[no_coverage]` function attribute, to fix derived Eq `0` coverage issue #83601 Derived Eq no longer shows uncovered The Eq trait has a special hidden function. MIR `InstrumentCoverage` would add this function to the coverage map, but it is never called, so the `Eq` trait would always appear uncovered. Fixes: #83601 The fix required creating a new function attribute `no_coverage` to mark functions that should be ignored by `InstrumentCoverage` and the coverage `mapgen` (during codegen). Adding a `no_coverage` feature gate with tracking issue #84605. r? `@tmandry` cc: `@wesleywiser`
2021-04-28Rollup merge of #84622 - jackh726:gats-trait-object, r=nikomatsakisYuki Okushi-0/+8
Make traits with GATs not object safe Closes #81823 r? `@nikomatsakis`
2021-04-27Make traits with GATs not object safeJack Huey-0/+8
2021-04-27Derived Eq no longer shows uncoveredRich Kadel-0/+4
The Eq trait has a special hidden function. MIR `InstrumentCoverage` would add this function to the coverage map, but it is never called, so the `Eq` trait would always appear uncovered. Fixes: #83601 The fix required creating a new function attribute `no_coverage` to mark functions that should be ignored by `InstrumentCoverage` and the coverage `mapgen` (during codegen). While testing, I also noticed two other issues: * spanview debug file output ICEd on a function with no body. The workaround for this is included in this PR. * `assert_*!()` macro coverage can appear covered if followed by another `assert_*!()` macro. Normally they appear uncovered. I submitted a new Issue #84561, and added a coverage test to demonstrate this issue.
2021-04-27Add [TRACKED_NO_CRATE_HASH] and [SUBSTRUCT] directivesJoshua Nelson-1/+1
This is necessary for options that should invalidate the incremental hash but *not* affect the crate hash (e.g. --remap-path-prefix). This doesn't add `for_crate_hash` to the trait directly because it's not relevant for *types*, only for *options*, which are fields on a larger struct. Instead, it adds a new `SUBSTRUCT` directive for options, which does take a `for_crate_hash` parameter. - Use TRACKED_NO_CRATE_HASH for --remap-path-prefix - Add test that `remap_path_prefix` is tracked - Reduce duplication in the test suite to avoid future churn
2021-04-27move `representability` out of `rustc_middle`lcnr-189/+2
2021-04-25Rollup merge of #84547 - RalfJung:max_const_fn, r=oli-obkDylan DPC-3/+1
Get rid of is_min_const_fn This removes the last trace of the min_const_fn mechanism by making the unsafety checker agnostic about whether something is a min or "non-min" const fn. It seems this distinction was used to disallow some features inside `const fn`, but that is the responsibility of the const checker, not of the unsafety checker. No test seems to even notice this change in the unsafety checker so I guess we are good... r? `@oli-obk` Cc https://github.com/rust-lang/rust/issues/84510
2021-04-25fix typographyRalf Jung-1/+1
2021-04-25Auto merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkorbors-1/+1
various const parameter defaults improvements Actually resolve names in const parameter defaults, fixing `struct Foo<const N: usize = { usize::MAX }>`. --- Split generic parameter ban rib for types and consts, allowing ```rust #![feature(const_generics_defaults)] struct Q; struct Foo<T = Q, const Q: usize = 3>(T); ``` --- Remove the type/const ordering restriction if `const_generics_defaults` is active, even if `const_generics` is not. allowing us to stabilize and test const param defaults separately. --- Check well formedness of const parameter defaults, eagerly emitting an error for `struct Foo<const N: usize = { 0 - 1 }>` --- Do not forbid const parameters in param defaults, allowing `struct Foo<const N: usize, T = [u8; N]>(T)` and `struct Foo<const N: usize, const M: usize = N>`. Note that this should not change anything which is stabilized, as on stable, type parameters must be in front of const parameters, which means that type parameter defaults are only allowed if no const parameters exist. We still forbid generic parameters inside of const param types. r? `@varkor` `@petrochenkov`
2021-04-25unsafety checking: no longer care about is_min_const_fnRalf Jung-3/+1
Rejecting the forbidden unsafe ops is done by const checking, not by unsafety checking
2021-04-25Auto merge of #84147 - cuviper:array-method-dispatch, r=nikomatsakis,m-ou-sebors-0/+7
Cautiously add IntoIterator for arrays by value Add the attribute described in #84133, `#[rustc_skip_array_during_method_dispatch]`, which effectively hides a trait from method dispatch when the receiver type is an array. Then cherry-pick `IntoIterator for [T; N]` from #65819 and gate it with that attribute. Arrays can now be used as `IntoIterator` normally, but `array.into_iter()` has edition-dependent behavior, returning `slice::Iter` for 2015 and 2018 editions, or `array::IntoIter` for 2021 and later. r? `@nikomatsakis` cc `@LukasKalbertodt` `@rust-lang/libs`
2021-04-24Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obkbors-1/+0
further split up const_fn feature flag This continues the work on splitting up `const_fn` into separate feature flags: * `const_fn_trait_bound` for `const fn` with trait bounds * `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here) I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more. `@oli-obk` are you currently able to do reviews?
2021-04-25Rollup merge of #83519 - oli-obk:assign_shrink_your_normal_code, r=pnkfelixYuki Okushi-6/+34
Implement a lint that highlights all moves larger than a configured limit Tracking issue: #83518 [MCP 420](https://github.com/rust-lang/compiler-team/issues/420) still ~blazing~ in progress r? ```@pnkfelix``` The main open issue I see with this minimal impl of the feature is that the lint is immediately "stable" (so it can be named on stable), even if it is never executed on stable. I don't think we have the concept of unstable lint names or hiding lint names without an active feature gate, so that would be a bigger change.
2021-04-22Rollup merge of #84343 - camsteffen:closure-tree, r=varkorDylan DPC-31/+0
Remove `ScopeTree::closure_tree` Seems to be dead code since #50649.
2021-04-22Auto merge of #71511 - hi-rustin:rustin-patch-rename-assoc, r=eddyb,varkorbors-4/+4
Rename AssociatedItems to AssocItems Signed-off-by: Rustin-Liu <rustin.liu@gmail.com> Part of https://github.com/rust-lang/rust/issues/60163#issuecomment-605308641
2021-04-21loosen ordering restricts for `const_generics_defaults`lcnr-1/+1
2021-04-20TidyOli Scherer-1/+4
2021-04-20Add an attribute to be able to configure the limitOli Scherer-5/+10
2021-04-20Implement a lint that highlights all moves larger than 1000 bytesOli Scherer-1/+21
2021-04-20Auto merge of #84334 - klensy:typo-compiler, r=jyn514bors-4/+4
fix few typos in comments
2021-04-19Remove closure_treeCameron Steffen-31/+0
2021-04-19Rollup merge of #84123 - bjorn3:compile_mono_item_dep_node, r=wesleywiserDylan DPC-9/+34
Introduce CompileMonoItem DepNode This is likely required for allowing efficient hot code swap support in cg_clif's jit mode. My prototype currently requires re-compiling all functions, which is both slow and uses a lot of memory as there is not support for freeing the memory used by replaced functions yet. cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1087
2021-04-19fix few typosklensy-4/+4
2021-04-18fix feature use in rustc libsRalf Jung-1/+0
2021-04-16Mark `has_global_allocator` query as `eval_always`Aaron Hill-0/+2
Fixes #84252 This query reads from untracked global state in `CStore`.
2021-04-16Add commentbjorn3-0/+1
2021-04-16Implement #[rustc_skip_array_during_method_dispatch]Josh Stone-0/+7
2021-04-12Introduce CompileMonoItem DepNodebjorn3-9/+33
2021-04-12Rollup merge of #84014 - estebank:cool-bears-hot-tip, r=varkorDylan DPC-5/+16
Improve trait/impl method discrepancy errors * Use more accurate spans * Clean up some code by removing previous hack * Provide structured suggestions Structured suggestions are particularly useful for cases where arbitrary self types are used, like in custom `Future`s, because the way to write `self: Pin<&mut Self>` is not necessarily self-evident when first encountered.
2021-04-09Auto merge of #83870 - jackh726:binder-refactor-fix, r=nikomatsakisbors-22/+87
Don't concatenate binders across types Partially addresses #83737 There's actually two issues that I uncovered in #83737. The first is that we are concatenating bound vars across types, i.e. in ``` F: Fn(&()) -> &mut (dyn Future<Output = ()> + Unpin) ``` the bound vars on `Future` get set as `for<anon>` since those are the binders on `Fn(&()`. This is obviously wrong, since we should only concatenate directly nested trait refs. This is solved here by introducing a new `TraitRefBoundary` scope, that we put around the "syntactical" trait refs and basically don't allow concatenation across. Now, this alone *shouldn't* be a super terrible problem. At least not until you consider the other issue, which is a much more elusive and harder to design a "perfect" fix. A repro can be seen in: ``` use core::future::Future; async fn handle<F>(slf: &F) where F: Fn(&()) -> &mut (dyn for<'a> Future<Output = ()> + Unpin), { (slf)(&()).await; } ``` Notice the `for<'a>` around `Future`. Here, `'a` is unused, so the `for<'a>` Binder gets changed to a `for<>` Binder in the generator witness, but the "local decl" still has it. This has heavy intersections with region anonymization and erasing. Luckily, it's not *super* common to find this unique set of circumstances. It only became apparently because of the first issue mentioned here. However, this *is* still a problem, so I'm leaving #83737 open. r? `@nikomatsakis`
2021-04-08Auto merge of #84008 - Dylan-DPC:rollup-invxvg8, r=Dylan-DPCbors-6/+6
Rollup of 6 pull requests Successful merges: - #80733 (Improve links in inline code in `core::pin`.) - #81764 (Stabilize `rustdoc::bare_urls` lint) - #81938 (Stabilize `peekable_peek_mut`) - #83980 (Fix outdated crate names in compiler docs) - #83992 (Merge idents when generating source content) - #84001 (Update Clippy) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-08Rollup merge of #83980 - pierwill:fix-compiler-librustc-names, r=davidtwcoDylan DPC-6/+6
Fix outdated crate names in compiler docs Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged.
2021-04-08Use more accurate spans for trait/impl method arg divergenceEsteban Küber-5/+16
2021-04-08Fix outdated crate names in compiler docspierwill-6/+6
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2021-04-08rustc: Add a new `wasm` ABIAlex Crichton-0/+2
This commit implements the idea of a new ABI for the WebAssembly target, one called `"wasm"`. This ABI is entirely of my own invention and has no current precedent, but I think that the addition of this ABI might help solve a number of issues with the WebAssembly targets. When `wasm32-unknown-unknown` was first added to Rust I naively "implemented an abi" for the target. I then went to write `wasm-bindgen` which accidentally relied on details of this ABI. Turns out the ABI definition didn't match C, which is causing issues for C/Rust interop. Currently the compiler has a "wasm32 bindgen compat" ABI which is the original implementation I added, and it's purely there for, well, `wasm-bindgen`. Another issue with the WebAssembly target is that it's not clear to me when and if the default C ABI will change to account for WebAssembly's multi-value feature (a feature that allows functions to return multiple values). Even if this does happen, though, it seems like the C ABI will be guided based on the performance of WebAssembly code and will likely not match even what the current wasm-bindgen-compat ABI is today. This leaves a hole in Rust's expressivity in binding WebAssembly where given a particular import type, Rust may not be able to import that signature with an updated C ABI for multi-value. To fix these issues I had the idea of a new ABI for WebAssembly, one called `wasm`. The definition of this ABI is "what you write maps straight to wasm". The goal here is that whatever you write down in the parameter list or in the return values goes straight into the function's signature in the WebAssembly file. This special ABI is for intentionally matching the ABI of an imported function from the environment or exporting a function with the right signature. With the addition of a new ABI, this enables rustc to: * Eventually remove the "wasm-bindgen compat hack". Once this ABI is stable wasm-bindgen can switch to using it everywhere. Afterwards the wasm32-unknown-unknown target can have its default ABI updated to match C. * Expose the ability to precisely match an ABI signature for a WebAssembly function, regardless of what the C ABI that clang chooses turns out to be. * Continue to evolve the definition of the default C ABI to match what clang does on all targets, since the purpose of that ABI will be explicitly matching C rather than generating particular function imports/exports. Naturally this is implemented as an unstable feature initially, but it would be nice for this to get stabilized (if it works) in the near-ish future to remove the wasm32-unknown-unknown incompatibility with the C ABI. Doing this, however, requires the feature to be on stable because wasm-bindgen works with stable Rust.
2021-04-07Auto merge of #81047 - glittershark:stabilize-cmp-min-max-by, r=kodrausbors-1/+0
Stabilize cmp_min_max_by I would like to propose cmp::{min_by, min_by_key, max_by, max_by_key} for stabilization. These are relatively simple and seemingly uncontroversial functions and have been unchanged in unstable for a while now. Closes: #64460
2021-04-07Stabilize cmp_min_max_byGriffin Smith-1/+0
I would like to propose cmp::{min_by, min_by_key, max_by, max_by_key} for stabilization. These are relatively simple and seemingly uncontroversial functions and have been unchanged in unstable for a while now.
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-4/+4
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See #83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes #83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-4/+4