about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-09-17Auto merge of #76028 - aticu:improve_e0118, r=estebank,jyn514,GuillaumeGomezbors-9/+31
Improve E0118 - Changes the "base type" terminology to "nominal type" (according to the [reference](https://doc.rust-lang.org/stable/reference/items/implementations.html#inherent-implementations)). - Suggests removing a reference, if one is present on the type. - Clarify what is meant by a "nominal type". closes #69392 This is my first not-entirely-trivial PR, so please let me know if I missed anything or if something could be improved. Though I probably won't be able to fix anything in the upcoming week.
2020-09-16Rollup merge of #76719 - hameerabbasi:min-const-generics-ty, r=lcnrTyler Mandry-5/+59
Change error message for ty param in const This PR introduces the following changes: * Change error message for type param in a const expression when using `min_const_generics` * Change `ParamInNonTrivialAnonConst` to contain an extra `bool` used for distinguishing whether the passed-in symbol is a type or a value. Fixes #76701
2020-09-16Rollup merge of #76642 - GuillaumeGomez:ignored-private-doc-test, r=jyn514Tyler Mandry-2/+14
Do not lint ignored private doc tests Fixes #76457. r? @ehuss
2020-09-16Rollup merge of #75026 - JulianKnodt:array_windows, r=AmanieuTyler Mandry-6/+6
Add array_windows fn This mimicks the functionality added by array_chunks, and implements a const-generic form of `windows`. It makes egregious use of `unsafe`, but by necessity because the array must be re-interpreted as a slice of arrays, and unlike array_chunks this cannot be done by casting the original array once, since each time the index is advanced it needs to move one element, not `N`. I'm planning on adding more tests, but this should be good enough as a premise for the functionality. Notably: should there be more functions overwritten for the iterator implementation/in general? ~~I've marked the issue as #74985 as there is no corresponding exact issue for `array_windows`, but it's based of off `array_chunks`.~~ Edit: See Issue #75027 created by @lcnr for tracking issue ~~Do not merge until I add more tests, please.~~ r? @lcnr
2020-09-16Add array window fnkadmin-6/+6
Updated issue to #75027 Update to rm oob access And hopefully fix docs as well Fixed naming conflict in test Fix test which used 1-indexing Nth starts from 0, woops Fix a bunch of off by 1 errors See https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=757b311987e3fae1ca47122969acda5a Add even more off by 1 errors And also write `next` and `next_back` in terms of `nth` and `nth_back`. Run fmt Fix forgetting to change fn name in test add nth_back test & document unsafe Remove as_ref().unwrap() Documented occurrences of unsafe, noting what invariants are maintained
2020-09-16Rollup merge of #76699 - lcnr:const-infer-err, r=varkorDylan DPC-8/+52
improve const infer error cc #72328 reduces it from ``` error[E0282]: type annotations needed --> src/main.rs:17:5 | 17 | Foo.bar().bar().bar().bar().baz(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: unable to infer the value of a const parameter ``` to ``` error[E0282]: type annotations needed --> $DIR/method-chain.rs:21:33 | LL | Foo.bar().bar().bar().bar().baz(); | ^^^ | = note: cannot infer the value of the const parameter `N` ``` r? @varkor
2020-09-16Rollup merge of #76695 - iximeow:trait-generic-bound-suggestion, r=estebankDylan DPC-2/+59
fix syntax error in suggesting generic constraint in trait parameter suggest `where T: Foo` for the first bound on a trait, then suggest `, T: Foo` when the suggested bound would add to an existing set of `where` clauses. `where T: Foo` may be the first bound if `T` has a default, because we'd rather suggest ``` trait A<T=()> where T: Copy ``` than ``` trait A<T: Copy=()> ``` for legibility reasons. the test case i added here is derived from [this reproduction](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0bf3ace9f2a183d0bdbd748c6b8e3971): ``` struct B<T: Copy> { t: T } trait A<T = ()> { fn returns_constrained_type(&self, t: T) -> B<T> { B { t } } } ``` where the suggested fix, ``` trait A<T = ()>, T: Copy { ... } ``` is in fact invalid syntax! i also found an error in the existing suggestion for `trait Base<T = String>: Super<T>` where rustc would suggest `trait Base<T = String>: Super<T>, T: Copy`, but `T: Copy` is the first of the trait's `where` clauses and should be `where T: Copy` as well. the test for that suggestion expects invalid syntax, and has been revised to a compiler-pleasing `trait Base<T = String>: Super<T> where T: Copy`. judging by https://github.com/rust-lang/rust/pull/70009 i'll.. cc @estebank ?
2020-09-16Rollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, ↵Ralf Jung-20/+0
r=jyn514 Move Various str tests in library Moved various string ui tests in library as a part of #76268 r? @matklad
2020-09-16Rollup merge of #76366 - ayushmishra2005:arith_tests_in_library, r=jyn514Ralf Jung-41/+0
Add Arith Tests in Library Added Arith Tests library as a part of #76268 r? @matklad
2020-09-16Rollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morseRalf Jung-67/+0
Make all methods of `Duration` unstably const Make the following methods of `Duration` unstable const under `duration_const_2`: - `from_secs_f64` - `from_secs_f32` - `mul_f64` - `mul_f32` - `div_f64` - `div_f32` This results in all methods of `Duration` being (unstable) const. Moved the tests to `library` as part of #76268. Possible because of #72449, which made the relevant `f32` and `f64` methods const. Tracking issue: #72440 r? @ecstatic-morse
2020-09-16Rollup merge of #76689 - jyn514:update-pulldown, r=GuillaumeGomezDylan DPC-0/+17
Upgrade to pulldown-cmark 0.8.0 Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs! - Get rid of unnecessary `RefCell` - Fix duplicate warnings for broken implicit reference link - Remove unnecessary copy of links Closes https://github.com/rust-lang/rust/issues/73264, closes https://github.com/rust-lang/rust/issues/76687. r? @euclio I'm not sure if the switch away from `locate` fixes any open bugs - euclio mentioned some in https://github.com/raphlinus/pulldown-cmark/issues/165, but I didn't see any related issues open for rustdoc. Let me know if I missed one.
2020-09-16Rollup merge of #75886 - erikdesjardins:index, r=nikicDylan DPC-0/+78
Test that bounds checks are elided for [..index] after .position() Closes #73396. This was fixed by the LLVM 11 update in #73526.
2020-09-16Rollup merge of #75304 - Aaron1011:feature/diag-deref-move-out, r=estebankDylan DPC-5/+87
Note when a a move/borrow error is caused by a deref coercion Fixes #73268 When a deref coercion occurs, we may end up with a move error if the base value has been partially moved out of. However, we do not indicate anywhere that a deref coercion is occuring, resulting in an error message with a confusing span. This PR adds an explicit note to move errors when a deref coercion is involved. We mention the name of the type that the deref-coercion resolved to, as well as the `Deref::Target` associated type being used.
2020-09-15improve diagnostics for lifetime after `&mut`SNCPlay42-0/+74
2020-09-15Auto merge of #76171 - estebank:turbofish-the-revenge, r=davidtwcobors-3/+101
Detect turbofish with multiple type params missing leading `::` Fix #76072.
2020-09-15This commit introduces the following changes:Hameer Abbasi-5/+59
* Change error message for type param in a const expression when using min_const_generics * Change ParamInNonTrivialAnonConst to contain an extra bool used for distinguishing whether the passed-in symbol is a type or a value.
2020-09-14Test that bounds checks are elided for indexing after .[r]position()Erik Desjardins-0/+78
2020-09-15Auto merge of #76612 - estebank:pat-missing-fields-suggestion, r=davidtwcobors-29/+47
Provide suggestion for missing fields in patterns
2020-09-14Auto merge of #75608 - estebank:suggest-boxed-match-exprs, r=lcnr,varkorbors-39/+277
More structured suggestions for boxed trait objects instead of impl Trait on non-coerceable tail expressions When encountering a `match` or `if` as a tail expression where the different arms do not have the same type *and* the return type of that `fn` is an `impl Trait`, check whether those arms can implement `Trait` and if so, suggest using boxed trait objects. Use structured suggestion for `impl T` to `Box<dyn T>`. Fix https://github.com/rust-lang/rust/issues/69107
2020-09-14Detect turbofish with multiple type params missing leading `::`Esteban Küber-3/+101
Fix #76072.
2020-09-14Auto merge of #75740 - GuillaumeGomez:stabilize-doc-alias-feature, r=ollie27bors-16/+0
Stabilize doc_alias feature Fixes #50146. This PR intend to stabilize the `doc_alias` feature. The last remaining bits were missing checks on the attribute usage and on its arguments. Both have been added so I think we can now move to the next step. r? `@ollie27` cc `@rust-lang/rustdoc`
2020-09-14Stabilize doc_alias featureGuillaume Gomez-16/+0
2020-09-14Auto merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514bors-0/+46
Ignore rustc_private items from std docs By ignoring rustc_private items for non local impl block, this may fix #74672 and fix #75588 . This might suppress #76529 if it is simple enough for backport.
2020-09-14improve const infer errBastian Kauschke-7/+7
2020-09-14shrink const infer errorBastian Kauschke-4/+48
2020-09-13fix syntax error in suggesting generic constraint in trait parameteriximeow-2/+59
suggest `where T: Foo` for the first bound on a trait, then suggest `, T: Foo` when the suggested bound would add to an existing set of `where` clauses. `where T: Foo` may be the first bound if `T` has a default, because we'd rather suggest ``` trait A<T=()> where T: Copy ``` than ``` trait A<T: Copy=()> ``` for legibility reasons.
2020-09-14Auto merge of #76195 - lcnr:const-Self, r=varkorbors-4/+92
allow concrete self types in consts This is quite a bad hack to fix #75486. There might be a better way to check if the self type depends on generic parameters, but I wasn't able to come up with one. r? `@varkor` cc `@petrochenkov`
2020-09-14Auto merge of #76123 - tmiasko:inline-args-storage, r=wesleywiserbors-0/+30
inliner: Emit storage markers for introduced arg temporaries When introducing argument temporaries during inlining, emit storage marker statements just before the assignment and in the beginning of the return block. This ensures that such temporaries will not be considered live across yield points after inlining inside a generator. Fixes #71793.
2020-09-13Don't use `link.span` yetJoshua Nelson-2/+2
This shows the span of the _whole_ link, including the brackets. But rustdoc only wants to warn about the link text.
2020-09-13Upgrade to pulldown-cmark 0.8.0Joshua Nelson-0/+17
Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs! - Get rid of unnecessary `RefCell` - Fix duplicate warnings for broken implicit reference link - Remove unnecessary copy of links
2020-09-13bless testsBastian Kauschke-4/+8
2020-09-13review, improve note spanBastian Kauschke-12/+6
2020-09-13allow concrete self types in constsBastian Kauschke-0/+90
2020-09-13Rollup merge of #75559 - RalfJung:union-test-move, r=joshtriplettJonas Schievink-1/+94
unions: test move behavior of non-Copy fields This test ensures the behaviors suggested by @petrochenkov [here](https://github.com/rust-lang/rust/issues/32836#issuecomment-242511491).
2020-09-13Auto merge of #76244 - vandenheuvel:remove__paramenv__def_id, r=nikomatsakisbors-3/+3
Removing the `def_id` field from hot `ParamEnv` to make it smaller This PR addresses https://github.com/rust-lang/rust/issues/74865.
2020-09-13rebase falloutRalf Jung-1/+1
2020-09-13make union-drop mem::forget test meaningfulRalf Jung-4/+4
2020-09-13please tidyRalf Jung-1/+1
2020-09-13unions: test move behavior of non-Copy fieldsRalf Jung-0/+93
2020-09-13Auto merge of #76623 - slightlyoutofphase:master, r=jyn514bors-3/+21
Use `is_unstable_const_fn` instead of `is_min_const_fn` in rustdoc where appropriate This closes #76501. Specifically, it allows for nightly users with the `#![feature(const_fn)]` flag enabled to still have their `const fn` declarations documented as such, while retaining the desired behavior that rustdoc *not* document functions that have the `rustc_const_unstable` attribute as `const`.
2020-09-13Auto merge of #76598 - ad-anssi:diagnostic_errors_fix, r=estebankbors-0/+35
Fixing memory exhaustion when formatting short code suggestion Details can be found in issue #76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.
2020-09-13Auto merge of #76658 - Aaron1011:fix/encode-dummy-loc-span, r=lcnrbors-157/+159
Properly encode spans with a dummy location and non-root `SyntaxContext` Previously, we would throw away the `SyntaxContext` of any span with a dummy location during metadata encoding. This commit makes metadata Span encoding consistent with incr-cache Span encoding - an 'invalid span' tag is only used when it doesn't lose any information.
2020-09-13Add ui test for 74672 and 76571Lzu Tao-0/+46
These tests will fall without the next commit.
2020-09-13Auto merge of #76585 - Aaron1011:ignore-vert-plus, r=petrochenkovbors-0/+149
Ignore `|` and `+` tokens during proc-macro pretty-print check Fixes #76182 This is an alternative to PR #76188 These tokens are not preserved in the AST in certain cases (e.g. a leading `|` in a pattern or a trailing `+` in a trait bound). This PR ignores them entirely during the pretty-print/reparse check to avoid spuriously using the re-parsed tokenstream.
2020-09-12Properly encode spans with a dummy location and non-root `SyntaxContext`Aaron Hill-157/+159
Previously, we would throw away the `SyntaxContext` of any span with a dummy location during metadata encoding. This commit makes metadata Span encoding consistent with incr-cache Span encoding - an 'invalid span' tag is only used when it doesn't lose any information.
2020-09-12Auto merge of #73461 - calebzulawski:validate-attribute-placement, ↵bors-429/+962
r=matthewjasper Validate built-in attribute placement Closes #54584, closes #47725, closes #54044. I've changed silently ignoring some incorrectly placed attributes to errors. I'm not sure what the policy is since this can theoretically break code (should they be warnings instead? does it warrant a crater run?).
2020-09-12Auto merge of #76538 - ↵bors-0/+39
fusion-engineering-forks:check-useless-unstable-trait-impl, r=lcnr Warn for #[unstable] on trait impls when it has no effect. Earlier today I sent a PR with an `#[unstable]` attribute on a trait `impl`, but was informed that this attribute has no effect there. (comment: https://github.com/rust-lang/rust/pull/76525#issuecomment-689678895, issue: https://github.com/rust-lang/rust/issues/55436) This PR adds a warning for this situation. Trait `impl` blocks with `#[unstable]` where both the type and the trait are stable will result in a warning: ``` warning: An `#[unstable]` annotation here has no effect. See issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information. --> library/std/src/panic.rs:235:1 | 235 | #[unstable(feature = "integer_atomics", issue = "32976")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` --- It detects three problems in the existing code: 1. A few `RefUnwindSafe` implementations for the atomic integer types in `library/std/src/panic.rs`. Example: https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/panic.rs#L235-L236 2. An implementation of `Error` for `LayoutErr` in `library/std/srd/error.rs`: https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/error.rs#L392-L397 3. `From` implementations for `Waker` and `RawWaker` in `library/alloc/src/task.rs`. Example: https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/alloc/src/task.rs#L36-L37 Case 3 interesting: It has a bound with an `#[unstable]` trait (`W: Wake`), so appears to have much effect on stable code. It does however break similar blanket implementations. It would also have immediate effect if `Wake` was implemented for any stable type. (Which is not the case right now, but there are no warnings in place to prevent it.) Whether this case is a problem or not is not clear to me. If it isn't, adding a simple `c.visit_generics(..);` to this PR will stop the warning for this case.
2020-09-12Add test for ignored private doc testGuillaume Gomez-2/+14
2020-09-12Give functions unique namesSlightlyOutOfPhase-2/+2
2020-09-12Fix `const-display.rs` XPATH queries (#1)SlightlyOutOfPhase-3/+21
* Fix `const-display.rs` XPATH queries * Add `issue_76501.rs` test file * Rename issue_76501.rs to issue-76501.rs