Commit graph

1748 commits

Author SHA1 Message Date
Ashley Mannix 7565809163 add a canary test for complex repr(simd) 2020-11-15 09:35:04 +10:00
Ashley Mannix 045105b1a2 remove internal simd_size_and_ty from llvm backend 2020-11-13 14:43:45 +10:00
gnzlbg 6e88e96ccf Support repr(simd) on ADTs containing a single array field
This PR allows using `#[repr(simd)]` on ADTs containing a
single array field:

```rust
 #[repr(simd)] struct S0([f32; 4]);
 #[repr(simd)] struct S1<const N: usize>([f32; N]);
 #[repr(simd)] struct S2<T, const N: usize>([T; N]);
```

This should allow experimenting with portable packed SIMD
abstractions on nightly that make use of const generics.
2020-11-08 12:01:48 +10:00
bors b1d9f31e04 Auto merge of #78638 - vn-ki:bindigs-after-at-issue-69971, r=oli-obk
reverse binding order in matches to allow the subbinding of copyable fields in bindings after @

Fixes #69971

### TODO

- [x] Regression tests

r? `@oli-obk`
2020-11-05 13:26:08 +00:00
Mara Bos 8416e13d88
Rollup merge of #78758 - eltociear:patch-1, r=jyn514
Fixed typo in comment

paramter -> parameter
2020-11-05 10:30:04 +01:00
Mara Bos 5ffccc4dfa
Rollup merge of #78742 - vn-ki:fix-issue-78655, r=oli-obk
make intern_const_alloc_recursive return error

fix #78655

r? ``@oli-obk``
2020-11-05 10:29:59 +01:00
Mara Bos 171d29c9c5
Rollup merge of #78739 - hameerabbasi:issue-78654, r=nikomatsakis
Fix ICE on type error in async function

Fixes #78654
2020-11-05 10:29:57 +01:00
Mara Bos 8640360870
Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514
fix a couple of clippy warnings:

filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-05 10:29:53 +01:00
Ikko Ashimine 873ebcb243
Fixed typo in comment
paramter -> parameter
2020-11-05 12:08:32 +09:00
bors 0fb00251a5 Auto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis
Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38)) currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20

r? `@ghost`
2020-11-04 22:45:15 +00:00
Vishnunarayan K I bd7229daf0 make intern_const_alloc_recursive return error fix #78655 2020-11-04 23:22:14 +05:30
bors 89631663b7 Auto merge of #78280 - bugadani:span, r=lcnr
Codegen: Query span as late as possible
2020-11-04 17:17:01 +00:00
Hameer Abbasi a70e0c20c3 Fix issue 78654. 2020-11-04 16:04:32 +00:00
bors 75f1db1102 Auto merge of #77227 - oli-obk:const_val_🌳_prelude, r=RalfJung
Refactorings in preparation for const value trees

cc #72396

This PR changes the `Scalar::Bits { data: u128, size: u8 }` variant to `Scalar::Bits(ScalarInt)` where `ScalarInt` contains the same information, but is `repr(packed)`. The reason for using a packed struct is to allow enum variant packing to keep the original size of `Scalar` instead of adding another word to its size due to padding.
Other than that the PR just gets rid of all the inspection of the internal fields of `Scalar::Bits` which were frankly scary. These fields have invariants that we need to uphold and we can't do that without making the fields private.

r? `@ghost`
2020-11-04 14:26:03 +00:00
Oli Scherer 332750f9eb
Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:13:06 +01:00
Oli Scherer 5f087f089f
Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:12:44 +01:00
oli 6e6c8a86e9 u64::try_from will now fail if ScalarInt isn't exactly 64 bits, thus we use to_bits with the correct size 2020-11-04 13:59:11 +00:00
oli 97bfff1f56 Make ScalarInt entirely independent of MIR interpretation 2020-11-04 13:55:29 +00:00
oli 2e53625421 Document an unwrap 2020-11-04 13:44:17 +00:00
oli abacaf2aef u128 truncation and sign extension are not just interpreter related 2020-11-04 13:41:58 +00:00
Matthias Krüger bcd2f2df67 fix a couple of clippy warnings:
filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-04 13:48:50 +01:00
bors 601c13c6fd Auto merge of #78677 - Aaron1011:fix/capture-inner-attrs, r=petrochenkov
Use reparsed `TokenStream` if we captured any inner attributes

Fixes #78675

We now bail out of `prepend_attrs` if we ended up capturing any inner
attributes (which can happen in several places, due to token capturing
for `macro_rules!` arguments.
2020-11-04 11:37:36 +00:00
oli e67c768110 Move ZST constant to the top of the impl block 2020-11-04 10:15:54 +00:00
Oli Scherer cb1cf6ae95 Update compiler/rustc_middle/src/ty/consts/int.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 10:15:40 +00:00
oli 98b70c9ac0 Simplify assert_bits impl 2020-11-04 10:15:09 +00:00
oli dad0036cb4 Do not raise interp errors from the scalar int module 2020-11-04 10:14:40 +00:00
oli 500af76831 Add helper for getting an int out of a Scalar 2020-11-04 10:13:59 +00:00
oli f03b18b99b Add is_null helper
This is cheaper than creating a null-`ScalarInt` and comparing
and then just throwing it away.
2020-11-04 10:13:22 +00:00
oli 0347ca7d02 Explain why we forward to self-printing during self-printing 2020-11-04 10:13:09 +00:00
oli d1074edb64 catch conversion errors during ptr_sized_op 2020-11-04 10:12:55 +00:00
oli 8282d526e0 Replace Scalar::zst with a Scalar::ZST constant 2020-11-04 10:12:41 +00:00
oli b8751c1fbb No need for a zst constructor method when we can have a constant 2020-11-04 10:12:27 +00:00
oli 3ef9dfdd42 Update comment 2020-11-04 10:12:13 +00:00
oli 1eb300ede1 Unaligned reads are UB in Rust irrelevant on which platform we are 2020-11-04 10:11:59 +00:00
oli e5258e6143 Remove outdated FIXME 2020-11-04 10:11:45 +00:00
oli df4d717d0b s/Scalar::Raw/Scalar::Int 2020-11-04 10:11:31 +00:00
oli 3a7970848c Fix cranelift build 2020-11-04 10:10:44 +00:00
oli c478574786 Explain the use of blocks around self.data accesses 2020-11-04 10:10:04 +00:00
oli 02131f4dcd Use packed struct instead of manually packing into an array 2020-11-04 10:09:10 +00:00
Oliver Scherer ed7a4adeb3 32 bit platforms don't have 64 bit pointers 2020-11-04 09:58:59 +00:00
Oliver Scherer eac309984f Encode ScalarInt::bytes as u128 instead of [u8; 16] to see if that caused the performance regression 2020-11-04 09:58:59 +00:00
Oliver Scherer 362123dd75 Split the "raw integer bytes" part out of Scalar 2020-11-04 09:58:59 +00:00
Dhruv Jauhar c9d9359b00 Address Pr comments regarding docstrings 2020-11-04 02:54:00 -05:00
bors 56293097f7 Auto merge of #78711 - m-ou-se:rollup-pxqnny7, r=m-ou-se
Rollup of 7 pull requests

Successful merges:

 - #77950 (Add support for SHA256 source file hashing)
 - #78624 (Sync rustc_codegen_cranelift)
 - #78626 (Improve errors about #[deprecated] attribute)
 - #78659 (Corrected suggestion for generic parameters in `function_item_references` lint)
 - #78687 (Suggest library/std when running all stage 0 tests)
 - #78699 (Show more error information in lldb_batchmode)
 - #78709 (Fix panic in bootstrap for non-workspace path dependencies.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-03 18:58:06 +00:00
Mara Bos f347dab47c
Rollup merge of #78659 - ayrtonm:fn-ref-lint-fix, r=oli-obk
Corrected suggestion for generic parameters in `function_item_references` lint

This commit handles functions with generic type parameters like you pointed out as well as const generics. Also this is probably a minor thing, but the type alias you used in the example doesn't show up so the suggestion right now would be `size_of::<[u8; 16]> as fn() ->`. This is because the lint checker works with MIR instead of HIR. I don't think we can get the alias at that point, but let me know if I'm wrong and there's a way to fix this. Also I put you as the reviewer, but I'm not sure if you want to review it or if it makes more sense to ask one of the original reviewers of this lint.
closes #78571
2020-11-03 19:32:38 +01:00
Mara Bos f0112928cb
Rollup merge of #78626 - fusion-engineering-forks:deprecated-trait-impl, r=estebank
Improve errors about #[deprecated] attribute

This change:

1. Turns `#[deprecated]` on a trait impl block into an error, which fixes #78625;
2. Changes these and other errors about `#[deprecated]` to use the span of the attribute instead of the item; and
3. Turns this error into a lint, to make sure it can be capped with `--cap-lints` and doesn't break any existing dependencies.

Can be reviewed per commit.

---
Example:
```rust
struct X;

#[deprecated = "a"]
impl Default for X {
    #[deprecated = "b"]
    fn default() -> Self {
        X
    }
}
```

Before:
```
error: This deprecation annotation is useless
 --> src/main.rs:6:5
  |
6 | /     fn default() -> Self {
7 | |         X
8 | |     }
  | |_____^
```

After:
```
error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:3:1
  |
3 | #[deprecated = "a"]
  | ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
  |
  = note: `#[deny(useless_deprecated)]` on by default

error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:5:5
  |
5 |     #[deprecated = "b"]
  |     ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
```
2020-11-03 19:32:36 +01:00
Mara Bos 39f5563e73
Rollup merge of #78624 - bjorn3:update_cg_clif-2020-11-01, r=jyn514
Sync rustc_codegen_cranelift

This fixes bootstrapping of rustc using cg_clif again. It regressed a while before #77975 got merged.

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/743
2020-11-03 19:32:34 +01:00
Mara Bos 52405f7c0c
Rollup merge of #77950 - arlosi:sha256, r=eddyb
Add support for SHA256 source file hashing

Adds support for `-Z src-hash-algorithm sha256`, which became available in LLVM 11.

Using an older version of LLVM will cause an error `invalid checksum kind` if the hash algorithm is set to sha256.

r? `@eddyb`
cc #70401 `@est31`
2020-11-03 19:32:26 +01:00
bors 5cdf5b882d Auto merge of #76931 - oli-obk:const_prop_inline_lint_madness, r=wesleywiser
Properly handle lint spans after MIR inlining

The first commit shows what happens when we apply mir inlining and then cause lints on the inlined MIR.
The second commit fixes that.

r? `@wesleywiser`
2020-11-03 16:32:34 +00:00
bors 0cd1516696 Auto merge of #78597 - RalfJung:raw-retag, r=oli-obk
Retagging: do not retag 'raw reborrows'

When doing `&raw const (*raw_ptr).field`, we do not want any retagging; the original provenance should be fully preserved.

Fixes https://github.com/rust-lang/miri/issues/1608
Test added by https://github.com/rust-lang/miri/pull/1614

Not sure whom to ask for review on this... `@oli-obk` can you have a look? Or maybe highfive makes a good choice.^^
2020-11-03 13:48:54 +00:00