about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/macros.rs
AgeCommit message (Collapse)AuthorLines
2023-10-13Format all the let chains in compilerMichael Goulet-24/+36
2023-10-05Rename `Resolver::active_features`.Nicholas Nethercote-1/+1
For the reasons described in the previous commit.
2023-09-12`#[diagnostic::on_unimplemented]` without filtersGeorg Semmler-2/+3
This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options: * `message` to customize the primary error message * `note` to add a customized note message to an error message * `label` to customize the label part of the error message Co-authored-by: León Orell Valerian Liehr <me@fmease.dev> Co-authored-by: Michael Goulet <michael@errs.io>
2023-09-04resolve: derive diag for undetermined macro resolutionbohan-8/+7
2023-08-24resolve: Make bindings for derive helper attributes uniqueVadim Petrochenkov-5/+14
instead of creating them every time such attribute is used
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-1/+2
Removes two pieces of mutable state. Follow up to #114622.
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-3/+3
2023-07-28Introduce the `#[diagnostic]` attribute namespaceGeorg Semmler-3/+17
Co-authored-by: est31 <est31@users.noreply.github.com> Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-07-22Use features() over features_untracked() where possibleLeón Orell Valerian Liehr-4/+1
2023-07-05resolve: Use `Interned` for `NameBinding`Vadim Petrochenkov-2/+2
2023-06-29resolve: Remove artificial import ambiguity errorsVadim Petrochenkov-1/+1
2023-06-18Add translatable diagnostic for cannot find in this scopeTom Martin-3/+10
2023-06-10Make "consider importing" consistent for macrosMu001999-3/+3
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-3/+9
`#[cfg]`s are frequently used to gate crate content behind cargo features. This can lead to very confusing errors when features are missing. For example, `serde` doesn't have the `derive` feature by default. Therefore, `serde::Serialize` fails to resolve with a generic error, even though the macro is present in the docs. This commit adds a list of all stripped item names to metadata. This is filled during macro expansion and then, through a fed query, persisted in metadata. The downstream resolver can then access the metadata to look at possible candidates for mentioning in the errors. This slightly increases metadata (800k->809k for the feature-heavy windows crate), but not enough to really matter.
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-2/+2
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-2/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-11/+11
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-25Fix static string lintsclubby789-3/+1
2023-04-17Suggest using integration tests for proc-macrosclubby789-5/+5
2023-04-07Change type and field name to be clearerTom Martin-3/+2
2023-04-07Rewrite added diagnostics as translatableTom Martin-6/+16
Start messages with lowercase
2023-04-06Collapse if statements, change message to lowercaseTom Martin-6/+7
2023-04-02Skip help messages if macro span is from macroTom Martin-3/+5
2023-03-30Fix typoTom Martin-1/+1
2023-03-30Update non-derive macro error message to match suggestionTom Martin-9/+3
It's now split between two errors, one to remove the invalid derive macro and one suggesting adding a new non-derive macro
2023-03-26Add suggestion to remove derive() if invoked macro is non-deriveTom Martin-5/+17
2023-03-23rustc_interface: Add a new query `pre_configure`Vadim Petrochenkov-2/+2
It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes are then expanded normally during the main expansion pass, like attributes on any other nodes.
2023-03-23Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgrbors-2/+2
Rollup of 9 pull requests Successful merges: - #108954 (rustdoc: handle generics better when matching notable traits) - #109203 (refactor/feat: refactor identifier parsing a bit) - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions) - #109358 (rustc: Remove unused `Session` argument from some attribute functions) - #109359 (Update stdarch) - #109378 (Remove Ty::is_region_ptr) - #109423 (Use region-erased self type during IAT selection) - #109447 (new solver cleanup + implement coherence) - #109501 (make link clickable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-22More general capturesest31-1/+1
This avoids repetition
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-2/+2
2023-03-06Querify registered_tools.Camille GILLOT-7/+11
2023-02-22resolve: Remove `ImportResolver`Vadim Petrochenkov-2/+1
It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-20Remove a redundant function argumentOli Scherer-6/+1
2023-02-20Prepare for adding a `TyCtxt` to `Resolver`Oli Scherer-23/+30
2023-02-14Separate the lifetime of the session and the arena in the resolverOli Scherer-2/+2
2023-02-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-2/+2
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-1/+1
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2022-12-09Move the untracked cstore and source_span into a structOli Scherer-1/+1
2022-12-09Generate crate loaders on the flyOli Scherer-1/+1
2022-11-12Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obkDylan DPC-1/+1
Add the `#[derive_const]` attribute Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to. r? `````@oli-obk`````
2022-10-20fix span for suggestionyukang-13/+7
2022-10-20fix #103112, add diagnostic for calling a function with the same name when a ↵yukang-2/+20
Macro is not found
2022-10-11rustc_hir: Less error-prone methods for accessing `PartialRes` resolutionVadim Petrochenkov-6/+3
2022-09-20Add the `#[derive_const]` attributeDeadbeef-1/+1
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-28Remove `register_attr` featureYuki Okushi-22/+7
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-21avoid embedding StabilityLevel::Unstable reason string into metadata ↵klensy-1/+1
multiple times
2022-07-20middle: add `implies_by` to `#[unstable]`David Wood-2/+9
If part of a feature is stabilized and a new feature is added for the remaining parts, then the `implied_by` attribute can be used to indicate which now-stable feature previously contained a item. If the now-stable feature is still active (if the user has only just updated rustc, for example) then there will not be an stability error for uses of the item from the implied feature. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-18avoid `Symbol` to `&str` conversionsTakayuki Maeda-2/+2
2022-06-17Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoeristerbors-1/+0
Split up `Definitions` and `ResolverAstLowering`. Split off https://github.com/rust-lang/rust/pull/95573 r? `@michaelwoerister`