about summary refs log tree commit diff
path: root/src/test/ui/macros
AgeCommit message (Collapse)AuthorLines
2018-08-07Suggest comma when missing in macro callEsteban Küber-4/+36
When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion.
2018-08-06Point at correct span when missing comma in `println`Esteban Küber-7/+19
2018-08-06Suggest comma when writing `println!("{}" a);`Esteban Küber-0/+24
2018-08-01Switch to bootstrapping from 1.29 betaMark Rousskov-4/+1
2018-07-31Use suggestions for shell format argumentsEsteban Küber-5/+24
2018-07-26Rollup merge of #52649 - estebank:fmt-span, r=oli-obkMark Rousskov-13/+43
Point spans to inner elements of format strings - Point at missing positional specifiers in string literal ``` error: invalid reference to positional arguments 3, 4 and 5 (there are 3 arguments) --> $DIR/ifmt-bad-arg.rs:34:38 | LL | format!("{name} {value} {} {} {} {} {} {}", 0, name=1, value=2); | ^^ ^^ ^^ | = note: positional arguments are zero-based ``` - Point at named formatting specifier in string literal ``` error: there is no argument named `foo` --> $DIR/ifmt-bad-arg.rs:37:17 | LL | format!("{} {foo} {} {bar} {}", 1, 2, 3); | ^^^^^ ``` - Update label for formatting string in "multiple unused formatting arguments" to be more correct ``` error: multiple unused formatting arguments --> $DIR/ifmt-bad-arg.rs:42:17 | LL | format!("", 1, 2); //~ ERROR: multiple unused formatting arguments | -- ^ ^ | | | multiple missing formatting specifiers ``` - When using `printf` string formatting, provide a structured suggestion instead of a note ``` error: multiple unused formatting arguments --> $DIR/format-foreign.rs:12:30 | LL | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments | -------------- ^^^^^^^^ ^^^^^^^ ^ | | | multiple missing formatting specifiers | = note: printf formatting not supported; see the documentation for `std::fmt` help: format specifiers in Rust are written using `{}` | LL | println!("{:.2$} {}!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments | ^^^^^^ ^^ ```
2018-07-24Add span label for format str missing specifierEsteban Küber-5/+9
2018-07-24Use suggestions for `printf` formatEsteban Küber-7/+33
2018-07-24Reword missing formatting arguments labelEsteban Küber-4/+4
2018-07-23Allow by default, fix testsmark-2/+18
2018-07-23Implement 2015 vs 2018 `?` kleene op + testmark-133/+376
2018-07-23Only point at inside of string literals if they're actually string literalsEsteban Küber-2/+2
2018-07-22Point at internal span in format stringEsteban Küber-2/+2
2018-07-22Auto merge of #52394 - estebank:println, r=oli-obkbors-35/+74
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. Fix #52347.
2018-07-21Suggest space separated format str literalEsteban Küber-2/+2
2018-07-20Update tests for new NLL mutability errorsMatthew Jasper-1/+1
2018-07-19rework printlnEsteban Küber-4/+4
2018-07-19review comments: modify note wording and change `println`Esteban Küber-5/+32
- Don't print the newline on its own to avoid the possibility of printing it out of order due to `stdout` locking. - Modify wording of `concat!()` with non-literals to not mislead into believing that only `&str` literals are accepted. - Add test for `concat!()` with non-literals.
2018-07-19Improve suggestion for missing fmt str in printlnEsteban Küber-35/+47
Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal.
2018-07-11suggest on new snippetcsmoe-4/+2
2018-07-06suggests with whole macro callcsmoe-1/+7
2018-07-03Suggestion for printcsmoe-1/+1
2018-06-19NLL: Updates to diagnostic output in `test/ui`.Felix S. Klock II-0/+2
2018-06-07Revert "Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov"Pietro Albini-44/+66
This reverts commit d6ba1b9b021c408fcad60ee52acf8af5e1b2eb00, reversing changes made to 8de5353f75dcde04abe947e0560dc5edd861cf3a.
2018-05-22Remove the unstable Float traitSimon Sapin-10/+10
Following up to #49896 and #50629. Fixes #32110. E0689 is weird.
2018-05-13stabilize :lifetimeAlex Burka-1/+1
2018-04-21Move intrinsics-based float methods out of libcore into libstdSimon Sapin-10/+10
Affected methods are `abs`, `signum`, and `powi`. CC https://github.com/rust-lang/rust/issues/32110#issuecomment-379503183
2018-04-16Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkovbors-66/+44
Update `?` repetition disambiguation. **Do not merge** (yet) This is a test implementation of some ideas from discussion in https://github.com/rust-lang/rust/issues/48075 . This PR - disallows `?` repetition from taking a separator, since the separator is never used. - disallows the use of `?` as a separator. This allows patterns like `$(a)?+` to match `+` and `a+` rather than `a?a?a`. This is a _breaking change_, but maybe that's ok? Perhaps a crater run is the right approach? cc @durka @alexreg @nikomatsakis
2018-04-14Auto merge of #49326 - petrochenkov:nteq, r=eddybbors-0/+47
macros: Remove matching on "complex" nonterminals requiring AST comparisons So, you can actually use nonterminals from outer macros in left hand side of nested macros and invocations of nested macros will try to match passed arguments to them. ```rust macro outer($nt_item: item) { macro inner($nt_item) { struct S; } inner!($nt_item); // OK, `$nt_item` matches `$nt_item` } ``` Why this is bad: - We can't do this matching correctly. When two nonterminals are compared, the original tokens are lost and we have to compare AST fragments instead. Right now the comparison is done by `PartialEq` impls derived on AST structures. - On one hand, AST loses information compared to original tokens (e.g. trailing separators and other simplifications done during parsing to AST), so we can produce matches that are not actually correct. - On another hand derived `PartialEq` impls for AST structures don't make much sense in general and compare various auxiliary garbage like spans. For the argument nonterminal to match we should use literally the same token (possibly cloned) as was used in the macro LHS (as in the example above). So we can reject matches that are actually correct. - Support for nonterminal matching is the only thing that forces us to derive `PartialEq` for all (!) AST structures. As I mentioned these impls are also mostly nonsensical. This PR removes support for matching on all nonterminals except for "simple" ones like `ident`, `lifetime` and `tt` for which we have original tokens that can be compared. After this is done I'll submit another PR removing huge number of `PartialEq` impls from AST and HIR structures. This is an arcane feature and I don't personally know why would anyone use it, but the change should ideally go through crater. We'll be able to support this feature again in the future when all nonterminals have original token streams attached to them in addition to (or instead of) AST fragments.
2018-04-14macros: Do not match on "complex" nonterminals requiring AST comparisonsVadim Petrochenkov-0/+47
2018-04-13Rename must-compile-successfully into compile-passGuillaume Gomez-1/+1
2018-04-12AST/HIR: Merge field access expressions for named and numeric fieldsVadim Petrochenkov-11/+11
2018-04-11Checkpoint the current status of NLL on `ui` tests via compare-mode=nll.Felix S. Klock II-0/+12
2018-04-06fix testMark Mansi-11/+11
2018-04-05No separator for `?`. No `?` as a separator.Mark Mansi-64/+42
2018-03-16Update testsJohn Kåre Alsaker-1/+4
2018-03-14update testsGuillaume Gomez-5/+4
2018-02-26Fix rebaseVadim Petrochenkov-13/+13
2018-02-26Update UI testsVadim Petrochenkov-2/+2
2018-02-26Update UI testsVadim Petrochenkov-53/+53
2018-02-26Auto merge of #48337 - GuillaumeGomez:rustc-explain, r=estebankbors-0/+5
Rustc explain Fixes #48041. To make the review easier, I separated tests update to code update. Also, I used this script to generate new ui tests stderr: ```python from os import listdir from os.path import isdir, isfile, join PATH = "src/test/ui" def do_something(path): files = [join(path, f) for f in listdir(path)] for f in files: if isdir(f): do_something(f) continue if not isfile(f) or not f.endswith(".stderr"): continue x = open(f, "r") content = x.read().strip() if "error[E" not in content: continue errors = dict() for y in content.splitlines(): if y.startswith("error[E"): errors[y[6:11]] = True errors = sorted(errors.keys()) if len(errors) < 1: print("weird... {}".format(f)) continue if len(errors) > 1: content += "\n\nYou've got a few errors: {}".format(", ".join(errors)) content += "\nIf you want more information on an error, try using \"rustc --explain {}\"".format(errors[0]) else: content += "\n\nIf you want more information on this error, try using \"rustc --explain {}\"".format(errors[0]) content += "\n" x = open(f, "w") x.write(content) do_something(PATH) ```
2018-02-25Update ui testsGuillaume Gomez-0/+5
2018-02-17Move macro-at-most-once-rep-ambig test to ui testMark Mansi-0/+133
2018-02-01Minimize weird spans involving macro contextEsteban Küber-0/+36
Sometimes the parser attempts to synthesize spans from within a macro context with the span for the captured argument, leading to non-sensical spans with very bad output. Given that an incorrect span is worse than a partially incomplete span, when detecting this situation return only one of the spans without mergin them.
2018-01-18Rollup merge of #47481 - estebank:unused-args, r=arielb1kennytm-39/+30
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`. Partially addresses #41850.
2018-01-16Add secondary span pointing at the statement (error span)Esteban Küber-15/+25
2018-01-15Point at unused arguments for format stringEsteban Küber-45/+26
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-15Don't include bang in macro replacement suggestionRyan Cumming-2/+2
When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang/rust#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes #47418
2018-01-04Do not use casting for suggestion to add type to numeric literalEsteban Küber-4/+4
2018-01-03Provide suggestion when trying to use method on numeric literalEsteban Küber-7/+47