about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-06-12Rollup merge of #73195 - ayazhafiz:i/73145, r=estebankDylan DPC-0/+2025
Provide suggestion to convert numeric op LHS rather than unwrapping RHS Given a code ```rust fn foo(x: u8, y: u32) -> bool { x > y } fn main() {} ``` it could be more helpful to provide a suggestion to do "u32::from(x)" rather than "y.try_into().unwrap()", since the latter may panic. We do this by passing the LHS of a binary expression up the stack into the coercion checker. Closes #73145
2020-06-12Rollup merge of #73163 - ayushmishra2005:61137-add-long-error-code-e0724, ↵Dylan DPC-0/+1
r=davidtwco Add long error explanation for E0724 Add long explanation for the E0724 error code Part of #61137
2020-06-12Rollup merge of #73033 - Amanieu:asm-tls, r=oli-obkDylan DPC-5/+47
Fix #[thread_local] statics as asm! sym operands The `asm!` RFC specifies that `#[thread_local]` statics may be used as `sym` operands for inline assembly. This also fixes a regression in the handling of `#[thread_local]` during monomorphization which caused link-time errors with multiple codegen units, most likely introduced by #71192. r? @oli-obk
2020-06-11Add long error explanation for E0724Ayush Kumar Mishra-0/+1
Minor refactoring Minor refactoring Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co> Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co> Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co> Minor refactoring
2020-06-11Rollup merge of #73230 - Amanieu:asm-unused2, r=petrochenkovDylan DPC-1/+21
Suggest including unused asm arguments in a comment to avoid error We require all arguments to an `asm!` to be used in the template string, just like format strings. However in some cases (e.g. `black_box`) it may be desirable to have `asm!` arguments that are not used in the template string. Currently this is a hard error rather than a lint since `#[allow]` does not work on macros (#63221), so this PR suggests using the unused arguments in an asm comment as a workaround. r? @petrochenkov
2020-06-11Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasperDylan DPC-2/+30
Track span of function in method calls, and use this in #[track_caller] Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-11Rollup merge of #73169 - Amanieu:asm-warnings, r=petrochenkovDylan DPC-1/+16
Handle assembler warnings properly Previously all inline asm diagnostics were treated as errors, but LLVM sometimes emits warnings and notes as well. Fixes #73160 r? @petrochenkov
2020-06-11Rollup merge of #73012 - Aaron1011:feature/span-debug-ctxt, r=matthewjasperDylan DPC-30/+30
Show `SyntaxContext` in formatted `Span` debug output This is only really useful in debug messages, so I've switched to calling `span_to_string` in any place that causes a `Span` to end up in user-visible output.
2020-06-11Rollup merge of #72180 - euclio:rustdoc-test-extra-space, r=Dylan-DPCDylan DPC-0/+22
remove extra space from crate-level doctest names Before: ``` running 2 tests test src/test/rustdoc-ui/doctest-output.rs - foo::bar (line 11) ... ok test src/test/rustdoc-ui/doctest-output.rs - (line 5) ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` After: ``` running 2 tests test src/test/rustdoc-ui/doctest-output.rs - foo::bar (line 11) ... ok test src/test/rustdoc-ui/doctest-output.rs - (line 5) ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ```
2020-06-11fixup! Provide suggestion to convert numeric op LHS rather than unwrapping RHSAyaz Hafiz-138/+463
2020-06-11Provide suggestion to convert numeric op LHS rather than unwrapping RHSAyaz Hafiz-0/+1700
Given a code ```rust fn foo(x: u8, y: u32) -> bool { x > y } fn main() {} ``` it could be more helpful to provide a suggestion to do "u32::from(x)" rather than "y.try_into().unwrap()", since the latter may panic. We do this by passing the LHS of a binary expression up the stack into the coercion checker. Closes #73145
2020-06-11Rollup merge of #73183 - Manishearth:intra-doc-macro, r=GuillaumeGomezDylan DPC-0/+62
Support proc macros in intra doc link resolution The feature was written pre-proc macro resolution, so it only supported the wacky MBE resolution rules. This adds support for proc macros as well. cc @GuillaumeGomez Fixes #73173
2020-06-11Rollup merge of #73164 - GuillaumeGomez:add-e0761, r=petrochenkovDylan DPC-2/+4
Add new E0762 error code
2020-06-11Rollup merge of #72941 - nagisa:ensure-stack-for-match, r=oli-obkDylan DPC-0/+5208
Ensure stack when building MIR for matches In particular matching on complex types such as strings will cause deep recursion to happen. Fixes #72933 r? @matthewjasper @oli-obk
2020-06-11Rollup merge of #72380 - lcnr:const_context, r=estebankDylan DPC-23/+24
Fix `is_const_context`, update `check_for_cast` A better version of #71477 Adds `fn enclosing_body_owner` and uses it in `is_const_context`. `is_const_context` now uses the same mechanism as `mir_const_qualif` as it was previously incorrect. Renames `is_const_context` to `is_inside_const_context`. I also updated `check_for_cast` in the second commit, so r? @estebank (I removed one lvl of indentation, so it might be easier to review by hiding whitespace changes)
2020-06-11Auto merge of #71896 - spastorino:existential-assoc-types-variance, ↵bors-3/+50
r=nikomatsakis Relate existential associated types with variance Invariant Fixes #71550 #72315 r? @nikomatsakis The test case reported in that issue now errors with the following message ... ``` error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in function call due to conflicting requirements --> /tmp/test.rs:25:5 | 25 | bad(&Bar(PhantomData), x) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 24:11... --> /tmp/test.rs:24:11 | 24 | fn extend<'a, T>(x: &'a T) -> &'static T { | ^^ note: ...so that reference does not outlive borrowed content --> /tmp/test.rs:25:28 | 25 | bad(&Bar(PhantomData), x) | ^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible --> /tmp/test.rs:25:9 | 25 | bad(&Bar(PhantomData), x) | ^^^^^^^^^^^^^^^^^ = note: expected `&'static T` found `&T` error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. ``` I could also add that test case if we want to have a weaponized one too.
2020-06-11Add a suggestion to use unused asm arguments in commentsAmanieu d'Antras-1/+21
2020-06-10Fix pprust-expr-roundtripAaron Hill-2/+2
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-0/+28
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-10Add tests for macro@ and derive@Manish Goregaokar-1/+7
2020-06-10Add tests for E0762Guillaume Gomez-2/+4
2020-06-10Rollup merge of #73157 - Aaron1011:where-oh-where-has-my-little-span-gone, ↵Dylan DPC-0/+39
r=ecstatic-morse Don't lose empty `where` clause when pretty-printing Previously, we would parse `struct Foo where;` and `struct Foo;` identically, leading to an 'empty' `where` clause being omitted during pretty printing. This will cause us to lose spans when proc-macros involved, since we will have a collected `where` token that does not appear in the pretty-printed item. We now explicitly track the presence of a `where` token during parsing, so that we can distinguish between `struct Foo where;` and `struct Foo;` during pretty-printing
2020-06-10Rollup merge of #73070 - ayazhafiz:i/72819, r=nikomatsakisDylan DPC-0/+30
Add regression test for const generic ICE in #72819 Closes #72819
2020-06-10Rollup merge of #73023 - ayushmishra2005:remove_noisy_suggestion, r=davidtwcoDylan DPC-69/+25
Remove noisy suggestion of hash_map Remove noisy suggestion of hash_map #72642 fixes #72642
2020-06-10Rollup merge of #73005 - Aaron1011:fix/error-overflow, r=estebankDylan DPC-181/+37
Don't create impl candidates when obligation contains errors Fixes #72839 In PR #72621, trait selection was modified to no longer bail out early when an error type was encountered. This allowed us treat `ty::Error` as `Sized`, causing us to avoid emitting a spurious "not sized" error after a type error had already occured. However, this means that we may now try to match an impl candidate against the error type. Since the error type will unify with almost anything, this can cause us to infinitely recurse (eventually triggering an overflow) when trying to verify certain `where` clauses. This commit causes us to skip generating any impl candidates when an error type is involved.
2020-06-10Rollup merge of #72897 - lcnr:structurally-match-normalize, r=pnkfelixDylan DPC-0/+23
normalize adt fields during structural match checking fixes #72896 currently only fixes the issue itself and compiles stage 1 libs. I believe we have to use something else to normalize the adt fields here, as I expect some partially resolved adts to cause problems :thinking: stage 1 libs and the test itself pass, not sure about the rest... Will spend some more time looking into it tomorrow. r? @pnkfelix cc @eddyb
2020-06-10Rollup merge of #72890 - ↵Dylan DPC-0/+17
davidtwco:issue-66202-normalize-and-transparent-improper-ctypes, r=varkor improper ctypes: normalize return types and transparent structs Fixes #66202. See each commit individually (except the first which adds a test) for more detailed explanations on the changes made. In summary, this PR ensures that return types are normalized before being checked for FFI-safety, and that transparent newtype wrappers are FFI-safe if the type being wrapped is FFI-safe (often true previously, but not if, after substitution, all types in a transparent newtype were zero sized).
2020-06-10Rollup merge of #72789 - petrochenkov:impcand, r=davidtwcoDylan DPC-9/+0
resolve: Do not suggest imports from the same module in which we are resolving Based on the idea from https://github.com/rust-lang/rust/pull/72623.
2020-06-10Avoid collisions between traits and their derive macrosManish Goregaokar-1/+10
2020-06-09Add test for proc macro resolution in intra doc linksManish Goregaokar-0/+47
2020-06-10Rollup merge of #73122 - doctorn:issue-73116, r=varkorDylan DPC-2/+2
Resolve E0584 conflict Adds a new error code (`E0761`) to indicate ambiguity in module file names and an accompanying expanded description to resolve a conflict over `E0584`. Resolves #73116
2020-06-09Relate existential associated types with variance InvariantSantiago Pastorino-3/+50
2020-06-09Handle assembler warnings properlyAmanieu d'Antras-1/+16
2020-06-09lint: transitive FFI-safety for transparent typesDavid Wood-21/+2
This commit ensures that if a `repr(transparent)` newtype's only non-zero-sized field is FFI-safe then the newtype is also FFI-safe. Previously, ZSTs were ignored for the purposes of linting FFI-safety in transparent structs - thus, only the single non-ZST would be checked for FFI-safety. However, if the non-zero-sized field is a generic parameter, and is substituted for a ZST, then the type would be considered FFI-unsafe (as when every field is thought to be zero-sized, the type is considered to be "composed only of `PhantomData`" which is FFI-unsafe). In this commit, for transparent structs, the non-zero-sized field is identified (before any substitutions are applied, necessarily) and then that field's type (now with substitutions) is checked for FFI-safety (where previously it would have been skipped for being zero-sized in this case). To handle the case where the non-zero-sized field is a generic parameter, which is substituted for `()` (a ZST), and is being used as a return type - the `FfiUnsafe` result (previously `FfiPhantom`) is caught and silenced. Signed-off-by: David Wood <david@davidtw.co>
2020-06-09lint: check for unit ret type after normalizationDavid Wood-15/+5
This commit moves the check that skips unit return types to after where the return type has been normalized - therefore ensuring that FFI-safety lints are not emitted for types which normalize to unit. Signed-off-by: David Wood <david@davidtw.co>
2020-06-09improper_ctypes: add test for #66202David Wood-0/+46
This commit adds a test of the improper ctypes lint, checking that return type are normalized bethat return types are normalized before being checked for FFI-safety, and that transparent newtype wrappers are FFI-safe if the type being wrapped is FFI-safe. Signed-off-by: David Wood <david@davidtw.co>
2020-06-09Auto merge of #73153 - ecstatic-morse:revert-71956, r=tmandrybors-2/+44
Revert #71956 ...since it caused unsoundness in #73137. Also adds a reduced version of #73137 to the test suite. The addition of the `MaybeInitializedLocals` dataflow analysis has not been reverted, but it is no longer used. Presumably there is a more targeted fix, but I'm worried that other bugs may be lurking. I'm not yet sure what the root cause of #73137 is. This will need to get backported to beta. r? @tmandry
2020-06-09Remove noisy suggestion of hash_map #72642Ayush Kumar Mishra-69/+25
Fixed failing test-cases Remove noisy suggestion of hash_map #72642 Fixed failing test-cases
2020-06-08Show `SyntaxContext` in formatted `Span` debug outputAaron Hill-30/+30
This is only really useful in debug messages, so I've switched to calling `span_to_string` in any place that causes a `Span` to end up in user-visible output.
2020-06-08Don't lose empty `where` clause when pretty-printingAaron Hill-0/+39
Previously, we would parse `struct Foo where;` and `struct Foo;` identically, leading to an 'empty' `where` clause being omitted during pretty printing. This will cause us to lose spans when proc-macros involved, since we will have a collected `where` token that does not appear in the pretty-printed item. We now explicitly track the presence of a `where` token during parsing, so that we can distinguish between `struct Foo where;` and `struct Foo;` during pretty-printing
2020-06-08fixup! Add regression test for const generic ICE in #72819Ayaz Hafiz-1/+1
2020-06-08fixup! Add regression test for const generic ICE in #72819Ayaz Hafiz-0/+3
2020-06-08Add regression test for #73137Dylan MacKenzie-0/+42
Co-authored-by: Aaron1011 <aa1ronham@gmail.com>
2020-06-08Revert #71956Dylan MacKenzie-2/+2
2020-06-08Rollup merge of #72912 - GuillaumeGomez:add-e0755, r=estebankDylan DPC-0/+20
Add new E0758 error code
2020-06-08Resolve E0584 conflictNathan Corbyn-2/+2
2020-06-08Rollup merge of #73001 - ilya-bobyr:master, r=dtolnayRalf Jung-1/+10
Free `default()` forwarding to `Default::default()` It feels a bit redundant to have to say `Default::default()` every time I need a new value of a type that has a `Default` instance. Especially so, compared to Haskell, where the same functionality is called `def`. Providing a free `default()` function that forwards to `Default::default()` seems to improve the situation. The trait is still there, so if someone wants to be explicit and to say `Default::default()` - it still works, but if imported as `std::default::default;`, then the free function reduces typing and visual noise.
2020-06-08Rollup merge of #72799 - Aaron1011:feature/span-debug, r=petrochenkovRalf Jung-0/+207
Add `-Z span-debug` to allow for easier debugging of proc macros Currently, the `Debug` impl for `proc_macro::Span` just prints out the byte range. This can make debugging proc macros (either as a crate author or as a compiler developer) very frustrating, since neither the actual filename nor the `SyntaxContext` is displayed. This commit adds a perma-unstable flag `-Z span-debug`. When enabled, the `Debug` impl for `proc_macro::Span` simply forwards directly to `rustc_span::Span`. Once #72618 is merged, this will start displaying actual line numbers. While `Debug` impls are not subject to Rust's normal stability guarnatees, we probably shouldn't expose any additional information on stable until `#![feature(proc_macro_span)]` is stabilized. Otherwise, we would be providing a 'backdoor' way to access information that's supposed be behind unstable APIs.
2020-06-08Rollup merge of #72026 - botika:master, r=estebankRalf Jung-1/+108
Update annotate-snippets-rs to 0.8.0 #59346 I made major changes to this library. In the previous version we worked with owned while in the current one with borrowed. I have adapted it without changing the behavior. I have modified the coverage since the previous one did not return correctly the index of the character in the line.
2020-06-08Auto merge of #73046 - marmeladema:save-analysis-fix-path, r=Xanewokbors-0/+27
save_analysis: fix some ICEs Fixes #73020 Fixes #73022 Fixes #73041