summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2022-10-04Use Predicate ConstraintCategory when normalizingJack Huey-0/+6
(cherry picked from commit e7ca6e1b47ce31ad544cd8f0eb7e5cd47b325e63)
2022-09-16Revert "Use Predicate ConstraintCategory when normalizing"Jack Huey-6/+0
This reverts commit aae37f87632dd74856d55c0cd45d2c192379c990.
2022-09-13Use Predicate ConstraintCategory when normalizingJack Huey-0/+6
2022-09-13Use tcx.hir() utils for spans in MIR building.Camille GILLOT-3/+3
This corrects the `span_with_body` in the case of closures, which was incorrectly shortened to the `def_span`.
2022-09-12A SubstitutionPart is not a deletion if it replaces nothing with nothingMichael Goulet-3/+2
2022-09-08Rollup merge of #98933 - oli-obk:opaque_type_late_bound_lifetimes, r=lcnrDylan DPC-1/+2
Opaque types' generic params do not imply anything about their hidden type's lifetimes fixes #97104 cc ```@aliemjay```
2022-09-08stop evaluating constants in `Relate`lcnr-33/+5
2022-09-08Clarify some diagnostic messagesOli Scherer-1/+2
2022-09-07Rollup merge of #101486 - asquared31415:invalid_repr_list, r=estebankYuki Okushi-0/+4
Add list of recognized repr attributes to the unrecognized repr error
2022-09-06add list of recognized repr attributes to the unrecognized repr errorasquared31415-0/+4
2022-09-05Point out when a callable is not actually callable because its return is not ↵Michael Goulet-3/+1
sized
2022-09-04Rollup merge of #100647 - obeis:issue-99875, r=nagisaMatthias Krüger-3/+52
Make trait bound not satisfied specify kind Closes #99875
2022-09-03Shrink suggestion span of argument mismatch errorMichael Goulet-3/+3
2022-09-01Auto merge of #100707 - dzvon:fix-typo, r=davidtwcobors-1/+1
Fix a bunch of typo This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Rollup merge of #101100 - compiler-errors:generalize-call-suggestions, ↵Matthias Krüger-22/+11
r=petrochenkov Make call suggestions more general and more accurate Cleans up some suggestions that have to do with adding `()` to make typeck happy. 1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr` 1. Autoderef until we get to a callable type in `suggest_fn_call`. 1. Don't erroneously suggest calling constructor when a method/field does not exist on it. 1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`) 1. Extend call suggestions to type parameters, fn pointers, trait objects where possible 1. Suggest calling in operators too (fixes #101054) 1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
2022-08-29Rollup merge of #100898 - compiler-errors:too-many-expr-fields, r=spastorinoMatthias Krüger-4/+0
Do not report too many expr field candidates When considering "this expressions' field has a {field/method}" suggestions: 1. Don't report methods that are out of scope 2. Use `span_suggestions` instead of reporting each field candidate, which caps the number of suggestions to 4 4. Blacklist some common traits like `Clone` and `Deref` Fixes #100894
2022-08-29Make the trait bound is not satisfied specify kindObei Sideg-3/+52
2022-08-28Rollup merge of #101002 - estebank:hashmap-idx, r=davidtwcoMatthias Krüger-1/+4
Provide structured suggestion for `hashmap[idx] = val`
2022-08-28More descriptive argument placeholdersMichael Goulet-4/+4
2022-08-28Suggest calling when operator types mismatchMichael Goulet-17/+8
2022-08-27Only suggest call on nonexistent fields and methods if they make senseMichael Goulet-3/+1
2022-08-26Rollup merge of #99064 - lyming2007:issue-97687-fix, r=estebankYuki Okushi-2/+2
distinguish the method and associated function diagnostic information Methods are defined within the context of a struct and their first parameter is always self Associated functions don’t take self as a parameter ``` modified: compiler/rustc_typeck/src/check/method/suggest.rs modified: src/test/ui/auto-ref-slice-plus-ref.stderr modified: src/test/ui/block-result/issue-3563.stderr modified: src/test/ui/issues/issue-28344.stderr modified: src/test/ui/suggestions/dont-suggest-pin-array-dot-set.stderr modified: src/test/ui/suggestions/suggest-methods.stderr modified: src/test/ui/traits/trait-upcasting/subtrait-method.stderr ```
2022-08-25Do not report too many expr field candidatesMichael Goulet-4/+0
2022-08-25Provide structured suggestion for `hashmap[idx] = val`Esteban Küber-1/+4
2022-08-25Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkovYuki Okushi-4/+2
Stabilize `#![feature(label_break_value)]` See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313.
2022-08-24Rollup merge of #100906 - ChayimFriedman2:map-index-mut, r=davidtwcoMatthias Krüger-0/+1
Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexing The error can be quite confusing to newcomers. Fixes #100873. I'm not so sure about the message, open to wording suggestions.
2022-08-23Stabilize `#![feature(label_break_value)]`Joshua Nelson-4/+2
# Stabilization proposal The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now). There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`. There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed). 1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234 2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176 3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630 Many different examples of code that's simpler using this feature have been provided: - A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014 - A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize). - Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395 - Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733 - An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569 - Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006 Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249 nrc later resolved their concern, mostly because of the aforementioned macro problems. joshtriplett suggested that macros could be able to generate IR directly (https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs, and the design space seems rather speculative. joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804 withoutboats has regrettably left the language team. joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353 [issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+ ## Report + Feature gate: - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/src/test/ui/feature-gates/feature-gate-label_break_value.rs + Diagnostics: - https://github.com/rust-lang/rust/blob/6b2d3d5f3cd1e553d87b5496632132565b6779d3/compiler/rustc_parse/src/parser/diagnostics.rs#L2629 - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L749 - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L1001 - https://github.com/rust-lang/rust/blob/111df9e6eda1d752233482c1309d00d20a4bbf98/compiler/rustc_passes/src/loops.rs#L254 - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L2079 - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L1569 + Tests: - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs ## Interactions with other features Labels follow the hygiene of local variables. label-break-value is permitted within `try` blocks: ```rust let _: Result<(), ()> = try { 'foo: { Err(())?; break 'foo; } }; ``` label-break-value is disallowed within closures, generators, and async blocks: ```rust 'a: { || break 'a //~^ ERROR use of unreachable label `'a` //~| ERROR `break` inside of a closure } ``` label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]: ```rust fn labeled_match() { match false 'b: { //~ ERROR block label not supported here _ => {} } } macro_rules! m { ($b:block) => { 'lab: $b; //~ ERROR cannot use a `block` macro fragment here unsafe $b; //~ ERROR cannot use a `block` macro fragment here |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here } } fn foo() { m!({}); } ``` [_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html [_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-23Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexingChayim Refael Friedman-0/+1
The error can be quite confusing to newcomers.
2022-08-23Improve local generic parameter suggestions.Camille GILLOT-11/+10
2022-08-22bless ui testsNilstrieb-3/+3
2022-08-22Auto merge of #100868 - Dylan-DPC:rollup-a1hfi1r, r=Dylan-DPCbors-6/+1
Rollup of 5 pull requests Successful merges: - #93162 (Std module docs improvements) - #99386 (Add tests that check `Vec::retain` predicate execution order.) - #99915 (Recover keywords in trait bounds) - #100694 (Migrate rustc_ast_passes diagnostics to `SessionDiagnostic` and translatable messages (first part)) - #100757 (Catch overflow early) Failed merges: - #99917 (Move Error trait into core) r? `@ghost` `@rustbot` modify labels: rollup
2022-08-22Rollup merge of #100757 - ouz-a:issue-95134, r=jackh726Dylan DPC-6/+1
Catch overflow early Although this code should raise an overflow error, it didn't because [check_recursion_limit](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/select/struct.SelectionContext.html#method.check_recursion_limit) it checks for `depth = 128` but not for `129` which should have triggered the overflow error. Anyways this catches that error early. Fixes #95134
2022-08-22Auto merge of #100676 - lcnr:implied-bounds-yay, r=nikomatsakisbors-11/+36
implied bounds: explicitly state which types are assumed to be wf Adds a new query which maps each definition to the types which that definition assumes to be well formed. The intent is to make it easier to reason about implied bounds. This change should not influence the user-facing behavior of rustc. Notably, `borrowck` still only assumes that the function signature of associated functions is well formed while `wfcheck` assumes that the both the function signature and the impl trait ref is well formed. Not sure if that by itself can trigger UB or whether it's just annoying. As a next step, we can add `WellFormed` predicates to `predicates_of` of these items and can stop adding the wf bounds at each place which uses them. I also intend to move the computation from `assumed_wf_types` to `implied_bounds` into the `param_env` computation. This requires me to take a deeper look at `compare_predicate_entailment` which is currently somewhat weird wrt implied bounds so I am not touching this here. r? `@nikomatsakis`
2022-08-21Make check for overlapping closure span more accurateMichael Goulet-27/+1
2022-08-21Adjust messages, address some nitsMichael Goulet-1/+1
2022-08-21Targeted fixes addressing erroneous suggestionsMichael Goulet-5/+1
2022-08-21Comment a bit, use find_ancestor_in_same_ctxt to suppress some weird macro notesMichael Goulet-1/+0
2022-08-21Rework ambiguity errorsMichael Goulet-4/+3
2022-08-21Note closure kind mismatch causeMichael Goulet-1/+9
2022-08-21Do not favor projection type when pointing out arg causing fulfillment errorMichael Goulet-1/+1
2022-08-21Account for relative pathsMichael Goulet-2/+4
2022-08-21Rework point-at-argMichael Goulet-38/+106
2022-08-20Rollup merge of #100617 - chenyukang:fix-100605, r=compiler-errorsMatthias Krüger-0/+55
Suggest the right help message for as_ref Fixes #100605
2022-08-20Rollup merge of #100507 - cameron1024:suggest-lazy, r=compiler-errorsMatthias Krüger-0/+3
suggest `once_cell::Lazy` for non-const statics Addresses https://github.com/rust-lang/rust/issues/100410 Some questions: - removing the `if` seems to include too many cases (e.g. calls to non-const functions inside a `const fn`), but this code excludes the following case: ```rust const FOO: Foo = non_const_fn(); ``` Should we suggest `once_cell` in this case as well? - The original issue mentions suggesting `AtomicI32` instead of `Mutex<i32>`, should this PR address that as well?
2022-08-20Suggest the right help message for as_refyukang-0/+55
2022-08-19Auto merge of #100740 - Dylan-DPC:rollup-0td6yq4, r=Dylan-DPCbors-2/+2
Rollup of 9 pull requests Successful merges: - #99576 (Do not allow `Drop` impl on foreign fundamental types) - #100081 (never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn)) - #100208 (make NOP dyn casts not require anything about the vtable) - #100494 (Cleanup rustdoc themes) - #100522 (Only check the `DefId` for the recursion check in MIR inliner.) - #100592 (Manually implement Debug for ImportKind.) - #100598 (Don't fix builtin index when Where clause is found) - #100721 (Add diagnostics lints to `rustc_type_ir` module) - #100731 (rustdoc: count deref and non-deref as same set of used methods) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-19Auto merge of #100209 - cjgillot:source-file-index, r=estebankbors-5/+5
Lazily decode SourceFile from metadata Currently, source files from foreign crates are decoded up-front from metadata. Spans from those crates were matched with the corresponding source using binary search among those files. This PR changes the strategy by matching spans to files during encoding. This allows to decode source files on-demand, instead of up-front. The on-disk format for spans becomes: `<tag> <position from start of file> <length> <file index> <crate (if foreign file)>`.
2022-08-19Catch overflow earlyouz-a-6/+1
2022-08-19Rollup merge of #99576 - compiler-errors:foreign-fundamental-drop-is-bad, ↵Dylan DPC-2/+2
r=TaKO8Ki Do not allow `Drop` impl on foreign fundamental types `Drop` should not be implemented on `Pin<T>` even if `T` is local. This does not trigger regular orphan rules is because `Pin` is `#[fundamental]`... but we don't allow specialized `Drop` impls anyways, so these rules are not sufficient to prevent this impl on stable. Let's just choose even stricter rules, since we shouldn't be implementing `Drop` on a foreign ADT ever. Fixes #99575