about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-11-17Rollup merge of #117892 - estebank:fat-arrow-typo, r=compiler-errorsMatthias Krüger-0/+39
Detect more `=>` typos Handle and recover `match expr { pat >= { arm } }`.
2023-11-16Remove option_payload_ptr; redundant to offset_ofGeorge Bateman-108/+0
2023-11-16Fix code indentationEsteban Küber-1/+1
2023-11-16Handle attempts to have multiple `cfg`d tail expressionsEsteban Küber-0/+73
When encountering code that seems like it might be trying to have multiple tail expressions depending on `cfg` information, suggest alternatives that will success to parse. ```rust fn foo() -> String { #[cfg(feature = "validation")] [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() #[cfg(not(feature = "validation"))] String::new() } ``` ``` error: expected `;`, found `#` --> $DIR/multiple-tail-expr-behind-cfg.rs:5:64 | LL | #[cfg(feature = "validation")] | ------------------------------ only `;` terminated statements or tail expressions are allowed after this attribute LL | [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() | ^ expected `;` here LL | #[cfg(not(feature = "validation"))] | - unexpected token | help: add `;` here | LL | [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>(); | + help: alternatively, consider surrounding the expression with a block | LL | { [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() } | + + help: it seems like you are trying to provide different expressions depending on `cfg`, consider using `if cfg!(..)` | LL ~ if cfg!(feature = "validation") { LL ~ [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() LL ~ } else if cfg!(not(feature = "validation")) { LL ~ String::new() LL + } | ``` Fix #106020.
2023-11-16Add more APIs and fix `Instance::body`Celina G. Val-11/+21
Add more APIs to retrieve information about types, and add more instance resolution options. Make `Instance::body()` return an Option<Body>, since not every instance might have an available body. For example, foreign instances, virtual instances, dependencies.
2023-11-16Auto merge of #116097 - jackh726:higher-ranked-lifetime-error-backup, ↵bors-0/+26
r=compiler-errors Try to use approximate placeholder regions when outputting an AscribeUserType error in borrowck Fixes #114866 Hi from GOSIM :)
2023-11-16address review commentEsteban Küber-5/+13
2023-11-16recover primary span labelEsteban Küber-102/+118
2023-11-16Suggest `unwrap()` on field not found for `Result`/`Option`Esteban Küber-16/+149
When encountering a `Result<T, _>` or `Option<T>` where `T` has a field that's being accessed, suggest calling `.unwrap()` to get to the field.
2023-11-16Suggest field typo through derefsEsteban Küber-59/+94
Take into account implicit dereferences when suggesting fields. ``` error[E0609]: no field `longname` on type `Arc<S>` --> $DIR/suggest-field-through-deref.rs:10:15 | LL | let _ = x.longname; | ^^^^^^^^ help: a field with a similar name exists: `long_name` ``` CC https://github.com/rust-lang/rust/issues/78374#issuecomment-719564114
2023-11-16Add test for parens around match arm pattern and conditionEsteban Küber-0/+63
2023-11-16Smaller span for unnessary `mut` suggestionEsteban Küber-6/+6
2023-11-16Move tests to subdirectoryEsteban Küber-0/+0
2023-11-16Suggest replacing `Self` with the right type on type errorEsteban Küber-0/+4
When encountering a type error caused by the use of `Self`, suggest using the actual type name instead. ``` error[E0308]: mismatched types --> $DIR/struct-path-self-type-mismatch.rs:13:9 | LL | impl<T> Foo<T> { | - ------ this is the type of the `Self` literal | | | found type parameter LL | fn new<U>(u: U) -> Foo<U> { | - ------ expected `Foo<U>` because of return type | | | expected type parameter LL | / Self { LL | | LL | | inner: u LL | | LL | | } | |_________^ expected `Foo<U>`, found `Foo<T>` | = note: expected struct `Foo<U>` found struct `Foo<T>` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters help: use the type name directly | LL | Foo::<U> { | ~~~~~~~~ ``` Fix #76086.
2023-11-16Point at impl self ty on type error involving `Self`Esteban Küber-1/+3
When encountering a type error involving a `Self` literal, point at the self type of the enclosing `impl`. CC #76086.
2023-11-16More detail when expecting expression but encountering bad macro argumentEsteban Küber-10/+56
Partially address #71039.
2023-11-16ignore implied bounds with placeholdersAli MJ Al-Nasrawy-0/+71
2023-11-16When using existing fn as module, don't claim it doesn't existEsteban Küber-3/+3
Tweak wording of module not found in resolve, when the name exists but belongs to a non-`mod` item. Fix #81232.
2023-11-15Bump cfg(bootstrap)sMark Rousskov-4/+2
2023-11-15Auto merge of #117878 - gavinleroy:proper-depth-check, r=lcnrbors-0/+2
Fix depth check in ProofTreeVisitor. The hack to cutoff overflows and cycles in the new trait solver was incorrect. We want to inspect everything with depth [0..10]. This fix exposed a previously unseen bug, which caused the compiler to ICE when invoking `trait_ref` on a non-assoc type projection. I simply added the guard in the `AmbiguityCausesVisitor`, and updated the expected output for the `auto-trait-coherence` test which now includes the extra note: ```text | = note: upstream crates may add a new impl of trait `std::marker::Send` for type `OpaqueType` in future versions ``` r? `@lcnr`
2023-11-15Auto merge of #116555 - paulmenage:llvm-module-flag, r=wesleywiserbors-0/+7
Add -Z llvm_module_flag Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-15Auto merge of #117908 - lcnr:region-kind-rename, r=BoxyUwUbors-7/+7
finish `RegionKind` renaming second step of https://github.com/rust-lang/types-team/issues/95 continues the work from #117876. While working on this and I encountered a bunch of further cleanup which I'll either open a tracking issue for or will do in a separate PR: - rewrite the `RegionKind` docs, they still talk about `ReEmpty` and are generally out of date - rename `DescriptionCtx` to `DescriptionCtxt` - what is `CheckRegions::Bound`? - `collect_late_bound_regions` et al - `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`? - `EraseEarlyRegions` visitor should be removed, feels duplicate r? `@BoxyUwU`
2023-11-15Auto merge of #117848 - compiler-errors:method-ambiguity-no-rcvr, r=TaKO8Kibors-0/+46
Don't expect a rcvr in `print_disambiguation_help` We don't necessarily have a receiver when we are both accidentally using the `.` operator *AND* we have more than one ambiguous method candidate. Fixes #117728
2023-11-15discard invalid spans in external blocksbohan-0/+67
2023-11-15Auto merge of #117517 - klinvill:smir-projections, r=ouz-abors-0/+173
Add richer structure for Stable MIR Projections Resolves https://github.com/rust-lang/project-stable-mir/issues/49. Projections in Stable MIR are currently just strings. This PR replaces that representation with a richer structure, namely projections become vectors of `ProjectionElem`s, just as in MIR. The `ProjectionElem` enum is heavily based off of the MIR `ProjectionElem`. This PR is a draft since there are several outstanding issues to resolve, including: - How should `UserTypeProjection`s be represented in Stable MIR? In MIR, the projections are just a vector of `ProjectionElem<(),()>`, meaning `ProjectionElem`s that don't have Local or Type arguments (for `Index`, `Field`, etc. objects). Should `UserTypeProjection`s be represented this way in Stable MIR as well? Or is there a more user-friendly representation that wouldn't drag along all the `ProjectionElem` variants that presumably can't appear? - What is the expected behavior of a `Place`'s `ty` function? Should it resolve down the chain of projections so that something like `*_1.f` would return the type referenced by field `f`? - Tests should be added for `UserTypeProjection`
2023-11-15Auto merge of #117359 - tmiasko:call-def, r=cjgillotbors-0/+30
Fix def-use check for call terminators Fixes #117331.
2023-11-14Rollup merge of #117893 - sjwang05:issue-52544-take-1, r=wesleywiserMatthias Krüger-0/+30
Suggest dereferencing the LHS for binops such as `&T == T` Fixes #52544
2023-11-14Rollup merge of #117686 - compiler-errors:gen-body, r=wesleywiserMatthias Krüger-0/+25
Build pre-coroutine-transform coroutine body on error I was accidentally building the post-transform coroutine body, rather than the pre-transform coroutine body. There's no pinning expected here yet, and the return type isn't yet transformed into `CoroutineState`. Fixes #117670
2023-11-14Rollup merge of #116244 - estebank:issue-73497, r=b-naberMatthias Krüger-1/+13
Apply structured suggestion that allows test to work since 1.64 Close #73497.
2023-11-14Fix def-use check for call terminatorsTomasz Miąsko-0/+30
2023-11-14review + fix CIlcnr-1/+1
2023-11-14finish `RegionKind` renamelcnr-6/+6
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-14Add guard checking for associated types before computing intercrate ↵Gavin Gray-0/+2
ambiguity of projections. Bless test with more specific notes on the ambiguity cause.
2023-11-14Auto merge of #117330 - tmiasko:custom-mir-cleanup-blocks, r=cjgillotbors-25/+182
Custom MIR: Support cleanup blocks Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-14Custom MIR: Support cleanup blocksTomasz Miąsko-25/+182
Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-14Auto merge of #117856 - estebank:issue-66023, r=compiler-errorsbors-0/+24
Always point at index span on index obligation failure Use more targetted span for index obligation failures by rewriting the obligation cause span. CC #66023
2023-11-14Detect more `=>` typosEsteban Küber-0/+39
Handle and recover `match expr { pat >= { arm } }`.
2023-11-13Suggest lhs deref for binopssjwang05-0/+30
2023-11-14Recover `dyn` and `impl` after `for<...>`Michael Goulet-0/+35
2023-11-13Rollup merge of #117879 - durin42:nneg-zext, r=nikicMatthias Krüger-2/+2
tests: update check for inferred nneg on zext This was broken by upstream llvm/llvm-project@dc6d0773960c664eee12a1ed871fad5c81a20a12. It's easy enough to use a regex match to support both, so we do that. r? `@nikic` `@rustbot` label: +llvm-main
2023-11-13Rollup merge of #117695 - ↵Matthias Krüger-0/+22
3tilley:prioritise-unwrap-expect-over-last-method-call, r=compiler-errors Reorder checks to make sure potential missing expect on Option/Result… … runs before removing last method call Fixes #117669
2023-11-13review comments: more targeted span setting approachEsteban Küber-0/+4
2023-11-13Auto merge of #117881 - TaKO8Ki:rollup-n7jtmgj, r=TaKO8Kibors-12/+20
Rollup of 5 pull requests Successful merges: - #117737 (Remove `-Zkeep-hygiene-data`.) - #117830 (Small improvements in object lifetime default code) - #117858 (Compute layout with spans for better cycle errors in coroutines) - #117863 (Remove some unused stuff from `rustc_index`) - #117872 (Cranelift isn't available on non-nightly channels) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-14Rollup merge of #117858 - compiler-errors:span, r=lcnrTakayuki Maeda-12/+20
Compute layout with spans for better cycle errors in coroutines Split out from #117703, this PR at least gives us a nicer span to point at when we hit a cycle error in coroutine layout cycles.
2023-11-13tests: update check for inferred nneg on zextAugie Fackler-2/+2
This was broken by upstream llvm/llvm-project@dc6d0773960c664eee12a1ed871fad5c81a20a12. It's easy enough to use a regex match to support both, so we do that. r? @nikic @rustbot label: +llvm-main
2023-11-13Auto merge of #117876 - lcnr:region-kind-rename, r=BoxyUwUbors-18/+18
`ReLateBound` -> `ReBound` first step of https://github.com/rust-lang/types-team/issues/95 already fairly large xx there's some future work here I intentionally did not contribute as part of this PR, from my notes: - `DescriptionCtx` to `DescriptionCtxt` - what is `CheckRegions::Bound`? - `collect_late_bound_regions` et al - `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`? - `EraseEarlyRegions` should be removed, feels duplicate r? `@BoxyUwU`
2023-11-13rename `ReLateBound` to `ReBound`lcnr-18/+18
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
2023-11-13Auto merge of #117811 - MU001999:master, r=lcnrbors-0/+28
Turn assert_eq into a delay_span_bug Fixes #117789
2023-11-13Auto merge of #117827 - Zalathar:bogus-macro-name-span, r=davidtwcobors-0/+90
coverage: Avoid creating malformed macro name spans This is a workaround for #117788. It detects a particular scenario where we would create malformed coverage spans that might cause `llvm-cov` to immediately exit with an error, preventing the user from processing coverage reports. The patch has been kept as simple as possible so that it's trivial to backport to beta (or stable) if desired. --- The `maybe_push_macro_name_span` method is trying to detect macro invocations, so that it can split a span into two parts just after the `!` of the invocation. Under some circumstances (probably involving nested macros), it gets confused and produces a span that is larger than the original span, and possibly extends outside its enclosing function and even into an adjacent file. In extreme cases, that can result in malformed coverage mappings that cause `llvm-cov` to fail. For now, we at least want to detect these egregious cases and avoid them, so that coverage reports can still be produced.
2023-11-13Compute layout with spans for better cycle errors in coroutinesMichael Goulet-12/+20