about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-09-30Rollup merge of #89314 - notriddle:notriddle/lint-fix-enum-variant-match, ↵Manish Goregaokar-0/+37
r=davidtwco fix(lint): don't suggest refutable patterns to "fix" irrefutable bind In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work. The general warning is still kept, because code like this is confusing. Fixes #88730 p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.
2021-09-30Rollup merge of #89303 - guswynn:std_suspend, r=dtolnayManish Goregaokar-0/+38
Add `#[must_not_suspend]` to some types in std I am not sure what else should have it? `Ref`?
2021-09-30Rollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, ↵Manish Goregaokar-2/+130
r=estebank Suggest similarly named associated items in trait impls Fix #85942 Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
2021-09-30Rollup merge of #89202 - estebank:infer-call-type, r=oli-obkManish Goregaokar-0/+14
Resolve infered types when complaining about unexpected call type ``` error[E0618]: expected function, found `{integer}` --> $DIR/call-block.rs:2:13 | LL | let _ = {42}(); | ^^^^-- | | | call expression requires function ``` instead of ``` error[E0618]: expected function, found `_` --> $DIR/call-block.rs:2:13 | LL | let _ = {42}(); | ^^^^-- | | | call expression requires function ```
2021-09-30Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillotManish Goregaokar-11/+30
Fix ICE when `start` lang item has wrong generics In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates. This fixes that by updating the requirement to be exactly one generic type. The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it. I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations. Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided. Fixes #79559, fixes #73584, fixes #83117 (all duplicates) Relevant to #9307 r? ````@cjgillot````
2021-09-30Auto merge of #89282 - sexxi-goose:fix-88118, r=nikomatsakisbors-0/+36
2229: Consume IfLet expr When using the IfLet guard feature, we can ICE when attempting to resolve PlaceBuilders. For pattern matching, we currently don't consume the IfLet expression when "visiting" the arms leading us to not "read" all variables and hence not being able to resolve them. r? `@nikomatsakis` Closes https://github.com/rust-lang/rust/issues/88118
2021-09-30Auto merge of #87998 - nneonneo:master, r=oli-obkbors-0/+132
Avoid spurious "previous iteration of loop" errors Only follow backwards edges during `get_moved_indexes` if the move path is definitely initialized at loop entry. Otherwise, the error occurred prior to the loop, so we ignore the backwards edges to avoid generating misleading "value moved here, in previous iteration of loop" errors. This patch also slightly improves the analysis of inits, including `NonPanicPathOnly` initializations (which are ignored by `drop_flag_effects::for_location_inits`). This is required for the definite initialization analysis, but may also help find certain skipped reinits in rare cases. Patch passes all non-ignored src/test/ui testcases. Fixes #72649.
2021-09-30Auto merge of #86853 - usbalbin:const_try, r=oli-obkbors-0/+23
Constify ?-operator for Result and Option Try to make `?`-operator usable in `const fn` with `Result` and `Option`, see #74935 . Note that the try-operator itself was constified in #87237. TODO * [x] Add tests for const T -> T conversions * [x] cleanup commits * [x] Remove `#![allow(incomplete_features)]` * [?] Await decision in #86808 - I'm not sure * [x] Await support for parsing `~const` in bootstrapping compiler * [x] Tracking issue(s)? - #88674
2021-09-30Auto merge of #89250 - Aaron1011:keep-bound-region-names, r=estebankbors-21/+21
Don't anonymize bound region names during typeck Once this anonymization has performed, we have no way of recovering the original names during NLL borrow checking. Keeping the original names allows error messages in full NLL mode to contain the original bound region names. As a result, the typeck results may contain types that differ only in the names used for their bound regions. However, anonimization of bound regions does not guarantee that all distinct types are unqual (e.g. not subtypes of each other). For example, `for<'a> fn(&'a u32, &'a u32)` and `for<'b, 'c> fn(&'b u32, &'c u32)` are subtypes of each other, as explained here: https://github.com/rust-lang/rust/blob/63cc2bb3d07d6c726dfcdc5f95cbe5ed4760641a/compiler/rustc_infer/src/infer/nll_relate/mod.rs#L682-L690 Therefore, any code handling types with higher-ranked regions already needs to handle the case where two distinct `Ty`s are 'actually' equal.
2021-09-30Auto merge of #89386 - ehuss:rollup-idf4dmj, r=ehussbors-27/+84
Rollup of 13 pull requests Successful merges: - #87428 (Fix union keyword highlighting in rustdoc HTML sources) - #88412 (Remove ignore-tidy-undocumented-unsafe from core::slice::sort) - #89098 (Fix generics where bounds order) - #89232 (Improve help for recursion limit errors) - #89294 (:arrow_up: rust-analyzer) - #89297 (Remove Never variant from clean::Type enum) - #89311 (Add unit assignment to MIR for `asm!()`) - #89313 (PassWrapper: handle function rename from upstream D36850) - #89315 (Clarify that `CString::from_vec_unchecked` appends 0 byte.) - #89335 (Optimize is_sorted for Range and RangeInclusive) - #89366 (rustdoc: Remove lazy_static dependency) - #89377 (Update cargo) - #89378 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-29Rollup merge of #89311 - FabianWolff:issue-89305, r=oli-obkEric Huss-0/+29
Add unit assignment to MIR for `asm!()` Fixes #89305. `ExprKind::LlvmInlineAsm` gets a `push_assign_unit()` here: https://github.com/rust-lang/rust/blob/2b6ed3b675475abc01ce7e68bb75b457f0c85684/compiler/rustc_mir_build/src/build/expr/into.rs#L475-L479 The same should probably happen for `ExprKind::InlineAsm`, which fixes the "use of possibly-uninitialized variable" error described in #89305.
2021-09-29Rollup merge of #89232 - rossmacarthur:fix-76424, r=wesleywiserEric Huss-27/+55
Improve help for recursion limit errors - Tweak help message and suggested limit (handle `0` case). - Add test for #75602 (it was already fixed, maybe can be resolved too). Fixes #76424
2021-09-30Auto merge of #89110 - Aaron1011:adjustment-span, r=estebankbors-581/+426
Use larger span for adjustment THIR expressions Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions. These spans are recoded when we first create the adjustment during typecheck. For example, an autoref adjustment triggered by a method call will record the span of the entire method call. The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-29fix(lint): don't suggest refutable patterns to "fix" irrefutable bindMichael Howell-0/+37
In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work. The general warning is still kept, because code like this is confusing. Fixes #88730
2021-09-29Auto merge of #89331 - GuillaumeGomez:rollup-b10unye, r=GuillaumeGomezbors-19/+60
Rollup of 8 pull requests Successful merges: - #87260 (Libgccjit codegen) - #89212 (x.py: run `rustup toolchain link` in setup) - #89233 (Hide `<...> defined here` note if the source is not available) - #89235 (make junit output more consistent with default format) - #89255 (Fix incorrect disambiguation suggestion for associated items) - #89276 (Fix the population of the `union.impls` field) - #89283 (Add regression test for issue #83564) - #89318 (rustc_session: Remove lint store from `Session`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-28ref/refmutGus Wynn-1/+1
2021-09-29Auto merge of #88950 - Nadrieril:deconstruct-pat, r=oli-obkbors-17/+99
Add an intermediate representation to exhaustiveness checking The exhaustiveness checking algorithm keeps deconstructing patterns into a `Constructor` and some `Fields`, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start. I find this makes code easier to follow. In particular `DeconstructedPat::specialize` is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm from `rustc_middle::Pat`.
2021-09-28Improve help for recursion limit errorsRoss MacArthur-27/+55
2021-09-28Rollup merge of #89283 - camelid:issue-83564-test, r=davidtwcoGuillaume Gomez-0/+26
Add regression test for issue #83564 cc #83564 r? ``@davidtwco``
2021-09-28Rollup merge of #89276 - Urgau:fix-union-impls, r=GuillaumeGomezGuillaume Gomez-0/+15
Fix the population of the `union.impls` field This pull-request fix the population of the `union.impls` field that was forgot when the `Union` type was introduce as a split from the `Struct` type https://github.com/rust-lang/rust/pull/81500. ``@rustbot`` label +T-rustdoc +A-rustdoc-json
2021-09-28Rollup merge of #89255 - FabianWolff:issue-88806, r=cjgillotGuillaume Gomez-19/+19
Fix incorrect disambiguation suggestion for associated items Fixes #88806. I have not added a new test case, because the erroneous behavior is already present in existing test cases.
2021-09-29Suggest similarly named assoc items in trait implsHirochika Matsumoto-2/+130
Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types and constants.
2021-09-28Auto merge of #89293 - ↵bors-0/+45
TaKO8Ki:fix-confusing-error-for-path-separator-to-refer-to-an-struct-item, r=estebank Suggest using the path separator for tuple struct Fix confusing error message `constructor is not visible here due to private fields` for tuple struct closes #83450
2021-09-28Auto merge of #89277 - jyn514:codeblock-edition, r=GuillaumeGomezbors-0/+38
Use the correct edition for syntax highlighting doctests Previously it would unconditionally use edition 2015, which was incorrect. Helps with https://github.com/rust-lang/rust/issues/89135 in that you can now override the doctest to be 2018 edition instead of being forced to fix the error. This doesn't resolve any of the deeper problems that rustdoc disagrees with most rust users on what a code block is. cc `@Mark-Simulacrum`
2021-09-28Add unit assignment to MIR for `asm!()`Fabian Wolff-0/+29
2021-09-27Auto merge of #89249 - Aaron1011:higher-ranked-cause, r=estebankbors-0/+40
Improve cause information for NLL higher-ranked errors This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
2021-09-27Auto merge of #89214 - smoelius:register_tool, r=petrochenkovbors-0/+14
Pass real crate-level attributes to `pre_expansion_lint` The PR concerns the unstable feature `register_tool` (#66079). The feature's implementation requires the attributes of the crate being compiled, so that when attributes like `allow(foo::bar)` are encountered, it can be verified that `register_tool(foo)` appears in the crate root. However, the crate's attributes are not readily available during early lint passes. Specifically, on this line, `krate.attrs` appears to be the attributes of the current source file, not the attributes of the whole crate: https://github.com/rust-lang/rust/blob/bf642323d621dcefeef1d8ab4711aae36e357615/compiler/rustc_lint/src/context.rs#L815 Consequently, "unknown tool" errors were being produced when `allow(foo::bar)` appeared in a submodule, even though `register_tool(foo)` appeared in the crate root. EDITED: The proposed fix is to obtain the real crate-level attributes in `configure_and_expand` and pass them to `pre_expansion_lint`. (See `@petrochenkov's` [comment](https://github.com/rust-lang/rust/pull/89214#issuecomment-926927072) below.) The original "prosed fix" text follows. --- The proposed fix is to add an `error_on_unknown_tool` flag to `LintLevelsBuilder`. The flag controls whether "unknown tool" errors are emitted. The flag is set during late passes, but not earlier. More specifically, this PR contains two commits: * The first adds a `known-tool-in-submodule` UI test that does not currently pass. * The second adds the `error_on_unknown_tool` flag. The new test passes with the addition of this flag. This change has the added benefit of eliminating some errors that were duplicated in existing tests. To the reviewer: please check that I implemented the UI test correctly.
2021-09-27#[feature] not required for lint resultGus Wynn-5/+4
2021-09-27lock typesGus Wynn-0/+39
2021-09-27Improve cause information for NLL higher-ranked errorsAaron Hill-0/+40
This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
2021-09-27Auto merge of #89263 - ↵bors-60/+177
TaKO8Ki:suggest-both-immutable-and-mutable-trait-implementations, r=estebank Suggest both of immutable and mutable trait implementations closes #85865
2021-09-27suggest path for tuple structTakayuki Maeda-0/+45
2021-09-26Fix testRoxane-9/+5
2021-09-262229: Consume IfLet exprRoxane-0/+40
2021-09-26Add regression test for issue #83564Noah Lev-0/+26
2021-09-26Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakisbors-527/+240
2229: Mark insignificant dtor in stdlib I looked at all public [stdlib Drop implementations](https://doc.rust-lang.org/stable/std/ops/trait.Drop.html#implementors) and categorized them into Insigificant/Maybe/Significant Drop. Reasons are noted here: https://docs.google.com/spreadsheets/d/19edb9r5lo2UqMrCOVjV0fwcSdS-R7qvKNL76q7tO8VA/edit#gid=1838773501 One thing missing from this PR is tagging HashMap as insigificant destructor as that needs some discussion. r? `@Mark-Simulacrum` cc `@nikomatsakis`
2021-09-26Use the correct edition when syntax highlighting doctestsJoshua Nelson-0/+38
Previously it would unconditionally use edition 2015, which was incorrect.
2021-09-26Fix populate of union.implsLoïc BRANSTETT-0/+15
2021-09-27test suggesting immutable or mutable trait implementationsTakayuki Maeda-36/+82
2021-09-27fix test errorTakayuki Maeda-4/+6
2021-09-26Auto merge of #88316 - est31:remove_box_tests, r=Mark-Simulacrumbors-1193/+999
Remove most box syntax uses from the testsuite except for src/test/ui/issues Removes most box syntax uses from the testsuite outside of the src/test/ui/issues directory. The goal was to only change tests where box syntax is an implementation detail instead of the actual feature being tested. So some tests were left out, like the regression test for #87935, or tests where the obtained error message changed significantly. Mostly this replaces box syntax with `Box::new`, but there are some minor drive by improvements, like formatting improvements or `assert_eq` instead of `assert!( == )`. Prior PR that removed box syntax from the compiler and tools: #87781
2021-09-27better suggestionsTakayuki Maeda-48/+65
2021-09-26Auto merge of #89101 - ehuss:compiletest-incremental-build, r=Mark-Simulacrumbors-87/+110
Support incremental in compiletest for non-incremental modes. This adds first-class support for using incremental builds in non-incremental-mode tests. These tests previously manually passed `-C incremental=tmp/foo` which resulted in reusing the same tmp folder between runs. This means that these tests could fail whenever the on-disk incremental format changed (such as when updating one's local source tree). This changes it so that these tests can pass a `// incremental-build` header which instructs compiletest to create a set aside a dedicated incremental directory which will be cleared before the test starts to ensure it has a clean slate.
2021-09-26fix the relevant testsTakayuki Maeda-20/+36
2021-09-26suggest both immutable and mutable trait implementationsTakayuki Maeda-0/+36
2021-09-26Auto merge of #88680 - ehuss:more-attr-validation, r=petrochenkovbors-9/+78
Validate builtin attributes for macro args. This adds some validation for `path`, `crate_type`, and `recursion_limit` attributes so that they will now return an error if you attempt to pass a macro into them (such as `#[path = foo!()]`). Previously, the attribute would be completely ignored. These attributes are special because their values need to be known before/during expansion. cc #87681
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-1193/+999
2021-09-25Rollup merge of #89198 - hkmatsumoto:hide-hidden-methods, r=jyn514Manish Goregaokar-0/+60
rustdoc: Don't show hidden trait methods Fix #89186. By skipping trait items whose attributes include `hidden`, we avoid showing such trait methods.
2021-09-26Replace `Pat` with a new intermediate representationNadrieril-15/+52
2021-09-26Rework `Fields` internals.Nadrieril-2/+2
Now `Fields` is just a `Vec` of patterns, with some extra info on the side to reconstruct patterns when needed. This emphasizes that this extra info is not central to the algorithm.