about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-02-28Auto merge of #94431 - matthiaskrgr:rollup-1jsj0wu, r=matthiaskrgrbors-0/+38
Rollup of 7 pull requests Successful merges: - #94396 (1 - Make more use of `let_chains`) - #94397 (Document that pre-expansion lint passes are softly deprecated) - #94399 (Add test for #79465 to prevent regression) - #94409 (avoid rebuilding bootstrap when PATH changes) - #94415 (Use the first codegen backend in the config.toml as default) - #94417 (Fix duplicated impl links) - #94420 (3 - Make more use of `let_chains`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-27Auto merge of #94157 - erikdesjardins:more-noundef, r=nikicbors-8/+58
Apply noundef attribute to all scalar types which do not permit raw init Beyond `&`/`&mut`/`Box`, this covers `char`, enum discriminants, `NonZero*`, etc. All such types currently cause a Miri error if left uninitialized, and an `invalid_value` lint in cases like `mem::uninitialized::<char>()`. Note that this _does not_ change whether or not it is UB for `u64` (or other integer types with no invalid values) to be undef. Fixes (partially) #74378. r? `@ghost` (blocked on #94127) `@rustbot` label S-blocked
2022-02-27Rollup merge of #94417 - GuillaumeGomez:fix-duplicated-impl-links, r=notriddleMatthias Krüger-0/+20
Fix duplicated impl links Fixes #78701. The problem is that the blanket impl has the same ID as the other impl, except that we don't derive IDs when we generate the sidebar. We now do. r? ``@notriddle``
2022-02-27Rollup merge of #94399 - GuillaumeGomez:regression-test-79465, r=matthiaskrgrMatthias Krüger-0/+18
Add test for #79465 to prevent regression Fixes #79465. Like this we will be able to close the issue. r? ````@matthiaskrgr````
2022-02-27make pgo-branch-weights test not dependent on argument attributesErik Desjardins-2/+2
2022-02-27Auto merge of #94412 - scottmcm:cfg-out-miri-from-swap, r=oli-obkbors-0/+27
For MIRI, cfg out the swap vectorization logic from 94212 Because of #69488 the swap logic from #94212 doesn't currently work in MIRI. Copying in smaller pieces is probably much worse for its performance anyway, so it'd probably rather just use the simple path regardless. Part of #94371, though another PR will be needed for the CTFE aspect. r? `@oli-obk` cc `@RalfJung`
2022-02-27Add test to ensure that links to impls are correctly generatedGuillaume Gomez-0/+20
2022-02-26For MIRI, cfg out the swap logic from 94212Scott McMurray-0/+27
2022-02-26Auto merge of #93516 - nagisa:branch-protection, r=cjgillotbors-25/+47
No branch protection metadata unless enabled Even if we emit metadata disabling branch protection, this metadata may conflict with other modules (e.g. during LTO) that have different branch protection metadata set. This is an unstable flag and feature, so ideally the flag not being specified should act as if the feature wasn't implemented in the first place. Additionally this PR also ensures we emit an error if `-Zbranch-protection` is set on targets other than the supported aarch64. For now the error is being output from codegen, but ideally it should be moved to earlier in the pipeline before stabilization.
2022-02-26Apply noundef attribute to all scalar types which do not permit raw initErik Desjardins-6/+56
Beyond `&`/`&mut`/`Box`, this covers `char`, discriminants, `NonZero*`, etc. All such types currently cause a Miri error if left uninitialized, and an `invalid_value` lint in cases like `mem::uninitialized::<char>()` Note that this _does not_ change whether or not it is UB for `u64` (or other integer types with no invalid values) to be undef.
2022-02-26Auto merge of #93449 - JakobDegen:restrict-hasdrop-optimization, r=cjgillotbors-0/+14
Restrict query recursion in `needs_significant_drop` Overly aggressive use of the query system to improve caching lead to query cycles and consequently ICEs. This patch fixes this by restricting the use of the query system as a cache to those cases where it is definitely correct. Closes #92725 . This is essentially a revert of #90845 for the significant drop case only. The general `needs_drop` still does the same thing. The hope is that this is enough to preserve the performance improvements of that PR while fixing the ICE. Should get a perf run to verify that this is the case. cc `@cjgillot`
2022-02-26Add test for #79465 to prevent regressionGuillaume Gomez-0/+18
2022-02-26Auto merge of #94078 - ↵bors-0/+329
TaKO8Ki:suggest-float-literal-for-float-divided-by-integer, r=estebank Suggest a float literal when dividing a floating-point type by `{integer}` closes #93829
2022-02-26Auto merge of #94127 - erikdesjardins:debugattr, r=nikicbors-4/+67
At opt-level=0, apply only ABI-affecting attributes to functions This should provide a small perf improvement for debug builds, and should more than cancel out the perf regression from adding noundef (https://github.com/rust-lang/rust/pull/93670#issuecomment-1038347581, #94106). r? `@nikic`
2022-02-26Auto merge of #94392 - matthiaskrgr:rollup-npscf95, r=matthiaskrgrbors-3/+83
Rollup of 5 pull requests Successful merges: - #93400 (Do not suggest using a const parameter when there are bounds on an unused type parameter) - #93982 (Provide extra note if synthetic type args are specified) - #94087 (Remove unused `unsound_ignore_borrow_on_drop`) - #94235 (chalk: Fix wrong debrujin index in opaque type handling.) - #94306 (Avoid exhausting stack space in dominator compression) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-26Rollup merge of #94235 - Dirbaio:fix-chalk-opaque-debrujin, r=jackh726Matthias Krüger-0/+48
chalk: Fix wrong debrujin index in opaque type handling. A folder in opaque type lowering was substituting all opaque type references with a variable with debrujin index 0 ignoring how many binders deep we are. This caused an ICE with `Not enough bound vars: ^0 not found in []` ([full logs](https://gist.github.com/Dirbaio/2b9374ff4fce37afb9d665dc9f0000df)) with the following code. ```rust fn main() -> () {} async fn foo(x: u32) -> u32 { x } ``` With the fix, it no longer ICEs. It still doesn't typecheck due to generator issues. I've added a "known-bug" test so that at least it doesn't regress back to ICEing. r? ``@jackh726``
2022-02-26Rollup merge of #93982 - nbdd0121:explicit-generic-args, r=jackh726Matthias Krüger-0/+1
Provide extra note if synthetic type args are specified Implement the unresolved question in #83701 as suggested in https://github.com/rust-lang/rust/pull/86176#discussion_r680613890. r? ``@jackh726``
2022-02-26Rollup merge of #93400 - ↵Matthias Krüger-3/+34
ChayimFriedman2:dont-suggest-using-const-with-bounds-unused-generic-param, r=jackh726 Do not suggest using a const parameter when there are bounds on an unused type parameter The user wrote the bound, so it's obvious they want a type.
2022-02-26suggest a float literal when dividing a floating-point type by {integer}Takayuki Maeda-0/+329
fix a message implement a rustfix-applicable suggestion implement `suggest_floating_point_literal` add `ObligationCauseCode::BinOp` remove duplicate code fix function names in uitests use `Diagnostic` instead of `DiagnosticBuilder`
2022-02-26Auto merge of #92884 - compiler-errors:const-generic-expr-recovery, r=jackh726bors-0/+81
Suggest adding `{ .. }` around more bad const generic exprs Fixes #92776
2022-02-26Provide extra note if synthetic type args are specifiedGary Guo-0/+1
2022-02-25Suggest {} around more bad const generic exprsMichael Goulet-0/+81
2022-02-25avoid test failure on targets where all functions are dso_local (e.g. wasm)Erik Desjardins-4/+4
2022-02-26Rollup merge of #94377 - cynecx:fix-used-with-args, r=nikicMatthias Krüger-0/+9
`check_used` should only look at actual `used` attributes cc? https://github.com/rust-lang/rust/issues/94348 r? ``@nikic``
2022-02-26Rollup merge of #94355 - ouz-a:master, r=oli-bokMatthias Krüger-0/+36
Add one more case to avoid ICE Fix for the #94291, added one more case to related function to avoid ICE. Not sure if my test is in the correct place 😅
2022-02-26Rollup merge of #93870 - tmiasko:const-precise-live-drops-with-coverage, ↵Matthias Krüger-0/+16
r=ecstatic-morse Fix switch on discriminant detection in a presence of coverage counters Fixes #93848. r? ``@ecstatic-morse``
2022-02-25Add one more case to avoid ICEouz-a-0/+36
2022-02-25`check_used` should only look at actual `used` attributescynecx-0/+9
2022-02-25make tests work on noopt builderErik Desjardins-4/+4
2022-02-25Rollup merge of #94353 - flip1995:fix_debug_assert_unused, r=Dylan-DPCMatthias Krüger-6/+6
Fix debug_assert in unused lint pass This fixes a debug assertion in the unused lint pass. As a side effect, this also improves the span generated for tuples in the `unused_must_use` lint. found in #94329 A reproducer for this would be ```rust fn main() { (1, (3,)); } ``` Not sure, if I should add a regression test for a `debug_assert`.
2022-02-25Rollup merge of #94154 - Urgau:rustdoc-check-cfg, r=GuillaumeGomezMatthias Krüger-0/+50
Wire up unstable rustc --check-cfg to rustdoc This pull-request wire up the new unstable `--check-cfg` option from `rustc` to `rustdoc` as [requested](https://github.com/rust-lang/rust/pull/93915#discussion_r807560445) in the [pull-request](https://github.com/rust-lang/rust/pull/93915) that introduce `--check-cfg`. The motivation was describe in the original PR by ``@jyn514`` who wrote https://github.com/rust-lang/rust/pull/89346#issuecomment-930129761: > > add plumbing to pass --check-cfg from rustdoc (do we want this one?) > > It would be useful, I think, it catches issues like cfg(doctst) or something (and in general I would like expansion to match rustc as closely as possible).
2022-02-25Rollup merge of #93850 - asquared31415:extern-static-size-ice, r=jackh726Matthias Krüger-0/+63
Don't ICE when an extern static is too big for the current architecture Fixes #93760 Emit an error instead of ICEing when an `extern` static's size overflows the allowed maximum for the target. Changes the error message in the existing `delay_span_bug` call to the true layout error, first for debugging purposes, but opted to leave in to potentially assist future developers as it was being reached in unexpected ways already.
2022-02-25Auto merge of #94357 - matthiaskrgr:rollup-xrjaof3, r=matthiaskrgrbors-1379/+255
Rollup of 7 pull requests Successful merges: - #93845 (Remove in band lifetimes) - #94155 (Extend toggle GUI test a bit) - #94252 (don't special case `DefKind::Ctor` in encoding) - #94305 (Remove an unnecessary restriction in `dest_prop`) - #94343 (Miri fn ptr check: don't use conservative null check) - #94344 (diagnostic: suggest parens when users want logical ops, but get closures) - #94352 (Fix SGX docs build) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-25Rollup merge of #94344 - notriddle:notriddle/suggest-parens-more, r=oli-obkMatthias Krüger-1/+135
diagnostic: suggest parens when users want logical ops, but get closures Fixes #93536
2022-02-25Rollup merge of #94343 - RalfJung:fn-ptr, r=oli-obkMatthias Krüger-2/+2
Miri fn ptr check: don't use conservative null check In https://github.com/rust-lang/rust/pull/94270 I used the wrong NULL check for function pointers: `memory.ptr_may_be_null` is conservative even on machines that support ptr-to-int casts, leading to false errors in Miri. This fixes that problem, and also replaces that foot-fun of a method with `scalar_may_be_null` which is never unnecessarily conservative. r? `@oli-obk`
2022-02-25Rollup merge of #94305 - JakobDegen:dp-1, r=oli-obkMatthias Krüger-7/+13
Remove an unnecessary restriction in `dest_prop` I had asked about this [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Do.20unions.20have.20active.20fields.3F) but didn't receive a response, so putting up this PR that makes the change I think we can. If it turns out that this is wrong, hopefully I'll find out here. Reposting my Zulip comment: > Not sure what channel to put this into, so using this as a fallback. The dest prop MIR opt has this comment: > > ```rust > //! Subtle case: If `dest` is a, or projects through a union, then we have to make sure that there > //! remains an assignment to it, since that sets the "active field" of the union. But if `src` is > //! a ZST, it might not be initialized, so there might not be any use of it before the assignment, > //! and performing the optimization would simply delete the assignment, leaving `dest` > //! uninitialized. > ``` > > In particular, the claim seems to be that we can't take > ``` > x = (); > y.field = x; > ``` > where `y` is a union having `field: ()` as one of its variants, and optimize the entire thing away (assuming `x` is unused otherwise). As far as I know though, Rust unions don't have active fields. Is this comment correct and am I missing something? Is there a worry about this interacting poorly with FFI code/C unions/LTO or something? This PR just removes that comment and the associated code. Also it fixes one unrelated comment that did not match the code it was commenting on. r? rust-lang/mir-opt
2022-02-25Rollup merge of #94252 - lcnr:def_kind-encoding, r=cjgillotMatthias Krüger-44/+44
don't special case `DefKind::Ctor` in encoding considering that we still use `DefKind::Ctor` for these in `Res`, this seems weird and definitely felt like a bug when encountering it while working on #89862. r? `@cjgillot`
2022-02-25Rollup merge of #94155 - GuillaumeGomez:extend-toggle-gui-test, r=jshaMatthias Krüger-2/+26
Extend toggle GUI test a bit Fixes #84422. r? `@jsha`
2022-02-25Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillotMatthias Krüger-1323/+35
Remove in band lifetimes As discussed in t-lang backlog bonanza, the `in_band_lifetimes` FCP closed in favor for the feature not being stabilized. This PR removes `#![feature(in_band_lifetimes)]` in its entirety. Let me know if this PR is too hasty, and if we should instead do something intermediate for deprecate the feature first. r? `@scottmcm` (or feel free to reassign, just saw your last comment on #44524) Closes #44524
2022-02-25Fix debug_assert in unused lint passflip1995-6/+6
This fixes a debug assertion in the unused lint pass. As a side effect, this also improves the span generated for tuples in the `unused_must_use` lint.
2022-02-25Auto merge of #93644 - michaelwoerister:simpler-debuginfo-typemap, r=wesleywiserbors-1/+1
debuginfo: Simplify TypeMap used during LLVM debuginfo generation. This PR simplifies the TypeMap that is used in `rustc_codegen_llvm::debuginfo::metadata`. It was unnecessarily complicated because it was originally implemented when types were not yet normalized before codegen. So it did it's own normalization and kept track of multiple unnormalized types being mapped to a single unique id. This PR is based on https://github.com/rust-lang/rust/pull/93503, which is not merged yet. The PR also removes the arena used for allocating string ids and instead uses `InlinableString` from the [inlinable_string](https://crates.io/crates/inlinable_string) crate. That might not be the best choice, since that crate does not seem to be very actively maintained. The [flexible-string](https://crates.io/crates/flexible-string) crate would be an alternative. r? `@ghost`
2022-02-25Extend toggle GUI test a bitGuillaume Gomez-2/+26
2022-02-25Auto merge of #94350 - matthiaskrgr:rollup-eesfiyr, r=matthiaskrgrbors-0/+114
Rollup of 6 pull requests Successful merges: - #92714 (Provide ignore message in the result of test) - #93273 (Always check cg_llvm with ./x.py check) - #94068 (Consider mutations as borrows in generator drop tracking) - #94184 (BTree: simplify test code) - #94297 (update const_generics_defaults release notes) - #94341 (Remove a duplicate space) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-25Rollup merge of #94068 - eholk:drop-track-field-assign, r=tmandryMatthias Krüger-0/+114
Consider mutations as borrows in generator drop tracking This is needed to match MIR more conservative approximation of any borrowed value being live across a suspend point (See #94067). This change considers an expression such as `x.y = z` to be a borrow of `x` and therefore keeps `x` live across suspend points. r? `@nikomatsakis`
2022-02-25Do not suggest using a const parameter when there are bounds on an unused ↵Chayim Refael Friedman-3/+34
type parameter The user wrote the bound, so it's obvious they want a type.
2022-02-25Auto merge of #94130 - erikdesjardins:partially, r=nikicbors-40/+20
Use undef for (some) partially-uninit constants There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code). Fixes: #84565 Original PR: #83698 Depends on LLVM 14: #93577
2022-02-24Remove in-band lifetimesMichael Goulet-1323/+35
2022-02-25Wire up --check-cfg to rustdocLoïc BRANSTETT-0/+50
2022-02-24Miri fn ptr check: don't use conservative null checkRalf Jung-2/+2
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-1/+1
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`