about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-03-04Rollup merge of #94466 - jonhoo:bootstrap-proper-env-flags, r=Mark-SimulacrumDylan DPC-29/+70
bootstrap: correct reading of flags for llvm First, this reverts the `CFLAGS`/`CXXFLAGS` of #93918. Those flags are already read by `cc` and populated into `Build` earlier on in the process. We shouldn't be overriding that based on `CFLAGS`, since `cc` also respects overrides like `CFLAGS_{TARGET}` and `HOST_CFLAGS`, which we want to take into account. Second, this adds the same capability to specify target-specific versions of `LDFLAGS` as we have through `cc` for the `C*` flags: https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables
2022-03-04Rollup merge of #93913 - bjorn3:remove_everybody_loops, r=jackh726Dylan DPC-67/+0
Remove the everybody loops pass It isn't used anymore by rustdoc. Split out of https://github.com/rust-lang/rust/pull/92895. There has been some previous discussion there.
2022-03-04Rollup merge of #93418 - ojeda:no-shortcut, r=camelidDylan DPC-4/+4
rustdoc & doc: no `shortcut` for `rel="icon"` According to https://html.spec.whatwg.org/multipage/links.html#rel-icon: > For historical reasons, the `icon` keyword may be preceded by the keyword "`shortcut`". And to https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types: > **Warning:** The `shortcut` link type is often seen before `icon`, but this link type is non-conforming, ignored and **web authors must not use it anymore.** While it was removed from the Rust logo case a while ago in commit 085679c ("Use theme-adaptive SVG favicon from other Rust sites"), it is still there for the custom logo case. Also updated a few other instances. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-03-04Auto merge of #94009 - compiler-errors:gat-rustdoc, r=GuillaumeGomezbors-176/+363
Support GATs in Rustdoc Implements: 1. Rendering GATs in trait definitions and impl blocks 2. Rendering GATs in types (e.g. in the return type of a function) Fixes #92341 This is my first rustdoc PR, so I have absolutely no idea how to produce tests for this. Advice from the rustdoc team would be wonderful! I tested locally and things looked correct: ![image](https://user-images.githubusercontent.com/3674314/153988325-9732cbf3-0645-4e1a-9e64-ddfd93877b55.png)
2022-03-03Generalize `get_nullable_type` to allow types where null is all-ones.Dan Gohman-2/+2
Generalize get_nullable_type to accept types that have an all-ones bit pattern as their sentry "null" value. This will allow [`OwnedFd`], [`BorrowedFd`], [`OwnedSocket`], and [`BorrowedSocket`] to be marked with `#[rustc_nonnull_optimization_guaranteed]`, which will allow `Option<OwnedFd>`, `Option<BorrowedFd>`, `Option<OwnedSocket>`, and `Option<BorrowedSocket>` to be used in FFI declarations, as described in the [I/O safety RFC]. For example, it will allow a function like `open` on Unix and `WSASocketW` on Windows to be declared using `Option<OwnedFd>` and `Option<OwnedSocket>` return types, respectively. The actual change to add `#[rustc_nonnull_optimization_guaranteed]` to the abovementioned types will be a separate PR, as it'll depend on having this patch in the stage0 compiler. Also, update the diagnostics to mention that "niche optimizations" are used in libstd as well as libcore, as `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` are already in use in libstd. [`OwnedFd`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/fd/owned.rs#L49 [`BorrowedFd`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/fd/owned.rs#L29 [`OwnedSocket`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/windows/io/socket.rs#L51 [`BorrowedSocket`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/windows/io/socket.rs#L29 [I/O safety RFC]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md#ownedfd-and-borrowedfdfd-1
2022-03-03Adjusted diagnostic output so that if there is no `use` in a item sequence,Felix S. Klock II-2/+2
then we just suggest the first legal position where you could inject a use. To do this, I added `inject_use_span` field to `ModSpans`, and populate it in parser (it is the span of the first token found after inner attributes, if any). Then I rewrote the use-suggestion code to utilize it, and threw out some stuff that is now unnecessary with this in place. (I think the result is easier to understand.) Then I added a test of issue 87613.
2022-03-03Adjusted diagnostic output so that if there is no `use` in a item sequence,Felix S. Klock II-4/+106
then we just suggest the first legal position where you could inject a use. To do this, I added `inject_use_span` field to `ModSpans`, and populate it in parser (it is the span of the first token found after inner attributes, if any). Then I rewrote the use-suggestion code to utilize it, and threw out some stuff that is now unnecessary with this in place. (I think the result is easier to understand.) Then I added a test of issue 87613.
2022-03-03Associate multiple with a crate too.Felix S. Klock II-3/+4
2022-03-03Associate multiple with a crate too.Felix S. Klock II-6/+7
2022-03-04Fix a bug in `x.py fmt` that prevents some files being formatted.Nicholas Nethercote-1/+6
If you have a file in the repository root with the same name as a file somewhere within a directory, the latter currently won't get formatted. I have experienced this multiple times and not understood what was happening; I finally figured out the problem today. This commit fixes the problem.
2022-03-03Emit `unused_attributes` if a level attr only has a reasonxFrednet-9/+81
2022-03-03Auto merge of #94571 - matthiaskrgr:rollup-4ul5ydb, r=matthiaskrgrbors-0/+41
Rollup of 8 pull requests Successful merges: - #92697 (Use cgroup quotas for calculating `available_parallelism`) - #94057 (improve comments for `simplify_type`) - #94547 (`parse_tt` cleanups) - #94550 (rustdoc: Add test for higher kinded functions generated by macros) - #94551 (Doc: Fix use of quote instead of backstick in Adapter::map.) - #94554 (Fix invalid lint_node_id being put on a removed stmt) - #94555 (all: fix some typos) - #94563 (Remove a unnecessary `..` pattern) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-03Tweak move errorEsteban Kuber-59/+94
Point at method definition that causes type to be consumed. Fix #94056.
2022-03-03add testsMichael Goulet-0/+76
2022-03-03don't forget generics for GATs in implsMichael Goulet-8/+2
2022-03-03make generic projection types print correctlyMichael Goulet-41/+107
2022-03-03Add a missing `#[no_mangle]`scottmcm-0/+1
2022-03-03refactor: prepare to associate multiple spans with a module.Felix S. Klock II-2/+2
2022-03-03refactor: prepare to associate multiple spans with a module.Felix S. Klock II-2/+2
2022-03-03Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkovMatthias Krüger-0/+20
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 #94550 - GuillaumeGomez:HKF-macros, r=notriddleMatthias Krüger-0/+21
rustdoc: Add test for higher kinded functions generated by macros Fixes #75564. The problem has been solved apparently so adding a test to prevent a regression. r? ```@notriddle```
2022-03-03Bless nll tests.Camille GILLOT-2/+2
2022-03-03Auto merge of #87835 - xFrednet:rfc-2383-expect-attribute-with-ids, ↵bors-0/+590
r=wesleywiser Implementation of the `expect` attribute (RFC 2383) This is an implementation of the `expect` attribute as described in [RFC-2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html). The attribute allows the suppression of lint message by expecting them. Unfulfilled lint expectations (meaning no expected lint was caught) will emit the `unfulfilled_lint_expectations` lint at the `expect` attribute. ### Example #### input ```rs // required feature flag #![feature(lint_reasons)] #[expect(unused_mut)] // Will warn about an unfulfilled expectation #[expect(unused_variables)] // Will be fulfilled by x fn main() { let x = 0; } ``` #### output ```txt warning: this lint expectation is unfulfilled --> $DIR/trigger_lint.rs:3:1 | LL | #[expect(unused_mut)] // Will warn about an unfulfilled expectation | ^^^^^^^^^^ | = note: `#[warn(unfulfilled_lint_expectations)]` on by default ``` ### Implementation This implementation introduces `Expect` as a new lint level for diagnostics, which have been expected. All lint expectations marked via the `expect` attribute are collected in the [`LintLevelsBuilder`] and assigned an ID that is stored in the new lint level. The `LintLevelsBuilder` stores all found expectations and the data needed to emit the `unfulfilled_lint_expectations` in the [`LintLevelsMap`] which is the result of the [`lint_levels()`] query. The [`rustc_errors::HandlerInner`] is the central error handler in rustc and handles the emission of all diagnostics. Lint message with the level `Expect` are suppressed during this emission, while the expectation ID is stored in a set which marks them as fulfilled. The last step is then so simply check if all expectations collected by the [`LintLevelsBuilder`] in the [`LintLevelsMap`] have been marked as fulfilled in the [`rustc_errors::HandlerInner`]. Otherwise, a new lint message will be emitted. The implementation of the `LintExpectationId` required some special handling to make it stable between sessions. Lints can be emitted during [`EarlyLintPass`]es. At this stage, it's not possible to create a stable identifier. The level instead stores an unstable identifier, which is later converted to a stable `LintExpectationId`. ### Followup TO-DOs All open TO-DOs have been marked with `FIXME` comments in the code. This is the combined list of them: * [ ] The current implementation doesn't cover cases where the `unfulfilled_lint_expectations` lint is actually expected by another `expect` attribute. * This should be easily possible, but I wanted to get some feedback before putting more work into this. * This could also be done in a new PR to not add to much more code to this one * [ ] Update unstable documentation to reflect this change. * [ ] Update unstable expectation ids in [`HandlerInner::stashed_diagnostics`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html#structfield.stashed_diagnostics) ### Open questions I also have a few open questions where I would like to get feedback on: 1. The RFC discussion included a suggestion to change the `expect` attribute to something else. (Initiated by `@Ixrec` [here](https://github.com/rust-lang/rfcs/pull/2383#issuecomment-378424091), suggestion from `@scottmcm` to use `#[should_lint(...)]` [here](https://github.com/rust-lang/rfcs/pull/2383#issuecomment-378648877)). No real conclusion was drawn on that point from my understanding. Is this still open for discussion, or was this discarded with the merge of the RFC? 2. How should the expect attribute deal with the new `force-warn` lint level? --- This approach was inspired by a discussion with `@LeSeulArtichaut.` RFC tracking issue: #54503 Mentoring/Implementation issue: #85549 [`LintLevelsBuilder`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/levels/struct.LintLevelsBuilder.html [`LintLevelsMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/struct.LintLevelMap.html [`lint_levels()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.lint_levels [`rustc_errors::HandlerInner`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html [`EarlyLintPass`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html
2022-03-03Add autovectorization codegen testJubilee Young-0/+31
Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com>
2022-03-03Redo the array-equality codegen tests for the different thresholdScott McMurray-10/+31
2022-03-03Revert #26494 regressionVin Singh-40/+4
2022-03-03Remove unused Default and Clone derives in config.rsbjorn3-6/+6
2022-03-03Remove some dead code from toolstate.rsbjorn3-11/+2
2022-03-03Cleanup feature gates.Camille GILLOT-267/+231
2022-03-03Gate stability attrs with other attributes.Camille GILLOT-107/+175
2022-03-03bootstrap: correct reading of flags for llvmJon Gjengset-29/+70
First, this reverts the `CFLAGS`/`CXXFLAGS` of #93918. Those flags are already read by `cc` and populated into `Build` earlier on in the process. We shouldn't be overriding that based on `CFLAGS`, since `cc` also respects overrides like `CFLAGS_{TARGET}` and `HOST_CFLAGS`, which we want to take into account. Second, this adds the same capability to specify target-specific versions of `LDFLAGS` as we have through `cc` for the `C*` flags: https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables Note that this also necessitated an update to compiletest to treat CXXFLAGS separately from CFLAGS.
2022-03-03Remove the everybody loops passbjorn3-67/+0
It isn't used anymore by rustdoc
2022-03-03Bless test.Camille GILLOT-2/+17
2022-03-03Add -Z oom={panic,abort} command-line optionAmanieu d'Antras-1/+23
2022-03-03Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obkbors-63/+57
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-03Add support for values() with --check-cfgLoïc BRANSTETT-4/+2
2022-03-03Fix invalid lint_node_id being put on a removed stmtLoïc BRANSTETT-0/+20
2022-03-03Add test for higher kinded functions generated by macrosGuillaume Gomez-0/+21
2022-03-03Rollup merge of #94537 - est31:master, r=notriddleMatthias Krüger-51/+48
Use ? operator in one instance instead of manual match As suggested [here](https://github.com/rust-lang/rust/pull/94139#discussion_r818102403). r? `@notriddle`
2022-03-03Rollup merge of #94536 - dtolnay:transmute, r=ManishearthMatthias Krüger-3/+2
Move transmute_undefined_repr back to nursery again This PR reapplies #94014, which was reverted unintentionally I think by #94329. The combination of https://github.com/rust-lang/rust-clippy/pull/8432 + https://github.com/rust-lang/rust-clippy/pull/8497 in clippy should prevent this from happening again. r? `@Manishearth`
2022-03-03Rollup merge of #94101 - notriddle:notriddle/strip-test-cases, r=GuillaumeGomezMatthias Krüger-0/+9
rustdoc: add test cases for hidden enum variants
2022-03-02make test work on noopt builderErik Desjardins-1/+1
2022-03-02bless clippyRalf Jung-4/+4
2022-03-03Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebankDylan DPC-1/+41
Unused doc comments blocks Fixes #77030.
2022-03-03Rollup merge of #94505 - cuviper:mono-item-sort-local, ↵Dylan DPC-9/+9
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 #94499 - RandomInsano:patch-1, r=Dylan-DPCDylan DPC-3/+3
Documentation was missed when demoting Windows XP to no_std only After a quick discussion on #81250 which removed special casing for mutexes added [here](https://github.com/rust-lang/rust/commit/10b103af48368c5df644fa61dc417a36083922c8) to support Windows XP, we can't say that the standard library can build for it. This change modifies the tier 3 non-ARM targets to show the standard library will no longer build for these and there is no work being done to change that.
2022-03-03Rollup merge of #94433 - Urgau:check-cfg-allowness, r=petrochenkovDylan DPC-0/+62
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-0/+310
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-12/+74
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 tests on platforms where Align16 is represented as i128Erik Desjardins-1/+1