Commit Graph

842 Commits

Author SHA1 Message Date
Jeffrey Seyfried
b107a4e4f6 Refactor module.try_define_child(..) -> resolver.try_define(module, ..). 2016-08-01 19:06:45 +00:00
Jeffrey Seyfried
096c3ed6c6 Refactor away resolution.try_define(). 2016-08-01 19:06:44 +00:00
Jeffrey Seyfried
5868e78b09 Refactor away resolution.report_conflicts(). 2016-08-01 19:06:43 +00:00
Jeffrey Seyfried
79e82b5c41 Implement Deref for ImportResolver to Resolver. 2016-08-01 19:06:41 +00:00
Jeffrey Seyfried
d6b10beb88 Make "type aliases cannot be used for traits" a note instead of a span_label. 2016-07-31 21:29:01 +00:00
Jeffrey Seyfried
93fd214d61 Clean up resolve_trait_reference. 2016-07-31 20:40:03 +00:00
Jeffrey Seyfried
46bd5d3fa0 Avoid emitting a unhelpful cascading resolution error. 2016-07-31 20:17:08 +00:00
Manish Goregaokar
8c6421fb17 Rollup merge of #35063 - jseyfried:avoid_importing_inaccessible_names, r=nrc
resolve: Exclude inaccessible names from single imports

If a single import resolves to an inaccessible name in some but not all namespaces, avoid importing the name in the inaccessible namespaces.

Currently, the inaccessible namespaces are imported but cause a privacy error when used.

r? @nrc
2016-07-30 13:44:46 +05:30
Jeffrey Seyfried
132bff9933 If a single import resolves to an inaccessible name in some but not all namespaces,
avoid importing the name in the inaccessible namespaces.

Currently, the inaccessible namespaces are imported but cause a privacy error when used.
2016-07-27 05:17:04 +00:00
Vadim Petrochenkov
d7a968eb1c Fix ICE happening when unresolved imports are used in patterns 2016-07-21 21:19:16 +03:00
Jeffrey Seyfried
44575f708a Rename mtwt to hygiene 2016-07-17 17:12:35 +00:00
Jeffrey Seyfried
76ed445622 Clean up and encapsulate syntax::ext::mtwt 2016-07-17 17:12:32 +00:00
bors
4db1874f4c Auto merge of #34570 - jseyfried:no_rename, r=nrc
Simplify the macro hygiene algorithm

This PR removes renaming from the hygiene algorithm and treats differently marked identifiers as unequal.

This change makes the scope of identifiers in `macro_rules!` items empty. That is, identifiers in `macro_rules!` definitions do not inherit any semantics from the `macro_rules!`'s scope.

Since `macro_rules!` macros are items, the scope of their identifiers "should" be the same as that of other items; in particular, the scope should contain only items. Since all items are unhygienic today, this would mean the scope should be empty.

However, the scope of an identifier in a `macro_rules!` statement today is the scope that the identifier would have if it replaced the `macro_rules!` (excluding anything unhygienic, i.e. locals only).

To continue to support this, this PR tracks the scope of each `macro_rules!` and uses it in `resolve` to ensure that an identifier expanded from a `macro_rules!` gets a chance to resolve to the locals in the `macro_rules!`'s scope.

This PR is a pure refactoring. After this PR,
 - `syntax::ext::expand` is much simpler.
 - We can expand macros in any order without causing problems for hygiene (needed for macro modularization).
 - We can deprecate or remove today's `macro_rules!` scope easily.
 - Expansion performance improves by 25%, post-expansion memory usage decreases by ~5%.
 - Expanding a block is no longer quadratic in the number of `let` statements (fixes #10607).

r? @nrc
2016-07-15 08:48:41 -07:00
Jeffrey Seyfried
c83e31e7c9 Include the MacroDefinition rib in the label ribs. 2016-07-15 05:16:21 +00:00
Jeffrey Seyfried
0701571fe7 Implement macro_rules! placeholders and the macro scope map 2016-07-14 01:34:37 +00:00
Jeffrey Seyfried
a15dfca54f Instead of renaming, treat differently marked identifiers as unequal 2016-07-14 01:34:31 +00:00
Jeffrey Seyfried
195a27faab Move node id assigning into resolve 2016-07-14 01:30:19 +00:00
Michael Rosenberg
5a99d79857 Fixed issue where importing a trait method directly and then calling the method causes a compiler panic 2016-07-13 02:34:10 -04:00
petrochenkov
d27e55c5d8 Stabilize FnOnce::Output + Fix rebase 2016-07-08 13:35:17 +03:00
Vadim Petrochenkov
eb32440d45 Do not generate Def::Err in bindings
Instead of Def::Err erroneous bindings can get usual definitions that doesn't require special cases later on and have less chances to generate ICE.
2016-07-08 12:42:57 +03:00
Vadim Petrochenkov
d3c94b25cb Don't generate Def::Err if it's not stored in def_map immediately 2016-07-08 12:36:45 +03:00
bors
b4e11c2af8 Auto merge of #34655 - jseyfried:improve_resolver_api, r=nrc
Add to `resolve`'s public API

This adds a public method `with_module_lexical_scope` to `Resolver` to allow users to resolve a path in the lexical scope of an arbitrary module.
r? @nrc
2016-07-06 23:18:23 -07:00
Steve Klabnik
26821a6f88 Rollup merge of #34636 - tshepang:shorten, r=GuillaumeGomez
doc: fix and shorten comment
2016-07-06 19:13:08 -04:00
Jeffrey Seyfried
58dd06d9e5 Add FIXME comment 2016-07-05 22:38:41 +00:00
Jeffrey Seyfried
6e0bd44fa3 Add method with_module_lexical_scope to Resolver. 2016-07-05 08:50:43 +00:00
Tshepang Lekhonkhobe
5efc780e14 doc: fix and shorten comment 2016-07-03 22:03:45 +02:00
Jeffrey Seyfried
d1e3d6272e Add the after_expand entry point between import resolution and the rest of name resolution 2016-07-01 00:07:32 +00:00
Manish Goregaokar
8e2598c3d2 Rollup merge of #34542 - jseyfried:fix_recursive_modules, r=nrc
Fix non-termination on recursive module re-exports in extern crates

Fixes #33776.
r? @nrc
2016-06-29 21:21:24 +05:30
Manish Goregaokar
2a0c2c3b3a Rollup merge of #34467 - GuillaumeGomez:err-codes, r=brson
Add new error codes and improve some explanations

r? @brson

cc @steveklabnik
cc @jonathandturner
2016-06-29 21:21:22 +05:30
Jeffrey Seyfried
232783c914 Fix infinite loop on recursive module exports in an extern crate 2016-06-28 23:03:56 +00:00
Jeffrey Seyfried
e58963d3e4 groundwork: create the Resolver earlier in phase 2 2016-06-28 05:28:27 +00:00
Jeffrey Seyfried
ec0c150152 groundwork: refactor the interface that resolve exposes to driver 2016-06-28 05:28:26 +00:00
Jeffrey Seyfried
4a13bcb4fb groundwork: use resolve_identifier instead of resolve_path to classify ident patterns 2016-06-28 05:28:23 +00:00
Jeffrey Seyfried
8748cd92d0 Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddyb
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26 02:17:27 +00:00
Jeffrey Seyfried
33ea1e330c Rollup merge of #33943 - jseyfried:libsyntax_cleanup, r=nrc
Miscellaneous low priority cleanup in `libsyntax`.
2016-06-26 02:15:04 +00:00
Guillaume Gomez
58955dee66 Add new error codes and improve some explanations 2016-06-26 02:26:42 +02:00
Jeffrey Seyfried
d3ae56d755 Rollup merge of #34403 - jonathandturner:move_liberror, r=alexcrichton
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors).  This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes.

As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos).  While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
2016-06-25 22:35:09 +00:00
Jeffrey Seyfried
4e2e31c118 Rollup merge of #34368 - petrochenkov:astqpath, r=Manishearth
The AST part of https://github.com/rust-lang/rust/pull/34365

plugin-[breaking-change] cc https://github.com/rust-lang/rust/issues/31645
2016-06-25 22:35:06 +00:00
Jeffrey Seyfried
f0310e061b Rollup merge of #34213 - josephDunne:trait_item_macros, r=jseyfried
**syntax-[breaking-change]** cc #31645
New `TraitItemKind::Macro` variant

This change adds support for macro expansion inside trait items by adding the new `TraitItemKind::Macro` and associated parsing code.
2016-06-25 22:35:01 +00:00
Jonathan Turner
6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
Liigo Zhuang
2d7bac7d86 Improve diagnostics E0425: use (public) items
E0425: unresolved name
2016-06-23 12:51:10 +08:00
Vadim Petrochenkov
f903c97959 Merge PatKind::QPath into PatKind::Path in AST 2016-06-20 23:39:02 +03:00
Guillaume Gomez
8637b4b034 Remove unused functions calls and unused E0406 2016-06-18 17:02:41 +02:00
Jeffrey Seyfried
f0b21c2d1e Rename ast::ExprKind::Again -> ast::ExprKind::Continue 2016-06-17 05:21:25 +00:00
Jeffrey Seyfried
962d5c16b5 Fix fallout 2016-06-17 05:21:23 +00:00
Jeffrey Seyfried
0644aba0b3 Remove the type parameter from syntax::visit::Visitor 2016-06-14 07:40:32 +00:00
Joseph Dunne
dc3d878e0f Add support for macro expansion inside trait items 2016-06-13 21:46:43 +01:00
Vadim Petrochenkov
6d7b35bd98 Address review comments + fix rebase 2016-06-10 01:06:37 +03:00
Vadim Petrochenkov
ee4e55398b Introduce TyCtxt::expect_def/expect_resolution helpers and use them where possible 2016-06-10 01:03:54 +03:00
Vadim Petrochenkov
4c30f6405c Move the hack with fake partial resolution for <A>::B from typeck to resolve 2016-06-10 01:03:54 +03:00
Vadim Petrochenkov
91b9dabdeb resolve: Rewrite resolve_pattern 2016-06-10 01:03:54 +03:00
Jeffrey Seyfried
49de80d7ea Refactor away the prelude injection pass 2016-06-07 00:31:42 +00:00
Jeffrey Seyfried
0f37edb758 Refactor away method resolve_name_in_lexical_scope of ModuleS 2016-06-06 21:51:11 +00:00
Eduard-Mihai Burtescu
0e98d1dc8f Rollup merge of #33955 - zackmdavis:explain_E0429, r=GuillaumeGomez
add explanation for E0429 (`self` use declaration must use brace syntax)

This is an item under #32777.

r? @GuillaumeGomez
2016-06-06 06:48:32 +03:00
bors
0646e8ae6e Auto merge of #33878 - GuillaumeGomez:improve_helps, r=jonathandturner
Improve help messages for E0425

Fixes #33876.

r? @Manishearth

cc @steveklabnik
cc @jonathandturner
2016-06-02 18:10:37 -07:00
ggomez
f4e6f3c186 Improve help messages for E0425 2016-06-02 13:58:21 +02:00
bors
c2cab1fd58 Auto merge of #33794 - petrochenkov:sanity, r=nrc
Add AST validation pass and move some checks to it

The purpose of this pass is to catch constructions that fit into AST data structures, but not permitted by the language. As an example, `impl`s don't have visibilities, but for convenience and uniformity with other items they are represented with a structure `Item` which has `Visibility` field.

This pass is intended to run after expansion of macros and syntax extensions (and before lowering to HIR), so it can catch erroneous constructions that were generated by them. This pass allows to remove ad hoc semantic checks from the parser, which can be overruled by syntax extensions and occasionally macros.

The checks can be put here if they are simple, local, don't require results of any complex analysis like name resolution or type checking and maybe don't logically fall into other passes. I expect most of errors generated by this pass to be non-fatal and allowing the compilation to proceed.

I intend to move some more checks to this pass later and maybe extend it with new checks, like, for example, identifier validity. Given that syntax extensions are going to be stabilized in the measurable future, it's important that they would not be able to subvert usual language rules.

In this patch I've added two new checks - a check for labels named `'static` and a check for lifetimes and labels named `'_`. The first one gives a hard error, the second one - a future compatibility warning.
Fixes https://github.com/rust-lang/rust/issues/33059 ([breaking-change])
cc https://github.com/rust-lang/rfcs/pull/1177

r? @nrc
2016-06-01 06:21:53 -07:00
Manish Goregaokar
eba82bb569 Rollup merge of #33967 - dsprenkels:enum_pattern_resolve_ice, r=petrochenkov
resolve: record pattern def when `resolve_pattern` returns `Err(true)`

I propose a fix for issue #33293.

In 1a374b8, (pr #33046) fixed the error reporting of a specific case, but the change that was introduced did not make sure that `record_def` was called in all cases, which lead to an ICE in [1].
This change restores the original `else` case, but keeps the changes that were committed in 1a374b8.

[1] `rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_`
2016-06-01 12:57:42 +05:30
Zack M. Davis
06ebda837e revise explanation for E0429 (focus on error first) 2016-05-30 16:45:41 -07:00
Daan Sprenkels
cde0f94a52 librustc_resolve: make sure pattern def gets recorded if resolve_path returns Err(true)
In 1a374b8, (pr #33046) fixed the error reporting of a specific
case, but the change that was introduced did not make sure that
`record_def` was called in all cases, which lead to an ICE in [1].
This change restores the original `else` case, but keeps the changes
that were committed in 1a374b8.

This commit fixes issue #33293.

[1] `rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_`
2016-05-30 18:31:01 +02:00
Manish Goregaokar
10e1e6a7a2 Rollup merge of #33793 - GuillaumeGomez:compile_fail, r=GuillaumeGomez
Fix compile_fail tag

Fixes #33780

r? @steveklabnik
2016-05-30 15:18:59 +05:30
Zack M. Davis
a2b7dfa349 add explanation for E0429 (self use declaration must use brace syntax)
This is an item under #32777.
2016-05-29 17:52:18 -07:00
Vadim Petrochenkov
c02c6e88e6 Move some other checks to AST sanity pass 2016-05-28 20:27:57 +03:00
Manish Goregaokar
7905452f08 Rollup merge of #33644 - petrochenkov:selfast, r=nrc
The AST part of https://github.com/rust-lang/rust/pull/33505.
https://github.com/rust-lang/rust/pull/33505 isn't landed yet, so this PR is based on top of it.

r? @nrc

plugin-[breaking-change] cc #31645 @Manishearth
2016-05-27 09:57:11 +05:30
Manish Goregaokar
35785712cd Rollup merge of #33639 - petrochenkov:dotdot, r=nmatsakis
cc https://github.com/rust-lang/rust/issues/33627
r? @nikomatsakis

plugin-[breaking-change] cc https://github.com/rust-lang/rust/issues/31645 @Manishearth
2016-05-27 09:57:00 +05:30
Manish Goregaokar
a70880fea9 Rollup merge of #33351 - birkenfeld:loop-label-spans, r=pnkfelix
This makes the \"shadowing labels\" warning *not* print the entire loop as a span, but only the lifetime.

Also makes #31719 go away, but does not fix its root cause (the span of the expanded loop is still wonky, but not used anymore).
2016-05-27 09:56:47 +05:30
Guillaume Gomez
abe9961283 * Fix compile_fail tag (in some cases, it compiled whereas it wasn't expected to and was still considered 'ok')
* Fix error explanations tests/tags
2016-05-27 00:39:57 +02:00
Vadim Petrochenkov
d69aeaf662 Implement .. in tuple (struct) patterns 2016-05-26 11:11:58 +03:00
Vadim Petrochenkov
dcea4b2626 Fix rebase 2016-05-25 22:17:58 +03:00
Vadim Petrochenkov
5660a00486 Remove ExplicitSelf from AST 2016-05-25 21:55:04 +03:00
bors
487de42083 Auto merge of #33615 - GuillaumeGomez:field_static_method, r=pnkfelix
Don't suggest using fields in a static method

Fixes #33613.

cc @LeoTestard
2016-05-24 21:52:02 -07:00
Georg Brandl
2e812e10f4 syntax/hir: give loop labels a span
This makes the "shadowing labels" warning *not* print the entire loop
as a span, but only the lifetime.

Also makes #31719 go away, but does not fix its root cause (the span
of the expanded loop is still wonky, but not used anymore).
2016-05-24 14:22:14 +02:00
ggomez
145747ebfc Don't suggest using fields in a static method 2016-05-23 01:18:06 +02:00
Niko Matsakis
7734308f89 ignore dep-graph in resolve and lower_crate
This got removed at some point, it seems.
2016-05-18 10:11:35 -04:00
Vadim Petrochenkov
79b343d87c lowering: Rename identifiers only when necessary
Do not rename invalid identifiers, they stop being invalid after renaming
2016-05-16 22:25:08 +03:00
Vadim Petrochenkov
aad347c4f7 Remove hir::Ident 2016-05-16 22:25:08 +03:00
bors
e87cd7e380 Auto merge of #33505 - petrochenkov:self, r=nrc
Remove ExplicitSelf from HIR

`self` argument is already kept in the argument list and can be retrieved from there if necessary, so there's no need for the duplication.
The same changes can be applied to AST, I'll make them in the next breaking batch.
The first commit also improves parsing of method declarations and fixes https://github.com/rust-lang/rust/issues/33413.

r? @eddyb
2016-05-15 23:14:52 -07:00
bors
5ebe41835f Auto merge of #33619 - jonathandturner:improve_structured_errors, r=nikomatsakis
Batch of improvements to errors for new error format

This is a batch of improvements to existing errors to help get the most out of the new error format.

* Added labels to primary spans (^^^) for a set of errors that didn't currently have them
* Highlight the source blue under the secondary notes for better readability
* Move some of the "Note:" into secondary spans+labels
* Fix span_label to take &mut instead, which makes it work the same as other methods in that set
2016-05-15 15:08:46 -07:00
Vadim Petrochenkov
766f9b5a2f Remove ExplicitSelf from HIR 2016-05-14 13:26:40 +03:00
Manish Goregaokar
8845592514 Rollup merge of #33572 - nagisa:assoc-const-types, r=eddyb
Support references to outer type params for assoc consts

Fixes #28809

r? @eddyb
2016-05-14 11:57:48 +02:00
Jonathan Turner
6793cace06 Address nit 2016-05-13 12:57:34 -07:00
bors
709e5c5fde Auto merge of #33596 - nikomatsakis:issue-33586-regr-assoc-type-path, r=eddyb
re-introduce a cache for ast-ty-to-ty

It turns out that `ast_ty_to_ty` is supposed to be updating the `def`
after it finishes, but at some point in the past it stopped doing
so. This was never noticed because of the `ast_ty_to_ty_cache`, but that
cache was recently removed. This PR fixes the code to update the def
properly, but apparently that is not quite enough to make the operation
idempotent, so for now we reintroduce the cache too.

Fixes #33586.

r? @eddyb
2016-05-13 00:29:22 -07:00
Jonathan Turner
1b6afd1e42 Update errors to use new error format 2016-05-12 16:48:59 -07:00
Jonathan Turner
104fe1c4db Updating a few more errors with labels 2016-05-12 16:39:19 -07:00
bors
4ec5ce5e44 Auto merge of #33282 - alexcrichton:rustbuild-crate-tests, r=brson
rustbuild: Add support for crate tests + doctests

This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc #31590
2016-05-12 14:31:54 -07:00
Niko Matsakis
aa00e3a552 re-introduce a cache for ast-ty-to-ty
It turns out that `ast_ty_to_ty` is supposed to be updating the `def`
after it finishes, but at some point in the past it stopped doing
so. This was never noticed because of the `ast_ty_to_ty_cache`, but that
cache was recently removed. This PR fixes the code to update the def
properly, but apparently that is not quite enough to make the operation
idempotent, so for now we reintroduce the cache too.

Fixes #33425.
2016-05-12 14:23:26 -04:00
Alex Crichton
bb9062a296 rustbuild: Add support for crate tests + doctests
This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc #31590
2016-05-12 08:52:20 -07:00
Simonas Kazlauskas
fd70788e6d Do not use const Rib for associated constants 2016-05-12 00:31:43 +03:00
Eduard Burtescu
3a3013613a rustc: Remove the unnecessary ast_ty_to_ty_cache. 2016-05-11 04:14:58 +03:00
bors
d6588097d4 Auto merge of #33471 - birkenfeld:issue-33464, r=jseyfried
resolve: do not modify span of non-importable name

This span modification is probably leftover from a time when import spans were assigned differently.

With this change, error spans for the following are properly reported:

```
use abc::one_el;
use abc::{a, bbb, cccccc};
use a_very_long_name::{el, el2};
```

before (spans only):
```
x.rs:3 use abc::one_el;
           ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~
(internal compiler error: unprintable span)
(internal compiler error: unprintable span)
```

after:
```
x.rs:3 use abc::one_el;
           ^~~~~~~~~~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~~~~
x.rs:5 use a_very_long_name::{el, el2};
                              ^~
x.rs:5 use a_very_long_name::{el, el2};
                                  ^~~
```

Fixes: #33464
2016-05-10 05:22:17 -07:00
Georg Brandl
b62e7ff18d resolve: do not modify span of non-importable name
This span modification is probably leftover from a time when
import spans were assigned differently.

With this change, error spans for the following are properly reported:

```
use abc::one_el;
use abc::{a, bbb, cccccc};
use a_very_long_name::{el, el2};
```

before (spans only):
```
x.rs:3 use abc::one_el;
           ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~
(internal compiler error: unprintable span)
(internal compiler error: unprintable span)
```

after:
```
x.rs:3 use abc::one_el;
           ^~~~~~~~~~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~~~~
x.rs:5 use a_very_long_name::{el, el2};
                              ^~
x.rs:5 use a_very_long_name::{el, el2};
                                  ^~~
```

Fixes: #33464
2016-05-10 08:35:37 +02:00
bors
a4d2424cc3 Auto merge of #33443 - jseyfried:resolve_ast, r=nrc
Perform name resolution before and during ast->hir lowering

This PR performs name resolution before and during ast->hir lowering instead of in phase 3.
r? @nrc
2016-05-09 21:31:55 -07:00
Jeffrey Seyfried
6710eef6b2 Refactor hir::lowering::Resolver 2016-05-09 10:27:24 +00:00
Manish Goregaokar
84843b73dc
Merge E0410 into E0408 2016-05-08 23:36:40 -07:00
Jeffrey Seyfried
e5a0dd7c6e Resolve paths generated in the ast->hir lowerer 2016-05-09 02:31:06 +00:00
Jeffrey Seyfried
983b4d3925 Refactor the interface that resolve exposes to driver 2016-05-09 02:31:06 +00:00
Jeffrey Seyfried
8428447253 Move resolution to before lowering 2016-05-09 02:31:04 +00:00
Jeffrey Seyfried
a988c9a839 Refactor Resolver field def_map from RefCell<DefMap> to DefMap 2016-05-09 00:48:48 +00:00
Jeffrey Seyfried
8c2fa93e81 Remove a use of ast_map.span_if_local() in resolve 2016-05-09 00:48:44 +00:00
Manish Goregaokar
cf8a1b0998 Add E0408/E0409 2016-05-08 10:13:58 -07:00
Manish Goregaokar
deb97fef21
Rollup merge of #33406 - Manishearth:diag-improve-const-let, r=GuillaumeGomez
Improve diagnostics for constants being used in irrefutable patterns

It's pretty confusing and this error triggers in resolve only when "shadowing" a const, so let's make that clearer.

r? @steveklabnik
2016-05-08 07:00:11 -07:00
bors
8e414e0e3f Auto merge of #33091 - sanxiyn:unused-trait-import-3, r=nrc
Warn unused trait imports, rebased

Rebase of #30021.

Fix #25730.
2016-05-08 04:50:27 -07:00
Manish Goregaokar
9f302b6bcd
Add long diagnostics for E0414 2016-05-05 10:12:22 +05:30
Manish Goregaokar
5f9e304310
Improve diagnostics for constants being used in irrefutable patterns
It's pretty confusing and this error triggers in resolve only when "shadowing" a
const, so let's make that clearer.
2016-05-04 23:31:02 +05:30
Manish Goregaokar
52c97f237b
Rollup merge of #33340 - birkenfeld:issue-23716, r=Manishearth
resolve: print location of static for "static in pattern" error

The implementation mirrors the one for "constant defined here" annotation used for constant patterns in the irrefutable-pattern case.

Fixes: #23716
2016-05-03 19:54:54 +05:30
Seo Sanghyeon
24d86137f5 Warn unused trait imports 2016-05-03 18:51:19 +09:00
Seo Sanghyeon
7ad1900e1c Remove unused trait imports flagged by lint 2016-05-03 18:48:34 +09:00
Manish Goregaokar
1d6cc191fc
Rollup merge of #33320 - birkenfeld:issue31573, r=arielb1
diagnostics for E0432: imports are relative to crate root

This is curiously missing from both the short message and this long diagnostic.

Refs #31573 (not sure if it should be considered "fixed" as the short message still only refers to extern crates).
2016-05-03 08:05:27 +05:30
Georg Brandl
4ba6bf44bd resolve: print location of static for "static in pattern" error
The implementation mirrors the one for "constant defined here" annotation
used for constant patterns in the irrefutable-pattern case.

Fixes: #23716
2016-05-02 22:02:07 +02:00
Niko Matsakis
2ba5fac1a4 fix rebase flaws 2016-05-02 11:49:26 -04:00
Niko Matsakis
489a6c95bf replace fileline_{help,note} with {help,note}
The extra filename and line was mainly there to keep the indentation
relative to the main snippet; now that this doesn't include
filename/line-number as a prefix, it is distracted.
2016-05-02 11:49:23 -04:00
Georg Brandl
d20b4067fd diagnostics for E0432: imports are relative to crate root
This is curiously missing from both the short message and this
long diagnostic.

Refs #31573 (not sure if it should be considered "fixed" as the
short message still only refers to extern crates).
2016-05-02 06:14:09 +02:00
bors
700d3e2374 Auto merge of #33190 - jseyfried:improve_diagnostics, r=nrc
resolve: improve diagnostics and lay groundwork for resolving before ast->hir

This PR improves diagnostics in `resolve` and lays some groundwork for resolving before ast->hir.

More specifically,
 - It removes an API in `resolve` intended for external refactoring tools (see #27493) that appears not to be in active use. The API is incompatible with resolving before ast->hir, but could be rewritten in a more compatible and less intrusive way.
 - It improves the diagnostics for pattern bindings that conflict with `const`s.
 - It improves the diagnostics for modules used as expressions (fixes #33186).
 - It refactors away some uses of the hir map, which is unavavailable before ast->hir lowering.

r? @eddyb
2016-05-01 20:39:33 -07:00
bors
9b63263d0d Auto merge of #33229 - timothy-mcroy:master, r=guillaumegomez
Explain E0434
2016-04-29 12:59:39 -07:00
Jeffrey Seyfried
a70e42a953 Remove use of ast_map.expect_item() and improve diagnostics (fixes #33186) 2016-04-29 18:34:49 +00:00
Jeffrey Seyfried
5a4e0b14e3 Remove use of ast_map.span_if_local() and improve diagnostics 2016-04-29 18:34:40 +00:00
Jeffrey Seyfried
60c8f7dbf5 Revert #27493 2016-04-29 18:34:13 +00:00
Timothy McRoy
0cfb5a0bb6 Add detailed error message for E0434 #32777 2016-04-28 10:56:32 -05:00
Jeffrey Seyfried
ac264196e2 Address style nits 2016-04-28 03:43:35 +00:00
Jeffrey Seyfried
6aa9145753 Avoid using the hir map when visibility checking in resolve
Refactor `ty::Visibility` methods to use a new trait `NodeIdTree` instead of the ast map.
2016-04-27 06:40:54 +00:00
Jeffrey Seyfried
33bb26998c Refactor away a use of ast_map.span_if_local() 2016-04-27 06:40:52 +00:00
Jeffrey Seyfried
3bcf818a8f Refactor resolve_crate_relative_path and resolve_module_relative_path
to return a `NameBinding` instead of a `Def`
2016-04-27 01:13:22 +00:00
Jeffrey Seyfried
6da115374f Refactor away get_trait_name 2016-04-27 01:13:22 +00:00
Jeffrey Seyfried
82e0dd5ac1 Refactor away is_static_method 2016-04-27 01:13:22 +00:00
Jeffrey Seyfried
2ccaeed50e Refactor away FallbackChecks and remove dead code 2016-04-27 01:13:21 +00:00
Jeffrey Seyfried
c9d8e1493c Refactor field span of NameBinding from Option<Span> to Span. 2016-04-27 01:13:15 +00:00
Jeffrey Seyfried
c46164b626 Refactor away field vis of ModuleS 2016-04-26 09:01:24 +00:00
Vadim Petrochenkov
6c44bea644 syntax: Check paths in visibilities for type parameters
syntax: Merge PathParsingMode::NoTypesAllowed and PathParsingMode::ImportPrefix
syntax: Rename PathParsingMode and its variants to better express their purpose
syntax: Remove obsolete error message about 'self lifetime
syntax: Remove ALLOW_MODULE_PATHS workaround
syntax/resolve: Adjust some error messages
resolve: Compare unhygienic (not renamed) names with keywords::Invalid, invalid identifiers may appear to be valid after renaming
2016-04-24 20:59:44 +03:00
Vadim Petrochenkov
8dbab5121e syntax: Don't parse idents with parse_path
Lift some restrictions on type parameters in paths
Sanity check import paths for type parameters
2016-04-24 20:59:44 +03:00
Vadim Petrochenkov
e2c821d35e syntax: Make static/super/self/Self keywords + special ident cleanup 2016-04-24 20:59:44 +03:00
bors
c2aaad4e22 Auto merge of #33060 - jseyfried:cleanup_resolve, r=nrc
resolve: miscellaneous clean-ups

This PR consists of some small, miscellaneous clean-ups in `resolve`.
r? @eddyb
2016-04-19 08:02:59 -07:00
Jeffrey Seyfried
6ae80273a0 resolve: improve performance 2016-04-18 02:01:57 +00:00
Jeffrey Seyfried
1e134a47d3 Update outdated comment 2016-04-18 00:26:18 +00:00
Jeffrey Seyfried
b01e63009f Refactor the per-module node map module_children into a per-resolver map. 2016-04-17 23:48:13 +00:00
Jeffrey Seyfried
5b12832012 Make import resolution and error resolution reporting deterministic.
These tasks used to depend on the iteration order of `module_children`.
2016-04-17 23:48:11 +00:00
Jeffrey Seyfried
5f47915554 Refactor is_prelude to only apply to glob imports 2016-04-17 23:47:12 +00:00
Manish Goregaokar
e1db767dbc Rollup merge of #33046 - jseyfried:fix_unresolved_pattern_diagnostics, r=eddyb
Fix diagnostics for unresolved patterns

This fixes #33043, a bug in the diagnostics for unresolved patterns.
r? @eddyb
2016-04-17 17:50:35 +05:30
Manish Goregaokar
df0eb16020 Rollup merge of #33045 - jseyfried:no_def_modifiers, r=eddyb
resolve: Refactor away `DefModifiers`

This refactors away `DefModifiers`, which is unneeded now that #32875 has landed.
r? @eddyb
2016-04-17 17:50:35 +05:30
Manish Goregaokar
02e40d910a Rollup merge of #33044 - petrochenkov:prefix, r=eddyb
syntax: Parse import prefixes as paths

Fixes https://github.com/rust-lang/rust/issues/10415

r? @eddyb
(This partially intersects with https://github.com/rust-lang/rust/pull/33041)
2016-04-17 17:50:35 +05:30
Jeffrey Seyfried
2c978dc80b resolve: Refactor away DefModifiers 2016-04-17 02:54:22 +00:00
Jeffrey Seyfried
1a374b8d11 Fix diagnostics for unresolved patterns 2016-04-17 02:42:39 +00:00
Vadim Petrochenkov
e7bc939f1e syntax: Parse import prefixes as paths 2016-04-17 03:48:40 +03:00
Jeffrey Seyfried
0833a89a3e resolve: refactor away PRIVATE_VARIANT and ensure that restricted
reexports of private variants are handled correctly.
2016-04-14 04:58:32 +00:00
Jeffrey Seyfried
a0c3ce3424 resolve: use the Restricted variant of ty::Visibility when privacy checking 2016-04-14 04:57:33 +00:00
Jeffrey Seyfried
a4196cd490 resolve: Use vis: ty::Visibility instead of is_public: bool 2016-04-14 04:56:21 +00:00
bors
4b71f8d141 Auto merge of #32814 - jseyfried:improve_duplicate_glob_detection, r=nikomatsakis
resolve: Improve duplicate glob detection

This fixes a bug introduced in #31726 in which we erroneously allow multiple imports of the same item under some circumstances.

More specifically, we erroneously allow a module that is in a cycle of glob re-exports to have other re-exports (besides the glob from the cycle).
For example,
```rust
pub fn f() {}
mod foo {
    pub use f; // (1) This defines `foo::f`.
    pub use bar::*; // (3) This also defines `foo::f`, which should be a duplicate error but is currently allowed.
}
mod bar {
    pub use foo::*; // (2) This defines `bar::f`.
}
```

A module in a glob re-export cycle can still have `pub` items after this PR. For example,
```rust
mod foo {
    pub fn f() {}; // (1) This defines `foo::f`.
    pub use bar::*; // (3) This is not a duplicate error since items shadow glob-imported re-exports (cf #31337).
}
mod bar {
    pub use foo::*; // (2) This defines `bar::f`.
}
```
r? @nikomatsakis
2016-04-12 22:21:23 -07:00
Jeffrey Seyfried
3238b4bbbd Add comments 2016-04-11 18:30:48 +00:00
Jeffrey Seyfried
2944fab398 Improve import resolution diagnostics 2016-04-09 02:12:15 +00:00
Jeffrey Seyfried
0383344a8f Detect duplicate glob imports arising from glob cycles 2016-04-08 01:09:28 +00:00
Manish Goregaokar
b0f81a3595 Rollup merge of #32789 - jseyfried:fix_duplicate_resolve_errors, r=eddyb
resolve: Avoid emitting redundant path resolution errors

This PR avoids emitting redundant path resolution errors in `resolve` (fixes #32760).

r? @eddyb
2016-04-07 20:22:43 +05:30