about summary refs log tree commit diff
path: root/tests/ui
AgeCommit message (Collapse)AuthorLines
2023-10-24Rollup merge of #117092 - matthewjasper:attribute-validation, r=compiler-errorsMatthias Krüger-0/+95
Add regression test for #117058 The new behavior in nightly is correct, so add a test that it stays this way. Closes #117058
2023-10-24Auto merge of #116773 - dtolnay:validatestable, r=compiler-errorsbors-64/+74
Validate `feature` and `since` values inside `#[stable(…)]` Previously the string passed to `#[unstable(feature = "...")]` would be validated as an identifier, but not `#[stable(feature = "...")]`. In the standard library there were `stable` attributes containing the empty string, and kebab-case string, neither of which should be allowed. Pre-existing validation of `unstable`: ```rust // src/lib.rs #![allow(internal_features)] #![feature(staged_api)] #![unstable(feature = "kebab-case", issue = "none")] #[unstable(feature = "kebab-case", issue = "none")] pub struct Struct; ``` ```console error[E0546]: 'feature' is not an identifier --> src/lib.rs:5:1 | 5 | #![unstable(feature = "kebab-case", issue = "none")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` For an `unstable` attribute, the need for an identifier is obvious because the downstream code needs to write a `#![feature(...)]` attribute containing that identifier. `#![feature(kebab-case)]` is not valid syntax and `#![feature(kebab_case)]` would not work if that is not the name of the feature. Having a valid identifier even in `stable` is less essential but still useful because it allows for informative diagnostic about the stabilization of a feature. Compare: ```rust // src/lib.rs #![allow(internal_features)] #![feature(staged_api)] #![stable(feature = "kebab-case", since = "1.0.0")] #[stable(feature = "kebab-case", since = "1.0.0")] pub struct Struct; ``` ```rust // src/main.rs #![feature(kebab_case)] use repro::Struct; fn main() {} ``` ```console error[E0635]: unknown feature `kebab_case` --> src/main.rs:3:12 | 3 | #![feature(kebab_case)] | ^^^^^^^^^^ ``` vs the situation if we correctly use `feature = "snake_case"` and `#![feature(snake_case)]`, as enforced by this PR: ```console warning: the feature `snake_case` has been stable since 1.0.0 and no longer requires an attribute to enable --> src/main.rs:3:12 | 3 | #![feature(snake_case)] | ^^^^^^^^^^ | = note: `#[warn(stable_features)]` on by default ```
2023-10-24Add regression test for #117058Matthew Jasper-0/+95
2023-10-24Auto merge of #116435 - compiler-errors:re-erased, r=lcnrbors-0/+51
Handle `ReErased` in responses in new solver There are legitimate cases in the compiler where we return `ReErased` for lifetimes that are uncaptured in the hidden type of an opaque. For example, in the test committed below, we ignore ignore the bivariant lifetimes of an opaque when it's inferred as the hidden type of another opaque. This may result in a `type_of(Opaque)` call returning a type that references `ReErased`. Let's handle this gracefully in the new solver. Also added a `rustc_hidden_type_of_opaques` attr to print hidden types. This seems useful for opaques. r? lcnr
2023-10-24Introduce `-C instrument-coverage=branch` to gate branch coverageArpad Borsos-4/+4
This flag has to be used in combination with `-Zunstable-options`, and is added in advance of adding branch coverage instrumentation.
2023-10-24Augment `stringify.rs` test some more.Nicholas Nethercote-40/+38
By making some case more complex, adding some new cases, tweaking formatting, and removing unnecessary `rustfmt` attributes.
2023-10-24Augment `stringify.rs` test.Nicholas Nethercote-2/+47
By adding tests (or placeholders, or comments) for missing AST variants.
2023-10-24Redo `stringify.rs` test.Nicholas Nethercote-539/+412
Currently it only tests AST pretty-printing. This commit changes it to run every example through both AST pretty-printing and TokenStream pretty-printing. This makes it clear where there two pretty-printing approaches produce different results.
2023-10-24tests/ui/abi/compatibility: Set min-llvm-version to 17 for LoongArch64WANG Rui-0/+1
2023-10-24tests: Add features-gate for LoongArchWANG Rui-1/+2
2023-10-24Auto merge of #116300 - cjgillot:split-move, r=petrochenkovbors-11/+11
Separate move path tracking between borrowck and drop elaboration. The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration. The 2 first commits are cleanups. The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more. The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-23nitsMichael Goulet-0/+12
2023-10-23coherence doesn't like region constraintsMichael Goulet-3/+37
2023-10-23Consider regionsMichael Goulet-0/+35
2023-10-23Make things work by using the new solverMichael Goulet-15/+9
2023-10-23Auto merge of #117103 - matthiaskrgr:rollup-96zuuom, r=matthiaskrgrbors-0/+33
Rollup of 6 pull requests Successful merges: - #107159 (rand use getrandom for freebsd (available since 12.x)) - #116859 (Make `ty::print::Printer` take `&mut self` instead of `self`) - #117046 (return unfixed len if pat has reported error) - #117070 (rustdoc: wrap Type with Box instead of Generics) - #117074 (Remove smir from triage and add me to stablemir) - #117086 (Update .mailmap to promote my livename) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-23When expecting closure argument but finding block provide suggestionEsteban Küber-0/+69
Detect if there is a potential typo where the `{` meant to open the closure body was written before the body. ``` error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<usize>` --> $DIR/ruby_style_closure_successful_parse.rs:3:31 | LL | let p = Some(45).and_then({|x| | ______________________--------_^ | | | | | required by a bound introduced by this call LL | | 1 + 1; LL | | Some(x * 2) | | ----------- this tail expression is of type `Option<usize>` LL | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<usize>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<usize>` note: required by a bound in `Option::<T>::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL help: you might have meant to open the closure body instead of placing a closure within a block | LL - let p = Some(45).and_then({|x| LL + let p = Some(45).and_then(|x| { | ``` Detect the potential typo where the closure header is missing. ``` error[E0277]: expected a `FnOnce<(&bool,)>` closure, found `bool` --> $DIR/block_instead_of_closure_in_arg.rs:3:23 | LL | Some(true).filter({ | _________________------_^ | | | | | required by a bound introduced by this call LL | |/ if number % 2 == 0 { LL | || number == 0 LL | || } else { LL | || number != 0 LL | || } | ||_________- this tail expression is of type `bool` LL | | }); | |______^ expected an `FnOnce<(&bool,)>` closure, found `bool` | = help: the trait `for<'a> FnOnce<(&'a bool,)>` is not implemented for `bool` note: required by a bound in `Option::<T>::filter` --> $SRC_DIR/core/src/option.rs:LL:COL help: you might have meant to create the closure instead of a block | LL | Some(true).filter(|_| { | +++ ``` Partially address #27300.
2023-10-23Rollup merge of #117046 - bvanjoi:fix-116186, r=oli-obkMatthias Krüger-0/+33
return unfixed len if pat has reported error - Fixes #116186 - Fixes #113021 This issue arises due to the creation of a fixed-length pattern, as a result of the mir body corruption. The corruption taints `tcx.eval_to_allocation_raw`, causing it to return `AlreadyReported`. Consequently, this prevents `len.try_eval_target_usize` from evaluating correctly and returns `None`. Lastly, it results in the return of `[usize; min_len]`. To rectify this issue, my approach is that to return unfixed when encountering `ErrorHandled::Reported`. Additionally, in instances of `ErrorHandled::TooGeneric`, the previous logic has been reinstated.
2023-10-23Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkovbors-24/+120
report `unused_import` for empty reexports even it is pub Fixes #116032 An easy fix. r? `@petrochenkov` (Discovered this issue while reviewing #115993.)
2023-10-23Let's see what those opaque types actually areMichael Goulet-1/+37
2023-10-23Handle ReErased in responses in new solverMichael Goulet-0/+15
2023-10-23Update `since` stability attributes in testsDavid Tolnay-61/+71
2023-10-23Fix stable feature names in testsDavid Tolnay-6/+6
2023-10-23Rollup merge of #117040 - Zalathar:instrument-coverage-ui, r=cjgillotMatthias Krüger-0/+39
coverage: Add UI tests for values accepted by `-Cinstrument-coverage` I wanted to clean up the code in `parse_instrument_coverage`, but it occurred to me that we currently don't have any UI tests for the various stable and unstable values supported by this flag. --- Normally it might be overkill to individually test all the different variants of `on`/`off`, but in this case the parsing of those values is mixed in with some other custom code, so I think it's worthwhile being thorough.
2023-10-23Rollup merge of #116960 - lqd:applied-member-constraints-scope, r=matthewjasperMatthias Krüger-0/+105
Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only The location-insensitive analysis considered loans to escape if there were member constraints, which makes *some* sense for scopes and matches the scopes that NLL computes on all the tests. However, polonius and NLLs differ on the fuzzed case #116657, where an SCC has member constraints but no applied ones (and is kinda surprising). The existing UI tests with member constraints impacting scopes all have some constraint applied. This PR changes the location-insensitive analysis to consider a loan to escape if there are applied member constraints, and for extra paranoia/insurance via fuzzing and crater: actually checks the constraint's min choice is indeed a universal region as we expect. (This could be turned into a `debug_assert` and early return as a slight optimization after these periods of verification) The 4 UI tests where member constraints are meaningful for computing scopes still pass obviously, and this also fixes #116657. r? `@matthewjasper`
2023-10-23return unfixed len if pat has reported errorbohan-0/+33
2023-10-23Merge associated types with the other alias typesOli Scherer-17/+17
2023-10-23Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillotbors-168/+142
Avoid a `track_errors` by bubbling up most errors from `check_well_formed` I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them. This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`) cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-23coverage: Add UI tests for values accepted by `-Cinstrument-coverage`Zalathar-0/+39
2023-10-23Auto merge of #115324 - francorbacho:master, r=davidtwcobors-0/+146
Suggest removing redundant arguments in format!() Closes #105225. This is also a follow-up to #105635, which seems to have become stale. r? `@estebank`
2023-10-22use visibility to check unused imports and delete some stmtsbohan-24/+120
2023-10-22Auto merge of #116256 - apekros:issue-114912, r=cjgillotbors-0/+33
Add test for rust-lang#114912 Closes #114912
2023-10-22Rollup merge of #117034 - Nadrieril:fix-117033, r=cjgillotMatthias Krüger-0/+7
Don't crash on empty match in the `nonexhaustive_omitted_patterns` lint Oops Fixes https://github.com/rust-lang/rust/issues/117033
2023-10-21Fix #117033Nadrieril-0/+7
2023-10-21Rollup merge of #116992 - estebank:issue-69492, r=oli-obkMatthias Krüger-0/+10
Mention the syntax for `use` on `mod foo;` if `foo` doesn't exist Newcomers might get confused that `mod` is the only way of defining scopes, and that it can be used as if it were `use`. Fix #69492.
2023-10-21Mention the syntax for `use` on `mod foo;` if `foo` doesn't existEsteban Küber-0/+10
Newcomers might get confused that `mod` is the only way of defining scopes, and that it can be used as if it were `use`. Fix #69492.
2023-10-21on unresolved import disambiguate suggested path if it would collideLeón Orell Valerian Liehr-6/+115
2023-10-21Auto merge of #117020 - matthiaskrgr:rollup-cg62m4h, r=matthiaskrgrbors-5/+34
Rollup of 3 pull requests Successful merges: - #106601 (Suggest `;` after bare `match` expression E0308) - #116975 (Move `invalid-llvm-passes` test to `invalid-compile-flags` folder) - #117019 (fix spans for removing `.await` on `for` expressions) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-21Rollup merge of #117019 - lukas-code:for-await, r=compiler-errorsMatthias Krüger-1/+19
fix spans for removing `.await` on `for` expressions We need to use a span with the outer syntax context of a desugared `for` expression to join it with the `.await` span. fixes https://github.com/rust-lang/rust/issues/117014
2023-10-21Rollup merge of #116975 - ojeda:move-invalid-test, r=NilstriebMatthias Krüger-0/+0
Move `invalid-llvm-passes` test to `invalid-compile-flags` folder Nowadays there is an `invalid-compile-flags` folder, thus move this one there.
2023-10-21Rollup merge of #106601 - estebank:match-semi, r=cjgillotMatthias Krüger-4/+15
Suggest `;` after bare `match` expression E0308 Fix #72634.
2023-10-21fix spans for removing `.await` on `for` expressionsLukas Markeffsky-1/+19
2023-10-21Auto merge of #116734 - Nadrieril:lint-per-column, r=cjgillotbors-110/+232
Lint `non_exhaustive_omitted_patterns` by columns This is a rework of the `non_exhaustive_omitted_patterns` lint to make it more consistent. The intent of the lint is to help consumers of `non_exhaustive` enums ensure they stay up-to-date with all upstream variants. This rewrite fixes two cases we didn't handle well before: First, because of details of exhaustiveness checking, the following wouldn't lint `Enum::C` as missing: ```rust match Some(x) { Some(Enum::A) => {} Some(Enum::B) => {} _ => {} } ``` Second, because of the fundamental workings of exhaustiveness checking, the following would treat the `true` and `false` cases separately and thus lint about missing variants: ```rust match (true, x) { (true, Enum::A) => {} (true, Enum::B) => {} (false, Enum::C) => {} _ => {} } ``` Moreover, it would correctly not lint in the case where the pair is flipped, because of asymmetry in how exhaustiveness checking proceeds. A drawback is that it no longer makes sense to set the lint level per-arm. This will silently break the lint for current users of it (but it's behind a feature gate so that's ok). The new approach is now independent of the exhaustiveness algorithm; it's a separate pass that looks at patterns column by column. This is another of the motivations for this: I'm glad to move it out of the algorithm, it was akward there. This PR is almost identical to https://github.com/rust-lang/rust/pull/111651. cc `@eholk` who reviewed it at the time. Compared to then, I'm more confident this is the right approach.
2023-10-21Do not report errors from move path builder.Camille GILLOT-11/+11
2023-10-21Rollup merge of #116995 - estebank:issue-69944, r=compiler-errorsMatthias Krüger-1/+6
Point at assoc fn definition on type param divergence When the number of type parameters in the associated function of an impl and its trait differ, we now *always* point at the trait one, even if it comes from a foreign crate. When it is local, we point at the specific params, when it is foreign, we point at the whole associated item. Fix #69944.
2023-10-21Rollup merge of #116990 - estebank:issue-68445, r=cjgillotMatthias Krüger-0/+4
Mention `into_iter` on borrow errors suggestions when appropriate If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`. Fix #68445.
2023-10-21Rollup merge of #116961 - estebank:issue-60164, r=oli-obkMatthias Krüger-0/+24
Typo suggestion to change bindings with leading underscore When encountering a binding that isn't found but has a typo suggestion for a binding with a leading underscore, suggest changing the binding definition instead of the use place. Fix #60164.
2023-10-21Rollup merge of #116911 - estebank:issue-85378, r=oli-obkMatthias Krüger-0/+44
Suggest relaxing implicit `type Assoc: Sized;` bound Fix #85378.
2023-10-20Point at assoc fn definition on type param divergenceEsteban Küber-1/+6
When the number of type parameters in the associated function of an impl and its trait differ, we now *always* point at the trait one, even if it comes from a foreign crate. When it is local, we point at the specific params, when it is foreign, we point at the whole associated item. Fix #69944.
2023-10-20Rename `generator` folderOli Scherer-0/+0