about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-08-11Update format string tests to explicitly escape multiple newlinesAnton Golov-4/+4
From what I can tell, the goal of the tests is to ensure that the error formatting is correct. I think this is still being tested as intended after this change.
2021-08-11Auto merge of #87587 - oli-obk:lazy_tait, r=spastorinobors-105/+63
Various refactorings of the TAIT infrastructure Before this PR we used to store the opaque type knowledge outside the `InferCtxt`, so it got recomputed on every opaque type instantiation. I also removed a feature gate check that makes no sense in the planned lazy TAIT resolution scheme Each commit passes all tests, so this PR is best reviewed commit by commit. r? `@spastorino`
2021-08-11Auto merge of #87254 - ↵bors-6/+20
rusticstuff:rustc_codegen_llvm_dont_emit_zero_sized_padding, r=eddyb LLVM codegen: Don't emit zero-sized padding for fields Currently padding is emitted before fields of a struct and at the end of the struct regardless of the ABI. Even if no padding is required zero-sized padding fields are emitted. This is not useful and - more importantly - it make it impossible to generate the exact vector types that LLVM expects for certain ARM SIMD intrinsics. This change should unblock the implementation of many ARM intrinsics using the `unadjusted` ABI, see https://github.com/rust-lang/stdarch/issues/1143#issuecomment-827404092. This is a proof of concept only because the field lookup now takes O(number of fields) time compared to O(1) before since it recalculates the mapping at every lookup. I would like to find out how big the performance impact actually is before implementing caching or restricting this behavior to the `unadjusted` ABI. cc `@SparrowLii` `@bjorn3` ([Discussion on internals](https://internals.rust-lang.org/t/feature-request-add-a-way-in-rustc-for-generating-struct-type-llvm-ir-without-paddings/15007))
2021-08-11Rollup merge of #87895 - TheWastl:issue-87872, r=estebankYuki Okushi-0/+48
typeck: don't suggest inaccessible fields in struct literals and suggest ignoring inaccessible fields in struct patterns Fixes #87872. This PR adjusts the missing field diagnostic logic in typeck so that when any of the missing fields in a struct literal or pattern is inaccessible then the error is less confusing, even if some of the missing fields are accessible. See also #76524.
2021-08-11Rollup merge of #87889 - estebank:method-call-disambiguate, r=oli-obkYuki Okushi-14/+16
Use smaller spans when suggesting method call disambiguation Use smaller spans when suggesting method call disambiguation.
2021-08-11Rollup merge of #87854 - BoxyUwU:var-None, r=oli-obkYuki Okushi-0/+24
correctly handle enum variants in `opt_const_param_of` Fixes #87542 `opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics. r? `@oli-obk`
2021-08-11Rollup merge of #87811 - estebank:issue-87549, r=oli-obkYuki Okushi-0/+45
Do not ICE on HIR based WF check when involving lifetimes Fix #87549.
2021-08-10typeck: better diagnostics for missing inaccessible fields in struct ↵TheWastl-0/+48
literals/patterns - typeck/expr: don't suggest adding fields in struct literals with inaccessible fields - typeck/pat: suggest ignoring inaccessible fields in struct patterns
2021-08-09Use smaller spans when suggesting method call disambiguationEsteban Kuber-14/+16
2021-08-09Do not ICE on HIR based WF check when involving lifetimesEsteban Küber-0/+45
Fix #87549.
2021-08-09Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkovbors-13/+18
Fix feature gate checking of static-nobundle and native_link_modifiers Feature native_link_modifiers_bundle don't need feature static-nobundle to work. Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate. ``` > touch lib.rs > rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib > rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static > rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib error[E0658]: kind="static-nobundle" is unstable | = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information = help: add `#![feature(static_nobundle)]` to the crate attributes to enable error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. ``` First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655
2021-08-08Auto merge of #87235 - poliorcetics:issue-87217-fn-quali-order, r=nagisabors-3/+150
Improve diagnostics for wrongly ordered keywords in function declaration Fix #87217 `@rustbot` label A-diagnostics T-compiler
2021-08-08Auto merge of #87697 - GuillaumeGomez:add-e0784, r=nagisabors-10/+10
Assign E0784 error code for union expression errors
2021-08-08 Fix feature gate checking of static-nobundle and native_link_modifiers12101111-13/+18
2021-08-08Auto merge of #87827 - eddyb:wrapperless-mem-replace, r=m-ou-sebors-30/+40
Avoid using the `copy_nonoverlapping` wrapper through `mem::replace`. This is a much simpler way to achieve the pre-#86003 behavior of `mem::replace` not needing dynamically-sized `memcpy`s (at least before inlining), than re-doing #81238 (which needs #86699 or something similar). I didn't notice it until recently, but `ptr::write` already explicitly avoided using the wrapper, while `ptr::read` just called the wrapper (and was the reason for us observing any behavior change from #86003 in Rust-GPU). <hr/> The codegen test I've added fails without the change to `core::ptr::read` like this (ignore the `v0` mangling, I was using a worktree with it turned on by default, for this): ```llvm 13: ; core::intrinsics::copy_nonoverlapping::<u8> 14: ; Function Attrs: inlinehint nonlazybind uwtable 15: define internal void `@_RINvNtCscK5tvALCJol_4core10intrinsics19copy_nonoverlappinghECsaS4X3EinRE8_25mem_replace_direct_memcpy(i8*` %src, i8* %dst, i64 %count) unnamed_addr #0 { 16: start: 17: %0 = mul i64 %count, 1 18: call void `@llvm.memcpy.p0i8.p0i8.i64(i8*` align 1 %dst, i8* align 1 %src, i64 %0, i1 false) not:17 !~~~~~~~~~~~~~~~~~~~~~ error: no match expected 19: ret void 20: } ``` With the `core::ptr::read` change, `core::intrinsics::copy_nonoverlapping` doesn't get instantiated and the test passes. <hr/> r? `@m-ou-se` cc `@nagisa` (codegen test) `@oli-obk` / `@RalfJung` (miri diagnostic changes)
2021-08-08Avoid using the `copy_nonoverlapping` wrapper through `mem::replace`.Eduard-Mihai Burtescu-30/+40
2021-08-08Auto merge of #87815 - BoxyUwU:cec-generics-of-ice, r=eddybbors-0/+81
encode `generics_of` for fields and ty params Fixes #87674 Fixes #87603 ICE was caused by calling `generics_of` on a `DefId` without any `generics_of` results. This was happening when we call `generics_of` on parent `DefId`s of an unevaluated const when we evaluate it. r? `@lcnr`
2021-08-07Auto merge of #87772 - npmccallum:naked_abi, r=Amanieubors-14/+8
Move naked function ABI check to its own lint This check was previously categorized under the lint named `UNSUPPORTED_NAKED_FUNCTIONS`. That lint is future incompatible and will be turned into an error in a future release. However, as defined in the Constrained Naked Functions RFC, this check should only be a warning. This is because it is possible for a naked function to be implemented in such a way that it does not break even the undefined ABI. For example, a `jmp` to a `const`. Therefore, this patch defines a new lint named `UNDEFINED_NAKED_FUNCTION_ABI` which contains just this single check. Unlike `UNSUPPORTED_NAKED_FUNCTIONS`, `UNDEFINED_NAKED_FUNCTION_ABI` will not be converted to an error in the future. rust-lang/rfcs#2774 rust-lang/rfcs#2972
2021-08-07fmtEllen-1/+1
2021-08-07less opt in const param ofEllen-0/+24
2021-08-08Rollup merge of #87789 - tmiasko:panik, r=Mark-SimulacrumYuki Okushi-0/+0
Make vec-shrink-panic test compatible with v0 mangling The v0 mangling includes an instantiating crate in a mangled name, which crates a false positive match for a word `panic`. Rename crate name / test case to avoid the issue.
2021-08-07Rollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obkYuki Okushi-2/+84
Add hint for unresolved associated trait items if the trait has a single item This PR introduces a special-cased hint for unresolved trait items paths. It is shown if: - the path was not resolved to any existing trait item - and no existing trait item's name was reasonably close with regard to edit distance - and the trait only has a single item in the corresponding namespace I didn't know where I should put tests, therefore so far I just managed to bless two existing tests. I would be glad for hints where should tests for a hint like this be created, how should they be named (with reference to the original issue?) and what tests should I create (is it enough to test it just for types? or create separate tests also for functions and constants?). It could also be turned into a machine applicable suggestion I suppose. This is my first `rustc` PR, so please go easy on me :) Fixes: https://github.com/rust-lang/rust/issues/87638
2021-08-06uwuEllen-1/+1
2021-08-06*sprinkles some dust everywhere*Ellen-1/+2
2021-08-06encode `generics_of` of fields and ty paramsEllen-0/+80
2021-08-06bless some nll testsOli Scherer-26/+2
2021-08-06Point to the value instead of the TAIT declaration for obligation failuresOli Scherer-38/+40
2021-08-06Immediately register new opaque types in the global list.Oli Scherer-20/+19
Previously each opaque type instantiation would create new inference vars, even for the same opaque type/substs combination. Now there is a global map in InferCtxt that gets filled whenever we encounter an opaque type.
2021-08-06Remove a useless feature gateingOli Scherer-21/+2
With the planned lazy TAIT system, this will not really make sense anymore anyway.
2021-08-06Add hint for unresolved associated trait items if the trait has a single itemJakub Beránek-2/+84
2021-08-06Rollup merge of #87770 - BoxyUwU:cec-drop-impl, r=lcnrYuki Okushi-0/+16
permit drop impls with generic constants in where clauses Fixes #79248 `==` is not sufficient to check for equality between unevaluated consts which causes the above issue because the const in `[(); N - 1]:` on the impl and the const in `[(); N - 1]:` on the struct def are not seen as equal. Any predicate that can contain an unevaluated const cant use `==` here as it will cause us to incorrectly emit an error. I dont know much about chalk but it seems like we ought to be relating the `TypeWellFormedFromEnv` instead of `==` as it contains a `Ty` so I added that too... r? ``````@lcnr``````
2021-08-06Rollup merge of #87742 - npmccallum:naked_ffi, r=AmanieuYuki Okushi-0/+32
Validate FFI-safety warnings on naked functions Test that FFI-safety warnings don't get accidentally dropped on naked functions. The big picture is that if you implement a naked function with the Rust ABI you'll get a warning. Further, if you implement a naked function with a standardized ABI, but use non-FFI-safe types you will still get a warning. rust-lang/rfcs#2774 rust-lang/rfcs#2972 cc ``````@joshtriplett`````` ``````@Amanieu`````` ``````@haraldh``````
2021-08-06Rollup merge of #87727 - SkiFire13:fix-87718, r=jackh726Yuki Okushi-3/+41
explicit_generic_args_with_impl_trait: fix min expected number of generics Fixes #87718 The problem was that `synth_type_param_count` was already subtracted from `named_type_param_count`, so this ended up being subtracted again. This caused `expected_min` to overflow, and ultimately resulting in weird and wrong behaviour. I've also added another test not present in the original issue but caused by the same bug.
2021-08-06Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeGomezYuki Okushi-1/+2
Add long error explanation for E0625 For #61137.
2021-08-05Fix URL conflict for std typeGuillaume Gomez-1/+1
2021-08-05Add missing root_path when generating links using hrefGuillaume Gomez-3/+9
2021-08-05Generate links for modules as wellGuillaume Gomez-4/+5
2021-08-05Add test for source code pages URLsGuillaume Gomez-0/+55
2021-08-05Ensure that --generate-link-to-definition is only used with HTML output and ↵Guillaume Gomez-0/+24
is unstable
2021-08-05Auto merge of #87740 - npmccallum:naked_args, r=Amanieubors-0/+150
Disable unused variable lint for naked functions In most calling conventions, accessing function parameters may require stack access. However, naked functions have no assembly prelude to set up stack access. This is why naked functions may only contain a single `asm!()` block. All parameter access is done inside the `asm!()` block, so we cannot validate the liveness of the input parameters. Therefore, we should disable the lint for naked functions. rust-lang/rfcs#2774 rust-lang/rfcs#2972 `@joshtriplett` `@Amanieu` `@haraldh`
2021-08-05Make vec-shrink-panic test compatible with v0 manglingTomasz Miąsko-0/+0
The v0 mangling includes an instantiating crate in a mangled name, which crates a false positive match for a word `panic`. Rename crate name / test case to avoid the issue.
2021-08-04Add testcase for proper LLVM representation of SIMD types.Hans Kratz-0/+14
Testcase to make sure that no 0-sized padding is inserted in structs and that structs are represented as expected by Neon intrinsics in LLVM.
2021-08-04Remove 0-sized paddings from field loyout tests.Hans Kratz-6/+6
2021-08-04Auto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakisbors-324/+246
rustc: Fill out remaining parts of C-unwind ABI This commit intends to fill out some of the remaining pieces of the C-unwind ABI. This has a number of other changes with it though to move this design space forward a bit. Notably contained within here is: * On `panic=unwind`, the `extern "C"` ABI is now considered as "may unwind". This fixes a longstanding soundness issue where if you `panic!()` in an `extern "C"` function defined in Rust that's actually UB because the LLVM representation for the function has the `nounwind` attribute, but then you unwind. * Whether or not a function unwinds now mainly considers the ABI of the function instead of first checking the panic strategy. This fixes a miscompile of `extern "C-unwind"` with `panic=abort` because that ABI can still unwind. * The aborting stub for non-unwinding ABIs with `panic=unwind` has been reimplemented. Previously this was done as a small tweak during MIR generation, but this has been moved to a separate and dedicated MIR pass. This new pass will, for appropriate functions and function calls, insert a `cleanup` landing pad for any function call that may unwind within a function that is itself not allowed to unwind. Note that this subtly changes some behavior from before where previously on an unwind which was caught-to-abort it would run active destructors in the function, and now it simply immediately aborts the process. * The `#[unwind]` attribute has been removed and all users in tests and such are now using `C-unwind` and `#![feature(c_unwind)]`. I think this is largely the last piece of the RFC to implement. Unfortunately I believe this is still not stabilizable as-is because activating the feature gate changes the behavior of the existing `extern "C"` ABI in a way that has no replacement. My thinking for how to enable this is that we add support for the `C-unwind` ABI on stable Rust first, and then after it hits stable we change the behavior of the `C` ABI. That way anyone straddling stable/beta/nightly can switch to `C-unwind` safely.
2021-08-04Disable unused variable lint for naked functionsNathaniel McCallum-71/+1
In most calling conventions, accessing function parameters may require stack access. However, naked functions have no assembly prelude to set up stack access. This is why naked functions may only contain a single `asm!()` block. All parameter access is done inside the `asm!()` block, so we cannot validate the liveness of the input parameters. Therefore, we should disable the lint for naked functions. rust-lang/rfcs#2774 rust-lang/rfcs#2972
2021-08-04Add test for naked function unused variables lintNathaniel McCallum-0/+220
This test proves that naked functions are treated the same as regular functions regarding unused function parameters. We will change this behavior in the next patch.
2021-08-04Move naked function ABI check to its own lintNathaniel McCallum-14/+8
This check was previously categorized under the lint named `UNSUPPORTED_NAKED_FUNCTIONS`. That lint is future incompatible and will be turned into an error in a future release. However, as defined in the Constrained Naked Functions RFC, this check should only be a warning. This is because it is possible for a naked function to be implemented in such a way that it does not break even the undefined ABI. For example, a `jmp` to a `const`. Therefore, this patch defines a new lint named `UNDEFINED_NAKED_FUNCTION_ABI` which contains just this single check. Unlike `UNSUPPORTED_NAKED_FUNCTIONS`, `UNDEFINED_NAKED_FUNCTION_ABI` will not be converted to an error in the future. rust-lang/rfcs#2774 rust-lang/rfcs#2972
2021-08-04dropckEllen-0/+16
2021-08-04Fix assertions in `coverage-reports` testAlex Crichton-76/+70
Update some `C-unwind` bits and then
2021-08-04Auto merge of #86197 - FabianWolff:trailing-whitespace, r=JohnTitorbors-242/+242
Remove unnecessary trailing whitespace from error messages Some error messages currently contain unnecessary trailing whitespace. There are some legitimate reasons for having trailing whitespace in the output, such as for uniform indentation of possibly-empty input lines, but the whitespace I have addressed here occurs in a line used only for spacing, and I see no reason why that should have trailing whitespace (spacing lines inserted in other places also don't have trailing whitespace). I have also removed a superfluous call to `buffer.putc()`, which has no effect because the same character is already placed there by `draw_col_separator()`. Use `git diff --ignore-space-at-eol` to see my changes; otherwise the diff is quite large due to the whitespace removed from expected outputs in `src/test/ui/`.