about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2020-08-26suggest await on unexpected typescsmoe-11/+40
2020-08-25suggest await before methodcsmoe-6/+21
2020-08-25suggest await on field accesscsmoe-40/+33
2020-08-25append more test cases for issue 61076csmoe-4/+58
2020-08-24Rollup merge of #75831 - lzutao:https, r=Dylan-DPCYuki Okushi-1/+1
doc: Prefer https link for wikipedia URLs A tiny changes.
2020-08-23Auto merge of #75656 - tirr-c:match-suggest-semi, r=estebankbors-0/+116
Provide better spans for the match arm without tail expression Resolves #75418. Applied the same logic in the `if`-`else` type mismatch case. r? @estebank
2020-08-23Auto merge of #72449 - ecstatic-morse:const-float-bitcast, r=RalfJungbors-0/+170
Const floating point bitcasts and classification Makes the `f32` and `f64` methods described in #72447 and #72505 unstably const. r? @RalfJung
2020-08-23Fix `compile-flags` directiveecstatic-morse-2/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-08-23Auto merge of #74238 - RalfJung:offset_from, r=oli-obkbors-15/+10
stabilize ptr_offset_from This stabilizes ptr::offset_from, and closes https://github.com/rust-lang/rust/issues/41079. It also removes the deprecated `wrapping_offset_from`. This function was deprecated 19 days ago and was never stable; given an FCP of 10 days and some waiting time until FCP starts, that leaves at least a month between deprecation and removal which I think is fine for a nightly-only API. Regarding the open questions in https://github.com/rust-lang/rust/issues/41079: * Should offset_from abort instead of panic on ZSTs? -- As far as I know, there is no precedent for such aborts. We could, however, declare this UB. Given that the size is always known statically and the check thus rather cheap, UB seems excessive. * Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return usize (like how isize-taking offset is more conveniently done with usize-taking add these days)? -- No reason to block stabilization on that, we can always add such methods later. Also nominating the lang team because this exposes an intrinsic. The stabilized method is best described [by its doc-comment](https://github.com/RalfJung/rust/blob/56d4b2d69abb93e4f0ca79471deca7aaaaeca214/src/libcore/ptr/const_ptr.rs#L227). The documentation forgot to mention the requirement that both pointers must "have the same provenance", aka "be derived from pointers to the same allocation", which I am adding in this PR. This is a precondition that [Miri already implements](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a3b9d0a07a01321f5202cd99e9613480) and that, should LLVM ever obtain a `psub` operation to subtract pointers, will likely be required for that operation (following the semantics in [this paper](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf)).
2020-08-23Prefer https link for wikipedia URLsLzu Tao-1/+1
2020-08-23Auto merge of #75465 - Aaron1011:feature/short-fn-def-span, r=estebankbors-543/+252
Use smaller def span for functions Currently, the def span of a function encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); } ``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-23Auto merge of #73084 - Aaron1011:feature/new-recursive-expand, r=petrochenkovbors-62/+172
Re-land PR #72388: Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro` PR #72388 allowed us to preserve the original `TokenStream` in more cases during proc-macro expansion, but had to be reverted due to a large number of regressions (See #72545 and #72622). These regressions fell into two categories 1. Missing handling for `Group`s with `Delimiter::None`, which are inserted during `macro_rules!` expansion (but are lost during stringification and re-parsing). A large number of these regressions were due to `syn` and `proc-macro-hack`, but several crates needed changes to their own proc-macro code. 2. Legitimate hygiene issues that were previously being masked by stringification. Some of these were relatively benign (e.g. [a compiliation error](https://github.com/paritytech/parity-scale-codec/pull/210) caused by misusing `quote_spanned!`). However, two crates had intentionally written unhygenic `macro_rules!` macros, which were able to access identifiers that were not passed as arguments (see https://github.com/rust-lang/rust/issues/72622#issuecomment-636402573). All but one of the Crater regressions have now been fixed upstream (see https://hackmd.io/ItrXWRaSSquVwoJATPx3PQ?both). The remaining crate (which has a PR pending at https://github.com/sammhicks/face-generator/pull/1) is not on `crates.io`, and is a Yew application that seems unlikely to have any reverse dependencies. As @petrochenkov mentioned in https://github.com/rust-lang/rust/issues/72545#issuecomment-638632434, not re-landing PR #72388 allows more crates to write unhygenic `macro_rules!` macros, which will eventually stop compiling. Since there is only one Crater regression remaining, since additional crates could write unhygenic `macro_rules!` macros in the time it takes that PR to be merged.
2020-08-22Use smaller def span for functionsAaron Hill-543/+252
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-22Add backwards-compat hack for certain '$name' tokensAaron Hill-0/+60
See issue #74616
2020-08-22Recursively expand `TokenKind::Interpolated` (take 2)Aaron Hill-62/+112
Fixes #68430 This is a re-attempt of PR #72388, which was previously reverted due to a large number of breakages. All of the known breakages should now be patched upstream.
2020-08-22Test new floating point bit castsDylan MacKenzie-0/+170
2020-08-22Auto merge of #74566 - lzutao:guard, r=petrochenkovbors-0/+430
Gate if-let guard feature Enhanced on #74315. That PR is in crater queue so I don't want to push to it. Close #74232 cc #51114
2020-08-22remove feature gate from testsRalf Jung-15/+10
2020-08-22Rollup merge of #75771 - tmiasko:const-eval-query-stack-normalize, ↵Dylan DPC-2/+3
r=jonas-schievink Extend normalization in const-eval-query-stack test Builds with debuginfo have additional information in backtrace.
2020-08-21Auto merge of #75697 - lzutao:mir-dumb-const-prefix, r=oli-obkbors-13/+13
Suppress "const" prefix of FnDef constants in MIR dump I [was asked][1] to suppress the `const` infront of `FnDef`. I tried to suppress comments for other types, but turned out that `const ()` and `()` is different: https://github.com/rust-lang/rust/pull/75697#discussion_r473892806 [1]: https://github.com/rust-lang/rust/pull/75670#issuecomment-675574333
2020-08-21Rollup merge of #75532 - tmiasko:rfc-1014, r=nikomatsakisYuki Okushi-2/+4
Fix RFC-1014 test Use two printlns when testing that writing to a closed stdout does not panic. Otherwise the test is ineffective, since the current implementation silently ignores the error during first println regardless.
2020-08-21Auto merge of #74846 - Aaron1011:fix/pat-token-capture, r=petrochenkovbors-2/+55
Capture tokens for Pat used in macro_rules! argument This extends PR #73293 to handle patterns (Pat). Unlike expressions, patterns do not support custom attributes, so we only need to capture tokens during macro_rules! argument parsing.
2020-08-21Suppress "const" prefix of FnDef in MIR dumpLzu Tao-13/+13
2020-08-21Extend normalization in const-eval-query-stack testTomasz Miąsko-2/+3
Builds with debuginfo have additional information in backtrace.
2020-08-20Auto merge of #75494 - matthewjasper:defer-recursive-projection-error, ↵bors-47/+103
r=nikomatsakis Don't immediately error for cycles during normalization #73452 meant some normalization cycles could be detected earlier, breaking some code. This PR makes defers errors for normalization cycles to fulfillment, fixing said code. Fixes #74868 r? @nikomatsakis
2020-08-20Don't immediately error for cycles during normalizationMatthew Jasper-47/+103
2020-08-20Rollup merge of #75710 - ThibsG:FixBadPrinting75447, r=oli-obkJosh Stone-1/+40
Fix bad printing of const-eval queries Fixes: #75447 r? @RalfJung cc @oli-obk
2020-08-20Rollup merge of #75703 - tmiasko:stack-overflow-musl, r=cuviperJosh Stone-2/+0
Enable stack-overflow detection on musl for non-main threads
2020-08-20Set RUST_BACKTRACE env variableThibsG-1/+2
2020-08-20Capture tokens for Pat used in macro_rules! argumentAaron Hill-2/+55
This extends PR #73293 to handle patterns (Pat). Unlike expressions, patterns do not support custom attributes, so we only need to capture tokens during macro_rules! argument parsing.
2020-08-20Auto merge of #75595 - ↵bors-0/+17
davidtwco:polymorphization-predicate-simplification-correction, r=eddyb polymorphize: if any param in a predicate is used, then all are used Addresses [review](https://github.com/rust-lang/rust/pull/75518#discussion_r470907646) [comments](https://github.com/rust-lang/rust/pull/75518#discussion_r470907865) [from](https://github.com/rust-lang/rust/pull/75518#discussion_r470908188) @eddyb in #75518 that I didn't get to resolve before bors merged. This PR modifies polymorphization's handling of predicates so that if any generic parameter is used in a predicate then all parameters in that predicate are used. r? @eddyb
2020-08-19Rollup merge of #75069 - lcnr:type-of-lazy-norm, r=varkorTyler Mandry-384/+155
move const param structural match checks to wfcheck fixes #75047 fixes #74950 We currently check for structural match violations inside of `type_of`. As we need to check the array length when checking if `[NonEq; arr_len]` is structural match, we potentially require the variance of an expression. Computing the variance requires `type_of` for all types though, resulting in a cycle error. r? @varkor @eddyb
2020-08-19Fix bad printing of const-eval queriesThibsG-1/+39
2020-08-19Auto merge of #74098 - GuillaumeGomez:doc-alias-checks, r=ollie27bors-0/+50
Doc alias checks: ensure only items appearing in search index can use it Following the discussion in #73721, I added checks to ensure that only items appearing in the search are allowed to have doc alias. r? @ollie27
2020-08-19Rollup merge of #75658 - tgnottingham:issue-75599, r=estebankYuki Okushi-169/+41
Don't emit "is not a logical operator" error outside of associative expressions Avoid showing this error where it doesn't make sense by not assuming "and" and "or" were intended to mean "&&" and "||" until after we decide to continue parsing input as an associative expression. Note that the decision of whether or not to continue parsing input as an associative expression doesn't actually depend on this assumption. Fixes #75599 --- First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
2020-08-19Rollup merge of #75554 - jumbatm:fix-clashing-extern-decl-overflow, r=lcnrYuki Okushi-0/+119
Fix clashing_extern_declarations stack overflow for recursive types. Fixes #75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
2020-08-19Enable stack-overflow detection on musl for non-main threadsTomasz Miąsko-2/+0
2020-08-18change const param ty warning messageBastian Kauschke-77/+57
2020-08-18run wfcheck in parralel again, add test for 74950Bastian Kauschke-11/+73
2020-08-18move const param structural match checks to wfcheckBastian Kauschke-311/+40
2020-08-18Don't emit "is not a logical operator" error outside of associative expressionsTyson Nottingham-169/+41
Avoid showing this error where it doesn't make sense by not assuming "and" and "or" were intended to mean "&&" and "||" until after we decide to continue parsing input as an associative expression. Note that the decision of whether or not to continue parsing input as an associative expression doesn't actually depend on this assumption. Fixes #75599
2020-08-18Promote missing_fragment_specifier to hard errorAleksey Kladov-37/+16
It has been deny_by_default since 2017 (and warned for some time before that), so it seems reasonable to promote it. The specific technical motivation to do this now is to remove a field from `ParseSess` -- it is a global state, and global state makes extracting libraries annoying. Closes #40107
2020-08-18Move macro test to ui/macrosAleksey Kladov-0/+0
2020-08-18Provide better spans for the match arm without tail expressionWonwoo Choi-0/+116
2020-08-18Auto merge of #75653 - JohnTitor:rollup-0ejtdfo, r=JohnTitorbors-12/+39
Rollup of 8 pull requests Successful merges: - #75389 (attempt to improve span_label docs) - #75392 (Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods) - #75464 (Move to intra doc links for ascii.rs and panic.rs) - #75578 (Allowing raw ptr dereference in const fn) - #75613 (Add explanation for `&mut self` method call when expecting `-> Self`) - #75626 (Clean up E0754 explanation) - #75629 (Use intra-doc links in `std::env`, `std::alloc` and `std::error`) - #75634 (Mark x86_64-linux-kernel as *) Failed merges: r? @ghost
2020-08-18Rollup merge of #75613 - estebank:explain-mut-method, r=petrochenkovYuki Okushi-0/+24
Add explanation for `&mut self` method call when expecting `-> Self` When a user tries to use a method as if it returned a new value of the same type as its receiver, we will emit a type error. Try to detect this and provide extra explanation that the method modifies the receiver in-place. This has confused people in the wild, like in https://users.rust-lang.org/t/newbie-why-the-commented-line-stops-the-snippet-from-compiling/47322
2020-08-18Rollup merge of #75578 - 5M1Sec:master, r=oli-obkYuki Okushi-12/+15
Allowing raw ptr dereference in const fn Reflect on issue #75340 Discussion in previous PR #75425 ## Updates Change `UnsafetyViolationKind::General` to `UnsafetyViolationKind::GeneralAndConstFn` in check_unsafety.rs Remove `unsafe` in min_const_fn_unsafe_bad.rs Bless min_const_fn Add the test case from issue 75340 *** Sorry for the chaos. I messed up and ended up deleting the repo in the last PR. I have to create a new PR for the new repo. I will make a feature branch next time. I will edit the old PR once I receive the commends. @RalfJung Thank you all for your replies. They are helpful! r? @oli-obk
2020-08-17Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obkbors-1/+1
rust_ast::ast => rustc_ast Rework of #71199 which is a rework #70621 Still working on this but just made the PR to track progress r? @Dylan-DPC
2020-08-17Auto merge of #75145 - ↵bors-1/+23
davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov Reference lang items during AST lowering Fixes #60607 and fixes #61019. This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols: - Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#diff-c0f791ead38d2d02916faaad0f56f41d). - ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~ - Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct. - I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#r40107992) but I'd prefer that be left for a follow-up. - I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit. r? @oli-obk cc @matthewjasper
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-1/+1