about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-12-14Auto merge of #105686 - matthiaskrgr:rollup-bedfk3j, r=matthiaskrgrbors-128/+209
Rollup of 7 pull requests Successful merges: - #103644 (Add docs for question mark operator for Option) - #105161 (Refine when invalid prefix case error arises) - #105491 (Illegal sized bounds: only suggest mutability change if needed) - #105502 (Suggest impl in the scenario of typo with fn) - #105523 (Suggest `collect`ing into `Vec<_>`) - #105595 (Suggest dereferencing receiver arguments properly) - #105611 (fold instead of obliterating args) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-14Rollup merge of #105611 - BoxyUwU:more_granular_placeholderification, ↵Matthias Krüger-15/+38
r=wesleywiser fold instead of obliterating args Fixes #105608 we call `const_eval_resolve` on the following constant: ``` def: playground::{impl#0}::and::{constant#0}, substs: [ ConstKind::Unevaluated { def: playground::{impl#0}::and::{constant#0}, substs: [ ConstKind::Value(0x0), _, ] } _, ], ``` when expanded out to `ConstKind::Expr` there are no infer vars so we attempt to evaluate it after replacing infer vars with garbage, however the current logic for replacing with garbage replaces _the whole arg containing the infer var_ rather than just the infer var. This means that after garbage replacement has occured we attempt to evaluate: ``` def: playground::{impl#0}::and::{constant#0}, substs: [ PLACEHOLDER, PLACEHOLDER, ], ``` Which then leads to ctfe being unable to evaluate the const. With this PR we attempt to evaluate: ``` def: playground::{impl#0}::and::{constant#0}, substs: [ ConstKind::Unevaluated { def: playground::{impl#0}::and::{constant#0}, substs: [ ConstKind::Value(0x0), PLACEHOLDER, ] } PLACEHOLDER, ], ``` which ctfe _can_ handle. I am not entirely sure why this function is supposed to replace params with placeholders rather than just inference vars :thinking:
2022-12-14Rollup merge of #105595 - TaKO8Ki:suggest-dereferencing-receiver-argument, ↵Matthias Krüger-6/+28
r=compiler-errors Suggest dereferencing receiver arguments properly Fixes #105429
2022-12-14Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errorsMatthias Krüger-94/+90
Suggest `collect`ing into `Vec<_>` Fix #105510.
2022-12-14Rollup merge of #105502 - chenyukang:yukang/fix-105366-impl, r=estebankMatthias Krüger-2/+29
Suggest impl in the scenario of typo with fn Fixes #105366
2022-12-14Rollup merge of #105491 - sulami:master, r=compiler-errorsMatthias Krüger-1/+1
Illegal sized bounds: only suggest mutability change if needed In a scenario like ```rust struct Type; pub trait Trait { fn function(&mut self) where Self: Sized; } impl Trait for Type { fn function(&mut self) {} } fn main() { (&mut Type as &mut dyn Trait).function(); } ``` the problem is Sized, not the mutability of self. Thus don't emit the "you need &T instead of &mut T" note, or the other way around, as all it does is just invert the mutability of whatever was supplied. Fixes #103622.
2022-12-14Rollup merge of #105161 - cassaundra:numeric-literal-error, r=nnethercoteMatthias Krüger-10/+23
Refine when invalid prefix case error arises Fix cases where the "invalid base prefix for number literal" error arises with suffixes that look erroneously capitalized but which are actually invalid.
2022-12-14Auto merge of #105221 - alex:fat-archive-cleanup, r=bjorn3bors-46/+38
Avoid a temporary file when processing macOS fat archives r? `@bjorn3`
2022-12-14Auto merge of #104875 - chenyukang:yukang/fix-104867-inc, r=estebankbors-43/+26
Properly handle postfix inc/dec in standalone and subexpr scenarios Fixes #104867 r? `@estebank`
2022-12-14Auto merge of #104986 - compiler-errors:opaques, r=oli-obkbors-617/+581
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` Implements https://github.com/rust-lang/types-team/issues/79. This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so: ``` enum AliasKind { Projection, Opaque, } struct AliasTy<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, } ``` Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example: ```diff match ty.kind() { - ty::Opaque(..) => + ty::Alias(ty::Opaque, ..) => {} _ => {} } ``` This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically. r? `@ghost`
2022-12-13Auto merge of #105667 - matthiaskrgr:rollup-fexlc0b, r=matthiaskrgrbors-1037/+1152
Rollup of 7 pull requests Successful merges: - #105147 (Allow unsafe through inline const) - #105438 (Move some codegen-y methods from `rustc_hir_analysis::collect` -> `rustc_codegen_ssa`) - #105464 (Support #[track_caller] on async closures) - #105476 (Change pattern borrowing suggestions to be verbose and remove invalid suggestion) - #105500 (Make some diagnostics not depend on the source of what they reference being available) - #105628 (Small doc fixes) - #105659 (Don't require owned data in `MaybeStorageLive`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-13rename argumentEsteban Küber-2/+6
2022-12-13review commentsEsteban Küber-29/+27
2022-12-13Rollup merge of #105659 - JakobDegen:storage-live-borrow, r=davidtwcoMatthias Krüger-9/+10
Don't require owned data in `MaybeStorageLive` Small improvement that avoids a clone. I don't expect this to have any noticeable perf effects, but better to have it than not to. r? ``@tmiasko``
2022-12-13Rollup merge of #105628 - spastorino:small-doc-fixes, r=compiler-errorsMatthias Krüger-10/+7
Small doc fixes r? `@compiler-errors`
2022-12-13Rollup merge of #105500 - oli-obk:unhide_unknown_spans, r=estebankMatthias Krüger-96/+106
Make some diagnostics not depend on the source of what they reference being available r? `@estebank` follow up to https://github.com/rust-lang/rust/pull/104449
2022-12-13Rollup merge of #105476 - estebank:moves-n-borrows, r=compiler-errorsMatthias Krüger-37/+65
Change pattern borrowing suggestions to be verbose and remove invalid suggestion Synthesize a more accurate span and use verbose suggestion output to make the message clearer. Do not suggest borrowing binding in pattern in let else. Fix #104838.
2022-12-13Rollup merge of #105464 - nbdd0121:hir, r=compiler-errorsMatthias Krüger-38/+49
Support #[track_caller] on async closures Follow up on #105180 r? ```@compiler-errors``` cc ```@cjgillot```
2022-12-13Rollup merge of #105438 - compiler-errors:move-methods, r=estebankMatthias Krüger-828/+857
Move some codegen-y methods from `rustc_hir_analysis::collect` -> `rustc_codegen_ssa` Unclear if they should live here, but they seem codegen-y enough, and `rustc_hir_analysis::collect` is extremely long, so it should probably lose some methods.
2022-12-13Rollup merge of #105147 - nbdd0121:inline_const_unsafe, r=oli-obkMatthias Krüger-19/+58
Allow unsafe through inline const Handle similar to closures. Address https://github.com/rust-lang/rust/pull/104087#issuecomment-1324173328 Note that this PR does not fix the issue for `unsafe { [0; function_requiring_unsafe()] }`. This is fundamentally unfixable for MIR unsafeck IMO. This PR also does not fix unsafety checking for inline const in pattern position. It actually breaks it, allowing unsafe functions to be used in inline const in pattern position without unsafe blocks. Inline const in pattern position is not visible in MIR so ignored by MIR unsafety checking (currently it is also not checked by borrow checker, which is the reason why it's considered an incomplete feature). `@rustbot` label: +T-lang +F-inline_const
2022-12-14suggest dereferencing receiver arguments properlyTakayuki Maeda-6/+28
fix a stderr
2022-12-13Auto merge of #102813 - ↵bors-0/+81
Akida31:issue-64915/simpler_diagnostic_when_passing_arg_to_closure_and_missing_borrow, r=estebank Simpler diagnostic when passing arg to closure and missing borrow fixes #64915 I followed roughly the instructions and the older PR #76362. The number of references for the expected and the found types will be compared and depending on which has more the diagnostic will be emitted. I'm not quite sure if my approach with the many `span_bug!`s is good, it could lead to some ICEs. Would it be better if those errors are ignored? As far as I know the following code works similarly but in a different context. Is this probably reusable since it looks like it would emit better diagnostics? https://github.com/rust-lang/rust/blob/a688a0305fad9219505a8f2576446510601bafe8/compiler/rustc_hir_analysis/src/check/demand.rs#L713-L1061 When running the tests locally, a codegen test failed. Is there something I can/ should do about that? If you have some improvements/ corrections please say so and I will happily include them. r? `@estebank` (as you added the mentoring instructions to the issue)
2022-12-13Suggest `: Type` instead of `: _`Esteban Küber-6/+10
2022-12-13Mention implementations that satisfy the traitEsteban Küber-2/+19
2022-12-13Remove unnecessary code and account for turbofish suggestionEsteban Küber-79/+35
Remove previously existing fallback that tried to give a good turbofish suggestion, `need_type_info` is already good enough. Special case `::<Vec<_>` suggestion for `Iterator::collect`.
2022-12-13Suggest `collect`ing into `Vec<_>`Esteban Küber-8/+25
2022-12-13Account for dereference expressionsEsteban Küber-7/+22
2022-12-13Fix span for `&mut ` removal suggestionEsteban Küber-0/+1
2022-12-13Suggest `ref` for some patterns as a fallbackEsteban Küber-10/+16
2022-12-13Do not suggest borrowing binding in pattern in let elseEsteban Küber-1/+1
Fix #104838.
2022-12-13Change pattern borrowing suggestions to be verboseEsteban Küber-29/+35
Synthesize a more accurate span and use verbose suggestion output to make the message clearer.
2022-12-13Address a few more nitsMichael Goulet-11/+12
2022-12-13Address nitsMichael Goulet-15/+5
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-12-13Remove chalk lowering for AliasTyMichael Goulet-11/+10
2022-12-13nit: docsMichael Goulet-3/+12
2022-12-13Combine OfOpaque and OfProjectionMichael Goulet-14/+6
2022-12-13Combine identical alias armsMichael Goulet-120/+69
2022-12-13Combine projection and opaque into aliasMichael Goulet-345/+357
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-183/+168
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-174/+152
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-110/+148
2022-12-13make Opaque have one field: OpaqueTyMichael Goulet-17/+28
2022-12-13tidy: ignore filelengthakida31-0/+1
2022-12-13reduce to single suggestion for all argumentsakida31-13/+24
2022-12-13remove manual `fn_decl` extractionakida31-17/+3
2022-12-13change error messageakida31-2/+2
2022-12-13move changes to an extra functionakida31-66/+76
2022-12-13Remove `hint` from help messageakida31-2/+2
2022-12-13Improve diagnostic when passing arg to closure and missing borrow.akida31-0/+73
This checks the number of references for the given and expected type and shows hints to the user if the numbers don't match.
2022-12-13Auto merge of #105612 - oli-obk:bind_rustdoc, r=GuillaumeGomezbors-1/+12
use ty::Binder in rustdoc instead of `skip_binder` r? `@GuillaumeGomez` this is a preliminary cleanup required to be able to normalize correctly/conveniently in rustdoc