summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2023-01-21Encode whether foreign opaques are TAITs or notMichael Goulet-1/+12
2023-01-19Correct detection of elided lifetimes in impl-trait.Camille GILLOT-2/+4
2023-01-19Revert "Make nested RPITIT inherit the parent opaque's generics." and adjust ↵Michael Goulet-1/+15
test This reverts commit e2d41f4c974f0cc09e5aafb02883f222487610f9.
2022-12-26Make fast-path for implied wf lint betterMichael Goulet-71/+92
2022-12-26Add IMPLIED_BOUNDS_ENTAILMENT lintMichael Goulet-5/+70
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-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-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.
2022-11-28Rename `ast::Lit` as `ast::MetaItemLit`.Nicholas Nethercote-2/+4
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-12/+13
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-74/+108
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-12/+13
2022-11-26Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errorsGuillaume Gomez-2/+2
Use the power of adding helper function to simplify code w/ `Mutability` r? `@compiler-errors`
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-82/+122
2022-11-25Simplify a bunch of trait ref obligation creationsOli Scherer-1/+1
2022-11-24Use kw::Empty for elided lifetimes in path.Camille GILLOT-6/+8
2022-11-24Change how suggested lifetime args are computed.Camille GILLOT-20/+48
2022-11-24move things from rustc_target::abi to rustc_abihkalbasi-2/+1