summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2021-11-09Add `ty::Visibility::is_public()`inquisitivecrystal-2/+2
2021-11-09Rollup merge of #90701 - michaelwoerister:more-artifact-sizes, r=davidtwcoMatthias Krüger-0/+3
Record more artifact sizes during self-profiling. This PR adds artifact size recording for - "linked artifacts" (executables, RLIBs, dylibs, static libs) - object files - dwo files - assembly files - crate metadata - LLVM bitcode files - LLVM IR files - codegen unit size estimates Currently the identifiers emitted for these are hard-coded as string literals. Is it worth adding constants to https://github.com/rust-lang/measureme/blob/master/measureme/src/rustc.rs instead? We don't do that for query names and the like -- but artifact kinds might be more stable than query names.
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-3/+9
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-08Record more artifact sizes during self-profiling.Michael Woerister-0/+3
2021-11-07Auto merge of #88368 - jyn514:metadata-error, r=petrochenkovbors-15/+75
Improve error when an .rlib can't be parsed This usually describes either an error in the compiler itself or some sort of IO error. Either way, we should report it to the user rather than just saying "crate not found". This only gives an error if the crate couldn't be loaded at all - if the compiler finds another .rlib or .rmeta file which was valid, it will continue to compile the crate. Example output: ``` error[E0785]: found invalid metadata files for crate `foo` --> bar.rs:3:24 | 3 | println!("{}", foo::FOO_11_49[0]); | ^^^ | = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset ``` cc `@ehuss`
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-1/+1
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-1/+1
2021-11-07Improve error when an .rlib can't be parsedJoshua Nelson-15/+75
This usually describes either an error in the compiler itself or some sort of IO error. Either way, we should report it to the user rather than just saying "crate not found". This only gives an error if the crate couldn't be loaded at all - if the compiler finds another .rlib or .rmeta file which was valid, it will continue to compile the crate. Example output: ``` error[E0785]: found invalid metadata files for crate `foo` --> bar.rs:3:24 | 3 | println!("{}", foo::FOO_11_49[0]); | ^^^ | = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset ```
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-0/+1
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07Give inline const separate DefKindGary Guo-3/+9
2021-11-03Demote metadata load warning to "info".Eric Huss-2/+2
2021-10-30Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkovGuillaume Gomez-16/+11
Improve and test cross-crate hygiene - Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck - Avoid suggesting importing names with def-site hygiene, since it's often not useful - Add more tests r? `@petrochenkov`
2021-10-28Remove `ModData` from rustc_metadataMatthew Jasper-11/+4
This avoids having to decode 2 `Lazy`s when decoding a modules exports.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-25Avoid a branch on key being local for queries that use the same local and ↵bjorn3-3/+3
extern providers
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-21Handle cross-crate module `ExpnId`s consistentlyMatthew Jasper-6/+8
- Always use the ExpnId serialized to `tables` - Use the Id for traits and enums from other crates in resolution.
2021-10-19Don't emit a warning for empty rmeta files.Eric Huss-0/+9
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-3/+2
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-17Auto merge of #89514 - davidtwco:polymorphize-shims-and-predicates, r=lcnrbors-1/+9
polymorphization: shims and predicates Supersedes #75737 and #75414. This pull request includes up some changes to polymorphization which hadn't landed previously and gets stage2 bootstrapping and the test suite passing when polymorphization is enabled. There are still issues with `type_id` and polymorphization to investigate but this should get polymorphization in a reasonable state to work on. - #75737 and #75414 both worked but were blocked on having the rest of the test suite pass (with polymorphization enabled) with and without the PRs. It makes more sense to just land these so that the changes are in. - #75737's changes remove the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. This won't have much of an effect until polymorphization's analysis is more advanced, but it doesn't hurt. - #75414's changes remove all logic which marks parameters as used based on their presence in predicates - given #75675, this will enable more polymorphization and avoid the symbol clashes that predicate logic previously sidestepped. - Polymorphization now explicitly checks (and skips) foreign items, this is necessary for stage2 bootstrapping to work when polymorphization is enabled. - The conditional determining the emission of a note adding context to a post-monomorphization error has been modified. Polymorphization results in `optimized_mir` running for shims during collection where that wouldn't happen previously, some errors are emitted during `optimized_mir` and these were considered post-monomorphization errors with the existing logic (more errors and shims have a `DefId` coming from the std crate, not the local crate), adding a note that resulted in tests failing. It isn't particularly feasible to change where polymorphization runs or prevent it from using `optimized_mir`, so it seemed more reasonable to not change the conditional. - `characteristic_def_id_of_type` was being invoked during partitioning for self types of impl blocks which had projections that depended on the value of unused generic parameters of a function - this caused a ICE in a debuginfo test. If partitioning is enabled and the instance needs substitution then this is skipped. That test still fails for me locally, but not with an ICE, but it fails in a fresh checkout too, so 🤷‍♂️. r? `@lcnr`
2021-10-16Adopt let_else across the compilerest31-3/+2
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-12Include rmeta candidates in "multiple matching crates" errorNoah Lev-13/+15
Only dylib and rlib candidates were included in the error. I think the reason is that at the time this error was originally implemented, rmeta crate sources were represented different from dylib and rlib sources. I wrote up more detailed analysis in [this comment][1]. The new version of the code is also a bit easier to read and should be more robust to future changes since it uses `CrateSources::paths()`. [1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436
2021-10-12Sort candidate libraries by source path in errorNoah Lev-1/+7
This makes the error output deterministic and thus testable.
2021-10-08Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514Guillaume Gomez-1/+1
clippy::complexity fixes
2021-10-08clippy::complexity fixesMatthias Krüger-1/+1
2021-10-07Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkovJubilee-6/+10
Correct decoding of foreign expansions during incr. comp. Fixes https://github.com/rust-lang/rust/issues/74946 The original issue was due to a wrong assertion in `expn_hash_to_expn_id`. The secondary issue was due to a mismatch between the encoding and decoding paths for expansions that are created after the TyCtxt is created.
2021-10-07Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoeristerJubilee-1/+7
Implement `#[link_ordinal(n)]` Allows the use of `#[link_ordinal(n)]` with `#[link(kind = "raw-dylib")]`, allowing Rust to link against DLLs that export symbols by ordinal rather than by name. As long as the ordinal matches, the name of the function in Rust is not required to match the name of the corresponding function in the exporting DLL. Part of #58713.
2021-10-06Do not ICE if some foreign expansions were not encoded.Camille GILLOT-2/+0
The metadata encoder does not necessarily encode all expansions, only those which are referenced in other metadata fields.
2021-10-06Access Session while decoding expn_id.Camille GILLOT-4/+10
2021-10-06Introduce get_diagnostic_nameCameron Steffen-5/+13
2021-10-05Rollup merge of #89546 - joshtriplett:grow-metadata-faster, r=petrochenkovManish Goregaokar-1/+3
Make an initial guess for metadata size to reduce buffer resizes When reading metadata, the compiler starts with a `Vec::new()`, which will need to grow repeatedly as the metadata gets decompressed into it. Reduce the number of resizes by starting out at the size of the compressed data.
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-13/+13
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-04Make an initial guess for metadata size to reduce buffer resizesJosh Triplett-1/+3
2021-10-04Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebankJubilee-3/+3
Practice diagnostic message convention Detected by #89455. r? ```@estebank```
2021-10-04Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwcoJubilee-1/+2
Recommend running `cargo clean` in E0514 output This suggestion has worked for me before. Seems to me it could help others.
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-13/+13
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-3/+3
2021-10-01Auto merge of #88880 - cjgillot:no-krate, r=oli-obkbors-6/+5
Rework HIR API to make invocations of the hir_crate query harder. `hir_crate` forces the recomputation of queries that depend on it. This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
2021-10-01polymorphize: polymorphize shimsDavid Wood-1/+9
This commit removes the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. Signed-off-by: David Wood <david.wood@huawei.com>
2021-09-30Recommend running `cargo clean` in E0514 outputpierwill-1/+2
2021-09-30Move EncodedMetadata to rustc_metadata.Camille GILLOT-4/+20
2021-09-30Move encode_metadata out of CrateStore.Camille GILLOT-7/+6
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-6/+5
2021-09-23Auto merge of #89016 - lcnr:non_blanket_impls, r=nikomatsakis,michaelwoeristerbors-43/+29
fix non_blanket_impls iteration order We sometimes iterate over all `non_blanket_impls`, not sure if this is observable outside of error messages (i.e. as incremental bugs). This should fix the underlying issue of #86986. second attempt of #88718 r? `@nikomatsakis`
2021-09-21Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebankbors-22/+22
Migrate in-tree crates to 2021 This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074. It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there. I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first. Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately. It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-21`crates` is already deterministiclcnr-43/+29
2021-09-20Adjust documentation for compatibility with 2021Mark Rousskov-22/+22
This also adjusts the lint docs generation to accept (and ignore) an allow attribute, rather than expecting the documentation to be immediately followed by the lint name.
2021-09-20Implement #[link_ordinal] attribute in the context of #[link(kind = ↵Richard Cobbe-1/+7
"raw-dylib")].
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-2/+2