about summary refs log tree commit diff
path: root/tests/ui/span
AgeCommit message (Collapse)AuthorLines
2025-01-23Bless and add testsBoxy-4/+0
2024-12-13Arbitrary self types v2: adjust diagnostic.Adrian Taylor-2/+2
The recently landed PR to adjust arbitrary self types was a bit overenthusiastic, advising folks to use the new Receiver trait even before it's been stabilized. Revert to the older wording of the lint in such cases.
2024-12-11Arbitrary self types v2: use Receiver traitAdrian Taylor-2/+2
In this new version of Arbitrary Self Types, we no longer use the Deref trait exclusively when working out which self types are valid. Instead, we follow a chain of Receiver traits. This enables methods to be called on smart pointer types which fundamentally cannot support Deref (for instance because they are wrappers for pointers that don't follow Rust's aliasing rules). This includes: * Changes to tests appropriately * New tests for: * The basics of the feature * Ensuring lifetime elision works properly * Generic Receivers * A copy of the method subst test enhanced with Receiver This is really the heart of the 'arbitrary self types v2' feature, and is the most critical commit in the current PR. Subsequent commits are focused on: * Detecting "shadowing" problems, where a smart pointer type can hide methods in the pointee. * Diagnostics and cleanup. Naming: in this commit, the "Autoderef" type is modified so that it no longer solely focuses on the "Deref" trait, but can now consider the "Receiver" trait instead. Should it be renamed, to something like "TraitFollower"? This was considered, but rejected, because * even in the Receiver case, it still considers built-in derefs * the name Autoderef is short and snappy.
2024-11-22Stabilize the 2024 editionEric Huss-1/+1
2024-09-22Don't call const normalize in error reportingMichael Goulet-2/+2
2024-09-09Ban non-array SIMDScott McMurray-2/+1
2024-08-01Do not underline suggestions for code that is already thereEsteban Küber-4/+0
When a suggestion part is for already present code, do not highlight it. If after that there are no highlights left, do not show the suggestion at all. Fix clippy lint suggestion incorrectly treated as `span_help`.
2024-07-26Peel off explicit (or implicit) deref before suggesting clone on move error ↵Michael Goulet-3/+3
in borrowck
2024-07-18Be more accurate about calculating `display_col` from a `BytePos`Esteban Küber-1/+1
No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter. This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2): ``` error: this file contains an unclosed delimiter --> $DIR/issue-68629.rs:5:17 | LL | ␜␟ts␀![{i | -- unclosed delimiter | | | unclosed delimiter LL | ␀␀ fn rݻoa>rݻm | ^ ```
2024-07-14Use ordinal number in argument errorlong-long-float-7/+7
Fix error message Fix tests Format
2024-07-05Use verbose style for argument removal suggestionEsteban Küber-8/+12
2024-06-20Fix `...` in multline code-skips in suggestionsEsteban Küber-1/+1
When we have long code skips, we write `...` in the line number gutter. For suggestions, we were "centering" the `...` with the line, but that was consistent with what we do in every other case.
2024-06-12Spell out other trait diagnosticAlex Macleod-4/+4
2024-05-21Make early lints translatableXiretza-1/+1
2024-05-11ignore generics args in attribute pathsbohan-8/+1
2024-05-03Rollup merge of #124510 - linyihai:raw-ident-in-typo-suggestion, r=fmeaseMatthias Krüger-0/+29
Add raw identifier in a typo suggestion Fixes #68962
2024-04-30Replace item names containing an error code with something more meaningfulLeón Orell Valerian Liehr-1/+1
or inline such functions if useless.
2024-04-29Add raw identifier in a typo suggestionLin Yihai-0/+29
2024-04-24Modify `find_expr` from `Span` to better account for closuresEsteban Küber-0/+3
Start pointing to where bindings were declared when they are captured in closures: ``` error[E0597]: `x` does not live long enough --> $DIR/suggest-return-closure.rs:23:9 | LL | let x = String::new(); | - binding `x` declared here ... LL | |c| { | --- value captured here LL | x.push(c); | ^ borrowed value does not live long enough ... LL | } | -- borrow later used here | | | `x` dropped here while still borrowed ``` Suggest cloning in more cases involving closures: ``` error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 | LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard help: consider cloning the value if the performance cost is acceptable | LL | if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, | ++++++++ ```
2024-04-11Suggest `.clone()` in some move errorsEsteban Küber-0/+5
``` error[E0507]: cannot move out of `*x` which is behind a shared reference --> $DIR/borrowck-fn-in-const-a.rs:6:16 | LL | return *x | ^^ move occurs because `*x` has type `String`, which does not implement the `Copy` trait | help: consider cloning the value if the performance cost is acceptable | LL - return *x LL + return x.clone() | ```
2024-04-11Account for unops when suggesting cloningEsteban Küber-6/+9
2024-04-11Suggest `.clone()` when moved while borrowedEsteban Küber-0/+20
2024-03-27Use `TraitRef::to_string` sorting in favor of `TraitRef::ord`, as the latter ↵Oli Scherer-2/+2
compares `DefId`s which we need to avoid
2024-03-07Merge collect_mod_item_types query into check_well_formedOli Scherer-2/+17
2024-02-22remove `sub_relations` from infcx, recompute in diagnosticslcnr-16/+1
we don't track them when canonicalizing or when freshening, resulting in instable caching in the old solver, and issues when instantiating query responses in the new one.
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-7/+4
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-17/+17
2024-02-14remove importing suggestions when there is a shadowed typo canddiateyukang-5/+0
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-3/+18
2024-02-06Make sure that async closures (and fns) only capture their parent callable's ↵Michael Goulet-27/+2
parameters by move, and nothing else
2024-01-29Supress unhelpful diagnostics for unresolved top level attributesyukang-12/+3
2024-01-13Bless testsGeorge-lewis-0/+1
Update tests
2024-01-05Remove revisions for THIR unsafeckMatthew Jasper-1593/+188
This is to make the diff when stabilizing it easier to review.
2023-11-24Show number in error message even for one errorNilstrieb-49/+49
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-07Rework print_disambiguation_helpMichael Goulet-4/+4
2023-10-26Tweak suggestion spans for invalid crate-level inner attributeEsteban Küber-2/+6
CC #89566.
2023-10-25Make THIR unused_unsafe lint consistent with MIRMatthew Jasper-305/+1592
Updates THIR behavior to match the changes from #93678
2023-10-02Replace `HashMap` with `IndexMap` in pattern binding resolveNilstrieb-17/+17
It will be iterated over, so we should avoid using `HashMap`.
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-2/+2
2023-09-17Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnayDylan DPC-6/+4
Remove Drop impl of mpsc Receiver and (Sync)Sender This change removes the empty `Drop` implementations for `mpsc::Receiver`, `mpsc::Sender` and `mpsc::SyncSender`. These implementations do not specify `#[may_dangle]`, so by removing them we make `mpsc` types play nice with drop check. This was previously attempted in [#105243](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337188646) but then [abandoned due to a test failure](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337227970). I've aligned the test with those for `Mutex` and `RwLock`.
2023-09-10Point out if a local trait has no implementationsMichael Goulet-0/+6
2023-08-18Bless test changesGary Guo-10/+10
2023-08-18Remove Drop impl of mpsc Receiver and (Sync)SenderBen Schulz-6/+4
2023-08-05Auto merge of #109348 - cjgillot:issue-109146, r=petrochenkovbors-4/+4
Resolve visibility paths as modules not as types. Asking for a resolution with `opt_ns = Some(TypeNS)` allows path resolution to look for type-relative paths, leaving unresolved segments behind. However, for visibility paths we really need to look for a module, so we need to pass `opt_ns = None`. Fixes https://github.com/rust-lang/rust/issues/109146 r? `@petrochenkov`
2023-08-04Improve spans for indexing expressionsNilstrieb-2/+2
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-02Resolve visibility paths as modules not as types.Camille GILLOT-4/+4
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-30/+32
2023-07-08Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillotMatthias Krüger-2/+2
Don't call `query_normalize` when reporting similar impls Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well. The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions: ``` error[E0277]: the trait bound `[X; 35]: Default` is not satisfied --> /home/gh-compiler-errors/test.rs:4:5 | 4 | <[X; 35] as Default>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: &[T] &mut [T] [T; 32] [T; core::::array::{impl#30}::{constant#0}] [T; core::::array::{impl#31}::{constant#0}] [T; core::::array::{impl#32}::{constant#0}] [T; core::::array::{impl#33}::{constant#0}] [T; core::::array::{impl#34}::{constant#0}] and 27 others ``` So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-2/+2
2023-06-24fix testasquared31415-3/+28