about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-09-05Add test for #98294Nikita Popov-0/+19
Add a test to make that the failure condition for this pattern is optimized away. Fixes #98294.
2022-09-05Add corresponding regression testDaniel Henry-Mantilla-0/+10
2022-09-05Add matrix based test for documenting the let / let else temporary drop orderest31-0/+321
The drop order of let and let else is supposed to be the same, and in order to ensure this, the test checks that this holds for the given list of cases. The test also ensures that we drop the temporaries of the condition before executing the else block. We made the test matrix based so it can check all the possible combinations and find out possible edge cases.
2022-09-05suggest introducing an explicit lifetime if it does not existTakayuki Maeda-10/+44
2022-09-05Auto merge of #101439 - Dylan-DPC:rollup-2wf1mtj, r=Dylan-DPCbors-151/+352
Rollup of 6 pull requests Successful merges: - #101142 (Improve HIR stats) - #101367 (Suggest `{Option,Result}::{copied,clone}()` to satisfy type mismatch) - #101391 (more clippy::perf fixes) - #101409 (Don't fire `rust_2021_incompatible_closure_captures` in `edition = 2021` crates) - #101420 (Fix `hir::Local` doc to match with the variable name used: `init`) - #101429 (Don't suggest reborrow if usage is inside a closure) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-09-05Rollup merge of #101429 - compiler-errors:issue-101119, r=lcnrDylan DPC-0/+31
Don't suggest reborrow if usage is inside a closure I can't think of why we would ever be able to *successfully* suggest a mutable reborrow `&mut *` due to a move happening due to a closure, so just suppress it. Fixes #101119
2022-09-05Rollup merge of #101409 - ↵Dylan DPC-0/+15
WaffleLapkin:rust_2021_compatibility_no_warn_in_2021_crates, r=TaKO8Ki Don't fire `rust_2021_incompatible_closure_captures` in `edition = 2021` crates Fixes #101284
2022-09-05Rollup merge of #101367 - compiler-errors:suggest-copied-or-cloned, r=lcnrDylan DPC-0/+129
Suggest `{Option,Result}::{copied,clone}()` to satisfy type mismatch Fixes #100699, but in the opposite direction (instead of suggesting to fix the signature, it fixes the body)
2022-09-05Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwcoDylan DPC-151/+177
Improve HIR stats #100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection. r? `@davidtwco`
2022-09-05Auto merge of #101414 - mystor:pm_nested_cross_thread, r=eddybbors-3/+20
proc_macro/bridge: use the cross-thread executor for nested proc-macros While working on some other changes in the bridge, I noticed that when running a nested proc-macro (which is currently only possible using the unstable `TokenStream::expand_expr`), any symbols held by the proc-macro client would be invalidated, as the same thread would be used for the nested macro by default, and the interner doesn't handle nested use. After discussing with `@eddyb,` we decided the best approach might be to force the use of the cross-thread executor for nested invocations, as it will never re-use thread-local storage, avoiding the issue. This shouldn't impact performance, as expand_expr is still unstable, and infrequently used. This was chosen rather than making the client symbol interner handle nested invocations, as that would require replacing the internal interner `Vec` with a `BTreeMap` (as valid symbol id ranges could now be disjoint), and the symbol interner is known to be fairly perf-sensitive. This patch adds checks to the execution strategy to use the cross-thread executor when doing nested invocations. An alternative implementation strategy could be to track this information in the `ExtCtxt`, however a thread-local in the `proc_macro` crate was chosen to add an assertion so that `rust-analyzer` is aware of the issue if it implements `expand_expr` in the future. r? `@eddyb`
2022-09-04Remove unnecessary `EMIT_MIR_FOR_EACH_BITWIDTHJakob Degen-1598/+12
2022-09-05UPDATE - into_diagnostic to take a Handler instead of a ParseSessJhonny Bill Mena-11/+11
Suggested by the team in this Zulip Topic https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20SessionDiagnostic.20on.20Handler Handler already has almost all the capabilities of ParseSess when it comes to diagnostic emission, in this migration we only needed to add the ability to access source_map from the emitter in order to get a Snippet and the start_point. Not sure if this is the best way to address this gap
2022-09-05Look at move place's type when suggesting mutable reborrowMichael Goulet-0/+50
2022-09-05Don't suggest reborrow if usage is inside a closureMichael Goulet-0/+31
2022-09-05Auto merge of #101386 - aDotInTheVoid:rdj-discriminant, r=GuillaumeGomezbors-0/+119
Rustdoc-Json: Add enum discriminant Does the first part of #101337, by adding it to `clean`, but doesn't change HTML output, as 1. [No Consensus has appeared on the UI for this](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Enum.20discriminant.20values.20in.20HTML.20output) 2. [When inlining across crates, information is lost](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60clean_variant_def.20.60vs.20.60clean_variant_data.60) JSON doesn't have either of these limitations. r? `@GuillaumeGomez`
2022-09-05Auto merge of #100759 - fee1-dead-contrib:const_eval_select_real_intrinsic, ↵bors-70/+89
r=oli-obk,RalfJung Make `const_eval_select` a real intrinsic This fixes issues where `track_caller` functions do not have nice panic messages anymore when there is a call to the function, and uses the MIR system to replace the call instead of dispatching via lang items. Fixes #100696.
2022-09-04Point at type parameter in plain path exprMichael Goulet-0/+23
2022-09-04proc_macro/bridge: use the cross-thread executor for nested proc-macrosNika Layzell-3/+20
While working on some other changes in the bridge, I noticed that when running a nested proc-macro (which is currently only possible using the unstable `TokenStream::expand_expr`), any symbols held by the proc-macro client would be invalidated, as the same thread would be used for the nested macro by default, and the interner doesn't handle nested use. After discussing with @eddyb, we decided the best approach might be to force the use of the cross-thread executor for nested invocations, as it will never re-use thread-local storage, avoiding the issue. This shouldn't impact performance, as expand_expr is still unstable, and infrequently used. This was chosen rather than making the client symbol interner handle nested invocations, as that would require replacing the internal interner `Vec` with a `BTreeMap` (as valid symbol id ranges could now be disjoint), and the symbol interner is known to be fairly perf-sensitive. This patch adds checks to the execution strategy to use the cross-thread executor when doing nested invocations. An alternative implementation strategy could be to track this information in the `ExtCtxt`, however a thread-local in the `proc_macro` crate was chosen to add an assertion so that `rust-analyzer` is aware of the issue if it implements `expand_expr` in the future. r? @eddyb
2022-09-04Rollup merge of #101407 - GuillaumeGomez:rm-duplicated-gui-test, r=Dylan-DPCMatthias Krüger-22/+0
Remove duplicated test (superseeded by search-form-elements.goml) I realized it when I worked on https://github.com/rust-lang/rust/pull/101348. The checks are more complete in `search-form-elements.goml` (for example [here](https://github.com/rust-lang/rust/blob/master/src/test/rustdoc-gui/search-form-elements.goml#L12-L29)). r? `@Dylan-DPC`
2022-09-04Rollup merge of #101388 - compiler-errors:issue-101376, r=fee1-deadMatthias Krüger-0/+35
Don't delay invalid LHS bug unless it will be covered by an error in `check_overloaded_binop` Fixes #101376
2022-09-04Don't fire `rust_2021_incompatible_closure_captures` in edition = 2021Maybe Waffle-0/+15
2022-09-04Remove duplicated test (superseeded by search-form-elements.goml)Guillaume Gomez-22/+0
2022-09-04Auto merge of #101296 - compiler-errors:head-span-for-enclosing-scope, r=oli-obkbors-266/+189
Use head span for `rustc_on_unimplemented`'s `enclosing_scope` attr This may make #101281 slightly easier to understand
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-70/+89
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-687/+1167
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in #92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](https://github.com/rust-lang/compiler-team/issues/411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - https://github.com/rust-lang/compiler-team/issues/411 - https://github.com/rust-lang/rust/issues/99571
2022-09-04Also suggest dereferencing LHS when both &mut T and T are valid binop LHSMichael Goulet-0/+35
2022-09-04Address nits, rename enclosing_scope => parent_labelMichael Goulet-43/+43
2022-09-04Use head span for rustc_on_unimplemented's enclosing_scope attrMichael Goulet-196/+119
2022-09-04Rollup merge of #101369 - compiler-errors:global-asm-pprint, r=jackh726Matthias Krüger-0/+12
Fix `global_asm` macro pretty printing Fixes #101051 Fixes #101047
2022-09-04Rollup merge of #100647 - obeis:issue-99875, r=nagisaMatthias Krüger-32/+81
Make trait bound not satisfied specify kind Closes #99875
2022-09-04Rollup merge of #100302 - compiler-errors:deref-path-methods, r=jackh726Matthias Krüger-0/+20
Suggest associated method on deref types when path syntax method fails Fixes #100278
2022-09-03Rustdoc-Json: Add enum discriminantNixon Enraght-Moony-0/+119
2022-09-03Do not call object_lifetime_default on lifetime params.Camille GILLOT-33/+71
2022-09-03Auto merge of #101378 - matthiaskrgr:rollup-s1awa47, r=matthiaskrgrbors-108/+128
Rollup of 4 pull requests Successful merges: - #101335 (rustdoc: remove old CSS selector that causes weird spacing) - #101347 (ffx component run should provide a collection) - #101364 (Shrink suggestion span of argument mismatch error) - #101365 (remove redundant clones) Failed merges: - #101349 (rustdoc: remove `.impl-items { flex-basis }` CSS, not in flex container) r? `@ghost` `@rustbot` modify labels: rollup
2022-09-03Rollup merge of #101364 - compiler-errors:arg-suggestion-spans, r=wesleywiserMatthias Krüger-108/+108
Shrink suggestion span of argument mismatch error This doesn't really help with #101242, but I wanted to put this up while I work on other fixes.
2022-09-03Rollup merge of #101335 - notriddle:notriddle/methods-stability, r=notriddleMatthias Krüger-0/+20
rustdoc: remove old CSS selector that causes weird spacing It was added with e08a84a0c18739417a50c3e46917ced5037244eb (actually, it was called `.methods > .stability` at the time) and was directly nested that way. **EDIT**: It is technically reachable code still, but it seems wrong. ## With the old CSS rule still present https://notriddle.com/notriddle-rustdoc-test/weird-spacing/lib/struct.Foo.html ![image](https://user-images.githubusercontent.com/1593513/188216226-c667c560-d33d-494f-a492-4e0ec3ac0009.png) ## Version 2 (an older version of this PR) https://notriddle.com/notriddle-rustdoc-test/normal-spacing-2/lib/struct.Foo.html ![image](https://user-images.githubusercontent.com/1593513/188216418-9fcd3109-f1b2-425d-b4fc-0c6b3b54e48e.png) ## Version 3 (with alignment fix for mobile) https://notriddle.com/notriddle-rustdoc-test/normal-spacing-3/lib/struct.Foo.html ![image](https://user-images.githubusercontent.com/1593513/188223161-0e1ebce7-842f-41cb-8a0c-ae43aedcfccc.png)
2022-09-03Auto merge of #100574 - Urgau:check-cfg-warn-cfg, r=petrochenkovbors-3/+23
Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in https://github.com/rust-lang/rust/pull/99519. r? `@petrochenkov`
2022-09-03Include enum path in variant suggestionMichael Goulet-232/+232
2022-09-03Fix global_asm macro pretty printingMichael Goulet-0/+12
2022-09-03Suggest copied or clonedMichael Goulet-0/+129
2022-09-03Suggest associated method on deref typesMichael Goulet-0/+20
2022-09-03Shrink suggestion span of argument mismatch errorMichael Goulet-108/+108
2022-09-03Suggest removing unnecessary prefix let in patternsMichael Goulet-0/+31
2022-09-03Rollup merge of #101348 - GuillaumeGomez:cleanup-css-theme, r=notriddleDylan DPC-2/+2
Cleanup css theme Follow-up of https://github.com/rust-lang/rust/pull/100494. The change for the border color of the search input in the dark mode was actually a weird case: the search input border was unique, it didn't share the same variable with other items with borders. This weird case being unique to the dark theme, I removed it, hence the modification in the GUI test. Live demo is [here](https://rustdoc.crud.net/imperio/cleanup-css-theme/std/index.html). cc `@jsha` r? `@notriddle`
2022-09-03Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514Dylan DPC-0/+3
[drop tracking] Use parent expression for scope, not parent node Previously we were just using the parent node as the scope for a temporary value, but it turns out this is too narrow. For example, in an expression like Foo { b: &42, a: async { 0 }.await, } the scope for the &42 was set to the ExprField node for `b: &42`, when we actually want to use the Foo struct expression. We fix this by recursively searching through parent nodes until we find a Node::Expr. It may be that we don't find one, and if so that's okay, we will just fall back on the enclosing temporary scope which is always sufficient. Helps with #97331 r? ``@jyn514``
2022-09-03Auto merge of #100966 - compiler-errors:revert-remove-deferred-sized-checks, ↵bors-25/+219
r=pnkfelix Revert "Remove deferred sized checks" cc: https://github.com/rust-lang/rust/pull/100652#issuecomment-1225798572 I'm okay with reverting this for now, and I will look into the diagnostic regressions. This reverts commit 33212bf7f527798a8cfa2bbb38781742f4ca718a. r? `@pnkfelix` ---- EDIT: This _also_ fixes #101066, a regression in method selection logic/coercion(?) due to the early registering of a `Sized` bound.
2022-09-03Update rustdoc-gui tests for search-input border color on dark themeGuillaume Gomez-2/+2
2022-09-02Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplettbors-0/+261
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE` When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program ```rust fn main() { loop { println!("hello world"); } } ``` will print an error if used with a short-lived pipe, e.g. % ./main | head -n 1 hello world thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace by enabling `#[unix_sigpipe = "sig_dfl"]` like this ```rust #![feature(unix_sigpipe)] #[unix_sigpipe = "sig_dfl"] fn main() { loop { println!("hello world"); } } ``` there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately: % ./main | head -n 1 hello world The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`. With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`. See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-09-02rustdoc: put in rule to get alignment in desktop and mobile layoutsMichael Howell-0/+20
2022-09-02Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obkMatthias Krüger-0/+25
Try normalizing types without RevealAll in ParamEnv in MIR validation Before, the MIR validator used RevealAll in its ParamEnv for type checking. This could cause false negatives in some cases due to RevealAll ParamEnvs not always use all predicates as expected here. Since some MIR passes like inlining use RevealAll as well, keep using it in the MIR validator too, but when it fails usign RevealAll, also try the check without it, to stop false negatives. Fixes #99866 cc ````````@compiler-errors```````` who nicely helped me on zulip