Commit Graph

60 Commits

Author SHA1 Message Date
Vadim Petrochenkov
cfe81559ee resolve: Recover "did you mean" suggestions in imports 2018-11-18 13:57:01 +03:00
Vadim Petrochenkov
4c5d822a8b resolve: Check resolution consistency for import paths and multi-segment macro paths 2018-11-18 13:55:58 +03:00
Vadim Petrochenkov
07af4ec7a2 resolve: Resolve single-segment imports using in-scope resolution on 2018 edition 2018-11-18 13:51:43 +03:00
Vadim Petrochenkov
f0ea1c6f1e resolve: Improve diagnostics for resolution ambiguities 2018-11-18 13:51:40 +03:00
David Wood
0d06b8c8e5
Add note linking to Rust 2018 path semantics docs.
This commit extends existing path suggestions to link to documentation
on the changed semantics of `use` in Rust 2018.
2018-10-28 09:16:10 +01:00
Matthias Krüger
4972beaf65 fix typos in various places 2018-10-23 15:56:25 +02:00
Zack M. Davis
1ddbd81c80 pick a reference issue for absolute-paths future incompatibility info
It would be kind of embarrassing to ship with the "issue TBD" message!
2018-10-20 12:40:48 -07:00
Vadim Petrochenkov
894a8d574d resolve: Scale back hard-coded extern prelude additions 2018-10-13 21:35:19 +03:00
David Wood
9d408e0511
Update tests to demonstrate 2015 behaviour.
Adds a test to demonstrate behaviour of suggestions in the
2015 edition.
2018-10-03 14:43:58 +02:00
David Wood
29e2376ac7
Add suggestions for unresolved imports.
This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.
2018-10-03 14:43:57 +02:00
David Wood
9e2d6e1e62
Add crate:: to trait suggestions in Rust 2018.
In the 2018 edition, when suggesting traits to import that implement a
given method that is being invoked, suggestions will now include the
`crate::` prefix if the suggested trait is local to the current crate.
2018-10-02 01:16:05 +02:00
kennytm
b18821201f
Rollup merge of #54488 - zackmdavis:and_the_case_of_the_unused_crate, r=estebank
in which we include attributes in unused `extern crate` suggestion spans

![unused_extern](https://user-images.githubusercontent.com/1076988/45921698-50243e80-be6f-11e8-930a-7b2a33b4935c.png)

Resolves #54400.

r? @estebank
2018-10-01 16:12:56 +08:00
bors
93efd533a3 Auto merge of #54650 - eddyb:no-extern's-land, r=alexcrichton
Don't lint non-extern-prelude extern crate's in Rust 2018.

Fixes #54381 by silencing the lint telling users to remove `extern crate` when `use` doesn't work.

r? @alexcrichton cc @petrochenkov @nikomatsakis @Centril
2018-09-30 22:20:16 +00:00
Eduard-Mihai Burtescu
81ca8ebee2 rustc_typeck: don't lint non-extern-prelude extern crate's in Rust 2018. 2018-09-28 23:35:01 +03:00
Zack M. Davis
032d97fa01 in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.

It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:

 • One outlives-bound. We want to drop the bound altogether, including
   the colon—

   MyStruct<'a, T: 'a>
                 ^^^^ help: remove this bound

 • An outlives bound first, followed by a trait bound. We want to
   delete the outlives bound and the following plus sign (and
   hopefully get the whitespace right, too)—

   MyStruct<'a, T: 'a + MyTrait>
                   ^^^^^ help: remove this bound

 • An outlives bound after a trait bound. We want to delete the
   outlives lifetime and the preceding plus sign—

   MyStruct<'a, T: MyTrait + 'a>
                          ^^^^^ help: remove this bound

This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!

A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.

We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.

This concerns #52042.
2018-09-27 20:24:14 -07:00
Zack M. Davis
7cbe0605fa in which we include attributes in unused extern crate suggestion spans
Resolves #54400.
2018-09-22 13:51:29 -07:00
Pietro Albini
822c51121e
Rollup merge of #54261 - varkor:dyn-keyword-2018, r=petrochenkov
Make `dyn` a keyword in the 2018 edition

Proposed in https://github.com/rust-lang/rust/issues/44662#issuecomment-421596088.
2018-09-22 09:56:27 +02:00
varkor
cb594cf373 Treat dyn as a keyword in the 2018 edition 2018-09-16 23:34:42 +01:00
Eduard-Mihai Burtescu
653cd47c09 rustc_resolve: use continue instead of return to "exit" a loop iteration. 2018-09-15 22:48:10 +03:00
Eduard-Mihai Burtescu
38c82a2180 rustc_resolve: always include core, std and meta in the extern prelude. 2018-09-15 22:48:10 +03:00
Eduard-Mihai Burtescu
9eb7a3c76f rustc_resolve: don't allow ::crate_name to bypass extern_prelude. 2018-09-15 22:48:10 +03:00
Niko Matsakis
0cd8e0d03e we now successfully warn about async in macro invocations 2018-09-11 08:56:59 -04:00
Niko Matsakis
5adbdf82f3 add test case 2018-09-10 17:21:01 -04:00
Eduard-Mihai Burtescu
d5da94a3b1 rustc_resolve: ignore uniform_paths canaries that resolve to an import of the same crate. 2018-09-10 11:48:46 +03:00
Eduard-Mihai Burtescu
0a33de04cf rustc_resolve: inject uniform_paths canaries regardless of the feature-gate, on Rust 2018. 2018-09-10 11:48:46 +03:00
Mark Rousskov
5af06768a9 Remove crate_visibility_modifier from 2018 edition 2018-09-09 02:28:13 +02:00
Eduard-Mihai Burtescu
31fce914b2 rustc_resolve: allow use crate_name; under uniform_paths. 2018-09-06 22:07:56 +03:00
Alex Crichton
003cab25d7 Generalize async_idents to all new keywords
This commit generalizes the existing `async_idents` lint to easily encompass
other identifiers that will be keywords in future editions. The new lint is
called `keyword_idents` and the old `async_idents` lint is registered as renamed
to this new lint.

As a proof of concept the `try` keyword was added to this list as it looks to be
listed as a keyword in the 2018 edition only. The `await` keyword was not added
as it's not listed as a keyword yet.

Closes #53077
2018-08-29 09:34:53 -07:00
Alex Crichton
51fd3bf6a8 rustc: Suggest removing extern crate in 2018
This commit updates the `unused_extern_crates` lint to make automatic
suggestions about removing `extern crate` annotations in the 2018 edition. This
ended up being a little easier than originally though due to what's likely been
fixed issues in the resolver!

Closes #52829
2018-08-27 10:52:21 -07:00
bors
9f9f2c0095 Auto merge of #53530 - kennytm:rollup, r=kennytm
Rollup of 17 pull requests

Successful merges:

 - #53030 (Updated RELEASES.md for 1.29.0)
 - #53104 (expand the documentation on the `Unpin` trait)
 - #53213 (Stabilize IP associated constants)
 - #53296 (When closure with no arguments was expected, suggest wrapping)
 - #53329 (Replace usages of ptr::offset with ptr::{add,sub}.)
 - #53363 (add individual docs to `core::num::NonZero*`)
 - #53370 (Stabilize macro_vis_matcher)
 - #53393 (Mark libserialize functions as inline)
 - #53405 (restore the page title after escaping out of a search)
 - #53452 (Change target triple used to check for lldb in build-manifest)
 - #53462 (Document Box::into_raw returns non-null ptr)
 - #53465 (Remove LinkMeta struct)
 - #53492 (update lld submodule to include RISCV patch)
 - #53496 (Fix typos found by codespell.)
 - #53521 (syntax: Optimize some literal parsing)
 - #53540 (Moved issue-53157.rs into src/test/ui/consts/const-eval/)
 - #53551 (Avoid some Place clones.)

Failed merges:

r? @ghost
2018-08-21 16:04:11 +00:00
Alexander Regueiro
e221fcce66 Removed raw_identifiers feature gate. 2018-08-20 21:57:56 +01:00
Matthias Krüger
71120ef1e5 Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
bors
c8c587fe4e Auto merge of #50911 - petrochenkov:macuse, r=alexcrichton
Stabilize `use_extern_macros`

Closes https://github.com/rust-lang/rust/issues/35896
2018-08-17 19:10:34 +00:00
Corey Farwell
5c7b837c4e
Rollup merge of #53413 - eddyb:featured-in-the-latest-edition, r=varkor
Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018.

cc @varkor @petrochenkov @joshtriplett
2018-08-17 08:23:44 -07:00
Vadim Petrochenkov
a0958048b6 Stabilize use_extern_macros 2018-08-17 13:14:26 +03:00
Eduard-Mihai Burtescu
9b1d3c70ac rustc_resolve: don't allow paths starting with ::crate. 2018-08-17 12:59:56 +03:00
Eduard-Mihai Burtescu
7a87e30f41 rustc_resolve: overhaul #![feature(uniform_paths)] error reporting. 2018-08-17 01:41:06 +03:00
Eduard-Mihai Burtescu
32e17b5921 tests: prefer edition: directives to compile-flags:--edition. 2018-08-16 10:36:11 +03:00
Eduard-Mihai Burtescu
2c4402638e syntax: also warn about edition "umbrella" features being implied by --edition. 2018-08-16 10:35:45 +03:00
Eduard-Mihai Burtescu
13bc0b5a48 rustc_resolve: also inject canaries to detect block scopes shadowing uniform_paths imports. 2018-08-14 07:06:50 +03:00
Eduard-Mihai Burtescu
2ad865d601 rustc_resolve: inject ambiguity "canaries" when #![feature(uniform_paths)] is enabled. 2018-08-14 07:06:50 +03:00
Alex Crichton
27b3cb552d rustc: Trim down the rust_2018_idioms lint group
These migration lints aren't all up to par in terms of a good migration
experience. Some, like `unreachable_pub`, hit bugs like #52665 and unprepared
macros to be handled enough of the time. Others like linting against
`#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and
slightly buggy pending a few current PRs).

The general idea is that we will continue to recommend the `rust_2018_idioms`
lint group as part of the transition guide (as an optional step) but we'll be
much more selective about which lints make it into this group. Only those with a
strong track record of not causing too much churn will make the cut.

cc #52679
2018-08-01 07:29:24 -07:00
Alex Crichton
336cf9db5f Tweak the raw_identifiers lints in 2018
* Enable the `raw_identifiers` feature automatically in the 2018 preview
* Only emit lint warnings if the `raw_identifiers` feature is activated

cc rust-lang/cargo#5783
2018-07-26 14:14:10 -07:00
bors
12ed235adc Auto merge of #52375 - oli-obk:the_early_lint_pass_gets_the_worm, r=Manishearth
Lint `async` identifiers in 2018 preparation mode

r? @Manishearth

fixes https://github.com/rust-lang/rust/issues/49716
2018-07-18 15:04:17 +00:00
Oliver Schneider
68c93e7da0 Make async_idents allow-by-default 2018-07-18 11:45:01 +02:00
Oliver Schneider
95208044e8 Make async_idents an edition incompat lint 2018-07-17 19:56:41 +02:00
Oliver Schneider
15a8a66d5c Lint the use of async as an identifier 2018-07-14 20:44:19 +02:00
Alex Crichton
0b969a9d68 rustc: Lint against #[macro_use] in 2018 idioms
This commit adds a lint to the compiler to warn against the `#[macro_use]`
directive as part of the `rust_2018_idioms` lint. This lint is turned off by
default and is only enabled when the `use_extern_macros` feature is also
enabled.

The lint here isn't fully fleshed out as it's just a simple warning rather than
suggestions of how to actually import the macro, but hopefully it's a good base
to start from!

cc #52043
2018-07-12 14:10:39 -07:00
Zack M. Davis
96b151bd9c in which use suggestions meet edition 2018
The intent here is to resolve #52202.
2018-07-09 23:21:29 -07:00
Niko Matsakis
8b39808ffe merge UNNECESSARY_EXTERN_CRATE and UNUSED_EXTERN_CRATES 2018-06-01 11:00:18 -04:00