about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-09-18ty::layout: intern `FnAbi`s as `&'tcx`.Eduard-Mihai Burtescu-23/+29
2021-09-18ty::context: move interning `Allocation`s and `Layout`s to `direct_interners!`.Eduard-Mihai Burtescu-55/+26
2021-09-18ty::layout: propagate errors up to (but not out of) `FnAbi::of_*`.Eduard-Mihai Burtescu-27/+129
2021-09-18rustc_target: `adjust_for_cabi` -> `adjust_for_foreign_abi`.Eduard-Mihai Burtescu-2/+2
2021-09-18ty::layout: split out a private trait from `FnAbiExt`.Eduard-Mihai Burtescu-10/+21
2021-09-18ty::layout: move `trait FnAbiExt` to just before its `impl`.Eduard-Mihai Burtescu-28/+28
2021-09-17Rollup merge of #89012 - vishadGoyal:issue-88802-fix, r=jyn514Guillaume Gomez-0/+16
Suggest removing `#![feature]` for library features that have been stabilized Issue: https://github.com/rust-lang/rust/issues/88802 Delayed the check if #![feature] has been used to enable lib features in a non-nightly build to occur after TyCtxt has been constructed.
2021-09-17Rollup merge of #88954 - nbdd0121:panic3, r=oli-obkGuillaume Gomez-2/+23
Allow `panic!("{}", computed_str)` in const fn. Special-case `panic!("{}", arg)` and translate it to `panic_display(&arg)`. `panic_display` will behave like `panic_any` in cosnt eval and behave like `panic!(format_args!("{}", arg))` in runtime. This should bring Rust 2015 and 2021 to feature parity in terms of `const_panic`; and hopefully would unblock the stabilisation of #51999. `@rustbot` modify labels: +T-compiler +T-libs +A-const-eval +A-const-fn r? `@oli-obk`
2021-09-17Rollup merge of #88949 - FabianWolff:issue-87563, r=estebankGuillaume Gomez-9/+5
Fix handling of `hir::GenericArg::Infer` in `wrong_number_of_generic_args.rs` Fixes #87563. More precisely, I have fixed the "index out of bounds" error, which is what #87563 is about. The example given there still ICEs due to running into this `todo!()`, but I'd say that this is a separate issue: https://github.com/rust-lang/rust/blob/c3c0f80d6081092faff801542dd82f0e2420152b/compiler/rustc_typeck/src/astconv/mod.rs#L460-L463
2021-09-17Rollup merge of #88899 - FabianWolff:issue-88844, r=matthewjasperGuillaume Gomez-16/+26
Do not issue E0071 if a type error has already been reported Fixes #88844. A suggested fix is already included in the error message for E0412, so with my changes, E0071 is simply not emitted anymore if the type in question is a "type error". This makes sense, I think, because we cannot confidently state that something is "not a struct" if we couldn't resolve it properly; and it's unnecessary to pollute the output with this additional error message, as it is a direct consequence of the former error. I have also addressed the issue mentioned in https://github.com/rust-lang/rust/issues/88844#issuecomment-917324856 by changing the fixed example in the documentation to more closely match the erroneous code example.
2021-09-17Rollup merge of #87566 - JohnTitor:find-eqeq-on-assoc-type-bounds, r=estebankGuillaume Gomez-1/+13
Recover invalid assoc type bounds using `==` Fix #87493 r? `@estebank`
2021-09-17Rollup merge of #87460 - FabianWolff:issue-87456, r=Aaron1011Guillaume Gomez-4/+8
Point to closure when emitting 'cannot move out' for captured variable Attempts to fix #87456. The error message now points to the capturing closure, but I was not able to explain _why_ the closure implements `Fn` or `FnMut` (`TypeckResults::closure_kind_origins` did not contain anything for the closure in question). cc `@Aaron1011`
2021-09-17Rollup merge of #86422 - JohnTitor:clearer-parens-err-for-loop, r=estebankGuillaume Gomez-19/+14
Emit clearer diagnostics for parens around `for` loop heads Fixes #63113 r? `@estebank`
2021-09-17Auto merge of #88945 - Aaron1011:no-projection-completion, ↵bors-51/+2
r=wesleywiser,jackh726 Remove concept of 'completion' from the projection cache Fixes #88910 When we initially store a `NormalizedTy` in the projection cache, we discard all obligations that we can (while ensuring that we don't cause any issues with incremental compilation). Marking a projection cache entry as 'completed' discards all obligations associated with it. This can only cause problems, since any obligations stored in the cache are there for a reason (e.g. they evaluate to `EvaluatedToOkModuloRegions`). This commit removes `complete` and `complete_normalized` entirely.
2021-09-17Auto merge of #89037 - JohnTitor:rollup-rd9btbs, r=JohnTitorbors-67/+110
Rollup of 10 pull requests Successful merges: - #86382 (Make diagnostics clearer for `?` operators) - #87529 (Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types) - #88339 (Add TcpListener::into_incoming and IntoIncoming) - #88735 (Don't lint about missing code examples in derived traits) - #88751 (Couple of changes to FileSearch and SearchPath) - #88883 (Move some tests to more reasonable directories - 7) - #88887 (Const Deref) - #88911 (Improve error message for type mismatch in generator arguments) - #89014 (PassWrapper: handle separate Module*SanitizerPass) - #89033 (Set the library path in sysroot-crates-are-unstable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-17Apply review commentsYuki Okushi-2/+2
2021-09-17Rollup merge of #89014 - durin42:llvm-14-module-pass-manager, r=nikicYuki Okushi-0/+8
PassWrapper: handle separate Module*SanitizerPass Change ab41eef9aca3 in LLVM split MemorySanitizerPass into MemorySanitizerPass for functions and ModuleMemorySanitizerPass for modules. There's a related change for ThreadSanitizerPass, and in here since we're using a ModulePassManager I only add the module flavor of the pass on LLVM 14. r? `@nikic` cc `@nagisa`
2021-09-17Rollup merge of #88911 - FabianWolff:issue-88653, r=petrochenkovYuki Okushi-14/+24
Improve error message for type mismatch in generator arguments Fixes #88653. The code example given there is invalid because the `Generator` trait (unlike the `Fn` traits) does not take the generator arguments in tupled-up form (because there can only be one argument, from my understanding). Hence, the type error in the example in #88653 is correct, because the given generator takes a `bool` argument, whereas the function's return type talks about a generator with a `(bool,)` argument. The error message is both confusing and wrong, though: It is wrong because it displays the wrong "expected signature", and it is confusing because both the "expected" and "found" notes point at the same span. With my changes, I get the following, more helpful output: ``` error[E0631]: type mismatch in generator arguments --> test.rs:5:22 | 5 | fn foo(bar: bool) -> impl Generator<(bool,)> { | ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _` 6 | |bar| { | ----- found signature of `fn(bool) -> _` ```
2021-09-17Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obkYuki Okushi-48/+42
Couple of changes to FileSearch and SearchPath * Turn a couple of regular comments into doc comments * Move `get_tools_search_paths` from `FileSearch` to `Session` * Use Lrc instead of Option to avoid duplication of a `SearchPath`
2021-09-17Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakisYuki Okushi-2/+8
Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types Fixes #87496. There is also another function in the same file that looks fishy, but I haven't been able to produce an ICE there, and in any case, it's not related to #87496: https://github.com/rust-lang/rust/blob/fd853c00e255559255885aadff9e93a1760c8728/compiler/rustc_lint/src/types.rs#L720-L734 r? ```@JohnTitor```
2021-09-17Recover invalid assoc type bounds using `==`Yuki Okushi-1/+13
2021-09-17Use `multipart_suggestion`Yuki Okushi-20/+14
2021-09-17Emit clearer diagnostics for parens around `for` loop headsYuki Okushi-2/+3
2021-09-17Make diagnostics clearer for `?` operatorsYuki Okushi-3/+28
2021-09-17Auto merge of #88934 - tmiasko:trace-log, r=davidtwcobors-4/+5
Avoid unnecessary formatting when trace log level is disabled
2021-09-17Auto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obkbors-3/+18
Introduce a fast path that avoids the `debug_tuple` abstraction when deriving Debug for unit-like enum variants. The intent here is to allow LLVM to remove the switch entirely in favor of an indexed load from a table of constant strings, which is likely what the programmer would write in C. Unfortunately, LLVM currently doesn't perform this optimization due to a bug, but there is [a patch](https://reviews.llvm.org/D109565) that fixes this issue. I've verified that, with that patch applied on top of this commit, Debug for unit-like tuple variants becomes a load, reducing the O(n) code bloat to O(1). Note that inlining `DebugTuple::finish()` wasn't enough to allow LLVM to optimize the code properly; I had to avoid the abstraction entirely. Not using the abstraction is likely better for compile time anyway. Part of #88793. r? `@oli-obk`
2021-09-16Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisabors-65/+194
Point at argument instead of call for their obligations When an obligation is introduced by a specific `fn` argument, point at the argument instead of the `fn` call if the obligation fails to be fulfilled. Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`. When giving an error about an obligation introduced by a function call that an argument doesn't fulfill, and that argument is a block, add a span_label pointing at the innermost tail expression. Current output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:31 | 2 | let p = Some(45).and_then({ | ______________________--------_^ | | | | | required by a bound introduced by this call 3 | | |x| println!("doubling {}", x); 4 | | Some(x * 2) | | ----------- 5 | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Previous output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:22 | 2 | let p = Some(45).and_then({ | ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Partially address #27300. Will require rebasing on top of #88546.
2021-09-16Auto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearthbors-34/+115
Rollup of 10 pull requests Successful merges: - #88292 (Enable --generate-link-to-definition for rustc's docs) - #88729 (Recover from `Foo(a: 1, b: 2)`) - #88875 (cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented) - #88892 (Move object safety suggestions to the end of the error) - #88928 (Document the closure arguments for `reduce`.) - #88976 (Clean up and add doc comments for CStr) - #88983 (Allow calling `get_body_with_borrowck_facts` without `-Z polonius`) - #88985 (Update clobber_abi list to include k[1-7] regs) - #88986 (Update the backtrace crate) - #89009 (Fix typo in `break` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-16PassWrapper: these two lines shouldn't have been ifdef'dAugie Fackler-2/+2
2021-09-16delay error for enabling unstable lib featuresVishad Goyal-0/+16
If #![feature] is used outside the nightly channel for only lib features, the check will be delayed to the stability pass after parsing. This is done so that appropriate help messages can be shown if the #![feature] has been used needlessly
2021-09-16Rollup merge of #88983 - willcrichton:allow-single-polonius-call, ↵Manish Goregaokar-13/+13
r=ecstatic-morse Allow calling `get_body_with_borrowck_facts` without `-Z polonius` For my [static analysis tool](https://github.com/willcrichton/flowistry), I need to access the set of outlives-constraints. Recently, #86977 merged a way to access these facts via Polonius. However, the merged implementation requires `-Z polonius` to be provided to use this feature. This uses Polonius for borrow checking on the entire crate, which as described [here](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Polonius.20performance.20in.20a.20rustc.20plugin/near/251301631), is very slow. This PR allows `get_body_with_borrowck_facts` to be called without `-Z polonius`. This is essential for my tool to run in a sensible length of time. This is a temporary patch as the Polonius-related APIs develop -- I can update my code as future changes happen. Additionally, this PR also makes public two APIs that were previously public but then became private after `rustc_mir` got broken up: `rustc_mir_dataflow::framework::graphviz` and `rustc_mir_transform::MirPass`. I need both of these for my analysis tool. (I can break this change into a separate PR if necessary.)
2021-09-16Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, ↵Manish Goregaokar-1/+1
r=Mark-Simulacrum Clean up and add doc comments for CStr CC #51430
2021-09-16Rollup merge of #88892 - estebank:trait-objects, r=petrochenkovManish Goregaokar-6/+10
Move object safety suggestions to the end of the error
2021-09-16Rollup merge of #88875 - notriddle:notriddle/cleanup-unused-trait-selection, ↵Manish Goregaokar-4/+0
r=Mark-Simulacrum cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented This isn't allowed by the validator, and seems to be unused. When it was added in ed10a3faae1fd1176b2edf4a61438e0542c103b9, it was used on `Sized`, and that usage is gone.
2021-09-16Rollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obkManish Goregaokar-10/+91
Recover from `Foo(a: 1, b: 2)` Detect likely `struct` literal using parentheses as delimiters and emit targeted suggestion instead of type ascription parse error. Fix #61326.
2021-09-16Auto merge of #88979 - tmiasko:no-remove-zsts-in-generators, r=oli-obkbors-0/+4
Disable RemoveZsts in generators to avoid query cycles Querying layout of a generator requires its optimized MIR. Thus computing layout during MIR optimization of a generator might create a query cycle. Disable RemoveZsts in generators to avoid the issue (similar approach is used in ConstProp transform already). Fixes #88972.
2021-09-16PassWrapper: handle separate Module*SanitizerPassAugie Fackler-0/+8
Change ab41eef9aca3 in LLVM split MemorySanitizerPass into MemorySanitizerPass for functions and ModuleMemorySanitizerPass for modules. There's a related change for ThreadSanitizerPass, and in here since we're using a ModulePassManager I only add the module flavor of the pass on LLVM 14. r? @nikic cc @nagisa
2021-09-16Point at argument when evaluating `Path`'s boundsEsteban Kuber-6/+33
When evaluating an `ExprKind::Call`, we first have to `check_expr` on it's callee. When this one is a `ExprKind::Path`, we had to evaluate the bounds introduced for its arguments, but by the time we evaluated them we no longer had access to the argument spans. Now we special case this so that we can point at the right place on unsatisfied bounds. This also allows the E0277 deduplication to kick in correctly, so we now emit fewer errors.
2021-09-16Fix rebaseEsteban Kuber-12/+12
2021-09-16Remove unnecessary labelEsteban Kuber-9/+14
2021-09-16fix `clone` callEsteban Kuber-2/+2
2021-09-16Account for blocks in argumentsEsteban Kuber-2/+22
When giving an error about an obligation introduced by a function call that an argument doesn't fulfill, and that argument is a block, add a span_label pointing at the innermost tail expression.
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-1/+11
2021-09-16Refactor `FulfillmentError` to track less dataEsteban Kuber-54/+83
Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`.
2021-09-16Point at argument instead of call for their obligationsEsteban Kuber-3/+41
When an obligation is introduced by a specific `fn` argument, point at the argument instead of the `fn` call if the obligation fails to be fulfilled.
2021-09-16Auto merge of #86809 - DevinR528:reachable-pat, r=Nadrierilbors-63/+286
Add non_exhaustive_omitted_patterns lint related to rfc-2008-non_exhaustive Fixes: #84332 This PR adds `non_exhaustive_omitted_patterns`, an allow by default lint that is triggered when a `non_exhaustive` type is missing explicit patterns. The warning or deny attribute can be put above the wildcard `_` pattern on enums or on the expression for enums or structs. The lint is capable of warning about multiple types within the same pattern. This lint will not be triggered for `if let ..` patterns. ```rust // crate A #[non_exhaustive] pub struct Foo { a: u8, b: usize, } #[non_exhaustive] pub enum Bar { A(Foo), B, } // crate B #[deny(non_exhaustive_omitted_patterns)] // here match Bar::B { Bar::B => {} #[deny(non_exhaustive_omitted_patterns)] // or here _ => {} } #[warn(non_exhaustive_omitted_patterns)] // only here let Foo { a, .. } = Foo::default(); #[deny(non_exhaustive_omitted_patterns)] match Bar::B { // triggers for Bar::B, and Foo.b Bar::A(Foo { a, .. }) => {} // if the attribute was here only Bar::B would cause a warning _ => {} } ```
2021-09-15Rollup merge of #88933 - tmiasko:remove-min-align-of, r=oli-obkManish Goregaokar-7/+2
Remove implementation of `min_align_of` intrinsic Since #88839 `min_align_of` is lowered to AlignOf operator.
2021-09-15Rollup merge of #88907 - ↵Manish Goregaokar-2/+11
WaffleLapkin:targeted_const_fn_with_a_bound_in_impl_block_error, r=estebank Highlight the `const fn` if error happened because of a bound on the impl block Currently, for the following code, the compiler produces the errors like the following: ```rust struct Type<T>(T); impl<T: Clone> Type<T> { const fn f() {} } ``` ```text error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable --> ./test.rs:3:6 | 3 | impl<T: Clone> Type<T> { | ^ | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable ``` This can be confusing (especially to newcomers) since the error mentions "const fn parameters", but highlights only the impl. This PR adds function highlighting, changing the error to the following: ```text error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable --> ./test.rs:3:6 | 3 | impl<T: Clone> Type<T> { | ^ 4 | pub const fn f() {} | ---------------- function declared as const here | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable ``` --- I've originally wanted to point directly to `const` token, but couldn't find a way to get it's span. It seems like this span is lost during the AST -> HIR lowering. Also, since the errors for object casts in `const fn`s (`&T` -> `&dyn Trait`) seem to trigger the same error, this PR accidentally changes these errors too. Not sure if it's desired or how to fix this. P.S. it's my first time contributing to diagnostics, so feedback is very appreciated! --- r? ```@estebank``` ```@rustbot``` label: +A-diagnostics
2021-09-15Rollup merge of #88841 - notriddle:notriddle/method-parens, r=estebankManish Goregaokar-1/+22
feat(rustc_typeck): suggest removing bad parens in `(recv.method)()` Fixes #88803
2021-09-15Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwcoManish Goregaokar-141/+23
Revert anon union parsing Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code. Fix #88583.