about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2022-12-13Rename `assert_uninit_valid` intrinsicNilstrieb-4/+4
It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that.
2022-12-13Clarify explicit_predicates_of is_assoc_item_ty commentSantiago Pastorino-3/+4
2022-12-13Move some codegen-y methods from rustc_hir_analysis::collect -> ↵Michael Goulet-816/+4
rustc_codegen_ssa
2022-12-13EarlyBinder nitsMichael Goulet-9/+5
2022-12-12Join match arms since they do the same thingSantiago Pastorino-5/+1
2022-12-12Fix typoSantiago Pastorino-1/+1
2022-12-11Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-deadMatthias Krüger-1/+0
compiler: remove unnecessary imports and qualified paths Some of these imports were necessary before Edition 2021, others were already in the prelude. I hope it's fine that this PR is so spread-out across files :/
2022-12-11Add `round_ties_even` to `f32` and `f64`Jules Bertholet-0/+2
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-12-10Rollup merge of #105410 - TaKO8Ki:fix-105257, r=BoxyUwUMatthias Krüger-1/+1
Consider `parent_count` for const param defaults Fixes #105257
2022-12-10Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3Matthias Krüger-1/+3
Add LLVM KCFI support to the Rust compiler This PR adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.) Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM KCFI can be enabled with -Zsanitizer=kcfi. Thank you again, `@bjorn3,` `@eddyb,` `@nagisa,` and `@ojeda,` for all the help!
2022-12-09Tweak `rustc_must_implement_one_of` diagnostic outputEsteban Küber-11/+8
2022-12-08Add LLVM KCFI support to the Rust compilerRamon de C Valle-1/+3
This commit adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.) Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM KCFI can be enabled with -Zsanitizer=kcfi. Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-12-08Rollup merge of #105255 - cjgillot:issue-105197, r=compiler-errorsMatthias Krüger-15/+1
Make nested RPIT inherit the parent opaque's generics. Fixes https://github.com/rust-lang/rust/issues/105197 r? ```@compiler-errors```
2022-12-08add a test case for `generic_const_exprs` in trait itemsTakayuki Maeda-1/+1
2022-12-07Auto merge of #104799 - pcc:linkage-fn, r=tmiaskobors-2/+47
Support Option and similar enums as type of static variable with linkage attribute Compiler MCP: rust-lang/compiler-team#565
2022-12-07consider `parent_count` for const param defaultsTakayuki Maeda-1/+1
2022-12-06Rollup merge of #105254 - cjgillot:issue-105251, r=oli-obkMatthias Krüger-4/+38
Recurse into nested impl-trait when computing variance. Fixes https://github.com/rust-lang/rust/issues/105251
2022-12-06Rollup merge of #105005 - estebank:where-clause-lts, r=compiler-errorsMatthias Krüger-11/+44
On E0195 point at where clause lifetime bounds Fix #104733
2022-12-05On E0195 point at where clause lifetime boundsEsteban Küber-11/+44
Fix #104733
2022-12-05Support Option and similar enums as type of static variable with linkage ↵Peter Collingbourne-2/+21
attribute. Compiler MCP: https://github.com/rust-lang/compiler-team/issues/565
2022-12-05Move linkage type check to HIR analysis and fix semantics issues.Peter Collingbourne-1/+27
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-12-05normalize inherent associated types after substitutionLeón Orell Valerian Liehr-0/+1
2022-12-05Auto merge of #104920 - compiler-errors:avoid-infcx-build, r=jackh726bors-4/+1
Avoid some `InferCtxt::build` calls Either because we're inside of an `InferCtxt` already, or because we're not in a place where we'd ever see inference vars. r? types
2022-12-04Avoid InferCtxt::build in generic_arg_mismatch_errMichael Goulet-4/+1
2022-12-04Auto merge of #105261 - matthiaskrgr:rollup-9ghhc9c, r=matthiaskrgrbors-21/+25
Rollup of 6 pull requests Successful merges: - #101975 (Suggest to use . instead of :: when accessing a method of an object) - #105141 (Fix ICE on invalid variable declarations in macro calls) - #105224 (Properly substitute inherent associated types.) - #105236 (Add regression test for #47814) - #105247 (Use parent function WfCheckingContext to check RPITIT.) - #105253 (Update a couple of rustbuild deps) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-04Rollup merge of #105247 - cjgillot:issue-102682, r=compiler-errorsMatthias Krüger-17/+16
Use parent function WfCheckingContext to check RPITIT. WF-check for RPITIT was done in the opaque type's param-env, so it could not benefit from assumed wf types from the function's parameters. cc `@compiler-errors` since you chose that param-env in fd2766e7fde4 Fixes https://github.com/rust-lang/rust/issues/102682 Fixes https://github.com/rust-lang/rust/issues/104908 Fixes https://github.com/rust-lang/rust/issues/102552 Fixes https://github.com/rust-lang/rust/issues/104529
2022-12-04Rollup merge of #105224 - cjgillot:issue-104240, r=compiler-errorsMatthias Krüger-4/+9
Properly substitute inherent associated types. Fixes https://github.com/rust-lang/rust/issues/104240
2022-12-04Make nested RPITIT inherit the parent opaque's generics.Camille GILLOT-15/+1
2022-12-04Auto merge of #103293 - est31:untwist_and_drop_order, r=nagisabors-9/+38
Remove drop order twist of && and || and make them associative Previously a short circuiting binop chain (chain of && or ||s) would drop the temporaries created by the first element after all the other elements, and otherwise follow evaluation order. So `f(1).g() && f(2).g() && f(3).g() && f(4).g()` would drop the temporaries in the order `2,3,4,1`. This made `&&` and `||` non-associative regarding drop order. In other words, adding ()'s to the expression would change drop order: `f(1).g() && (f(2).g() && f(3).g()) && f(4).g()` for example would drop in the order `3,2,4,1`. As, except for the bool result, there is no data returned by the sub-expressions of the short circuiting binops, we can safely discard of any temporaries created by the sub-expr. Previously, code was already putting the rhs's into terminating scopes, but missed it for the lhs's. This commit addresses this "twist". We now also put the lhs into a terminating scope. The drop order of the above expressions becomes `1,2,3,4`. There might be code relying on the current order, and therefore I'd recommend doing a crater run to gauge the impact. I'd argue that such code is already quite wonky as it is one `foo() &&` addition away from breaking. ~~For the impact, I don't expect any *build* failures, as the compiler gets strictly more tolerant: shortening the lifetime of temporaries only expands the list of programs the compiler accepts as valid. There might be *runtime* failures caused by this change however.~~ Edit: both build and runtime failures are possible, e.g. see the example provided by dtolnay [below](https://github.com/rust-lang/rust/pull/103293#issuecomment-1285341113). Edit2: the crater run has finished and [results](https://github.com/rust-lang/rust/pull/103293#issuecomment-1292275203) are that there is only one build failure which is easy to fix with a +/- 1 line diff. I've included a testcase that now compiles thanks to this patch. The breakage is also limited to drop order relative to conditionals in the && chain: that is, in code like this: ```Rust let hello = foo().hi() && bar().world(); println!("hi"); ``` we already drop the temporaries of `foo().hi()` before we reach "hi". I'd ideally have this PR merged before let chains are stabilized. If this PR is taking too long, I'd love to have a more restricted version of this change limited to `&&`'s in let chains: the `&&`'s of such chains are quite special anyways as they accept `let` bindings, in there the `&&` is therefore more a part of the "if let chain" construct than a construct of its own. Fixes #103107 Status: waiting on [this accepted FCP](https://github.com/rust-lang/rust/pull/103293#issuecomment-1293411354) finishing.
2022-12-04Recurse into nested impl-trait when computing variance.Camille GILLOT-4/+38
2022-12-04Use parent function WfCheckingContext to check RPITIT.Camille GILLOT-17/+16
2022-12-04Also avoid creating a terminating scope in mixed chainsest31-13/+13
This avoids creation of a terminating scope in chains that contain both && and ||, because also there we know that a terminating scope is not neccessary: all the chain members are already in such terminating scopes. Also add a mixed && / || test.
2022-12-04Improve commentsest31-6/+18
2022-12-03Remove drop order twist of && and || and make them associativeest31-4/+21
Previously a short circuiting && chain would drop the first element after all the other elements, and otherwise follow evaluation order, so code like: f(1).g() && f(2).g() && f(3).g() && f(4).g() would drop the temporaries in the order 2,3,4,1. This made && and || non-associative regarding drop order, so adding ()'s to the expression would change drop order: f(1).g() && (f(2).g() && f(3).g()) && f(4).g() for example would drop in the order 3,2,4,1. As, except for the bool result, there is no data returned by the sub-expressions of the short circuiting binops, we can safely discard of any temporaries created by the sub-expr. Previously, code was already putting the rhs's into terminating scopes, but missed it for the lhs's. This commit addresses this "twist". In the expression, we now also put the lhs into a terminating scope. The drop order for the above expressions is 1,2,3,4 now.
2022-12-03Properly substitute inherent associated types.Camille GILLOT-4/+9
2022-12-03Rollup merge of #105200 - cjgillot:issue-104562, r=compiler-errorsMatthias Krüger-19/+0
Remove useless filter in unused extern crate check. Fixes https://github.com/rust-lang/rust/issues/104562
2022-12-03Rollup merge of #105193 - tmiasko:naked-nocoverage, r=wesleywiserMatthias Krüger-0/+5
Disable coverage instrumentation for naked functions Fixes #105170.
2022-12-03Remove useless filter in unused extern crate check.Camille GILLOT-19/+0
2022-12-03Mark naked functions as never inline in codegen_fn_attrsTomasz Miąsko-0/+1
Use code generation attributes to ensure that naked functions are never inline, replacing separate checks in MIR inliner and LLVM code generation.
2022-12-03Disable coverage instrumentation for naked functionsTomasz Miąsko-0/+4
2022-12-02Rollup merge of #105163 - compiler-errors:afit-lt-arity, r=jackh726Matthias Krüger-21/+18
Check lifetime param count in `collect_trait_impl_trait_tys` We checked the type and const generics count, but not the lifetimes, which were handled in a different function. Fixes #105154
2022-12-02Check lifetime param count in collect_trait_impl_trait_tysMichael Goulet-21/+18
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-1/+1
2022-11-30Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorinobors-12/+17
Some initial normalization method changes 1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`) 2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`) 3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize` 4. Remove some unused other normalization fns in `Inherited` and `FnCtxt` Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic. Stacked on top of #104835 for convenience. r? types
2022-11-29Make inferred_outlives_crate return ClauseSantiago Pastorino-23/+15
2022-11-28Make ObligationCtxt::normalize take cause by borrowMichael Goulet-12/+12
2022-11-28Simplify more FnCtxt normalizationMichael Goulet-1/+1
2022-11-28FnCtxt normalization stuffMichael Goulet-0/+5
2022-11-28Rename `NestedMetaItem::[Ll]iteral` as `NestedMetaItem::[Ll]it`.Nicholas Nethercote-1/+1
We already use a mix of `Literal` and `Lit`. The latter is better because it is shorter without causing any ambiguity.