Commit Graph

65 Commits

Author SHA1 Message Date
Matthias Krüger
1164c2725e
Rollup merge of #122217 - estebank:issue-119685, r=fmease
Handle str literals written with `'` lexed as lifetime

Given `'hello world'` and `'1 str', provide a structured suggestion for a valid string literal:

```
error[E0762]: unterminated character literal
  --> $DIR/lex-bad-str-literal-as-char-3.rs:2:26
   |
LL |     println!('hello world');
   |                          ^^^^
   |
help: if you meant to write a `str` literal, use double quotes
   |
LL |     println!("hello world");
   |              ~           ~
```
```
error[E0762]: unterminated character literal
  --> $DIR/lex-bad-str-literal-as-char-1.rs:2:20
   |
LL |     println!('1 + 1');
   |                    ^^^^
   |
help: if you meant to write a `str` literal, use double quotes
   |
LL |     println!("1 + 1");
   |              ~     ~
```

Fix #119685.
2024-03-24 01:05:51 +01:00
Matthias Krüger
e647543cda
Rollup merge of #122844 - matthiaskrgr:just_one_more_test_mom, r=compiler-errors
add test for ice "cannot relate region: LUB(ReErased, ReError)"

Fixes #109178
2024-03-22 01:07:34 +01:00
Matthias Krüger
847311e36f add test for ice "cannot relate region: LUB(ReErased, ReError)"
Fixes #109178
2024-03-21 22:02:32 +01:00
Matthias Krüger
35a78459aa add test for https://github.com/rust-lang/rust/issues/122098 ICE: index out of bounds, snapshot_vec.rs
Fixes #122098
2024-03-21 20:57:54 +01:00
Ali MJ Al-Nasrawy
19e0ea4a6d make type_flags(ReError) & HAS_ERROR 2024-03-20 17:29:58 +00:00
Esteban Küber
6c31f6ce12 Provide structured suggestion for #![feature(foo)]
```
error: `S2<'_>` is forbidden as the type of a const generic parameter
  --> $DIR/lifetime-in-const-param.rs:5:23
   |
LL | struct S<'a, const N: S2>(&'a ());
   |                       ^^
   |
   = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
   |
LL + #![feature(adt_const_params)]
   |
```

Fix #55941.
2024-03-18 16:08:58 +00:00
Esteban Küber
999a0dc300 review comment: str -> string in messages 2024-03-17 23:35:18 +00:00
Esteban Küber
4a10b01f95 Use shorter span for existing ' -> " structured suggestion 2024-03-17 23:35:18 +00:00
Michael Goulet
383051092f Ignore tests w/ current/next revisions from compare-mode=next-solver 2024-03-10 21:18:41 -04:00
Caio
2aab000105 Move tests 2024-03-03 16:30:48 -03:00
yukang
e2ce5d74a5 renaming test cases 2024-02-29 08:46:00 +08:00
yukang
e6f48fa0bb Suggest removing superfluous semicolos when statements used as expressions 2024-02-29 08:24:00 +08:00
Nicholas Nethercote
72b172bdf6 Overhaul the handling of errors at the top-level.
Currently `emit_stashed_diagnostic` is called from four(!) different
places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`,
and `compile_status`.

And `flush_delayed` is called from two different places:
`DiagCtxtInner::drop` and `Queries`.

This is pretty gross! Each one should really be called from a single
place, but there's a bunch of entanglements. This commit cleans up this
mess.

Specifically, it:
- Removes all the existing calls to `emit_stashed_diagnostic`, and adds
  a single new call in `finish_diagnostics`.
- Removes the early `flush_delayed` call in `codegen_and_build_linker`,
  replacing it with a simple early return if delayed bugs are present.
- Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so
  they both assert that the stashed diagnostics are empty (i.e.
  processed beforehand).
- Changes `interface::run_compiler` so that any errors emitted during
  `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are
  counted and cannot be overlooked. This requires adding
  `ErrorGuaranteed` return values to several functions.
- Removes the `stashed_err_count` call in `analysis`. This is possible
  now that we don't have to worry about calling `flush_delayed` early
  from `codegen_and_build_linker` when stashed diagnostics are pending.
- Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a
  `delayed_span_bug`, because it now can be reached due to the removal
  of the `stashed_err_count` call in `analysis`.
- Slightly changes the expected output of three tests. If no errors are
  emitted but there are delayed bugs, the error count is no longer
  printed. This is because delayed bugs are now always printed after the
  error count is printed (or not printed, if the error count is zero).

There is a lot going on in this commit. It's hard to break into smaller
pieces because the existing code is very tangled. It took me a long time
and a lot of effort to understand how the different pieces interact, and
I think the new code is a lot simpler and easier to understand.
2024-02-22 08:03:47 +11:00
Esteban Küber
b4a424feb8 Drive-by DUMMY_SP -> Span and fmt changes
Noticed these while doing something else. There's no practical change, but it's preferable to use `DUMMY_SP` as little as possible, particularly when we have perfectlly useful `Span`s available.
2024-02-19 17:04:23 +00:00
许杰友 Jieyou Xu (Joe)
ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
bors
ee9c7c940c Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errors
Continue compilation after check_mod_type_wf errors

The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too.

The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication.

fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14 18:32:19 +00:00
Oli Scherer
5f6390f947 Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
Caio
0e9aa75bcd Move tests 2024-02-13 18:08:25 -03:00
Oli Scherer
a6b1e433da Remove a has_errors check that only hides errors after unrelated items have errored. 2024-01-31 16:51:42 +00:00
Esteban Küber
a9841936fe Deduplicate more sized errors on call exprs
Change the implicit `Sized` `Obligation` `Span` for call expressions to
include the whole expression. This aids the existing deduplication
machinery to reduce the number of errors caused by a single unsized
expression.
2024-01-24 02:53:15 +00:00
lcnr
058ab53dc5 use implied bounds compat mode in MIR borrowck 2024-01-19 15:27:32 +01:00
Jack Huey
a9e30e6cdf Don't use compat versions of implied bounds in ImpliedOutlivesBounds query 2024-01-17 22:03:06 -05:00
George-lewis
d56cdd48cb Bless tests
Update tests
2024-01-13 12:46:58 -05:00
Jake Goulding
53eca9fa87 Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
lcnr
11d16c4082 update use of feature flags 2023-12-14 15:22:37 +01:00
Michael Goulet
d473bdfdc3 Support bare unit structs in destructuring assignments 2023-12-08 19:55:07 +00:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Oli Scherer
fd9ef69adf Avoid a track_errors by bubbling up most errors from check_well_formed 2023-10-20 08:46:27 +00:00
Esteban Küber
bd8b46800d Tweak wording of type errors involving type params
Fix #78206.
2023-10-18 23:53:18 +00:00
yukang
25d38c48c3 Suggest adding return if the type of unused semi return value can coerce to the fn return type 2023-10-15 22:57:03 +08:00
Esteban Küber
4483ac2206 Fix windows test that has different stderr output 2023-10-06 15:51:04 +00:00
Esteban Küber
91b9ffeab0 Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
2023-10-04 02:04:14 +00:00
Esteban Küber
2817ece19c Show more information when multiple impl apply 2023-10-04 02:04:13 +00:00
Esteban Küber
ecf2f68e45 Tweak output of to_pretty_impl_header involving only anon lifetimes
Do not print `impl<> Foo for &Bar`.
2023-08-28 17:17:11 +00:00
Esteban Küber
b6494a7bb4 More accurately point at arguments 2023-08-26 19:25:46 +00:00
beetrees
072d8c8bbc
Fix suggestion for attempting to define a string with single quotes 2023-08-16 21:51:57 +01:00
Michael Goulet
d21a335e8f Don't select infer -> dyn Trait 2023-08-01 23:12:03 +00:00
lcnr
e449daad6c stop mentioning number of applicate implementations 2023-07-16 15:36:19 +02:00
lcnr
19d46b690a self type param infer, avoid ICE 2023-07-16 15:29:08 +02:00
Jubilee
f7a34f9518
Rollup merge of #113567 - chenyukang:yukang-fix-113354-while-let, r=cjgillot
While let suggestion will work for closure body

Fixes #113354
2023-07-11 21:00:28 -07:00
yukang
9aed9697cf While let suggestion will work for closure 2023-07-11 22:00:53 +08:00
许杰友 Jieyou Xu (Joe)
b5208b3611
Don't suggest impl Trait in path position 2023-07-08 00:04:33 +08:00
Michael Goulet
acf257e62c Point at correct exprs for assert_eq type mismatch 2023-06-08 16:30:05 +00:00
Matthias Krüger
985ea22489
Rollup merge of #111021 - c410-f3r:dqewdas, r=petrochenkov
Move some tests

r? ``@petrochenkov``
2023-05-09 20:49:31 +02:00
Caio
0285611096 Move tests 2023-05-08 17:58:01 -03:00
Michael Goulet
a9051d861c Tweak borrow suggestion 2023-05-08 03:36:30 +00:00
Matthias Krüger
bcd55cebfa
Rollup merge of #110825 - notriddle:notriddle/issue-70082, r=compiler-errors
diagnostics: add test case for already-solved issue

Fixes #70082
2023-04-26 18:51:44 +02:00
Michael Howell
1bfbac7903 diagnostics: add test case for already-solved issue
Fixes #70082
2023-04-25 13:07:09 -07:00
Michael Goulet
b0a7d6e4b7 Suggest deref on comparison binop RHS even if type is not Copy 2023-04-19 16:47:11 +00:00
ickk
30f458ed1e update tests/ui 2023-04-07 18:07:11 +10:00