about summary refs log tree commit diff
path: root/src/test/ui/lint
AgeCommit message (Collapse)AuthorLines
2019-12-18Add more tests for raw_ref_opMatthew Jasper-4/+18
2019-12-14Revert "Remove `#![feature(never_type)]` from tests."Niko Matsakis-4/+5
This reverts commit 8f6197f39f7d468dfc5b2bd41dae4769992a2f83.
2019-12-06Remove failing test caseGeorg Semmler-18/+0
2019-12-03Fix #66295Georg Semmler-11/+20
2019-11-24Update tests for raw array in FFI lintElichai Turkel-1/+33
2019-11-21Remove `#![feature(never_type)]` from tests.Mazdak Farrokhzad-5/+4
Also remove `never_type` the feature-gate test.
2019-11-16Use "field is never read" instead of "field is never used"cosine-10/+10
2019-11-14Auto merge of #66314 - GuillaumeGomez:move-error-codes, r=Centrilbors-2/+1
Move error codes Works towards #66210. r? @Centril Oh btw, for the ones interested, I used this python script to get all error codes content sorted into one final file: <details> ```python from os import listdir from os.path import isdir, isfile, join def get_error_codes(error_codes, f_path): with open(f_path) as f: short_mode = False lines = f.read().split("\n") i = 0 while i < len(lines): line = lines[i] if not short_mode and line.startswith("E0") and line.endswith(": r##\""): error = line error += "\n" i += 1 while i < len(lines): line = lines[i] error += line if line.endswith("\"##,"): break error += "\n" i += 1 error_codes["long"].append(error) elif line == ';': short_mode = True elif short_mode is True and len(line) > 0 and line != "}": error_codes["short"].append(line) while i + 1 < len(lines): line = lines[i + 1].strip() if not line.startswith("//"): break parts = line.split("//") if len(parts) < 2: break if parts[1].strip().startswith("E0"): break error_codes["short"][-1] += "\n" error_codes["short"][-1] += lines[i + 1] i += 1 i += 1 def loop_dirs(error_codes, cur_dir): for entry in listdir(cur_dir): f = join(cur_dir, entry) if isfile(f) and entry == "error_codes.rs": get_error_codes(error_codes, f) elif isdir(f) and not entry.startswith("librustc_error_codes"): loop_dirs(error_codes, f) def get_error_code(err): x = err.split(",") if len(x) < 2: return err x = x[0] if x.strip().startswith("//"): x = x.split("//")[1].strip() return x.strip() def write_into_file(error_codes, f_path): with open(f_path, "w") as f: f.write("// Error messages for EXXXX errors. Each message should start and end with a\n") f.write("// new line, and be wrapped to 80 characters. In vim you can `:set tw=80` and\n") f.write("// use `gq` to wrap paragraphs. Use `:set tw=0` to disable.\n\n") f.write("syntax::register_diagnostics! {\n\n") error_codes["long"].sort() for i in error_codes["long"]: f.write(i) f.write("\n\n") f.write(";\n") error_codes["short"] = sorted(error_codes["short"], key=lambda err: get_error_code(err)) for i in error_codes["short"]: f.write(i) f.write("\n") f.write("}\n") error_codes = { "long": [], "short": [] } loop_dirs(error_codes, "src") write_into_file(error_codes, "src/librustc_error_codes/src/error_codes.rs") ``` </details> And to move the error codes into their own files: <details> ```python import os try: os.mkdir("src/librustc_error_codes/error_codes") except OSError: print("Seems like folder already exist, moving on!") data = '' with open("src/librustc_error_codes/error_codes.rs") as f: x = f.read().split('\n') i = 0 short_part = False while i < len(x): line = x[i] if short_part is False and line.startswith('E0') and line.endswith(': r##"'): err_code = line.split(':')[0] i += 1 content = '' while i < len(x): if x[i] == '"##,': break content += x[i] content += '\n' i += 1 f_path = "src/librustc_error_codes/error_codes/{}.md".format(err_code) with open(f_path, "w") as ff: ff.write(content) data += '{}: include_str!("./error_codes/{}.md"),'.format(err_code, err_code) elif short_part is False and line == ';': short_part is True data += ';\n' else: data += line data += '\n' i += 1 with open("src/librustc_error_codes/error_codes.rs", "w") as f: f.write(data) ``` </details>
2019-11-14Fix ui tests with better error code usageGuillaume Gomez-2/+1
2019-11-13Revert "Auto merge of #65134 - ↵Robin Kruppe-433/+0
davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, r=rkruppe" This reverts commit 3f0e16473de5ec010f44290a8c3ea1d90e0ad7a2, reversing changes made to 61a551b4939ec1d5596e585351038b8fbd0124ba.
2019-11-10Make error and warning annotations mandatory in UI testsTomasz Miąsko-95/+113
This change makes error and warning annotations mandatory in UI tests. The only exception are tests that use error patterns to match compiler output and don't have any annotations.
2019-11-07Rollup merge of #66182 - RalfJung:invalid-value, r=CentrilMazdak Farrokhzad-35/+35
invalid_value lint: fix help text Now that we also warn about `MaybUninit::uninit().assume_init()`, just telling people "use `MaybeUninit`" isn't always sufficient. And anyway this seems like an important enough point to mention it here.
2019-11-07Rollup merge of #66087 - tmiasko:ui-mode, r=CentrilMazdak Farrokhzad-4/+4
Update some build-pass ui tests to use check-pass where applicable Helps with issue https://github.com/rust-lang/rust/issues/62277.
2019-11-07invalid_value lint: fix help textRalf Jung-35/+35
2019-11-07Rollup merge of #66044 - RalfJung:uninit-lint, r=oli-obkYuki Okushi-7/+71
Improve uninit/zeroed lint * Also warn when creating a raw pointer with a NULL vtable. * Also identify `MaybeUninit::uninit().assume_init()` and `MaybeUninit::zeroed().assume_init()` as dangerous.
2019-11-06Auto merge of #65134 - davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, ↵bors-0/+433
r=rkruppe improper_ctypes: `extern "C"` fns cc #19834. Fixes #65867. This pull request implements the change [described in this comment](https://github.com/rust-lang/rust/issues/19834#issuecomment-466671572). cc @rkruppe @varkor @shepmaster
2019-11-06Auto merge of #65830 - Quantumplation:master, r=davidtwco,estebankbors-48/+266
Use ident.span instead of def_span in dead-code pass Hello! First time contributor! :) This should fix #58729. According to @estebank in the duplicate #63064, def_span scans forward on the line until it finds a {, and if it can't find one, falls back to the span for the whole item. This was apparently written before the identifier span was explicitly tracked on each node. This means that if an unused function signature spans multiple lines, the entire function (potentially hundreds of lines) gets flagged as dead code. This could, for example, cause IDEs to add error squiggly's to the whole function. By using the span from the ident instead, we narrow the scope of this in most cases. In a wider sense, it's probably safe to use ident.span instead of def_span in most locations throughout the whole code base, but since this is my first contribution, I kept it small. Some interesting points that came up while I was working on this: - I reorganized the tests a bit to bring some of the dead code ones all into the same location - A few tests were for things unrelated to dead code (like the path-lookahead for parens), so I added #![allow(dead_code)] and cleaned up the stderr file to reduce noise in the future - The same fix doesn't apply to const and static declarations. I tried adding these cases to the match expression, but that created a much wider change to tests and error messages, so I left it off until I could get some code review to validate the approach.
2019-11-05improper ctypes: adjust lint msg for extern fnsDavid Wood-24/+24
Signed-off-by: David Wood <david@davidtw.co>
2019-11-05improper_ctypes: `extern "C"` fnsDavid Wood-0/+433
2019-11-04Use check-pass in ui tests where appropriateTomasz Miąsko-4/+4
2019-11-02also identiy MaybeUninit::uninit().assume_init() as dangerousRalf Jung-1/+40
2019-11-02uninit/zeroed lint: warn against NULL vtablesRalf Jung-7/+32
2019-11-02Update error annotations in tests that successfully compileTomasz Miąsko-7/+9
Those annotation are silently ignored rather than begin validated against compiler output. Update them before validation is enabled, to avoid test failures.
2019-11-01Rollup merge of #65112 - jack-t:type-parens-lint, r=varkorTyler Mandry-12/+30
Add lint and tests for unnecessary parens around types This is my first contribution to the Rust project, so I apologize if I'm not doing things the right way. The PR fixes #64169. It adds a lint and tests for unnecessary parentheses around types. I've run `tidy` and `rustfmt` &mdash; I'm not totally sure it worked right, though &mdash; and I've tried to follow the instructions linked in the readme. I tried to think through all the variants of `ast::TyKind` to find exceptions to this lint, and I could only find the one mentioned in the original issue, which concerns types with `dyn`. I'm not a Rust expert, thought, so I may well be missing something. There's also a problem with getting this to build. The new lint catches several things in the, e.g., `core`. Because `x.py` seems to build with an equivalent of `-Werror`, what would have been warnings cause the build to break. I got it to build and the tests to pass with `--warnings warn` on my `x.py build` and `x.py test` commands.
2019-10-29Add lint for unnecessary parens around typesjack-t-12/+30
2019-10-29Rollup merge of #65294 - varkor:lint-inline-prototype, r=matthewjasperMazdak Farrokhzad-0/+142
Lint ignored `#[inline]` on function prototypes Fixes https://github.com/rust-lang/rust/issues/51280. - Adds a `unused_attribute` lint for `#[inline]` on function prototypes. - As a consequence, foreign items, impl items and trait items now have their attributes checked, which could cause some code to no longer compile (it was previously erroneously ignored).
2019-10-26Use ident instead of def_span in dead-code passPi Lanningham-42/+87
According to @estebank, def_span scans forward on the line until it finds a {, and if it can't find one, fallse back to the span for the whole item. This was apparently written before the identifier span was explicitly tracked on each node. This means that if an unused function signature spans multiple lines, the entire function (potentially hundreds of lines) gets flagged as dead code. This could, for example, cause IDEs to add error squiggly's to the whole function. By using the span from the ident instead, we narrow the scope of this in most cases. In a wider sense, it's probably safe to use ident.span instead of def_span in most locations throughout the whole code base, but since this is my first contribution, I kept it small. Some interesting points that came up while I was working on this: - I reorganized the tests a bit to bring some of the dead code ones all into the same location - A few tests were for things unrelated to dead code (like the path-lookahead for parens), so I added #![allow(dead_code)] and cleaned up the stderr file to reduce noise in the future - The same fix doesn't apply to const and static declarations. I tried adding these cases to the match expression, but that created a much wider change to tests and error messages, so I left it off until I could get some code review to validate the approach.
2019-10-26Move dead_code related tests to test/ui/dead-codePi Lanningham-14/+187
This helps organize the tests better. I also renamed several of the tests to remove redundant dead-code in the path, and better match what they're testing
2019-10-26Make inline associated constants a future compatibility warningvarkor-17/+28
2019-10-25Handle `ImplItem` in `check_attr`varkor-5/+49
2019-10-25Add test for attribute error checking on trait and foreign itemsvarkor-0/+54
2019-10-25Emit warning for ignored #[inline] on foreign function prototypesvarkor-0/+11
2019-10-25Emit warning for ignored #[inline] on trait method prototypesvarkor-0/+22
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+1
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-23Rollup merge of #65507 - polyedre:master, r=nikomatsakisYuki Okushi-754/+66
Fix test style in unused parentheses lint test I think this fixes #63237 I'm not sure if I had to add text after the `//~ ERROR` comments. This is my first pull request, so I'm open to feedback. This issues already received one pull request [here](https://github.com/rust-lang/rust/pull/63257) but it was marked as closed for inactivity. r? @nikomatsakis
2019-10-19Auto merge of #64890 - wesleywiser:const_prop_rvalue, r=oli-obkbors-2/+8
[const-prop] Handle remaining MIR Rvalue cases r? @oli-obk
2019-10-18Added text after error messagesLucas Henry-26/+26
2019-10-18[const-prop] Handle MIR Rvalue::AggregatesWesley Wiser-2/+8
2019-10-18Change how `Symbol::Debug` works.Nicholas Nethercote-1/+1
Currently, `Symbol::Debug` and `Symbol::Display` produce the same output; neither wraps the symbol in double quotes. This commit changes `Symbol::Debug` so it wraps the symbol in quotes. This change brings `Symbol`'s behaviour in line with `String` and `InternedString`. The change requires a couple of trivial test output adjustments.
2019-10-17Replaced pretty-json error-format with only jsonLucas Henry-106/+6
2019-10-17Replaced pretty-json error-format with only jsonLucas Henry-626/+22
2019-10-17Replaced warn attribute by denyLucas Henry-144/+152
2019-10-17Replaced warn attibute by denyLucas Henry-26/+34
2019-10-15Organize `never_type` testsMazdak Farrokhzad-4/+3
Also move {run-fail -> ui}/never_type
2019-10-14Tweak heuristics for less noiseEsteban Küber-5/+5
2019-10-14Use heuristics for capitalization warning in suggestionsEsteban Küber-8/+8
2019-10-13Bring attention to suggestions when the only difference is capitalizationEsteban Küber-28/+28
2019-09-29syntax: fix #64682.Mazdak Farrokhzad-5/+38
Fuse parsing of `self` into `parse_param_general`.
2019-09-28Rollup merge of #64387 - nathanwhit:redundant-semi-fix, r=varkorMazdak Farrokhzad-0/+52
Fix redundant semicolon lint interaction with proc macro attributes Fixes #63967 and fixes #63947, both of which were caused by the lint's changes to the parser interacting poorly with proc macro attributes and causing span information to be lost r? @varkor
2019-09-28Fix lint-exceeding-bitshifts ui testsWesley Wiser-23/+27