about summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2020-09-01Clarify message about unresolved useKornel-3/+3
2020-08-30Suggest `if let x = y` when encountering `if x = y`Esteban Küber-6/+6
Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
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-22Use smaller def span for functionsAaron Hill-104/+34
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-20Don't immediately error for cycles during normalizationMatthew Jasper-6/+6
2020-08-19Rollup merge of #75658 - tgnottingham:issue-75599, r=estebankYuki Okushi-0/+24
Don't emit "is not a logical operator" error outside of associative expressions Avoid showing this error where it doesn't make sense by not assuming "and" and "or" were intended to mean "&&" and "||" until after we decide to continue parsing input as an associative expression. Note that the decision of whether or not to continue parsing input as an associative expression doesn't actually depend on this assumption. Fixes #75599 --- First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
2020-08-18Don't emit "is not a logical operator" error outside of associative expressionsTyson Nottingham-0/+24
Avoid showing this error where it doesn't make sense by not assuming "and" and "or" were intended to mean "&&" and "||" until after we decide to continue parsing input as an associative expression. Note that the decision of whether or not to continue parsing input as an associative expression doesn't actually depend on this assumption. Fixes #75599
2020-08-18Move macro test to ui/macrosAleksey Kladov-19/+0
2020-08-16Rollup merge of #75177 - JohnTitor:broken-mir-test, r=eddybTyler Mandry-0/+205
Add regression test for issue-66768 Fixes #66768 This is fixed by #70452 (in particular, https://github.com/rust-lang/rust/pull/70452/files#diff-53aef089a36a8e2ed07627fc8915fe63R1763) and I'm not sure it's worth to add this test (i.e. the tests in #70452 are enough), so r? @eddyb to confirm it.
2020-08-16Auto merge of #75536 - estebank:e0255-suggestion, r=varkorbors-15/+15
Tweak output of E0225 When encountering multiple non-auto trait bounds suggest creating a new trait and explain what auto-traits are. _Inspired by https://fasterthanli.me/articles/frustrated-its-not-you-its-rust_
2020-08-14Rollup merge of #75509 - estebank:coming-merrily-from-java-land, r=lcnrTyler Mandry-5/+36
Tweak suggestion for `this` -> `self` * When referring to `this` in associated `fn`s always suggest `self`. * Point at ident for `fn` lacking `self` * Suggest adding `self` to assoc `fn`s when appropriate _Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
2020-08-14Tweak output of E0225Esteban Küber-15/+15
When encountering multiple non-auto trait bounds suggest creating a new trait and explain what auto-traits are.
2020-08-14review comment: suggestion message wordingEsteban Küber-2/+2
2020-08-13Rollup merge of #75319 - estebank:format-ice, r=eddybTyler Mandry-0/+13
Fix ICE #75307 in `format` Remove usages of `unwrap` (even when some are safe today). Fix #75307.
2020-08-13Tweak suggestion for `this` -> `self`Esteban Küber-5/+36
2020-08-13Rollup merge of #75449 - RalfJung:const-prop-test, r=wesleywiserYuki Okushi-0/+14
add regression test for #74739 (mir const-prop bug) Fixes https://github.com/rust-lang/rust/issues/74739
2020-08-12add regression test for #74739 (mir const-prop bug)Ralf Jung-0/+14
2020-08-11Detect tuple variants used as struct pattern and suggest correct patternEsteban Küber-5/+11
2020-08-11Rollup merge of #75352 - estebank:incorrect-tuple-struct-pat, r=oli-obkYuki Okushi-8/+5
Tweak conditions for E0026 and E0769 When we have a tuple struct used with struct we don't want to suggest using the (valid) struct syntax with numeric field names. Instead we want to suggest the expected syntax. Given ```rust fn main() { match MyOption::MySome(42) { MyOption::MySome { x: 42 } => (), _ => (), } } ``` We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant" instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
2020-08-10Auto merge of #74005 - estebank:type-ascription-redux, r=petrochenkovbors-13/+2
Clean up errors in typeck and resolve * Tweak ordering of suggestions * Do not suggest similarly named enclosing item * Point at item definition in foreign crates * Add missing primary label CC #34255.
2020-08-10Do not suggest similarly named enclosing itemEsteban Küber-13/+2
2020-08-10Tweak ordering of suggestionsEsteban Küber-5/+5
Modify logic to make it easier to follow and recover labels that would otherwise be lost.
2020-08-10Auto merge of #74953 - JulianKnodt:master, r=lcnrbors-1/+1
Remove restriction on type parameters preceding consts w/ feature const-generics Removed the restriction on type parameters preceding const parameters when the feature const-generics is enabled. Builds on #74676, which deals with unsorted generic parameters. This just lifts the check in lowering the AST to HIR that permits consts and types to be reordered with respect to each other. Lifetimes still must precede both This change is not intended for min-const-generics, and is gated behind the `#![feature(const_generics)]`. One thing is that it also permits type parameters without a default to come after consts, which I expected to not work, and was hoping to get more guidance on whether that should be permitted or how to prevent it otherwise. I did not go through the RFC process for this pull request because there was prior work to get this feature added. In the previous PR that was cited, work was done to enable this change. r? @lcnr
2020-08-09Tweak conditions for E0026 and E0769Esteban Küber-8/+5
When we have a tuple struct used with struct we don't want to suggest using the (valid) struct syntax with numeric field names. Instead we want to suggest the expected syntax. Given ```rust fn main() { match MyOption::MySome(42) { MyOption::MySome { x: 42 } => (), _ => (), } } ``` We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant" instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
2020-08-10Rollup merge of #75350 - estebank:foreign-fn-with-body-ice, r=davidtwcoYuki Okushi-0/+24
Do not ICE when lowering invalid extern fn with bodies Fix #75283.
2020-08-09Do not ICE when lowering invalid extern fn with bodiesEsteban Küber-0/+24
Fix #75283.
2020-08-09Blessed old test where error message had changedkadmin-1/+1
Added minor fmt change to ast_validation
2020-08-08Detect likely `for foo of bar` JS syntaxEsteban Küber-1/+11
Fix #75311.
2020-08-08Fix ICE #75307 in `format`Esteban Küber-0/+13
Remove usages of `unwrap` (even when some are safe today).
2020-08-05Add regression test for issue-66768Yuki Okushi-0/+205
2020-08-03Auto merge of #75076 - tmiasko:simplify-goto, r=oli-obkbors-0/+7
Fix change detection in CfgSimplifier::collapse_goto_chain Check that the old target is different from the new collapsed one, before concluding that anything changed. Fixes #75074 Fixes #75051
2020-08-02Auto merge of #74948 - lzutao:stalize-result-as-deref, r=dtolnaybors-45/+3
Stabilize `Result::as_deref` and `as_deref_mut` FCP completed in https://github.com/rust-lang/rust/issues/50264#issuecomment-645681400. This PR stabilizes two new APIs for `std::result::Result`: ```rust fn as_deref(&self) -> Result<&T::Target, &E> where T: Deref; fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E> where T: DerefMut; ``` This PR also removes two rarely used unstable APIs from `Result`: ```rust fn as_deref_err(&self) -> Result<&T, &E::Target> where E: Deref; fn as_deref_mut_err(&mut self) -> Result<&mut T, &mut E::Target> where E: DerefMut; ``` Closes #50264
2020-08-03Fix change detection in CfgSimplifier::collapse_goto_chainTomasz Miąsko-0/+7
Check that the old target is different from the new collapsed one, before concluding that anything changed.
2020-08-02Rollup merge of #75064 - petrochenkov:llvmtarg, r=Mark-SimulacrumManish Goregaokar-0/+3
compiletest: Support ignoring tests requiring missing LLVM components This PR implements a more principled solution to the problem described in https://github.com/rust-lang/rust/pull/66084. Builds of LLVM backends take a lot of time and disk space. So it usually makes sense to build rustc with ```toml [llvm] targets = "X86" experimental-targets = "" ``` unless you are working on some target-specific tasks. A few tests, however, require non-x86 backends to be built. A new test directive `// needs-llvm-components: component1 component2 component3` makes such tests to be automatically ignored if one of the listed components is missing in the provided LLVM (this is determined through `llvm-config --components`). As a result, the test suite now fully passes with LLVM built only with the x86 backend. The component list in this case is ``` aggressiveinstcombine all all-targets analysis asmparser asmprinter binaryformat bitreader bitstreamreader bitwriter cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker engine executionengine frontendopenmp fuzzmutate globalisel instcombine instrumentation interpreter ipo irreader jitlink libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mirparser native nativecodegen objcarcopts object objectyaml option orcerror orcjit passes profiledata remarks runtimedyld scalaropts selectiondag support symbolize tablegen target textapi transformutils vectorize windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xray ``` (With the default target list it's much larger.) ``` aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker engine executionengine frontendopenmp fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader jitlink libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcerror orcjit passes powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvutils runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xray ``` https://github.com/rust-lang/rust/pull/66084 is also reverted now. r? @Mark-Simulacrum
2020-08-02Auto merge of #74963 - JohnTitor:ptn-ice, r=petrochenkovbors-35/+44
Fix ICEs with `@ ..` binding This reverts #74557 and introduces an alternative fix while ensuring that #74954 is not broken. The diagnostics are verbose though, it fixes three related issues. cc #74954, #74539, and #74702
2020-08-02compiletest: Support ignoring tests requiring missing LLVM componentsVadim Petrochenkov-0/+3
2020-08-02Auto merge of #74785 - euclio:deprecation-kinds, r=petrochenkovbors-2/+2
report kind of deprecated item in message This is important for fields, which are incorrectly referred to as "items".
2020-08-01Auto merge of #74717 - ↵bors-0/+1
davidtwco:issue-74636-polymorphized-closures-inherited-params, r=oli-obk mir: add `used_generic_parameters_needs_subst` Fixes #74636. This PR adds a `used_generic_parameters_needs_subst` helper function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. This is used in the MIR interpreter to make the check for some pointer casts and for reflection intrinsics more precise. I've opened this as a draft PR because this might not be the approach we want to fix this issue and we have to decide what to do about the reflection case. r? @eddyb cc @lcnr @wesleywiser
2020-07-31interp: needs_subst -> ensure_monomorphic_enoughDavid Wood-0/+1
This commit adds a `ensure_monomorphic_enough` utility function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. `ensure_monomorphic_enough` is then used throughout interpret where `needs_subst` checks previously existed (in particular, for some pointer casts and for reflection intrinsics more precise). Signed-off-by: David Wood <david@davidtw.co>
2020-07-31Stabilize as_deref and as_deref on ResultLzu Tao-7/+3
2020-07-31Remove as_deref_err and as_deref_mut_err from ResultLzu Tao-38/+0
2020-07-31Fix ICEs with `@ ..` bindingYuki Okushi-2/+44
2020-07-31Revert "Fix an ICE on an invalid `binding @ ...` in a tuple struct pattern"Yuki Okushi-33/+0
This reverts commit f5e5eb6f46ef2cf0dd45dba4f975305509334fc6.
2020-07-28Make closures and generators a must use typesTomasz Miąsko-2/+24
Warn about unused expressions with closure or generator type. This follows existing precedence of must use annotations present on `FnOnce`, `FnMut`, `Fn` traits, which already indirectly apply to closures in some cases, e.g.,: ```rust fn f() -> impl FnOnce() { || {} } fn main() { // an existing warning: unused implementer of `std::ops::FnOnce` that must be used: f(); // a new warning: unused closure that must be used: || {}; } ```
2020-07-27mv std libs to library/mark-12/+12
2020-07-27Handle trait/projection predicates with bound regions correctlyMatthew Jasper-1/+1
2020-07-27Auto merge of #74817 - JohnTitor:rollup-0fchdye, r=JohnTitorbors-2/+1
Rollup of 6 pull requests Successful merges: - #74088 (Avoid writes without any data in `Write::write_all_vectored`) - #74598 (Fix sync_once_cell_does_not_leak_partially_constructed_boxes) - #74750 (Clean up some uses of logging in ui tests) - #74783 (python codes cleanup) - #74790 (Don't italicize comments in ayu theme) - #74799 (Fixed typo in `closure`) Failed merges: r? @ghost
2020-07-27Rollup merge of #74750 - oli-obk:logging_and_test_cleanups, r=JohnTitorYuki Okushi-2/+1
Clean up some uses of logging in ui tests The removed test can't possibly trigger anything today as we don't have logging in libstd. The `exec-env` flag was mistakenly used for adding env vars to rustc invocations both in test and in the test suite and there were some accidental renames from RUST_LOG to RUSTC_LOG that I reverted.
2020-07-27Auto merge of #74737 - smmalis37:astconv-factor, r=davidtwcobors-1/+1
Pull out some duplicated code into a new function I debated pulling the actual struct_span_err calls into the new method, but I felt like having to pass in multiple arguments for it and wiring up string formatting outweighed the benefits. Viewing the diff with whitespace ignored is recommended.
2020-07-26Auto merge of #74708 - kanru:issue-74564, r=davidtwcobors-0/+10419
Ensure stack when type checking and building MIR for large if expressions Fixes #74564