about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-09-02Add warning against unexpected --cfg with --check-cfgUrgau-3/+23
2022-09-02Rollup merge of #101294 - Xiretza:fix-100844-accident, r=davidtwcoGuillaume Gomez-85/+299
Fix #100844 rebase accident This undoes the rebase accident in #100844, which accidentally caused #100970 to be reverted.
2022-09-02Rollup merge of #100827 - JakobDegen:better-tests, r=wesleywiserGuillaume Gomez-1509/+742
Simplify MIR opt tests This commit removes many cases of MIR opt tests emitting `.diff`s for more than one pass. These tests cannot be `unit-test`s, and so they are easy to break, and they also provide little value due to having excessively strong opinions over *how* a piece of code should be optimized. Where reasonable, we instead add separate test files that only emit the `PreCodegen.after` MIR for code where we want to track what the end to end effect of the optimization pipeline on the example code is. r? `````@wesleywiser`````
2022-09-02Rollup merge of #100147 - Bryanskiy:private-in-public, r=petrochenkovGuillaume Gomez-0/+174
optimization of access level table construction Refactoring which was mentioned in #87487
2022-09-02Rollup merge of #97739 - a2aaron:let_underscore, r=estebankGuillaume Gomez-0/+63
Uplift the `let_underscore` lints from clippy into rustc. This PR resolves #97241. This PR adds three lints from clippy--`let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use`, which are meant to capture likely-incorrect uses of `let _ = ...` bindings (in particular, doing this on a type with a non-trivial `Drop` causes the `Drop` to occur immediately, instead of at the end of the scope. For a type like `MutexGuard`, this effectively releases the lock immediately, which is almost certainly the wrong behavior) In porting the lints from clippy I had to copy over a bunch of utility functions from `clippy_util` that these lints also relied upon. Is that the right approach? Note that I've set the `must_use` and `drop` lints to Allow by default and set `lock` to Deny by default (this matches the same settings that clippy has). In talking with `@estebank` he informed me to do a Crater run (I am not sure what type of Crater run to request here--I think it's just "check only"?) On the linked issue, there's some discussion about using `must_use` and `Drop` together as a heuristic for when to warn--I did not implement this yet. r? `@estebank`
2022-09-01Simplify MIR opt testsJakob Degen-1509/+742
This commit removes many cases of MIR opt tests emitting `.diff`s for more than one pass. These tests cannot be `unit-test`s, and so they are easy to break, and they also provide little value due to having excessively strong opinions over *how* a piece of code should be optimized. Where reasonable, we instead add separate test files that only emit the `PreCodegen.after` MIR for code where we want to track what the result of the net result of the optimization pipeline's output is.
2022-09-01Rollup merge of #101285 - ↵Matthias Krüger-0/+26
TaKO8Ki:do-not-suggest-adding-move-when-closure-is-already-marked-as-move, r=oli-obk Do not suggest adding `move` to closure when `move` is already used Fixes #101227
2022-09-01Rollup merge of #101279 - GuillaumeGomez:doc_auto_cfg_nested_impl, r=notriddleMatthias Krüger-0/+24
Fix doc_auto_cfg for impl blocks in different modules with different `cfg` Fixes #101129. Just like reexports, impl blocks don't necessarily share the same "space" as the item they implement so we need to merge attributes from its parents as well. r? `@notriddle`
2022-09-01Rollup merge of #101245 - GuillaumeGomez:remove-unneeded-where-whitespace, ↵Matthias Krüger-52/+104
r=notriddle Remove unneeded where whitespace It fixes these two bugs: ![Screenshot from 2022-08-31 18-14-40](https://user-images.githubusercontent.com/3050060/187727950-94657419-abfa-454c-9d27-004280fbcb45.png) ![Screenshot from 2022-08-31 18-14-49](https://user-images.githubusercontent.com/3050060/187727956-21d1b39d-62d7-4e7b-8f6f-631ceda67a19.png) It's a relic from a very old time (this commit: https://github.com/rust-lang/rust/commit/bfd01b7f40ae2cbfe9acbc1d10e79ffe16870df8). You can test the result [here](https://rustdoc.crud.net/imperio/remove-unneeded-where-whitespace/lib2/struct.WhereWhitespace.html). cc `````````@jsha````````` r? `````````@notriddle`````````
2022-09-01Rollup merge of #94467 - ibraheemdev:master, r=pnkfelixMatthias Krüger-0/+56
Add `special_module_name` lint Declaring `lib` as a module is one of the most common beginner mistakes when trying to setup a binary and library target in the same crate. `special_module_name` lints against it, as well as `mod main;` ``` warning: found module declaration for main.rs --> $DIR/special_module_name.rs:4:1 | LL | mod main; | ^^^^^^^^^ | = note: a binary crate cannot be used as library warning: found module declaration for lib.rs --> $DIR/special_module_name.rs:1:1 | LL | mod lib; | ^^^^^^^^ | = note: `#[warn(special_module_name)]` on by default = note: lib.rs is the root of this crate's library target = help: to refer to it from other targets, use the library's name as the path ``` Note that the help message is not the best in that it doesn't provide an example of an import path (`the_actual_crate_name::`), and doesn't check whether the current file is part of a library/binary target to provide more specific error messages. I'm not sure where this lint would have to be run to access that information.
2022-09-01Allow deriving multiple subdiagnostics using one SessionSubdiagnosticXiretza-48/+34
This reimplements ac638c1, which had to be reverted in the previous commit because it contains a rebase accident that itself reverted significant unrelated changes to SessionSubdiagnostic.
2022-09-01Revert parts of "use derive proc macro to impl SessionDiagnostic"Xiretza-85/+313
This reverts parts of commit ac638c1f5fca36484506415319ab254ad522a692. During rebase, this commit accidentally reverted unrelated changes to the subdiagnostic derive (those allowing multipart_suggestions to be derived). This commit reverts all changes to the subdiagnostic code made in ac638c1f5fc, the next commit will reintroduce the actually intended changes.
2022-09-01Auto merge of #101239 - oli-obk:tracing_cleanup, r=estebankbors-2/+2
Tracing cleanup r? `@ghost`
2022-09-01Adjust stderr fileOli Scherer-2/+2
2022-09-01do not suggest adding `move` to closure when `move` is already usedTakayuki Maeda-0/+26
2022-09-01Auto merge of #100606 - cuviper:upgrade-linux-ci, r=Mark-Simulacrumbors-2/+2
ci: Upgrade non-dist Linux testers from ubuntu:16.04 to 22.04 The main goal of updating to 22.04 is to get away from `llvm.allow-old-toolchain`. A side benefit is that they can also use the system `cmake` instead of building one.
2022-09-01Sort tests at compile time, not at startupBen Kimock-0/+82
Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately.
2022-09-01Add regression test for #101129Guillaume Gomez-0/+24
2022-09-01Auto merge of #100707 - dzvon:fix-typo, r=davidtwcobors-69/+69
Fix a bunch of typo This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-09-01Auto merge of #100537 - petrochenkov:piccheck, r=oli-obkbors-2/+2
rustc_target: Add some more target spec sanity checking
2022-08-31Merge remote-tracking branch 'origin/master' into ↵Matthew Kelly-5184/+9169
mpk/add-long-error-message-for-E0311
2022-08-31Rollup merge of #101230 - davidtwco:translation-internal-lint-no-self-lint, ↵Matthias Krüger-7/+15
r=fee1-dead lint: avoid linting diag functions with diag lints Functions annotated with `#[rustc_lint_diagnostics]` are used by the diagnostic migration lints to know when to lint, but functions that are annotated with this attribute shouldn't themselves be linted. cc #100717 https://github.com/rust-lang/rust/pull/101041#discussion_r959303706
2022-08-31Rollup merge of #101161 - ldm0:ldm_fix_diagnostic, r=cjgillotMatthias Krüger-15/+45
Fix uintended diagnostic caused by `drain(..)` Calling `drain(..)` makes later `suggestable_variants.is_empty()` always true, which makes the diagnostics unintended.
2022-08-31Rollup merge of #100844 - evopen:migrate-diag, r=davidtwcoMatthias Krüger-313/+85
migrate rustc_query_system to use SessionDiagnostic issues: * variable list is not supported in fluent * ~~cannot have two sub diagnostic with the same tag (eg. 2 .note or 2 .help)~~ allow multiple tag with SessionSubdiagnostic derive
2022-08-31Rollup merge of #100838 - ↵Matthias Krüger-3/+127
hkmatsumoto:move-gen-args-to-trait-when-appropriate, r=davidtwco Suggest moving redundant generic args of an assoc fn to its trait Closes #89064
2022-08-31Rollup merge of #100787 - chenyukang:fix-100770-pretty-crash, r=petrochenkovMatthias Krüger-0/+8
Pretty printing give proper error message without panic Fixes #100770
2022-08-31Add rustdoc GUI testGuillaume Gomez-0/+27
2022-08-31Update rustdoc testsGuillaume Gomez-52/+77
2022-08-31lint: avoid linting diag functions with diag lintsDavid Wood-7/+15
Functions annotated with `#[rustc_lint_diagnostics]` are used by the diagnostic migration lints to know when to lint, but functions that are annotated with this attribute shouldn't themselves be linted. Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-31Rollup merge of #101204 - aDotInTheVoid:async-resugar-in-clean, r=GuillaumeGomezRalf Jung-0/+36
rustdoc: Resugar async fn return type in `clean`, not `html` This way it also happens for json output. Fixes #101199 r? ``@GuillaumeGomez``
2022-08-31Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwcoRalf Jung-2/+2
Migrate rustc_monomorphize to use SessionDiagnostic ### Description - Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic` - Adds an `impl IntoDiagnosticArg for PathBuf` ### TODO / Help! - [x] I'm having trouble figuring out how to apply an optional note. 😕 Help!? - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files - [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment. - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694 - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it? - [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](https://github.com/rust-lang/rust/blob/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f/compiler/rustc_monomorphize/src/collector.rs#L917-L927)? - [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](https://github.com/rust-lang/rust/blob/0b79f758c9aa6646606662a6d623a0752286cd17/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs#L83-L114) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-31Rollup merge of #90946 - GuillaumeGomez:def-id-remove-weird-case, r=ManishearthRalf Jung-0/+37
Ignore `reference`s in "Type::inner_def_id" Fixes #90775. Reopening of #90726. As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/rendering.20for.20reference.20primitive.20doc.20page), the reference page shouldn't list these implementations (since they are listed on the types and on the traits in any case). And more generally, you don't implement something on a reference but on something behind a reference. I think it's the important point. So currently it looks like this: ![Screenshot from 2021-11-16 10-20-41](https://user-images.githubusercontent.com/3050060/141957799-57aeadc5-41f8-45f6-a4a5-33b1eca6a500.png) With this PR, only the implementations over generics behind a reference are kept. You can test it [here](https://rustdoc.crud.net/imperio/def-id-remove-weird-case/std/primitive.reference.html). cc ``@camelid``
2022-08-31use derive proc macro to impl SessionDiagnosticYuanheng Li-313/+85
fixes `SessionSubdiagnostic` to accept multiple attributes emitting list of fluent message remains unresolved
2022-08-31add TestReachabilityVisitorBryanskiy-0/+174
2022-08-31Fix ci checksDezhi Wu-2/+2
2022-08-31Fix a bunch of typoDezhi Wu-67/+67
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Add regression test for implementations displayed on reference primitive typeGuillaume Gomez-0/+37
2022-08-31Rollup merge of #101185 - compiler-errors:tweak-wf-locs, r=davidtwcoMatthias Krüger-30/+30
Tweak `WellFormedLoc`s a bit Gives a bit tighter spans in returns and generic ty defaults
2022-08-31Rollup merge of #101100 - compiler-errors:generalize-call-suggestions, ↵Matthias Krüger-140/+274
r=petrochenkov Make call suggestions more general and more accurate Cleans up some suggestions that have to do with adding `()` to make typeck happy. 1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr` 1. Autoderef until we get to a callable type in `suggest_fn_call`. 1. Don't erroneously suggest calling constructor when a method/field does not exist on it. 1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`) 1. Extend call suggestions to type parameters, fn pointers, trait objects where possible 1. Suggest calling in operators too (fixes #101054) 1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
2022-08-31Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davidtwcoMatthias Krüger-100/+292
Allow deriving multipart suggestions This turned into a bit more of a rewrite than I was initially hoping for... Still, I think the `SessionSubdiagnostic` derive is a little cleaner overall now, and closer to the `SessionDiagnostic` derive to make future code sharing easier. r? ``@davidtwco``
2022-08-31Fix uintended diagnostic caused by `drain(..)`Donough Liu-15/+45
2022-08-30Stabilize GATsJack Huey-766/+307
2022-08-31Auto merge of #101220 - JohnTitor:rollup-ov7upr7, r=JohnTitorbors-0/+71
Rollup of 10 pull requests Successful merges: - #100804 (Fix search results color on hover for ayu theme) - #100892 (Add `AsFd` implementations for stdio types on WASI.) - #100927 (Adding new Fuchsia rustup docs... reworking walkthrough) - #101088 (Set DebuginfoKind::Pdb in msvc_base) - #101159 (add tracking issue number to const_slice_split_at_not_mut) - #101192 (Remove path string) - #101193 (Avoid zeroing large stack buffers in stdio on Windows) - #101197 (:arrow_up: rust-analyzer) - #101200 (Add test for issue #85872) - #101219 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-31Rollup merge of #101200 - nikic:issue-85872, r=compiler-errorsYuki Okushi-0/+20
Add test for issue #85872 This has been fixed by the LLVM 15 upgrade, add a codegen test. Fixes #85872.
2022-08-31Rollup merge of #100804 - GuillaumeGomez:search-results-color-ayu, r=notriddleYuki Okushi-0/+51
Fix search results color on hover for ayu theme Before: ![image](https://user-images.githubusercontent.com/3050060/185747851-038d2333-8b01-44a8-a104-ceb7410ac089.png) After: ![image](https://user-images.githubusercontent.com/3050060/185747869-53b502f5-5800-470f-b897-2683f1cdb7ee.png) You can test it [here](https://rustdoc.crud.net/imperio/search-results-color-ayu/foo/index.html?search=item). r? ``@jsha``
2022-08-30Auto merge of #99102 - JakobDegen:reorder-generators, r=oli-obkbors-49/+68
Rework definition of MIR phases to more closely reflect semantic concerns Implements most of rust-lang/compiler-team#522 . I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.
2022-08-30[drop tracking] Use parent expression for scopeEric Holk-0/+3
Previously we were just using the parent node as the scope for a temporary value, but it turns out this is too narrow. For example, in an expression like Foo { b: &42, a: async { 0 }.await, } the scope for the &42 was set to the ExprField node for `b: &42`, when we actually want to use the Foo struct expression. We fix this by recursively searching through parent nodes until we find a Node::Expr. It may be that we don't find one, and if so that's okay, we will just fall back on the enclosing temporary scope which is always sufficient.
2022-08-30Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJungbors-10/+66
Strengthen invalid_value lint to forbid uninit primitives, adjust docs to say that's UB For context: https://github.com/rust-lang/rust/issues/66151#issuecomment-1174477404= This does not make it a FCW, but it does explicitly state in the docs that uninit integers are UB. This also doesn't affect any runtime behavior, uninit u32's will still successfully be created through mem::uninitialized.
2022-08-30rustdoc: Resugar async fn return type in `clean`, not `html`Nixon Enraght-Moony-0/+36
This way it also happens for json output. Fixes #101199
2022-08-30Add test for issue #85872Nikita Popov-0/+20
This has been fixed by the LLVM 15 upgrade, add a codegen test. Fixes #85872.