about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2020-09-04Bless changed test outputJack Huey-1/+1
2020-09-04Upgrade chalk to 0.21Jack Huey-6/+14
2020-09-03Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkovbors-4252/+4270
diagnostics: shorten paths of unique symbols This is a step towards implementing a fix for #50310, and continuation of the discussion in [Pre-RFC: Nicer Types In Diagnostics - compiler - Rust Internals](https://internals.rust-lang.org/t/pre-rfc-nicer-types-in-diagnostics/11139). Impressed upon me from previous discussion in #21934 that an RFC for this is not needed, and I should just come up with code. The recent improvements to `use` suggestions that I've contributed have given rise to this implementation. Contrary to previous suggestions, it's rather simple logic, and I believe it only reduces the amount of cognitive load that a developer would need when reading type errors. ----- If a symbol name can only be imported from one place, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path to the last component. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable from anywhere.
2020-09-03avoid applying in-place collect specialization in type-length testThe8472-1/+2
the test was sized to match external iteration only, since vec's in-place collect now uses internal iteration we collect into a different type now. Note that any other try-fold based operation such as count() would also have exceeded the type length limit for that iterator.
2020-09-03rustc_lint: avoid trimmed paths for ty_find_init_errorDan Aloni-5/+5
2020-09-03specialization_graph: avoid trimmed paths for OverlapErrorDan Aloni-71/+71
2020-09-03Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morseDylan DPC-0/+58
Make all methods of `std::net::Ipv4Addr` const Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature: - `octets` - `is_loopback` - `is_private` - `is_link_local` - `is_global` (unstable) - `is_shared` (unstable) - `is_ietf_protocol_assignment` (unstable) - `is_benchmarking` (unstable) - `is_reserved` (unstable) - `is_multicast` - `is_broadcast` - `is_documentation` - `to_ipv6_compatible` - `to_ipv6_mapped` This would make all methods of `Ipv6Addr` const. Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation. Part of #76205
2020-09-02Auto merge of #76160 - scileo:format-recovery, r=petrochenkovbors-42/+61
Improve recovery on malformed format call The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues. r? @petrochenkov
2020-09-02pretty: trim paths of unique symbolsDan Aloni-4328/+4346
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-09-02Improve recovery on malformed format callSasha-42/+61
If a comma in a format call is replaced with a similar token, then we emit an error and continue parsing, instead of stopping at this point.
2020-09-01Rollup merge of #76218 - petrochenkov:shebang3, r=matkladTyler Mandry-8/+5
lexer: Tiny improvement to shebang detection Lexer now discerns between regular comments and doc comments, so use that. The change only affects the choice of reported errors.
2020-09-01Rollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morseTyler Mandry-0/+53
Make all methods of `std::net::Ipv6Addr` const Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature: - `segments` - `is_unspecified` - `is_loopback` - `is_global` (unstable) - `is_unique_local` - `is_unicast_link_local_strict` - `is_documentation` - `multicast_scope` - `is_multicast` - `to_ipv4_mapped` - `to_ipv4` This would make all methods of `Ipv6Addr` const. Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`, all other methods did not require a change. All these methods are dependent on `segments`, the current implementation of which requires unstable `const_fn_transmute` ([PR#75085](https://github.com/rust-lang/rust/pull/75085)). Part of #76205
2020-09-01Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkovTyler Mandry-3/+48
Give a better error message for duplicate built-in macros Minor follow-up to https://github.com/rust-lang/rust/pull/75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug. r? @petrochenkov
2020-09-01Make all remaining methods of `std::net::Ipv4Addr` constChristiaan Dirkx-1/+18
Makes the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature: - `is_global` - `is_reserved` - `is_broadcast` - `to_ipv6_compatible` - `to_ipv6_mapped` This results in all methods of `Ipv4Addr` being const. Also adds tests for these methods in a const context.
2020-09-02lexer: Tiny improvement to shebang detectionVadim Petrochenkov-8/+5
Lexer now discerns between regular comments and doc comments, so use that. The change only affects the choice of reported errors.
2020-09-01Auto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkovbors-0/+251
Run cfg-stripping on generic parameters before invoking derive macros Fixes #75930 This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute on a generic paramter is unusual, and combining it with a proc-macro derive is probably even more unusual. I don't expect this to cause any breakage.
2020-09-01Add test for `Ipv4Addr` methods in a const contextChristiaan Dirkx-0/+41
2020-09-01Add trailing newline to `ipv6.rs`CDirkx-1/+1
2020-09-01Add test for `Ipv6Addr` methods in a const contextCDirkx-0/+53
2020-09-01Give a better error message for duplicate built-in macrosJoshua Nelson-3/+48
Previously, this would say no such macro existed, but this was misleading, since the macro _did_ exist, it was just already seen. - Say where the macro was previously defined - Add long-form error message
2020-08-31Rollup merge of #76172 - ecstatic-morse:revert-75463, r=RalfJungTyler Mandry-15/+0
Revert #75463 This was approved by me prematurely. It needs T-libs approval. Sorry @CDirkx. r? @RalfJung
2020-08-31Rollup merge of #76139 - CDirkx:cow-is-borrowed, r=ecstatic-morseTyler Mandry-0/+15
Make `cow_is_borrowed` methods const Constify the following methods of `alloc::borrow::Cow`: - `is_borrowed` - `is_owned` Analogous to the const methods `is_some` and `is_none` for Option, and `is_ok` and `is_err` for Result. These methods are still unstable under `cow_is_borrowed`. Possible because of #49146 (Allow if and match in constants). Tracking issue: #65143
2020-09-01Auto merge of #75931 - estebank:suggest-if-let, r=petrochenkovbors-88/+203
Suggest `if let x = y` when encountering `if x = y` Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-09-01Add a test for constCDirkx-0/+15
Similar to the tests for Option and Result.
2020-08-31Revert #75463Dylan MacKenzie-15/+0
This was approved by me prematurely. It needs T-libs approval.
2020-08-31Rollup merge of #75938 - Amjad50:min_const_generics-tests-revisions, r=lcnrAleksey Kladov-375/+762
Added some `min_const_generics` revisions into `const_generics` tests Help in #75279. still a lot more to cover though r? @lcnr
2020-08-31Fix duplicate error messages in const_generics testsAmjad Alsharafi-64/+42
2020-08-31Auto merge of #75082 - Aaron1011:feature/proc-macro-backtrace, r=petrochenkovbors-0/+32
Add `-Z proc-macro-backtrace` to allow showing proc-macro panics Fixes #75050 Previously, we would unconditionally suppress the panic hook during proc-macro execution. This commit adds a new flag `-Z proc-macro-backtrace`, which allows running the panic hook for easier debugging.
2020-08-30Add `-Z proc-macro-backtrace` to allow showing proc-macro panicsAaron Hill-0/+32
Fixes #75050 Previously, we would unconditionally suppress the panic hook during proc-macro execution. This commit adds a new flag -Z proc-macro-backtrace, which allows running the panic hook for easier debugging.
2020-08-31Auto merge of #75463 - CDirkx:ordering-const, r=CDirkxbors-0/+15
Make some Ordering methods const Constify the following methods of `core::cmp::Ordering`: - `reverse` - `then` Possible because of #49146 (Allow `if` and `match` in constants). Tracking issue: #76113
2020-08-30Suggest `if let x = y` when encountering `if x = y`Esteban Küber-88/+203
Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-08-30Stabilize feature `const_ordering`CDirkx-2/+0
2020-08-30Use string literal directly when available in formatSasha-0/+54
Previous implementation used the `Parser::parse_expr` function in order to extract the format expression. If the first comma following the format expression was mistakenly replaced with a dot, then the next format expression was eaten by the function, because it looked as a syntactically valid expression, which resulted in incorrectly spanned error messages. The way the format expression is exctracted is changed: we first look at the first available token in the first argument supplied to the `format!` macro call. If it is a string literal, then it is promoted as a format expression immediatly, otherwise we fall back to the original `parse_expr`-related method. This allows us to ensure that the parser won't consume too much tokens when a typo is made. A test has been created so that it is ensured that the issue is properly fixed.
2020-08-30Run cfg-stripping on generic parameters before invoking derive macrosAaron Hill-0/+251
Fixes #75930 This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute on a generic paramter is unusual, and combining it with a proc-macro derive is probably even more unusual. I don't expect this to cause any breakage.
2020-08-30Add unstable `const_ordering` feature, and some tests.CDirkx-0/+17
2020-08-30mv compiler to compiler/mark-7/+7
2020-08-30Auto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasperbors-12/+36
Account for async functions when suggesting new named lifetime Fix #75850.
2020-08-30Rollup merge of #75885 - ↵Dylan DPC-14/+89
jumbatm:issue75739-clashing-extern-declarations-transparent-nonzero, r=lcnr Fix another clashing_extern_declarations false positive. Fixes #75739. Fix another clashing_extern_declarations false positive, this time for transparent newtype with a non-zero member. r? @lcnr
2020-08-28Rollup merge of #75972 - JulianKnodt:i70381, r=rollupPietro Albini-0/+14
Fix ICE due to carriage return w/ multibyte char Based off of this [commit](https://github.com/kfitch/rust/commit/972560b83f80e1219b5735ff3d751c034115b08e) Fixes #70381 CC: @Dylan-DPC
2020-08-28Auto merge of #70212 - Amanieu:catch_foreign, r=Mark-Simulacrumbors-23/+32
Abort when foreign exceptions are caught by catch_unwind Prior to this PR, foreign exceptions were not caught by catch_unwind, and instead passed through invisibly. This represented a painful soundness hole in some libraries ([take_mut](https://github.com/Sgeo/take_mut/blob/master/src/lib.rs#L37)), which relied on `catch_unwind` to handle all possible exit paths from a closure. With this PR, foreign exceptions are now caught by `catch_unwind` and will trigger an abort since catching foreign exceptions is currently UB according to the latest proposals by the FFI unwind project group. cc @rust-lang/wg-ffi-unwind
2020-08-27Abort when catch_unwind catches a foreign exceptionAmanieu d'Antras-23/+32
2020-08-27Auto merge of #75933 - Aaron1011:feature/closure-move-err, r=oli-obkbors-0/+30
Point to a move-related span when pointing to closure upvars Fixes #75904 When emitting move/borrow errors, we may point into a closure to indicate why an upvar is used in the closure. However, we use the 'upvar span', which is just an arbitrary usage of the upvar. If the upvar is used in multiple places (e.g. a borrow and a move), we may end up pointing to the borrow. If the overall error is a move error, this can be confusing. This PR tracks the span that caused an upvar to become captured by-value instead of by-ref (assuming that it's not a `move` closure). We use this span instead of the 'upvar' span when we need to point to an upvar usage during borrow checking.
2020-08-27Auto merge of #72784 - csmoe:issue-61076, r=estebankbors-4/+95
Await on mismatched future types Closes #61076 This PR suggests to `await` on: 1. `async_fn().bar() => async_fn().await.bar()` 2. `async_fn().field => async_fn().await.field` 3. ` if let x = async() {} => if let x = async().await {}` r? @tmandry @estebank
2020-08-27Fix ICE due to carriage return w/ multibyte charkadmin-0/+14
Based off of https://github.com/kfitch/rust/commit/972560b83f80e1219b5735ff3d751c034115b08e
2020-08-27Fix ICE on unwrap of unknown layout.jumbatm-0/+23
2020-08-26Fixed file formatting and made `tidy` happyAmjad Alsharafi-5/+8
2020-08-26Added more min_const_generics revisions to testsAmjad Alsharafi-157/+224
2020-08-26Added a lot of min_const_generics revisionsAmjad Alsharafi-236/+575
2020-08-26Auto merge of #75687 - TimDiekmann:realloc-align, r=Amanieubors-11/+5
Allow reallocation to different alignment in `AllocRef` The allocator-wg [has decided](https://github.com/rust-lang/wg-allocators/issues/5#issuecomment-672591112) to support reallocating to a different alignment in `AllocRef`. For more details please see the linked issue. r? @Amanieu closes https://github.com/rust-lang/wg-allocators/issues/5
2020-08-26suggest await on unexpected typescsmoe-11/+40