about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-06-08Stabilize `const_intrinsic_copy`Yuki Okushi-7/+7
2022-06-08Auto merge of #97860 - Dylan-DPC:rollup-t3vxos8, r=Dylan-DPCbors-10/+193
Rollup of 5 pull requests Successful merges: - #97595 (Remove unwrap from get_vtable) - #97597 (Preserve unused pointer to address casts) - #97819 (Recover `import` instead of `use` in item) - #97823 (Recover missing comma after match arm) - #97851 (Use repr(C) when depending on struct layout in ptr tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-08Rollup merge of #97823 - compiler-errors:missing-comma-match-arm, r=estebankDylan DPC-10/+6
Recover missing comma after match arm If we're missing a comma after a match arm expression, try parsing another pattern and a following `=>`. If we find both of those, then recover by suggesting to insert a `,`. Fixes #80112
2022-06-08Rollup merge of #97819 - compiler-errors:use-import, r=wesleywiserDylan DPC-0/+44
Recover `import` instead of `use` in item When we definitely don't have a macro invocation (i.e. when we don't have `import ::`), then it's more productive to parse `import` as if it was incorrectly mistaken for `use`. Not sure if this needs to be a verbose suggestion, but it renders strangely when it's not verbose: ``` error: expected item, found `import` --> /home/michael/test.rs:1:1 | 1 | import std::{io::{self, Write}, rc::Rc}; | ^^^^^^ help: items are imported using the `use` keyword: `use` ``` Happy to change it to `span_suggestion` instead of `span_suggestion_verbose` though. Fixes #97788
2022-06-08Rollup merge of #97597 - tmiasko:simplify-locals-side-effects, ↵Dylan DPC-0/+28
r=RalfJung,JakobDegen Preserve unused pointer to address casts Fixes #97421. cc `@RalfJung`
2022-06-08Rollup merge of #97595 - ouz-a:issue-97381, r=compiler-errorsDylan DPC-0/+115
Remove unwrap from get_vtable This avoids ICE on issue #97381 I think the bug is a bit deeper though, it compiles fine when `v` is `&v` which makes me think `Deref` is causing some issue with borrowck but it's fine I guess since this thing crashes since `nightly-2020-09-17` 😅
2022-06-08Auto merge of #97447 - nnethercote:improve-folding, r=jackh726bors-2/+2
Folding revamp r? `@ghost`
2022-06-07recover `import` instead of `use` in itemMichael Goulet-0/+44
2022-06-08Folding revamp.Nicholas Nethercote-2/+2
This commit makes type folding more like the way chalk does it. Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods. - `fold_with` is the standard entry point, and defaults to calling `super_fold_with`. - `super_fold_with` does the actual work of traversing a type. - For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead calls into a `TypeFolder`, which can then call back into `super_fold_with`. With the new approach, `TypeFoldable` has `fold_with` and `TypeSuperFoldable` has `super_fold_with`. - `fold_with` is still the standard entry point, *and* it does the actual work of traversing a type, for all types except types of interest. - `super_fold_with` is only implemented for the types of interest. Benefits of the new model. - I find it easier to understand. The distinction between types of interest and other types is clearer, and `super_fold_with` doesn't exist for most types. - With the current model is easy to get confused and implement a `super_fold_with` method that should be left defaulted. (Some of the precursor commits fixed such cases.) - With the current model it's easy to call `super_fold_with` within `TypeFolder` impls where `fold_with` should be called. The new approach makes this mistake impossible, and this commit fixes a number of such cases. - It's potentially faster, because it avoids the `fold_with` -> `super_fold_with` call in all cases except types of interest. A lot of the time the compile would inline those away, but not necessarily always.
2022-06-07Rollup merge of #97845 - estebank:spancito, r=compiler-errorsMatthias Krüger-2/+2
Use more targeted suggestion when confusing i8 with std::i8 r? `@compiler-errors`
2022-06-07Rollup merge of #97829 - JohnTitor:issue-95307, r=compiler-errorsMatthias Krüger-0/+43
Add regresion test for #95307 Closes #95307 r? `@compiler-errors`
2022-06-07Use more targeted suggestion when confusing i8 with std::i8Esteban Küber-2/+2
2022-06-07Preserve unused pointer to address castsTomasz Miąsko-0/+28
2022-06-07Rollup merge of #97826 - GuillaumeGomez:rustdoc-gui-tests-info, r=Dylan-DPCDylan DPC-5/+16
Add more information for rustdoc-gui tests It was missing `--no-sandbox` in the `--help` message and the README was a bit outdated. cc `@jsha` (I recall you asking some questions about passing arguments to the rustdoc gui tester so here it). r? `@notriddle`
2022-06-07Rollup merge of #97817 - lnicola:rust-analyzer-2022-06-07, r=lnicolaDylan DPC-23/+8
:arrow_up: rust-analyzer r? ``@ghost``
2022-06-07Rollup merge of #97325 - tmiasko:capture-enum-field, r=arora-amanDylan DPC-0/+27
Fix precise field capture of univariant enums When constructing a MIR from a THIR field expression, introduce an additional downcast projection before accessing a field of an enum. When rebasing a place builder on top of a captured place, account for the fact that a single HIR enum field projection corresponds to two MIR projection elements: a downcast element and a field element. Fixes #95271. Fixes #96299. Fixes #96512. Fixes #97378. r? ``@nikomatsakis`` ``@arora-aman``
2022-06-08Add regresion test for #95307Yuki Okushi-0/+43
2022-06-07Auto merge of #97825 - Dylan-DPC:rollup-ya51k1k, r=Dylan-DPCbors-0/+94
Rollup of 5 pull requests Successful merges: - #97058 (Various refactors to the incr comp workproduct handling) - #97301 (Allow unstable items to be re-exported unstably without requiring the feature be enabled) - #97738 (Fix ICEs from zsts within unsized types with non-zero offsets) - #97771 (Remove SIGIO reference on Haiku) - #97808 (Add some unstable target features for the wasm target codegen) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-07Update rustdoc-gui READMEGuillaume Gomez-5/+15
2022-06-07Update help message for rustdoc-gui runnerGuillaume Gomez-0/+1
2022-06-07Rollup merge of #97738 - Kixiron:zst-panic, r=eddybDylan DPC-0/+28
Fix ICEs from zsts within unsized types with non-zero offsets - Fixes #97732 - Fixes ICEs while compiling `alloc` with `-Z randomize-layout` r? ``@eddyb``
2022-06-07Rollup merge of #97301 - semicoleon:unstable-reexport, r=petrochenkovDylan DPC-0/+66
Allow unstable items to be re-exported unstably without requiring the feature be enabled Closes #94972 The diagnostic may need some work still, and I haven't added a test yet
2022-06-07Recover missing comma after match armMichael Goulet-10/+6
2022-06-07Auto merge of #97512 - scottmcm:add-coldcc, r=nagisa,lcnrbors-2/+107
Add support for emitting functions with `coldcc` to LLVM The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.
2022-06-07:arrow_up: rust-analyzerLaurențiu Nicola-23/+8
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-11971/+1742
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-07Auto merge of #97801 - RalfJung:miri, r=RalfJungbors-10/+8
update Miri Fixes https://github.com/rust-lang/rust/issues/97745 r? `@ghost` Cc `@rust-lang/miri` Cc `@InfRandomness`
2022-06-07Rollup merge of #97794 - eltociear:patch-13, r=matthiaskrgrMatthias Krüger-1/+1
Fix typo in redundant_pattern_match.rs alway -> always
2022-06-07Rollup merge of #97792 - GuillaumeGomez:eslint-checks, r=Dylan-DPCMatthias Krüger-1/+7
More eslint checks Here is the list of newly added eslint checks: * [no-confusing-arrow](https://eslint.org/docs/rules/no-confusing-arrow) * [no-div-regex](https://eslint.org/docs/rules/no-div-regex) * [no-floating-decimal](https://eslint.org/docs/rules/no-floating-decimal) * [no-implicit-globals](https://eslint.org/docs/rules/no-implicit-globals) * [no-implied-eval](https://eslint.org/docs/rules/no-implied-eval) * [no-label-var](https://eslint.org/docs/rules/no-label-var) Since you already reviewed the previous ones: r? `@Dylan-DPC`
2022-06-06Auto merge of #97730 - flip1995:clippyup, r=Manishearthbors-2622/+7458
Update Clippy r? `@Manishearth` This includes a bit bigger `Cargo.lock` update.
2022-06-06update MiriRalf Jung-10/+8
2022-06-06Auto merge of #97795 - Dylan-DPC:rollup-dxilagr, r=Dylan-DPCbors-11/+167
Rollup of 5 pull requests Successful merges: - #97312 (Compute lifetimes in scope at diagnostic time) - #97495 (Add E0788 for improper #[no_coverage] usage) - #97579 (Avoid creating `SmallVec`s in `global_llvm_features`) - #97767 (interpret: do not claim UB until we looked more into variadic functions) - #97787 (E0432: rust 2018 -> rust 2018 or later in --explain message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-06Update src/test/ui/unsized/issue-97732.rsChase Wilson-3/+8
Co-authored-by: Eduard-Mihai Burtescu <edy.burt@gmail.com>
2022-06-06Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obkbors-357/+390
interpret: better control over whether we read data with provenance The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen. This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`). The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!
2022-06-06Rollup merge of #97495 - clarfonthey:e0788-no-coverage, r=nagisaDylan DPC-0/+156
Add E0788 for improper #[no_coverage] usage Essentially, this adds proper checking for the attribute (tracking issue #84605) and throws errors when it's put in obviously-wrong places, like on struct or const definitions. Most of the code is taken directly from the checks for the `#[inline]` attribute, since it's very similar. Right now, the code only checks at the function level, but it seems reasonable to allow adding `#[no_coverage]` to individual blocks or expressions, so, for now those just throw `unused_attributes` warnings. Similarly, since there was a lot of desire to eventually allow recursive definitions as well on modules and impl blocks, these also throw `unused_attributes` instead of an error. I'm not sure if anything has to be done since this error is technically for an unstable feature, but since an error for using unstable features will show up anyway, I think it's okay. This is the first big piece needed for stabilising this attribute, although I personally would like to explore renaming it to `#[coverage(never)]` on a separate PR, which I will offer soon. There's a lot of discussion still to be had about that, which is why it will be kept separate. I don't think much is needed besides adding this simple check and a UI test, but let me know if there's something else that should be added to make this happen.
2022-06-06Rollup merge of #97312 - cjgillot:no-path-in-scope, r=compiler-errorsDylan DPC-11/+11
Compute lifetimes in scope at diagnostic time The set of available lifetimes is currently computed during lifetime resolution on HIR. It is only used for one diagnostic. In this PR, HIR lifetime resolution just reports whether elided lifetimes are well-defined at the place of use. The diagnostic code is responsible for building a list of lifetime names if elision is not allowed. This will allow to remove lifetime resolution on HIR eventually.
2022-06-06Fix typo in redundant_pattern_match.rsIkko Ashimine-1/+1
alway -> always
2022-06-06Add "no-label-var" eslint checkGuillaume Gomez-0/+1
2022-06-06Add "no-implied-eval" eslint checkGuillaume Gomez-0/+1
2022-06-06Add "no-implicit-globals" eslint checkGuillaume Gomez-0/+1
2022-06-06Add "no-floating-decimal" eslint checkGuillaume Gomez-0/+1
2022-06-06Add "no-div-regex" eslint checkGuillaume Gomez-0/+1
2022-06-06Add "no-confusing-arrow" eslint checkGuillaume Gomez-1/+2
2022-06-06Auto merge of #97086 - 5225225:link-section-is-unsafe, r=davidtwcobors-16/+35
Report unsafe for overriding link sections I'm not too sure about the lint wording here, but I couldn't think of anything better.
2022-06-06Add winnt feature to winapi in rustc-workspace-hackPhilipp Krones-0/+1
2022-06-06Auto merge of #97783 - matthiaskrgr:rollup-14t9htt, r=matthiaskrgrbors-33/+271
Rollup of 7 pull requests Successful merges: - #90905 (Add empty impl blocks if they have documentation) - #97683 (Fail gracefully when encountering an HRTB in APIT. ) - #97721 (Do `suggest_await_before_try` with infer variables in self, and clean up binders) - #97752 (typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now) - #97759 (Suggest adding `{}` for `'label: non_block_expr`) - #97764 (use strict provenance APIs) - #97765 (Restore a test that was intended to test `as` cast to ptr) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-06Rollup merge of #97765 - RalfJung:restoration, r=Mark-SimulacrumMatthias Krüger-1/+2
Restore a test that was intended to test `as` cast to ptr This test was changed in https://github.com/rust-lang/rust/pull/61864, but the original bug https://github.com/rust-lang/rust/issues/46365 was about casts so I doubt the changed test still even tests what this was intended to test. Let's restore the original test.
2022-06-06Rollup merge of #97759 - WaffleLapkin:recover_label_expr, r=compiler-errorsMatthias Krüger-13/+126
Suggest adding `{}` for `'label: non_block_expr` Adds suggestions like this: ```text help: consider enclosing expression in a block | 3 | 'l {0}; | + + ``` inspired by https://github.com/rust-lang/rust/issues/48594#issuecomment-1146744400 r? ``@compiler-errors``
2022-06-06Rollup merge of #97721 - compiler-errors:issue-97704, r=jackh726Matthias Krüger-0/+53
Do `suggest_await_before_try` with infer variables in self, and clean up binders Fixes #97704 Also cleans up binders in this fn, since everything is a `Poly*` and we really shouldn't have stray escaping late-bound regions everywhere. That's why the function changed so much. This isn't necessary, so I can revert if necessary.
2022-06-06Rollup merge of #97683 - cjgillot:no-apit-hrtb, r=nagisaMatthias Krüger-0/+22
Fail gracefully when encountering an HRTB in APIT. Fixes https://github.com/rust-lang/rust/issues/96954 ~The first commit will be merged as part of https://github.com/rust-lang/rust/pull/97415~