about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-24/+21
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-24/+21
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17Lint elided lifetimes in path on the AST.Camille GILLOT-61/+188
2022-04-17Report undeclared lifetimes on AST.Camille GILLOT-381/+831
2022-04-17Remove is_in_fn_syntax.Camille GILLOT-11/+0
2022-04-17Visit generics inside visit_fn.Camille GILLOT-2/+10
2022-04-17Count number of lifetime parameters in a separate pass.Camille GILLOT-13/+39
2022-04-16Rollup merge of #95887 - petrochenkov:doclink5, r=cjgillotDylan DPC-30/+28
resolve: Create dummy bindings for all unresolved imports Apparently such bindings weren't previously created for all unresolved imports, causing issues like https://github.com/rust-lang/rust/issues/95879. In this PR I'm trying to create such dummy bindings in a more centralized way by calling `import_dummy_binding` once for all imports in `finalize_imports`. Fixes https://github.com/rust-lang/rust/issues/95879.
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-2/+71
global_asm!
2022-04-12Rollup merge of #95918 - compiler-errors:issue-95878, r=cjgillotDylan DPC-0/+9
Delay a bug when we see SelfCtor in ref pattern Fixes #95878
2022-04-12Rollup merge of #95405 - cjgillot:probe, r=petrochenkovDylan DPC-2191/+2337
Move name resolution logic to a dedicated file The code resolution logic from an Ident is scattered between several files. The first commits creates `rustc_resolve::probe` module to hold the different mutually recursive functions together. Just a move, no code change. The following commits attempt to make the logic a bit more readable. The two fields `last_import_segment` and `unusable_binding` are replaced by function parameters. In order to manage the fallout, `maybe_` variants of the function are added, dedicated to speculative resolution. r? `@petrochenkov`
2022-04-12Handle `unusable_binding` more compactly.Vadim Petrochenkov-17/+14
2022-04-12Fix imports.Camille GILLOT-8/+3
2022-04-12Move diagnostic methods to the dedicated module.Camille GILLOT-477/+472
2022-04-12Simplify error reporting.Camille GILLOT-85/+76
2022-04-12Move path resolution error to rustc_resolve::diagnostics.Camille GILLOT-164/+207
2022-04-12Make the logic more explicit with let chains.Camille GILLOT-18/+16
2022-04-12Do not record Res when builing a suggestion.Camille GILLOT-6/+9
2022-04-12Insert error after checking for binding usability.Camille GILLOT-6/+6
2022-04-12Pass last_import_segment and unusable_binding as parameters.Camille GILLOT-79/+177
2022-04-12Simplify binding finalization.Camille GILLOT-53/+54
2022-04-12Move ident resolution to a dedicated module.Camille GILLOT-1643/+1668
2022-04-12Rollup merge of #95936 - TaKO8Ki:fix-relative-paths-error-message, r=Dylan-DPCMatthias Krüger-1/+1
Fix a bad error message for `relative paths are not supported in visibilities` error closes #95638
2022-04-11fix a bad error message for `relative paths are not supported in ↵Takayuki Maeda-1/+1
visibilities` error
2022-04-11Rollup merge of #95907 - compiler-errors:diag, r=Dylan-DPCMatthias Krüger-7/+6
address fixme for diagnostic variable name quick rename
2022-04-10Delay a bug when we see SelfCtor in ref patternMichael Goulet-0/+9
2022-04-10resolve: Create dummy bindings for all unresolved importsVadim Petrochenkov-30/+28
2022-04-10FIXME for diagnostic variable nameMichael Goulet-7/+6
2022-04-10Store LocalDefId in is_late_bound_map.Camille GILLOT-7/+10
This allows to avoid looking at HIR from borrowck.
2022-04-09Auto merge of #95697 - klensy:no-strings, r=petrochenkovbors-1/+1
refactor: simplify few string related interactions Few small optimizations: check_doc_keyword: don't alloc string for emptiness check check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use FxHashSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-08check_doc_keyword: don't alloc string for emptiness checkklensy-1/+1
check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-06Fix unit struct/enum variant in destructuring assignmentMichael Goulet-7/+4
2022-04-07rustdoc: Early doc link resolution fixes and refactoringsVadim Petrochenkov-5/+6
2022-04-05resolve: Fix resolution of empty paths passed from rustdocVadim Petrochenkov-1/+3
2022-04-05Rollup merge of #95512 - davidtwco:diagnostic-translation, r=oli-obkDylan DPC-11/+12
diagnostics: translation infrastructure An implementation of the infrastructure required to have translatable diagnostic messages. - Introduces a `DiagnosticMessage` type which can represent both the current non-translatable messages and identifiers for [Fluent](https://projectfluent.org/). - Modifies current diagnostic API so that existing calls still work but `DiagnosticMessage`s can be provided too. - Adds support for always loading a "fallback bundle" containing the English diagnostic messages, which are used when a `DiagnosticMessage::FluentIdentifier` is used in a diagnostic being emitted. - Adds support for loading a "primary bundle" which contains the user's preferred language translation, and is used preferentially when it contains a diagnostic message being emitted. Primary bundles are loaded either from the path provided to `-Ztranslate-alternate-ftl` (for testing), or from the sysroot at `$sysroot/locale/$locale/*.ftl` given a locale with `-Ztranslate-lang` (which is parsed as a language identifier). - Adds "diagnostic args" which enable normally-interpolated variables to be made available as variables for Fluent messages to use. - Updates `#[derive(SessionDiagnostic)]` so that it can only be used for translatable diagnostics and update the handful of diagnostics which used the derive to be translatable. For example, the following diagnostic... ```rust #[derive(SessionDiagnostic)] #[error = "E0195"] pub struct LifetimesOrBoundsMismatchOnTrait { #[message = "lifetime parameters or bounds on {item_kind} `{ident}` do not match the trait declaration"] #[label = "lifetimes do not match {item_kind} in trait"] pub span: Span, #[label = "lifetimes in impl do not match this {item_kind} in trait"] pub generics_span: Option<Span>, pub item_kind: &'static str, pub ident: Ident, } ``` ...becomes... ```rust #[derive(SessionDiagnostic)] #[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")] pub struct LifetimesOrBoundsMismatchOnTrait { #[primary_span] #[label] pub span: Span, #[label = "generics-label"] pub generics_span: Option<Span>, pub item_kind: &'static str, pub ident: Ident, } ``` ```fluent typeck-lifetimes-or-bounds-mismatch-on-trait = lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration .label = lifetimes do not match {$item_kind} in trait .generics-label = lifetimes in impl do not match this {$item_kind} in trait ``` r? `@estebank` cc `@oli-obk` `@Manishearth`
2022-04-05errors: implement fallback diagnostic translationDavid Wood-3/+3
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-8/+9
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05Auto merge of #95337 - petrochenkov:doclink3, r=camelidbors-3/+12
rustdoc: Fix resolution of `crate`-relative paths in doc links Resolve `crate::foo` paths transparently to rustdoc, so their resolution no longer affects diagnostics and modules used for determining traits in scope. The proper solution is to account for the current `module_id`/`parent_scope` in `fn resolve_crate_root`, but it's a slightly larger compiler changes. This PR moves the code closer to it, but keeps it rustdoc-specific. Fixes https://github.com/rust-lang/rust/issues/78696 Fixes https://github.com/rust-lang/rust/issues/94924
2022-04-04format condTakayuki Maeda-2/+4
2022-04-04remove unnecessary nested blocksTakayuki Maeda-12/+8
2022-03-31Stop emitting lints during lowering.Camille GILLOT-4/+0
2022-03-31Store next_disambiguator in Definitions.Camille GILLOT-12/+1
2022-03-31Remove mutability in ResolverAstLowering.Camille GILLOT-8/+8
2022-03-31rustdoc: Fix resolution of `crate`-relative paths in doc linksVadim Petrochenkov-3/+12
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-9/+9
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Spellchecking compiler commentsYuri Astrakhan-9/+9
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-6/+6
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-27resolve: Simplify some diagnostic code to avoid an ICEVadim Petrochenkov-17/+4
2022-03-25resolve: Rename `CrateLint` to `Finalize`Vadim Petrochenkov-170/+147
And `crate_lint`/`record_used` to `finalize`
2022-03-25resolve: Stop passing unused spans and node ids to path resolution functionsVadim Petrochenkov-267/+188