Commit Graph

164 Commits

Author SHA1 Message Date
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
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
5f47915554 Refactor is_prelude to only apply to glob imports 2016-04-17 23:47:12 +00:00
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
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
a4196cd490 resolve: Use vis: ty::Visibility instead of is_public: bool 2016-04-14 04:56:21 +00:00
Jeffrey Seyfried
bb66d91c98 Make hir::Visibility non-copyable and add ty::Visibility 2016-04-07 04:31:45 +00:00
Eduard Burtescu
ffca6c3e15 rustc: move middle::{def,def_id,pat_util} to hir. 2016-04-06 09:14:21 +03:00
Eduard Burtescu
8b0937293b rustc: move rustc_front to rustc::hir. 2016-04-06 09:01:55 +03:00
Manish Goregaokar
bdd264a0bb Rollup merge of #32403 - vlastachu:super_in_path, r=jseyfried
Fix issue: Global paths in `use` directives can begin with `super` or `self` #32225

This PR fixes #32225 by warning on `use ::super::...` and `use ::self::...` on `resolve`.

Current changes is the most minimal and ad-hoc.
2016-04-05 16:43:20 +05:30
vlastachu
6c73134fc7 Fixes bug which accepting using super in use statemet.
Issue: #32225
2016-04-05 11:57:56 +03:00
bors
7fd331e166 Auto merge of #32328 - jseyfried:coherence, r=nikomatsakis
resolve: Improve import failure detection and lay groundwork for RFC 1422

This PR improves import failure detection and lays some groundwork for RFC 1422.
More specifically, it
 - Avoids recomputing the resolution of an import directive's module path.
 - Refactors code in `resolve_imports` that does not scale to the arbitrarily many levels of visibility that will be required by RFC 1422.
  - Replaces `ModuleS`'s fields `public_glob_count`, `private_glob_count`, and `resolved_globs` with a list of glob import directives `globs`.
  - Replaces `NameResolution`'s fields `pub_outstanding_references` and `outstanding_references` with a field `single_imports` of a newly defined type `SingleImports`.
 - Improves import failure detection by detecting cycles that include single imports (currently, only cycles of globs are detected). This fixes #32119.

r? @nikomatsakis
2016-04-04 21:50:05 -07:00
Benjamin Herr
d05f726eed librustc_resolve: use bug!(), span_bug!() 2016-03-31 22:06:52 +02:00
Jeffrey Seyfried
bfb832e7c8 Add SingleImports and use it in place of outstanding_references
and `pub_outstanding_references`.
2016-03-27 22:27:18 +00:00
Jeffrey Seyfried
5ff21f138a Refactor ModuleS fields public_glob_count, private_glob_count, and
`resolved_globs` into a single field `globs: RefCell<Vec<ImportDirective>>`.
2016-03-27 03:53:42 +00:00
Eduard Burtescu
5efdde0de1 rustc: move cfg, infer, traits and ty from middle to top-level. 2016-03-27 01:05:54 +02:00
Jeffrey Seyfried
1744f55ad7 Refactor away GraphBuilder 2016-03-26 18:22:40 +00:00
Jeffrey Seyfried
0bed9aea2d Make populate_module_if_necessary a method of resolver 2016-03-26 18:22:37 +00:00
Jeffrey Seyfried
77f0f4a624 Avoid repeating parent 2016-03-26 18:22:34 +00:00
Jeffrey Seyfried
ff014a3a10 Refactor away populate_external_module 2016-03-26 18:22:33 +00:00
Jeffrey Seyfried
7bc6c75d0f Refactor away handle_external_def 2016-03-26 18:22:31 +00:00
Jeffrey Seyfried
febef471e3 Refactor how the prelude is handled 2016-03-25 22:22:12 +00:00
Jeffrey Seyfried
21064d097e Refactor away resolve_imports::Shadowable and rename shadowable -> is_prelude 2016-03-25 22:18:30 +00:00
Jeffrey Seyfried
65ec4dfe61 Improve diagnostics for duplicate names 2016-03-16 08:52:31 +00:00
bors
5807fbbfde Auto merge of #32134 - jseyfried:forbid_type_alias_as_module, r=nikomatsakis
Forbid glob-importing from a type alias

This PR forbids glob-importing from a type alias or trait (fixes #30560):
```rust
type Alias = ();
use Alias::*; // This is currently allowed but shouldn't be
```

This is a [breaking-change]. Since the disallowed glob imports don't actually import anything, any breakage can be fixed by removing the offending glob import.

r? @alexcrichton
2016-03-11 09:26:47 -08:00
bors
3ac4076ac0 Auto merge of #32097 - jseyfried:fix_resolution_regression, r=nikomatsakis
Fix a regression in import resolution

This fixes #32089 (caused by #31726) by deducing that name resolution has failed (as opposed to being determinate) in more cases.

r? @nikomatsakis
2016-03-09 22:41:48 -08:00
Jeffrey Seyfried
ad28c28f46 Stop treating a type alias like a module or enum (preventing use TypeAlias::*) 2016-03-08 21:50:20 +00:00
Jeffrey Seyfried
61f1f4d21e Add a field pub_outstanding_references to NameResolution.
Add an argument `allow_private_imports` to some methods.
2016-03-07 11:24:20 +00:00
Jeffrey Seyfried
2998564615 Refactor away ExternalExports 2016-03-06 05:46:49 +00:00
Jeffrey Seyfried
b3572ae15a Finish encapsulating the details of import resolution in resolve_imports 2016-03-04 20:48:55 +00:00
Jeffrey Seyfried
20b99d303d Start importing bindings from globs as soon as the glob path is known. 2016-03-04 20:48:51 +00:00
Jeffrey Seyfried
fb4710ce21 Add a field in Module for the ResolverArenas 2016-03-04 20:48:50 +00:00
Jeffrey Seyfried
6b94bc345c Add an arena for import directives 2016-03-04 20:48:49 +00:00
Jeffrey Seyfried
064f17c6a3 Record that an import succeeded or failed in one namespace even while it is indeterminate in the other namespace (fixes #31444) 2016-03-04 20:48:43 +00:00
bors
7cee8b9ffb Auto merge of #31824 - jseyfried:privacy_in_resolve, r=nikomatsakis
This PR privacy checks paths as they are resolved instead of in `librustc_privacy` (fixes #12334 and fixes #31779). This removes the need for the `LastPrivate` system introduced in PR #9735, the limitations of which cause #31779.

This PR also reports privacy violations in paths to intra- and inter-crate items the same way -- it always reports the first inaccessible segment of the path.

Since it fixes #31779, this is a [breaking-change]. For example, the following code would break:
```rust
mod foo {
    pub use foo::bar::S;
    mod bar { // `bar` should be private to `foo`
        pub struct S;
    }
}

impl foo::S {
    fn f() {}
}

fn main() {
    foo::bar::S::f(); // This is now a privacy error
}
```

r? @alexcrichton
2016-03-03 02:21:28 +00:00
Vadim Petrochenkov
9047b201bf Move span into StructField
+ some cleanup in rustdoc
2016-03-02 10:32:04 +03:00
Vadim Petrochenkov
8b026a6e48 Use numeric field Names ("0", "1" etc) for positional fields 2016-03-02 10:31:19 +03:00
Vadim Petrochenkov
8b60b948d9 Get rid of hir::StructFieldKind 2016-03-02 10:31:19 +03:00
Jeffrey Seyfried
b20d567c2b Privacy check paths in resolve and typeck 2016-02-26 00:37:27 +00:00
Jeffrey Seyfried
07957ffb2e Refactor Module's field extern_crate_did: Option<DefId> to extern_crate_id: Option<NodeId> 2016-02-26 00:37:27 +00:00
Jeffrey Seyfried
3358fb11da Fix the visibility of extern crate declarations and stop warning on pub extern crate 2016-02-24 01:34:14 +00:00
Jeffrey Seyfried
5ad84f1301 Replace the field imports in Module with unresolved_imports and refactor away resolved_import_count 2016-02-18 00:02:50 +00:00
Jeffrey Seyfried
81d5d02c37 Rename Module field anonymous_children to module_children, expand it to include both named an anonymous modules, and fix #31644 2016-02-14 09:05:37 +00:00
Jeffrey Seyfried
d881eee608 Change try_define_child to return a Result instead of an Option 2016-02-08 02:25:07 +00:00
Jeffrey Seyfried
16e7ff1bff Write and use increment_outstanding_references_for and decrement_outstanding_references_for 2016-02-08 02:25:05 +00:00
Jeffrey Seyfried
96b4dc4b87 Refactor away the fields id and is_public of ImportResolution and rename ImportResolution to NameResolution 2016-02-08 02:25:03 +00:00