about summary refs log tree commit diff
path: root/compiler/rustc_passes
AgeCommit message (Collapse)AuthorLines
2021-11-29Auto merge of #91299 - cjgillot:expect-ldid, r=petrochenkovbors-5/+4
Take a LocalDefId in expect_*item. Items and item-likes are always HIR owners. When trying to find such nodes, there is no ambiguity, the `LocalDefId` and the `HirId::owner` always match. In such cases, `local_def_id_to_hir_id` does not carry any meaningful information, so we can just skip calling it altogether.
2021-11-28Remove unused root_parent.Camille GILLOT-13/+1
2021-11-28Remove eval_always for lib_features.Camille GILLOT-3/+3
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-5/+4
2021-11-25Rollup merge of #89359 - fee1-dead:const-it, r=oli-obkMatthias Krüger-0/+6
Various fixes for const_trait_impl A few problems I found while making `Iterator` easier to const-implement. 1. More generous `~const Drop` check. We check for nested fields with caller bounds. For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either: - Bounded (`A: ~const Drop`, `B: Copy`) - Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`) 2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates. I think anyone can review this, so no r? this time.
2021-11-24Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelidGuillaume Gomez-1/+1
Create rustdoc_internals feature gate As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag. This is pretty much what it would look like (needs to update the tests too). The tracking issue is https://github.com/rust-lang/rust/issues/90418. What do you think ``@rust-lang/rustdoc`` ?
2021-11-24Create rustdoc_internals feature gateGuillaume Gomez-1/+1
2021-11-24Allow features like const_try in d_m_b_i_cDeadbeef-0/+6
2021-11-18Add checks for more empty attributes.Eric Huss-2/+11
2021-11-18Check for duplicate attributes.Eric Huss-17/+101
2021-11-17Rollup merge of #89610 - guswynn:must_use_future, r=wesleywiserMatthias Krüger-0/+32
warn on must_use use on async fn's As referenced in #78149 This only works on `async` fn's for now, I can also look into if I can get `Box<dyn Future>` and `impl Future` working at this level (hir)
2021-11-16Update compiler/rustc_passes/src/check_attr.rsWesley Wiser-1/+1
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2021-11-15Stabilize format_args_captureJosh Triplett-1/+1
Works as expected, and there are widespread reports of success with it, as well as interest in it.
2021-11-12rustc_feature: Convert `BuiltinAttribute` from tuple to a structVadim Petrochenkov-2/+2
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-5/+6
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-08warn on must_use use on async fn'sGus Wynn-0/+32
2021-11-07more clippy fixesMatthias Krüger-3/+3
2021-11-07Rename functions reflect that inline const is also "typeck_child"Gary Guo-3/+3
2021-11-07Implement type inference for inline constsGary Guo-2/+3
In most cases it is handled in the same way as closures.
2021-10-30Rollup merge of #90374 - GuillaumeGomez:unify-rustdoc-book-titles, r=camelidMatthias Krüger-1/+1
Unify titles in rustdoc book doc attributes chapter As discussed in https://github.com/rust-lang/rust/pull/90339. I wasn't able to find out where the link to the titles was used so let's see if the CI fails. :) r? ``@camelid``
2021-10-29Unify titles in rustdoc book doc attributes chapterGuillaume Gomez-1/+1
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-84/+61
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-15add a `rustc::query_stability` lintlcnr-61/+83
2021-10-11Use Ancestory to check default fn in const impl instead of comparing identsGary Guo-18/+26
2021-10-09Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obkMatthias Krüger-16/+120
make #[target_feature] work with `asm` register classes Fixes #89289
2021-10-08Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514Guillaume Gomez-2/+1
clippy::complexity fixes
2021-10-08clippy::complexity fixesMatthias Krüger-2/+1
2021-10-07make #[target_feature] work with `asm` register classesasquared31415-16/+120
2021-10-07Auto merge of #89629 - GuillaumeGomez:rollup-s4r8me6, r=GuillaumeGomezbors-0/+1
Rollup of 7 pull requests Successful merges: - #89298 (Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers ) - #89461 (Add `deref_into_dyn_supertrait` lint.) - #89477 (Move items related to computing diffs to a separate file) - #89559 (RustWrapper: adapt for LLVM API change) - #89585 (Emit item no type error even if type inference fails) - #89596 (Make cfg imply doc(cfg)) - #89615 (Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-10-07Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514Guillaume Gomez-0/+1
Make cfg imply doc(cfg) This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well): * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc. * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation. * I updated the version for the feature. There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624) > I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different. How/why should they differ? EDIT: this part has been solved, the current code was fine, just needed a little simplification. cc `@Nemo157` r? `@jyn514` Original PR description: This is only active when the `doc_cfg` feature is active. The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like: ```rust #[cfg(unix)] #[doc(cfg(all()))] pub struct Unix; ``` By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-07Auto merge of #89534 - camsteffen:diag-name, r=oli-obkbors-20/+14
Introduce `tcx.get_diagnostic_name` Introduces a "reverse lookup" for diagnostic items. This is mainly intended for `@rust-lang/clippy` which often does a long series of `is_diagnostic_item` calls for the same `DefId`. r? `@oli-obk`
2021-10-07Auto merge of #89454 - erikdesjardins:perfattrcheck, r=nikomatsakisbors-38/+4
perf: only check for `rustc_trivial_field_reads` attribute on traits, not items, impls, etc. The checks that are removed in this PR (originally added in #85200) caused a small perf regression: https://github.com/rust-lang/rust/pull/88824#issuecomment-932664761 Since the attribute is currently only applied to traits, I don't think it's worth keeping the additional checks for now. If/when we decide to apply the attribute somewhere else, we can (partially) revert this and reevaluate the perf impact. r? `@nikomatsakis` cc `@FabianWolff`
2021-10-06Introduce get_diagnostic_nameCameron Steffen-20/+14
2021-10-05Rollup merge of #89442 - GuillaumeGomez:duplicated-doc-alias, r=estebankManish Goregaokar-7/+38
Add check for duplicated doc aliases r? ``@estebank``
2021-10-05Rollup merge of #88871 - FabianWolff:issue-88403, r=jackh726Manish Goregaokar-8/+15
Fix suggestion for nested struct patterns Fixes #88403, and also a similar problem where the unused binding is in a function parameter pattern.
2021-10-05Add `cfg_hide` to the list of known attributesJoshua Nelson-0/+1
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-3/+2
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-04Add a check for duplicated doc aliases in unused lintGuillaume Gomez-7/+38
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-3/+2
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-2/+2
2021-10-02only check for automatically_derived on impls, not individual methodsErik Desjardins-18/+6
this matches behavior of existing code https://github.com/rust-lang/rust/blob/b27661eb33c74cb514dba059b47d86b6582ac1c2/compiler/rustc_passes/src/liveness.rs#L326-L333
2021-10-01perf: only check for rustc_trivial_field_reads attribute on traitsErik Desjardins-23/+1
The checks removed here caused a small perf regression: https://github.com/rust-lang/rust/pull/88824#issuecomment-932664761 Since the attribute is currently only applied to traits, I don't think it's worth keeping the additional checks for now. If/when we decide to apply the attribute somewhere else, we can (partially) revert this and evaluate if the perf impact is acceptable.
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-22/+16
2021-09-22Auto merge of #88865 - guswynn:must_not_suspend, r=oli-obkbors-0/+16
Implement `#[must_not_suspend]` implements #83310 Some notes on the impl: 1. The code that searches for the attribute on the ADT is basically copied from the `must_use` lint. It's not shared, as the logic did diverge 2. The RFC does specify that the attribute can be placed on fn's (and fn-like objects), like `must_use`. I think this is a direct copy from the `must_use` reference definition. This implementation does NOT support this, as I felt that ADT's (+ `impl Trait` + `dyn Trait`) cover the usecase's people actually want on the RFC, and adding an imp for the fn call case would be significantly harder. The `must_use` impl can do a single check at fn call stmt time, but `must_not_suspend` would need to answer the question: "for some value X with type T, find any fn call that COULD have produced this value". That would require significant changes to `generator_interior.rs`, and I would need mentorship on that. `@eholk` and I are discussing it. 3. `@estebank` do you know a way I can make the user-provided `reason` note pop out? right now it seems quite hidden Also, I am not sure if we should run perf on this r? `@nikomatsakis`
2021-09-21Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebankbors-1/+1
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-20Migrate to 2021Mark Rousskov-1/+1
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-2/+2
2021-09-19Auto merge of #88703 - cjgillot:lazymod, r=petrochenkovbors-3/+3
Gather module items after lowering. This avoids having a non-local analysis inside lowering. By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.
2021-09-16delay error for enabling unstable lib featuresVishad Goyal-0/+10
If #![feature] is used outside the nightly channel for only lib features, the check will be delayed to the stability pass after parsing. This is done so that appropriate help messages can be shown if the #![feature] has been used needlessly