Commit Graph

106833 Commits

Author SHA1 Message Date
Amos Onn
40ca167944 Improve #Safety in various methods in core::ptr
For all methods which read a value of type T, `read`, `read_unaligned`,
`read_volatile` and `replace`, added missing
constraint:
The value they point to must be properly initialized
2020-02-15 14:00:21 +01:00
Amos Onn
351782d30a Improve #Safety of core::ptr::replace
Added missing condition:
`dst` must be readable
2020-02-15 14:00:10 +01:00
Amos Onn
302b9e4b54 Improve #Safety in various methods in core::ptr
s/for reads and writes/for both ...
2020-02-15 13:58:54 +01:00
bors
433aae93e4 Auto merge of #69115 - ehuss:update-books, r=Dylan-DPC
Update books.

This required some changes in how the books are tested due to some changes in rust-lang/book.  It uses new syntax that is not compatible with bare `rustdoc --test`.  This changes it so that it uses rustbook to run the tests, which is essentially the same as `mdbook test`.

## reference

7 commits in 11e893fc1357bc688418ddf1087c2b7aa25d154d..64239df6d173562b9deb4f012e4c3e6e960c4754
2020-01-18 21:24:08 +0100 to 2020-02-10 19:05:13 +0100
- Update for nested receivers. (rust-lang-nursery/reference#724)
- clarify note re. leading `::` in 2018 (rust-lang-nursery/reference#752)
- Update macro-ambiguity.md (rust-lang-nursery/reference#754)
- typo fix: add missing `by` (rust-lang-nursery/reference#753)
- fix `TypeParamBounds` link on trait objects (rust-lang-nursery/reference#749)
- reorganize docs on references (rust-lang-nursery/reference#745)
- add MacroRepOp usage for ? (rust-lang-nursery/reference#744)

## book

49 commits in 87dd6843678575f8dda962f239d14ef4be14b352..6fb3705e5230311b096d47f7e2c91f9ce24393d0
2020-01-20 15:20:40 -0500 to 2020-02-12 13:48:57 -0500
- Fix nomicon links. (rust-lang/book#2253)
- Update to Rust 1.41.0 (rust-lang/book#2244)
- Listing 19-6: use ptr.add instead of ptr.offset (rust-lang/book#2201)
- Remove unneeded mutable reference
- Clarify deref coercion explanation
- Fix typo in link to 1.30 book
- Acknowledge Murphy's Law
- Clarify that buffer overread is UB in C
- Change from "must" to "idiomatic" about comments
- Fancy quotes
- Make HashMap types match previous example; add fwd ref to ch 13
- Tweak wording to array clarification
- Merge remote-tracking branch 'origin/pr/2236'
- Update all our crates (rust-lang/book#2235)
- Reword git caveat
- Merge remote-tracking branch 'origin/pr/2234'
- Merge remote-tracking branch 'origin/pr/2230'
- println! is a macro (rust-lang/book#2224)
- Update a translated version link (rust-lang/book#2221)
- move `Macro invocation` from section on tuple to section on mac… (rust-lang/book#2206)
- Do not limit `Self` usage in trait implementation (rust-lang/book#2197)
- Merge remote-tracking branch 'origin/pr/2191'
- Fix wrapping
- Merge remote-tracking branch 'origin/pr/2187'
- Updated appendix 07 to reflect deprecation of rustup install (rust-lang/book#2181)
- Make links to the Nomicon consistent
- Merge remote-tracking branch 'origin/pr/2180'
- Merge remote-tracking branch 'origin/pr/2175'
- Merge remote-tracking branch 'origin/pr/2171'
- Merge remote-tracking branch 'origin/pr/2170'
- Clarify and make consistent the explanation of unions
- Merge remote-tracking branch 'origin/pr/2166'
- Handle dev or test in the Finished output line
- Link to macros by example rather than macros (rust-lang/book#2164)
- Merge remote-tracking branch 'origin/pr/2147'
- Fix parens (rust-lang/book#2132)
- Clarify type inference with closures requires calling the closures
- Update link to French translation (rust-lang/book#2119)
- Merge remote-tracking branch 'origin/pr/2108'
- Add an explicit cross reference to data type
- Merge remote-tracking branch 'origin/pr/2105'
- ch15-02-deref: Improve explanation on immut-to-mut (rust-lang/book#2030)
- Remove unnecessary quotes
- Make markdown link identifier match
- Remove extra newline
- Merge remote-tracking branch 'origin/pr/2004'
- Extract code and output; script formatting and updating them (rust-lang/book#2231)
- Switch "Finally" to "Next" to reflect new chapters having been… (rust-lang/book#2098)
- ch19-06 added curly braces to macro output (rust-lang/book#2050)

## rust-by-example

2 commits in 1c2bd024d13f8011307e13386cf1fea2180352b5..32facd5522ddbbf37baf01e4e4b6562bc55c071a
2020-01-20 12:18:36 -0300 to 2020-02-11 09:25:06 -0300
- Add missing `dyn` in code sample (rust-lang/rust-by-example#1306)
- Improve grammar in a few sections (rust-lang/rust-by-example#1305)

## edition-guide

1 commits in 1a2390247ad6d08160e0dd74f40a01a9578659c2..37f9e6848411188a1062ead1bd8ebe4b8aa16899
2019-12-29 10:40:55 -0800 to 2020-02-10 14:36:14 +0100
- Fixed typo (rust-lang-nursery/edition-guide#196)

## embedded-book

4 commits in 4d78994915af1bde9a95c04a8c27d8dca066232a..b2e1092bf67bd4d7686c4553f186edbb7f5f92db
2020-01-14 08:25:25 +0000 to 2020-01-30 08:45:46 +0000
- Make typestate initialization notes correct  (rust-embedded/book#224)
- Mention discovery book more prominently  (rust-embedded/book#219)
- Replace nursery links with rust-lang links  (rust-embedded/book#222)
- Add a Glossary appendix page  (rust-embedded/book#223)
2020-02-14 19:59:05 +00:00
bors
35071e3e2e Auto merge of #69100 - cjgillot:resolve_instance, r=Zoxc
Move resolve_instance to rustc_ty.

r? @Zoxc
2020-02-14 16:30:31 +00:00
bors
e168dcd254 Auto merge of #69162 - RalfJung:miri, r=RalfJung
update miri

Fixes https://github.com/rust-lang/rust/issues/69117

Cc @oli-obk r? @ghost
2020-02-14 12:46:52 +00:00
Ralf Jung
cdb4a59633 update miri 2020-02-14 09:41:32 +01:00
bors
21ed50522d Auto merge of #68693 - Zoxc:query-no-arc, r=michaelwoerister
Construct query job latches on-demand

r? @michaelwoerister
2020-02-14 01:37:50 +00:00
bors
10104085e4 Auto merge of #69144 - Dylan-DPC:rollup-apt6zjj, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #68728 (parse: merge `fn` syntax + cleanup item parsing)
 - #68938 (fix lifetime shadowing check in GATs)
 - #69057 (expand: misc cleanups and simplifications)
 - #69108 (Use HirId in TraitCandidate.)
 - #69125 (Add comment to SGX entry code)
 - #69126 (miri: fix exact_div)
 - #69127 (Enable use after scope detection in the new LLVM pass manager)
 - #69135 (Spelling error "represening" to "representing")
 - #69141 (Don't error on network failures)

Failed merges:

r? @ghost
2020-02-13 22:20:58 +00:00
Dylan DPC
7704e590ec
Rollup merge of #69141 - mark-i-m:proper-linkcheck-2, r=Dylan-DPC
Don't error on network failures

This should further reduce spurious failures.

r? @JohnTitor and/or @ehuss
2020-02-13 21:28:14 +01:00
Dylan DPC
0bdf568ce4
Rollup merge of #69135 - drewrip:drewrip-spelling, r=jonas-schievink
Spelling error "represening" to "representing"

Small spelling mistake I noticed when looking through the Rust lexer.
2020-02-13 21:28:12 +01:00
Dylan DPC
a8a2c141ec
Rollup merge of #69127 - tmiasko:new-pass-manager-use-after-scope, r=nikic
Enable use after scope detection in the new LLVM pass manager

Implementation of 08a1c566a7 for the new LLVM pass manager, support for which landed in the meantime.
2020-02-13 21:28:11 +01:00
Dylan DPC
c8343b8653
Rollup merge of #69126 - RalfJung:exact-div, r=oli-obk
miri: fix exact_div

Turns out `exact_div` was relying on the broken behavior of `Rem` for `int_min % -1` that was fixed in https://github.com/rust-lang/rust/pull/69002. This PR fixes `exact_div`.

Inside rustc, `exact_div` is only used in a single place where the divisor is always positive (in `ptr_offset_from`), so we cannot test the fix in rustc. The Miri test suite covers this through the `exact_div` intrinsic, though (and it is how I found out).

One step to https://github.com/rust-lang/rust/issues/69117 (then we also need to address build failures introduced by https://github.com/rust-lang/rust/pull/68969)

r? @oli-obk
2020-02-13 21:28:09 +01:00
Dylan DPC
8e2772c0fd
Rollup merge of #69125 - jethrogb:jb/cleanup-sgx-entry, r=Dylan-DPC
Add comment to SGX entry code

Meant to force push this to be included in #69040, but forgot

r? @nagisa
2020-02-13 21:28:07 +01:00
Dylan DPC
b5ee867b50
Rollup merge of #69108 - cjgillot:trait_candidate, r=Zoxc
Use HirId in TraitCandidate.

I had to duplicate the `TraitMap` type to hold `NodeId`s until AST->HIR lowering is done.

r? @Zoxc
2020-02-13 21:28:06 +01:00
Dylan DPC
fc51170af5
Rollup merge of #69057 - Centril:clean-expand, r=petrochenkov
expand: misc cleanups and simplifications

Some work I did while trying to understand expand for the purposes of https://github.com/rust-lang/rust/issues/64197.

r? @petrochenkov
2020-02-13 21:28:05 +01:00
Dylan DPC
998daf36b9
Rollup merge of #68938 - Areredify:gat_lifetime_shadowing, r=estebank
fix lifetime shadowing check in GATs

closes #67512
2020-02-13 21:28:00 +01:00
Dylan DPC
89f5dcfb43
Rollup merge of #68728 - Centril:towards-fn-merge, r=petrochenkov
parse: merge `fn` syntax + cleanup item parsing

Here we continue the work in https://github.com/rust-lang/rust/pull/67131 in particular to merge the grammars of `fn` items in various positions.

A list of *language level* changes (as sanctioned by the language team in https://github.com/rust-lang/rust/issues/65041#issuecomment-538105286 and https://github.com/rust-lang/rust/pull/67131):

- `self` parameters are now *syntactically* allowed as the first parameter irrespective of item context (and in function pointers). Instead, semantic validation (`ast_validation`) is used.

- Syntactically, `fn` items in `extern { ... }` blocks can now have bodies (`fn foo() { ... }` as opposed to `fn foo();`). As above, we use semantic restrictions instead.

- Syntactically, `fn` items in free contexts (directly in a file or a module) can now be without bodies (`fn foo();` as opposed to `fn foo() { ... }`. As above, we use semantic restrictions instead, including for non-ident parameter patterns.

- `const extern fn` feature gating is now done post-expansion such that we do not have conditional compatibilities of function qualifiers *in parsing*.

- The `FnFrontMatter` grammar becomes:
   ```rust
   Extern = "extern" StringLit ;
   FnQual = "const"? "async"? "unsafe"? Extern? ;
   FnFrontMatter = FnQual "fn" ;
   ```

   That is, all item contexts now *syntactically* allow `const async unsafe extern "C" fn` and use semantic restrictions to rule out combinations previously prevented syntactically. The semantic restrictions include in particular:

   - `fn`s in `extern { ... }` can have no qualifiers.
   - `const` and `async` cannot be combined.

- To fuse the list-of-items parsing in the 4 contexts that items are allowed, we now must permit inner attributes (`#![attr]`) inside `trait Foo { ... }` definitions. That is, we now allow e.g. `trait Foo { #![attr] }`. This was probably an oversight due to not using a uniform parsing mechanism, which we now do have (`fn parse_item_list`). The semantic support (including e.g. for linting) falls out directly from the attributes infrastructure. To ensure this, we include a test for lints.

Put together, these grammar changes allow us to substantially reduce the complexity of item parsing and its grammar. There are however some other non-language improvements that allow the compression to take place.

A list of *compiler-internal* changes (in particular noting the parser-external data-structure changes):

- We use `enum AllowPlus/RecoverQPath/AllowCVariadic { Yes, No }` in `parser/ty.rs` instead of passing around 3 different `bool`s. I felt this was necessary as it was becoming mentally taxing to track which-is-which.

- `fn visit_trait_item` and `fn visit_impl_item` are merged into `fn visit_assoc_item` which now is passed an `AssocCtxt` to check which one it is.

- We change `FnKind` to:

  ```rust
  pub enum FnKind<'a> {
      Fn(FnCtxt, Ident, &'a FnSig, &'a Visibility, Option<&'a Block>),
      Closure(&'a FnDecl, &'a Expr),
  }
  ```

  with:

  ```rust
  pub enum FnCtxt {
      Free,
      Foreign,
      Assoc(AssocCtxt),
  }
  ```

  This is then taken advantage of in tweaking the various semantic restrictions as well as in pretty printing.

- In `ItemKind::Fn`, we change `P<Block>` to `Option<P<Block>>`.

- In `ForeignItemKind::Fn`, we change `P<FnDecl>` to `FnSig` and `P<Block>` to `Option<P<Block>>`.

- We change `ast::{Unsafety, Spanned<Constness>}>` into `enum ast::{Unsafe, Const} { Yes(Span), No }` respectively. This change in formulation allow us to exclude `Span` in the case of `No`, which facilitates parsing. Moreover, we also add a `Span` to `IsAsync` which is renamed to `Async`. The new `Span`s in `Unsafety` and `Async` are then taken advantage of for better diagnostics. A reason this change was made is to have a more uniform and clear naming scheme.

  The HIR keeps the structures in AST (with those definitions moved into HIR) for now to avoid regressing perf.

- Various cleanups, bug fixes, and diagnostics improvements are made along the way. It is probably best to understand those via the diffs.

I would recommend reviewing this commit-by-commit with whitespace changes hidden.

r? @estebank @petrochenkov
2020-02-13 21:27:58 +01:00
bors
5d04ce67fd Auto merge of #68406 - andjo403:selfprofileLlvm, r=wesleywiser
[self-profiler] add selfprofiling to llvm

using pass name as event id and add additional data with name of module, function …

![image](https://user-images.githubusercontent.com/844398/72761970-205d8600-3bde-11ea-86de-87386e127944.png)

r? @michaelwoerister or @wesleywiser
2020-02-13 19:12:43 +00:00
Camille GILLOT
0e652c5507 Move resolve_instance to rustc_ty. 2020-02-13 18:53:21 +01:00
Mark Mansi
23cb749bbb don't error on network failures 2020-02-13 11:53:07 -06:00
Drew Ripberger
026dec5500
Spelling error "represening" to "representing" 2020-02-13 11:14:21 -05:00
Eric Huss
1e1b6ad108 Update books. 2020-02-13 08:11:09 -08:00
Camille GILLOT
2a899e2a2f Make TraitCandidate generic. 2020-02-13 16:47:51 +01:00
Camille GILLOT
4706c38e17 Use HirId in TraitCandidate. 2020-02-13 16:39:09 +01:00
Mazdak Farrokhzad
ad72c3abb9 parser: inline parse_assoc_macro_invoc 2020-02-13 16:29:10 +01:00
Mazdak Farrokhzad
aaaf0ba072 parser: misc small item related improvements & cleanups. 2020-02-13 16:29:10 +01:00
Mazdak Farrokhzad
46d3ef58a8 parser: extract recover_const_mut. 2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
15e07a6a11 parser: fuse trait parsing & layer with is_path_start_item 2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
fd64b3bcdf parser: make eat_macro_def redundant. 2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
c2026030b5 parser: remove Option<Vec<Attribute>> in ItemInfo. 2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
20ba6875e6 parser_item_mod: avoid cloning outer attributes 2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
73d5970cdc parser: introduce parse_item_kind as central ItemInfo logic.
this also extracts macro item parsers.
2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
511dfdb8b3 parser: extract recover_missing_kw_before_item 2020-02-13 15:16:36 +01:00
Mazdak Farrokhzad
7737d0ffde parser: unify item list parsing.
as a consequence, `trait X { #![attr] }` becomes legal.
2020-02-13 15:16:29 +01:00
Mazdak Farrokhzad
9fed2d587c parser: extract common foreign item code for each kind 2020-02-13 14:43:20 +01:00
bors
d538b80ad7 Auto merge of #68969 - RalfJung:dont-panic, r=oli-obk
remove Panic variant from InterpError

The interpreter engine itself does not raise `Panic` errors any more, so remove them from the error enum. Instead, const-prop and const-eval have to do their own handling of panics.

I used the opportunity to refactor the const-eval error handling a bit to use the `MachineStop` variant.

Also, in const-prop I could do some cleanup as now, no more lints are being reported in `use_ecx`. However, I am quite puzzled by why exactly the linting there works the way it does -- the code can certainly be cleaned up more, but I don't know enough of the intent to do that. I left some questions for the most confusing parts, but for now behavior should be unchanged by this PR (so, all that weirdness I am asking about is pre-existing and merely maintained here). Cc @wesleywiser

Fixes https://github.com/rust-lang/rust/issues/66902

r? @oli-obk
2020-02-13 12:53:43 +00:00
Ralf Jung
33ba83c3a0
fix typo 2020-02-13 11:26:09 +01:00
Mazdak Farrokhzad
ec43450015 expand: simplify flat_map_item wrt. inline module detection 2020-02-13 11:25:34 +01:00
Mazdak Farrokhzad
dc6bd6a123 expand: simplify flat_map_item 2020-02-13 11:25:34 +01:00
Mazdak Farrokhzad
fcce5fa6e7 expand: simplify classify_* 2020-02-13 11:25:33 +01:00
Mazdak Farrokhzad
7518492315 expand: extract error_wrong_fragment_kind 2020-02-13 11:25:33 +01:00
Mazdak Farrokhzad
acad033424 expand: extract error_recursion_limit_reached 2020-02-13 11:25:33 +01:00
Ralf Jung
10f342abae miri: fix exact_div 2020-02-13 11:21:29 +01:00
Ralf Jung
ed2f22c5a9 rename PanicInfo -> AssertKind 2020-02-13 11:04:49 +01:00
Ralf Jung
7e7d1c39ed improve comments:
- comment for special handling of Shl/Shr
- reference a PR
2020-02-13 11:04:26 +01:00
Ralf Jung
55339f2eb7 small cleanup in ConstEvalErr::struct_generic 2020-02-13 11:04:26 +01:00
Ralf Jung
6457b29104 move PanicInfo to mir module 2020-02-13 11:04:26 +01:00
Ralf Jung
17a8cfd605 no need for hook_panic_fn to return a bool 2020-02-13 10:56:38 +01:00
Ralf Jung
f3ff02bdd8 remove PanicInfo::Panic variant that MIR does not use or need 2020-02-13 10:56:38 +01:00