about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
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
2022-03-25resolve: Optimize path resolution for rustdocVadim Petrochenkov-59/+16
Do not construct or pass unused data
2022-03-25resolve: Do not build expensive suggestions if they are not actually usedVadim Petrochenkov-255/+215
Also remove a redundant parameter from `fn resolve_path(_with_ribs)`, `crate_lint: CrateLint` is a more detailed version of `record_used: bool` with `CrateLint::No` meaning `false` and anything else meaning `true`.
2022-03-21Return err instead of ICEouz-a-2/+23
2022-03-18Rollup merge of #95047 - ↵Matthias Krüger-1/+1
TaKO8Ki:remove-unnecessary-pattern-for-ignoring-all-parts, r=wesleywiser Refactor: remove an unnecessary pattern for ignoring all parts
2022-03-17Rollup merge of #94960 - codehorseman:master, r=oli-obkDylan DPC-1/+1
Fix many spelling mistakes Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-18refactor: remove an unnecessary pattern for ignoring all partsTakayuki Maeda-1/+1
2022-03-16rustc_error: make ErrorReported impossible to constructmark-6/+8
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15Rollup merge of #94958 - est31:pluralize, r=oli-obkMatthias Krüger-3/+3
Support other types of pluralization in pluralize macro
2022-03-15Support other types of pluralization in pluralize macroest31-3/+3
2022-03-15Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuberbors-55/+50
More robust fallback for `use` suggestion Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion. But this was fragile, as illustrated in issue #87613 This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion. Fix #87613
2022-03-04Rollup merge of #94595 - ↵Dylan DPC-1/+3
TaKO8Ki:fix-invalid-unresolved-imports-errors-for-asterisk-wildcard-syntax, r=estebank Fix invalid `unresolved imports` errors for a single-segment import closes #90248
2022-03-04fix invalid `unresolved imports` errors the asterisk wildcard syntax causesTakayuki Maeda-1/+3
use a path variabale
2022-03-03Adjusted diagnostic output so that if there is no `use` in a item sequence,Felix S. Klock II-53/+48
then we just suggest the first legal position where you could inject a use. To do this, I added `inject_use_span` field to `ModSpans`, and populate it in parser (it is the span of the first token found after inner attributes, if any). Then I rewrote the use-suggestion code to utilize it, and threw out some stuff that is now unnecessary with this in place. (I think the result is easier to understand.) Then I added a test of issue 87613.
2022-03-03Associate multiple with a crate too.Felix S. Klock II-2/+2
2022-03-04remove a unnecessary `..` patternTakayuki Maeda-1/+1
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-8/+12