about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2021-02-18Rollup merge of #82246 - jesusprubio:add-long-explanation-e0549, ↵Dylan DPC-1/+1
r=GuillaumeGomez Add long explanation for E0549 Helps with #61137
2021-02-18Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkorDylan DPC-33/+33
Replace if-let and while-let with `if let` and `while let` This pull request replaces if-let and while-let with `if let` and `while let`. closes https://github.com/rust-lang/rust/issues/82205
2021-02-18Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkovDylan DPC-1/+21
In some limited cases, suggest `where` bounds for non-type params Partially address #81971.
2021-02-18Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkorDylan DPC-0/+34
const_generics: Dont evaluate array length const when handling yet another error Same ICE as #82009 except triggered by a different error. cc ``@lcnr`` r? ``@varkor``
2021-02-18Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726Dylan DPC-76/+298
Ensure valid TraitRefs are created for GATs This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`. r? ````@jackh726````
2021-02-18Rollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPCYuki Okushi-17/+3
Move some tests to more reasonable directories - 4 cc #81941
2021-02-18Rollup merge of #82055 - JulianKnodt:ty_where_const, r=estebankYuki Okushi-14/+84
Add diagnostics for specific cases for const/type mismatch err For now, this adds at least more information so better diagnostics can be emitted for const mismatch errors. I'm not sure what exactly we want to emit, so I've left notes there temporarily, also to see if this is the right approach r? ```@lcnr``` cc: ```@estebank```
2021-02-18Add long explanation for E0549Jesus Rubio-1/+1
2021-02-17Rollup merge of #82021 - csmoe:issue-78600, r=tmandryDylan DPC-0/+23
Spell out nested Self type in lint message Closes #78600 r? `@tmandry`
2021-02-17Rollup merge of #82007 - sexxi-goose:reborrow, r=nikomatsakisDylan DPC-46/+346
Implement reborrow for closure captures The strategy for captures is detailed here with examples: https://hackmd.io/PzxYMPY4RF-B9iH9uj9GTA Key points: - We only need to reborrow a capture in case of move closures. - If we mutate something via a `&mut` we store it as a `MutBorrow`/`UniqueMuBorrow` of the path containing the `&mut`, - Similarly, if it's read via `&` ref we just store it as a `ImmBorrow` of the path containing the `&` ref. - If a path doesn't deref a `&mut`, `&`, then that path is captured by Move. - If the use of a path results in a move when the closure is called, then that path is truncated before any deref and the truncated path is moved into the closure. - In the case of non-move closure if a use of a path results in a move, then the path is truncated before any deref and the truncated path is moved into the closure. Note that the implementation differs a bit from the document to allow for truncated path to be used in the ClosureKind analysis that happens as part of the first capture analysis pass. Closes: https://github.com/rust-lang/project-rfc-2229/issues/31 r? ````@nikomatsakis````
2021-02-17Rollup merge of #81972 - matthewjasper:hrtb-error-cleanup, r=nikomatsakisDylan DPC-343/+155
Placeholder lifetime error cleanup - Remove note of trait definition - Avoid repeating the same self type - Use original region names when possible - Use this error kind more often - Print closure signatures when they are suppose to implement `Fn*` traits Works towards #57374 r? ```@nikomatsakis```
2021-02-17Rollup merge of #81869 - mark-i-m:leading-vert, r=petrochenkovDylan DPC-211/+73
Simplify pattern grammar, improve or-pattern diagnostics This implements the change under FCP in https://github.com/rust-lang/rust/issues/81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2). Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc. r? `@petrochenkov`
2021-02-17Rollup merge of #81860 - osa1:issue81800, r=estebankDylan DPC-0/+21
Fix SourceMap::start_point `start_point` needs to return the *first* character's span, but it would previously call `find_width_of_character_at_span` which returns the span of the *last* character. The implementation is now fixed. Other changes: - Docs for start_point, end_point, find_width_of_character_at_span updated - Minor simplification in find_width_of_character_at_span code Fixes #81800
2021-02-17Auto merge of #82235 - GuillaumeGomez:rollup-oflxc08, r=GuillaumeGomezbors-19/+155
Rollup of 11 pull requests Successful merges: - #79981 (Add 'consider using' message to overflowing_literals) - #82094 (To digit simplification) - #82105 (Don't fail to remove files if they are missing) - #82136 (Fix ICE: Use delay_span_bug for mismatched subst/hir arg) - #82169 (Document that `assert!` format arguments are evaluated lazily) - #82174 (Replace File::create and write_all with fs::write) - #82196 (Add caveat to Path::display() about lossiness) - #82198 (Use internal iteration in Iterator::is_sorted_by) - #82204 (Update books) - #82207 (rustdoc: treat edition 2021 as unstable) - #82231 (Add long explanation for E0543) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-17Rollup merge of #82231 - jesusprubio:add-long-explanation-e0543, ↵Guillaume Gomez-1/+1
r=GuillaumeGomez Add long explanation for E0543 Helps with #61137
2021-02-17Rollup merge of #82169 - not-an-aardvark:assert-lazy-format-expressions, ↵Guillaume Gomez-0/+12
r=sfackler Document that `assert!` format arguments are evaluated lazily It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example: ```rust assert!( some_condition, "The state is invalid. Details: {}", expensive_call_to_get_debugging_info(), ); ``` It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
2021-02-17Rollup merge of #82136 - edward-shen:mismatched-subst-and-hir, r=lcnrGuillaume Gomez-0/+68
Fix ICE: Use delay_span_bug for mismatched subst/hir arg Fixes #82126.
2021-02-17Rollup merge of #82105 - nagisa:nagisa/ensure-removed, r=petrochenkovGuillaume Gomez-0/+7
Don't fail to remove files if they are missing In the backend we may want to remove certain temporary files, but in certain other situations these files might not be produced in the first place. We don't exactly care about that, and the intent is really that these files are gone after a certain point in the backend. Here we unify the backend file removing calls to use `ensure_removed` which will attempt to delete a file, but will not fail if it does not exist (anymore). The tradeoff to this approach is, of course, that we may miss instances were we are attempting to remove files at wrong paths due to some bug – compilation would silently succeed but the temporary files would remain there somewhere.
2021-02-17Rollup merge of #79981 - camelid:overflowing_literals-inference-error, r=lcnrGuillaume Gomez-18/+67
Add 'consider using' message to overflowing_literals Fixes #79744. Ironically, the `overflowing_literals` handler for binary or hex already had this message! You would think it would be the other way around :) cc ```@scottmcm```
2021-02-17In some limited cases, suggest `where` bounds for non-type paramsEsteban Küber-1/+21
Partially address #81971.
2021-02-17Add long explanation for E0543Jesus Rubio-1/+1
2021-02-17replace if-let and while-let with `if let` and `while let`Takayuki Maeda-33/+33
2021-02-16Move some tests to more reasonable directoriesCaio-17/+3
2021-02-16Ensure debug_assert! tests get runTeddy Katz-0/+1
2021-02-17Use -Ccodegen-units=1 to make issue-23458 test deterministicTomasz Miąsko-1/+1
The test case fails with either one error or two errors. Use a single code generation unit to avoid nondeterminism.
2021-02-16Remove ordering hintkadmin-2/+0
2021-02-16Rollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obkGuillaume Gomez-10/+37
validation: fix invalid-fn-ptr error message https://github.com/rust-lang/rust/pull/82061 changed the code here to print an `ImmTy` instead of a `ScalarMaybeUninit`; that was an accident. So go back to printing a `ScalarMaybeUninit`. r? ```@oli-obk```
2021-02-16Rollup merge of #82161 - jesusprubio:add-long-explanation-e0545, ↵Guillaume Gomez-1/+2
r=GuillaumeGomez Add long explanation for E0545 Helps with #61137
2021-02-16add testRalf Jung-10/+37
2021-02-16Document that `assert!` format arguments are evaluated lazilyTeddy Katz-0/+11
It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example: ```rust assert!( some_condition, "The state is invalid. Details: {}", expensive_call_to_get_debugging_info(), ); ``` It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
2021-02-16Update w/ commentskadmin-16/+68
2021-02-15Treat read of COpy types via refs as not move in move-closureAman Arora-34/+248
2021-02-15Handle restricting closure originAman Arora-0/+39
2021-02-15Implement reborrow for closure capturesAman Arora-12/+59
2021-02-15Add long explanation for E0545Jesus Rubio-1/+2
2021-02-15Simplify pattern grammar by allowing nested leading vertmark-211/+73
Along the way, we also implement a handful of diagnostics improvements and fixes, particularly with respect to the special handling of `||` in place of `|` and when there are leading verts in function params, which don't allow top-level or-patterns anyway.
2021-02-15Rollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obkJonas Schievink-0/+24
const_generics: Fix incorrect ty::ParamEnv::empty() usage Fixes #80561 Not sure if I should keep the `debug!(..)`s or not but its the second time I've needed them so they sure seem useful lol cc ``@lcnr`` r? ``@oli-obk``
2021-02-15Rollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obkJonas Schievink-1/+1
CTFE validation: catch ReadPointerAsBytes and better error r? ``@oli-obk`` Fixes https://github.com/rust-lang/rust/issues/79690 Cc https://github.com/rust-lang/miri/issues/1706
2021-02-15Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkorJonas Schievink-0/+35
const_generics: Dont evaluate array length const when handling errors Fixes #79518 Fixes #78246 cc ````@lcnr```` This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter r? ````@varkor````
2021-02-15Rollup merge of #81897 - ↵Jonas Schievink-0/+29
vandenheuvel:match_exhaustive_diagnostics_regression_test, r=Mark-Simulacrum Add match pattern diagnostics regression test Closes #72377 by adding a regression test. This test case fails on stable but now works on beta and nightly. It *should* have worked already for years, the crucial point whether it is mentioned that some uncovered patterns are not explicitly mentioned.
2021-02-15Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebankJonas Schievink-0/+22
Suggest to create a new `const` item if the `fn` in the array is a `const fn` Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary. Example: ```rust fn main() { // Should not compile but hint to create a new const item (stable) or an inline const block (nightly) let strings: [String; 5] = [String::new(); 5]; println!("{:?}", strings); } ``` Gives this error: ``` error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:3:32 | 2 | let strings: [String; 5] = [String::new(); 5]; | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String` | = note: the `Copy` trait is required because the repeated element will be copied ``` With this change, this is the error message: ``` error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:3:32 | LL | let strings: [String; 5] = [String::new(); 5]; | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | = help: moving the function call to a new `const` item will resolve the error ```
2021-02-15the environment round here is awfully emptyEllen-0/+34
capitalism
2021-02-15Fix test issue referenceEdward Shen-1/+1
2021-02-14Use delay_span_bug for mismatched subst/hir argEdward Shen-0/+68
2021-02-14Don't fail to remove files if they are missingSimonas Kazlauskas-0/+7
In the backend we may want to remove certain temporary files, but in certain other situations these files might not be produced in the first place. We don't exactly care about that, and the intent is really that these files are gone after a certain point in the backend. Here we unify the backend file removing calls to use `ensure_removed` which will attempt to delete a file, but will not fail if it does not exist (anymore). The tradeoff to this approach is, of course, that we may miss instances were we are attempting to remove files at wrong paths due to some bug – compilation would silently succeed but the temporary files would remain there somewhere.
2021-02-14Rollup merge of #82056 - b-naber:mut_for_loop_bug, r=oli-obkDylan DPC-0/+30
fix ice (#82032) Fixes https://github.com/rust-lang/rust/issues/82032
2021-02-14Rollup merge of #81927 - vandenheuvel:issue_32498, r=Mark-SimulacrumDylan DPC-0/+16
Add a regression test for #32498 [This](https://github.com/rust-lang/rust/issues/32498#issuecomment-613626968) test mentioned at issue #32498 now passes. This PR adds this regression test.
2021-02-14Rollup merge of #81914 - kper:fixing-81885, r=estebankDylan DPC-8/+27
Fixing bad suggestion for `_` in `const` type when a function #81885 Closes #81885 ``` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item_help.rs:13:22 | LL | const TEST4: fn() -> _ = 42; | ^ | | | not allowed in type signatures | help: use type parameters instead: `T` ``` Do not show the suggestion `help: use type parameters instead: T` when `fn`
2021-02-14Rollup merge of #81912 - sexxi-goose:Migrations2_review, r=nikomatsakisDylan DPC-0/+232
Implement the precise analysis pass for lint `disjoint_capture_drop_reorder` The precision pass for the lint prevents the lint from triggering for a variable (that was previously entirely captured by the closure) if all paths that need Drop starting at root variable have been captured by the closure. r? `@nikomatsakis`
2021-02-14Rollup merge of #80920 - rylev:check_attr-refactor, r=davidtwcoDylan DPC-6/+31
Visit more targets when validating attributes This begins to address #80048, allowing for additional validation of attributes. There are more refactorings that can be done, though I think they should be tackled in additional PRs: * ICE when a builtin attribute is encountered that is not checked * Move some of the attr checking done `ast_validation` into `rustc_passes` * note that this requires a bit of additional refactoring, especially of extern items which currently parse attributes (and thus are a part of the AST) but do not possess attributes in their HIR representation. * Rename `Target` to `AttributeTarget` * Refactor attribute validation completely to go through `Visitor::visit_attribute`. * This would require at a minimum passing `Target` into this method which might be too big of a refactoring to be worth it. * It's also likely not possible to do all the validation this way as some validation requires knowing what other attributes a target has. r? `@davidtwco`