about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/check
AgeCommit message (Collapse)AuthorLines
2022-10-12Auto merge of #101679 - compiler-errors:rpitit-default-body, r=nikomatsakisbors-23/+33
Support default-body trait functions with return-position `impl Trait` in traits Introduce a new `Trait` candidate kind for the `ImplTraitInTrait` projection candidate, which just projects an RPITIT down to its opaque type form. This is a hack until we lower RPITITs to regular associated types, after which we will need to rework how these default bodies are type-checked, so comments are left in a few places for us to clean up later. Fixes #101665
2022-10-12Rollup merge of #102890 - camsteffen:adt-sized-representability, r=cjgillotDylan DPC-3/+2
Check representability in adt_sized_constraint Now that representability is a query, we can use it to preemptively avoid a cycle in `adt_sized_constraint`. I moved the representability check into `check_mod_type_wf` to avoid a scenario where rustc quits before checking all the types for representability. This also removes the check from rustdoc, which is alright AFAIK. r? ``@cjgillot``
2022-10-10Check representability in adt_sized_constraintCameron Steffen-3/+2
2022-10-10Fix compiler docsGuillaume Gomez-1/+3
2022-10-10Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8KiYuki Okushi-2/+2
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type` The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-09ImplItemKind::TyAlias => ImplItemKind::TypeMichael Goulet-2/+2
2022-10-08Auto merge of #102809 - matthiaskrgr:rollup-qq62vuv, r=matthiaskrgrbors-5/+15
Rollup of 8 pull requests Successful merges: - #101520 (Allow transmutes between the same types after erasing lifetimes) - #102675 (Remove `mir::CastKind::Misc`) - #102778 (Fix MIR inlining of asm_unwind) - #102785 (Remove `DefId` from some `SelectionCandidate` variants) - #102788 (Update rustc-dev-guide) - #102789 (Update browser UI test version) - #102797 (rustdoc: remove no-op CSS `.rightside { position: initial }`) - #102798 (rustdoc: add main-heading and example-wrap link CSS to big selector) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-08Rollup merge of #101520 - oli-obk:transmute_lifetimes, r=compiler-errorsMatthias Krüger-5/+15
Allow transmutes between the same types after erasing lifetimes r? ````@compiler-errors```` on the impl fixes #101081 See discussion in the issue and at https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/.23101081.3A.20Regression.20transmuting.20.60RwLockReadGuard.3CT.3A.20.3FSized.3E.E2.80.A6 I think this may need lang team signoff as its implications may go beyond the jurisdiction of T-types I'll write up a proper summary later
2022-10-08Auto merge of #100720 - camsteffen:representable, r=cjgillotbors-26/+3
Rewrite representability * Improve placement of `Box` in the suggestion * Multiple items in a cycle emit 1 error instead of an error for each item in the cycle * Introduce `representability` query to avoid traversing an item every time it is used. * Also introduce `params_in_repr` query to avoid traversing generic items every time it is used.
2022-10-07Check hidden types in dead codeOli Scherer-7/+5
2022-10-07Remap hidden types from typeck before storing them in the TypeckResultOli Scherer-1/+10
2022-10-07Unconditionally encode hidden types in typeck resultsOli Scherer-24/+20
2022-10-07Allow transmutes between the same types after erasing lifetimesOli Scherer-5/+15
2022-10-07Rewrite representabilityCameron Steffen-26/+3
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-666/+645
2022-10-07Remove a reference from InheritedCameron Steffen-13/+13
2022-10-07Remove TypeckResults from InferCtxtCameron Steffen-12/+16
2022-10-07Introduce TypeErrCtxtCameron Steffen-48/+79
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't need to.
2022-10-07Rollup merge of #102720 - lyming2007:issue-102397-fix, r=compiler-errorsMatthias Krüger-1/+1
do not reverse the expected type and found type for ObligationCauseCo… …de of IfExpressionWithNoElse this will fix #102397
2022-10-07suggest `==` to the first expr which has `ExprKind::Assign`Takayuki Maeda-0/+12
2022-10-06Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnrMatthias Krüger-37/+36
make `compare_const_impl` a query and use it in `instance.rs` Fixes #88365 the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons: - the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable) - it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71)) r? `@lcnr`
2022-10-06reviewsBoxy-41/+41
2022-10-06Rollup merge of #102708 - TaKO8Ki:improve-eqeq-suggestion, r=estebankMatthias Krüger-2/+10
Suggest `==` to wrong assign expr Given the following code: ```rust fn main() { let x = 3; let y = 3; if x == x && y = y { println!("{}", x); } } ``` Current output is: ``` error[E0308]: mismatched types --> src/main.rs:4:18 | 4 | if x == x && y = y { | ^ expected `bool`, found integer error[E0308]: mismatched types --> src/main.rs:4:8 | 4 | if x == x && y = y { | ^^^^^^^^^^^^^^^ expected `bool`, found `()` ``` This adds a suggestion: ```diff error[E0308]: mismatched types --> src/main.rs:6:18 | 6 | if x == x && y = y { | ^ expected `bool`, found integer error[E0308]: mismatched types --> src/main.rs:6:8 | 6 | if x == x && y = y { | ^^^^^^^^^^^^^^^ expected `bool`, found `()` | + help: you might have meant to compare for equality + | + 6 | if x == x && y == y { + | + ``` And this fixes a part of #97469
2022-10-06Rollup merge of #102694 - compiler-errors:fn-to-method, r=davidtwcoMatthias Krüger-6/+136
Suggest calling method if fn does not exist I tried to split this up into two commits, the first where we stash the resolution error until typeck (which causes a bunch of diagnostics changes because the ordering of error messages change), then the second commit is the actual logic that actually implements the suggestion. I am not in love with the presentation of the suggestion, so I could use some advice for how to format the actual messaging. r? diagnostics Fixes #102518
2022-10-05do not reverse the expected type and found type for ObligationCauseCode of ↵Yiming Lei-1/+1
IfExpressionWithNoElse this will fix #102397
2022-10-05Update compiler/rustc_hir_analysis/src/check/callee.rsMichael Goulet-1/+1
Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2022-10-05suggest `==` to the rest of assign exprTakayuki Maeda-0/+8
2022-10-05use smaller spanTakayuki Maeda-2/+2
2022-10-05Rollup merge of #102496 - compiler-errors:into-suggestion, r=davidtwcoDylan DPC-36/+119
Suggest `.into()` when all other coercion suggestions fail Also removes some bogus suggestions because we now short-circuit when offering coercion suggestions(instead of, for example, suggesting every one that could possibly apply) Fixes #102415
2022-10-05Suggest calling method if fn does not existMichael Goulet-6/+120
2022-10-05Delay function resolution error until typeckMichael Goulet-1/+17
2022-10-05Validate opaques in default trait bodies, don't normalize unless a body is ↵Michael Goulet-23/+33
provided
2022-10-04Rollup merge of #102650 - ↵Michael Howell-1/+1
Rageking8:slightly-improve-no-return-for-returning-function-error, r=compiler-errors Slightly improve no return for returning function error Fixes #100607 The rationale is that absolute beginners will be slightly confused as to why certain lines of code in a function does not require a semicolon. (I have actually witness a beginner having this confusion). Hence, a slight rationale is added "to return this value", which signals to the user that after removing said semicolon the value is returned resolving that error. However, if this is not desirable, I welcome any other suggestions. Thanks.
2022-10-05Suggest `.into()` when all other coercion suggestions failMichael Goulet-36/+119
2022-10-04It's not about types or consts, but the lack of regionsOli Scherer-9/+7
2022-10-04find the correct lang item for rangesyukang-32/+44
2022-10-04slightly improve no return for returning function errorRageking8-1/+1
2022-10-04fix #102396, suggest parentheses for possible range methodsyukang-5/+70
2022-10-04Rollup merge of #102441 - chenyukang:fix-102320-unwrap_or_else, ↵Matthias Krüger-2/+57
r=compiler-errors Suggest unwrap_or_else when a closure is given Fixes #102320 r? `@compiler-errors`
2022-10-03`HirId` for `deferred_transmute_checks`lcnr-12/+15
2022-10-02fix #102320, suggest unwrap_or_else when a closure is passed to unwrap_or ↵yukang-2/+57
instead of suggesting calling it
2022-10-01Rollup merge of #102500 - compiler-errors:parse-sess-cleanup, r=cjgillotMatthias Krüger-3/+6
Remove `expr_parentheses_needed` from `ParseSess` Not sure why this method needed to exist on `ParseSess`, but we can achieve the same behavior by just inlining it everywhere.
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-154/+159
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01Refactor rustc lint APIMaybe Waffle-154/+159
2022-09-30make query take `(LocalDefId, DefId)`Boxy-22/+22
2022-09-30make `compare_const_impl` a query and use it in `instance.rs`Boxy-54/+53
2022-09-30Remove expr_parentheses_needed from ParseSessMichael Goulet-3/+6
2022-09-29Auto merge of #101887 - nnethercote:shrink-Res, r=spastorinobors-4/+8
Shrink `hir::def::Res` r? `@spastorino`
2022-09-29Split out the error reporting logic into a separate functionOli Scherer-134/+140
2022-09-29Shrink `hir::def::Res`.Nicholas Nethercote-4/+8
`Res::SelfTy` currently has two `Option`s. When the second one is `Some` the first one is never consulted. So we can split it into two variants, `Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res` from 24 bytes to 12. This then shrinks `hir::Path` and `hir::PathSegment`, which are the HIR types that take up the most space.