about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2020-11-18Auto merge of #79106 - tmiasko:inline-hint, r=nagisa,eddybbors-12/+4
Fix setting inline hint based on `InstanceDef::requires_inline` For instances where `InstanceDef::requires_inline` is true, an attempt is made to set an inline hint though a call to the `inline` function. The attempt is ineffective, since all attributes will be usually removed by the second call. Fix the issue by applying the attributes only once, with user provided attributes having a priority when provided. Closes #79108.
2020-11-18Auto merge of #78995 - Nadrieril:clean-empty-match, r=varkorbors-111/+141
Handle empty matches cleanly in exhaustiveness checking This removes the special-casing of empty matches that was done in `check_match`. This fixes most of https://github.com/rust-lang/rust/issues/55123. Somewhat unrelatedly, I also made `_match.rs` more self-contained, because I think it's cleaner. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-11-18Rollup merge of #79158 - lcnr:lazy-norm-coerce, r=oli-obkMara Bos-1/+2
type is too big -> values of the type are too big strictly speaking, `[u8; usize::MAX]` or even `[[[u128; usize::MAX]; usize::MAX]; usize::MAX]` are absolutely fine types as long as you don't try to deal with any values of it. This error message seems to cause some confusion imo, for example in https://github.com/rust-lang/rust/pull/79135#issuecomment-729361380 so I would prefer us to be more precise here. See the added test case which uses one of these types without causing an error. r? ``@oli-obk``
2020-11-18Rollup merge of #79079 - camelid:mir-visit-docs, r=matthewjasperMara Bos-62/+62
Turn top-level comments into module docs in MIR visitor
2020-11-18Rollup merge of #78999 - petrochenkov:deprid, r=eddybMara Bos-2/+4
stability: More precise location for deprecation lint on macros One missing piece of https://github.com/rust-lang/rust/pull/73178.
2020-11-18Rollup merge of #78361 - DevJPM:master, r=workingjubileeMara Bos-0/+23
Updated the list of white-listed target features for x86 This PR both adds in-source documentation on what to look out for when adding a new (X86) feature set and [adds all that are detectable at run-time in Rust stable as of 1.27.0](https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/src/detect/arch/x86.rs). This should only enable the use of the corresponding LLVM intrinsics. Actual intrinsics need to be added separately in rust-lang/stdarch. It also re-orders the run-time-detect test statements to be more consistent with the actual list of intrinsics whitelisted and removes underscores not present in the actual names (which might be mistaken as being part of the name) The reference for LLVM's feature names used is [this file](https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/X86TargetParser.def). This PR was motivated as the compiler end's part for allowing #67329 to be adressed over on rust-lang/stdarch
2020-11-18change error for `LayoutErr::SizeOverflow`Bastian Kauschke-1/+1
2020-11-17Fix broken handling of `MacroDef` in `Map::attrs`Joshua Nelson-17/+26
This also uses an exhaustive match to avoid future similar bugs.
2020-11-17Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebankMara Bos-10/+54
Fix exhaustiveness in case a byte string literal is used at slice type fixes #79048
2020-11-17Rollup merge of #78702 - wesleywiser:self_profile_cgu_sizes, r=Mark-SimulacrumMara Bos-2/+26
[self-profiling] Include the estimated size of each cgu in the profile This is helpful when looking for CGUs where the size estimate isn't a good indicator of compilation time. I verified that moving the profiling timer call doesn't affect the results. Results: <img width="297" alt="Screen Shot 2020-11-03 at 7 25 04 AM" src="https://user-images.githubusercontent.com/831192/97985503-5901d100-1da6-11eb-9f10-f3e399702952.png"> `measureme` doesn't have support for custom arg names yet so `arg0` is the CGU name and `arg1` is the estimated size.
2020-11-17Rollup merge of #74293 - GuillaumeGomez:rustdoc-test-compiler-output-color, ↵Mara Bos-0/+17
r=jyn514 Rustdoc test compiler output color Fixes #72915 We just need to be sure it doesn't break rustdoc doctests' compilation checks. Maybe some other unforeseen consequences too? r? `@ehuss` cc `@rust-lang/rustdoc`
2020-11-17Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obkbors-212/+229
Introduce `TypeVisitor::BreakTy` Implements MCP rust-lang/compiler-team#383. r? `@ghost` cc `@lcnr` `@oli-obk` ~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-17Simplfy color availability checkGuillaume Gomez-0/+17
2020-11-17Fix exhaustiveness in case a byte string literal is used at slice typeoli-10/+54
2020-11-17Rollup merge of #79088 - euclio:span-label-doc, r=estebankMara Bos-8/+10
clarify `span_label` documentation Fixes #71857. r? ``@estebank`` cc ``@RalfJung``
2020-11-17Rollup merge of #79027 - tmiasko:inline-always-live-locals, r=oli-obkMara Bos-1/+42
Limit storage duration of inlined always live locals Closes #76375.
2020-11-17Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakisbors-176/+855
RFC-2229: Implement Precise Capture Analysis ### This PR introduces - Feature gate for RFC-2229 (incomplete) `capture_disjoint_field` - Rustc Attribute to print out the capture analysis `rustc_capture_analysis` - Precise capture analysis ### Description of the analysis 1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat) 2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout. 3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list. Check rust-lang/project-rfc-2229#9 for more detailed examples. 4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing. ### Known issues - Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression. ### Testing We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762 ### Thanks This has been slowly in the works for a while now. I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us. Closes rust-lang/project-rfc-2229#7 Closes rust-lang/project-rfc-2229#9 Closes rust-lang/project-rfc-2229#6 Closes rust-lang/project-rfc-2229#19 r? `@nikomatsakis`
2020-11-17Auto merge of #78313 - lcnr:somebody-fold-me, r=nikomatsakisbors-838/+881
TypeFoldable: take self by value Implements https://github.com/rust-lang/compiler-team/issues/371 which is currently still in FCP. r? `@nikomatsakis`
2020-11-17Fix setting inline hint based on `InstanceDef::requires_inline`Tomasz Miąsko-12/+4
For instances where `InstanceDef::requires_inline` is true, an attempt is made to set an inline hint though a call to the `inline` function. The attempt is ineffective, since all attributes will be usually removed by the second call. Fix the issue by applying the attributes only once, with user provided attributes having a priority when provided.
2020-11-16clarify `span_label` documentationAndy Russell-8/+10
2020-11-16update `cg_clif`Bastian Kauschke-46/+45
2020-11-16wordslcnr-105/+87
2020-11-16compiler: fold by valueBastian Kauschke-699/+679
2020-11-16add IdFunctor to rustc_data_structuresBastian Kauschke-0/+82
2020-11-16Rollup merge of #79087 - ThePuzzlemaker:issue-79083-docfix, r=RalfJungMara Bos-8/+11
Update E0744 about control flow in `const` contexts to accurately describe when the error is triggered and why This PR fixes #79083. `const fn` currently supports `if`, `match`, `loop`, and `while` in terms of control flow. The error relating to control flow in `const` contexts currently states that those control flow constructs are not allowed in `const` contexts. That is no longer true, as RFC 2342 and 2344 were [stabilized](https://github.com/rust-lang/rust/pull/72437). `for` loops, however, as well as `?` and `.await` are still not allowed, so I changed the error message to be more descriptive of the error as it is not just control flow that could trigger this error. I also added links to tracking issues that mark things that are blocking the usage of these expressions.
2020-11-16Rollup merge of #79032 - lcnr:arg-count, r=varkorMara Bos-103/+88
improve type const mismatch errors Doesn't completely remove `check_generic_arg_count` as that would have required some more complex changes but instead checks type and const params in only one step. Also moved the help added by `@JulianKnodt` in #75611 to `generic_arg_mismatch_err`. r? `@varkor` cc `@petrochenkov`
2020-11-16Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAusMara Bos-23/+4
Simplify output capturing This is a sequence of incremental improvements to the unstable/internal `set_panic` and `set_print` mechanism used by the `test` crate: 1. Remove the `LocalOutput` trait and use `Arc<Mutex<dyn Write>>` instead of `Box<dyn LocalOutput>`. In practice, all implementations of `LocalOutput` were just `Arc<Mutex<..>>`. This simplifies some logic and removes all custom `Sink` implementations such as `library/test/src/helpers/sink.rs`. Also removes a layer of indirection, as the outermost `Box` is now gone. It also means that locking now happens per `write_fmt`, not per individual `write` within. (So `"{} {}\n"` now results in one `lock()`, not four or more.) 2. Since in all cases the `dyn Write`s were just `Vec<u8>`s, replace the type with `Arc<Mutex<Vec<u8>>>`. This simplifies things more, as error handling and flushing can be removed now. This also removes the hack needed in the default panic handler to make this work with `::realstd`, as (unlike `Write`) `Vec<u8>` is from `alloc`, not `std`. 3. Replace the `RefCell`s by regular `Cell`s. The `RefCell`s were mostly used as `mem::replace(&mut *cell.borrow_mut(), something)`, which is just `Cell::replace`. This removes an unecessary bookkeeping and makes the code a bit easier to read. 4. Merge `set_panic` and `set_print` into a single `set_output_capture`. Neither the test crate nor rustc (the only users of this feature) have a use for using these separately. Merging them simplifies things even more. This uses a new function name and feature name, to make it clearer this is internal and not supposed to be used by other crates. Might be easier to review per commit.
2020-11-16Update E0744 about control flow in `const` contexts to reflect the current ↵James-8/+11
status of `const fn`. This is a squash of these commits: - Update E0744 about control flow in `const` contexts to reflect current status of `const fn`. - E0744 isn't just about `for` loops or control flow - Fix formatting on E0744 cause my editor decided to not copy it well - Improve wording - Fix a markdown formatting error - Fix E0744's description as I interpreted some code wrong - Fix a minor wording issue again - Add a few more links to blocking issues - Improve links to tracking issues
2020-11-16improve error message for const ty param mismatchBastian Kauschke-80/+75
2020-11-16instrument `QueryNormalizer::fold_ty`Bastian Kauschke-0/+1
2020-11-16Apply suggestions from code reviewNadrieril-2/+2
Co-authored-by: varkor <github@varkor.com>
2020-11-15Ignore doctest for capture analysis examplesAman Arora-9/+12
2020-11-15Fix case when ExprUseVisitor is called after typeck writebackAman Arora-0/+49
Clippy uses `ExprUseVisitor` and atleast in some cases it runs after writeback. We currently don't writeback the min_capture results of closure capture analysis since no place within the compiler itself uses it. In the short term to fix clippy we add a fallback when walking captures of a closure to check if closure_capture analysis has any entries in it. Writeback for closure_min_captures will be implemented in rust-lang/project-rfc-2229#18
2020-11-15Turn top-level comments into module docs in MIR visitorCamelid-62/+62
2020-11-15Remove dead `TypeFoldable::visit_tys_shallow` methodLeSeulArtichaut-14/+0
2020-11-15Rollup merge of #79058 - dtolnay:likelymacro, r=Mark-SimulacrumJonas Schievink-6/+6
Move likely/unlikely argument outside of invisible unsafe block The previous `likely!`/`unlikely!` macros were unsound because it permits the caller's expr to contain arbitrary unsafe code. ```rust pub fn huh() -> bool { likely!(std::ptr::read(&() as *const () as *const bool)) } ``` **Before:** compiles cleanly. **After:** ```console error[E0133]: call to unsafe function is unsafe and requires unsafe function or block | 70 | likely!(std::ptr::read(&() as *const () as *const bool)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior ```
2020-11-15Rollup merge of #79036 - cjgillot:steal, r=oli-obkJonas Schievink-20/+18
Move Steal to rustc_data_structures.
2020-11-15Rollup merge of #79034 - petrochenkov:mrscopes3, r=eddybJonas Schievink-36/+21
rustc_resolve: Make `macro_rules` scope chain compression lazy As suggested in https://github.com/rust-lang/rust/pull/78826#issuecomment-723420664.
2020-11-15Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-schievinkJonas Schievink-0/+7
Validate that locals have a corresponding `LocalDecl` Fixes #73356.
2020-11-15Rollup merge of #79019 - lcnr:generic-arg-validation, r=petrochenkovJonas Schievink-178/+292
astconv: extract closures into a separate trait Am currently looking into completely removing `check_generic_arg_count` and `create_substs_for_generic_args` was somewhat difficult to understand for me so I moved these closures into a trait. This should not have changed the behavior of any of these methods
2020-11-15Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkovJonas Schievink-2/+32
Make `_` an expression, to discard values in destructuring assignments This is the third and final step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the third and final part of #71156, which was split up to allow for easier review. With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance, ```rust (a, _) = (1, 2) ``` will simply assign 1 to `a` and discard the 2. Note that for consistency, ``` _ = foo ``` is also allowed and equivalent to just `foo`. Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating. r? ````@petrochenkov````
2020-11-15Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwcoJonas Schievink-16/+7
cleanup: Remove `ParseSess::injected_crate_name` Its only remaining use is in pretty-printing where the necessary information can be easily re-computed.
2020-11-15Rollup merge of #77802 - jyn514:bootstrap-specific, r=nikomatsakisJonas Schievink-58/+102
Allow making `RUSTC_BOOTSTRAP` conditional on the crate name Motivation: This came up in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Require.20users.20to.20confirm.20they.20know.20RUSTC_.E2.80.A6.20compiler-team.23350/near/208403962) for https://github.com/rust-lang/compiler-team/issues/350. See also https://github.com/rust-lang/cargo/pull/6608#issuecomment-458546258; this implements https://github.com/rust-lang/cargo/issues/6627. The goal is for this to eventually allow prohibiting setting `RUSTC_BOOTSTRAP` in build.rs (https://github.com/rust-lang/cargo/issues/7088). ## User-facing changes - `RUSTC_BOOTSTRAP=1` still works; there is no current plan to remove this. - Things like `RUSTC_BOOTSTRAP=0` no longer activate nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway. - `RUSTC_BOOTSTRAP=x` will enable nightly features only for crate `x`. - `RUSTC_BOOTSTRAP=x,y` will enable nightly features only for crates `x` and `y`. ## Implementation changes The main change is that `UnstableOptions::from_environment` now requires an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how. Other major changes: - Added `Session::is_nightly_build()`, which uses the `crate_name` of the session - Added `nightly_options::match_is_nightly_build`, a convenience method for looking up `--crate-name` from CLI arguments. `Session::is_nightly_build()`should be preferred where possible, since it will take into account `#![crate_name]` (I think). - Added `unstable_features` to `rustdoc::RenderOptions` I'm not sure whether this counts as T-compiler or T-lang; _technically_ RUSTC_BOOTSTRAP is an implementation detail, but it's been used so much it seems like this counts as a language change too. r? `@joshtriplett` cc `@Mark-Simulacrum` `@hsivonen`
2020-11-15Re-enable LLVM 9 target features with LLVM 9 being the minimum nowDevJPM-2/+2
With #78848 merged, the minimum supported LLVM version is now 9 which means we can actually use the target features introduced in LLVM 9
2020-11-15Rollup merge of #79013 - jryans:cleanup-use-once-pretty-comment, ↵Dylan DPC-3/+0
r=Mark-Simulacrum Clean up outdated `use_once_payload` pretty printer comment While reading some parts of the pretty printer code, I noticed this old comment which seemed out of place. The `use_once_payload` this outdated comment mentions was removed in 2017 in 40f03a1e0d6702add1922f82d716d5b2c23a59f0, so this completes the work by removing the comment.
2020-11-15Rollup merge of #78993 - petrochenkov:specdash, r=oli-obkDylan DPC-8/+8
rustc_target: Fix dash vs underscore mismatches in option names Fixes https://github.com/rust-lang/rust/issues/78981 (regression from https://github.com/rust-lang/rust/pull/78875, the old option names used dashes)
2020-11-15Rollup merge of #78980 - thiolliere:gui-fix-qpath, r=estebankDylan DPC-5/+6
Fix rustc_ast_pretty print_qpath resulting in invalid macro input related https://github.com/rust-lang/rust/issues/76874 (third case) ### Issue: The input for a procedural macro is incorrect, for the rust code: ```rust mod m { pub trait Tr { type Ts: super::Tu; } } trait Tu { fn dummy() { } } #[may_proc_macro] fn foo() { <T as m::Tr>::Ts::dummy(); } ``` the macro will get the input: ```rust fn foo() { <T as m::Tr>::dummy(); } ``` Thus `Ts` has disappeared. ### Fix: This is due to invalid pretty print of qpath. This PR fix it.
2020-11-15Rollup merge of #78969 - tmiasko:normalize, r=davidtwcoDylan DPC-8/+7
Normalize function type during validation During inlining, the callee body is normalized and has types revealed, but some of locals corresponding to the arguments might come from the caller body which is not. As a result the caller body does not pass validation without additional normalization. Closes #78442.
2020-11-15Rollup merge of #78966 - tmiasko:inline-never, r=oli-obkDylan DPC-22/+19
Never inline C variadics, cold functions, functions with incompatible attributes ... ... and fix generator inlining. Closes #67863. Closes #78859.
2020-11-15Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tmandryDylan DPC-25/+780
Added some unit tests as requested As discussed in PR #78267, for example: * https://github.com/rust-lang/rust/pull/78267#discussion_r515404722 * https://github.com/rust-lang/rust/pull/78267#discussion_r515405958 r? ```````@tmandry``````` FYI: ```````@wesleywiser``````` This is pretty much self contained, but depending on feedback and timing, I may have a chance to add a few more unit tests requested against `counters.rs`. I'm looking at those now.