about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-04-12Turn old edition lints (anonymous-parameters, keyword-idents) into ↵Manish Goregaokar-4/+7
warn-by-default on 2015
2021-04-12Auto merge of #84068 - Amanieu:fix_lint, r=lcnrbors-0/+1
Add `bad_asm_style` to HardwiredLints This was missed when the lint was added, which prevents the lint from being ignored with `#[allow]`.
2021-04-12Rollup merge of #84014 - estebank:cool-bears-hot-tip, r=varkorDylan DPC-86/+103
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-12Rollup merge of #83669 - kwj2104:issue-81508-fix, r=varkorDylan DPC-3/+64
Issue 81508 fix Fix #81508 **Problem**: When variable name is used incorrectly as path, error and warning point to undeclared/unused name, when in fact the name is used, just incorrectly (should be used as a variable, not part of a path). **Summary for fix**: When path resolution errs, diagnostics checks for variables in ```ValueNS``` that have the same name (e.g., variable rather than path named Foo), and adds additional suggestion that user may actually intend to use the variable name rather than a path. The fix does not suppress or otherwise change the *warning* that results. I did not find a straightforward way in the code to modify this, but would love to make changes here as well with any guidance.
2021-04-11Allow using `-C force-unwind-tables=no` when `panic=unwind`hyd-dev-16/+9
2021-04-11Implement token-based handling of attributes during expansionAaron Hill-474/+1316
This PR modifies the macro expansion infrastructure to handle attributes in a fully token-based manner. As a result: * Derives macros no longer lose spans when their input is modified by eager cfg-expansion. This is accomplished by performing eager cfg-expansion on the token stream that we pass to the derive proc-macro * Inner attributes now preserve spans in all cases, including when we have multiple inner attributes in a row. This is accomplished through the following changes: * New structs `AttrAnnotatedTokenStream` and `AttrAnnotatedTokenTree` are introduced. These are very similar to a normal `TokenTree`, but they also track the position of attributes and attribute targets within the stream. They are built when we collect tokens during parsing. An `AttrAnnotatedTokenStream` is converted to a regular `TokenStream` when we invoke a macro. * Token capturing and `LazyTokenStream` are modified to work with `AttrAnnotatedTokenStream`. A new `ReplaceRange` type is introduced, which is created during the parsing of a nested AST node to make the 'outer' AST node aware of the attributes and attribute target stored deeper in the token stream. * When we need to perform eager cfg-expansion (either due to `#[derive]` or `#[cfg_eval]`), we tokenize and reparse our target, capturing additional information about the locations of `#[cfg]` and `#[cfg_attr]` attributes at any depth within the target. This is a performance optimization, allowing us to perform less work in the typical case where captured tokens never have eager cfg-expansion run.
2021-04-10Auto merge of #84023 - Aaron1011:derive-invoc-order, r=petrochenkovbors-3/+9
Expand derive invocations in left-to-right order While derives were being collected in left-to-order order, the corresponding `Invocation`s were being pushed in the wrong order.
2021-04-10Expand derive invocations in left-to-right orderAaron Hill-3/+9
While derives were being collected in left-to-order order, the corresponding `Invocation`s were being pushed in the wrong order.
2021-04-10Add `bad_asm_style` to HardwiredLintsAmanieu d'Antras-0/+1
2021-04-10Don't tell users to use a nightly flag on the stable channelKornel-8/+11
Hint upgrading to a newer Rust version instead
2021-04-10Auto merge of #84024 - estebank:unclosed-brace-use, r=jackh726bors-1/+3
Avoid `;` -> `,` recovery and unclosed `}` recovery from being too verbose Those two recovery attempts have a very bad interaction that causes too unnecessary output. Add a simple gate to avoid interpreting a `;` as a `,` when there are unclosed braces. Fix #83498.
2021-04-09Auto merge of #84004 - mattico:print-target-features-improvements, ↵bors-25/+91
r=petrochenkov Categorize and explain target features support There are 3 different uses of the `-C target-feature` args passed to rustc: 1. All of the features are passed to LLVM, which uses them to configure code-generation. This is sort-of stabilized since 1.0 though LLVM does change/add/remove target features regularly. 2. Target features which are in [the compiler's allowlist](https://github.com/rust-lang/rust/blob/69e1d22ddbc67b25141a735a22a8895a678b32ca/compiler/rustc_codegen_ssa/src/target_features.rs#L12-L34) can be used in `cfg!(target_feature)` etc. These may have different names than in LLVM and are renamed before passing them to LLVM. 3. Target features which are in the allowlist and which are stabilized or feature-gate-enabled can be used in `#[target_feature]`. It can be confusing that `rustc --print target-features` just prints out the LLVM features without separating out the rustc features or even mentioning that the dichotomy exists. This improves the situation by separating out the rustc and LLVM target features and adding a brief explanation about the difference. Abbreviated Example Output: ``` $ rustc --print target-features Features supported by rustc for this target: adx - Support ADX instructions. aes - Enable AES instructions. ... xsaves - Support xsaves instructions. crt-static - Enables libraries with C Run-time Libraries(CRT) to be statically linked. Code-generation features supported by LLVM for this target: 16bit-mode - 16-bit mode (i8086). 32bit-mode - 32-bit mode (80386). ... x87 - Enable X87 float instructions. xop - Enable XOP instructions. Use +feature to enable a feature, or -feature to disable it. For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2 Code-generation features cannot be used in cfg or #[target_feature], and may be renamed or removed in a future version of LLVM or rustc. ``` Motivated by #83975. CC https://github.com/rust-lang/rust/issues/49653
2021-04-09Avoid `;` -> `,` recovery and unclosed `}` recovery from being too verboseEsteban Küber-1/+3
Those two recovery attempts have a very bad interaction that causes too unnecessary output. Add a simple gate to avoid interpreting a `;` as a `,` when there are unclosed braces.
2021-04-09Categorize and explain target features supportMatt Ickstadt-25/+91
2021-04-09Auto merge of #83956 - estebank:issue-83892, r=varkorbors-9/+6
Use a more appropriate span for `;` suggestion Fix #83892.
2021-04-09Auto merge of #83870 - jackh726:binder-refactor-fix, r=nikomatsakisbors-86/+223
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 #83941 - wesleywiser:win_dbginfo_closures, r=nagisabors-15/+51
Improve debuginfo for closures and async functions on Windows MSVC The issue was that the resulting debuginfo was too complex for LLVM to translate into CodeView records correctly. As a result, it simply ignored the debuginfo which meant Windows debuggers could not display any closed over variables when stepping inside a closure or async fn. This fixes that by creating additional allocas on the stack so that the resulting debuginfo is simple (just `*my_variable.dbg.spill`) and LLVM can generate the correct CV records. I also updated some of our existing tests to run in CDB to cover this case. Before (closure): ![image](https://user-images.githubusercontent.com/831192/113756857-e6dc4200-96df-11eb-8d6d-b7ed7a84aad5.png) After (closure): ![image](https://user-images.githubusercontent.com/831192/113757067-2e62ce00-96e0-11eb-89f7-7dc8ab89b1b8.png) Before (async): ![image](https://user-images.githubusercontent.com/831192/114077916-4e2bfa80-9876-11eb-9f15-e302d1faa652.png) After (async): ![image](https://user-images.githubusercontent.com/831192/114077677-0d33e600-9876-11eb-8ce3-cac20a9ea94a.png) Fixes #83709
2021-04-08Provide verbose suggestion for new output typeEsteban Küber-9/+7
2021-04-08Suggest return typeEsteban Küber-1/+27
2021-04-08Suggest changing impl parameter types to match traitEsteban Küber-7/+43
This is particularly useful for cases where arbitrary self types are used, like in custom `Future`s.
2021-04-08Auto merge of #84008 - Dylan-DPC:rollup-invxvg8, r=Dylan-DPCbors-30/+31
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-27/+27
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-08Rollup merge of #81764 - jyn514:lint-links, r=GuillaumeGomezDylan DPC-3/+4
Stabilize `rustdoc::bare_urls` lint Closes https://github.com/rust-lang/rust/issues/77501. Closes https://github.com/rust-lang/rust/issues/83598.
2021-04-08Fix closed over variables not available in debuginfo for Windows MSVCWesley Wiser-15/+51
The issue was that the resulting debuginfo was too complex for LLVM to translate into CodeView records correctly. As a result, it simply ignored the debuginfo which meant Windows debuggers could not display any closed over variables when stepping inside a closure. This fixes that by spilling additional variables to the stack so that the resulting debuginfo is simple (just `*my_variable.dbg.spill`) and LLVM can generate the correct CV records.
2021-04-08Use more accurate spans for trait/impl method arg divergenceEsteban Küber-80/+37
2021-04-08Fix outdated crate names in compiler docspierwill-27/+27
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-119/+121
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-08add commentsNiko Matsakis-1/+23
2021-04-08Auto merge of #83981 - nagisa:nagisa/revert-cfg-wasm, r=Mark-Simulacrumbors-4/+0
Remove the insta-stable `cfg(wasm)` The addition of `cfg(wasm)` was an oversight on my end that turns out to have a number of downsides: * It was introduced as an insta-stable addition, forgoing the usual staging mechanism we use for potentially far-reaching changes; * It is a breaking change for people who are using `--cfg wasm` either directly or via cargo for other purposes; * It is not entirely clear if a bare `wasm` cfg is a right option or whether `wasm` family of targets are special enough to warrant special-casing these targets specifically. As for the last point, there appears to be a fair amount of support for reducing the boilerplate in specifying architectures from the same family, while ignoring their pointer width. The suggested way forward would be to propose such a change as a separate RFC as it is potentially a quite contentious addition. cc #83879 `@devsnek`
2021-04-08Auto merge of #82958 - camelid:res-docs, r=petrochenkovbors-13/+142
Document `Res` and its friends I noticed [this Zulip conversation][z] and thought it would be a good idea to document `Res` and the other types near it. [z]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.2382516.20-.20Add.20inherent.20associated.20types/near/227914819
2021-04-07Document `Res` and its friendsCamelid-13/+142
2021-04-08Rollup merge of #83974 - pierwill:fix-callbacks-names, r=jyn514Dylan DPC-7/+7
Fix outdated crate names in `rustc_interface::callbacks`
2021-04-08Rollup merge of #83965 - rust-lang:debug-intravisit-fnkind, r=lqdDylan DPC-1/+1
Add Debug implementation for hir::intravisit::FnKind
2021-04-08Rollup merge of #83952 - estebank:issue-83943, r=petrochenkovDylan DPC-0/+1
Account for `ExprKind::Block` when suggesting .into() and deref Fix #83943.
2021-04-08Rollup merge of #83689 - estebank:cool-bears-hot-tip, r=davidtwcoDylan DPC-66/+140
Add more info for common trait resolution and async/await errors * Suggest `Pin::new`/`Box::new`/`Arc::new`/`Box::pin` in more cases * Point at `impl` and type defs introducing requirements on E0277
2021-04-07Remove the insta-stable `cfg(wasm)`Simonas Kazlauskas-4/+0
The addition of `cfg(wasm)` was an oversight on my end that has a number of downsides: * It was introduced as an insta-stable addition, forgoing the usual staging mechanism we use for potentially far-reaching changes; * It is a breaking change for people who are using `--cfg wasm` either directly or via cargo for other purposes; * It is not entirely clear if a bare `wasm` cfg is a right option or whether `wasm` family of targets are special enough to warrant special-casing these targets specifically. As for the last point, there appears to be a fair amount of support for reducing the boilerplate in specifying architectures from the same family, while ignoring their pointer width. The suggested way forward would be to propose such a change as a separate RFC as it is potentially a quite contentious addition.
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-07Fix outdated crate names in `rustc_interface::callbacks`pierwill-7/+7
2021-04-07Added additional comments and minor editsK-44/+62
2021-04-07Auto merge of #83964 - Dylan-DPC:rollup-9kinaiv, r=Dylan-DPCbors-159/+193
Rollup of 8 pull requests Successful merges: - #83476 (Add strong_count mutation methods to Rc) - #83634 (Do not emit the advanced diagnostics on macros) - #83816 (Trigger `unused_doc_comments` on macros at once) - #83916 (Use AnonConst for asm! constants) - #83935 (forbid `impl Trait` in generic param defaults) - #83936 (Disable using non-ascii identifiers in extern blocks.) - #83945 (Add suggestion to reborrow mutable references when they're moved in a for loop) - #83954 (Do not ICE when closure is involved in Trait Alias Impl Trait) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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-07Auto merge of #83932 - lcnr:probe-perf, r=estebankbors-2/+4
use a `SmallVec` in `impl_or_trait_item` #83293 showed that this is fairly hot, slightly improves max-rss and cpu cycles, does not noticeably improve instruction counts
2021-04-07Add Debug implementation for hir::intravisit::FnKindGuillaume Gomez-1/+1
2021-04-07Rollup merge of #83954 - estebank:issue-83613, r=varkorDylan DPC-3/+8
Do not ICE when closure is involved in Trait Alias Impl Trait Fix #83613.
2021-04-07Rollup merge of #83945 - SkiFire13:fix-83924, r=estebankDylan DPC-1/+18
Add suggestion to reborrow mutable references when they're moved in a for loop Address #83924
2021-04-07Rollup merge of #83936 - crlf0710:disallow_extern_block_non_ascii, r=ManishearthDylan DPC-1/+23
Disable using non-ascii identifiers in extern blocks. Fixes #83923.
2021-04-07Rollup merge of #83935 - SNCPlay42:param-default-impl-trait, r=varkorDylan DPC-7/+1
forbid `impl Trait` in generic param defaults Fixes #83929 Forbid using `impl Trait` in the default types of generic parameters, e.g. `struct Foo<T = impl Trait>`. I assume this was never supposed to be allowed - it seems no UI test used it. Note that using `impl Trait` in this position did not hit a feature gate error; however, this *shouldn't* be a breaking change as any attempt to use it should have hit the ICE in #83929 and/or failed to provide a defining use of the `impl Trait`.
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-143/+127
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-07Rollup merge of #83816 - JohnTitor:unused-doc-comments-on-macros, r=varkorDylan DPC-3/+13
Trigger `unused_doc_comments` on macros at once Fixes #83768
2021-04-07Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkorDylan DPC-1/+3
Do not emit the advanced diagnostics on macros Fixes #83510