89 Commits

Author SHA1 Message Date
Guillaume Gomez
4fa4bb5633
Rollup merge of #53504 - ekse:suggestions-applicability-2, r=estebank
Set applicability for more suggestions.

Converts a couple more calls to `span_suggestion_with_applicability`  (#50723). To be on the safe side, I marked suggestions that depend on the intent of the user or that are potentially lossy conversions as MaybeIncorrect.

r? @estebank
2018-08-22 17:45:34 +02:00
kennytm
b5519db323
Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor
Fix typos found by codespell.
2018-08-21 17:51:49 +08:00
Sébastien Duquette
5a23a0d283 Set applicability for more suggestions. 2018-08-20 03:56:06 -04:00
Donato Sciarra
d3fe97f3d3 mv codemap() source_map() 2018-08-19 23:01:01 +02:00
Matthias Krüger
71120ef1e5 Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
ljedrz
aab063a40e Use Cow<str> in describe_num_args 2018-08-09 09:59:13 +02:00
ljedrz
c7646d54dd Refactor expand_preparsed_format_args 2018-08-09 08:55:49 +02:00
Esteban Küber
cce4ea5149 Point at correct span when missing comma in println 2018-08-06 20:54:51 -07:00
ljedrz
59c8a279da Replace push loops with collect() and extend() where possible 2018-07-29 18:53:22 +02:00
Esteban Küber
9a893cc2b8 Add span label for format str missing specifier 2018-07-24 20:46:22 -07:00
Esteban Küber
4d8aa5989c Use suggestions for printf format 2018-07-24 16:01:38 -07:00
Esteban Küber
f9e37625e6 Reword missing formatting arguments label 2018-07-24 09:51:04 -07:00
Esteban Küber
c55a698943 Only point at inside of string literals if they're actually string literals 2018-07-23 15:41:32 -07:00
Esteban Küber
6bcf8777fe Point only at invalid positional arguments 2018-07-23 15:09:00 -07:00
Esteban Küber
42306591b9 Point at incorrect named arg in format string 2018-07-23 08:22:20 -07:00
Esteban Küber
38abca8c2d Point at internal span in format string 2018-07-22 23:09:00 -07:00
Esteban Küber
915ff0b969 fix logic bug 2018-07-21 17:17:49 -07:00
Esteban Küber
93b2bb01a9 Remove dependency on libsyntax 2018-07-21 16:18:06 -07:00
Esteban Küber
00d500052c Gate format_args_nll behind feature flag 2018-07-21 15:50:46 -07:00
Esteban Küber
83a8af50bb Suggest space separated format str literal 2018-07-21 12:16:06 -07:00
Esteban Küber
f4306ffbfc Use correct spans for format string errors
When encountering format string errors in a raw string, or regular
string literal with embedded newlines, account for the positional
change to use correct spans.

:drive by fix: 🚗
2018-07-19 23:18:07 -07:00
Esteban Küber
154dee2dcc rework println 2018-07-19 23:18:07 -07:00
Esteban Küber
f53c145ef1 Improve suggestion for missing fmt str in println
Avoid using `concat!(fmt, "\n")` to improve the diagnostics being
emitted when the first `println!()` argument isn't a formatting string
literal.
2018-07-19 23:18:07 -07:00
ljedrz
08c113abef Deny bare trait objects in src/libsyntax_ext 2018-07-12 11:58:16 +02:00
Vadim Petrochenkov
1e4269cb83 Add Ident::as_str helper 2018-05-26 15:20:23 +03:00
Mark Simulacrum
b3734bd78f
Rollup merge of #50610 - estebank:fmt-str, r=Kimundi
Improve format string errors

Point at format string position inside the formatting string:
```
error: invalid format string: unmatched `}` found
  --> $DIR/format-string-error.rs:21:22
   |
LL |     let _ = format!("}");
   |                      ^ unmatched `}` in format string
```

Explain that argument names can't start with an underscore:
```
error: invalid format string: invalid argument name `_foo`
  --> $DIR/format-string-error.rs:15:23
   |
LL |     let _ = format!("{_foo}", _foo = 6usize);
   |                       ^^^^ invalid argument name in format string
   |
   = note: argument names cannot start with an underscore
```

Fix #23476.

The more accurate spans will only be seen when using `format!` directly, when using `println!` the diagnostics machinery makes the span be the entire statement.
2018-05-17 13:51:21 -06:00
Irina Popa
b63d7e2b1c Rename trans to codegen everywhere. 2018-05-17 15:08:30 +03:00
Esteban Küber
3f6b3bbace Improve format string errors
- Point at format string position inside the formatting string
 - Explain that argument names can't start with an underscore
2018-05-10 09:09:58 -07:00
James Sanderson
27b0f1e193 Gensym arguments for format macro 2018-04-24 21:31:22 +01:00
Vadim Petrochenkov
43ad972318 Use Span::apply_mark where possible 2018-04-06 11:48:19 +03:00
Lymia Aluysia
fad1648e0f
Initial implementation of RFC 2151, Raw Identifiers 2018-03-18 10:07:19 -05:00
leonardo.yvens
2e7e68b762 while let all the things 2018-03-05 15:58:54 -03:00
Esteban Küber
eb3da09333 Add secondary span pointing at the statement (error span) 2018-01-16 18:13:43 -08:00
Esteban Küber
a4660dfea2 Point at unused arguments for format string
Avoid overlapping spans by only pointing at the arguments that are not
being used in the argument string. Enable libsyntax to have diagnostics
with multiple primary spans by accepting `Into<MultiSpan>` instead of
`Span`.
2018-01-15 21:38:12 -08:00
Tommy Ip
b577b9aef3 Retain information on whether a format argument has explicit position 2017-11-09 20:57:58 +00:00
Tommy Ip
82d5ea4b12 Make format! positional argument errors clear 2017-11-06 16:28:30 +00:00
Eduard-Mihai Burtescu
10f66bd6e4 Use rvalue promotion to 'static instead of static items. 2017-09-10 11:20:27 +03:00
Vadim Petrochenkov
3da868dcb6 Make fields of Span private 2017-08-30 01:38:54 +03:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Isaac van Bakel
c623375326 Fixed extra cases found in better checking. 2017-08-01 23:01:24 +01:00
Nick Cameron
bbc00c9e9c format!: use a dummy span rather than callee span for the span base for temporary variables 2017-07-28 16:42:39 +12:00
Perry Fraser
0fcb4fca19 Change the error message for multiple unused print params 2017-07-18 22:06:24 -04:00
Jeffrey Seyfried
d4488b7df9 Simplify hygiene::Mark application, and
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-26 02:05:45 +00:00
kennytm
4711982314
Removed as many "```ignore" as possible.
Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.

Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-23 15:31:53 +08:00
Jeffrey Seyfried
7fdc1fb2e4 Hygienize lifetimes. 2017-05-25 05:52:09 +00:00
Jeffrey Seyfried
f08d5ad4c5 Refactor how spans are combined in the parser. 2017-03-29 11:17:59 +00:00
Jeffrey Seyfried
ec7c0aece1 Merge ExpnId and SyntaxContext. 2017-03-29 00:41:10 +00:00
Jeffrey Seyfried
e85a0d70b8 Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Jeffrey Seyfried
d2f8fb0a0a Move syntax::util::interner -> syntax::symbol, cleanup. 2016-11-20 23:40:20 +00:00
Eduard-Mihai Burtescu
048daa6224 Rollup merge of #37695 - estebank:unescaped-curly, r=alexcrichton
On fmt string with unescaped `{` note how to escape

On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char.

Fix #34300.
2016-11-12 10:38:42 +02:00