about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2022-08-02Improve position named arguments lint underline and formatting namesPreston From-104/+220
For named arguments used as implicit position arguments, underline both the opening curly brace and either: * if there is formatting, the next character (which will either be the closing curl brace or the `:` denoting the start of formatting args) * if there is no formatting, the entire arg span (important if there is whitespace like `{ }`) This should make it more obvious where the named argument should be. Additionally, in the lint message, emit the formatting argument names without a dollar sign to avoid potentially confusion. Fixes #99907
2022-08-02Rollup merge of #100011 - compiler-errors:let-chain-restriction, r=fee1-deadMatthias Krüger-248/+332
Use Parser's `restrictions` instead of `let_expr_allowed` This also means that the `ALLOW_LET` flag is reset properly for subexpressions, so we can properly deny things like `a && (b && let c = d)`. Also the parser is a tiny bit smaller now. It doesn't reject _all_ bad `let` expr usages, just a bit more. cc `@c410-f3r`
2022-08-02Properly reject the `may_unwind` option in `global_asm!`Amanieu d'Antras-36/+36
This was accidentally accepted even though it had no effect in `global_asm!`. The option only makes sense for `asm!` which runs within a function.
2022-08-01Prevent ICE for doc_alias on match arm, statement, expressionhdelc-2/+26
2022-08-01Rollup merge of #99911 - cjgillot:no-guess, r=davidtwcoMatthias Krüger-56/+65
Remove some uses of `guess_head_span` That function cuts a span at the first occurrence of `{`. Using `def_span` is almost always more precise.
2022-08-01Rollup merge of #99629 - obeis:issue-99470, r=compiler-errorsMatthias Krüger-29/+54
Improve `cannot move out of` error message Closes #99470 r? `@bjorn3`
2022-08-01Auto merge of #99944 - bjorn3:hide_proc_macro_symbols, r=eddybbors-29/+39
Limit symbols exported from proc macros Only `__rustc_proc_macro_decls_*__` and `rust_metadata_*` need to be exported for proc macros to work. All other symbols only increase binary size and have the potential to conflict with symbols from the host compiler. Fixes https://github.com/rust-lang/rust/issues/99909 Fixes #59998 cc `@eddyb`
2022-08-01Use expr parse restrictions for let expr parsingMichael Goulet-248/+332
2022-08-01Don't derive `PartialEq::ne`.Nicholas Nethercote-169/+7
Currently we skip deriving `PartialEq::ne` for C-like (fieldless) enums and empty structs, thus reyling on the default `ne`. This behaviour is unnecessarily conservative, because the `PartialEq` docs say this: > Implementations must ensure that eq and ne are consistent with each other: > > `a != b` if and only if `!(a == b)` (ensured by the default > implementation). This means that the default implementation (`!(a == b)`) is always good enough. So this commit changes things such that `ne` is never derived. The motivation for this change is that not deriving `ne` reduces compile times and binary sizes. Observable behaviour may change if a user has defined a type `A` with an inconsistent `PartialEq` and then defines a type `B` that contains an `A` and also derives `PartialEq`. Such code is already buggy and preserving bug-for-bug compatibility isn't necessary. Two side-effects of the change: - There is only one error message produced for types where `PartialEq` cannot be derived, instead of two. - For coverage reports, some warnings about generated `ne` methods not being executed have disappeared. Both side-effects seem fine, and possibly preferable.
2022-07-31Rollup merge of #99986 - WaffleLapkin:record_struct_wrap_suggestion, ↵Matthias Krüger-5/+15
r=compiler-errors Add wrap suggestions for record variants This PR adds a suggestions to wrap an expression in a record struct/variant when encountering mismatched types, similarly to a suggestion to wrap expression in a tuple struct that was added before. An example: ```rust struct B { f: u8, } enum E { A(u32), B { f: u8 }, } fn main() { let _: B = 1; let _: E = 1; } ``` ```text error[E0308]: mismatched types --> ./t.rs:11:16 | 11 | let _: B = 1; | - ^ expected struct `B`, found integer | | | expected due to this | help: try wrapping the expression in `B` | 11 | let _: B = B { f: 1 }; | ++++++ + error[E0308]: mismatched types --> ./t.rs:12:16 | 12 | let _: E = 1; | - ^ expected enum `E`, found integer | | | expected due to this | help: try wrapping the expression in a variant of `E` | 12 | let _: E = E::A(1); | +++++ + 12 | let _: E = E::B { f: 1 }; | +++++++++ + ``` r? `@compiler-errors`
2022-07-31Rollup merge of #99973 - RalfJung:layout-things, r=eddybMatthias Krüger-920/+920
Layout things These two commits are pretty independent, but didn't seem worth doing individual PRs for: - Always check that size is a multiple of align, even without debug assertions - Change Layout debug printing to put `variants` last, since it often huge and not usually the part we are most interested in Cc `@eddyb`
2022-07-31Rollup merge of #99620 - hudson-ayers:fix-location-detail, r=davidtwcoMatthias Krüger-0/+10
`-Z location-detail`: provide option to disable all location details As reported [here](https://github.com/rust-lang/rust/pull/89920#issuecomment-1190598924), when I first implemented the `-Z location-detail` flag there was a bug, where passing an empty list was not correctly supported, and instead rejected by the compiler. This PR fixes that such that passing an empty list results in no location details being tracked, as originally specified in https://github.com/rust-lang/rfcs/pull/2091 . This PR also adds a test case to verify that this option continues to work as intended.
2022-07-31Rollup merge of #99519 - Urgau:check-cfg-implicit, r=petrochenkovMatthias Krüger-38/+63
Remove implicit names and values from `--cfg` in `--check-cfg` This PR remove the implicit names and values from `--cfg` in `--check-cfg` because the behavior is quite surprising but also because it's really easy to inadvertently really on the implicitness and when the `--cfg` is not set anymore to have an unexpected warning from an unexpected condition that pass with the implicitness. This change in behavior will also enable us to warn when an unexpected `--cfg` is passed, ex: the user wrote `--cfg=unstabl` instead of `--cfg=unstable`. The implementation of the warning will be done in a follow-up PR. cc `@petrochenkov`
2022-07-31Improve `cannot move out of` error messageObei Sideg-29/+54
2022-07-31--bless testsMaybe Waffle-5/+15
2022-07-31add test for earlier drop despite extend lifetimeDing Xiang Fei-0/+11
2022-07-31reorder fields in Laout debug outputRalf Jung-920/+920
2022-07-31Rollup merge of #99974 - ↵Dylan DPC-0/+200
TaKO8Ki:suggest-removing-semicolon-and-boxing-the-expressions, r=compiler-errors Suggest removing a semicolon and boxing the expressions for if-else `InferCtxt::suggest_remove_semi_or_return_binding` was not working well, so I fixed it and added a ui test.
2022-07-31Rollup merge of #99741 - compiler-errors:copy-impl-impl-generics, r=fee1-deadDylan DPC-0/+95
Use `impl`'s generics when suggesting fix on bad `impl Copy` See the UI test for a more complicated example, but we weren't correctly suggesting to add bounds given a manual `impl` whose generics didn't match the struct generics. ```rust #[derive(Clone)] struct Wrapper<T>(T); impl<S> Copy for Wrapper<S> {} ``` Coincidentally this fix didn't cause any regressions for `derive(Copy)` impls, I think because those use the same spans in the impl generics as the struct generics, so the machinery still applies the same change.
2022-07-31Remove workarounds for issue 59998bjorn3-29/+39
2022-07-31add a test to check if `suggest_remove_semi_or_return_binding` is working ↵Takayuki Maeda-0/+200
well for if-else
2022-07-30Auto merge of #99959 - cuviper:niche-size, r=eddybbors-0/+469
Fix the size of niche enums with ZST alignment For enums with an aligned ZST variant, like `[T; 0]`, the niche layout was not computing a sufficient size to be consistent with alignment. Now we pad that size up to the alignment, and also make sure to only use the niche variant's ABI when the size and alignment still match. Fixes #99836 r? `@eddyb`
2022-07-30Rollup merge of #99890 - compiler-errors:issue-99828, r=lcnrMatthias Krüger-6/+41
Do not allow bad projection term to leak into the type checker Fixes #99828
2022-07-30Test another enum niche with multiple ZST alignmentsJosh Stone-3/+132
2022-07-30Fix the size of niche enums with ZST alignmentJosh Stone-0/+340
For enums with an aligned ZST variant, like `[T; 0]`, the niche layout was not computing a sufficient size to be consistent with alignment. Now we pad that size up to the alignment, and also make sure to only use the niche variant's ABI when the size and alignment still match.
2022-07-30Always create elided lifetimes, even if inferred.Camille GILLOT-0/+17
2022-07-30Rollup merge of #99903 - gimbles:pub, r=davidtwcoDylan DPC-0/+29
Add diagnostic when using public instead of pub Forwarding from https://github.com/rust-lang/rust/pull/99706 I accidentally broke something(??) in git and the commits in that PR are absolutely not what I did in that branch Anyways, this is the PR for this now. Adding tests again in a minute. cc `@davidtwco`
2022-07-30Rollup merge of #99895 - compiler-errors:type-ascription-aint-cast, r=davidtwcoDylan DPC-73/+73
don't call type ascription "cast" Noticed in #99885
2022-07-30Rollup merge of #99862 - WaffleLapkin:type_mismatch_fix, r=compiler-errorsDylan DPC-63/+119
Improve type mismatch w/ function signatures This PR makes use of `note: expected/found` (instead of labeling types in labels) in type mismatch with function signatures. Pros: it's easier to compare the signatures, cons: the error is a little more verbose now. This is especially nice when - The signatures differ in a small subset of parameters (same parameters are elided) - The difference is in details, for example `isize` vs `usize` (there is a better chance that the types align) Also this PR fixes the inconsistency in variable names in the edited code (`expected` and `found`). A zulip thread from which this pr started: [[link]](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Type.20error.20regression.3F.2E.2E.2E/near/289756602). An example diagnostic: <table> <tr> <th>this pr</th> <th>nightly</th> </tr> <tr> <td> ```text error[E0631]: type mismatch in function arguments --> ./t.rs:4:12 | 4 | expect(&f); | ------ ^^ expected due to this | | | required by a bound introduced by this call ... 10 | fn f(_: isize, _: u8, _: Vec<u32>) {} | ---------------------------------- found signature defined here | = note: expected function signature `fn(usize, _, Vec<u64>) -> _` found function signature `fn(isize, _, Vec<u32>) -> _` note: required because of the requirements on the impl of `Trait` for `fn(isize, u8, Vec<u32>) {f}` --> ./t.rs:8:9 | 8 | impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} | ^^^^^ ^ = note: required for the cast from `fn(isize, u8, Vec<u32>) {f}` to the object type `dyn Trait` ``` </td> <td> ```text error[E0631]: type mismatch in function arguments --> ./t.rs:4:12 | 4 | expect(&f); | ------ ^^ expected signature of `fn(usize, u8, Vec<u64>) -> _` | | | required by a bound introduced by this call ... 10 | fn f(_: isize, _: u8, _: Vec<u32>) {} | ---------------------------------- found signature of `fn(isize, u8, Vec<u32>) -> _` | note: required because of the requirements on the impl of `Trait` for `fn(isize, u8, Vec<u32>) {f}` --> ./t.rs:8:9 | 8 | impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} | ^^^^^ ^ = note: required for the cast to the object type `dyn Trait` ``` </td> </tr> </table> <details><summary>code</summary> <p> ```rust fn main() { fn expect(_: &dyn Trait) {} expect(&f); } trait Trait {} impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} fn f(_: isize, _: u8, _: Vec<u32>) {} ``` </p> </details> r? `@compiler-errors`
2022-07-30Auto merge of #99796 - compiler-errors:issue-53475, r=oli-obkbors-0/+27
use `check_region_obligations_and_report_errors` to avoid ICEs If we don't call `process_registered_region_obligations` before `resolve_regions_and_report_errors` then we'll ICE if we have any region obligations, and `check_region_obligations_and_report_errors` just does both of these for us in a nice convenient function. Fixes #53475 r? types
2022-07-30Do not leak type variables from opaque type relationMichael Goulet-0/+34
2022-07-30Auto merge of #99925 - JohnTitor:rollup-4bt9ou3, r=JohnTitorbors-33/+178
Rollup of 8 pull requests Successful merges: - #99227 (Fix thumbv4t-none-eabi frame pointer setting) - #99518 (Let-else: break out scopes when a let-else pattern fails to match) - #99671 (Suggest dereferencing index when trying to use a reference of usize as index) - #99831 (Add Fuchsia platform support documentation) - #99881 (fix ICE when computing codegen_fn_attrs on closure with non-fn parent) - #99888 (Streamline lint checking) - #99891 (Adjust an expr span to account for macros) - #99904 (Cleanup html whitespace) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-29Fix after rebasingEric Holk-1/+1
2022-07-29Update to still be correct without drop trackingEric Holk-6/+33
2022-07-29Update must_not_suspend lint to traverse referencesEric Holk-6/+6
2022-07-29Add drop tracking version of must_not_suspend ref testEric Holk-0/+30
2022-07-30Rollup merge of #99891 - compiler-errors:suggest-slicing-carefully, r=oli-obkYuki Okushi-1/+17
Adjust an expr span to account for macros Fix this erroneous suggestion: ``` error[E0529]: expected an array or slice, found `Vec<{integer}>` --> /home/gh-compiler-errors/test.rs:2:9 | 2 | let [..] = vec![1, 2, 3]; | ^^^^ pattern cannot match with input type `Vec<{integer}>` | help: consider slicing here --> /home/gh-compiler-errors/rust2/library/alloc/src/macros.rs:50:36 | 50~ $crate::__rust_force_expr!(<[_]>::into_vec( 51+ #[rustc_box] 52+ $crate::boxed::Box::new([$($x),+]) 53~ )[..]) ```
2022-07-30Rollup merge of #99881 - compiler-errors:issue-99876, r=tmiaskoYuki Okushi-0/+9
fix ICE when computing codegen_fn_attrs on closure with non-fn parent Other call sites check `has_codegen_attrs` first, so let's do that too. Fixes #99876
2022-07-30Rollup merge of #99671 - TaKO8Ki:suggest-dereferencing-index, r=compiler-errorsYuki Okushi-32/+63
Suggest dereferencing index when trying to use a reference of usize as index fixes #96678
2022-07-30Rollup merge of #99518 - dingxiangfei2009:let-else-additional-tests, r=oli-obkYuki Okushi-0/+89
Let-else: break out scopes when a let-else pattern fails to match This PR will commit to a new behavior so that values from initializer expressions are dropped earlier when a let-else pattern fails to match. Fix #98672. Close #93951. cc `@camsteffen` `@est31`
2022-07-29Auto merge of #99730 - lcnr:bound-vars-anon, r=jackh726bors-0/+14
anonymize all bound vars, not just regions fixes #98702 r? types
2022-07-29add a silly test for keywords in trait bounds recoveryMaybe Waffle-0/+218
2022-07-29Recover keywords in boundsMaybe Waffle-4/+11
For example, this fixes a error for `impl fn()` (notice the capitalization)
2022-07-29Auto merge of #99467 - BelovDV:add_option_link_arg, r=petrochenkovbors-8/+38
flag '-l link-arg=___ was added #99427
2022-07-29Add diagnostic when using public instead of pubGimgim-0/+29
2022-07-29Add ui test for #99625Obei Sideg-0/+34
2022-07-29Auto merge of #99892 - JohnTitor:rollup-qi4fem8, r=JohnTitorbors-0/+56
Rollup of 8 pull requests Successful merges: - #99686 (add suggestion when there is a impl of external trait on pointer with wrong coherence rules) - #99760 (doc/rustc: describe the uefi target platforms) - #99766 (Htmldocck: Substitute the doc channel when blessing) - #99781 (Use String::from_utf8_lossy in CStr demo) - #99803 (Update mentions to `rustc_metadata::rmeta::Lazy`) - #99845 (Remove `$` prefix for bash scripts in doc) - #99850 (rustdoc: Remove more Clean trait implementations) - #99872 (Clone the `src/llvm-project` submodule if profiling is enabled) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-29dont call type ascription 'cast'Michael Goulet-73/+73
2022-07-29Rollup merge of #99686 - vincenzopalazzo:macros/impl_on_ptr, r=compiler-errorsYuki Okushi-0/+56
add suggestion when there is a impl of external trait on pointer with wrong coherence rules Closes https://github.com/rust-lang/rust/issues/99572 This will try to improve the node in the error message by suggesting a general solution because the solution, in this case, is application depended. I'm not super happy regarding the code quality, but I'm happy to have feedback on it. `@rustbot` r? `@compiler-errors`
2022-07-29Adjust an expr span to account for macrosMichael Goulet-1/+17