about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-03-03Rollup merge of #94563 - ↵Matthias Krüger-1/+1
TaKO8Ki:remove-unnecessary-patten-for-ignoring-remaining-parts, r=Dylan-DPC Remove a unnecessary `..` pattern
2022-03-03Rollup merge of #94555 - cuishuang:master, r=oli-obkMatthias Krüger-15/+15
all: fix some typos Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkovMatthias Krüger-2/+2
Fix invalid lint_node_id being put on a removed stmt This pull-request remove a invalid `assign_id!` being put on an stmt node. The problem is that this node is being removed away by a cfg making it unreachable when triggering a buffered lint. The comment in the other match arm already tell to not assign a id because it could have a `#[cfg()]` so this is just respecting the comment. Fixes https://github.com/rust-lang/rust/issues/94523 r? ```````@petrochenkov```````
2022-03-03Rollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkovMatthias Krüger-101/+115
`parse_tt` cleanups I've been looking closely at this code, and saw some opportunities to improve its readability. r? ```````@petrochenkov```````
2022-03-03Rollup merge of #94057 - lcnr:simplify_type-uwu, r=nikomatsakisMatthias Krüger-60/+66
improve comments for `simplify_type` Should now correctly describe what's going on. Experimented with checking the invariant for projections but that ended up requiring fairly involved changes. I assume that it is not possible to get unsoundness here, at least for now and I can pretty much guarantee that it's impossible to trigger it by accident. r? `````@nikomatsakis````` cc #92721
2022-03-04remove a unnecessary `..` patternTakayuki Maeda-1/+1
2022-03-03Auto merge of #84944 - lcnr:obligation-dedup, r=jackh726bors-22/+0
remove obligation dedup from `impl_or_trait_obligations` Looking at the examples from #38528 they all seem to compile fine even without this and it seems like this might be unnecessary effort
2022-03-03Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obkbors-17/+30
Miri/CTFE: properly treat overflow in (signed) division/rem as UB To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine. r? `@oli-obk`
2022-03-03all: fix some typoscuishuang-15/+15
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03Fix invalid lint_node_id being put on a removed stmtLoïc BRANSTETT-2/+2
2022-03-03Change `initial_matcher_pos()` into `MatcherPos::new()`.Nicholas Nethercote-29/+29
2022-03-03Use a better return type for `inner_parse_loop`.Nicholas Nethercote-25/+35
Because `inner_parse_loop` has only one way to not succeed, not three.
2022-03-03Introduce `MatcherPosRepetition`.Nicholas Nethercote-23/+27
There are three `Option` fields in `MatcherPos` that are only used in tandem. This commit combines them, making the code slightly easier to read. (It also makes clear that the `sep` field arguably should have been `Option<Option<Token>>`!)
2022-03-03Add a static size assertion for `MatcherPos`.Nicholas Nethercote-0/+4
2022-03-03Improve if/else formatting in macro_parser.rs.Nicholas Nethercote-32/+28
To avoid the strange style where comments force `else` onto its own line. The commit also removes several else-after-return constructs, which can be hard to read.
2022-03-03Rollup merge of #94544 - mark-i-m:macro-comments, r=petrochenkovMatthias Krüger-0/+38
Add some examples to comments in mbe code I found these things non-obvious when re-familiarizing myself with the code. r? `@petrochenkov`
2022-03-03Rollup merge of #94522 - thinety:fix-e0284-message, r=Dylan-DPCMatthias Krüger-2/+0
Remove out-of-context line at end of E0284 message Removed the last line of E0284 message because it was out of context (probably kept by accident when changing whole error message).
2022-03-03Rollup merge of #94484 - c410-f3r:more-let-chains, r=jackh726Matthias Krüger-185/+145
8 - Make more use of `let_chains` Continuation of #94376. cc #53667
2022-03-02add some examples to comments in mbe codemark-0/+38
2022-03-03Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebankDylan DPC-2/+12
Unused doc comments blocks Fixes #77030.
2022-03-03Rollup merge of #94505 - cuviper:mono-item-sort-local, ↵Dylan DPC-5/+4
r=michaelwoerister,davidtwco Restore the local filter on mono item sorting In `CodegenUnit::items_in_deterministic_order`, there's a comment that only local HirIds should be taken into account, but #90408 removed the `as_local` call that sets others to None. Restoring that check fixes the s390x hangs seen in [RHBZ 2058803]. [RHBZ 2058803]: https://bugzilla.redhat.com/show_bug.cgi?id=2058803
2022-03-03Rollup merge of #94433 - Urgau:check-cfg-allowness, r=petrochenkovDylan DPC-26/+60
Improve allowness of the unexpected_cfgs lint This pull-request improve the allowness (`#[allow(...)]`) of the `unexpected_cfgs` lint. Before this PR only crate level `#![allow(unexpected_cfgs)]` worked, now with this PR it also work when put around `cfg!` or if it is in a upper level. Making it work ~for the attributes `cfg`, `cfg_attr`, ...~ for the same level is awkward as the current code is design to give "Some parent node that is close to this macro call" (cf. https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/base/struct.ExpansionData.html) meaning that allow on the same line as an attribute won't work. I'm note even sure if this would be possible. Found while working on https://github.com/rust-lang/rust/pull/94298. r? ````````@petrochenkov````````
2022-03-03Rollup merge of #94375 - WaffleLapkin:copy-suggestion, r=estebankDylan DPC-164/+298
Adt copy suggestions Previously we've only suggested adding `Copy` bounds when the type being moved/copied is a type parameter (generic). With this PR we also suggest adding bounds when a type - Can be copy - All predicates that need to be satisfied for that are based on type params i.e. we will suggest `T: Copy` for `Option<T>`, but won't suggest anything for `Option<String>`. An example: ```rust fn duplicate<T>(t: Option<T>) -> (Option<T>, Option<T>) { (t, t) } ``` New error (current compiler doesn't provide `help`:): ```text error[E0382]: use of moved value: `t` --> t.rs:2:9 | 1 | fn duplicate<T>(t: Option<T>) -> (Option<T>, Option<T>) { | - move occurs because `t` has type `Option<T>`, which does not implement the `Copy` trait 2 | (t, t) | - ^ value used here after move | | | value moved here | help: consider restricting type parameter `T` | 1 | fn duplicate<T: Copy>(t: Option<T>) -> (Option<T>, Option<T>) { | ++++++ ``` Fixes #93623 r? ``````````@estebank`````````` ``````````@rustbot`````````` label +A-diagnostics +A-suggestion-diagnostics +C-enhancement ---- I'm not at all sure if this is the right implementation for this kind of suggestion, but it seems to work :')
2022-03-03Rollup merge of #93072 - ↵Dylan DPC-2/+19
m-ou-se:compatible-variants-suggestion-with-desugaring, r=estebank Compatible variants suggestion with desugaring This fixes #90553 for `for` loops and other desugarings. r? ```@estebank```
2022-03-02Fix unused_doc_comments lint errorsGuillaume Gomez-2/+2
2022-03-028 - Make more use of `let_chains`Caio-185/+145
2022-03-02Fix Ok(()) suggestion when desugaring is involved.Mara Bos-2/+19
2022-03-02Extend unused_doc_comments lint to check on blocksGuillaume Gomez-0/+10
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-546/+567
2022-03-02Remove out-of-context line at end of E0284 messageThiago Trannin-2/+0
2022-03-02Auto merge of #94229 - erikdesjardins:rem2, r=nikicbors-87/+13
Remove LLVM attribute removal This was necessary before, because `declare_raw_fn` would always apply the default optimization attributes to every declared function. Then `attributes::from_fn_attrs` would have to remove the default attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build. (see [`src/test/codegen/optimize-attr-1.rs`](https://github.com/rust-lang/rust/blob/03a8cc7df1d65554a4d40825b0490c93ac0f0236/src/test/codegen/optimize-attr-1.rs#L33)) However, every relevant callsite of `declare_raw_fn` (i.e. where we actually generate code for the function, and not e.g. a call to an intrinsic, where optimization attributes don't [?] matter) calls `from_fn_attrs`, so we can remove the attribute setting from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct attributes all at once. r? `@ghost` (blocked on #94221) `@rustbot` label S-blocked
2022-03-02Auto merge of #94514 - matthiaskrgr:rollup-pdzn82h, r=matthiaskrgrbors-389/+337
Rollup of 9 pull requests Successful merges: - #94464 (Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.) - #94476 (7 - Make more use of `let_chains`) - #94478 (Fix panic when handling intra doc links generated from macro) - #94482 (compiler: fix some typos) - #94490 (Update books) - #94496 (tests: accept llvm intrinsic in align-checking test) - #94498 (9 - Make more use of `let_chains`) - #94503 (Provide C FFI types via core::ffi, not just in std) - #94513 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-02Rollup merge of #94498 - c410-f3r:chega-ja-deu, r=Dylan-DPCMatthias Krüger-218/+176
9 - Make more use of `let_chains` Continuation of #94376. cc #53667
2022-03-02Rollup merge of #94482 - cuishuang:master, r=Dylan-DPCMatthias Krüger-7/+7
compiler: fix some typos
2022-03-02Rollup merge of #94476 - c410-f3r:yet-more-let-chains, r=Dylan-DPCMatthias Krüger-112/+100
7 - Make more use of `let_chains` Continuation of #94376. cc #53667
2022-03-02Rollup merge of #94464 - kckeiks:lifetime-elision-mismatch-hint-for-traits, ↵Matthias Krüger-52/+54
r=estebank Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls. Suggest adding a new lifetime parameter when two elided lifetimes should match up for functions in traits and impls. Issue #94462
2022-03-02Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, ↵bors-91/+186
r=estebank Direct users towards using Rust target feature names in CLI This PR consists of a couple of changes on how we handle target features. In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed). The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery. And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me. Sponsored by: standard.ai
2022-03-01Miri/CTFE: properly treat overflow in (signed) division/rem as UBRalf Jung-17/+30
2022-03-019 - Make more use of `let_chains`Caio-218/+176
Continuation of #94376. cc #53667
2022-03-01Restore the local filter on mono item sortingJosh Stone-5/+4
In `CodegenUnit::items_in_deterministic_order`, there's a comment that only local HirIds should be taken into account, but #90408 removed the `as_local` call that sets others to None. Restoring that check fixes the s390x hangs seen in [RHBZ 2058803]. [RHBZ 2058803]: https://bugzilla.redhat.com/show_bug.cgi?id=2058803
2022-03-01add suggestion to update trait if error is in implFausto-2/+8
2022-03-01Suggest adding `Copy` bound when Adt is moved outMaybe Waffle-1/+62
Previously we've only suggested adding `Copy` bounds when the type being moved/copied is a type parameter (generic). With this commit we also suggest adding bounds when a type - Can be copy - All predicates that need to be satisfied for that are based on type params i.e. we will suggest `T: Copy` for `Option<T>`, but won't suggest anything for `Option<String>`. Future work: it would be nice to also suggest adding `.clone()` calls
2022-03-01Improve allowness of the unexpected_cfgs lintLoïc BRANSTETT-26/+60
2022-03-01compiler: fix some typoscuishuang-7/+7
2022-03-01Auto merge of #94477 - matthiaskrgr:rollup-8h29qek, r=matthiaskrgrbors-123/+130
Rollup of 3 pull requests Successful merges: - #94359 (Fix inconsistent symbol mangling of integers constants with -Zverbose) - #94465 (6 - Make more use of `let_chains`) - #94470 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-01Rollup merge of #94465 - c410-f3r:more-let-chains, r=Dylan-DPCMatthias Krüger-118/+97
6 - Make more use of `let_chains` Continuation of #94376. cc #53667
2022-03-01Rollup merge of #94359 - tmiasko:legacy-verbose-const, r=petrochenkovMatthias Krüger-5/+33
Fix inconsistent symbol mangling of integers constants with -Zverbose The `PrettyPrinter` changes formatting of array size and integer constants based on `-Zverbose`, so its implementation cannot be used in legacy symbol mangling. Example symbol demangling before changes: ```console $ cat a.rs pub struct A<T>(T); impl A<[u8; 128]> { pub fn f() {} } $ rustc --crate-type=lib a.rs -Zverbose=n && nm -C ./liba.rlib 00000000 T a::A<[u8; 128]>::f $ rustc --crate-type=lib a.rs -Zverbose=y && nm -C ./liba.rlib 00000000 T a::A<[u8; Const { ty. usize, val. Value(Scalar(0x0000000000000080)) }]>::f ```
2022-03-017 - Make more use of `let_chains`Caio-112/+100
Continuation of #94376. cc #53667
2022-03-01Add helper function to suggest multiple constraintsMaybe Waffle-163/+236
Add `rustc_middle::ty::suggest_constraining_type_params` that suggests adding multiple constraints. `suggest_constraining_type_param` now just forwards params to this new function.
2022-03-01Auto merge of #94402 - erikdesjardins:revert-coldland, r=nagisabors-35/+12
Revert "Auto merge of #92419 - erikdesjardins:coldland, r=nagisa" Should fix (untested) #94390 Reopens #46515, #87055 r? `@ehuss`