Commit Graph

18 Commits

Author SHA1 Message Date
Vadim Petrochenkov
fa72a81bea Update tests 2019-03-11 23:10:26 +03:00
varkor
9cfdb80085 Update tests
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-15 22:29:24 +00:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Zack M. Davis
475be10dbd in which unused-parens suggestions heed what the user actually wrote
Aaron Hill pointed out that unnecessary parens around a macro call
(paradigmatically, `format!`) yielded a suggestion of hideous
macro-expanded code. (The slightly unusual choice of using the
pretty-printer to compose suggestions was quite recently commented on
in the commit message for 1081bbbfc ("abolish ICE when pretty-printing
async block"), but without any grounds to condemn it as a 𝘣𝘢𝘥
choice. Hill's report provides the grounds.) `span_to_snippet` is
fallable as far as the type system is concerned (because, who knows,
macros or something), so the pretty-printing can live on in the
oft-neglected `else` branch.

Resolves #55109.
2018-10-16 21:36:02 -07:00
Alex Crichton
d7d7045374 rustc: Allow #[no_mangle] anywhere in a crate
This commit updates the compiler to allow the `#[no_mangle]` (and
`#[export_name]` attributes) to be located anywhere within a crate.
These attributes are unconditionally processed, causing the compiler to
always generate an exported symbol with the appropriate name.

After some discussion on #54135 it was found that not a great reason
this hasn't been allowed already, and it seems to match the behavior
that many expect! Previously the compiler would only export a
`#[no_mangle]` symbol if it were *publicly reachable*, meaning that it
itself is `pub` and it's otherwise publicly reachable from the root of
the crate. This new definition is that `#[no_mangle]` *is always
reachable*, no matter where it is in a crate or whether it has `pub` or
not.

This should make it much easier to declare an exported symbol with a
known and unique name, even when it's an internal implementation detail
of the crate itself. Note that these symbols will persist beyond LTO as
well, always making their way to the linker.

Along the way this commit removes the `private_no_mangle_functions` lint
(also for statics) as there's no longer any need to lint these
situations. Furthermore a good number of tests were updated now that
symbol visibility has been changed.

Closes #54135
2018-10-06 13:57:30 -07:00
Zack M. Davis
8d1cbb018e private no-mangle lints: help hint note if visibility modifier is pub
If the item is `pub`, one imagines users being confused as to why it's
not reachable/exported; a code suggestion is beyond our local knowledge
here, but we can at least offer a prose hint. (Thanks to Vadim
Petrochenkov for shooting down the present author's original bad idea
for the note text.)

While we're here, use proper HELP expectations instead of ad hoc
comments to communicate (and now, enforce) the expected suggestions in
test/ui/lint/suggestions.rs.
2018-06-30 22:48:05 -07:00
Zack M. Davis
53307473fd private no-mangle lints: issue suggestion for restricted visibility
This is probably quite a lot less likely to come up in practice than the
"inherited" (no visibility keyword) case, but now that we have
visibility spans in the HIR, we can do this, and it presumably doesn't
hurt to be exhaustive. (Who can say but that the attention to detail
just might knock someone's socks off, someday, somewhere?)

This is inspired by #47383.
2018-06-30 22:47:47 -07:00
Vadim Petrochenkov
fa2d9fc4b9 Update UI tests 2018-02-26 20:24:02 +03:00
Esteban Küber
d0bd090efb Consider all whitespace when preparing span 2018-01-26 14:24:17 -08:00
Esteban Küber
a8f77e12fc Include space in suggestion mut in bindings 2018-01-26 14:24:17 -08:00
Zack M. Davis
661e03383c in which the private no-mangle lints receive a valued lesson in humility
The incompetent fool who added these suggestions in 38e5a964f2 apparently
thought it was safe to assume that, because the offending function or
static was unreachable, it would therefore have not have any existing
visibility modifiers, making it safe for us to unconditionally suggest
inserting `pub`. This isn't true.

This resolves #47383.
2018-01-16 00:31:43 -08:00
Esteban Küber
e9f4fc8d40 Point at while true span instead of entire block 2017-12-19 15:48:46 -08:00
Esteban Küber
95a0458358 Resolve type on return type suggestion 2017-12-09 15:19:39 -08:00
Oliver Schneider
8937d6a6cf
Merge cfail and ui tests into ui tests 2017-11-24 11:32:35 +01:00
Vadim Petrochenkov
bf0cdb52f2 Add several lints into unused lint group
Remove a couple of obsolete lints
2017-10-29 22:14:23 +03:00
Zack M. Davis
8e6ed1203b bolster UI test converage for lint suggestions 2017-10-16 12:14:15 -07:00
Alex Crichton
4df1278c69 rustc: Remove used_mut_nodes from TyCtxt
This updates the borrowck query to return a result, and this result is then used
to incrementally check for unused mutable nodes given sets of all the used
mutable nodes.

Closes #42384
2017-10-14 09:29:02 -07:00
Zack M. Davis
e3b498971d code suggestions for unused-mut, while-true lints; UI test 2017-09-30 11:31:12 -07:00