about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2021-08-16Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearthbors-0/+20
Add future-incompat lint for `doc(primitive)` ## What is `doc(primitive)`? `doc(primitive)` is an attribute recognized by rustdoc which adds documentation for the built-in primitive types, such as `usize` and `()`. It has been stable since Rust 1.0. ## Why change anything? `doc(primitive)` is useless for anyone outside the standard library. Since rustdoc provides no way to combine the documentation on two different primitive items, you can only replace the docs, and since the standard library already provides extensive documentation there is no reason to do so. While fixing rustdoc's handling of primitive items (https://github.com/rust-lang/rust/pull/87073) I discovered that even rustdoc's existing handling of primitive items was broken if you had more than two crates using it (it would pick randomly between them). That meant both: - Keeping rustdoc's existing treatment was nigh-impossible, because it was random. - doc(primitive) was even more useless than it would otherwise be. The only use-case for this outside the standard library is for no-std libraries which want to link to primitives (https://github.com/rust-lang/rust/issues/73423) which is being fixed in https://github.com/rust-lang/rust/pull/87073. https://github.com/rust-lang/rust/pull/87073 makes various breaking changes to `doc(primitive)` (breaking in the sense that they change the semantics, not in that they cause code to fail to compile). It's not possible to avoid these and still fix rustdoc's issues. ## What can we do about it? As shown by the crater run (https://github.com/rust-lang/rust/pull/87050#issuecomment-886166706), no one is actually using doc(primitive), there wasn't a single true regression in the whole run. We can either: 1. Feature gate it completely, breaking anyone who crater missed. They can easily fix the breakage just by removing the attribute. 2. add it to the `INVALID_DOC_ATTRIBUTES` future-incompat lint, and at the same time make it a no-op unless you add a feature gate. That would mean rustdoc has to look at the features of dependent crates, because it needs to know where primitives are defined in order to link to them. 3. add it to `INVALID_DOC_ATTRIBUTES`, but still use it to determine where primitives come from 4. do nothing; the behavior will silently change in https://github.com/rust-lang/rust/pull/87073. My preference is for 2, but I would also be happy with 1 or 3. I don't think we should silently change the behavior. This PR currently implements 3.
2021-08-16Add more assert!() tests for non_fmt_panics.Mara Bos-4/+60
2021-08-16Add tests for non_fmt_panics in generic functions.Mara Bos-1/+105
2021-08-16Update non_fmt_panics test.Mara Bos-15/+68
2021-08-16Add ui testDeadbeef-0/+18
2021-08-16Don't mark `if_let_guard` as an incomplete featureLéo Lanteri Thauvin-18/+12
2021-08-16Update test output.Mara Bos-152/+44
2021-08-16Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiserbors-0/+1346
Uplift the invalid_atomic_ordering lint from clippy to rustc This is mostly just a rebase of https://github.com/rust-lang/rust/pull/79654; I've copy/pasted the text from that PR below. r? `@lcnr` since you reviewed the last one, but feel free to reassign. --- This is an implementation of https://github.com/rust-lang/compiler-team/issues/390. As mentioned, in general this turns an unconditional runtime panic into a (compile time) lint failure. It has no false positives, and the only false negatives I'm aware of are if `Ordering` isn't specified directly and is comes from an argument/constant/whatever. As a result of it having no false positives, and the alternative always being strictly wrong, it's on as deny by default. This seems right. In the [zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Uplift.20the.20.60invalid_atomic_ordering.60.20lint.20from.20clippy/near/218483957) `@joshtriplett` suggested that lang team should FCP this before landing it. Perhaps libs team cares too? --- Some notes on the code for reviewers / others below ## Changes from clippy The code is changed from [the implementation in clippy](https://github.com/rust-lang/rust-clippy/blob/68cf94f6a66e47234e3adefc6dfbe806cd6ad164/clippy_lints/src/atomic_ordering.rs) in the following ways: 1. Uses `Symbols` and `rustc_diagnostic_item`s instead of string literals. - It's possible I should have just invoked Symbol::intern for some of these instead? Seems better to use symbol, but it did require adding several. 2. The functions are moved to static methods inside the lint struct, as a way to namespace them. - There's a lot of other code in that file — which I picked as the location for this lint because `@jyn514` told me that seemed reasonable. 3. Supports unstable AtomicU128/AtomicI128. - I did this because it was almost easier to support them than not — not supporting them would have (ideally) required finding a way not to give them a `rustc_diagnostic_item`, which would have complicated an already big macro. - These don't have tests since I wasn't sure if/how I should make tests conditional on whether or not the target has the atomic... This is to a certain extent an issue of 64bit atomics too, but 128-bit atomics are much less common. Regardless, the existing tests should be *more* than thorough enough here. 4. Minor changes like: - grammar tweaks ("loads cannot have `Release` **and** `AcqRel` ordering" => "loads cannot have `Release` **or** `AcqRel` ordering") - function renames (`match_ordering_def_path` => `matches_ordering_def_path`), - avoiding clippy-specific helper methods that don't exist in rustc_lint and didn't seem worth adding for this case (for example `cx.struct_span_lint` vs clippy's `span_lint_and_help` helper). ## Potential issues (This is just about the code in this PR, not conceptual issues with the lint or anything) 1. I'm not sure if I should have used a diagnostic item for `Ordering` and its variants (I couldn't figure out how really, so if I should do this some pointers would be appreciated). - It seems possible that failing to do this might possibly mean there are more cases this lint would miss, but I don't really know how `match_def_path` works and if it has any pitfalls like that, so maybe not. 2. I *think* I deprecated the lint in clippy (CC `@flip1995` who asked to be notified about clippy changes in the future in [this comment](https://github.com/rust-lang/rust/pull/75671#issuecomment-718731659)) but I'm not sure if I need to do anything else there. - I'm kind of hoping CI will catch if I missed anything, since `x.py test src/tools/clippy` fails with a lot of errors with and without my changes (and is probably a nonsense command regardless). Running `cargo test` from src/tools/clippy also fails with unrelated errors that seem like refactorings that didnt update clippy? So, honestly no clue. 3. I wasn't sure if the description/example I gave good. Hopefully it is. The example is less thorough than the one from clippy here: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering. Let me know if/how I should change it if it needs changing. 4. It pulls in the `if_chain` crate. This crate was already used in clippy, and seems like it's used elsewhere in rustc, but I'm willing to rewrite it to not use this if needed (I'd prefer not to, all things being equal).
2021-08-16feature gate doc(primitive)Joshua Nelson-0/+20
2021-08-16Uplift the `invalid_atomic_ordering` lint from clippy to rustcThom Chiovoloni-0/+1346
- Deprecate clippy::invalid_atomic_ordering - Use rustc_diagnostic_item for the orderings in the invalid_atomic_ordering lint - Reduce code duplication - Give up on making enum variants diagnostic items and just look for `Ordering` instead I ran into tons of trouble with this because apparently the change to store HIR attrs in a side table also gave the DefIds of the constructor instead of the variant itself. So I had to change `matches_ordering` to also check the grandparent of the defid as well. - Rename `atomic_ordering_x` symbols to just the name of the variant - Fix typos in checks - there were a few places that said "may not be Release" in the diagnostic but actually checked for SeqCst in the lint. - Make constant items const - Use fewer diagnostic items - Only look at arguments after making sure the method matches This prevents an ICE when there aren't enough arguments. - Ignore trait methods - Only check Ctors instead of going through `qpath_res` The functions take values, so this couldn't ever be anything else. - Add if_chain to allowed dependencies - Fix grammar - Remove unnecessary allow
2021-08-15add regression testErik Desjardins-0/+25
2021-08-15Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"Erik Desjardins-4/+11
This reverts commit 8007b506ac5da629f223b755f5a5391edd5f6d01, reversing changes made to e55c13e1099b78b1a485202fabc9c1b10b1f1d15.
2021-08-16Auto merge of #80357 - c410-f3r:new-hir-let, r=matthewjasperbors-657/+239
Introduce `hir::ExprKind::Let` - Take 2 Builds on #68577 and depends on #79328. cc #53667
2021-08-15Auto merge of #87590 - Amanieu:deprecate_llvm_asm, r=nagisabors-132/+177
Deprecate llvm_asm! We would like to remove `llvm_asm!` from the compiler once `asm!` is stabilized. This PR deprecates `llvm_asm!` to encourage any remaining users to migrate to `asm!` (or if `asm!` is not supported for their target, to add this support to rustc). The only remaining user of `llvm_asm!` in the standard library was `black_box`, which has been rewritten to use volatile operations when `asm!` is not available on the current target. cc `@rust-lang/wg-inline-asm` cc `@RalfJung` for the changes to `black_box` which might affect Miri. r? `@nagisa`
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-657/+239
2021-08-15Auto merge of #87982 - m-ou-se:non-fmt-panic-assert-str, r=cjgillotbors-27/+75
Add automatic migration for assert!(.., string). Fixes part of #87313.
2021-08-15Add a dead code test for using anon const in patternGary Guo-0/+45
2021-08-15Fix ui tests for llvm_asm! deprecationAmanieu d'Antras-132/+177
2021-08-15Auto merge of #87975 - m-ou-se:unused-import-attributes, r=nagisabors-0/+33
Include attributes in removal span for unused imports. Fixes https://github.com/rust-lang/rust/issues/87973
2021-08-15Report nicer errors for HRTB NLL errors from queriesMatthew Jasper-82/+222
2021-08-15Report mismatched type errors for bound region errors in NLLMatthew Jasper-47/+119
2021-08-14Only compute place if upvars can be resolvedRoxane-0/+54
2021-08-14Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisabors-56/+225
Add support for clobber_abi to asm! This PR adds the `clobber_abi` feature that was proposed in #81092. Fixes #81092 cc `@rust-lang/wg-inline-asm` r? `@nagisa`
2021-08-14Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obkbors-11/+4
Run RemoveZsts pass at mir-opt-level=1 per https://github.com/rust-lang/rust/pull/83177#issuecomment-803942217 This pass removes assignments to ZST places. Perf (from https://github.com/rust-lang/rust/pull/83177#issuecomment-803442557): https://perf.rust-lang.org/compare.html?start=41b315a470d583f6446599984ff9ad3bd61012b2&end=bd5d1b96f0c64c9938feea831789e1b5bb2cd4a2 r? `@oli-obk`
2021-08-14Auto merge of #87324 - asquared31415:named-asm-labels, r=Amanieubors-0/+406
Lint against named asm labels This adds a deny-by-default lint to prevent the use of named labels in inline `asm!`. Without a solution to #81088 about whether the compiler should rewrite named labels or a special syntax for labels, a lint against them should prevent users from writing assembly that could break for internal compiler reasons, such as inlining or anything else that could change the number of actual inline assembly blocks emitted. This does **not** resolve the issue with rewriting labels, that still needs a decision if the compiler should do any more work to try to make them work.
2021-08-14Auto merge of #87375 - fee1-dead:move-constness-to-traitpred, r=oli-obkbors-34/+53
Try filtering out non-const impls when we expect const impls **TL;DR**: Associated types on const impls are now bounded; we now disallow calling a const function with bounds when the specified type param only has a non-const impl. r? `@oli-obk`
2021-08-14Auto merge of #87600 - JohnTitor:classify-ui-tests, r=petrochenkovbors-26/+0
Move some UI tests to more suitable subdirs The classifui result: https://gist.github.com/JohnTitor/c9e00840990b5e4a8fc562ec3571e427/e06c42226c6038da91e403c33b9947843420cf44 Some notes: - backtrace-debuginfo.rs: previously I skipped this, I'm still not sure what the best dir is. Any ideas? - estr-subtyping.rs: Seems a quite old test so removed, shouldn't? - deref-suggestion.rs: moved to inference as `suggestions` is not an ideal dir. - issue-43023.rs: a bit misclassified, moved to `derives` cc #73494 r? `@petrochenkov`
2021-08-13Update comment and fix fmtRoxane-4/+4
2021-08-13Auto merge of #87478 - jackh726:issue-84931, r=estebankbors-4/+105
Point to where clause for GATs to add bound Fixes #84931 r? `@estebank`
2021-08-13Point to where clause for GATsjackh726-4/+105
2021-08-13Auto merge of #86492 - hyd-dev:no-mangle-method, r=petrochenkovbors-202/+805
Associated functions that contain extern indicator or have `#[rustc_std_internal_symbol]` are reachable Previously these fails to link with ``undefined reference to `foo'``: <details> <summary>Example 1</summary> ```rs struct AssocFn; impl AssocFn { #[no_mangle] fn foo() {} } fn main() { extern "Rust" { fn foo(); } unsafe { foo() } } ``` ([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f1244afcdd26e2a28445f6e82ca46b50)) </details> <details> <summary>Example 2</summary> ```rs #![crate_name = "lib"] #![crate_type = "lib"] struct AssocFn; impl AssocFn { #[no_mangle] fn foo() {} } ``` ```rs extern crate lib; fn main() { extern "Rust" { fn foo(); } unsafe { foo() } } ``` </details> But I believe they should link successfully, because this works: <details> ```rs #[no_mangle] fn foo() {} fn main() { extern "Rust" { fn foo(); } unsafe { foo() } } ``` ([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=789b3f283ee6126f53939429103ed98d)) </details> This PR fixes the problem, by adding associated functions that have "custom linkage" to `reachable_set`, just like normal functions. I haven't tested whether #76211 and [Miri](https://github.com/rust-lang/miri/issues/1837) are fixed by this PR yet, but I'm submitting this anyway since this fixes the examples above. I added a `run-pass` test that combines my two examples above, but I'm not sure if that's the right way to test this. Maybe I should add / modify an existing codegen test (`src/test/codegen/export-no-mangle.rs`?) instead?
2021-08-13Auto merge of #87984 - m-ou-se:closure-lint-wording, r=Aaron1011bors-280/+280
Closure lint wording Some small changes to the wording of the closure migration lint. r? `@Aaron1011`
2021-08-13Update tests for new closure migration lint wording.Mara Bos-280/+280
2021-08-13Rollup merge of #87966 - pietroalbini:fix-pidfd-test, r=m-ou-seGuillaume Gomez-1/+12
Fix `command-create-pidfd` test inside unprivileged Docker containers In `src/test/ui/command/command-create-pidfd.rs` (added #81825), the detection code to skip the test on unsupported platforms doesn't account for unprivileged Docker containers (CI uses privileged containers), which leads to a test failure as you can't call the `clone3` syscall in that environment. This PR enhances the detection code to also consider unprivileged containers.
2021-08-13Rollup merge of #87795 - estebank:erase-lifetimes-in-suggestion, r=oli-obkGuillaume Gomez-1/+30
Avoid ICE caused by suggestion When suggesting dereferencing something that can be iterable in a `for` loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region constraints already solved' panic. Fix #87657, fix #87709, fix #87651.
2021-08-13Fix Cargo.lock and ui testDeadbeef-1/+1
2021-08-13Update non-fmt-panic tests.Mara Bos-27/+75
2021-08-13Bless testDeadbeef-4/+4
2021-08-13Make assoc types work with `?const `opt=outDeadbeef-1/+11
2021-08-13Moved ui testDeadbeef-20/+0
2021-08-13Fix testsDeadbeef-2/+4
2021-08-13Fix call-generic-method-nonconst testDeadbeef-3/+15
2021-08-13Fix assoc-type testDeadbeef-5/+20
2021-08-13move Constness into TraitPredicateDeadbeef-1/+1
2021-08-13Auto merge of #87956 - m-ou-se:closure-migration-macro-body, r=Aaron1011bors-0/+56
Fix closure migration suggestion when the body is a macro. Fixes https://github.com/rust-lang/rust/issues/87955 Before: ``` warning: changes to closure capture in Rust 2021 will affect drop order --> src/main.rs:5:13 | 5 | let _ = || panic!(a.0); | ^^^^^^^^^^---^ | | | in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0` 6 | } | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure | help: add a dummy let to cause `a` to be fully captured | 20~ ($msg:expr $(,)?) => ({ let _ = &a; 21+ $crate::rt::begin_panic($msg) 22~ }), | ``` After: ``` warning: changes to closure capture in Rust 2021 will affect drop order --> src/main.rs:5:13 | 5 | let _ = || panic!(a.0); | ^^^^^^^^^^---^ | | | in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0` 6 | } | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure | help: add a dummy let to cause `a` to be fully captured | 5 | let _ = || { let _ = &a; panic!(a.0) }; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
2021-08-12Add missing multi variant casesRoxane-0/+63
2021-08-12Auto merge of #87916 - nbdd0121:black_box, r=nagisabors-1/+1
Implement `black_box` using intrinsic Introduce `black_box` intrinsic, as suggested in https://github.com/rust-lang/rust/pull/87590#discussion_r680468700. This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity. cc `@Amanieu` as this is related to inline assembly cc `@bjorn3` for rustc_codegen_cranelift changes cc `@RalfJung` as this affects MIRI r? `@nagisa` I suppose
2021-08-12Forbid `!` from being used in `asm!` outputGary Guo-0/+27
2021-08-12Rollup merge of #87965 - m-ou-se:non-fmt-panic-external, r=estebankManish Goregaokar-12/+6
Silence non_fmt_panic from external macros. This stops the non_fmt_panic lint from triggering if a macro from another crate is entirely responsible. In those cases there's nothing that the current crate can/should do. See also https://github.com/rust-lang/rust/issues/87621#issuecomment-890311054
2021-08-12Rollup merge of #87953 - m-ou-se:closure-migration-multiline-formatting, ↵Manish Goregaokar-81/+108
r=petrochenkov Improve formatting of closure capture migration suggestion for multi-line closures. Fixes https://github.com/rust-lang/rust/issues/87952 Before: ``` help: add a dummy let to cause `a` to be fully captured | 5 ~ let _ = || { let _ = &a; 6 + dbg!(a.0); 7 ~ }; | ``` After: ``` help: add a dummy let to cause `a` to be fully captured | 5 ~ let _ = || { 6 + let _ = &a; 7 + dbg!(a.0); 8 ~ }; | ```