about summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2021-03-05Bump mir-opt-level from 3 to 4 in testsSantiago Pastorino-1/+1
2021-03-05Rollup merge of #81939 - kper:fixing-81584-allocate-in-iter, r=davidtwcoMara-0/+30
Add suggestion `.collect()` for iterators in iterators Closes #81584 ``` error[E0515]: cannot return value referencing function parameter `y` --> main3.rs:4:38 | 4 | ... .map(|y| y.iter().map(|x| x + 1)) | -^^^^^^^^^^^^^^^^^^^^^^ | | | returns a value referencing data owned by the current function | `y` is borrowed here | help: Maybe use `.collect()` to allocate the iterator ``` Added the suggestion: `help: Maybe use `.collect()` to allocate the iterator`
2021-02-27Rollup merge of #82370 - ↵Dylan DPC-27/+27
0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank Improve anonymous lifetime note to indicate the target span Improvement for #81650 Cc #81995 Message after this improvement: (Improve note in the middle) ``` error[E0311]: the parameter type `T` may not live long enough --> src/main.rs:25:11 | 24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) { | -- help: consider adding an explicit lifetime bound...: `T: 'a +` 25 | scope.spawn(move |_| { | ^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40... --> src/main.rs:24:40 | 24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) { | ^^^^^ note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds --> src/main.rs:25:11 | 25 | scope.spawn(move |_| { | ^^^^^ ``` r? ``````@estebank``````
2021-02-25Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkorDylan DPC-5/+5
fix the false 'defined here' messages Closes #80853. Take this code: ```rust struct S; fn repro_ref(thing: S) { thing(); } ``` Previously, the error message would be this: ``` error[E0618]: expected function, found `S` --> src/lib.rs:4:5 | 3 | fn repro_ref(thing: S) { | ----- `S` defined here 4 | thing(); | ^^^^^-- | | | call expression requires function error: aborting due to previous error ``` This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted: ``` error[E0618]: expected function, found `S` --> $DIR/80853.rs:4:5 | LL | fn repro_ref(thing: S) { | ----- is of type `S` LL | thing(); | ^^^^^-- | | | call expression requires function | = note: local variable `S` is not a function error: aborting due to previous error ``` As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example: ``` LL | struct Empty2; | -------------- is of type `Empty2` ``` As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously): ``` LL | struct Empty2; | -------------- `Empty2` defined here ``` If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me. **Update: This is now fixed** CC `@camelid`
2021-02-25Update test output for edition preludes.Mara Bos-4/+4
2021-02-25add helpful error notes and fix the false 'defined here' messagesHenry Boisdequin-5/+5
2021-02-24Add suggestion for iterators in iteratorsKevin Per-0/+30
2021-02-23Rollup merge of #82362 - osa1:issue81918, r=oli-obkDylan DPC-0/+11
Fix mir-cfg dumps Fixes #81918 Fixes #82326 (duplicate) Fixes #82325 --- r? ``@oli-obk``
2021-02-23Rollup merge of #81235 - reese:rw-tuple-diagnostics, r=estebankDylan DPC-1/+6
Improve suggestion for tuple struct pattern matching errors. Closes #80174 This change allows numbers to be parsed as field names when pattern matching on structs, which allows us to provide better error messages when tuple structs are matched using a struct pattern. r? ``@estebank``
2021-02-22Update test cases0yoyoyo-27/+27
2021-02-22Fix mir-cfg dumpsÖmer Sinan Ağacan-0/+11
Fixes #81918 Fixes #82326 (duplicate) Fixes #82325
2021-02-22Rollup merge of #82287 - r00ster91:field_name_and, r=petrochenkovYuki Okushi-3/+3
Make "missing field" error message more natural ```rust struct A { x: i32, y: i32, z: i32, } fn main() { A { }; } ``` ``` error[E0063]: missing fields `x`, `y`, `z` in initializer of `A` --> src/main.rs:8:5 | 8 | A { }; | ^ missing `x`, `y`, `z` ``` This error is now: ``` error[E0063]: missing fields `x`, `y` and `z` in initializer of `A` --> src/main.rs:8:5 | 8 | A { }; | ^ missing `x`, `y` and `z` ``` I thought it looked nicer and more natural this way. Also, if there is >3 fields missing, there is an "and" as well ("missing \`x\`, \`y\`, \`z\` *and* 1 other field"), but for <=3 there is not. As such it improves consistency too. As for the implementation, originally I ended up with a chunky `push_str` algorithm but then I figured I could just do the formatting manually since it's just 3 field names at maximum. It is comparatively readable. As a sidenote, one thing I was wondering about is, isn't there more cases where you have a list of things like field names? Maybe this whole thing can at some point later be made into a more general function to be used in multiple areas.
2021-02-21Auto merge of #79100 - a1phyr:better_assert_eq, r=m-ou-sebors-16/+10
Improve assert_eq! and assert_ne! This PR improves `assert_eq!` and `assert_ne!` by moving the panicking code in an external function. It does not change the fast path, but the move of the formatting in the cold path (the panic) may have a positive effect on in instruction cache use and with inlining. Moreover, the use of trait objects instead of generic may improve compile times for `assert_eq!`-heavy code. Godbolt link: ~~https://rust.godbolt.org/z/TYa9MT~~ \ Updated: https://rust.godbolt.org/z/bzE84x
2021-02-20Fix suggestion span and move suggestions into new subwindow.Reese Williams-3/+6
2021-02-20Make "missing field" error message more naturalr00ster91-3/+3
2021-02-19Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011Dylan DPC-4/+2
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
2021-02-18Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkorDylan DPC-1/+1
Replace if-let and while-let with `if let` and `while let` This pull request replaces if-let and while-let with `if let` and `while let`. closes https://github.com/rust-lang/rust/issues/82205
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-4/+2
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-18Rollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPCYuki Okushi-458/+0
Move some tests to more reasonable directories - 4 cc #81941
2021-02-17Rollup merge of #81972 - matthewjasper:hrtb-error-cleanup, r=nikomatsakisDylan DPC-52/+20
Placeholder lifetime error cleanup - Remove note of trait definition - Avoid repeating the same self type - Use original region names when possible - Use this error kind more often - Print closure signatures when they are suppose to implement `Fn*` traits Works towards #57374 r? ```@nikomatsakis```
2021-02-17Auto merge of #82235 - GuillaumeGomez:rollup-oflxc08, r=GuillaumeGomezbors-0/+25
Rollup of 11 pull requests Successful merges: - #79981 (Add 'consider using' message to overflowing_literals) - #82094 (To digit simplification) - #82105 (Don't fail to remove files if they are missing) - #82136 (Fix ICE: Use delay_span_bug for mismatched subst/hir arg) - #82169 (Document that `assert!` format arguments are evaluated lazily) - #82174 (Replace File::create and write_all with fs::write) - #82196 (Add caveat to Path::display() about lossiness) - #82198 (Use internal iteration in Iterator::is_sorted_by) - #82204 (Update books) - #82207 (rustdoc: treat edition 2021 as unstable) - #82231 (Add long explanation for E0543) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-17Rollup merge of #79981 - camelid:overflowing_literals-inference-error, r=lcnrGuillaume Gomez-0/+25
Add 'consider using' message to overflowing_literals Fixes #79744. Ironically, the `overflowing_literals` handler for binary or hex already had this message! You would think it would be the other way around :) cc ```@scottmcm```
2021-02-17replace if-let and while-let with `if let` and `while let`Takayuki Maeda-1/+1
2021-02-16Move some tests to more reasonable directoriesCaio-458/+0
2021-02-17Use -Ccodegen-units=1 to make issue-23458 test deterministicTomasz Miąsko-1/+1
The test case fails with either one error or two errors. Use a single code generation unit to avoid nondeterminism.
2021-02-14Apply suggestionsBenoît du Garreau-4/+4
- Move `assert_failed` to core::panicking` - Make `assert_failed` use an enum instead of a string
2021-02-14Fix UI tests and merge `assert_eq` and `assert_ne` internal functionsBenoît du Garreau-16/+10
2021-02-14Clarify error message and remove pretty printing in help suggestions.Reese Williams-1/+3
2021-02-14Rollup merge of #81914 - kper:fixing-81885, r=estebankDylan DPC-4/+26
Fixing bad suggestion for `_` in `const` type when a function #81885 Closes #81885 ``` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item_help.rs:13:22 | LL | const TEST4: fn() -> _ = 42; | ^ | | | not allowed in type signatures | help: use type parameters instead: `T` ``` Do not show the suggestion `help: use type parameters instead: T` when `fn`
2021-02-13Improve error and help messagesCamelid-2/+2
2021-02-09Print closure signatures when reporting placeholder errorsMatthew Jasper-1/+1
2021-02-09Report "nice" placeholder errors more oftenMatthew Jasper-14/+10
If we have a cause containing `ValuePairs::PolyTraitRefs` but neither TraitRef has any escaping bound regions then we report the same error as for `ValuePairs::TraitRefs`.
2021-02-09Remove unnecessary note on errorsMatthew Jasper-38/+10
Seeing the trait definition doesn't help with implementation not general enough errors, so don't make the error message larger to show it.
2021-02-09Auto merge of #81384 - tmiasko:partial-ord, r=petrochenkovbors-45/+1
Fix derived PartialOrd operators The derived implementation of `partial_cmp` compares matching fields one by one, stopping the computation when the result of a comparison is not equal to `Some(Equal)`. On the other hand the derived implementation for `lt`, `le`, `gt` and `ge` continues the computation when the result of a field comparison is `None`, consequently those operators are not transitive and inconsistent with `partial_cmp`. Fix the inconsistency by using the default implementation that fall-backs to the `partial_cmp`. This also avoids creating very deeply nested closures that were quite costly to compile. Fixes #81373. Helps with #81278, #80118.
2021-02-09Fixing bad suggestion for `_` in `const` type when a function #81885Kevin Per-4/+26
2021-02-09Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakisDylan DPC-27/+22
Allow Trait inheritance with cycles on associated types take 2 This reverts the revert of #79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in #80648 and #79811. For easier review I'd say, check only the last commit, the first one is just a revert of the revert of #79209 which was already approved. This also could be considered part or the actual fix of #79560 but I guess for that to be closed and fixed completely we would need to land #80648 and #79811 too. r? `@nikomatsakis` cc `@Aaron1011`
2021-02-09./x.py test --blessTomasz Miąsko-45/+1
2021-02-08Rollup merge of #81828 - davidhewitt:capture-raw-format-strings, r=estebankMara Bos-2/+2
parse_format: treat r" as a literal This PR changes `format_args!` internal parsing machinery to treat raw strings starting `r"` as a literal. Currently `"` and `r#` are recognised as valid starting combinations for string literals, but `r"` is not. This was noticed when debugging https://github.com/rust-lang/rust/issues/67984#issuecomment-753413156 As well as fixing the behavior observed in that comment, this improves diagnostic spans for `r"` formatting strings.
2021-02-07Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisabors-33/+0
Improve SIMD type element count validation Resolves rust-lang/stdsimd#53. These changes are motivated by `stdsimd` moving in the direction of const generic vectors, e.g.: ```rust #[repr(simd)] struct SimdF32<const N: usize>([f32; N]); ``` This makes a few changes: * Establishes a maximum SIMD lane count of 2^16 (65536). This value is arbitrary, but attempts to validate lane count before hitting potential errors in the backend. It's not clear what LLVM's maximum lane count is, but cranelift's appears to be much less than `usize::MAX`, at least. * Expands some SIMD intrinsics to support arbitrary lane counts. This resolves the ICE in the linked issue. * Attempts to catch invalid-sized vectors during typeck when possible. Unresolved questions: * Generic-length vectors can't be validated in typeck and are only validated after monomorphization while computing layout. This "works", but the errors simply bail out with no context beyond the name of the type. Should these errors instead return `LayoutError` or otherwise provide context in some way? As it stands, users of `stdsimd` could trivially produce monomorphization errors by making zero-length vectors. cc `@bjorn3`
2021-02-07Auto merge of #79078 - petrochenkov:derattr, r=Aaron1011bors-43/+27
expand/resolve: Turn `#[derive]` into a regular macro attribute This PR turns `#[derive]` into a regular attribute macro declared in libcore and defined in `rustc_builtin_macros`, like it was previously done with other "active" attributes in https://github.com/rust-lang/rust/pull/62086, https://github.com/rust-lang/rust/pull/62735 and other PRs. This PR is also a continuation of #65252, #69870 and other PRs linked from them, which layed the ground for converting `#[derive]` specifically. `#[derive]` still asks `rustc_resolve` to resolve paths inside `derive(...)`, and `rustc_expand` gets those resolution results through some backdoor (which I'll try to address later), but otherwise `#[derive]` is treated as any other macro attributes, which simplifies the resolution-expansion infra pretty significantly. The change has several observable effects on language and library. Some of the language changes are **feature-gated** by [`feature(macro_attributes_in_derive_output)`](https://github.com/rust-lang/rust/issues/81119). #### Library - `derive` is now available through standard library as `{core,std}::prelude::v1::derive`. #### Language - `derive` now goes through name resolution, so it can now be renamed - `use derive as my_derive; #[my_derive(Debug)] struct S;`. - `derive` now goes through name resolution, so this resolution can fail in corner cases. Crater found one such regression, where import `use foo as derive` goes into a cycle with `#[derive(Something)]`. - **[feature-gated]** `#[derive]` is now expanded as any other attributes in left-to-right order. This allows to remove the restriction on other macro attributes following `#[derive]` (https://github.com/rust-lang/reference/issues/566). The following macro attributes become a part of the derive's input (this is not a change, non-macro attributes following `#[derive]` were treated in the same way previously). - `#[derive]` is now expanded as any other attributes in left-to-right order. This means two derive attributes `#[derive(Foo)] #[derive(Bar)]` are now expanded separately rather than together. It doesn't generally make difference, except for esoteric cases. For example `#[derive(Foo)]` can now produce an import bringing `Bar` into scope, but previously both `Foo` and `Bar` were required to be resolved before expanding any of them. - **[feature-gated]** `#[derive()]` (with empty list in parentheses) actually becomes useful. For historical reasons `#[derive]` *fully configures* its input, eagerly evaluating `cfg` everywhere in its target, for example on fields. Expansion infra doesn't do that for other attributes, but now when macro attributes attributes are allowed to be written after `#[derive]`, it means that derive can *fully configure* items for them. ```rust #[derive()] #[my_attr] struct S { #[cfg(FALSE)] // this field in removed by `#[derive()]` and not observed by `#[my_attr]` field: u8 } ``` - `#[derive]` on some non-item targets is now prohibited. This was accidentally allowed as noop in the past, but was warned about since early 2018 (#50092), despite that crater found a few such cases in unmaintained crates. - Derive helper attributes used before their introduction are now reported with a deprecation lint. This change is long overdue (since macro modularization, https://github.com/rust-lang/rust/issues/52226#issuecomment-422605033), but it was hard to do without fixing expansion order for derives. The deprecation is tracked by #79202. ```rust #[trait_helper] // warning: derive helper attribute is used before it is introduced #[derive(Trait)] struct S {} ``` Crater analysis: https://github.com/rust-lang/rust/pull/79078#issuecomment-731436821
2021-02-07expand/resolve: Turn `#[derive]` into a regular macro attributeVadim Petrochenkov-43/+27
2021-02-07Rollup merge of #81843 - bstrie:issue-29821, r=lcnrGuillaume Gomez-0/+19
Add regression test for #29821 Closes #29821
2021-02-07Auto merge of #81462 - osa1:issue75158, r=Mark-Simulacrumbors-69/+0
Add test for #75158 This also shifts some type-size related tests into a new directory, so that we keep the number of files at the root down. Closes #75158
2021-02-06Auto merge of #78052 - da-x:path-trimming-type-aliases, r=davidtwcobors-30/+30
path trimming: ignore type aliases Continuation of #73996.
2021-02-06Add regression test for #29821bstrie-0/+19
Closes #29821
2021-02-06Rollup merge of #81738 - camelid:misc-small-diag-cleanup, r=lcnrJonas Schievink-2/+2
Miscellaneous small diagnostics cleanup
2021-02-06parse_format: treat r" as a literalDavid Hewitt-2/+2
2021-02-06path trimming: ignore type aliasesDan Aloni-30/+30
2021-02-05Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, ↵Santiago Pastorino-27/+22
r=Mark-Simulacrum" This reverts commit b4def89d76896eec73b4af33642ba7e5eb53c567, reversing changes made to 7dc1e852d43cb8c9e77dc1e53014f0eb85d2ebfb.
2021-02-05Move type size check tests to new dir ui/limitsÖmer Sinan Ağacan-89/+0