about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-04-18* Greatly improve the rustdoc search parser source codeGuillaume Gomez-106/+56
* Move all functions outside parseQuery
2022-04-18* If type filter is in quotes, throw an error.Guillaume Gomez-55/+34
* If there are generics, don't allow to have quotes.
2022-04-18Improve naming of "val" fieldGuillaume Gomez-25/+25
2022-04-18Add parser testsGuillaume Gomez-6/+643
2022-04-18Update testsGuillaume Gomez-31/+81
2022-04-18Auto merge of #95695 - the8472:vec-codegen-tests, r=Mark-Simulacrumbors-4/+63
Add codegen tests for additional cases where noop iterators get optimized away Optimizations have improved over time and now LLVM manages to optimize more in-place-collect noop-iterators to O(1) functions. This updates the codegen test to match. Many but not all cases reported in #79308 work now.
2022-04-17Add regression test for rustdoc duplicated blanket implsGuillaume Gomez-0/+14
2022-04-17Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkovbors-172/+673
Report undeclared lifetimes during late resolution. First step in https://github.com/rust-lang/rust/pull/91557 We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes. r? `@petrochenkov`
2022-04-17Bless nll test.Camille GILLOT-0/+106
2022-04-17Lint elided lifetimes in path on the AST.Camille GILLOT-14/+40
2022-04-17Bless tests.Camille GILLOT-158/+527
2022-04-17Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiaskobors-19/+9
Implement `core::ptr::Unique` on top of `NonNull` Removes the use `rustc_layout_scalar_valid_range_start` and some `unsafe` blocks.
2022-04-17Auto merge of #96002 - nnethercote:speed-up-Vec-clear-2, r=m-ou-sebors-11/+0
Speed up Vec::clear(). Currently it just calls `truncate(0)`. `truncate()` is (a) not marked as `#[inline]`, and (b) more general than needed for `clear()`. This commit changes `clear()` to do the work itself. This modest change was first proposed in rust-lang#74172, where the reviewer rejected it because there was insufficient evidence that `Vec::clear()`'s performance mattered enough to justify the change. Recent changes within rustc have made `Vec::clear()` hot within `macro_parser.rs`, so the change is now clearly worthwhile. Although it doesn't show wins on CI perf runs, this seems to be because they use PGO. But not all platforms currently use PGO. Also, local builds don't use PGO, and `truncate` sometimes shows up in an over-represented fashion in local profiles. So local profiling will be made easier by this change. Note that this will also benefit `String::clear()`, because it just calls `Vec::clear()`. Finally, the commit removes the `vec-clear.rs` codegen test. It was added in #52908. From before then until now, `Vec::clear()` just called `Vec::truncate()` with a zero length. The body of Vec::truncate() has changed a lot since then. Now that `Vec::clear()` is doing actual work itself, and not just calling `Vec::truncate()`, it's not surprising that its generated code includes a load and an icmp. I think it's reasonable to remove this test. r? `@m-ou-se`
2022-04-17Rollup merge of #96112 - niluxv:strict-provenance-lint-improvements, r=nagisaDylan DPC-4/+39
Strict provenance lint diagnostics improvements Use `multipart_suggestion` instead of `span_suggestion` and getting a snippet for the expression. Also don't suggest unnecessary parenthesis in `lossy_provenance_casts`. cc ``@estebank`` ``@rustbot`` label A-diagnostics
2022-04-17Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelixDylan DPC-52/+19
Stablize `const_extern_fn` for "Rust" and "C" All other ABIs are left unstable for now. cc #64926
2022-04-16Rollup merge of #95006 - tmiasko:thread-local-static, r=wesleywiserDylan DPC-0/+68
Reject `#[thread_local]` attribute on non-static items
2022-04-16Rollup merge of #94985 - dtolnay:constattr, r=pnkfelixDylan DPC-0/+9
Parse inner attributes on inline const block According to https://github.com/rust-lang/rust/pull/84414#issuecomment-826150936, inner attributes are intended to be supported *"in all containers for statements (or some subset of statements)"*. This PR adds inner attribute parsing and pretty-printing for inline const blocks (https://github.com/rust-lang/rust/issues/76001), which contain statements just like an unsafe block or a loop body. ```rust let _ = const { #![allow(...)] let x = (); x }; ```
2022-04-16Rollup merge of #96059 - euclio:doc-cfg, r=manishearth,guillaumegomezDylan DPC-23/+23
clarify doc(cfg) wording The current "This is supported" wording implies that it's possible to still use the item on other configurations, but in an unsupported way. Changing this to "Available" removes this ambiguity.
2022-04-16Rollup merge of #95887 - petrochenkov:doclink5, r=cjgillotDylan DPC-15/+20
resolve: Create dummy bindings for all unresolved imports Apparently such bindings weren't previously created for all unresolved imports, causing issues like https://github.com/rust-lang/rust/issues/95879. In this PR I'm trying to create such dummy bindings in a more centralized way by calling `import_dummy_binding` once for all imports in `finalize_imports`. Fixes https://github.com/rust-lang/rust/issues/95879.
2022-04-16Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPCbors-39/+566
Rollup of 9 pull requests Successful merges: - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used) - #94605 (Add missing links in platform support docs) - #95372 (make unaligned_references lint deny-by-default) - #95859 (Improve diagnostics for unterminated nested block comment) - #95961 (implement SIMD gather/scatter via vector getelementptr) - #96004 (Consider lifetimes when comparing types for equality in MIR validator) - #96050 (Remove some now-dead code that was only relevant before deaggregation.) - #96070 ([test] Add test cases for untested functions for BTreeMap) - #96099 (MaybeUninit array cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-16Improve `fuzzy_provenance_casts` lint diagnosticsniluxv-1/+1
Use `multipart_suggestion` instead of getting a snippet.
2022-04-16Improve `lossy_provenance_casts` lint diagnosticsniluxv-3/+38
Use `multipart_suggestion` and don't suggested unnecessary parenthesis.
2022-04-16Auto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, ↵bors-2855/+9319
r=estebank Better method call error messages Rebase/continuation of #71827 ~Based on #92360~ ~Based on #93118~ There's a decent description in #71827 that I won't copy here (for now at least) In addition to rebasing, I've tried to restore most of the original suggestions for invalid arguments. Unfortunately, this does make some of the errors a bit verbose. To fix this will require a bit of refactoring to some of the generalized error suggestion functions, and I just don't have the time to go into it right now. I think this is in a state that the error messages are overall better than before without a reduction in the suggestions given. ~I've tried to split out some of the easier and self-contained changes into separate commits (mostly in #92360, but also one here). There might be more than can be done here, but again just lacking time.~ r? `@estebank` as the original reviewer of #71827
2022-04-16Implementation for 65853Jack Huey-2855/+9319
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-16Rollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkovDylan DPC-0/+10
Consider lifetimes when comparing types for equality in MIR validator Closes #95978 .
2022-04-16Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubileeDylan DPC-0/+26
implement SIMD gather/scatter via vector getelementptr Fixes https://github.com/rust-lang/portable-simd/issues/271 However, I don't *really* know what I am doing here... Cc ``@workingjubilee`` ``@calebzulawski`` I didn't do anything for cranelift -- ``@bjorn3`` not sure if it's okay for that backend to temporarily break. I'm happy to cherry-pick a patch that adds cranelift support. :)
2022-04-16Rollup merge of #95859 - rainy-me:unterminated-nested-block-comment, ↵Dylan DPC-0/+25
r=petrochenkov Improve diagnostics for unterminated nested block comment close #95283 (This is my first time try to messing around with rust compiler and might get a lot of things wrong... :bow: )
2022-04-16Rollup merge of #95372 - RalfJung:unaligned_references, r=oli-obkDylan DPC-37/+488
make unaligned_references lint deny-by-default This lint has been warn-by-default for a year now (since https://github.com/rust-lang/rust/pull/82525), so I think it is time to crank it up a bit. Code that triggers the lint causes UB (without `unsafe`) when executed, so we really don't want people to write code like this.
2022-04-16Rollup merge of #93969 - bjorn3:codegen_backend_dep_info, r=pnkfelixDylan DPC-2/+17
Only add codegen backend to dep info if -Zbinary-dep-depinfo is used I am currently migrating the cg_clif build system from using a binary linked to the codegen backend as rustc replacement to passing `-Zcodegen-backend` instead. Without this PR this would force cargo to rebuild the sysroot on any change to the codegen backend even if I explicitly specify that I want it to be preserved, which would make development of cg_clif a lot slower. If you still want to have changes to the codegen backend invalidate the cargo build cache you can explicitly specify `-Zbinary-dep-depinfo`. cc ``@eddyb`` as the codegen backend was initially added to the depinfo for rust-gpu.
2022-04-16Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisabors-58/+115
Implement sym operands for global_asm! Tracking issue: #93333 This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are: - At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`. - At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails). - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`. - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to. - The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression. - At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details. - On Mach-O, all symbols have a leading underscore. - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall. - No mangling is needed on other platforms. r? `@nagisa` cc `@eddyb`
2022-04-16Update tests for sym support in global_asm!Amanieu d'Antras-58/+115
2022-04-15add codegen smoke testRalf Jung-0/+26
2022-04-15Rollup merge of #95749 - compiler-errors:ambig, r=oli-obkDylan DPC-25/+23
only downgrade selection Error -> Ambiguous if type error is in predicate That is, we don't care if there's a TypeError type in the ParamEnv. Fixes #95408
2022-04-15Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelixDylan DPC-5/+4
remove find_use_placement A more robust solution to finding where to place use suggestions was added in #94584. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it instead of calling `find_use_placement` Fixes #94941
2022-04-15Rollup merge of #94849 - ouz-a:master4, r=oli-obkDylan DPC-0/+27
Check var scope if it exist Fixes #92893. Added helper function to check the scope of a variable, if it doesn't have a scope call delay_span_bug, which avoids us trying to get a block/scope that doesn't exist. Had to increase `ROOT_ENTRY_LIMIT` was getting tidy error
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-8/+9
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-15Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwcoDylan DPC-53/+29
Stabilize `derive_default_enum` This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility). ```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-14make unaligned_reference warning visible in future compat reportRalf Jung-0/+450
2022-04-14make unaligned_references lint deny-by-defaultRalf Jung-37/+38
2022-04-14clarify doc(cfg) wordingAndy Russell-23/+23
The current "This is supported" wording implies that it's possible to still use the item on other configurations, but in an unsupported way. Changing this to "Available" removes this ambiguity.
2022-04-14Update issue-92893.stderrouz-a-0/+27
2022-04-14Update inline-into-box-place test outputEduardo Sánchez Muñoz-2/+2
2022-04-14Update output of cycle-cache-err-60010 testEduardo Sánchez Muñoz-1/+1
2022-04-14`Unique<T>` is now considered FFI-safeEduardo Sánchez Muñoz-16/+6
2022-04-14Auto merge of #95315 - compiler-errors:pointee-fix, r=pnkfelixbors-0/+19
when checking pointee metadata, canonicalize the `Sized` check Use `infcx.predicate_must_hold_modulo_regions` with a `Sized` obligation instead of just calling `ty.is_sized`, because the latter does not canonicalize region and type vars (and in the test case I added in this PR, there's a region var in the `ParamEnv`). Fixes #95311
2022-04-14refactor: change to use peekablerainy-me-1/+1
2022-04-13Add codegen tests for additional cases where noop iterators get optimized awayThe 8472-4/+63
Optimization have improved over time and now LLVM manages to optimize more in-place-collect noop-iterators to O(1) functions. This updates the codegen test to match.
2022-04-14improve diagnostics for unterminated nested block commentrainy-me-0/+25
2022-04-13Rollup merge of #95991 - PoorlyDefinedBehaviour:fix/issue_95898, r=fee1-deadDylan DPC-0/+24
fix: wrong trait import suggestion for T: The suggestion to bound `T` had an extra `:`. ```rust fn foo<T:>(t: T) { t.clone(); } ``` ``` error[E0599]: no method named `clone` found for type parameter `T` in the current scope --> src/lib.rs:2:7 | 2 | t.clone(); | ^^^^^ method not found in `T` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `clone`, perhaps you need to restrict type parameter `T` with it: | 1 | fn foo<T: Clone:>(t: T) { | ~~~~~~~~ ``` Fixes: #95898
2022-04-13Rollup merge of #93217 - willcrichton:example-analyzer, r=GuillaumeGomezDylan DPC-3/+2
Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers This PR improves a few aspects of the scrape examples feature in Rustdoc. * Only function names and not the full call expression are highlighted. * For call-sites with multiline arguments, the minimized code viewer will scroll to the top of the call-site rather than the middle if the argument is larger than the viewer size, ensuring that the function name is visible. * This fixes an issue where the line numbers column had a visible x-scroll bar. r? `@GuillaumeGomez`