about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2021-01-15Rollup merge of #80944 - LingMan:map_or, r=nagisaYuki Okushi-6/+5
Use Option::map_or instead of `.map(..).unwrap_or(..)` ``@rustbot`` modify labels +C-cleanup +T-compiler
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-6/+5
2021-01-14Auto merge of #79689 - Vooblin:patch1, r=tmandrybors-10/+10
Update tests of "unused_lifetimes" lint for async functions and corresponding source code Before this PR the following code would cause an error: ``` #![deny(unused_lifetimes)] async fn f<'a>(_: &'a i32) {} fn main() {} ``` It was happening because of the desugaring of return type in async functions. As a result of the desugaring, the return type contains all lifetimes involved in the function signature. And these lifetimes were interpreted separately from the same in the function scope => so they are unused. Now, all lifetimes from the return type are interpreted as used. It is also not perfect, but at least this lint doesn't cause wrong errors now. This PR connected to issues #78522, #77217
2021-01-13Auto merge of #77524 - Patryk27:fixes/66228, r=estebankbors-1/+1
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-4/+4
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-4/+4
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-12Rollup merge of #80927 - LingMan:matches, r=estebankYuki Okushi-2/+1
Replace a simple `if let` with the `matches` macro `@rustbot` modify labels +C-cleanup +T-compiler
2021-01-12Replace a simple `if let` with the `matches` macroLingMan-2/+1
2021-01-12Rollup merge of #80870 - petrochenkov:bmactable, r=oli-obkYuki Okushi-7/+9
resolve: Simplify built-in macro table We don't use full `SyntaxExtension`s from the table, only `SyntaxExtensionKind`s, and `Ident` in `register_builtin_macro` always had dummy span. This PR removes unnecessary data from the table and related function signatures. Noticed when reviewing #80850.
2021-01-11resolve: Simplify collection of traits in scopeVadim Petrochenkov-127/+74
2021-01-10Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasperbors-56/+81
resolve: Scope visiting doesn't need an `Ident` Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part. The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow. I think it's clearer to pass only the necessary part. Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case. r? `@matthewjasper`
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-1/+1
2021-01-10resolve: Simplify built-in macro tableVadim Petrochenkov-7/+9
2021-01-10Rollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkovYuki Okushi-5/+5
Allow #[rustc_builtin_macro = "name"] This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`. This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007. Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly. r? ``@petrochenkov``
2021-01-10Rollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkovYuki Okushi-16/+31
Use correct span for structured suggestion On structured suggestion for `let` -> `const` and `const` -> `let`, use a proper `Span` and update tests to check the correct application. Follow up to #80012.
2021-01-09Allow #[rustc_builtin_macro = "name"].Mara Bos-5/+5
This makes it possible to have both std::panic and core::panic as a builtin macro, by using different builtin macro names for each. Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly.
2021-01-09resolve/expand: Improve attribute expansion on macro definitions and callsVadim Petrochenkov-16/+24
2021-01-07Use correct span for structured suggestionEsteban Küber-16/+31
On structured suggestion for `let` -> `const` and `const` -> `let`, use a proper `Span` and update tests to check the correct application. Follow up to #80012.
2021-01-08Rollup merge of #80012 - sasurau4:feature/point-constant-identifier-E0435, ↵Yuki Okushi-19/+67
r=petrochenkov Add pointing const identifier when emitting E0435 Fix #79919
2021-01-07resolve: Scope visiting doesn't need an `Ident`Vadim Petrochenkov-56/+81
2021-01-07Add pointing const identifier when emitting E0435Daiki Ihara-19/+67
2021-01-06Rename to `nearest_parent_mod`Camelid-27/+35
* Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod` `normal_ancestor_id` is a very confusing name if you don't already understand what it means. Adding docs helps, but using a clearer and more obvious name is also important. * Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod` * Add more docs
2021-01-06Document `ModuleData`Camelid-6/+14
* Convert comments on fields to doc comments so they're visible in API docs * Add new documentation * Get rid of "normal module" terminology
2021-01-01adjust const generics defaults FIXMEs to the new feature gateRémy Rakic-1/+1
2021-01-01first pass at default values for const genericsJulian Knodt-1/+2
- Adds optional default values to const generic parameters in the AST and HIR - Parses these optional default values - Adds a `const_generics_defaults` feature gate
2020-12-31Consistently call editions "Rust 20xx" in messages.Mara Bos-2/+2
2020-12-30Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkovMara Bos-9/+9
Rename kw::Invalid -> kw::Empty See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context. r? `@petrochenkov`
2020-12-30Rename kw::Invalid -> kw::EmptyJoshua Nelson-9/+9
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context.
2020-12-30Rollup merge of #80509 - matthiaskrgr:ptr_arg, r=varkorYuki Okushi-5/+3
where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)
2020-12-30remove unused return types such as empty Results or Options that would ↵Matthias Krüger-12/+11
always be Some(..) remove unused return type of dropck::check_drop_obligations() don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..) remove redundant return type of back::write::optimize() don't Option-wrap return type of compute_type_parameters() since we always return Some(..) don't return empty Result in assemble_generator_candidates() don't return empty Result in assemble_closure_candidates() don't return empty result in assemble_fn_pointer_candidates() don't return empty result in assemble_candidates_from_impls() don't return empty result in assemble_candidates_from_auto_impls() don't return emtpy result in assemble_candidates_for_trait_alias() don't return empty result in assemble_builtin_bound_candidates() don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait() remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..) remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-30where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)Matthias Krüger-5/+3
2020-12-29Remove `compile-fail` test suiteVadim Petrochenkov-1/+1
2020-12-28Rollup merge of #80411 - petrochenkov:nosymwith, r=matthewjasperDylan DPC-1/+4
rustc_span: Remove `Symbol::with` A subset of https://github.com/rust-lang/rust/pull/79425 that is a pure refactoring.
2020-12-28Rollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPCDylan DPC-11/+8
use matches!() macro in more places
2020-12-27rustc_span: Remove `Symbol::with`Vadim Petrochenkov-1/+4
2020-12-26stabilize min_const_genericsBastian Kauschke-7/+15
2020-12-24use matches!() macro in more placesMatthias Krüger-11/+8
2020-12-20Move std_path construction into conditionDániel Buga-5/+4
2020-12-20Inline a single-use closureDániel Buga-2/+2
2020-12-20Create closure outside of the loopDániel Buga-4/+4
2020-12-20Add missing semicolonDániel Buga-1/+1
2020-12-20Remove unnecessary clonedDániel Buga-1/+1
2020-12-20Precompute vector length in smart_resolve_path_fragmentDániel Buga-1/+2
2020-12-20Clean up with_generic_param_rib, avoid double hashingDániel Buga-24/+17
2020-12-17Enhance error message when misspelled label to value in break expressionDaiki Ihara-0/+20
Apply suggestions from code review Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
2020-12-12Resolve enum field visibility correctlyCamelid-1/+11
Previously, this code treated enum fields' visibility as if they were struct fields. However, that's not correct because the visibility of a struct field with `ast::VisibilityKind::Inherited` is private to the module it's defined in, whereas the visibility of an *enum* field with `ast::VisibilityKind::Inherited` is the visibility of the enum it belongs to.
2020-12-04Update tests of "unused_lifetimes" lint for async functions and ↵Dmitry Murygin-10/+10
corresponding source code
2020-12-02Tweak diagnostics on shadowing lifetimes/labelsYuki Okushi-1/+1
2020-11-26Remove ForeignMod struct.Camille GILLOT-1/+1
2020-11-24Move lev_distance to rustc_ast, make non-genericArlie Davis-28/+33
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST would not have any dependency its lexer, for minimizing unnecessarily design-time dependencies. Breaking this dependency would also have practical benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast. This commit does not remove the rustc_ast --> rustc_lexer dependency, but it does remove one of the sources of this dependency, which is the code that handles fuzzy matching between symbol names for making suggestions in diagnostics. Since that code depends only on Symbol, it is easy to move it to rustc_span. It might even be best to move it to a separate crate, since other tools such as Cargo use the same algorithm, and have simply contain a duplicate of the code. This changes the signature of find_best_match_for_name so that it is no longer generic over its input. I checked the optimized binaries, and this function was duplicated at nearly every call site, because most call sites used short-lived iterator chains, generic over Map and such. But there's no good reason for a function like this to be generic, since all it does is immediately convert the generic input (the Iterator impl) to a concrete Vec<Symbol>. This has all of the costs of generics (duplicated method bodies) with no benefit. Changing find_best_match_for_name to be non-generic removed about 10KB of code from the optimized binary. I know it's a drop in the bucket, but we have to start reducing binary size, and beginning to tame over-use of generics is part of that.