about summary refs log tree commit diff
path: root/src/test/ui/span
AgeCommit message (Collapse)AuthorLines
2021-09-25Use larger span for adjustments on method callsAaron Hill-31/+32
Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-15Point to closure when emitting 'cannot move out' for captured variableFabian Wolff-4/+10
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-7/+7
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-11Modify structured suggestion outputEsteban Küber-39/+39
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-09Use smaller spans when suggesting method call disambiguationEsteban Kuber-4/+5
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-1/+1
2021-07-30Use multispan suggestions more oftenEsteban Küber-4/+6
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-26Actually infer args in visitorskadmin-2/+26
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-3/+6
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-06-20Specify if struct/enum in arg mismatch errorSmitty-2/+2
2021-05-27Test THIR unsafeck for unsafe ops in closuresLeSeulArtichaut-9/+78
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-6/+6
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-02-17Rollup merge of #81860 - osa1:issue81800, r=estebankDylan DPC-0/+21
Fix SourceMap::start_point `start_point` needs to return the *first* character's span, but it would previously call `find_width_of_character_at_span` which returns the span of the *last* character. The implementation is now fixed. Other changes: - Docs for start_point, end_point, find_width_of_character_at_span updated - Minor simplification in find_width_of_character_at_span code Fixes #81800
2021-02-07Fix SourceMap::start_pointÖmer Sinan Ağacan-0/+21
`start_point` needs to return the *first* character's span, but it would previously call `find_width_of_character_at_span` which returns the span of the *last* character. The implementation is now fixed. Other changes: - Docs for start_point, end_point, find_width_of_character_at_span updated - Minor simplification in find_width_of_character_at_span code Fixes #81800
2021-02-07expand/resolve: Turn `#[derive]` into a regular macro attributeVadim Petrochenkov-35/+7
2021-02-06path trimming: ignore type aliasesDan Aloni-1/+1
2021-01-26Point only at generic arguments when they are unexpectedEsteban Küber-9/+18
2021-01-13Update tests for extern block lintingMark Rousskov-1/+1
2020-12-29Remove `compile-fail` test suiteVadim Petrochenkov-2/+2
2020-11-22Drop support for cloudabi targetsLzu Tao-3/+1
2020-11-19expand: Stop derive expansion un unexpected targets earlyVadim Petrochenkov-28/+1
Collect derive placeholders using `collect` instead of `push`
2020-11-19resolve: Centralize some error reporting for unexpected macro resolutionsVadim Petrochenkov-4/+4
2020-10-15ensure arguments are included in count mismatch spanAndy Russell-21/+39
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-08Update testsGuillaume Gomez-1/+2
2020-09-02pretty: trim paths of unique symbolsDan Aloni-43/+43
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-06-27Fix wording for anonymous parameter name helpJames Box-2/+2
2020-06-20update testsChristian Poveda-1/+3
2020-06-10review comments: only suggest one substitutionEsteban Küber-15/+3
2020-06-10On recursive ADT, provide indirection structured suggestionEsteban Küber-12/+33
2020-06-04resolve: Sort E0408 errors by Symbol strTom Eccles-10/+10
Previously errors were sorted by Symbol index instead of the string. The indexes are not the same between architectures because Symbols for architecture extensions (e.g. x86 AVX or RISC-V d) are interned before the source file is parsed. RISC-V's naming of extensions after single letters led to it having errors sorted differently for test cases using single letter variable names. Instead sort the errors by the Symbol string so that it is stable across architectures.
2020-05-07reword "possible candidate" import suggestionAndy Russell-1/+1
2020-04-29Rollup merge of #71217 - estebank:tail-borrow-sugg, r=pnkfelixDylan DPC-3/+18
Suggest `;` or assignment to drop borrows in tail exprs Address the diagnostics part of #70844. ``` error[E0597]: `counter` does not live long enough --> $DIR/issue-54556-niconii.rs:22:20 | LL | if let Ok(_) = counter.lock() { } | ^^^^^^^------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... ... LL | } | - | | | `counter` dropped here while still borrowed | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result<MutexGuard<'_>, ()>` | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | LL | if let Ok(_) = counter.lock() { }; | ^ ```
2020-04-28Suggest `;` or assignment to drop borrows in tail exprsEsteban Küber-3/+18
Address the diagnostics part of #70844. ``` error[E0597]: `counter` does not live long enough --> $DIR/issue-54556-niconii.rs:22:20 | LL | if let Ok(_) = counter.lock() { } | ^^^^^^^------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... ... LL | } | - | | | `counter` dropped here while still borrowed | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result<MutexGuard<'_>, ()>` | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | LL | if let Ok(_) = counter.lock() { }; | ^ ```
2020-04-23Moving more build-pass tests to check-passVal Markovic-2/+2
One or two tests became build-pass without the FIXME because they really needed build-pass (were failing without it). Helps with #62277
2020-04-14Rename AssocKind::Method to AssocKind::FnRustin-Liu-10/+10
Rename fn_has_self_argument to fn_has_self_parameter Rename AssocItemKind::Method to AssocItemKind::Fn Refine has_no_input_arg Refine has_no_input_arg Revert has_no_input_arg Refine suggestion_descr Move as_def_kind into AssocKind Signed-off-by: Rustin-Liu <rustin.liu@gmail.com> Fix tidy check issue Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
2020-04-11rustc: Add a warning count upon completionRoccoDev-0/+8
2020-03-24fix rebase falloutMazdak Farrokhzad-0/+2
2020-03-23Rollup merge of #70300 - aleksator:66636_reword_unused_variable_warning, ↵Mazdak Farrokhzad-1/+1
r=Dylan-DPC Reword unused variable warning Fixes #66636
2020-03-23Reword unused variable warningAlex Tokarev-1/+1
2020-03-22Increase verbosity when suggesting subtle code changesEsteban Küber-4/+5
2020-03-18Properly handle Spans that reference imported SourceFilesAaron Hill-0/+44
Previously, metadata encoding used DUMMY_SP to represent any spans that referenced an 'imported' SourceFile - e.g. a SourceFile from an upstream dependency. These leads to sub-optimal error messages in certain cases (see the included test). This PR changes how we encode and decode spans in crate metadata. We encode spans in one of two ways: * 'Local' spans, which reference non-imported SourceFiles, are encoded exactly as before. * 'Foreign' spans, which reference imported SourceFiles, are encoded with the CrateNum of their 'originating' crate. Additionally, their 'lo' and 'high' values are rebased on top of the 'originating' crate, which allows them to be used with the SourceMap data encoded for that crate. The `ExternalSource` enum is renamed to `ExternalSourceKind`. There is now a struct called `ExternalSource`, which holds an `ExternalSourceKind` along with the original line number information for the file. This is used during `Span` serialization to rebase spans onto their 'owning' crate.
2020-03-12update testsMark Mansi-1/+1
2020-02-20Rollup merge of #68877 - estebank:point-at-params, r=petrochenkovMazdak Farrokhzad-20/+32
On mismatched argument count point at arguments
2020-02-17Do not emit note suggesting to implement trait to foreign typeLeSeulArtichaut-4/+0
Update tests Extend to other operations Refractor check in a separate function Fix more tests
2020-02-11On mismatched argument count point at argumentsEsteban Küber-20/+32
2020-02-09--bless --compare-mode=nllMatthias Prechtl-2/+2
2020-02-09Auto merge of #68689 - estebank:where-clause-sugg-missing-fn, r=varkorbors-1/+1
When suggesting associated fn with type parameters, include in the structured suggestion Address #50734. ``` error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `baz` --> file.rs:14:1 | 14 | impl TraitA<()> for S { | ^^^^^^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `baz` in implementation | = help: implement the missing item: `fn foo<T>(_: T) -> Self where T: TraitB, TraitB::Item = A { unimplemented!() }` = help: implement the missing item: `fn bar<T>(_: T) -> Self { unimplemented!() }` = help: implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: std::marker::Copy { unimplemented!() }` ``` It doesn't work well for associated types with `ty::Predicate::Projection`s as we need to resugar `T: Trait, Trait::Assoc = K` → `T: Trait<Assoc = K>`.
2020-02-08review commentEsteban Küber-1/+1
2020-02-06rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.Eduard-Mihai Burtescu-3/+8