Commit graph

42 commits

Author SHA1 Message Date
ninad 38c4885c39 Add more test cases 2024-04-14 21:34:14 +05:30
ninad 857f5dd475 Don't inline integer literals when out of range 2024-04-14 20:17:44 +05:30
joboet 0f52cd0e71
core: get rid of USIZE_MARKER 2024-04-12 12:00:14 +02:00
Oli Scherer ae24fef028 Use TraitRef::to_string sorting in favor of TraitRef::ord, as the latter compares DefIds which we need to avoid 2024-03-27 14:02:15 +00:00
Matthias Krüger 45e005df42
Rollup merge of #122556 - jieyouxu:non-identifier-format-arg, r=petrochenkov
Extend format arg help for simple tuple index access expression

The help is only applicable for simple field access `a.b` and (with this PR) simple tuple index access expressions `a.0`.

Closes #122535.
2024-03-19 18:03:50 +01:00
Rémy Rakic f3e9dfaed6 add non-regression test for issue 122674 2024-03-18 10:01:35 +00:00
许杰友 Jieyou Xu (Joe) 52a1125036
Extend format arg help for simple tuple index access expression 2024-03-16 22:33:02 +00:00
Nilstrieb f6b4080592
Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnay
Implement `NonZero` traits generically.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? ````@dtolnay````
2024-02-20 15:13:52 +01:00
Vadim Petrochenkov 9f8d05f29f macro_rules: Preserve all metavariable spans in a global side table 2024-02-18 11:19:24 +03:00
Markus Reiter f12d248a6a
Implement NonZero traits generically. 2024-02-17 21:58:56 +01:00
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Caio 0e9aa75bcd Move tests 2024-02-13 18:08:25 -03:00
Esteban Küber 6efddac288 Provide more context on derived obligation error primary label
Expand the primary span of E0277 when the immediate unmet bound is not what the user wrote:

```
error[E0277]: the trait bound `i32: Bar` is not satisfied
 --> f100.rs:6:6
  |
6 |     <i32 as Foo>::foo();
  |      ^^^ the trait `Bar` is not implemented for `i32`, which is required by `i32: Foo`
  |
help: this trait has no implementations, consider adding one
 --> f100.rs:2:1
  |
2 | trait Bar {}
  | ^^^^^^^^^
note: required for `i32` to implement `Foo`
 --> f100.rs:3:14
  |
3 | impl<T: Bar> Foo for T {}
  |         ---  ^^^     ^
  |         |
  |         unsatisfied trait bound introduced here
```

Fix #40120.
2024-01-30 21:28:18 +00:00
Mads Ravn 506c06636b Removing redudant note from parse error 2024-01-08 19:41:01 +01:00
Mads Ravn 5b30586ba8 Adding alignment to the list of cases to test for specific error message. Covers >, ^ and <. 2024-01-07 20:39:46 +01:00
Esteban Küber 9d846fcc11 Tweak short_ty_string to reduce number of files
When shortening types and writing them to disk, make `short_ty_string`
capable of reusing the same file, instead of writing a file per
shortened type.
2023-12-13 23:07:10 +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
Lukas Markeffsky d990eee0c8 add diagnostic for raw identifiers in format string 2023-09-06 18:55:45 +02:00
David Tolnay 823bacb6e3
Revert "Suggest using Arc on !Send/!Sync types"
This reverts commit 9de1a472b6.
2023-08-28 03:16:48 -07:00
bors e286f25ec0 Auto merge of #114507 - sebastiantoh:issue-114235, r=jackh726
Add suggestion to quote inlined format argument as string literal

Fixes #114235
2023-08-11 01:41:30 +00:00
Esteban Kuber 9de1a472b6 Suggest using Arc on !Send/!Sync types 2023-08-09 14:04:10 +00:00
Sebastian Toh d003fd9859 Add suggestion to quote inlined format argument as string literal 2023-08-05 17:29:06 +08:00
Michael Goulet a872762151 Improve error message when closing bracket interpreted as formatting fill character 2023-07-19 16:37:09 +00:00
Michael Goulet fe4d1f9fe9 Fix quotes in output 2023-07-19 16:27:28 +00:00
Michael Goulet 2c33dfea76 Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
Jubilee Young 4499daac77 Bless tests for portable-simd sync
API changes resulted in subtle MIR and impl differences
2023-05-11 12:14:57 -07:00
Vadim Petrochenkov 6f6c379ee0 rustc_middle: Fix opt_item_ident for non-local def ids 2023-05-03 20:09:10 +03:00
Dylan DPC b727132e23
Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwU
Add `ConstParamTy` trait

This is a bit sketch, but idk.
r? `@BoxyUwU`

Yet to be done:
- [x] ~~Figure out if it's okay to implement `StructuralEq` for primitives / possibly remove their special casing~~ (it should be okay, but maybe not in this PR...)
- [ ] Maybe refactor the code a little bit
- [x] Use a macro to make impls a bit nicer

Future work:
- [ ] Actually™ use the trait when checking if a `const` generic type is allowed
- [ ] _Really_ refactor the surrounding code
- [ ] Refactor `marker.rs` into multiple modules for each "theme" of markers
2023-05-02 11:44:50 +05:30
Maybe Waffle 182eee298c fixup tests wrt new normalization 2023-04-28 11:56:02 +00:00
Mara Bos 9cc5949f9f Update tests. 2023-04-24 16:16:14 +02:00
Esteban Küber 5b40aa5eb4 Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
Mara Bos 6c72a002a6 Add test for span of implicit format args captures. 2023-03-27 14:57:02 +02:00
Mara Bos 7f395f1eff Bless UI tests. 2023-03-27 14:56:59 +02:00
Nilstrieb 729185338f Properly allow macro expanded format_args invocations to uses captures
Originally, this was kinda half-allowed. There were some primitive
checks in place that looked at the span to see whether the input was
likely a literal. These "source literal" checks are needed because the
spans created during `format_args` parsing only make sense when it is
indeed a literal that was written in the source code directly.

This is orthogonal to the restriction that the first argument must be a
"direct literal", not being exanpanded from macros. This restriction was
imposed by [RFC 2795] on the basis of being too confusing. But this was
only concerned with the argument of the invocation being a literal, not
whether it was a source literal (maybe in spirit it meant it being a
source literal, this is not clear to me).

Since the original check only really cared about source literals (which
is good enough to deny the `format_args!(concat!())` example), macros
expanding to `format_args` invocations were able to use implicit
captures if they spanned the string in a way that lead back to a source
string.

The "source literal" checks were not strict enough and caused ICEs in
certain cases (see # 106191 (the space is intended to avoid spammy
backreferences)). So I tightened it up in # 106195 to really only work
if it's a direct source literal.

This caused the `indoc` crate to break. `indoc` transformed the source
literal by removing whitespace, which made it not a "source literal"
anymore (which is required to fix the ICE). But since `indoc` spanned
the literal in ways that made the old check think that it's a literal,
it was able to use implicit captures (which is useful and nice for the
users of `indoc`).

This commit properly seperates the previously introduced concepts of
"source literal" and "direct literal" and therefore allows `indoc`
invocations, which don't create "source literals" to use implicit
captures again.

[RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14 13:16:52 +00:00
Caio d75e43c371 Move tests 2023-02-16 11:42:35 -03:00
Esteban Küber a7597a1526 Tweak ICE message
Modify main message to be more conversational and emit one fewer note.
2023-02-07 19:17:24 +00:00
Matthias Krüger 2fdb3559c4
Rollup merge of #106805 - madsravn:master, r=compiler-errors
Suggest `{var:?}` when finding `{?:var}` in inline format strings

Link to issue: https://github.com/rust-lang/rust/issues/106572

This is my first PR to this project, so hopefully I can get some good pointers with me from the first PR.

Currently my idea was to test out whether or not this is the correct solution to this issue and then hopefully expand upon the idea to not only work for Debug formatting but for all of  them. If this is a valid solution, I will create a new issue to give a better error message to a broader range of wrong-order formatting.
2023-02-03 06:30:23 +01:00
Mads Ravn f922c8395d PR fixing wrong order of format parameters in strings. Issue #106572
Adding

Adding

Fixing small issues for PR

Adding tests

Removing unused binding

Changing the wording on note

Fixing PR comment
2023-02-02 12:56:04 +01:00
Esteban Küber 62ba3e70a1 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Mara Bos 47adb652d3 Update tests. 2023-01-29 20:19:26 +01:00
Nilstrieb a8086cf9df Revert "Improve heuristics whether format_args string is a source literal"
This reverts commit e6c02aad93.

Keeps the code improvements from the PR and the test (as a known-bug).
2023-01-18 20:33:17 +01:00
Albert Larsan cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00