about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-07-20Rollup merge of #99486 - ↵Dylan DPC-8/+9
TaKO8Ki:remove-type-string-comparison-in-check-str-addition, r=compiler-errors Refactor: remove a string comparison between types in `check_str_addition` This patch removes remove a string of types comparison.
2022-07-20Rollup merge of #99485 - mdholloway:unused-qualifications-in-derive, r=oli-obkDylan DPC-9/+1
Stop injecting `#[allow(unused_qualifications)]` in generated `derive` implementations Currently, the `#[derive]` attribute always injects an `#[allow(unused_qualifications)]` attribute in the generated implementation. This results in an error when a derive is used in combination with `#![forbid(unused_qualifications)]`, because the `forbid` rule by definition cannot be overridden by `allow`. It appears that the original issue that prompted the inclusion of `#[allow(unused_qualifications)]` (#19102) is no longer present in the current stable release, and the associated [test case](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-19102.rs) still passes, so the `allow` is simply removed here. Fixes #71898.
2022-07-20Rollup merge of #99483 - compiler-errors:issue-99482, r=jyn514Dylan DPC-0/+2
Fix a numerical underflow in tuple wrap suggestion Fixes #99482 I'm a clown, I rewrote the arg mismatch algo to use well-typed indices to avoid things like this, but then I added my own indexing bug, lol.
2022-07-20Rollup merge of #99436 - Nilstrieb:toggle-box-noalias, r=fee1-deadDylan DPC-2/+10
Add flag to configure `noalias` on `Box<T>` The aliasing rules of `Box<T>` are still not decided, but currently, `Box<T>` is unique and gets `noalias`. To aid making an informed decision about the future of `Box<T>`, this PR adds a flag `-Zbox-noalias` to configure `noalias` for `Box<T>` (for example, for benchmarking). The same flag already exists for `&mut T` `noalias`, where it was added because it was the problem of various miscompilations in LLVM. For more information, see rust-lang/unsafe-code-guidelines#326
2022-07-20Rollup merge of #99383 - ouz-a:issue_57961, r=oli-obkDylan DPC-149/+184
Formalize defining_use_anchor This tackles issue #57961 Introduces new enum called `DefiningAnchor` that replaces `Option<LocalDefId>` of `defining_use_anchor`. Now every use of it is explicit and exhaustively matched, catching errors like one in the linked issue. This is not a perfect fix but it's a step in the right direction. r? `@oli-obk`
2022-07-20Rollup merge of #99345 - compiler-errors:issue-99073-redux, r=oli-obkDylan DPC-1/+22
Do not allow typeck children items to constrain outer RPITs Fixes #99073 in a simpler and more conservative way than #99079. Simply raise a mismatched types error if we try to constrain an RPIT in an item that isn't the RPIT's parent. r? `@oli-obk`
2022-07-20use def_idouz-a-1/+1
2022-07-20take opaq typesouz-a-149/+184
2022-07-20Auto merge of #99493 - Dylan-DPC:rollup-lli4gcx, r=Dylan-DPCbors-46/+164
Rollup of 5 pull requests Successful merges: - #98784 (Suggest returning local on "expected `ty`, found `()`" due to expr-less block) - #98916 (Windows: Use `FindFirstFileW` for getting the metadata of locked system files) - #99433 (Erase regions before comparing signatures of foreign fns.) - #99452 (int_macros was only using to_xe_bytes_doc and not from_xe_bytes_doc) - #99481 (Add regression test for #71547) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-20Rollup merge of #99433 - cjgillot:erase-foreign-sig, r=compiler-errorsDylan DPC-3/+4
Erase regions before comparing signatures of foreign fns. Fixes https://github.com/rust-lang/rust/issues/99276 The version with explicit lifetimes is probably tracked in another bug, but I could not find it.
2022-07-20Rollup merge of #98784 - compiler-errors:forgot-to-return-binding, r=estebankDylan DPC-43/+160
Suggest returning local on "expected `ty`, found `()`" due to expr-less block Putting this up for _initial_ review. Notably, this doesn't consider if the value has possibly been moved, or whether the type is `Copy`. It also provides a structured suggestion if there's one "preferred" binding that matches the type (i.e. one binding in the block or its parent), otherwise it just points them out if there's fewer than 4 of them. Fixes #98177 r? `@estebank`
2022-07-20Auto merge of #98843 - Urgau:check-cfg-stage0, r=Mark-Simulacrumbors-33/+29
Enable check-cfg in stage0 Now that the bootstrap cargo supports `rustc-check-cfg` we can now enable it with `-Zcheck-cfg=output` and use it in `rustc_llvm` to unblock `--check-cfg` support in stage0. r? `@Mark-Simulacrum`
2022-07-20Suggest returning binding from block or enclosing scope on ↵Michael Goulet-43/+160
coerce_forced_unit error
2022-07-19Fix a numerical underflow in tuple wrap suggestionMichael Goulet-0/+2
2022-07-20remove a type string comparison in `check_str_addition`Takayuki Maeda-8/+9
2022-07-19Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, ↵bors-20/+27
r=petrochenkov,GuillaumeGomez Improve the function pointer docs This is #97842 but for function pointers instead of tuples. The concept is basically the same. * Reduce duplicate impls; show `fn (T₁, T₂, …, Tₙ)` and include a sentence saying that there exists up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`. https://notriddle.com/notriddle-rustdoc-test/std/primitive.fn.html
2022-07-19Erase regions before comparing signatures of foreign fns.Camille GILLOT-3/+4
2022-07-19Auto merge of #99309 - RalfJung:no-large-copies, r=oli-obkbors-82/+54
interpret: make some large types not Copy Also remove some unused trait impls (mostly HashStable). This didn't find any unnecessary copies that I managed to avoid, but it might still be better to require explicit clone for these types? Not sure. r? `@oli-obk`
2022-07-19use opaque_ty_origin_unchecked instead of destructuring HIRMichael Goulet-13/+5
2022-07-19Do not allow typeck children items to constrain outer RPITsMichael Goulet-0/+29
2022-07-19Improve the function pointer docsMichael Howell-6/+7
* Reduce duplicate impls; show only the `fn (T)` and include a sentence saying that there exists up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.
2022-07-19Add flag to configure `noalias` on `Box<T>`nils-2/+10
To aid making an informed decision about the aliasing rules of box, give users an option to remove `noalias` from box.
2022-07-19Rollup merge of #99457 - SparrowLii:para_iter, r=fee1-deadMatthias Krüger-6/+4
use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items` Using `par_iter` in non-parallel mode will cause the entire process to abort when any iteration panics. So we can use `par_for_each_in` instead to make the error message consistent with parallel mode. This means that the compiler will output more error messages in some cases. This fixes the following ui tests when set `parallel-compiler = true`: ``` [ui] src/test\ui\privacy\privacy2.rs [ui] src/test\ui\privacy\privacy3.rs [ui] src/test\ui\type_length_limit.rs ``` This refers to #68171 Updates #75760
2022-07-19Rollup merge of #99438 - WaffleLapkin:dont_wrap_in_non_zero, r=compiler-errorsMatthias Krüger-6/+83
Improve suggestions for `NonZeroT` <- `T` coercion error Currently, when encountering a type mismatch error with `NonZeroT` and `T` (for example `NonZeroU8` and `u8`) we errorneusly suggest wrapping expression in `NonZeroT`: ```text error[E0308]: mismatched types --> ./t.rs:7:35 | 7 | let _: std::num::NonZeroU64 = 1; | -------------------- ^ expected struct `NonZeroU64`, found integer | | | expected due to this | help: try wrapping the expression in `std::num::NonZeroU64` | 7 | let _: std::num::NonZeroU64 = std::num::NonZeroU64(1); | +++++++++++++++++++++ + ``` I've removed this suggestion and added suggestions to call `new` (for `Option<NonZeroT>` <- `T` case) or `new` and `unwrap` (for `NonZeroT` <- `T` case): ```text error[E0308]: mismatched types --> ./t.rs:7:35 | 7 | let _: std::num::NonZeroU64 = 1; | -------------------- ^ expected struct `NonZeroU64`, found integer | | | expected due to this | help: Consider calling `NonZeroU64::new` | 7 | let _: std::num::NonZeroU64 = NonZeroU64::new(1).unwrap(); | ++++++++++++++++ ++++++++++ error[E0308]: mismatched types --> ./t.rs:8:43 | 8 | let _: Option<std::num::NonZeroU64> = 1; | ---------------------------- ^ expected enum `Option`, found integer | | | expected due to this | = note: expected enum `Option<NonZeroU64>` found type `{integer}` help: Consider calling `NonZeroU64::new` | 8 | let _: Option<std::num::NonZeroU64> = NonZeroU64::new(1); | ++++++++++++++++ + ``` r? `@compiler-errors`
2022-07-19Rollup merge of #99435 - CAD97:revert-dollar-dollar-crate, r=Mark-SimulacrumMatthias Krüger-0/+2
Revert "Stabilize $$ in Rust 1.63.0" This mechanically reverts commit 9edaa76adce4de737db54194eb13d6c298827b37, the one commit from #95860. https://github.com/rust-lang/rust/issues/99035; the behavior of `$$crate` is potentially unexpected and not ready to be stabilized. https://github.com/rust-lang/rust/pull/99193 attempts to forbid `$$crate` without also destabilizing `$$` more generally. `@rustbot` modify labels +T-compiler +T-lang +P-medium +beta-nominated +relnotes (applying the labels I think are accurate from the issue and alternative partial revert) cc `@Mark-Simulacrum`
2022-07-19Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercoteMatthias Krüger-23/+28
Avoid `Symbol` to `&str` conversions `Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-19Rollup merge of #99384 - compiler-errors:issue-99375, r=oli-obkMatthias Krüger-7/+4
use body's param-env when checking if type needs drop The type comes from the body, so we should be using the body's param-env, as opposed to the ADT's param env, because we know less in the latter compared to the former. Fixes #99375
2022-07-19Rollup merge of #98028 - aticu:master, r=estebankMatthias Krüger-33/+156
Add E0790 as more specific variant of E0283 Fixes #81701 I think this should be good to go, there are only two things where I am somewhat unsure: - Is there a better way to get the fully-qualified path for the suggestion? I tried `self.tcx.def_path_str`, but that didn't seem to always give a correct path for the context. - Should all this be extracted into it's own method or is it fine where it is? r? `@estebank`
2022-07-19use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items`SparrowLii-6/+4
2022-07-19Auto merge of #99451 - Dylan-DPC:rollup-ceghu18, r=Dylan-DPCbors-112/+88
Rollup of 8 pull requests Successful merges: - #97183 (wf-check generators) - #98320 (Mention first and last macro in backtrace) - #99335 (Use split_once in FromStr docs) - #99347 (Use `LocalDefId` in `OpaqueTypeKey`) - #99392 (Fix debuginfo tests.) - #99404 (Use span_bug for unexpected field projection type) - #99410 (Update invalid atomic ordering lint) - #99434 (Fix `Skip::next` for non-fused inner iterators) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-19Don't use main; improve exampleaticu-19/+11
2022-07-19Add E0790 as more specific variant of E0283aticu-29/+160
2022-07-19Rollup merge of #99410 - tmiasko:atomic-lint, r=fee1-deadDylan DPC-43/+3
Update invalid atomic ordering lint The restriction that success ordering must be at least as strong as its failure ordering in compare-exchange operations was lifted in #98383.
2022-07-19Rollup merge of #99404 - jmqd:master, r=compiler-errorsDylan DPC-1/+5
Use span_bug for unexpected field projection type Improves the compiler error backtrace information, as shown in #99363, by using `span_bug` instead of `bug`. New output: ``` build/aarch64-apple-darwin/stage1/bin/rustc /tmp/test.rs --edition=2021 error: internal compiler error: compiler/rustc_middle/src/ty/closure.rs:185:25: Unexpected type Opaque(DefId(0:5 ~ test[db0f]::main::T::{opaque#0}), []) for `Field` projection --> /tmp/test.rs:11:27 | 11 | let Foo((a, b)) = foo; | ^^^ thread 'rustc' panicked at 'Box<dyn Any>', /Users/jmq/src/forked/rust/compiler/rustc_errors/src/lib.rs:1331:9 stack backtrace: ``` (Remainder of output truncated.)
2022-07-19Rollup merge of #99347 - compiler-errors:opaque-type-key-local-def-id, r=oli-obkDylan DPC-53/+51
Use `LocalDefId` in `OpaqueTypeKey` Addresses a `// FIXME(oli-obk): make this a LocalDefId` r? ``@oli-obk``
2022-07-19Rollup merge of #98320 - compiler-errors:macro-backtrace, r=estebankDylan DPC-6/+19
Mention first and last macro in backtrace Slight improvement to diagnostic mentioning what macro an error originates from. Not sure if it's worthwhile.
2022-07-19Rollup merge of #97183 - oli-obk:tait_ice_async, r=jackh726Dylan DPC-9/+10
wf-check generators fixes #90409 We should not rely on generators being well formed by construction now that they can get used via type alias impl trait (and thus users can choose generic arguments that are invalid). This can cause surprising behaviour if (definitely unsound) transmutes are used, and it's generally saner to just check for well formedness.
2022-07-19Auto merge of #98189 - mystor:fast_ident_literal, r=eddybbors-229/+173
proc_macro/bridge: stop using a remote object handle for proc_macro Ident and Literal This is the fourth part of https://github.com/rust-lang/rust/pull/86822, split off as requested in https://github.com/rust-lang/rust/pull/86822#pullrequestreview-1008655452. This patch transforms the `Ident` and `Group` types into structs serialized over IPC rather than handles. Symbol values are interned on both the client and server when deserializing, to avoid unnecessary string copies and keep the size of `TokenTree` down. To do the interning efficiently on the client, the proc-macro crate is given a vendored version of the fxhash hasher, as `SipHash` appeared to cause performance issues. This was done rather than depending on `rustc_hash` as it is unfortunately difficult to depend on crates from within `proc_macro` due to it being built at the same time as `std`. In addition, a custom arena allocator and symbol store was also added, inspired by those in `rustc_arena` and `rustc_span`. To prevent symbol re-use across multiple invocations of a macro on the same thread, a new range of `Symbol` names are used for each invocation of the macro, and symbols from previous invocations are cleaned-up. In order to keep `Ident` creation efficient, a special ASCII-only case was added to perform ident validation without using RPC for simple identifiers. Full identifier validation couldn't be easily added, as it would require depending on the `rustc_lexer` and `unicode-normalization` crates from within `proc_macro`. Unicode identifiers are validated and normalized using RPC. See the individual commit messages for more details on trade-offs and design decisions behind these patches.
2022-07-19Mention first and last macro in backtraceMichael Goulet-6/+19
2022-07-19Auto merge of #98120 - TaKO8Ki:box-diagnostic-metadata-field, r=estebankbors-2/+2
[Experiment] Box `diagnostic_metadata` field closes #97954 r? `@estebank`
2022-07-18Don't add attribute to allow unused-qualifications to derive impl'sSamrat Man Singh-9/+1
Currently `#![forbid(unused_qualifications)]` is incompatible with all derive's because we add `#[allow(unused_qualifications)]` in all generated impl's.
2022-07-19Use LocalDefId in OpaqueTypeKeyMichael Goulet-53/+51
2022-07-19Add a note about privacy to wrapping suggestionMaybe Waffle-11/+17
2022-07-19Apply suggestions from the reviewMaybe Waffle-8/+5
- Use `expr.hir_id.owner` instead of `self.tcx.parent_module(expr.hir_id)` - Use `.type_at()` instead of `.first()` + `.expect_ty()` - Use single `.find()` with `&&` condition Co-authored-by: Michael Goulet <michael@errs.io>
2022-07-19check accessibility before suggesting wrapping expressionsMaybe Waffle-8/+10
2022-07-18Auto merge of #99422 - Dylan-DPC:rollup-htjofm6, r=Dylan-DPCbors-10/+23
Rollup of 7 pull requests Successful merges: - #98839 (Add assertion that `transmute_copy`'s U is not larger than T) - #98998 (Remove branch target prologues from `#[naked] fn`) - #99198 (add missing null ptr check in alloc example) - #99344 (rustdoc: avoid inlining items with duplicate `(type, name)`) - #99351 (Use `typeck_results` to get accurate qpath res for arg mismatch error) - #99378 (interpret/visitor: add missing early return) - #99394 (Add regression test for #95230) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-19Suggest a fix for `NonZero*` <- `*` coercion errorMaybe Waffle-0/+64
2022-07-18Revert "Stabilize $$ in Rust 1.63.0"Christopher Durham-0/+2
This reverts commit 9edaa76adce4de737db54194eb13d6c298827b37.
2022-07-18interpret: make some large types not CopyRalf Jung-39/+45
2022-07-18Do not suggest "wrapping the expression in `std::num::NonZeroU64`"Maybe Waffle-0/+8