about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2021-09-20Add a doc comment to infer_projectionOli Scherer-0/+6
2021-09-20Use `ty::Error` for opaque types with errors in its bounds.Oli Scherer-38/+10
This reduces unhelpful diagnostics down the road.
2021-09-20Generate inference vars and obligations for projections in opaque types ↵Oli Scherer-22/+36
instead of trying to normalize them.
2021-09-20Inline a function that is only called onceOli Scherer-10/+4
2021-09-20Use tracing debugging in `fold_opaque_ty`Oli Scherer-14/+6
2021-09-20Add helper function to `InferCtxt` that generates inference vars for ↵Oli Scherer-11/+35
unresolved associated types
2021-09-20Update odht crate to 0.3.0Michael Woerister-4/+4
This version of odht contains a potential fix for #89085.
2021-09-20:arrow_up: rust-analyzerLaurențiu Nicola-32/+16
2021-09-20Enable 2021 compatibility lints for all in-tree codeMark Rousskov-1/+4
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
2021-09-20Enable 2021 compatibility lints for all in-tree codeMark Rousskov-34/+52
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
2021-09-20Adjust to SourceType::InTree in several placesMark Rousskov-5/+3
These were left over in migrations to subtrees, which should generally be treated as-if it was local. Also fixes a warning caused by this change.
2021-09-20Workaround ICE with if-let and RFC 2229Mark Rousskov-9/+8
2021-09-20Mark unsafe NonZero*::unchecked_(add|mul) as constIago-lito-2/+2
2021-09-20no ensureEllen-3/+6
2021-09-20Expand BOX_VEC to BOX_COLLECTIONF3real-48/+97
2021-09-20Auto merge of #88321 - glaubitz:m68k-linux, r=wesleywiserbors-2/+196
Add initial support for m68k This patch series adds initial support for m68k making use of the new M68k backend introduced with LLVM-13. Additional changes will be needed to be able to actually use the backend for this target.
2021-09-20Bless incremental tests.Camille GILLOT-7/+11
2021-09-20Make with_hir_id_owner responsible for registering the item.Camille GILLOT-140/+91
2021-09-20Fix a technicality regarding the size of C's `char` typeNadja Reitzenstein-1/+1
Specifically, ISO/IEC 9899:2018 — better known as "C18" — (and at least C11, C99 and C89) do not specify the size of `byte` in bits. Section 3.6 defines "byte" as "addressable unit of data storage" while section 6.2.5 ("Types") only defines "char" as "large enough to store any member of the basic execution set" giving it a lower bound of 7 bit (since there are 96 characters in the basic execution set). With section 6.5.3.4 paragraph 4 "When sizeof is applied to an operant that has type char […] the result is 1" you could read this as the size of `char` in bits being defined as exactly the same as the number of bits in a byte but it's also valid to read that as an exception. In general implementations take `char` as the smallest unit of addressable memory, which for modern byte-addressed architectures is overwhelmingly 8 bits to the point of this convention being completely cemented into just about all of our software. So is any of this actually relevant at all? I hope not. I sincerely hope that this never, ever comes up. But if for some reason a poor rustacean is having to interface with C code running on a Cray X1 that in 2003 is still doing word-addressed memory with 64-bit words and they trust the docs here blindly it will blow up in her face. And I'll be truly sorry for her to have to deal with … all of that.
2021-09-20Auto merge of #88842 - wesleywiser:fix_dbg_tests_windows_sdk, r=michaelwoeristerbors-89/+58
Fix debuginfo tests for the latest version of the Windows SDK. Re-enable the tests that were disabled to fix CI. Changes: - Cdb now correctly visualizes enums. - Cdb doesn't render emoji characters in `OSStr` anymore. - Cdb doesn't always render `str` correctly (#88840)
2021-09-20Auto merge of #88708 - Aaron1011:aggregate-usage, r=oli-obkbors-46/+83
Add `ConstraintCategory::Usage` for handling aggregate construction In some cases, we emit borrowcheck diagnostics pointing at a particular field expression in a struct expression (e.g. `MyStruct { field: my_expr }`). However, this behavior currently relies on us choosing the `ConstraintCategory::Boring` with the 'correct' span. When adding additional variants to `ConstraintCategory`, (or changing existing usages away from `ConstraintCategory::Boring`), the current behavior can easily get broken, since a non-boring constraint will get chosen over a boring one. To make the diagnostic output less fragile, this commit adds a `ConstraintCategory::Usage` variant. We use this variant for the temporary assignments created for each field of an aggregate we are constructing. Using this new variant, we can emit a message mentioning "this usage", emphasizing the fact that the error message is related to the specific use site (in the struct expression). This is preparation for additional work on improving NLL error messages (see #57374)
2021-09-20Remove lower_node_id_with_owner.Camille GILLOT-63/+34
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-1/+1
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-70/+49
2021-09-19Auto merge of #88575 - eddyb:fn-abi-queries, r=nagisabors-242/+506
Querify `FnAbi::of_{fn_ptr,instance}` as `fn_abi_of_{fn_ptr,instance}`. *Note: opening this PR as draft because it's based on #88499* This more or less replicates the `LayoutOf::layout_of` setup from #88499, to replace `FnAbi::of_{fn_ptr,instance}` with `FnAbiOf::fn_abi_of_{fn_ptr,instance}`, and also route them through queries (which `layout_of` has used for a while). The two changes at the use sites (other than the names) are: * return type is now wrapped in `&'tcx` * the value *is* interned, which may affect performance * the `extra_args` list is now an interned `&'tcx ty::List<Ty<'tcx>>` * should be cheap (it's empty for anything other than C variadics) Theoretically, a `FnAbiOfHelpers` implementer could choose to keep the `Result<...>` instead of eagerly erroring, but the only existing users of these APIs are codegen backends, so they don't (want to) take advantage of this. At least miri could make use of this, since it prefers propagating errors (it "just" doesn't use `FnAbi` yet - cc `@RalfJung).` The way this is done is probably less efficient than what is possible, because the queries handle the correctness-oriented API (i.e. the split into `fn` pointers vs instances), whereas a lower-level query could end up with more reuse between different instances with identical signatures. r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-19Auto merge of #89049 - Aaron1011:caching-sourcemap-assert, r=Mark-Simulacrumbors-7/+7
Convert `debug_assert` to `assert` in `CachingSourceMapView` I suspect that there's a bug somewhere in this code, which is leading to the `predicates_of` ICE being seen in #89035
2021-09-19Restore the suggestion to set `ninja = false`.Daira Hopwood-1/+2
2021-09-19Fix generics where bounds orderGuillaume Gomez-4/+6
2021-09-19Auto merge of #7690 - Jarcho:while_loop_by_ref, r=xFrednetbors-27/+22
Change `while_let_on_iterator` suggestion to use `by_ref()` It came up in the discussion #7659 that suggesting `iter.by_ref()` is a clearer suggestion than `&mut iter`. I personally think they're equivalent, but if `by_ref()` is clearer to people then that should be the suggestion. changelog: Change `while_let_on_iterator` suggestion when using `&mut` to use `by_ref()`
2021-09-19Auto merge of #88703 - cjgillot:lazymod, r=petrochenkovbors-83/+147
Gather module items after lowering. This avoids having a non-local analysis inside lowering. By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.
2021-09-19[bootstrap] Improve the error message when `ninja` is not found to link to ↵Daira Hopwood-2/+6
installation instructions. Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-09-19Auto merge of #88627 - cjgillot:noallocuse, r=petrochenkovbors-100/+32
Do not preallocate HirIds Part of https://github.com/rust-lang/rust/pull/87234 r? `@petrochenkov`
2021-09-19Merge commit '61667dedf55e3e5aa584f7ae2bd0471336b92ce9' into ↵bjorn3-294/+332
sync_cg_clif-2021-09-19
2021-09-19Rustup to rustc 1.57.0-nightly (aa8f2d432 2021-09-18)bjorn3-5/+5
2021-09-19Sync from rust 7a3d1a5f3dfeaf5177885fedd7db8ecc70670dc1bjorn3-4/+9
2021-09-19Auto merge of #89089 - JohnTitor:rollup-6s6mccx, r=JohnTitorbors-139/+506
Rollup of 10 pull requests Successful merges: - #87960 (Suggest replacing an inexisting field for an unmentioned field) - #88855 (Allow simd_shuffle to accept vectors of any length) - #88966 (Check for shadowing issues involving block labels) - #88996 (Fix linting when trailing macro expands to a trailing semi) - #89017 (fix potential race in AtomicU64 time monotonizer) - #89021 (Add a separate error for `dyn Trait` in `const fn`) - #89051 (Add intra-doc links and small changes to `std::os` to be more consistent) - #89053 (refactor: VecDeques IntoIter fields to private) - #89055 (Suggest better place to add call parentheses for method expressions wrapped in parentheses) - #89081 (Fix a typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-19Suggest replacing braces for brackets on array-esque invalid block exprHirochika Matsumoto-4/+120
Newcomers may write `{1, 2, 3}` for making arrays, and the current error message is not informative enough to quickly convince them what is needed to fix the error. This PR implements a diagnostic for this case, and its output looks like this: ```text error: this code is interpreted as a block expression, not an array --> src/lib.rs:1:22 | 1 | const FOO: [u8; 3] = { | ______________________^ 2 | | 1, 2, 3 3 | | }; | |_^ | = note: to define an array, one would use square brackets instead of curly braces help: try using [] instead of {} | 1 | const FOO: [u8; 3] = [ 2 | 1, 2, 3 3 | ]; | ``` Fix #87672
2021-09-19Resolve issue 85066Theo-0/+32
Fix : use struct_dummy Fix different os messages
2021-09-19Rollup merge of #89081 - ondra05:patch-1, r=dtolnayYuki Okushi-2/+2
Fix a typo Removed extra spaces in front of commas
2021-09-19Rollup merge of #89055 - Kobzol:wrapped-method-expr-call-parens, r=wesleywiserYuki Okushi-4/+47
Suggest better place to add call parentheses for method expressions wrapped in parentheses I wanted to improve the suggestion a bit to both remove the wrapping parentheses **and** add call parentheses by both calling `suggest_method_call` and using `multipart_suggestion`. But I very quickly ran into a problem where multiple overlapping machine applicable suggestions cannot be properly applied together. So I applied the suggestion from the issue and only added the call parentheses directly after the expression. Fixes: https://github.com/rust-lang/rust/issues/89044
2021-09-19Rollup merge of #89053 - DeveloperC286:into_iter_fields_to_private, ↵Yuki Okushi-2/+8
r=Mark-Simulacrum refactor: VecDeques IntoIter fields to private Made the fields of VecDeque's IntoIter private by creating a IntoIter::from(...) function to create a new instance of IntoIter and migrating usage to use IntoIter::from(...).
2021-09-19Rollup merge of #89051 - schctl:master, r=jyn514Yuki Okushi-15/+60
Add intra-doc links and small changes to `std::os` to be more consistent I believe that a few items in `std::os` should be linked. I've also added a basic example in `std::os::windows`.
2021-09-19Rollup merge of #89021 - ↵Yuki Okushi-23/+62
WaffleLapkin:separate_error_for_dyn_trait_in_const_fn, r=estebank Add a separate error for `dyn Trait` in `const fn` Previously "trait bounds other than `Sized` on const fn parameters are unstable" error was used for both trait bounds (`<T: Trait>`) and trait objects (`dyn Trait`). This was pretty confusing. This PR adds a separate error for trait objects: "trait objects in const fn are unstable". The error for trait bounds is otherwise intact. This is follow up to #88907 r? ``@estebank`` ``@rustbot`` label: +A-diagnostics
2021-09-19Rollup merge of #89017 - the8472:fix-u64-time-monotonizer, r=kennytmYuki Okushi-28/+30
fix potential race in AtomicU64 time monotonizer The AtomicU64-based monotonizer introduced in #83093 is incorrect because several threads could try to update the value concurrently and a thread which doesn't have the newest value among all the updates could win. That bug probably has little real world impact since it doesn't make observed time worse than hardware clocks. The worst case would probably be a thread which has a clock that is behind by several cycles observing several inconsistent fixups, which should be similar to observing the unfiltered backslide in the first place. New benchmarks, they don't look as good as the original PR but still an improvement compared to the mutex. I don't know why the contended mutex case is faster now than in the previous benchmarks. ``` actually_monotonic() == true: test time::tests::instant_contention_01_threads ... bench: 44 ns/iter (+/- 0) test time::tests::instant_contention_02_threads ... bench: 45 ns/iter (+/- 0) test time::tests::instant_contention_04_threads ... bench: 45 ns/iter (+/- 0) test time::tests::instant_contention_08_threads ... bench: 45 ns/iter (+/- 0) test time::tests::instant_contention_16_threads ... bench: 46 ns/iter (+/- 0) atomic u64: test time::tests::instant_contention_01_threads ... bench: 66 ns/iter (+/- 0) test time::tests::instant_contention_02_threads ... bench: 287 ns/iter (+/- 14) test time::tests::instant_contention_04_threads ... bench: 296 ns/iter (+/- 43) test time::tests::instant_contention_08_threads ... bench: 604 ns/iter (+/- 163) test time::tests::instant_contention_16_threads ... bench: 1,147 ns/iter (+/- 29) mutex: test time::tests::instant_contention_01_threads ... bench: 78 ns/iter (+/- 0) test time::tests::instant_contention_02_threads ... bench: 652 ns/iter (+/- 275) test time::tests::instant_contention_04_threads ... bench: 900 ns/iter (+/- 32) test time::tests::instant_contention_08_threads ... bench: 1,927 ns/iter (+/- 62) test time::tests::instant_contention_16_threads ... bench: 3,748 ns/iter (+/- 146) ```
2021-09-19Rollup merge of #88996 - Aaron1011:trailing-macro-semi, r=petrochenkovYuki Okushi-6/+43
Fix linting when trailing macro expands to a trailing semi When a macro is used in the trailing expression position of a block (e.g. `fn foo() { my_macro!() }`), we currently parse it as an expression, rather than a statement. As a result, we ended up using the `NodeId` of the containing statement as our `lint_node_id`, even though we don't normally do this for macro calls. If such a macro expands to an expression with a `#[cfg]` attribute, then the trailing statement can get removed entirely. This lead to an ICE, since we were usng the `NodeId` of the expression to emit a lint. Ths commit makes us skip updating `lint_node_id` when handling a macro in trailing expression position. This will cause us to lint at the closest parent of the macro call.
2021-09-19Rollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkovYuki Okushi-21/+61
Check for shadowing issues involving block labels
2021-09-19Rollup merge of #88855 - calebzulawski:feature/simd_shuffle, r=nagisaYuki Okushi-35/+171
Allow simd_shuffle to accept vectors of any length cc ``@rust-lang/project-portable-simd`` ``@workingjubilee``
2021-09-19Rollup merge of #87960 - ↵Yuki Okushi-3/+22
hkmatsumoto:suggest-inexisting-field-for-unmentioned-field, r=estebank Suggest replacing an inexisting field for an unmentioned field Fix #87938 This PR adds a suggestion to replace an inexisting field for an unmentioned field. Given the following code: ```rust enum Foo { Bar { alpha: u8, bravo: u8, charlie: u8 }, } fn foo(foo: Foo) { match foo { Foo::Bar { alpha, beta, // `bravo` miswritten as `beta` here. charlie, } => todo!(), } } ``` the compiler now emits the error messages below. ```text error[E0026]: variant `Foo::Bar` does not have a field named `beta` --> src/lib.rs:9:13 | 9 | beta, // `bravo` miswritten as `beta` here. | ^^^^ | | | variant `Foo::Bar` does not have this field | help: `Foo::Bar` has a field named `bravo`: `bravo` ``` Note that this suggestion is available iff the number of inexisting fields and unmentioned fields are both 1.
2021-09-19Auto merge of #89031 - the8472:outline-once-cell-init-closure, r=Mark-Simulacrumbors-1/+10
Don't inline OnceCell initialization closures The more general variant of #89026, originally suggested in https://github.com/rust-lang/rust/pull/86898#issuecomment-920138051
2021-09-19Auto merge of #89028 - Aaron1011:coercion-cause, r=nagisabors-23/+52
Propagate coercion cause into `try_coerce` Currently, `coerce_inner` discards its `ObligationCause` when calling `try_coerce`. This interfers with other diagnostc improvements I'm working on, since we will lose the original span by the time the actual coercion occurs. Additionally, we now use the span of the trailing expression (rather than the span of the entire function) when performing a coercion in `check_return_expr`. This currently has no visible effect on any of the unit tests, but will unblock future diagnostic improvements.