Commit Graph

321 Commits

Author SHA1 Message Date
Jeffrey Seyfried
4294528b5d Improve hygiene when privacy-checking struct expression or struct constructor fields. 2018-02-17 21:48:35 -08:00
Carol (Nichols || Goulding)
e168aa385b
Reexport -> re-export in prose and documentation comments 2018-01-15 13:36:53 -05:00
leonardo.yvens
f93183adb4 Remove impl Foo for .. in favor of auto trait Foo
No longer parse it.
Remove AutoTrait variant from AST and HIR.
Remove backwards compatibility lint.
Remove coherence checks, they make no sense for the new syntax.
Remove from rustdoc.
2018-01-13 18:48:00 +03:00
Alex Crichton
8c9bf663d4 rustc: Don't use relative paths for extended errors
These no longer work now that Cargo changes the cwd of rustc while it's running.
Instead use an absolute path that's set by rustbuild.
2018-01-04 07:21:22 -08:00
Jonas Platte
78493ed21a Add GenericParam, refactor Generics in ast, hir, rustdoc
The Generics now contain one Vec of an enum for the generic parameters,
rather than two separate Vec's for lifetime and type parameters.

Additionally, places that previously used Vec<LifetimeDef> now use
Vec<GenericParam> instead.
2017-12-21 13:38:10 +01:00
Vadim Petrochenkov
c6209a36bb Always report private-in-public in associated types as hard errors
according to RFC 2145.

Fix a silly label message.
2017-12-21 03:19:05 +03:00
Vadim Petrochenkov
020961d880 Prohibit access to private statics from other crates through macros 2.0 2017-12-21 03:17:19 +03:00
Vadim Petrochenkov
190adc0e19 Properly check traits in type privacy 2017-12-21 03:17:19 +03:00
Alex Burka
2eefc9db15 add trait aliases to HIR 2017-12-14 12:56:26 -05:00
Jeffrey Seyfried
58e80400b2 Include non-pub use and extern crate items in the crate metadata for macros 2.0. 2017-12-05 17:23:01 -08:00
Christopher Vittal
8fd48e7d59 Split hir::TyImplTrait, move checks to HIR lowering
Replace hir::TyImplTrait with TyImplTraitUniversal and
TyImplTraitExistential.

Add an ImplTraitContext enum to rustc::hir::lowering to track the kind
and allowedness of an impl Trait.

Significantly alter lowering to thread ImplTraitContext and one other
boolean parameter described below throughought much of lowering.

The other parameter is for tracking if lowering a function is in a trait
impl, as there is not enough information to otherwise know this
information during lowering otherwise.

This change also removes the checks from ast_ty_to_ty for impl trait
allowedness as they are now all taking place in HIR lowering.
2017-11-15 15:46:01 -05:00
bors
d762b1d6c6 Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov
RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute

This work-in-progress pull request contains my changes to implement [RFC 2008](https://github.com/rust-lang/rfcs/pull/2008). The related tracking issue is #44109.

As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored.

WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).
2017-11-04 18:07:07 +00:00
David Wood
059eccb07f
Implemented RFC 2008 for enums (not including variants) and structs. 2017-11-03 19:36:18 +00:00
leonardo.yvens
06506bb751 [Syntax Breaking] Rename DefaultImpl to AutoImpl
DefaultImpl is a highly confusing name for what we now call auto impls,
as in `impl Send for ..`. The name auto impl is not formally decided
but for sanity anything is better than `DefaultImpl` which refers
neither to `default impl` nor to `impl Default`.
2017-11-03 16:13:20 -02:00
Paul Lietar
77f7e85d7f Implement RFC 1861: Extern types 2017-10-27 23:01:34 +02:00
Wesley Wiser
8281e883dd Switch several crate-wide queries to use eval_always
Closes #45238
2017-10-26 18:47:47 -04:00
Vadim Petrochenkov
419069d984 Use recorded types in rustc_privacy 2017-09-23 00:50:46 +03:00
Alex Crichton
caaf365a9d rustc: Remove HirId from queries
This'll allow us to reconstruct query parameters purely from the `DepNode`
they're associated with. Some queries could move straight to `HirId` but others
that don't always have a correspondance between `HirId` and `DefId` moved to
two-level maps where the query operates over a `DefIndex`, returning a map,
which is then keyed off `ItemLocalId`.

Closes #44414
2017-09-11 07:53:48 -07:00
Alex Crichton
43ae380191 rustc: Flag some CrateStore methods as "untracked"
The main use of `CrateStore` *before* the `TyCtxt` is created is during
resolution, but we want to be sure that any methods used before resolution are
not used after the `TyCtxt` is created. This commit starts moving the methods
used by resolve to all be named `{name}_untracked` where the rest of the
compiler uses just `{name}` as a query.

During this transition a number of new queries were added to account for
post-resolve usage of these methods.
2017-09-05 07:37:39 -07:00
Mark Simulacrum
f3b7197384 Rollup merge of #44202 - alexcrichton:xcrate-generators, r=arielb1
rustc: Fix reachability with cross-crate generators

Same solution as in f2df1857

Closes #44181
2017-08-31 18:07:42 -06:00
Alex Crichton
41d3e83183 rustc: Fix reachability with cross-crate generators
Same solution as in f2df1857

Closes #44181
2017-08-30 17:32:21 -07:00
Alex Crichton
5c279a40ae Merge branch 'hide-trait-map' into rollup 2017-08-30 13:17:40 -07:00
Alex Crichton
942c8dcf19 rustc: Make the export_map of TyCtxt private
This map, like `trait_map`, is calculated in resolve, but we want to be sure to
track it for incremental compliation. Hide it behind a query to get more
refactorings later.
2017-08-29 22:00:40 -07:00
Vadim Petrochenkov
3da868dcb6 Make fields of Span private 2017-08-30 01:38:54 +03:00
Tamir Duberstein
b3f50caee0
*: remove crate_{name,type} attributes
Fixes #41701.
2017-08-25 16:18:21 -04:00
Vadim Petrochenkov
de4dbe5789 rustc: Remove some dead code 2017-08-19 13:27:16 +03:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
bors
0d12553320 Auto merge of #43740 - michaelwoerister:local-id-in-typecktables, r=arielb1
Use hir::ItemLocalId as keys in TypeckTables.

This PR makes `TypeckTables` use `ItemLocalId` instead of `NodeId` as key. This is needed for incremental compilation -- for stable hashing and for being able to persist and reload these tables. The PR implements the most important part of https://github.com/rust-lang/rust/issues/40303.

Some notes on the implementation:
* The PR adds the `HirId` to HIR nodes where needed (`Expr`, `Local`, `Block`, `Pat`) which obviates the need to store a `NodeId -> HirId` mapping in crate metadata. Thanks @eddyb for the suggestion! In the future the `HirId` should completely replace the `NodeId` in HIR nodes.
* Before something is read or stored in one of the various `TypeckTables` subtables, the entry's key is validated via the new `TypeckTables::validate_hir_id()` method. This makes sure that we are not mixing information from different items in a single table.

That last part could be made a bit nicer by either (a) new-typing the table-key and making `validate_hir_id()` the only way to convert a `HirId` to the new-typed key, or (b) just encapsulate sub-table access a little better. This PR, however, contents itself with not making things significantly worse.

Also, there's quite a bit of switching around between `NodeId`, `HirId`, and `DefIndex`. These conversions are cheap except for `HirId -> NodeId`, so if the valued reviewer finds such an instance in a performance critical place, please let me know.

Ideally we convert more and more code from `NodeId` to `HirId` in the future so that there are no more `NodeId`s after HIR lowering anywhere. Then the amount of switching should be minimal again.

r? @eddyb, maybe?
2017-08-14 14:15:06 +00:00
Michael Woerister
f2df18579b Mark closures return via impl-trait as reachable. 2017-08-14 12:04:52 +02:00
Michael Woerister
6fd7d8586c Fix some merge fallout. 2017-08-14 11:21:34 +02:00
Michael Woerister
a69eaf62c5 Improve validation of TypeckTables keys. 2017-08-11 12:17:07 +02:00
Michael Woerister
1f54df1101 Encapsulate sub-table access in TypeckTables and validate keys on each access. 2017-08-11 12:17:07 +02:00
Michael Woerister
7f2423eede Use ItemLocalId as key for node_types, node_substs, and adjustments in TypeckTables. 2017-08-11 12:11:38 +02:00
Michael Woerister
783ccc443b Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId. 2017-08-11 12:11:38 +02:00
bors
2400ebfe76 Auto merge of #43522 - alexcrichton:rewrite-lints, r=michaelwoerister
rustc: Rearchitect lints to be emitted more eagerly

In preparation for incremental compilation this commit refactors the lint
handling infrastructure in the compiler to be more "eager" and overall more
incremental-friendly. Many passes of the compiler can emit lints at various
points but before this commit all lints were buffered in a table to be emitted
at the very end of compilation. This commit changes these lints to be emitted
immediately during compilation using pre-calculated lint level-related data
structures.

Linting today is split into two phases, one set of "early" lints run on the
`syntax::ast` and a "late" set of lints run on the HIR. This commit moves the
"early" lints to running as late as possible in compilation, just before HIR
lowering. This notably means that we're catching resolve-related lints just
before HIR lowering. The early linting remains a pass very similar to how it was
before, maintaining context of the current lint level as it walks the tree.

Post-HIR, however, linting is structured as a method on the `TyCtxt` which
transitively executes a query to calculate lint levels. Each request to lint on
a `TyCtxt` will query the entire crate's 'lint level data structure' and then go
from there about whether the lint should be emitted or not.

The query depends on the entire HIR crate but should be very quick to calculate
(just a quick walk of the HIR) and the red-green system should notice that the
lint level data structure rarely changes, and should hopefully preserve
incrementality.

Overall this resulted in a pretty big change to the test suite now that lints
are emitted much earlier in compilation (on-demand vs only at the end). This in
turn necessitated the addition of many `#![allow(warnings)]` directives
throughout the compile-fail test suite and a number of updates to the UI test
suite.

Closes https://github.com/rust-lang/rust/issues/42511
2017-08-10 11:20:15 +00:00
Alex Crichton
0374e6aab7 rustc: Rearchitect lints to be emitted more eagerly
In preparation for incremental compilation this commit refactors the lint
handling infrastructure in the compiler to be more "eager" and overall more
incremental-friendly. Many passes of the compiler can emit lints at various
points but before this commit all lints were buffered in a table to be emitted
at the very end of compilation. This commit changes these lints to be emitted
immediately during compilation using pre-calculated lint level-related data
structures.

Linting today is split into two phases, one set of "early" lints run on the
`syntax::ast` and a "late" set of lints run on the HIR. This commit moves the
"early" lints to running as late as possible in compilation, just before HIR
lowering. This notably means that we're catching resolve-related lints just
before HIR lowering. The early linting remains a pass very similar to how it was
before, maintaining context of the current lint level as it walks the tree.

Post-HIR, however, linting is structured as a method on the `TyCtxt` which
transitively executes a query to calculate lint levels. Each request to lint on
a `TyCtxt` will query the entire crate's 'lint level data structure' and then go
from there about whether the lint should be emitted or not.

The query depends on the entire HIR crate but should be very quick to calculate
(just a quick walk of the HIR) and the red-green system should notice that the
lint level data structure rarely changes, and should hopefully preserve
incrementality.

Overall this resulted in a pretty big change to the test suite now that lints
are emitted much earlier in compilation (on-demand vs only at the end). This in
turn necessitated the addition of many `#![allow(warnings)]` directives
throughout the compile-fail test suite and a number of updates to the UI test
suite.
2017-08-09 09:13:51 -07:00
Isaac van Bakel
400075d9d9 Fixed all unnecessary muts in language core 2017-08-01 23:01:24 +01:00
Tobias Schottdorf
687ee7fee4 Downgrade ProjectionTy's TraitRef to its substs
Addresses the second part of #42171 by removing the `TraitRef` from
`ProjectionTy`, and directly storing its `Substs`.

Closes #42171.
2017-07-11 10:33:09 -04:00
Vadim Petrochenkov
8c44a9dca7 Store all generic arguments for method calls in HIR 2017-07-10 00:20:25 +03:00
petrochenkov
a27f8cf8a3 Address review comments
Fix regressions after rebase
2017-07-07 01:22:48 +03:00
Vadim Petrochenkov
08a1d45818 Check adjustments and node substs
Cleanup checking of inherent static methods and fix checking of inherent associated constants
Add more tests
2017-07-06 23:50:02 +03:00
Vadim Petrochenkov
85fb9e0d91 Check types for privacy 2017-07-06 23:50:02 +03:00
Eduard-Mihai Burtescu
33ecf72e8e rustc: move the PolyFnSig out of TyFnDef. 2017-06-27 16:39:52 +03:00
kennytm
4711982314
Removed as many "```ignore" as possible.
Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.

Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-23 15:31:53 +08:00
Alex Crichton
be7ebdd512 Bump version and stage0 compiler 2017-06-19 22:25:05 -07:00
Jeffrey Seyfried
8497061a49 Hygienize librustc_privacy. 2017-05-25 05:52:08 +00:00
Alex Crichton
ab54f4b226 rustc: Remove #![unstable] annotation
These are now no longer necessary with `-Z force-unstable-if-unmarked`
2017-05-11 16:03:05 -07:00
Oliver Schneider
dd87eabd83 Remove need for &format!(...) or &&"" dances in span_label calls 2017-05-08 12:56:15 +02:00
bors
b0a4074c5e Auto merge of #41504 - eddyb:query-api, r=nikomatsakis
Improve the librustc on-demand/query API ergonomics.

Queries are now performed through these two forms:
* `tcx.type_of(def_id)` (the most common usage)
* `tcx.at(span).type_of(def_id)` (to provide a more specific location in the cycle stack)

Several queries were renamed to work better as method names, i.e. by suffixing with `_of`.

r? @nikomatsakis
2017-04-26 09:54:11 +00:00
Vadim Petrochenkov
1883b8d715 privacy: Rename and cleanup PrivacyVisitor 2017-04-25 22:38:39 +03:00