about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late.rs
AgeCommit message (Collapse)AuthorLines
2021-03-27lazily calls some fnsklensy-1/+1
2021-03-23Some refactoringvarkor-14/+14
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-0/+1
This currently creates a field which is always false on GenericParamDefKind for future use when consts are permitted to have defaults Update const_generics:default locations Previously just ignored them, now actually do something about them. Fix using type check instead of value Add parsing This adds all the necessary changes to lower const-generics defaults from parsing. Change P<Expr> to AnonConst This matches the arguments passed to instantiations of const generics, and makes it specific to just anonymous constants. Attempt to fix lowering bugs
2021-03-16ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`Vadim Petrochenkov-2/+2
2021-02-25Address review commentsAmanieu d'Antras-37/+3
2021-02-24Properly reject non-const argumentsAmanieu d'Antras-2/+50
2021-02-19Rollup merge of #82259 - osa1:issue82156, r=petrochenkovDylan DPC-6/+5
Fix popping singleton paths in when generating E0433 Fixes #82156 --- This was introduced with #72923, so pinging `@Patryk27` for reviews.
2021-02-18Fix popping singleton paths in when generating E0433Ömer Sinan Ağacan-6/+5
Fixes #82156
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-1/+1
Also remove `ast::Mod` which is mostly redundant now
2021-02-06Rollup merge of #81680 - camsteffen:primty, r=oli-obkJonas Schievink-8/+4
Refactor `PrimitiveTypeTable` for Clippy I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
2021-02-03Refactor out PrimitiveTypeTableCameron Steffen-8/+4
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-10/+16
2021-01-21Fix clippy and commentEsteban Küber-1/+1
2021-01-21Suggest `'a` when given `a` only when appropriateEsteban Küber-0/+6
When encountering a name `a` that isn't resolved, but a label `'a` is found in the current ribs, only suggest `'a` if this name is the value expression of a `break` statement. Solve FIXME.
2021-01-21Rollup merge of #81046 - rylev:unknown-external-crate, r=estebankYuki Okushi-0/+7
Improve unknown external crate error This improves error messages when unknown items in the crate root are encountered. Fixes #63799 r? ```@estebank```
2021-01-18Improve unknown external crate errorRyan Levick-0/+7
2021-01-17Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasperMara Bos-62/+10
resolve: Simplify collection of traits in scope "Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace. Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore. I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351. In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits. It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway. The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names. I'm not sure whether it is desirable or not, but I think it's acceptable for now. The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope. If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well. --- The PR also contains a couple of pure refactorings - Scope walk is done by using `visit_scopes` instead of a hand-rolled version. - Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all. r? ```@matthewjasper```
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-1/+1
2021-01-12Replace a simple `if let` with the `matches` macroLingMan-2/+1
2021-01-11resolve: Simplify collection of traits in scopeVadim Petrochenkov-62/+10
2021-01-10Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasperbors-35/+47
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-08Rollup merge of #80012 - sasurau4:feature/point-constant-identifier-E0435, ↵Yuki Okushi-10/+28
r=petrochenkov Add pointing const identifier when emitting E0435 Fix #79919
2021-01-07resolve: Scope visiting doesn't need an `Ident`Vadim Petrochenkov-35/+47
2021-01-07Add pointing const identifier when emitting E0435Daiki Ihara-10/+28
2021-01-06Rename to `nearest_parent_mod`Camelid-2/+2
* 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-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-30Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkovMara Bos-1/+1
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-1/+1
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-30where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)Matthias Krüger-5/+3
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-11-13Auto merge of #78826 - petrochenkov:mrscopes2, r=eddybbors-1/+1
resolve: Collapse `macro_rules` scope chains on the fly Otherwise they grow too long and you have to endlessly walk through them when resolving macros or imports. Addresses https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Slow.20Builtin.20Derives/near/215750815
2020-11-11Implement destructuring assignment for structs and slicesFabian Zaiser-3/+1
Co-authored-by: varkor <github@varkor.com>
2020-11-07resolve: Collapse `macro_rules` scope chains on the flyVadim Petrochenkov-1/+1
2020-11-01Auto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkovbors-16/+8
Suggest calling associated `fn` inside `trait`s When calling a function that doesn't exist inside of a trait's associated `fn`, and another associated `fn` in that trait has that name, suggest calling it with the appropriate fully-qualified path. Expand the label to be more descriptive. Prompted by the following user experience: https://users.rust-lang.org/t/cannot-find-function/50663
2020-10-30Fix even more clippy warningsJoshua Nelson-40/+17
2020-10-26Suggest calling associated `fn` inside `trait`sEsteban Küber-16/+8
When calling a function that doesn't exist inside of a trait's associated `fn`, and another associated `fn` in that trait has that name, suggest calling it with the appropriate fully-qualified path. Expand the label to be more descriptive. Prompted by the following user experience: https://users.rust-lang.org/t/cannot-find-function/50663
2020-10-22min_const_generics: allow ty param in repeat exprBastian Kauschke-18/+70
2020-10-17Suggest correct place to add `self` parameter when inside closureJan Verbeek-3/+5
It would incorrectly suggest adding it as a parameter to the closure instead of the containing function.
2020-10-09Add docstringEsteban Küber-0/+2
2020-10-09Given `<T as Trait>::A: Ty` suggest `T: Trait<A = Ty>`Esteban Küber-0/+11
Fix #75829
2020-10-09Point out why a trait is expected on `Struct + 'lt`Esteban Küber-0/+7
2020-09-18use matches!() macro for simple if let conditionsMatthias Krüger-1/+1
2020-09-13allow concrete self types in constsBastian Kauschke-2/+5
2020-09-11Auto merge of #76499 - guswynn:priv_des, r=petrochenkovbors-11/+19
Give better diagnostic when using a private tuple struct constructor Fixes #75907 Some notes: 1. This required some deep changes, including removing a Copy impl for PatKind. If some tests fail, I would still appreciate review on the overall approach 2. this only works with basic patterns (no wildcards for example), and fails if there is any problems getting the visibility of the fields (i am not sure what the failure that can happen in resolve_visibility_speculative, but we check the length of our fields in both cases against each other, so if anything goes wrong, we fall back to the worse error. This could be extended to more patterns 3. this does not yet deal with #75906, but I believe it will be similar 4. let me know if you want more tests 5. doesn't yet at the suggestion that `@yoshuawuyts` suggested at the end of their issue, but that could be added relatively easily (i believe)