about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-07-26Integrate context into the memorial to AnnaJames Munns-6/+10
2021-07-26Mir borrowck does not generate lifetime variables for 'static lifetimes ↵Oli Scherer-0/+73
during opaque type resolution
2021-07-26Rollup merge of #87458 - ibraheemdev:help-msg-block-borrow, r=oli-obkGuillaume Gomez-1/+33
Fix help message for modification to &T created by &{t} Previous: ```rust error[E0594]: cannot assign to `*x` which is behind a `&` reference --> src/main.rs:3:5 | 2 | let x: &usize = &mut{0}; | ------- help: consider changing this to be a mutable reference: `&mut mut{0}` 3 | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written ```
2021-07-26Rollup merge of #87436 - ebobrow:suggest-semicolon, r=oli-obkGuillaume Gomez-7/+61
Suggest `;` on parse error where applicable fixes #87197
2021-07-26Add test for enum item tuple fields documentationGuillaume Gomez-4/+21
2021-07-262229: Don't capture preicese paths on top of a unionAman Arora-0/+90
- Accessing fields of a union require unsafe block - As part of 2229 we don't allow precision where we need an unsafe block to capture. Fixes: #87378 r? @nikomatsakis
2021-07-25Auto merge of #87390 - notriddle:notriddle/rustdoc-headers-patch, ↵bors-196/+196
r=GuillaumeGomez Rustdoc accessibility: use real headers for doc items Part of #87059 Partially reverts #84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
2021-07-25Rustdoc accessibility: use real headers for doc itemsbors-196/+196
Part of #87059 Partially reverts #84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
2021-07-25Add test for tuple struct documentation fieldsGuillaume Gomez-0/+19
2021-07-25Auto merge of #86595 - a1phyr:allocator_api_for_vecdeque, r=Amanieubors-2/+2
Add support for custom allocator in `VecDeque` This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections. `@rustbot` modify labels: +A-allocators +T-libs
2021-07-25Fix failing testBenoît du Garreau-2/+2
2021-07-25fix help message for modification to &T created by &{t}ibraheemdev-1/+33
2021-07-25Auto merge of #86438 - FabianWolff:issue-83693, r=jackh726bors-0/+87
Fix the ICE described in #83693 This pull request fixes #83693 and fixes #84768.
2021-07-25fix test/ui/borrowck/issue-33819ibraheemdev-1/+1
2021-07-25tidyibraheemdev-1/+1
2021-07-25suggest removing unnecessary \&mut as help messageibraheemdev-35/+35
2021-07-25Auto merge of #85646 - Moxinilian:separate-const-switch, r=cjgillotbors-0/+710
MIR opt: separate constant predecessors of a switch For each block S ending with a switch, this pass copies S for each of S's predecessors that seem to assign the value being switched over as a const. This is done using a somewhat simple heuristic to determine what seems to be a const transitively. More precisely, this is what the pass does: - find a block that ends in a switch - track if there is an unique place set before the current basic block that determines the result of the switch (this is the part that resolves switching over discriminants) - if there is, iterate over the parents that have a reasonable terminator and find if the found determining place is likely to be (transitively) set from a const within that parent block - if so, add the corresponding edge to a vector of edges to duplicate - once this is done, iterate over the found edges: copy the target block and replace the reference to the target block in the origin block with the new block This pass is not optimal and could probably duplicate in more cases, but the intention was mostly to address cases like in #85133 or #85365, to avoid creating new enums that get destroyed immediately afterwards (notably making the new try v2 `?` desugar zero-cost). A benefit of this pass working the way it does is that it is easy to ensure its correctness: the worst that can happen is for it to needlessly copy a basic block, which is likely to be destroyed by cleanup passes afterwards. The complex parts where aliasing matters are only heuristics and the hard work is left to further passes like ConstProp. # LLVM blocker Unfortunately, I believe it would be unwise to enable this optimization by default for now. Indeed, currently switch lowering passes like SimplifyCFG in LLVM lose the information on the set of possible variant values, which means it tends to actually generate worse code with this optimization enabled. A fix would have to be done in LLVM itself. This is something I also want to look into. I have opened [a bug report at the LLVM bug tracker](https://bugs.llvm.org/show_bug.cgi?id=50455). When this is done, I hope we can enable this pass by default. It should be fairly fast and I think it is beneficial in many cases. Notably, it should be a sound alternative to simplify-arm-identity. By the way, ConstProp only seems to pick up the optimization in functions that are not generic. This is however most likely an issue in ConstProp that I will look into afterwards. This is my first contribution to rustc, and I would like to thank everyone on the Zulip mir-opt chat for the help and support, and especially `@scottmcm` for the guidance.
2021-07-25Auto merge of #83723 - cjgillot:ownernode, r=petrochenkovbors-163/+163
Store all HIR owners in the same container This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem. This should allow for a more compact storage. Based on https://github.com/rust-lang/rust/pull/83114
2021-07-25Bless tests.Camille GILLOT-161/+161
2021-07-25Introduce OwnerNode::Crate.Camille GILLOT-2/+2
2021-07-25Add inferred args to typeckkadmin-1/+12
2021-07-25Add generic arg inferkadmin-36/+14
2021-07-25Auto merge of #87381 - Aaron1011:note-semi-trailing-macro, r=petrochenkovbors-0/+2
Display an extra note for trailing semicolon lint with trailing macro Currently, we parse macros at the end of a block (e.g. `fn foo() { my_macro!() }`) as expressions, rather than statements. This means that a macro invoked in this position cannot expand to items or semicolon-terminated expressions. In the future, we might want to start parsing these kinds of macros as statements. This would make expansion more 'token-based' (i.e. macro expansion behaves (almost) as if you just textually replaced the macro invocation with its output). However, this is a breaking change (see PR #78991), so it will require further discussion. Since the current behavior will not be changing any time soon, we need to address the interaction with the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint. Since we are parsing the result of macro expansion as an expression, we will emit a lint if there's a trailing semicolon in the macro output. However, this results in a somewhat confusing message for users, since it visually looks like there should be no problem with having a semicolon at the end of a block (e.g. `fn foo() { my_macro!() }` => `fn foo() { produced_expr; }`) To help reduce confusion, this commit adds a note explaining that the macro is being interpreted as an expression. Additionally, we suggest adding a semicolon after the macro *invocation* - this will cause us to parse the macro call as a statement. We do *not* use a structured suggestion for this, since the user may actually want to remove the semicolon from the macro definition (allowing the block to evaluate to the expression produced by the macro).
2021-07-24Add test for -Z unpretty=thir-treeSmitty-0/+59
2021-07-24Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakisbors-0/+96
dont provide fwd declared params to cg defaults Fixes #83938 ```rust #![feature(const_evaluatable_checked, const_generics, const_generics_defaults)] #![allow(incomplete_features)] pub struct Bar<const N: usize, const M: usize = { N + 1 }>; pub fn foo<const N1: usize>() -> Bar<N1> { loop {} } fn main() {} ``` This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for `Bar<N1>` we would subst the anon ct: `ConstKind::Unevaluated({N + 1}, substs: [N, M])` with substs of `[N1]`. the anon const has forward declared params supplied though so we end up trying to substitute the provided `M` param which causes the ICE. This PR doesn't handle the predicates of the const so ```rust trait Foo<const N: usize> { const Assoc: usize; } pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>; ``` Resolves to `<() as Foo<N>>::Assoc` which can allow for using fwd declared params indirectly. ```rust trait Foo<const N: usize> {} struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>; ``` This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params PR was briefly discussed [in this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/evil.20preds.20in.20param.20env.20.2386580)
2021-07-24fix code to suggest `;` on parse errorElliot Bobrow-7/+61
2021-07-24Rollup merge of #87403 - LeSeulArtichaut:assign-dropping-union, r=oli-obkManish Goregaokar-3/+19
Implement `AssignToDroppingUnionField` in THIR unsafeck r? ``@oli-obk`` cc rust-lang/project-thir-unsafeck#7
2021-07-24Rollup merge of #87359 - jyn514:bless-rustup, r=estebankManish Goregaokar-2/+5
Remove detection of rustup and cargo in 'missing extern crate' diagnostics Previously, this would change the test output when RUSTUP_HOME was set: ``` ---- [ui] ui/issues/issue-49851/compiler-builtins-error.rs stdout ---- diff of stderr: 1 error[E0463]: can't find crate for `core` 2 | 3 = note: the `thumbv7em-none-eabihf` target may not be installed + = help: consider downloading the target with `rustup target add thumbv7em-none-eabihf` 4 5 error: aborting due to previous error 6 ``` Originally, I fixed it by explicitly unsetting RUSTUP_HOME in compiletest. Then I realized that almost no one has RUSTUP_HOME set, since rustup doesn't set it itself. It does set RUST_RECURSION_COUNT whenever it launches a proxy, though - use that instead. r? ```@estebank``` cc ```@petrochenkov``` ```@kinnison```
2021-07-24Rollup merge of #87348 - SkiFire13:fix-87261, r=oli-obkManish Goregaokar-0/+337
Fix span when suggesting to add an associated type bound Fixes #87261 Note that this fix is not perfect, it ~~will still give incorrect~~ won't give suggestions in some situations: - If the associated type is defined on a supertrait of those contained in the opaque type, it will fallback to the previous behaviour, e.g. if `AssocTy` is defined on the trait `Foo`, `Bar` has `Foo` as supertrait and the opaque type is a `impl Bar + Baz`. - If the the associated type is defined on a generic trait and the opaque type includes two versions of that generic trait, e.g. the opaque type is `impl Foo<A> + Foo<B>`
2021-07-24Display an extra note for trailing semicolon lint with trailing macroAaron Hill-0/+2
Currently, we parse macros at the end of a block (e.g. `fn foo() { my_macro!() }`) as expressions, rather than statements. This means that a macro invoked in this position cannot expand to items or semicolon-terminated expressions. In the future, we might want to start parsing these kinds of macros as statements. This would make expansion more 'token-based' (i.e. macro expansion behaves (almost) as if you just textually replaced the macro invocation with its output). However, this is a breaking change (see PR #78991), so it will require further discussion. Since the current behavior will not be changing any time soon, we need to address the interaction with the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint. Since we are parsing the result of macro expansion as an expression, we will emit a lint if there's a trailing semicolon in the macro output. However, this results in a somewhat confusing message for users, since it visually looks like there should be no problem with having a semicolon at the end of a block (e.g. `fn foo() { my_macro!() }` => `fn foo() { produced_expr; }`) To help reduce confusion, this commit adds a note explaining that the macro is being interpreted as an expression. Additionally, we suggest adding a semicolon after the macro *invocation* - this will cause us to parse the macro call as a statement. We do *not* use a structured suggestion for this, since the user may actually want to remove the semicolon from the macro definition (allowing the block to evaluate to the expression produced by the macro).
2021-07-24Auto merge of #87296 - Aaron1011:inert-warn, r=petrochenkovbors-8/+70
Warn on inert attributes used on bang macro invocation These attributes are currently discarded. This may change in the future (see #63221), but for now, placing inert attributes on a macro invocation does nothing, so we should warn users about it. Technically, it's possible for there to be attribute macro on the same macro invocation (or at a higher scope), which inspects the inert attribute. For example: ```rust #[look_for_inline_attr] #[inline] my_macro!() #[look_for_nested_inline] mod foo { #[inline] my_macro!() } ``` However, this would be a very strange thing to do. Anyone running into this can manually suppress the warning.
2021-07-24Auto merge of #86461 - crlf0710:rich_vtable, r=nikomatsakisbors-0/+522
Refactor vtable format for upcoming trait_upcasting feature. This modifies vtable format: 1. reordering occurrence order of methods coming from different traits 2. include `VPtr`s for supertraits where this vtable cannot be directly reused during trait upcasting. Also, during codegen, the vtables corresponding to these newly included `VPtr` will be requested and generated. For the cases where this vtable can directly used, now the super trait vtable has exactly the same content to some prefix of this one. r? `@bjorn3` cc `@RalfJung` cc `@rust-lang/wg-traits`
2021-07-24Remove detection of rustup and cargo in 'missing extern crate' diagnosticsJoshua Nelson-2/+5
Previously, this would change the test output when RUSTUP_HOME was set: ``` ---- [ui] ui/issues/issue-49851/compiler-builtins-error.rs stdout ---- diff of stderr: 1 error[E0463]: can't find crate for `core` 2 | 3 = note: the `thumbv7em-none-eabihf` target may not be installed + = help: consider downloading the target with `rustup target add thumbv7em-none-eabihf` 4 5 error: aborting due to previous error 6 ``` Originally, I fixed it by explicitly unsetting RUSTUP_HOME in compiletest. Then I realized that almost no one has RUSTUP_HOME set, since rustup doesn't set it itself; although it does set RUST_RECURSION_COUNT whenever it launches a proxy. Then it was pointed out that this runtime check doesn't really make sense and it's fine to make it unconditional.
2021-07-24Rollup merge of #87398 - GuillaumeGomez:test-font-module-items, r=notriddleYuki Okushi-0/+4
Add test for fonts used for module items Fixes #85632. r? `@notriddle`
2021-07-24Rollup merge of #87322 - chazkiker2:fix/suggestion-ref-sync-send, r=estebankYuki Okushi-0/+48
fix: clarify suggestion that `&T` must refer to `T: Sync` for `&T: Send` ### Description - [x] fix #86507 - [x] add UI test for relevant code from issue - [x] change `rustc_trait_selection/src/traits/error_reporting/suggestions.rs` to include a more clear suggestion when `&T` fails to satisfy `Send` bounds due to the fact that `T` fails to implement `Sync` - [x] update UI test in Clippy: `src/tools/tests/ui/future_not_send.stderr`
2021-07-24Rollup merge of #87266 - hellow554:issue87076, r=Mark-SimulacrumYuki Okushi-0/+20
Add testcase for 87076 Closes #87076 I also moved the issue tests into the issues subfolder, nothing changed there.
2021-07-23Implement `AssignToDroppingUnionField` in THIR unsafeckLeSeulArtichaut-3/+19
2021-07-23Fix typo in a comment.Vytautas Astrauskas-1/+1
2021-07-23Move obtain-borrowck to run-make-fulldeps.Vytautas Astrauskas-25/+20
2021-07-23Rollup merge of #87383 - Alexendoo:impl_trait_in_bindings-tests, r=oli-obkYuki Okushi-0/+221
Add regression tests for the impl_trait_in_bindings ICEs Closes #54600, closes #54840, closes #58504, closes #58956, closes #70971, closes #79099, closes #84919, closes #86201, closes #86642, closes #87295 r? ``@oli-obk``
2021-07-23Rollup merge of #87373 - Aaron1011:hir-wf-field, r=estebankYuki Okushi-8/+8
Extend HIR WF checking to fields r? ``@estebank``
2021-07-23Rollup merge of #87332 - camelid:dont-hide-fields, r=GuillaumeGomezYuki Okushi-4/+2
Don't hide fields of enum struct variants * The toggle adds visual clutter * It's easy to miss that there are fields * Tuple variant fields are always shown, so it is inconsistent to hide struct variant fields * It's annoying to have to click the toggle every time
2021-07-23Rollup merge of #87298 - boringcactus:patch-2, r=steveklabnikYuki Okushi-0/+3
memorialize Anna Harren in the bastion of the turbofish this seems fitting, at least to me.
2021-07-23Add test for fonts used for module itemsGuillaume Gomez-0/+4
2021-07-23Add regression testGiacomo Stevanato-0/+337
2021-07-23Auto merge of #87287 - oli-obk:fixup_fixup_fixup_opaque_types, r=spastorinobors-194/+136
Make mir borrowck's use of opaque types independent of the typeck query's result fixes #87218 fixes #86465 we used to use the typeck results only to generate an obligation for the mir borrowck type to be equal to the typeck result. When i removed the `fixup_opaque_types` function in #87200, I exposed a bug that showed that mir borrowck can't doesn't get enough information from typeck in order to build the correct lifetime mapping from opaque type usage to the actual concrete type. We therefor now fully compute the information within mir borrowck (we already did that, but we only used it to verify the typeck result) and stop using the typeck information. We will likely be able to remove most opaque type information from the borrowck results in the future and just have all current callers use the mir borrowck result instead. r? `@spastorino`
2021-07-22Squash all commits.chaz-kiker-0/+48
add test for issue 86507 add stderr for issue 86507 update issue-86507 UI test add comment for the expected error in UI test file add proper 'refers to <ref_type>' in suggestion update diagnostic phrasing; update test to match new phrasing; re-organize logic for checking T: Sync evaluate additional obligation to figure out if T is Sync run './x.py test tidy --bless' incorporate changes from review; reorganize logic for readability
2021-07-22Add a test for get_body_with_borrowck_facts.Vytautas Astrauskas-0/+236
2021-07-22Don't hide fields of enum struct variantsNoah Lev-4/+2
* The toggle adds visual clutter * It's easy to miss that there are fields * Tuple variant fields are always shown, so it is inconsistent to hide struct variant fields * It's annoying to have to click the toggle every time
2021-07-22Add regression tests for the impl_trait_in_bindings ICEsAlex Macleod-0/+221