about summary refs log tree commit diff
path: root/src/test/ui/borrowck
AgeCommit message (Collapse)AuthorLines
2021-07-25fix test/ui/borrowck/issue-33819ibraheemdev-1/+1
2021-07-25tidyibraheemdev-1/+1
2021-07-25suggest removing unnecessary \&mut as help messageibraheemdev-4/+7
2021-07-21Revert PR 81473 to resolve (on mainline) issues 81626 and 81658.Felix S. Klock II-1/+0
Revert "Add missing brace" This reverts commit 85ad773049536d7fed9a94ae0ac74f97135c8655. Revert "Simplify base_expr" This reverts commit 899aae465eb4ef295dc1eeb2603f744568e0768c. Revert "Warn write-only fields" This reverts commit d3c69a4c0dd98af2611b7553d1a65afef6a6ccb0.
2021-07-18Auto merge of #85686 - ptrojahn:loop_reinitialize, r=estebankbors-0/+102
Add help on reinitialization between move and access Fixes #83760
2021-07-07Add help on reinitialization between move and accessPaul Trojahn-0/+102
Fixes #83760
2021-07-02Improve error reporting for modifications behind `&` referencesFabian Wolff-13/+30
2021-06-30Move some UI tests to more suitable subdirsYuki Okushi-0/+95
2021-06-24compiletest: ignore tests on a per-revision basisSimonas Kazlauskas-2/+2
Otherwise something that ought to seemingly work like `//[x86] needs-llvm-components: x86` or `//[nll_beyond]should-fail` do not get evaluated properly.
2021-06-16Do not emit invalid suggestions on multiple mutable borrow errorsYuki Okushi-0/+32
2021-06-04updated line #'s on ui tests and removed feature flag testmarcusdunn-17/+17
2021-06-04removed more uses of feature gatemarcusdunn-1/+0
2021-05-30Do not suggest ampmut if rhs is already mutableDeadbeef-0/+20
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-5/+5
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-11improve diagnosts for GATsb-naber-5/+5
2021-05-01Closure capture borrow diagnostics for disjoint capturesChris Pardy-31/+31
2021-04-28Auto merge of #83401 - fee1-dead:master, r=davidtwcobors-0/+44
Fix ICE of for-loop mut borrowck where no suggestions are available Fixes #83309.
2021-04-12Compiler error messages: reduce assertiveness of message E0384James Addison-14/+14
This message is emitted as guidance by the compiler when a developer attempts to reassign a value to an immutable variable. Following the message will always currently work, but it may not always be the best course of action; following the 'consider ...' messaging pattern provides a hint to the developer that it could be wise to explore other alternatives.
2021-04-03Remove redundant `ignore-tidy-linelength` annotationsSimon Jakobi-55/+47
This is step 2 towards fixing #77548. In the codegen and codegen-units test suites, the `//` comment markers were kept in order not to affect any source locations. This is because these tests cannot be automatically `--bless`ed.
2021-03-23Fix ICE of for-loop mut borrowck where no suggestions are availableDeadbeef-0/+44
2021-03-19update testsmark-32/+29
2021-03-06Move some tests to more suitable subdirsYuki Okushi-0/+17
2021-02-23Rollup merge of #81629 - 1000teslas:issue-81365-fix, r=Aaron1011Dylan DPC-0/+520
Point out implicit deref coercions in borrow Fixes #81365 `@Aaron1011` I'm not sure why my code shows the note even in an implicit `Deref` call. See the output for `issue-81365-8.rs`.
2021-02-19Add deref definition location1000teslas-0/+40
Update conflict_errors.rs Add deref definition location
2021-02-15Fix test issue referenceEdward Shen-1/+1
2021-02-14Use delay_span_bug for mismatched subst/hir argEdward Shen-0/+68
2021-02-13add testb-naber-0/+30
2021-02-08Add tests1000teslas-1/+139
2021-02-08Point out implicit deref coercions in borrow1000teslas-0/+342
Clean up code
2021-02-02Rollup merge of #81634 - jesusprubio:jesusprubio/add-long-explanation-e0521, ↵Jack Huey-0/+5
r=GuillaumeGomez Add long explanation e0521 Helps with #61137
2021-02-01Update ui testsJesus Rubio-0/+5
2021-01-31Move some tests to more reasonable directoriesCaio-0/+20
2021-01-30Rollup merge of #81473 - sanxiyn:write-only-field, r=oli-obkYuki Okushi-0/+1
Warn write-only fields cc `@Boscop's` example in #49256.
2021-01-28Warn write-only fieldsSeo Sanghyeon-0/+1
2021-01-25Point to span of upvar making closure FnMut1000teslas-1/+3
Add expected error Add comment Tweak comment wording Fix after rebase to updated master Fix after rebase to updated master Distinguish mutation in normal and move closures Tweak error message Fix error message for nested closures Refactor code showing mutated upvar in closure Remove debug assert B
2021-01-17Auto merge of #80942 - c410-f3r:tests-tests-tests, r=petrochenkovbors-0/+402
Move some tests to more reasonable directories - 2 All tests with a score equal or greater than 1.0 were moved to their respective directories by issuing ```bash cat FILE | tr -s " " | tr -d '():' | sort -k3 | awk '$3 >= 1' | cut -d " " -f1-2 | sed 's;\\;/;g' | xargs -n2 git mv ``` **Observation**: The first column values is the only column with results greater zero To attest the confidentiality of the model, some manual revision of at least of tests is needed and this process will be tracked in the following list: * `src/test/ui/abi/issue-28676.rs` OK #28676 * `src/test/ui/array-slice-vec/issue-15730.rs` OK * `src/test/ui/associated-types/issue-24338.rs` OK #54823 * `src/test/ui/associated-types/issue-48551.rs` Looks OK #48551 * `src/test/ui/associated-types/issue-50301.rs` Looks OK #63577 ... cc #73494 r? `@petrochenkov`
2021-01-16Move some tests to more reasonable directories - 2Caio-0/+402
Address comments Update limits
2021-01-12Do not suggest invalid code in pattern with loopYuki Okushi-0/+25
2020-12-24Auto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwcobors-5/+5
Added better error message for shared borrow treated as unique for purposes of lifetimes Part of Issue #76630 r? `@jyn514`
2020-12-01Added better error message for shared borrow treated as unique for purposes ↵PankajChaudhary5-5/+5
of lifetimes
2020-11-09Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-SimulacrumDylan DPC-1/+1
Improve lifetime name annotations for closures & async functions * Don't refer to async functions as "generators" in error output * Where possible, emit annotations pointing exactly at the `&` in the return type of closures (when they have explicit return types) and async functions, like we do for arguments. Addresses #74072, but I wouldn't call that *closed* until annotations are identical for async and non-async functions. * Emit a better annotation when the lifetime doesn't appear in the full name type, which currently happens for opaque types like `impl Future`. Addresses #74497, but further improves could probably be made (why *doesn't* it appear in the type as `impl Future + '1`?) This is included in the same PR because the changes to `give_name_if_anonymous_region_appears_in_output` would introduce ICE otherwise (it would return `None` in cases where it didn't previously, which then gets `unwrap`ped)
2020-11-09use RegionNameHighlight for async fn and closure returnsSNCPlay42-1/+1
2020-11-02Provide diagnostic suggestion in ExprUseVisitor DelegateDhruv Jauhar-1/+1
The [Delegate trait](https://github.com/rust-lang/rust/blob/981346fc07dd5ef414c5b1b21999f7604cece006/compiler/rustc_typeck/src/expr_use_visitor.rs#L28-L38) currently use `PlaceWithHirId` which is composed of Hir `Place` and the corresponding expression id. Even though this is an accurate way of expressing how a Place is used, it can cause confusion during diagnostics. Eg: ``` let arr : [String; 5]; let [a, ...] = arr; ^^^ E1 ^^^ = ^^E2^^ ``` Here `arr` is moved because of the binding created E1. However, when we point to E1 in diagnostics with the message `arr` was moved, it can be confusing. Rather we would like to report E2 to the user. Closes: https://github.com/rust-lang/project-rfc-2229/issues/20
2020-10-16Rollup merge of #76119 - Amjad50:stabilizing-move_ref_pattern, r=nikomatsakisDylan DPC-19/+17
Stabilize move_ref_pattern # Implementation - Initially the rule was added in the run-up to 1.0. The AST-based borrow checker was having difficulty correctly enforcing match expressions that combined ref and move bindings, and so it was decided to simplify forbid the combination out right. - The move to MIR-based borrow checking made it possible to enforce the rules in a finer-grained level, but we kept the rule in place in an effort to be conservative in our changes. - In #68376, @Centril lifted the restriction but required a feature-gate. - This PR removes the feature-gate. Tracking issue: #68354. # Description This PR is to stabilize the feature `move_ref_pattern`, which allows patterns containing both `by-ref` and `by-move` bindings at the same time. For example: `Foo(ref x, y)`, where `x` is `by-ref`, and `y` is `by-move`. The rules of moving a variable also apply here when moving *part* of a variable, such as it can't be referenced or moved before. If this pattern is used, it would result in *partial move*, which means that part of the variable is moved. The variable that was partially moved from cannot be used as a whole in this case, only the parts that are still not moved can be used. ## Documentation - The reference (rust-lang/reference#881) - Rust by example (rust-lang/rust-by-example#1377) ## Tests There are many tests, but I think one of the comperhensive ones: - [borrowck-move-ref-pattern-pass.rs](https://github.com/Centril/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs) - [borrowck-move-ref-pattern.rs](https://github.com/Centril/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs) # Examples ```rust #[derive(PartialEq, Eq)] struct Finished {} #[derive(PartialEq, Eq)] struct Processing { status: ProcessStatus, } #[derive(PartialEq, Eq)] enum ProcessStatus { One, Two, Three, } #[derive(PartialEq, Eq)] enum Status { Finished(Finished), Processing(Processing), } fn check_result(_url: &str) -> Status { // fetch status from some server Status::Processing(Processing { status: ProcessStatus::One, }) } fn wait_for_result(url: &str) -> Finished { let mut previous_status = None; loop { match check_result(url) { Status::Finished(f) => return f, Status::Processing(p) => { match (&mut previous_status, p.status) { (None, status) => previous_status = Some(status), // first status (Some(previous), status) if *previous == status => {} // no change, ignore (Some(previous), status) => { // Now it can be used // new status *previous = status; } } } } } } ``` Before, we would have used: ```rust match (&previous_status, p.status) { (Some(previous), status) if *previous == status => {} // no change, ignore (_, status) => { // new status previous_status = Some(status); } } ``` Demonstrating *partial move* ```rust fn main() { #[derive(Debug)] struct Person { name: String, age: u8, } let person = Person { name: String::from("Alice"), age: 20, }; // `name` is moved out of person, but `age` is referenced let Person { name, ref age } = person; println!("The person's age is {}", age); println!("The person's name is {}", name); // Error! borrow of partially moved value: `person` partial move occurs //println!("The person struct is {:?}", person); // `person` cannot be used but `person.age` can be used as it is not moved println!("The person's age from person struct is {}", person.age); } ```
2020-10-08Suggest removing &mut from borrow of &mutLzu Tao-13/+23
Fix a typo: minding -> binding Add test for &mut &mut
2020-09-28pretty.rs: Update Closure and Generator printAman Arora-1/+1
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-09-15Stabilize move_ref_patternAmjad Alsharafi-19/+17
2020-09-02pretty: trim paths of unique symbolsDan Aloni-172/+172
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-08-30mv compiler to compiler/mark-5/+5
2020-08-08Be consistent when describing a move as a 'partial' in diagnosticsAaron Hill-195/+195
When an error occurs due to a partial move, we would use the world "partial" in some parts of the error message, but not in others. This commit ensures that we use the word 'partial' in either all or none of the diagnostic messages. Additionally, we no longer describe a move out of a `Box` via `*` as a 'partial move'. This was a pre-existing issue, but became more noticable when the word 'partial' is used in more places.