summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2019-12-11resolve: Always resolve visibilities on impl itemsVadim Petrochenkov-12/+12
2019-12-11Rollup merge of #67074 - ehuss:extern-options, r=petrochenkovMazdak Farrokhzad-2/+4
Add options to --extern flag. This changes the `--extern` flag so that it can take a series of options that changes its behavior. The general syntax is `[opts ':'] name ['=' path]` where `opts` is a comma separated list of options. Two options are supported, `priv` which replaces `--extern-private` and `noprelude` which avoids adding the crate to the extern prelude. ```text --extern priv:mylib=/path/to/libmylib.rlib --extern noprelude:alloc=/path/to/liballoc.rlib ``` `noprelude` is to be used by Cargo's build-std feature in order to use `--extern` to reference standard library crates. This also includes a second commit which adds the `aux-crate` directive to compiletest. I can split this off into a separate PR if desired, but it helps with defining these kinds of tests. It is based on #54020, and can be used in the future to replace and simplify some of the Makefile tests.
2019-12-09resolve: Make visibility resolution more speculativeVadim Petrochenkov-60/+85
To avoid potential duplicate diagnostics and separate the error reporting logic
2019-12-09resolve: Cleanup some field processing codeVadim Petrochenkov-32/+31
2019-12-09resolve: Resolve visibilities on fields with non-builtin attributesVadim Petrochenkov-4/+14
2019-12-09Add options to --extern flag.Eric Huss-2/+4
2019-12-06Rename to `then_some` and `then`varkor-4/+4
2019-12-06Use `to_option` in various placesvarkor-20/+5
2019-11-30Rollup merge of #66895 - Centril:rustc_feature, r=oli-obkMazdak Farrokhzad-14/+8
Feature gating *declarations* => new crate `rustc_feature` This PR moves the data-oriented parts of feature gating into its own crate, `rustc_feature`. The parts consist of some data types as well as `accepted`, `active`, `removed`, and `builtin_attrs`. Feature gate checking itself remains in `syntax::feature_gate::check`. The parts which define how to emit feature gate errors could probably be moved to `rustc_errors` or to the new `rustc_session` crate introduced in #66878. The visitor itself could probably be moved as a pass in `rustc_passes` depending on how the dependency edges work out. The PR also contains some drive-by cleanup of feature gate checking. As such, the PR probably best read commit-by-commit. r? @oli-obk cc @petrochenkov cc @Mark-Simulacrum
2019-11-30move GateIssue to rustc_feature & simplify emit_feature_errMazdak Farrokhzad-8/+3
2019-11-30builtin_attrs.rs -> rustc_featureMazdak Farrokhzad-4/+5
2019-11-30move is_builtin_attr to syntax::attrMazdak Farrokhzad-3/+1
2019-11-28rustc_metadata: Merge `cstore.rs` into `creader.rs`Vadim Petrochenkov-3/+2
2019-11-26Rollup merge of #66754 - estebank:rustdoc-capitalization, r=Dylan-DPCTyler Mandry-2/+4
Various tweaks to diagnostic output
2019-11-25Various cleanupsEsteban Küber-2/+4
2019-11-25Auto merge of #66669 - petrochenkov:tup2attr, r=matthewjasperbors-9/+10
Fix some issues with attributes on unnamed fields Fixes https://github.com/rust-lang/rust/issues/66487 Fixes https://github.com/rust-lang/rust/issues/66555
2019-11-24Auto merge of #66647 - petrochenkov:nosynt, r=Centrilbors-10/+5
rustc_plugin: Remove support for syntactic plugins This part of the plugin interface was successfully replaced by token-based procedural macros in theory and in practice. cc https://github.com/rust-lang/rust/issues/29597 cc https://github.com/rust-lang/rust/pull/64675 r? @Centril
2019-11-24Auto merge of #66592 - estebank:raw-raw-ah-ah-ah, r=cramertjbors-3/+4
Rework raw ident suggestions Use heuristics to determine whethersuggesting raw identifiers is appropriate. Account for raw identifiers when printing a path in a `use` suggestion. Fix #66126.
2019-11-24rustc_plugin: Remove support for syntactic pluginsVadim Petrochenkov-10/+5
2019-11-24expand: Fully preserve visibilities on unnamed fields with attributesVadim Petrochenkov-0/+3
2019-11-24def_collector: Do not forget to save indices of fields with multiple attributesVadim Petrochenkov-9/+7
2019-11-23review commentsEsteban Küber-1/+1
2019-11-23Rework raw ident suggestionsEsteban Küber-3/+4
Use heuristics to determine whethersuggesting raw identifiers is appropriate. Account for raw identifiers when printing a path in a `use` suggestion.
2019-11-23Move def collector from `rustc` to `rustc_resolve`Vadim Petrochenkov-3/+358
2019-11-22resolve: more declarative fresh_bindingMazdak Farrokhzad-15/+7
2019-11-20Auto merge of #66104 - yodaldevoid:generic-arg-disambiguation, r=petrochenkovbors-0/+54
Generic arg disambiguation Using the tactic suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/60804#issuecomment-516769465 and on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/generic.20argument.20disambiguation), this change checks type arguments to see if they are really incorrectly-parsed const arguments. it should be noted that `segments.len() == 1 && segments[0].arg.is_none()` was reduced to `segments.len() == 1` as suggested by @petrochenkov in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/generic.20argument.20disambiguation/near/177848002). This change allowed a few more existing tests to have their braces removed. There are a couple of "problems" with these changes that I should note. First, there was a regression in the error messages found in "src/test/ui/privacy-ns1.rs" and "src/test/ui/privacy-ns1.rs". Second, some braces were unable to be removed from "src/test/ui/const-generics/fn-const-param-infer.rs". Those on line 24 caused the statement to stop equating when removed, and those on line 20 cause a statement that should not equate to produce no error when removed. I have not looked further into any of these issues yet, though I would be willing to look into them before landing this. I simply wanted to get some other eyes on this before going further. Fixes #60804 cc @varkor @jplatte
2019-11-18resolve: late: Check if type arg is really a const argGabriel Smith-0/+46
A path type argument could be a generic const argument due to limitations as to what we can determine at parsing. We double check just to be sure by trying to resolve in the type namespace first, and if that fails we try again in the value namespace. If resolution in the value namespace succeeds, we have a generic const argument on our hands.
2019-11-18resolve: Allow idents to resolve to primitives in the type namespaceGabriel Smith-0/+8
2019-11-19resolve: Give derive helpers highest priority during resolutionVadim Petrochenkov-9/+16
2019-11-17Rollup merge of #66344 - petrochenkov:noregattr, r=matthewjasperYuki Okushi-23/+1
rustc_plugin: Remove `Registry::register_attribute` Legacy plugins cannot register inert attributes anymore. The preferred replacement is to use `register_tool` ([tracking issue](https://github.com/rust-lang/rust/issues/66079)). ```rust #![register_tool(servo)] #[servo::must_root] struct S; ``` The more direct replacement is `register_attribute` ([tracking issue](https://github.com/rust-lang/rust/issues/66080)) ```rust #![register_attr(must_root)] #[must_root] struct S; ``` , but it requires registering each attribute individually rather than registering the tool once, and is more likely to be removed rather than stabilized.
2019-11-16rustc_plugin: Remove `Registry::register_attribute`Vadim Petrochenkov-23/+1
2019-11-16expand: Stop marking derive helper attributes as knownVadim Petrochenkov-0/+3
Pass them through name resolution instead
2019-11-16resolve: Introduce a new scope for derive helpersVadim Petrochenkov-7/+54
2019-11-16resolve: `Scope::DeriveHelpers` -> `Scope::DeriveHelpersCompat`Vadim Petrochenkov-6/+6
These helpers are resolved before their respective derives through a kind of look ahead into future expansions. Some of these will migrate to proper resolution, others will be deprecated. ``` #[trait_helper] // Deprecate #[derive(Trait)] #[trait_helper] // Migrate to proper resolution ```
2019-11-15Rollup merge of #66197 - Centril:transparent-ast, r=varkorTyler Mandry-20/+6
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per https://github.com/rust-lang/rfcs/pull/2515, this needs to change to allow `impl Trait` in nested positions. This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported. r? @varkor
2019-11-15Don't warn labels beginning with `_`Yuki Okushi-1/+3
2019-11-14TAIT: adjust resolveMazdak Farrokhzad-20/+6
2019-11-14Clean some error codes diagnosticsGuillaume Gomez-5/+5
2019-11-14Remove unused error_codes.rs filesGuillaume Gomez-2048/+0
2019-11-14Update to use new librustc_error_codes libraryGuillaume Gomez-1/+13
2019-11-10Auto merge of #66070 - petrochenkov:regattr, r=matthewjasperbors-81/+101
Support registering inert attributes and attribute tools using crate-level attributes And remove `#[feature(custom_attribute)]`. (`rustc_plugin::Registry::register_attribute` is not removed yet, I'll do it in a follow up PR.) ```rust #![register_attr(my_attr)] #![register_tool(my_tool)] #[my_attr] // OK #[my_tool::anything] // OK fn main() {} ``` --- Some tools (`rustfmt` and `clippy`) used in tool attributes are hardcoded in the compiler. We need some way to introduce them without hardcoding as well. This PR introduces a way to do it with a crate level attribute. The previous attempt to introduce them through command line (https://github.com/rust-lang/rust/pull/57921) met some resistance. This probably needs to go through an RFC before stabilization. However, I'd prefer to land *this* PR without an RFC to able to remove `#[feature(custom_attribute)]` and `Registry::register_attribute` while also providing a replacement. --- `register_attr` is a direct replacement for `#![feature(custom_attribute)]` (https://github.com/rust-lang/rust/issues/29642), except it doesn't rely on implicit fallback from unresolved attributes to custom attributes (which was always hacky and is the primary reason for the removal of `custom_attribute`) and requires registering the attribute explicitly. It's not clear whether it should go through stabilization or not. It's quite possible that all the uses should migrate to `#![register_tool]` (https://github.com/rust-lang/rust/issues/66079) instead. --- Details: - The naming is `register_attr`/`register_tool` rather than some `register_attributes` (plural, no abbreviation) for consistency with already existing attributes like `cfg_attr`, or `feature`, etc. --- Previous attempt: https://github.com/rust-lang/rust/pull/57921 cc https://github.com/rust-lang/rust/issues/44690 Tracking issues: #66079 (`register_tool`), #66080 (`register_attr`) Closes https://github.com/rust-lang/rust/issues/29642
2019-11-09Inline reserve_node_idsMark Rousskov-13/+5
This function was only ever called with 1 so there's little point in it; this isn't an expensive operation (essentially a checked add) so we're not really "reserving" anything either.
2019-11-09Move next_node_id to ResolverMark Rousskov-4/+27
This doesn't migrate the pretty-printing everybody loops, which will be done in the next few commits.
2019-11-09Address review commentsVadim Petrochenkov-4/+5
2019-11-09resolve: Factor out some common binding creation functionalityVadim Petrochenkov-29/+14
2019-11-09resolve: Remove some bits relevant only to legacy pluginsVadim Petrochenkov-22/+11
They are unstable and going to be removed anyway and the removed code would complicate the next commit
2019-11-09Remove `#[feature(custom_attribute)]`Vadim Petrochenkov-24/+2
2019-11-09Support registering attributes and attribute tools using crate-level attributesVadim Petrochenkov-20/+87
2019-11-08Rollup merge of #66188 - Centril:fnsig, r=davidtwcoMazdak Farrokhzad-1/+1
`MethodSig` -> `FnSig` & Use it in `ItemKind::Fn` In both AST & HIR, rename `MethodSig` to `FnSig` and then proceed to use it in `ItemKind::Fn` so that the overall structure is more regular. r? @davidtwco
2019-11-08Rollup merge of #65785 - Centril:compat-to-error-2, r=oli-obkMazdak Farrokhzad-30/+8
Transition future compat lints to {ERROR, DENY} - Take 2 Follow up to https://github.com/rust-lang/rust/pull/63247 implementing https://github.com/rust-lang/rust/pull/63247#issuecomment-536295992. - `legacy_ctor_visibility` (ERROR) -- closes #39207 - `legacy_directory_ownership` (ERROR) -- closes #37872 - `safe_extern_static` (ERROR) -- closes #36247 - `parenthesized_params_in_types_and_modules` (ERROR) -- closes #42238 - `duplicate_macro_exports` (ERROR) - `nested_impl_trait` (ERROR) -- closes #59014 - `ill_formed_attribute_input` (DENY) -- transitions #57571 - `patterns_in_fns_without_body` (DENY) -- transitions #35203 r? @varkor cc @petrochenkov