summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle
AgeCommit message (Collapse)AuthorLines
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-3/+2
2023-05-19Auto merge of #111641 - michaelwoerister:debugger-visualizer-fixes, r=cjgillotbors-0/+39
Fix dependency tracking for debugger visualizers This PR fixes dependency tracking for debugger visualizer files by changing the `debugger_visualizers` query to an `eval_always` query that scans the AST while it is still available. This way the set of visualizer files is already available when dep-info is emitted. Since the query is turned into an `eval_always` query, dependency tracking will now reliably detect changes to the visualizer script files themselves. TODO: - [x] perf.rlo - [x] Needs a bit more documentation in some places - [x] Needs regression test for the incr. comp. case Fixes https://github.com/rust-lang/rust/issues/111226 Fixes https://github.com/rust-lang/rust/issues/111227 Fixes https://github.com/rust-lang/rust/issues/111295 r? `@wesleywiser` cc `@gibbyfree`
2023-05-17Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkinDylan DPC-6/+2
Remove `LangItems::require` It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-16Move DebuggerVisualizerFile types from rustc_span to rustc_middleMichael Woerister-0/+39
2023-05-16Remove `LangItems::require`Nilstrieb-6/+2
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-3/+3
2023-05-11Populate effective visibilities in rustc_privacyBryanskiy-26/+19
2023-05-08Revert "Populate effective visibilities in `rustc_privacy`"Michael Goulet-19/+26
This reverts commit cff85f22f5030fbe7266d272da74a9e76160523c.
2023-05-05Populate effective visibilities in `rustc_privacy`Bryanskiy-26/+19
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-4/+4
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-28Remove some unnecessary derives.Nicholas Nethercote-3/+3
I was curious about how many `Encodable`/`Decodable` derives we have. Some grepping revealed that it's over 500 of each, but the number of `Encodable` ones was higher, which was weird. Most of the `Encodable`-only ones were in `hir.rs`. This commit removes them all, plus some other unnecessary derives in that file and others that I found via trial and error.
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-1/+1
2023-04-01fix clippy::iter_kv_mapMatthias Krüger-1/+1
2023-03-30Rollup merge of #109704 - petrochenkov:effvisclean, r=jackh726Michael Goulet-1/+5
resolve: Minor improvements to effective visibilities See individual commits.
2023-03-29Support TLS access into dylibs on WindowsJohn Kåre Alsaker-0/+5
2023-03-28effvis: Stop considering crate root its own parentVadim Petrochenkov-1/+5
It helped to reuse `update_def` for the crate root, but it created confusion and caused some mistakes when I implemented #109500
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-7/+7
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-2/+2
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-20Remove IntoDefIdTreeOli Scherer-17/+8
2023-02-18Move late-bound arg type checks to resolve_bound_varsMichael Goulet-0/+2
2023-02-17Rollup merge of #108126 - tshepang:nits, r=lcnrMatthias Krüger-1/+2
fix a line, and do a consistency fix
2023-02-16fix some lines, and do a consistency fixTshepang Mbambo-1/+2
2023-02-16Make things actually workMichael Goulet-2/+2
2023-02-16Rename some region-specific stuffMichael Goulet-6/+6
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-2/+2
2022-12-20Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obkbors-3/+2
Improve syntax of `newtype_index` This makes it more like proper Rust and also makes the implementation a lot simpler. Mostly just turns weird flags in the body into proper attributes. It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-19clippy::complexity fixesMatthias Krüger-6/+1
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-2/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Use `#[derive]` instead of custom syntax in all `newtype_index`Nilstrieb-1/+1
2022-12-05Move linkage type check to HIR analysis and fix semantics issues.Peter Collingbourne-1/+4
This ensures that the error is printed even for unused variables, as well as unifying the handling between the LLVM and GCC backends. This also fixes unusual behavior around exported Rust-defined variables with linkage attributes. With the previous behavior, it appears to be impossible to define such a variable such that it can actually be imported and used by another crate. This is because on the importing side, the variable is required to be a pointer, but on the exporting side, the type checker rejects static variables of pointer type because they do not implement `Sync`. Even if it were possible to import such a type, it appears that code generation on the importing side would add an unexpected additional level of pointer indirection, which would break type safety. This highlighted that the semantics of linkage on Rust-defined variables is different to linkage on foreign items. As such, we now model the difference with two different codegen attributes: linkage for Rust-defined variables, and import_linkage for foreign items. This change gives semantics to the test src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was previously expected to fail to compile. Therefore, convert it into a test that is expected to successfully compile. The update to the GCC backend is speculative and untested.
2022-11-27Add `TyCtxt::is_fn_trait`Maybe Waffle-0/+8
2022-11-27Rename `fn_trait_kind_from_{from_lang=>def_id}` to better convey meaningMaybe Waffle-1/+1
2022-11-25Auto merge of #104602 - petrochenkov:effvisperf5, r=oli-obkbors-50/+57
privacy: Fix more (potential) issues with effective visibilities Continuation of https://github.com/rust-lang/rust/pull/103965. See individual commits for more detailed description of the changes. The shortcuts removed in https://github.com/rust-lang/rust/pull/104602/commits/4eb63f618e601efee657d24cd4e8833fb03fac4c and https://github.com/rust-lang/rust/pull/104602/commits/c7c7d1672739e38c8d39ae861b284486aefd5b48 could actually be correct (or correct after some tweaks), but they used global reasoning like "we can skip this update because if the code compiles then some other update should do the same thing eventually". I have some expertise in this area, but I still have doubt whether such global reasoning was correct or not, especially in presence of all possible exotic cases with imports. After this PR all table changes should be "locally correct" after every update, even if it may be overcautious. If similar optimizations are introduced again they will need detailed comments explaining why it's legal to do what they do and providing proofs. Fixes https://github.com/rust-lang/rust/issues/104249. Fixes https://github.com/rust-lang/rust/issues/104539.
2022-11-24effective visibility: Always add table entries for nodes used as parentsVadim Petrochenkov-33/+37
Previously if the parent was not in the table, and there was nothing to inherit from, the child's private visibility was used, but that's not correct - the parent may have a larger visibility so we should set it to at least the parent's private visibility. That parent's private visibility is also inserted into the table for caching, so it's not recalculated later if used again.
2022-11-24effective visibility: Remove questionable optimizationsVadim Petrochenkov-7/+0
First, they require eagerly calculating private visibility (current normal module), which is somewhat expensive. Private visibilities are also lost once calculated, instead of being cached in the table. Second, I cannot prove that the optimizations are correct. Maybe they can be partially reinstated in the future in cases when it's cheap and provably correct to do them. They will also probably be merged into `fn update` in that case. Partially fixes https://github.com/rust-lang/rust/issues/104249 Fixes https://github.com/rust-lang/rust/issues/104539
2022-11-24effective visibility: Satisfy borrow checker to use resolver lazily from a ↵Vadim Petrochenkov-10/+20
closure
2022-11-23Bump the const eval step limitOli Scherer-1/+1
2022-11-05resolve: Fill effective visibilities for import def ids in a separate passVadim Petrochenkov-2/+28
This should result in less update calls than doing it repeatedly during the fix point iteration.
2022-11-05privacy: Check effective visibility invariantsVadim Petrochenkov-1/+50
2022-11-05resolve: More detailed effective visibility tracking for importsVadim Petrochenkov-18/+25
Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there.
2022-10-31Rollup merge of #103603 - camsteffen:refactor-lang, r=oli-obkDylan DPC-4/+0
Lang item cleanups Various cleanups related to lang items.
2022-10-29Cleanup weak lang itemsCameron Steffen-4/+0
2022-10-29rustc_middle: Remove unnecessary type parameter from `AccessLevels`Vadim Petrochenkov-32/+16
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-80/+79
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-25Perf improvements for effective visibility calculatingBryanskiy-33/+35
2022-10-16Auto merge of #102026 - Bryanskiy:resolve_update, r=petrochenkovbors-32/+104
Populate effective visibilities in 'rustc_resolve' Next part of RFC https://github.com/rust-lang/rust/issues/48054. previous: https://github.com/rust-lang/rust/pull/101713 `@rustbot` author r? `@petrochenkov`
2022-10-16Populate effective visibilities in 'rustc_resolve'Bryanskiy-32/+104
2022-10-01Refactor rustc lint APIMaybe Waffle-7/+4
2022-09-24separate definitions and `HIR` ownersTakayuki Maeda-4/+4
fix a ui test use `into` fix clippy ui test fix a run-make-fulldeps test implement `IntoQueryParam<DefId>` for `OwnerId` use `OwnerId` for more queries change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-19Rollup merge of #101881 - TaKO8Ki:remove-unused-struct-field, r=sanxiynMatthias Krüger-6/+1
Remove an unused struct field `late_bound`