about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
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-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-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-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-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-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.
2021-09-25Auto merge of #87584 - adamgemmell:dev/asm-tests, r=Amanieubors-237/+2839
Add inline asm! tests for aarch64 Port many of the x86-only UI tests for inline asm! over to aarch64.
2021-09-25Check for macros in built-in attributes that don't support them.Eric Huss-0/+69
2021-09-25Move malformed attribute code to a function and fix inner attribute suggestion.Eric Huss-9/+9
Moving to a dedicated function in preparation for other validation. The suggestion given didn't consider if it was an inner attribute.
2021-09-25Auto merge of #88243 - nikic:newpm-2, r=nagisabors-5/+10
Enable new pass manager with LLVM 13 The new pass manager is enabled by default in clang since Clang/LLVM 13. Per the recent discussion on llvm-dev (https://lists.llvm.org/pipermail/llvm-dev/2021-August/152305.html) the legacy pass manager will be unmaintained in LLVM 14 and removed entirely in LLVM 15. This switches us to use the new pass manager if LLVM >= 13 is used. It's possible to still use the old pass manager using `-Z new-llvm-pass-manager=no`.
2021-09-25Auto merge of #89030 - nbdd0121:box2, r=jonas-schievinkbors-213/+342
Introduce `Rvalue::ShallowInitBox` Polished version of #88700. Implements MCP rust-lang/compiler-team#460, and should allow #43596 to go forward. In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP. `NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient. Experiments in #88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.
2021-09-25Pin panic-in-drop=abort test to old pass managerNikita Popov-1/+8
2021-09-25Make expectation in panic-in-drop-abort.rs test more preciseNikita Popov-4/+2
Check whether a call/invoke of the function exists, but don't match a leftover function declaration. Also remove the CHECK-LABELs: In panic-in-drop=unwind mode the call will not actually be in either of those functions, so remove the restriction and look for any calls.
2021-09-25rustdoc: Don't show hidden trait methodsHirochika Matsumoto-0/+60
By skipping trait items whose attributes include `hidden`, we void showing such trait methods.
2021-09-25Auto merge of #87220 - petrochenkov:derivecfglimit2, r=Aaron1011bors-100/+75
Make `#[derive(A, B, ...)]` cfg-eval its input only for `A, B, ...` and stabilize `feature(macro_attributes_in_derive_output)` Stabilization report: https://github.com/rust-lang/rust/pull/87220#issuecomment-881923657 Closes #81119 r? `@Aaron1011`
2021-09-25Auto merge of #89230 - workingjubilee:rollup-1swktdq, r=workingjubileebors-0/+437
Rollup of 8 pull requests Successful merges: - #88893 (Add 1.56.0 release notes) - #89001 (Be explicit about using Binder::dummy) - #89072 (Avoid a couple of Symbol::as_str calls in cg_llvm ) - #89104 (Simplify scoped_thread) - #89208 ([rfc 2229] Drop fully captured upvars in the same order as the regular drop code) - #89210 (Add missing time complexities to linked_list.rs) - #89217 (Enable "generate-link-to-definition" option on rust tools docs as well) - #89221 (Give better error for `macro_rules! name!`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-25Bless testsGary Guo-213/+342
2021-09-24Auto merge of #86246 - FabianWolff:issue-83471, r=estebankbors-0/+115
Add basic checks for well-formedness of `fn`/`fn_mut` lang items This pull request fixes #83471. Lang items are never actually checked for well-formedness (#9307). This means that one can get an ICE quite easily, e.g. as follows: ```rust #![feature(lang_items)] #[lang = "fn"] trait MyFn { const call: i32 = 42; } fn main() { (|| 42)(); } ``` or this: ```rust #![feature(lang_items)] #[lang = "fn"] trait MyFn { fn call(i: i32, j: i32); } fn main() { (|| 42)(); } ``` Ideally, there should probably be a more comprehensive strategy for checking lang items for well-formedness, but for the time being, I have added some rudimentary well-formedness checks that prevent #83471 and similar issues.
2021-09-24Stabilize `feature(macro_attributes_in_derive_output)`Vadim Petrochenkov-107/+38
2021-09-24builtin_macros: Make #[derive(A, B, ...)] cfg-eval its input only for `A, B, ↵Vadim Petrochenkov-2/+46
...`
2021-09-24Rollup merge of #89221 - aDotInTheVoid:macro-error-1, r=estebankJubilee-0/+24
Give better error for `macro_rules! name!` r? ``@estebank`` ``@rustbot`` modify labels: +A-diagnostics +A-parser
2021-09-24Rollup merge of #89208 - wesleywiser:rfc_2229_droporder, r=nikomatsakisJubilee-0/+413
[rfc 2229] Drop fully captured upvars in the same order as the regular drop code Currently, with the new 2021 edition, if a closure captures all of the fields of an upvar, we'll drop those fields in the order they are used within the closure instead of the normal drop order (the definition order of the fields in the type). This changes that so we sort the captured fields by the definition order which causes them to drop in that same order as well. Fixes rust-lang/project-rfc-2229#42 r? `@nikomatsakis`
2021-09-24Make error message for malformed `fn`/`fn_mut` lang item more specificFabian Wolff-4/+4
2021-09-24Disable a spuriously failing testVadim Petrochenkov-0/+2
2021-09-24Disable some tests for platforms without registers.Adam Gemmell-188/+296
Update new tests to run on aarch64 platforms.
2021-09-24Update and add more testsWesley Wiser-65/+118
2021-09-24Add basic checks for well-formedness of `fn`/`fn_mut` lang itemsFabian Wolff-0/+115
2021-09-24Add inline asm! tests for aarch64Adam Gemmell-76/+2570
Enable tests which are largely architecture-independent on all supported platforms
2021-09-24Give better error for `macro_rules! name!`Nixon Enraght-Moony-0/+24
2021-09-24Auto merge of #88835 - FabianWolff:issue-88770, r=petrochenkovbors-0/+77
Fix error recovery in format macro parsing Fixes #88770. Basically, the assumption in the following comment is incorrect: https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/compiler/rustc_builtin_macros/src/format.rs#L167-L172 This is only true in the first iteration of the loop, when [`p.clear_expected_tokens()`](https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/compiler/rustc_builtin_macros/src/format.rs#L164) is called. In subsequent iterations, `p.expected_tokens` won't be empty, so `p.expect()` won't actually call `unexpected_try_recover()`: https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/compiler/rustc_parse/src/parser/mod.rs#L487-L498 Instead, it will call `expect_one_of()`, which _can_ recover and return `Ok()`. This PR handles this case to fix the ICE in #88770.
2021-09-24Auto merge of #89120 - In-line:remove_unneded_visible_parents_map, r=estebankbors-15/+16
Disable visible path calculation for PrettyPrinter in Ok path of compiler
2021-09-23Fix tidy and respond to some feedbackWesley Wiser-2/+2
2021-09-23Add known-tool-in-submodule testSamuel E. Moelius III-0/+14
The test currently fails. The next commit fixes it.
2021-09-24Auto merge of #89211 - workingjubilee:rollup-fj4eduk, r=workingjubileebors-2/+57
Rollup of 7 pull requests Successful merges: - #88612 (Add a better error message for #39364) - #89023 (Resolve issue : Somewhat confusing error with extended_key_value_attributes) - #89148 (Suggest `_` in turbofish if param will be inferred from fn argument) - #89171 (Run `no_core` rustdoc tests only on Linux) - #89176 (Change singular to plural) - #89184 (Temporarily rename int_roundings functions to avoid conflicts) - #89200 (Fix typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup