about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2023-04-09Rollup merge of #109985 - blyxyas:is_test_crate, r=compiler-errorsMatthias Krüger-1/+1
Add little `is_test_crate` function Ok, this is quite a story. I'm mainly a Clippy contributor, so I was fixing [this Clippy issue](https://github.com/rust-lang/rust-clippy/pull/10584) about a lint having to ignore test modules but that wasn't ignoring test files (integration test, `test/` dirs and such). As test **files** don't tend to have an inner `#[cfg(test)]` module inside them, I tried everything, looking for filenames, looking for item's parents in the HIR Map, doing black magic... I even asked [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20Checking.20if.20file.20is.20integration.20test), and jyn answered something about `--cfg test`. Aha! That's something that I might be looking for, so I started looking at `rustc_driver_impl` flag parsing and configuration and all that. Then, I stumbled on [this function right here](https://github.com/rust-lang/rust/blob/2e486be8d29d198d48bc26bfce5712a4822814f5/compiler/rustc_driver_impl/src/lib.rs#L174-L181), and noticed the argument `config: Config`. That's a hint. So [Config](https://doc.rust-lang.org/beta/nightly-rustc/rustc_interface/interface/struct.Config.html) has the field `opts: Options`, and [`Options`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_session/options/struct.Options.html) has the field `test`. This journey has been ~7 or 8 hours in 3 days, it's a very hard thing to find, so this PR adds a mini-function to check if the current crate is a testing one. So that no one has to travel through the same as me, and can just search for `is_test_crate` in the documentation.
2023-04-09Remove turbofishNilstrieb-1/+1
2023-04-09Some simple `clippy::perf` fixesNilstrieb-1/+1
2023-04-09Migrate `sess.opts.tests` uses to `sess.is_test_crate()`blyxyas-1/+1
2023-04-09Auto merge of #109500 - petrochenkov:modchainld, r=oli-obkbors-1/+22
resolve: Preserve reexport chains in `ModChild`ren This may be potentially useful for - avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues) - preserving documentation comments on all reexports, including those from other crates - preserving and checking stability/deprecation info on reexports - all kinds of diagnostics The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct. Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used. The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore Fixes https://github.com/rust-lang/rust/issues/109631 Fixes https://github.com/rust-lang/rust/issues/109614 Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errorsbors-7/+12
Suggest defining const parameter when appropriate Helps a bit with #91119. Following #105523's lead, I use placeholder `/* Type */` instead of `_` in the suggestion. It should be easier for newcomers to parse. `@rustbot` label A-diagnostics r? diagnostics
2023-04-08resolve: Preserve reexport chains in `ModChild`renVadim Petrochenkov-1/+22
This may be potentially useful for - avoiding uses of `hir::ItemKind::Use` - preserving documentation comments on all reexports - preserving and checking stability/deprecation info on reexports - all kinds of diagnostics
2023-04-07Change type and field name to be clearerTom Martin-5/+4
2023-04-07Rewrite added diagnostics as translatableTom Martin-6/+43
Start messages with lowercase
2023-04-07suggest adding const paramLeón Orell Valerian Liehr-7/+12
2023-04-07Use smart-resolve when checking for trait in RHS of UFCSMichael Goulet-2/+30
2023-04-07Rollup merge of #110013 - compiler-errors:non-exhaustive-privacy-reason, ↵Matthias Krüger-1/+19
r=WaffleLapkin Label `non_exhaustive` attribute on privacy errors from non-local items Label when an ADT is `non_exhaustive` and we get a privacy error, help with confusion in a case like this: ```rust #[non_exhaustive] pub struct Foo; // other crate let x = Foo; //~^ ERROR unit struct `Foo` is private ```
2023-04-06Collapse if statements, change message to lowercaseTom Martin-6/+7
2023-04-06Make span a bit betterMichael Goulet-1/+13
2023-04-06Label non_exhaustive on privacy errorsMichael Goulet-1/+7
2023-04-05Auto merge of #109986 - JohnTitor:rollup-3aax38t, r=JohnTitorbors-11/+16
Rollup of 7 pull requests Successful merges: - #109909 (Deny `use`ing tool paths) - #109921 (Don't ICE when encountering `dyn*` in statics or consts) - #109922 (Disable `has_thread_local` on OpenHarmony) - #109926 (write threads info into log only when debugging) - #109968 (Add regression test for #80409) - #109969 (Add regression test for #86351) - #109973 (rustdoc: Improve logo display very small screen) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-06Rollup merge of #109909 - clubby789:import-tool-mod, r=petrochenkovYuki Okushi-11/+16
Deny `use`ing tool paths Fixes #109853 Fixes #109147
2023-04-05Auto merge of #109437 - petrochenkov:effvisopt, r=davidtwcobors-8/+28
resolve: Restore some effective visibility optimizations Something similar was previously removed as a part of https://github.com/rust-lang/rust/pull/104602. So we can see [bitmaps-3.1.0](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/bitmaps-3.1.0), [match-stress](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/match-stress) and [unused-warnings](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/unused-warnings) in regressions there, and in improvements in this PR. After this PR all table changes should also be "locally correct" after every update.
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-2/+2
2023-04-04box a bunch of large typesOli Scherer-5/+5
2023-04-04Deny `use`ing tool pathsclubby789-11/+16
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-5/+5
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-3/+4
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-2/+2
2023-04-04Auto merge of #109599 - notriddle:notriddle/use-redundant-glob, r=petrochenkovbors-14/+21
diagnostics: account for glob shadowing when linting redundant imports Fixes #92904
2023-04-02Skip help messages if macro span is from macroTom Martin-3/+5
2023-04-01slighty simplify a few boolean expressions (clippy::nonminimal_bool)Matthias Krüger-1/+1
2023-04-01fix clippy::iter_kv_mapMatthias Krüger-5/+4
2023-04-01diagnostics: account for glob shadowing when linting redundant importsMichael Howell-14/+21
Co-Authored-By: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-03-31Auto merge of #109824 - GuillaumeGomez:rollup-i5r4uts, r=GuillaumeGomezbors-3/+5
Rollup of 7 pull requests Successful merges: - #109104 (rustdoc: Fix invalid suggestions on ambiguous intra doc links v2) - #109443 (Move `doc(primitive)` future incompat warning to `invalid_doc_attributes`) - #109680 (Fix subslice capture in closure) - #109798 (fluent_messages macro: don't emit the OS error in a note) - #109805 (Source map cleanups) - #109818 (rustdoc: Add GUI test for jump to collapsed item) - #109820 (rustdoc-search: update docs for comma in `?` help popover) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-31Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddleGuillaume Gomez-3/+5
Move `doc(primitive)` future incompat warning to `invalid_doc_attributes` Fixes #88070. It's been a while since this was turned into a "future incompatible lint" so I think we can now turn it into a hard error without problem. r? `@jyn514`
2023-03-31Auto merge of #109010 - compiler-errors:rtn, r=eholkbors-0/+2
Initial support for return type notation (RTN) See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/ 1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter. * I'd add this in a follow-up. 3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~ * I don't think we actually want this. 5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`. * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it. 7. ~I'm not in love with the feature gate name 😺~ * I renamed it to `return_type_notation` :heavy_check_mark: Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later. r? `@ghost`
2023-03-31resolve: Restore some effective visibility optimizationsVadim Petrochenkov-8/+28
Something similar was previously removed as a part of #104602, but after this PR all table changes should also be "locally correct" after every update.
2023-03-31Update doc(primitive) in rustc_resolveGuillaume Gomez-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-28effvis: Stop considering crate root its own parentVadim Petrochenkov-7/+6
It helped to reuse `update_def` for the crate root, but it created confusion and caused some mistakes when I implemented #109500
2023-03-28effvis: Merge two similar code pathsVadim Petrochenkov-34/+23
2023-03-28Add `(..)` syntax for RTNMichael Goulet-0/+2
2023-03-27Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez-3/+1
Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-26Add suggestion to remove derive() if invoked macro is non-deriveTom Martin-5/+17
2023-03-24Auto merge of #107932 - petrochenkov:onlyexport, r=jyn514bors-2/+19
rustdoc: Skip doc link resolution for non-exported items
2023-03-24Rollup merge of #109536 - petrochenkov:qcstore3, r=cjgillotMatthias Krüger-3/+8
resolve: Rename some cstore methods to match queries and add comments about costs associated with replacing them with query calls. Supersedes https://github.com/rust-lang/rust/pull/108346. r? `@cjgillot`
2023-03-23Rollup merge of #109487 - GuillaumeGomez:move-useless-reexport-check, ↵Matthias Krüger-2/+40
r=petrochenkov Move useless_anynous_reexport lint into unused_imports As mentioned in https://github.com/rust-lang/rust/pull/109003, this check should have been merged with `unused_imports` in the start. r? `@petrochenkov`
2023-03-23Rollup merge of #107880 - jieyouxu:issue-107563, r=petrochenkovMatthias Krüger-20/+85
Lint ambiguous glob re-exports Attempts to fix #107563. We currently already emit errors for ambiguous re-exports when two names are re-exported *specifically*, i.e. not from glob exports. This PR attempts to emit deny-by-default lints for ambiguous glob re-exports.
2023-03-23resolve: Rename some cstore methods to match queries and add commentsVadim Petrochenkov-3/+8
about costs associated with replacing them with query calls.
2023-03-23Auto merge of #108221 - petrochenkov:cratecfg, r=michaelwoeristerbors-7/+8
rustc_interface: Add a new query `pre_configure` 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 on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes. This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working. Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
2023-03-23Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgrbors-31/+18
Rollup of 7 pull requests Successful merges: - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs) - #109137 (resolve: Querify most cstore access methods (subset 2)) - #109380 (add `known-bug` test for unsoundness issue) - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate)) - #109475 (Simpler checked shifts in MIR building) - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.) - #109506 (make param bound vars visibly bound vars with -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-23rustdoc: Skip doc link resolution for non-exported itemsVadim Petrochenkov-2/+19
2023-03-23rustc_interface: Add a new query `pre_configure`Vadim Petrochenkov-7/+8
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.