summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2022-06-23Rollup merge of #98336 - fmease:remove-faulty-doc-hidden-lint, r=GuillaumeGomezYuki Okushi-74/+2
Remove the unused-`#[doc(hidden)]` logic from the `unused_attributes` lint Fixes #96890. It was found out that `#[doc(hidden)]` on trait impl items does indeed have an effect on the generated documentation (see the linked issue). In my opinion and the one of [others](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60/near/281846219), rustdoc's output is actually a bit flawed in that regard but that should be tracked in a new issue I suppose (I will open an issue for that in the near future). The check was introduced in #96008 which is marked to be part of version `1.62` (current `beta`). As far as I understand, this means that **this PR needs to be backported** to `beta` to fix #96890 on time. Correct me if I am wrong. CC `@dtolnay` (in case you would like to agree or disagree with my decision to fully remove this check) `@rustbot` label A-lint T-compiler T-rustdoc r? `@rust-lang/compiler`
2022-05-10fix typolcnr-1/+1
2022-05-10only_local: always check for misuselcnr-9/+9
2022-05-09Auto merge of #96473 - lcnr:querify-codegen-fn-attrs, r=cjgillotbors-21/+52
store `codegen_fn_attrs` in crate metadata extracted from #95562 because the change isn't trivial.
2022-05-09reviewlcnr-3/+3
2022-05-09only compute `codegen_fn_attrs` where neededlcnr-21/+52
2022-05-08Warn on unused doc(hidden) on trait impl itemsLeón Orell Valerian Liehr-2/+74
2022-05-06use def_span and def_kind queries instead of calling tcx.hir() methodsMiguel Guarniz-2/+2
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-05Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkovbors-1/+27
generalize "incoherent impls" impl for user defined types To allow the move of `trait Error` into core. continues the work from #94963, finishes https://github.com/rust-lang/compiler-team/issues/487 r? `@petrochenkov` cc `@yaahc`
2022-05-05generalize "incoherent impls" impl for custom typeslcnr-1/+27
2022-05-04Cleanup broken doc links.ridwanabdillahi-1/+1
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-0/+199
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-9/+8
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-30Box HIR Generics and Impl.Camille GILLOT-2/+2
2022-04-25Auto merge of #95604 - nbdd0121:used2, r=petrochenkovbors-0/+5
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix #50007 and #47384 This is the synthetic object file approach that I described in https://github.com/rust-lang/rust/pull/95363#issuecomment-1079932354, allowing all exported and used symbols to be linked while still allowing them to be GCed. Related #93791, #95363 r? `@petrochenkov` cc `@carbotaniuman`
2022-04-25Auto merge of #96246 - SparrowLii:bound_contxet, r=compiler-errorsbors-1/+2
Add `BoundKind` in `visit_param_bounds` to check questions in bounds From the FIXME in the impl of `AstValidator`. Better bound checks by adding `BoundCtxt` type parameter to `visit_param_bound` cc `@ecstatic-morse`
2022-04-23Fix lints.Camille GILLOT-35/+14
2022-04-23Drop vis in Item.Camille GILLOT-1/+1
2022-04-23Drop vis in FieldDef.Camille GILLOT-4/+14
2022-04-21rename to `BoundKind` and add commentsSparrowLii-2/+2
2022-04-20Add `BoundCtxt` in `visit_param_bounds` to check questions in boundsSparrowLii-1/+2
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-35/+26
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-18Make `#[used]` considered reachableGary Guo-0/+5
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-35/+26
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-59/+48
Refactor HIR item-like traversal (part 1) Issue #95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
2022-04-16Rollup merge of #95006 - tmiasko:thread-local-static, r=wesleywiserDylan DPC-0/+16
Reject `#[thread_local]` attribute on non-static items
2022-04-16Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisabors-6/+54
Implement sym operands for global_asm! Tracking issue: #93333 This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are: - At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`. - At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails). - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`. - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to. - The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression. - At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details. - On Mach-O, all symbols have a leading underscore. - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall. - No mangling is needed on other platforms. r? `@nagisa` cc `@eddyb`
2022-04-15Rollup merge of #96027 - matthiaskrgr:clippy_rec, r=fee1-deadDylan DPC-3/+2
remove function parameters only used in recursion
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-6/+54
global_asm!
2022-04-14remove redundant function param in check_for_self_assign_helper()Matthias Krüger-3/+2
2022-04-13couple of clippy::complexity fixesMatthias Krüger-2/+2
2022-04-09restrict access to span only when we emit diagnosticMiguel Guarniz-1/+1
2022-04-08add mapping from DefKind to Target and remove more ItemLikeVisitor implsMiguel Guarniz-62/+36
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08remove some uses of visit_all_item_likes in typeck, symbol_mangling and ↵Miguel Guarniz-1/+16
passes crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08check_doc_keyword: don't alloc string for emptiness checkklensy-32/+28
check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-05span: move `MultiSpan`David Wood-2/+2
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-03Rollup merge of #95553 - jam1garner:naked-function-compile-error, r=tmiaskoDylan DPC-3/+22
Don't emit non-asm contents error for naked function composed of errors ## Motivation For naked functions an error is emitted when they are composed of anything other than a single asm!() block. However, this error triggers in a couple situations in which it adds no additional information or is actively misleading. One example is if you do have an asm!() block but simply one with a syntax error: ```rust #[naked] unsafe extern "C" fn compiler_errors() { asm!(invalid_syntax) } ``` This results in two errors, one for the syntax error itself and another telling you that you need an asm block in your function: ```rust error[E0787]: naked functions must contain a single asm block --> src/main.rs:6:1 | 6 | / unsafe extern "C" fn naked_compile_error() { 7 | | asm!(blah) 8 | | } | |_^ ``` This issue also comes up when [utilizing `compile_error!()` for improving your diagnostics](https://twitter.com/steveklabnik/status/1509538243020218372), such as raising a compiler error when compiling for an unsupported target. ## Implementation The rules this PR implements are as follows: 1. If any non-erroneous non-asm statement is included, an error will still occur 2. If multiple asm statements are included, an error will still occur 3. If 0 or 1 asm statements are present, as well as any non-zero number of erroneous statements, then this error will *not* be raised as it is likely either redundant or incorrect The rule of thumb is effectively "if an error is present and its correction could change things, don't raise an error".
2022-04-02Rollup merge of #95544 - jam1garner:improve-naked-noreturn-diagnostic, r=tmiaskoDylan DPC-1/+14
Add error message suggestion for missing noreturn in naked function I had to google the syntax for inline asm's `noreturn` option when I got this error earlier today, so I figured I'd save others the trouble and add the syntax/fix as a suggestion in the error.
2022-04-02Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnrDylan DPC-4/+7
Handle rustc_const_stable attribute in library feature collector The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were: - When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable". This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase: ```console error[E0635]: unknown feature `const_ptr_offset` --> $DIR/offset_from_ub.rs:1:35 | LL | #![feature(const_ptr_offset_from, const_ptr_offset)] | ^^^^^^^^^^^^^^^^ ``` - We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes. This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-01Reword purpose description of noreturn in naked functionjam1garner-1/+1
2022-04-01Don't emit non-asm contents error for naked function composed of errorsjam1garner-3/+22
2022-03-31Add error message suggestion for missing noreturn in naked functionjam1garner-1/+14
2022-03-31Handle rustc_const_stable attribute in library feature collectorDavid Tolnay-4/+7
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-1/+1
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-4/+4
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-1/+1
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30Addressed comments by @compiler-errors and @bjorn3Yuri Astrakhan-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-5/+5
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30rework implementation for inherent impls for builtin typeslcnr-0/+21
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-1/+1
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.