Commit Graph

902 Commits

Author SHA1 Message Date
Tomasz Miąsko fe0c46d07e Pass PlaceTy by reference not value 2021-02-16 23:52:05 +01:00
Tomasz Miąsko e915cf45dc Pass OpTy by reference not value 2021-02-16 23:52:05 +01:00
Tomasz Miąsko 6c9d7fbeed Add size assertions for interpreter data structures 2021-02-16 23:34:50 +01:00
bors 8fe989dd76 Auto merge of #81611 - cjgillot:meowner, r=estebank
Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16 22:14:32 +00:00
Ralf Jung b08bc7836b fix MIR fn-ptr pretty-printing 2021-02-16 09:59:38 +01:00
Ralf Jung 897cb61076 validation: fix invalid-fn-ptr error message 2021-02-16 09:58:35 +01:00
Henry Boisdequin 5ec4b060a7 make `visit_projection` take a `PlaceRef` 2021-02-16 14:20:36 +05:30
Henry Boisdequin 30c5125fbe update formating 2021-02-16 07:07:42 +05:30
Camille GILLOT 786a80e9ea Only store a LocalDefId in hir::ImplItem. 2021-02-15 19:32:29 +01:00
Camille GILLOT cebbba081e Only store a LocalDefId in hir::Item.
Items are guaranteed to be HIR owner.
2021-02-15 19:32:10 +01:00
Camille GILLOT bd3cd5dbed Use an ItemId inside mir::GlobalAsm. 2021-02-15 19:24:58 +01:00
Camille GILLOT c676e358a5 Use ItemId as a strongly typed index. 2021-02-15 19:24:58 +01:00
Jonas Schievink 665bf9e35f
Rollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk
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-15 16:06:59 +01:00
Jonas Schievink 5e8435abe0
Rollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obk
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-15 16:06:57 +01:00
Jonas Schievink 6fde3c5438
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
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-15 16:06:55 +01:00
Jonas Schievink f02f7b05b2
Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank
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-15 16:06:47 +01:00
Edward Shen a4b2fafcc1
Revise HIR lowering comment 2021-02-15 00:28:58 -05:00
Edward Shen a491f51218
Use delay_span_bug for mismatched subst/hir arg 2021-02-14 23:59:45 -05:00
Dylan DPC bcb14035e9
Rollup merge of #82056 - b-naber:mut_for_loop_bug, r=oli-obk
fix ice (#82032)

Fixes https://github.com/rust-lang/rust/issues/82032
2021-02-14 16:54:53 +01:00
Dylan DPC c8dacf95ae
Rollup merge of #82029 - tmiasko:debug, r=matthewjasper
Use debug log level for developer oriented logs

The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-14 16:54:52 +01:00
Dylan DPC 2efde8c795
Rollup merge of #81965 - osa1:issue81200, r=oli-obk
Fix MIR pretty printer for non-local DefIds

Tries to fix #81200 -- the reproducer in the issue is not fixed yet.
Submitting PR to get feedback.

r? oli-obk
2021-02-14 16:54:51 +01:00
klensy 93c8ebe022 bumped smallvec deps 2021-02-14 18:03:11 +03:00
Henry Boisdequin eace240ebe use option<PlaceRef<'tcx>> to clean up mir code a little 2021-02-14 14:39:24 +05:30
Ellen b6144e7a20 yeet ya fixme into the void 2021-02-13 19:10:08 +00:00
Ömer Sinan Ağacan fe82365630 Fix MIR pretty printer for non-local DefIds 2021-02-13 20:23:27 +03:00
Ellen a3e079534d Heat up the ICE-y error reporting
rest in peace match bool <3
2021-02-13 14:42:30 +00:00
Ralf Jung d6dcb3de54 CTFE validation: catch ReadPointerAsBytes and better error 2021-02-13 14:58:31 +01:00
b-naber 77dfd71b95 fix 82032 2021-02-13 11:47:44 +01:00
Tomasz Miąsko 361dcd5ca7 Use debug log level for developer oriented logs
The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-13 00:00:00 +00:00
Dylan DPC fc93e260e9
Rollup merge of #81479 - osa1:issue24151, r=lcnr
Allow casting mut array ref to mut ptr

Allow casting mut array ref to mut ptr

We now allow two new casts:

- mut array reference to mut ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *mut usize;

  We allow casting const array references to const pointers so not
  allowing mut references to mut pointers was inconsistent.

- mut array reference to const ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *const usize;

  This was similarly inconsistent as we allow casting mut references to
  const pointers.

Existing test 'vector-cast-weirdness' updated to test both cases.

Fixes #24151
2021-02-12 22:53:29 +01:00
Yuki Okushi 0b7fc80e45
Rollup merge of #81959 - therealprof:fix-typo, r=oli-obk
Fix assosiated typo

Introduced in d3c4dbd85d, noticed only
after the fact, sorry. 😅

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2021-02-12 19:32:12 +09:00
Casey Rodarmor 66f4883308
[librustdoc] Reform lang string token splitting
Only split doctest lang strings on `,`, ` `, and `\t`. Additionally, to
preserve backwards compatibility with pandoc-style langstrings, strip a
surrounding `{}`, and remove leading `.`s from each token.

Prior to this change, doctest lang strings were split on all
non-alphanumeric characters except `-` or `_`, which limited future
extensions to doctest lang string tokens, for example using `=` for
key-value tokens.

This is a breaking change, although it is not expected to be disruptive,
because lang strings using separators other than `,` and ` ` are not
very common
2021-02-12 00:02:52 -08:00
bors 26e5bcd220 Auto merge of #81350 - tmiasko:instrument-debug, r=lcnr
Reduce log level used by tracing instrumentation from info to debug

Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`;  one use was novel).
2021-02-11 13:44:00 +00:00
Ömer Sinan Ağacan d64b749f2c Allow casting mut array ref to mut ptr
We now allow two new casts:

- mut array reference to mut ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *mut usize;

  We allow casting const array references to const pointers so not
  allowing mut references to mut pointers was inconsistent.

- mut array reference to const ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *const usize;

  This was similarly inconsistent as we allow casting mut references to
  const pointers.

Existing test 'vector-cast-weirdness' updated to test both cases.

Fixes #24151
2021-02-10 15:44:41 +03:00
Daniel Egger a6d413715c Fix assosiated typo
Introduced in d3c4dbd85d, noticed only
after the fact, sorry. 😅

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2021-02-10 09:36:26 +01:00
Dániel Buga 3c1d792f49 Only initialize what is used 2021-02-10 09:20:41 +01:00
Jacob Pratt c28f2a8bee
Stabilize str_split_once 2021-02-09 23:17:11 -05:00
Yuki Okushi 3f09418cbe
Rollup merge of #81466 - sasurau4:fix/enhance-sugget-mut-method-for-loop, r=oli-obk
Add suggest mut method for loop

Part of #49839

This PR focus on [the comment case](https://github.com/rust-lang/rust/issues/49839#issuecomment-761930746)
2021-02-10 12:24:21 +09:00
bors 87bacf22ec Auto merge of #81132 - bugadani:map-prealloc, r=matthewjasper
Borrowck: refactor visited map to a bitset

This PR refactors `Borrows`  and the `precompute_borrows_out_of_scope` function so that this initial phase has a much reduced memory pressure. This is achieved by reducing what is stored on the heap, and also reusing heap memory as much as possible.
2021-02-09 21:28:58 +00:00
Dániel Buga 5271c628be Remove RCs from Borrows 2021-02-08 20:37:16 +01:00
Mara Bos b263981fd7
Rollup merge of #81779 - geogriff:const-ptr-to-int-error, r=lcnr
improve error message for disallowed ptr-to-int casts in const eval

Improves an error message as [suggested](https://github.com/rust-lang/rust/issues/80875#issuecomment-762754580) in #80875.

Does the wording make enough sense? I tried to follow precedent for error message style while maintaining brevity.

It seems like the rest of the `ConstEvalErrKind::NeedsRfc` error messages could be improved as well. I could give that a go if this approach works.

Closes #80875
2021-02-08 19:28:17 +01:00
1000teslas b2eed3a559 Point out implicit deref coercions in borrow
Clean up code
2021-02-08 13:24:37 +11:00
Dániel Buga 46f30455f4 Optimize Borrows
Reuse as much memory as possible, reduce number of allocations.
Use BitSet instead of a HashMap, since only a single bit of
information was used as the map's value.
2021-02-07 22:26:21 +01:00
Daiki Ihara d3c4dbd85d Add suggest mu method for loop 2021-02-05 22:12:31 +09:00
Jeffrey Griffin ff315e34e8 improve error message for disallowed ptr-to-int casts in const eval 2021-02-05 00:52:19 -08:00
Tomasz Miąsko eb5e2d08c7 Never MIR inline functions with a different instruction set 2021-02-05 00:00:00 +00:00
Aaron Hill bc84e21107
Fix panic when emitting diagnostic for closure mutable binding error
Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 12:36:24 -05:00
Henry Boisdequin c2e849c022 added a suggestion to create a `const` item if the `fn` in the array repeat expression is a `const fn` 2021-02-03 10:18:08 +05:30
Jonas Schievink 9e8753e2bb
Rollup merge of #81463 - matsujika:nll-ensure-c-case, r=varkor
Rename NLL* to Nll* accordingly to C-CASE

Given [C-CASE](https://rust-lang.github.io/api-guidelines/naming.html#casing-conforms-to-rfc-430-c-case), `NLLRegionVariableOrigin` and `NLL` are encouraged to be `NllRegionVariableOrigin` and `Nll` respectively.
2021-02-01 14:29:35 +01:00
Jonas Schievink 99f2f5a830
Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obk
Remove const_in_array_repeat

Fixes #80371. Fixes #81315. Fixes #80767. Fixes #75682.

I thought there might be some issue with `Repeats(_, 0)`, but if you increase the items in the array it still ICEs. I'm not sure if this is the best fix but it does fix the given issue.
2021-01-31 16:36:42 +01:00
Jonas Schievink 7e3a8ec688
Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakis
2229: Fix issues with move closures and mutability

This PR fixes two issues when feature `capture_disjoint_fields` is used.

1. Can't mutate using a mutable reference
2. Move closures try to move value out through a reference.

To do so, we
1. Compute the mutability of the capture and store it as part of the `CapturedPlace`  that is written in TypeckResults
2. Restrict capture precision. Note this is temporary for now, to allow the feature to be used with move closures and ByValue captures and might change depending on discussions with the lang team.
    - No Derefs are captured for ByValue captures, since that will result in value behind a reference getting moved.
    - No projections are applied to raw pointers since these require unsafe blocks. We capture
    them completely.

r? `````@nikomatsakis`````
2021-01-31 16:36:41 +01:00
bors 9b32429822 Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obk
codegen: assume constants cannot fail to evaluate

https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :)

r? `@oli-obk`
2021-01-31 07:03:09 +00:00
kadmin 6946534d84 Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
Ralf Jung 944237f6cd codegen: assume constants cannot fail to evaluate
also don't submit code to LLVM when the session has errors
2021-01-30 12:29:57 +01:00
Yuki Okushi 91ea1cbc17
Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-se
Stabilize `unsigned_abs`

Resolves #74913.

This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`.

I have gone ahead and used this in a couple locations throughout the repository.
2021-01-30 13:36:44 +09:00
Aman Arora fadf03ee1b Fix typos 2021-01-29 16:01:27 -05:00
Aman Arora ffd53277dc Add fixme for precise path diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora c748f32ee4 Fix incorrect use mut diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora 604cbdcfdd Fix unused 'mut' warning for capture's root variable 2021-01-29 15:37:42 -05:00
Aman Arora 3488082582 Compute mutability of closure captures
When `capture_disjoint_fields` is not enabled, checking if the root variable
binding is mutable would suffice.

However with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.

This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in `ty::CapturedPlace` and then use
`ty::CapturedPlace::mutability` in mir_build and borrow_check.
2021-01-29 15:37:40 -05:00
bors b122908617 Auto merge of #81470 - tmiasko:remove-allocations, r=matthewjasper
Avoid memory allocation when removing dead blocks

Use `reachable_as_bitset` to reuse a bitset from the traversal rather
than allocating it seprately. Additionally check if there are any
unreachable blocks before proceeding.
2021-01-29 13:10:09 +00:00
bors 099f27b6cb Auto merge of #81440 - tmiasko:always-live-locals, r=matthewjasper
Visit only statements in always live locals

No functional changes intended.
2021-01-29 06:56:29 +00:00
Yuki Okushi 046a414c19
Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk
clean up some const error reporting around promoteds

These are some error reporting simplifications enabled by https://github.com/rust-lang/rust/pull/80579.

Further simplifications are possible but could be blocked on making `const_err` a hard error.

r? ``````@oli-obk``````
2021-01-29 09:17:38 +09:00
Yuki Okushi 4283623bc0
Rollup merge of #81158 - 1000teslas:issue-80313-fix, r=Aaron1011
Point to span of upvar making closure FnMut

For #80313.
2021-01-29 09:17:31 +09:00
bors bf193d69fe Auto merge of #81441 - tmiasko:ctfe-inline, r=oli-obk
Try inlining trivial functions used by CTFE

r? `@ghost`
2021-01-28 15:19:16 +00:00
Hirochika Matsumoto f8e0e78d75 Rename NLL* to Nll* accordingly to C-CASE 2021-01-28 16:18:25 +09:00
Yuki Okushi 446edd1e1a
Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakis
Refractor a few more types to `rustc_type_ir`

In the continuation of #79169, ~~blocked on that PR~~.

This PR:
 - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance`
 - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler.

~~I will split up that commit to make this easier to review and to have a better commit history.~~
EDIT: done, I split the PR in commits of 200-ish lines each

r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-28 15:09:02 +09:00
Tomasz Miąsko dc6ec3596b Avoid memory allocation when removing dead blocks
Use `reachable_as_bitset` to reuse a bitset from the traversal rather
than allocating it seprately. Additionally check if there are any
unreachable blocks before proceeding.
2021-01-28 00:00:00 +00:00
Tomasz Miąsko 20982b386f Inline MemPlace::offset 2021-01-27 16:13:58 +01:00
kadmin fe39653116 Check that value is explicitly none 2021-01-27 03:56:54 +00:00
Tomasz Miąsko 56865936a7 Visit only statements in always live locals
No functional changes intended.
2021-01-27 00:00:00 +00:00
Yuki Okushi c2c90bf548
Rollup merge of #80900 - camelid:readpointerasbytes-ice, r=oli-obk
Fix ICE with `ReadPointerAsBytes` validation error

Fixes #79690.

r? ``````@oli-obk``````
2021-01-27 04:43:16 +09:00
bors f4eb5d9f71 Auto merge of #68828 - oli-obk:inline_cycle, r=wesleywiser
Prevent query cycles in the MIR inliner

r? `@eddyb` `@wesleywiser`

cc `@rust-lang/wg-mir-opt`

The general design is that we have a new query that is run on the `validated_mir` instead of on the `optimized_mir`. That query is forced before going into the optimization pipeline, so as to not try to read from a stolen MIR.

The query should not be cached cross crate, as you should never call it for items from other crates. By its very design calls into other crates can never cause query cycles.

This is a pessimistic approach to inlining, since we strictly have more calls in the `validated_mir` than we have in `optimized_mir`, but that's not a problem imo.
2021-01-25 19:03:37 +00:00
1000teslas 26b4baf46e Point to span of upvar making closure FnMut
Add expected error

Add comment

Tweak comment wording

Fix after rebase to updated master

Fix after rebase to updated master

Distinguish mutation in normal and move closures

Tweak error message

Fix error message for nested closures

Refactor code showing mutated upvar in closure

Remove debug assert

B
2021-01-25 16:53:27 +11:00
Jonas Schievink d9c177f777
Rollup merge of #78578 - oli-obk:const_mut_refs, r=RalfJung
Permit mutable references in all const contexts

fixes #71212

cc `@rust-lang/wg-const-eval` `@christianpoveda`
2021-01-24 22:09:48 +01:00
Ralf Jung 48f9dbfd59 clean up some const error reporting around promoteds 2021-01-24 13:34:34 +01:00
Tomasz Miąsko 59457ab86e Reduce log level used by tracing instrumentation from info to debug 2021-01-24 00:00:00 +00:00
Jonas Schievink 3a3470bf04
Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJung
mir: Improve size_of handling when arg is unsized

As discussed on Zulip with `@RalfJung.`
2021-01-23 20:16:04 +01:00
Jonas Schievink 3382771dfd
Rollup merge of #81072 - RalfJung:place-ref-ty, r=oli-obk
PlaceRef::ty: use method call syntax
2021-01-23 20:15:59 +01:00
oli 209889ddc1 Leave some notes for future changes to the MIR opt level of mir inlining 2021-01-23 16:51:23 +00:00
oli 0491e74dd9 Make sure that const prop does not produce unsilenceable lints after inlining 2021-01-23 16:51:23 +00:00
oli b8727e2d60 Prevent query cycles during inlining 2021-01-23 16:51:22 +00:00
bors 4d0dd02ee0 Auto merge of #80579 - RalfJung:no-fallible-promotion, r=oli-obk
avoid promoting division, modulo and indexing operations that could fail

For division, `x / y` will still be promoted if `y` is a non-zero integer literal; however, `1/(1+1)` will not be promoted any more.

While at it, also see if we can reject promoting floating-point arithmetic (which are [complicated](https://github.com/rust-lang/unsafe-code-guidelines/issues/237) so maybe we should not promote them).

This will need a crater run to see if there's code out there that relies on these things being promoted.

If we can land this, promoteds in `fn`/`const fn` cannot fail to evaluate any more, which should let us do some simplifications in codegen/Miri!

Cc https://github.com/rust-lang/rfcs/pull/3027
Fixes https://github.com/rust-lang/rust/issues/61821
r? `@oli-obk`
2021-01-23 13:19:04 +00:00
oli 14f39aa81a Do not allow arbitrary mutable references in `static mut`, just keep with the existing exceptions 2021-01-23 11:33:45 +00:00
oli 00e62fabf1 Adjust wording of a diagnostic 2021-01-23 11:33:45 +00:00
oli d118021f8b Permit mutable references in all const contexts 2021-01-23 11:33:45 +00:00
bors f2de221b00 Auto merge of #81101 - tmiasko:combine-now, r=nagisa
Combine instructions immediately
2021-01-22 13:10:48 +00:00
Ralf Jung f62cecd807 do promote array indexing if we know it is in-bounds 2021-01-22 10:36:25 +01:00
Ralf Jung 5be27b7a70 avoid promoting division, modulo and indexing operations that could fail 2021-01-22 10:21:49 +01:00
Ömer Sinan Ağacan e3faeb486a mir: Improve size_of handling when arg is unsized 2021-01-21 22:17:05 +03:00
bors 65767e5653 Auto merge of #81122 - tmiasko:no-drop, r=davidtwco
Visit only terminators when removing unneeded drops

No functional changes intended
2021-01-21 17:02:49 +00:00
Yuki Okushi 2ebc036220
Rollup merge of #81187 - eltociear:patch-6, r=jonas-schievink
Fix typo in counters.rs

formating -> formatting
2021-01-21 20:04:55 +09:00
Yuki Okushi bc950c85c5
Rollup merge of #81185 - osa1:fix_80742, r=oli-obk
Fix ICE in mir when evaluating SizeOf on unsized type

Not quite ready yet. This tries to fix #80742 as discussed on [Zulip topic][1],
by using `delay_span_bug`.

I don't understand what `delay_span_bug` does. It seems like my error message
is never used. With this patch, in this program:

```rust
#![allow(incomplete_features)]
#![feature(const_evaluatable_checked)]
#![feature(const_generics)]

use std::fmt::Debug;
use std::marker::PhantomData;
use std::mem::size_of;

struct Inline<T>
where
    [u8; size_of::<T>() + 1]: ,
{
    _phantom: PhantomData<T>,
    buf: [u8; size_of::<T>() + 1],
}

impl<T> Inline<T>
where
    [u8; size_of::<T>() + 1]: ,
{
    pub fn new(val: T) -> Inline<T> {
        todo!()
    }
}

fn main() {
    let dst = Inline::<dyn Debug>::new(0); // line 27
}
```

these errors are printed, both for line 27 (annotated line above):

- "no function or associated item named `new` found for struct `Inline<dyn
  Debug>` in the current scope"
- "the size for values of type `dyn Debug` cannot be known at compilation time"

Second error makes sense, but I'm not sure about the first one and why it's
even printed.

Finally, I'm not sure about the span passing in `const_eval`.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Help.20fixing.20.2380742
2021-01-21 20:04:53 +09:00
Yuki Okushi cd0c54abb9
Rollup merge of #81178 - tmiasko:no-landing-pads, r=oli-obk
Visit only terminators when removing landing pads

No functional changes intended
2021-01-21 20:04:48 +09:00
Ömer Sinan Ağacan 3fb53c2c85 Fix ICE in mir when evaluating SizeOf on unsized type
Fixes #80742
2021-01-19 18:35:21 +03:00
Ikko Ashimine 203df1764c
Fix typo in counters.rs
formating -> formatting
2021-01-19 23:42:18 +09:00
bors 47121d6d88 Auto merge of #81110 - LeSeulArtichaut:fix-unused-unsafe-label, r=RalfJung
Fix `unused_unsafe` label with `unsafe_block_in_unsafe_fn

Previously, the following code:

```rust
#![feature(unsafe_block_in_unsafe_fn)]

unsafe fn foo() {
    unsafe { unsf() }
}

unsafe fn unsf() {}
```

Would give the following warning:

```
warning: unnecessary `unsafe` block
 --> src/lib.rs:4:5
  |
4 |     unsafe { unsf() }
  |     ^^^^^^ unnecessary `unsafe` block
  |
  = note: `#[warn(unused_unsafe)]` on by default
```
which doesn't point out that the block is in an `unsafe fn`.

Tracking issue: #71668
cc #79208
2021-01-19 08:59:37 +00:00
bors d98d2f57d9 Auto merge of #80707 - oli-obk:stability_hole_const_intrinsics, r=RalfJung
Stability oddity with const intrinsics

cc `@RalfJung`

In https://github.com/rust-lang/rust/pull/80699#discussion_r551495670 `@usbalbin` realized we accepted some intrinsics as `const` without a `#[rustc_const_(un)stable]` attribute. I did some digging, and that example works because intrinsics inherit their stability from their parents... including `#[rustc_const_(un)stable]` attributes. While we may want to fix that (not sure, wasn't there just a MCPed PR that caused this on purpose?), we definitely want tests for it, thus this PR adding tests and some fun tracing statements.
2021-01-18 20:54:36 +00:00
LeSeulArtichaut 50e1ae15e9 Use ty::{IntTy,UintTy,FloatTy} in rustc 2021-01-18 21:09:30 +01:00
Camelid def0e9b8a4 Fix ICE with `ReadPointerAsBytes` validation error 2021-01-18 11:51:18 -08:00