about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-12-18Rollup merge of #87901 - poliorcetics:pub-pub-pub, r=jackh726Matthias Krüger-15/+64
Fix suggestion of additional `pub` when using `pub pub fn ...` Fix #87694. Marked as draft to start with because I want to explore doing the same fix for `const const fn` and other repeated-but-valid keywords. `@rustbot` label A-diagnostics D-invalid-suggestion T-compiler
2021-12-17Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisabors-19/+683
Implement let-else type annotations natively Tracking issue: #87335 Fixes #89688, fixes #89807, edit: fixes #89960 as well As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved. This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically: * `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~ * It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that. * ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~ * ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~ * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~ Some other misc notes: * ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~ * in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
2021-12-17Auto merge of #91838 - scottmcm:array-slice-eq-via-arrays-not-slices, r=dtolnaybors-3/+16
Do array-slice equality via array equality, rather than always via slices ~~Draft because it needs a rebase after #91766 eventually gets through bors.~~ This enables the optimizations from #85828 to be used for array-to-slice comparisons too, not just array-to-array. For example, <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=5f9ba69b3d5825a782f897c830d3a6aa> ```rust pub fn demo(x: &[u8], y: [u8; 4]) -> bool { *x == y } ``` Currently writes the array to stack for no reason: ```nasm sub rsp, 4 mov dword ptr [rsp], edx cmp rsi, 4 jne .LBB0_1 mov eax, dword ptr [rdi] cmp eax, dword ptr [rsp] sete al add rsp, 4 ret .LBB0_1: xor eax, eax add rsp, 4 ret ``` Whereas with the change in this PR it just compares it directly: ```nasm cmp rsi, 4 jne .LBB1_1 cmp dword ptr [rdi], edx sete al ret .LBB1_1: xor eax, eax ret ```
2021-12-16Rollup merge of #92001 - fee1-dead:dmbic-xcrate-fix, r=oli-obkMatthias Krüger-0/+21
Fix default_method_body_is_const when used across crates r? `@oli-obk` unblocks #91439.
2021-12-16Rollup merge of #91172 - Ethiraric:ethiraric/fix90979, r=petrochenkovMatthias Krüger-0/+63
Warn when a `#[test]`-like built-in attribute macro is present multiple times. Fixes #90979.
2021-12-16Fix default_method_body_is_const when used across cratesDeadbeef-0/+21
2021-12-16Rollup merge of #91958 - jsha:rust-logo, r=GuillaumeGomezMatthias Krüger-0/+14
Apply rust-logo class only on default logo Fixes #91653. ![image](https://user-images.githubusercontent.com/220205/146138145-a7a62ea6-3205-4bc7-8460-e985284d93ea.png) Demo: https://rustdoc.crud.net/jsha/hashes/sha2/ r? ``@GuillaumeGomez``
2021-12-16Auto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiserbors-195/+245
Include rustc version in `rustc_span::StableCrateId` `rustc_span::def_id::StableCrateId` is a hash of various data about a crate during compilation. This PR includes the version of `rustc` in the input when computing this hash. From a cursory reading of [RFC 2603](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html), this appears to be acceptable within that design. In order to pass the `mir-opt` and `ui` test suites, this adds new [normalization for hashes and symbol names in `compiletest`](https://github.com/rust-lang/rust/pull/89836/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b). These are enabled by default, but we might prefer it to be configurable. In the UI tests, I had to truncate a significant amount of error annotations in v0 symbols (and maybe some legacy) in order to get the normalization to work correctly. (See https://github.com/rust-lang/rust/issues/90116.) Closes #85142.
2021-12-15Add a lint for duplicated attributes.Ethiraric-0/+63
2021-12-15Auto merge of #86986 - lcnr:simplify_type, r=nikomatsakis,oli-obkbors-7/+21
extend `simplify_type` might cause a slight perf inprovement and imo more accurately represents what types there are. considering that I was going to use this in #85048 it seems like we might need this in the future anyways :shrug:
2021-12-15Apply rust-logo class only on default logoJacob Hoffman-Andrews-0/+14
Also replace ' with " in rustdoc template
2021-12-15Auto merge of #91962 - matthiaskrgr:rollup-2g082jw, r=matthiaskrgrbors-89/+95
Rollup of 7 pull requests Successful merges: - #91880 (fix clippy::single_char_pattern perf findings) - #91885 (Remove `in_band_lifetimes` from `rustc_codegen_ssa`) - #91898 (Make `TyS::is_suggestable` check for non-suggestable types structually) - #91915 (Add another regression test for unnormalized fn args with Self) - #91916 (Fix a bunch of typos) - #91918 (Constify `bool::then{,_some}`) - #91920 (Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-15Rollup merge of #91915 - jackh726:issue-91899, r=Mark-SimulacrumMatthias Krüger-0/+37
Add another regression test for unnormalized fn args with Self Closes #91899
2021-12-15Rollup merge of #91898 - compiler-errors:dont_suggest_closure_return_type, ↵Matthias Krüger-89/+58
r=lcnr Make `TyS::is_suggestable` check for non-suggestable types structually Not sure if I went overboard checking substs in dyn types, etc. Let me know if I should simplify this function. Fixes #91832
2021-12-15Auto merge of #91959 - matthiaskrgr:rollup-rhajuvw, r=matthiaskrgrbors-335/+115
Rollup of 7 pull requests Successful merges: - #90521 (Stabilize `destructuring_assignment`) - #91479 (Add `[T]::as_simd(_mut)`) - #91584 (Improve code for rustdoc-gui tester) - #91886 (core: minor `Option` doc correction) - #91888 (Handle unordered const/ty generics for object lifetime defaults) - #91905 (Fix source code page sidebar on mobile) - #91906 (Removed `in_band_lifetimes` from `library\proc_macro`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-15update testslcnr-4/+6
2021-12-15Rollup merge of #91905 - GuillaumeGomez:source-code-page-sidebar, r=jshaMatthias Krüger-0/+32
Fix source code page sidebar on mobile Current broken behaviour: https://user-images.githubusercontent.com/3050060/145984316-35c82353-5bab-4dc6-9ac6-63ea7e5c27d8.mp4 Fixed: https://user-images.githubusercontent.com/3050060/145984329-8be1127b-d707-424d-ac3c-c1fb3c48a093.mp4 r? `@jsha`
2021-12-15Rollup merge of #91888 - BoxyUwU:generic_arg_infer_aaaa, r=lcnrMatthias Krüger-0/+25
Handle unordered const/ty generics for object lifetime defaults *feel like I should have a PR description but cant think of what to put here* r? ```@lcnr```
2021-12-15Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, ↵Matthias Krüger-335/+58
r=jackh726,pnkfelix Stabilize `destructuring_assignment` Closes #71126 - [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058) - [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819) `@rustbot` label +F-destructuring-assignment +T-lang Also needs +relnotes but I don't have permission to add that tag.
2021-12-15Auto merge of #91752 - yaahc:track-caller-result, r=cuviperbors-3/+3
Readd track_caller to Result::from_residual This is a followup on https://github.com/rust-lang/rust/issues/87401 in and an attempt to move the issue towards resolution. As part of the overhaul of the Try trait we removed the ability for errors to grab location information during propagation via `?` with the builtin `std::result::Result`. The previously linked issue has a fair bit of discussion into the reasons for and against the usage of `#[track_caller]` on the `FromResidual` impl on `Result` that I will do my best to summarize. --- ### For - https://github.com/rust-lang/rust/issues/87401#issuecomment-915053533: Difficulties with using non `std::result::Result` like types - https://github.com/rust-lang/rust/issues/87401#issuecomment-978355102: Inconsistency with functionality provided for recoverable (Result) and non-recoverable errors (panic), where panic provides a location and Result does not, pushing some users towards using panic ### Against - https://github.com/rust-lang/rust/issues/84277#issuecomment-885322833: concern that this will bloat callers that never use this data --- Personally, I want to quantify the performance / bloat impact of re-adding this attribute, and fully evaluate the pros and cons before deciding if I need to switch `eyre` to have a custom `Result` type, which would also mean I need `try_trait_v2` to be stabilized, cc `@scottmcm.` If the performance impact is minor enough in the general case I think I would prefer that the default `Result` type has the ability to track location information for consistency with `panic` error reporting, and leave it to applications that need particularly high performance to handle the micro optimizations of introducing their own efficient custom Result type or matching manually. Alternatively, I wonder if the performance penalty on code that doesn't use the location information on `FromResidual` could be mitigated via new optimizations.
2021-12-14Stabilize `destructuring_assignment`Jacob Pratt-335/+58
2021-12-15Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgrbors-108/+149
Rollup of 7 pull requests Successful merges: - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring) - #91859 (Iterator::cycle() — document empty iterator special case) - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`) - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking) - #91881 (Stabilize `iter::zip`) - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`) - #91940 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-15Rollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obkMatthias Krüger-0/+1
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace` The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`.
2021-12-15Rollup merge of #90939 - estebank:wg-af-polish, r=tmandryMatthias Krüger-108/+148
Tweak errors coming from `for`-loop, `?` and `.await` desugaring * Suggest removal of `.await` on non-`Future` expression * Keep track of obligations introduced by desugaring * Remove span pointing at method for obligation errors coming from desugaring * Point at called local sync `fn` and suggest making it `async` ``` error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:9:10 | LL | boo().await; | -----^^^^^^ `()` is not a future | | | this call returns `()` | = help: the trait `Future` is not implemented for `()` help: do not `.await` the expression | LL - boo().await; LL + boo(); | help: alternatively, consider making `fn boo` asynchronous | LL | async fn boo () {} | +++++ ``` Fix #66731.
2021-12-15Auto merge of #91933 - matthiaskrgr:rollup-cw9qolb, r=matthiaskrgrbors-0/+113
Rollup of 7 pull requests Successful merges: - #89825 (Make split_inclusive() on an empty slice yield an empty output) - #91239 (regression test for issue 87490) - #91597 (Recover on invalid operators `<>` and `<=>`) - #91774 (Fix typo for MutVisitor) - #91786 (Return an error when `eval_rvalue_with_identities` fails) - #91798 (Avoid suggest adding `self` in visibility spec) - #91856 (Looser check for overflowing_binary_op) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-14Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplettbors-733/+682
Stabilize asm! and global_asm! Tracking issue: #72016 It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature! The main changes in this PR are: - Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228. - Stabilizing the `asm` and `global_asm` features. - Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483). - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example. - Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`. - Updating `stdarch` and `compiler-builtins`. - Updating all the tests. r? `@joshtriplett`
2021-12-14Do array-slice equality via arrays, rather than always via slicesScott McMurray-3/+16
This'll still go via slices eventually for large arrays, but this way slice comparisons to short arrays can use the same memcmp-avoidance tricks. Added some tests for all the combinations to make sure I didn't accidentally infinitely-recurse something.
2021-12-14Rollup merge of #91856 - ouz-a:master, r=oli-obkMatthias Krüger-0/+9
Looser check for overflowing_binary_op Fix for issue #91636 tight check resulted in ICE, this makes the check a little looser. It seems `eq` allows comparing of `supertype` and `subtype` if `lhs = supertype` and `rhs = subtype` but not vice versa, is this intended behavior ?
2021-12-14Rollup merge of #91798 - bugadani:issue-91783, r=michaelwoeristerMatthias Krüger-0/+44
Avoid suggest adding `self` in visibility spec Fixes #91783
2021-12-14Rollup merge of #91786 - tmiasko:const-prop, r=oli-obkMatthias Krüger-0/+12
Return an error when `eval_rvalue_with_identities` fails Previously some code paths would fail to evaluate the rvalue, while incorrectly indicating success with `Ok`. As a result the previous value of lhs could have been incorrectly const propagated. Fixes #91725. r? `@oli-obk`
2021-12-14Rollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obkMatthias Krüger-0/+24
Recover on invalid operators `<>` and `<=>` Thanks to #89871 for showing me how to do this. Next, I think it'd be nice to recover on `<=>` too, like #89871 intended, if this even works.
2021-12-14Rollup merge of #91239 - cameron1024:issue-87490-regression, r=jackh726Matthias Krüger-0/+24
regression test for issue 87490 Closes #87490
2021-12-14Make TyS::is_suggestable more structualMichael Goulet-89/+58
2021-12-14Recover on invalid operators <> and <=>r00ster91-0/+24
2021-12-14Return an error when `eval_rvalue_with_identities` failsTomasz Miąsko-0/+12
Previously some code paths would fail to evaluate the rvalue, while incorrectly indicating success with `Ok`. As a result the previous value of lhs could have been incorrectly const propagated.
2021-12-14Add another regression test for unnormalized fn args with SelfJack Huey-0/+37
2021-12-14extend `simplify_type`lcnr-3/+15
2021-12-14Add GUI test for source code page sidebarGuillaume Gomez-0/+32
2021-12-14Rollup merge of #91892 - compiler-errors:fix-inferty-hashtable, r=dtolnayMatthias Krüger-0/+17
Fix HashStable implementation on InferTy HashStable impl forgot to hash the discriminant. Fixes #91807
2021-12-14Rollup merge of #91875 - b-naber:mir-transform-norm-erase-reg, r=Aaron1011Matthias Krüger-0/+21
Use try_normalize_erasing_regions in RevealAllVisitor Fixes https://github.com/rust-lang/rust/issues/91745 Thanks to ``@Aaron1011`` for [pointing out the problem](https://github.com/rust-lang/rust/issues/91745#issuecomment-991996008). r? ``@Aaron1011``
2021-12-14Rollup merge of #91820 - rukai:help_with_personality_issues, r=davidtwcoMatthias Krüger-1/+7
Suggest to specify a target triple when lang item is missing It is very common for newbies to embedded to hit this confusing error when forgetting to specify the target. Source: me googling this error many times. ## Possible changes * We could possibly restrict the note+help to only be included on eh_personality lang item if that helped reduce false positives, but its also possible doing so would just increase false negatives * Open to any suggestions on rewriting the messages * We could possibly remove the `.cargo/config` alternative to avoid the message getting too noisy but I think its valuable to have as its the correct approach for most embedded projects so that `cargo build` just works. r? rust-lang/diagnostics
2021-12-13Fix HashStable implementation on InferTyMichael Goulet-0/+17
2021-12-14testEllen-0/+25
2021-12-14Auto merge of #91660 - llogiq:make-a-hash-of-def-ids, r=nnethercotebors-17/+17
manually implement `Hash` for `DefId` This might speed up hashing for hashers that can work on individual u64s. Just as an experiment, suggested in a reddit thread on `FxHasher`. cc `@nnethercote` Note that this should not be merged as is without cfg-ing the code path for 64 bits.
2021-12-14test should pass :sweat_smile:ouz-a-0/+1
2021-12-13use try_normalize_erasing_regions in RevealAllVisitorb-naber-0/+21
2021-12-14Add regression test and commentouz-a-0/+8
2021-12-13Update test to new error messageAlexis Bourget-15/+17
2021-12-13Fix broken span and related testsAlexis Bourget-6/+16
2021-12-13Add tests for misplaced/duplicated pub in fn declAlexis Bourget-0/+37