about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-11-29rustdoc-search: allow `:: ` and ` ::`Michael Howell-18/+57
This restriction made sense back when spaces separated function parameters, but now that they separate path components, there's no real ambiguity any more. Additionally, the Rust language allows it.
2023-11-29Rollup merge of #118426 - aDotInTheVoid:const-wat, r=compiler-errors,cjgillotMatthias Krüger-0/+67
ConstProp: Correctly remove const if unknown value assigned to it. Closes #118328 The problematic sequence of MIR is: ```rust _1 = const 0_usize; _1 = const _; // This is an associated constant we can't know before monomorphization. _0 = _1; ``` 1. When `ConstProp::visit_assign` happens on `_1 = const 0_usize;`, it records that `0x0usize` is the value for `_1`. 2. Next `visit_assign` happens on `_1 = const _;`. Because the rvalue `.has_param()`, it can't be const evaled. 3. Finaly, `visit_assign` happens on `_0 = _1;`. Here it would think the value of `_1` was `0x0usize` from step 1. The solution is to remove consts when checking the RValue fails, as they may have contained values that should now be invalidated, as that local was overwritten. This should probably be back-ported to beta. Stable is more iffy, as it's gone unidentified since 1.70, so I only think it's worthwhile if there's another reason for a 1.74.1 release anyway.
2023-11-29Rollup merge of #118333 - eduardosm:print-missing-target-features, r=est31Matthias Krüger-47/+129
Print list of missing target features when calling a function with target features outside an unsafe block Fixes https://github.com/rust-lang/rust/issues/108680 Supersedes https://github.com/rust-lang/rust/pull/109710. I used the same wording for the messages, but the implementation is different. r? `@est31`
2023-11-29Rollup merge of #118191 - estebank:let-chain-typo, r=compiler-errorsMatthias Krüger-10/+23
Suggest `let` or `==` on typo'd let-chain When encountering a bare assignment in a let-chain, suggest turning the assignment into a `let` expression or an equality check. ``` error: expected expression, found `let` statement --> $DIR/bad-if-let-suggestion.rs:5:8 | LL | if let x = 1 && i = 2 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions help: you might have meant to continue the let-chain | LL | if let x = 1 && let i = 2 {} | +++ help: you might have meant to compare for equality | LL | if let x = 1 && i == 2 {} | + ```
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-0/+221
Add `never_patterns` feature gate This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment. `@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgrbors-51/+32
Rollup of 7 pull requests Successful merges: - #116839 (Implement thread parking for xous) - #118265 (remove the memcpy-on-equal-ptrs assumption) - #118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`) - #118394 (Remove HIR opkinds) - #118398 (Add proper cfgs in std) - #118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context) - #118422 (Fix coroutine validation for mixed panic strategy) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-29Rollup merge of #118429 - cuviper:its-arguments, r=compiler-errorsMatthias Krüger-2/+2
Fix a typo in a `format_args!` note
2023-11-29Rollup merge of #118413 - chenyukang:yukang-fix-118145-unwrap-for-shorthand, ↵Matthias Krüger-0/+303
r=compiler-errors Fix the issue of suggesting unwrap/expect for shorthand field Fixes #118145
2023-11-29Rollup merge of #118342 - compiler-errors:macro-generic-bang, r=estebankMatthias Krüger-0/+13
Dont suggest `!` for path in function call if it has generic args Fixes #118335
2023-11-29Rollup merge of #118422 - tmiasko:mix, r=compiler-errorsMatthias Krüger-0/+24
Fix coroutine validation for mixed panic strategy Validation introduced in #113124 allows `UnwindAction::Continue` and `TerminatorKind::Resume` to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates. Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies. Avoid the problem by executing `AbortUnwindingCalls` along with the validation. Fixes #116953.
2023-11-29Rollup merge of #118419 - compiler-errors:await-span2, r=cjgillotMatthias Krüger-51/+8
Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context This PR does 2 things: 1. Refuses to lower `.await` or `yield` when we are outside of the right coroutine context for the operator. Instead, we lower to `hir::ExprKind::Err`, to silence subsequent redundant errors. 2. Reworks a bit of the span tracking in `LoweringContext` to fix a bad span when we have something like `let x = [0; async_fn().await]` where the `await` is inside of an anon const. The span for the "item" still kinda sucks, since it overlaps with the `await` span, but at least it's accurate.
2023-11-29Add `never_patterns` feature gateNadrieril-0/+221
2023-11-28Fix a typo in a `format_args!` noteJosh Stone-2/+2
2023-11-29Auto merge of #114841 - bvanjoi:fix-114814, r=cuviperbors-4/+81
add track_caller for arith ops Fixes #114814 `#[track_caller]` is works, r? `@scottmcm`
2023-11-29More fix on mismatched type suggestion for shorthand fieldsyukang-0/+234
2023-11-28Rename and add another testAlona Enraght-Moony-3/+30
2023-11-28Auto merge of #118412 - matthiaskrgr:rollup-ghzhti2, r=matthiaskrgrbors-1/+1
Rollup of 6 pull requests Successful merges: - #118193 (Add missing period in `std::process::Command` docs) - #118222 (unify read_to_end and io::copy impls for reading into a Vec) - #118323 (give dev-friendly error message for incorrect config profiles) - #118378 (Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto) - #118399 (Clean dead codes in miri) - #118410 (update test for new LLVM 18 codegen) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-28ConstProp: Remove const when rvalue check fails.Alona Enraght-Moony-2/+1
2023-11-28Fix coroutine validation for mixed panic strategyTomasz Miąsko-0/+24
Validation introduced in #113124 allows UnwindAction::Continue and TerminatorKind::Resume to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates. Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies. Avoid the problem by executing AbortUnwindingCalls along with the validation.
2023-11-28thir-unsafeck: print list of missing target features when calling a function ↵Eduardo Sánchez Muñoz-13/+65
with target features outside an unsafe block
2023-11-28Fix spans for bad await in inline constMichael Goulet-47/+8
2023-11-28Eagerly return ExprKind::Err on yield/await in wrong coroutine contextMichael Goulet-4/+0
2023-11-28Suggest `let` or `==` on typo'd let-chainEsteban Küber-10/+23
When encountering a bare assignment in a let-chain, suggest turning the assignment into a `let` expression or an equality check. ``` error: expected expression, found `let` statement --> $DIR/bad-if-let-suggestion.rs:5:8 | LL | if let x = 1 && i = 2 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions help: you might have meant to continue the let-chain | LL | if let x = 1 && let i = 2 {} | +++ help: you might have meant to compare for equality | LL | if let x = 1 && i == 2 {} | + ```
2023-11-28fix the issue of suggest unwrap/expect for shorthand fieldyukang-0/+69
2023-11-28Precommit test for https://github.com/rust-lang/rust/issues/118328.Alona Enraght-Moony-0/+41
2023-11-28Rollup merge of #118410 - krasimirgg:llvm-18-test, r=nikicMatthias Krüger-1/+1
update test for new LLVM 18 codegen LLVM at HEAD now emits `or disjoint`: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/24076#018c1596-8153-488e-b622-951266a02f6c/741-774
2023-11-28def collector: Set correct namespace in `DefPathData` for foreign typesVadim Petrochenkov-1/+1
2023-11-28resolve: Feed the `def_kind` query immediately on `DefId` creationVadim Petrochenkov-2/+2
2023-11-28update test for new LLVM 18 codegenKrasimir Georgiev-1/+1
LLVM at HEAD now emits `or disjoint`: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/24076#018c1596-8153-488e-b622-951266a02f6c/741-774
2023-11-28Auto merge of #118405 - matthiaskrgr:rollup-3a2eevc, r=matthiaskrgrbors-8/+35
Rollup of 7 pull requests Successful merges: - #115331 (optimize str::iter::Chars::advance_by) - #118236 (Update mod comment) - #118299 (Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on the existing example.) - #118314 (Rename `{collections=>alloc}{tests,benches}`) - #118341 (Simplify indenting in THIR printing) - #118366 (Detect and reject malformed `repr(Rust)` hints) - #118397 (Fix comments for unsigned non-zero `checked_add`, `saturating_add`) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-28Rollup merge of #118366 - fmease:detect-reject-malformed-rust-repr, ↵Matthias Krüger-8/+35
r=compiler-errors Detect and reject malformed `repr(Rust)` hints Fixes #118334.
2023-11-28Auto merge of #118282 - fee1-dead-contrib:enforce-more, r=compiler-errorsbors-30/+75
effects: Run `enforce_context_effects` for all method calls So that we also perform checks when overloaded `PartialEq`s are called. r? `@compiler-errors`
2023-11-27Rollup merge of #118381 - Enselic:edit-dist-len, r=WaffleLapkinMichael Goulet-0/+13
rustc_span: Use correct edit distance start length for suggestions Otherwise the suggestions can be off-base for non-ASCII identifiers. For example suggesting that `Ok` is a name similar to `读文`. Closes https://github.com/rust-lang/rust/issues/72553.
2023-11-27Rollup merge of #118202 - azhogin:azhogin/link_args_wrapping, r=petrochenkovMichael Goulet-0/+9
Added linker_arg(s) Linker trait methods for link-arg to be prefixed "-Wl," for cc-like linker args and not verbatim https://github.com/rust-lang/rust/issues/99427#issuecomment-1234443468 > here's one possible improvement to -l link-arg making it more portable between linkers and useful - befriending it with the verbatim modifier (https://github.com/rust-lang/rust/issues/99425). > > -l link-arg:-verbatim=-foo would add -Wl,-foo (or equivalent) when C compiler is used as a linker, and just -foo when bare linker is used. > -l link-arg:+verbatim=-bar on the other hand would always pass just -bar.
2023-11-27Rollup merge of #117526 - estebank:issue-24157, r=b-naberMichael Goulet-0/+37
Account for `!` arm in tail `match` expr On functions with a default return type that influences the coerced type of `match` arms, check if the failing arm is actually of type `!`. If so, suggest changing the return type so the coercion against the prior arms is successful. ``` error[E0308]: `match` arms have incompatible types --> $DIR/match-tail-expr-never-type-error.rs:9:13 | LL | fn bar(a: bool) { | - help: try adding a return type: `-> i32` LL | / match a { LL | | true => 1, | | - this is found to be of type `{integer}` LL | | false => { LL | | never() | | ^^^^^^^ | | | | | expected integer, found `()` | | this expression is of type `!`, but it get's coerced to `()` due to its surrounding expression LL | | } LL | | } | |_____- `match` arms have incompatible types ``` Fix #24157.
2023-11-27Rollup merge of #111133 - hkmatsumoto:handle-python-slicing, r=TaKO8KiMichael Goulet-0/+20
Detect Python-like slicing and suggest how to fix Fix #108215
2023-11-27Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviperbors-46/+1
Update the minimum external LLVM to 16. With this change, we'll have stable support for LLVM 16 and 17. For reference, the previous increase to LLVM 15 was #114148 [Relevant zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/riscv.20forced-atomics)
2023-11-27Auto merge of #117200 - rmehri01:repeated_help, r=WaffleLapkinbors-1/+0
Don't add redundant help for object safety violations Fixes #117186 r? WaffleLapkin
2023-11-27Print list of missing target features when calling a function with target ↵Eduardo Sánchez Muñoz-37/+67
features outside an unsafe block
2023-11-27rustc_span: Use correct edit distance start length for suggestionsMartin Nordholts-0/+13
Otherwise the suggestions can be off-base for non-ASCII identifiers. For example suggesting that `Ok` is a name similar to `读文`.
2023-11-27Auto merge of #118118 - spastorino:do-not-erase-late-bound-regions-on-iat, ↵bors-1/+24
r=compiler-errors Do not erase late bound regions when selecting inherent associated types In the fix for #97156 we would want the following code: ```rust #![feature(inherent_associated_types)] #![allow(incomplete_features)] struct Foo<T>(T); impl Foo<fn(&'static ())> { type Assoc = u32; } trait Other {} impl Other for u32 {} // FIXME(inherent_associated_types): Avoid emitting two diagnostics (they only differ in span). // FIXME(inherent_associated_types): Enhancement: Spruce up the diagnostic by saying something like // "implementation is not general enough" as is done for traits via // `try_report_trait_placeholder_mismatch`. fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} //~^ ERROR mismatched types //~| ERROR mismatched types fn main() {} ``` to fail with ... ``` error[E0220]: associated type `Assoc` not found for `Foo<for<'a> fn(&'a ())>` in the current scope --> tests/ui/associated-inherent-types/issue-109789.rs:18:36 | 4 | struct Foo<T>(T); | ------------- associated item `Assoc` not found for this struct ... 18 | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} | ^^^^^ associated item not found in `Foo<for<'a> fn(&'a ())>` | = note: the associated type was found for - `Foo<fn(&'static ())>` error: aborting due to previous error For more information about this error, try `rustc --explain E0220`. ``` This PR fixes the ICE we are currently getting "was a subtype of Foo<Binder(fn(&ReStatic ()), [])> during selection but now it is not" Also fixes #112631 r? `@lcnr`
2023-11-27Account for `!` arm in tail `match` exprEsteban Küber-0/+37
On functions with a default return type that influences the coerced type of `match` arms, check if the failing arm is actually of type `!`. If so, suggest changing the return type so the coercion against the prior arms is successful. ``` error[E0308]: `match` arms have incompatible types --> $DIR/match-tail-expr-never-type-error.rs:9:13 | LL | fn bar(a: bool) { | - help: try adding a return type: `-> i32` LL | / match a { LL | | true => 1, | | - this is found to be of type `{integer}` LL | | false => { LL | | never() | | ^^^^^^^ | | | | | expected integer, found `()` | | this expression is of type `!`, but it get's coerced to `()` due to its surrounding expression LL | | } LL | | } | |_____- `match` arms have incompatible types ``` Fix #24157.
2023-11-27Added linker_arg(s) Linker trait methods for link-arg to be prefixed "-Wl," ↵Andrew Zhogin-0/+9
for cc-like linker args and not verbatim
2023-11-27Rollup merge of #118359 - hkmatsumoto:suggest-box-ref, r=TaKO8KiTakayuki Maeda-0/+36
Suggest swapping the order of `ref` and `box` It is not valid grammar to write `ref box <ident>` in patterns, but `box ref <ident>` is. This patch adds a diagnostic to suggest swapping them, analogous to what we do for `mut let`.
2023-11-27Change help message to make some sense in broader contextHirochika Matsumoto-2/+2
2023-11-27Address review feedbacksHirochika Matsumoto-7/+1
Also addressed merge conflicts upon rebasing.
2023-11-27Make tidy test happyHirochika Matsumoto-1/+1
2023-11-27Detect Python-like slicing and suggest how to fixHirochika Matsumoto-0/+26
Fix #108215
2023-11-27Suggest swapping the order of `ref` and `box`Hirochika Matsumoto-0/+36
2023-11-27Detect and reject malformed repr(Rust) hintsLeón Orell Valerian Liehr-8/+35