Commit graph

136862 commits

Author SHA1 Message Date
oli
f238148214 Allow libcore to be built with MIR inlining
Inlining caused new lints to get emitted, so we silence those lints now that we actually can.
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
bors
4153fa82ff Auto merge of #80715 - JulianKnodt:skip_opt, r=nagisa
Change branching in `iter.skip()`

Optimize branching in `Skip`, which was brought up in #80416.
This assumes that if `next` is called, it's likely that there will be more calls to `next`, and the branch for skip will only be hit once thus it's unlikely to take that path. Even w/o the `unlikely` intrinsic, it compiles more efficiently, I believe because the path where `next` is called is always taken.

It should be noted there are very few places in the compiler where `Skip` is used, so probably won't have a noticeable perf impact.

[New impl](https://godbolt.org/z/85rdj4)
[Old impl](https://godbolt.org/z/Wc74rh)

[Some additional asm examples](https://godbolt.org/z/feKzoz) although they really don't have a ton of difference between them.
2021-01-23 09:25:11 +00:00
bors
1986b58c64 Auto merge of #80065 - b-naber:parse-angle-arg-diagnostics, r=petrochenkov
Improve diagnostics when parsing angle args

https://github.com/rust-lang/rust/pull/79266 introduced parsing of generic arguments in associated type constraints, this however resulted in possibly very confusing error messages in cases in which closing angle brackets were missing such as in `Vec<(u32, _, _) = vec![]`, which outputs an incorrectly parsed equality constraint error, as noted by `@cynecx.`

This PR tries to provide better error messages in such cases.

r? `@petrochenkov`
2021-01-23 06:27:21 +00:00
bors
fe0fa59b50 Auto merge of #76391 - danii:master, r=cuviper
Split up core/test/iter.rs into multiple files

This PR removes the `// ignore-tidy-filelength` at the top of [iter.rs](04f44fb923/library/core/tests/iter.rs) by splitting it into several sub files. I have split the file per test, based on what I felt the test was really trying to test.
Addresses issue #60302.
- [associated_util.rs](d29180a8ed/library/core/tests/iter/associated_util.rs) - For testing the module level functions. (Maybe should be renamed?)
- [collection.rs](d29180a8ed/library/core/tests/iter/collection.rs) - For testing methods that use the values of all the items in an iterator, and creates one value from them, whether it be a Vec of all the values, or a number that represents the sum.
- [mod.rs](d29180a8ed/library/core/tests/iter/mod.rs) - For utility structs used in all tests, and other tests I didn't know where to place.
- [range.rs](d29180a8ed/library/core/tests/iter/range.rs) - For testing ranges.
- [transformation.rs](d29180a8ed/library/core/tests/iter/transformation.rs) - For testing methods that transform all the values in an iterator.
- [util.rs](d29180a8ed/library/core/tests/iter/util.rs) - For testing methods that provide utility in more specific use cases.

"Programatically"
-----------------------
You may have noticed I "Programatically" split up the file. [This is how](https://gist.github.com/danii/a58b3bcafa9faf1c3e4b01ad7495baf4) I managed to do that. 😛 Hope that's fine.
2021-01-23 03:33:16 +00:00
bors
693ed05bbd Auto merge of #81017 - Aaron1011:collect-trailing-token, r=petrochenkov
Refactor token collection to capture trailing token immediately

Split out from https://github.com/rust-lang/rust/pull/80689 - when we start capturing more information about attribute targets, we'll need to know in advance if we're capturing a trailing token or not.

r? `@ghost`
2021-01-23 00:42:37 +00:00
Daniel Conley
0c78500426 library/core/tests/iter documentation and cleanup 2021-01-22 17:57:08 -05:00
Daniel Conley
bc830a274b library/core/tests/iter rearrange & add back missed doc comments 2021-01-22 17:57:07 -05:00
Daniel Conley
1e3a2def67 library/core/test/iter add newlines between tests 2021-01-22 16:58:21 -05:00
bors
34b3d41e1a Auto merge of #79233 - yoshuawuyts:alloc-doc-alias, r=GuillaumeGomez
Add doc aliases for memory allocations

This patch adds doc aliases for various C allocation functions, making it possible to search for the C-equivalent of a function and finding the (safe) Rust counterpart:

- `Vec::with_capacity` / `Box::new` / `vec!` -> alloc + malloc, allocates memory
- `Box::new_zeroed` -> calloc, allocates zeroed-out memory
- `Vec::{reserve,reserve_exact,try_reserve_exact,shrink_to_fit,shrink_to}` -> realloc, reallocates a previously allocated slice of memory

It's worth noting that `Vec::new` does not allocate, so we don't link to it. Instead people are probably looking for `Vec::with_capacity` or `vec!`. I hope this will allow people comfortable with the system allocation APIs to make it easier to find what they may be looking for.

Thanks!
2021-01-22 21:48:41 +00:00
bors
22ddcd1a13 Auto merge of #72160 - slo1:libstd-setgroups, r=KodrAus
Add setgroups to std::os::unix::process::CommandExt

Should fix #38527. I'm not sure groups is the greatest name though.
2021-01-22 19:00:11 +00:00
b-naber
3ba6cf13f4 bless tests 2021-01-22 18:31:25 +01:00
Yoshua Wuyts
7d102383f9 Add doc aliases for memory allocations
- Vec::with_capacity / Box::new -> alloc + malloc
- Box::new_zeroed -> calloc
- Vec::{reserve,reserve_exact,try_reserve_exact,shrink_to_fit,shrink_to} -> realloc
2021-01-22 18:15:28 +01:00
b-naber
5ddad99a56 add and update tests 2021-01-22 17:07:27 +01:00
b-naber
728d257839 improve diagnostics for angle args 2021-01-22 17:07:27 +01:00
bors
b814b63983 Auto merge of #81271 - m-ou-se:rollup-xv7gq3w, r=m-ou-se
Rollup of 10 pull requests

Successful merges:

 - #80573 (Deny rustc::internal lints for rustdoc and clippy)
 - #81173 (Expand docs on Iterator::intersperse)
 - #81194 (Stabilize std::panic::panic_any.)
 - #81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`)
 - #81225 (Make 'docs' nullable in rustdoc-json output)
 - #81227 (Remove doctree::StructType)
 - #81233 (Document why not use concat! in dbg! macro)
 - #81236 (Gracefully handle loop labels missing leading `'` in different positions)
 - #81241 (Turn alloc's force_expr macro into a regular macro_rules.)
 - #81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-22 16:04:36 +00:00
Mara Bos
9c2a5776b2
Rollup merge of #81242 - jyn514:const-cap, r=sfackler
Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time

Previously, it would usually get computed by LLVM, but this enforces it. This removes the need for the comment saying "LLVM is smart enough".

I don't expect this to make a performance difference, but I do think it makes the performance properties easier to reason about.
2021-01-22 14:30:22 +00:00
Mara Bos
70597f28f6
Rollup merge of #81241 - m-ou-se:force-expr-macro-rules, r=oli-obk
Turn alloc's force_expr macro into a regular macro_rules.

This turns `alloc`'s `force_expr` macro into a regular `macro_rules`.

Otherwise rust-analyzer doesn't understand `vec![]`. See https://github.com/rust-analyzer/rust-analyzer/issues/7349 and https://github.com/rust-lang/rust/pull/81080#issuecomment-764741721

Edit: See https://github.com/rust-lang/rust/pull/81241#issuecomment-764812660 for a discussion of alternatives.
2021-01-22 14:30:21 +00:00
Mara Bos
3682a06dcf
Rollup merge of #81236 - estebank:everybody-loop-now, r=oli-obk
Gracefully handle loop labels missing leading `'` in different positions

Fix #81192.

* Account for labels when suggesting `loop` instead of `while true`
* Suggest `'a` when given `a` only when appropriate
* Add loop head span to hir
* Tweak error for invalid `break expr`
* Add more misspelled label tests
* Avoid emitting redundant "unused label" lint
* Parse loop labels missing a leading `'`

Each commit can be reviewed in isolation.
2021-01-22 14:30:19 +00:00
Mara Bos
81a60b7aa8
Rollup merge of #81233 - lzutao:dbg, r=KodrAus
Document why not use concat! in dbg! macro

Original title: Reduce code generated by `dbg!` macro
The expanded code before/after: <https://rust.godbolt.org/z/hE3j95>.

---

We cannot use `concat!` since `file!` could contains `{` or the expression is a block (`{ .. }`).
Using it will generated malformed format strings.
So let's document this reason why we don't use `concat!` macro at all.
2021-01-22 14:30:17 +00:00
Mara Bos
2ceee72427
Rollup merge of #81227 - CraftSpider:struct-type-clean, r=jyn514
Remove doctree::StructType

Also removes it from the Union type, as unions can only ever be 'Plain'. Adds a new StructType to JSON, 'union', as the easiest way to encode the type of a union there. This leaves only one item in doctree, `Module`.

r? `@jyn514`
2021-01-22 14:30:16 +00:00
Mara Bos
1cc13b4f5a
Rollup merge of #81225 - CraftSpider:json-opt-docs, r=jyn514
Make 'docs' nullable in rustdoc-json output

Matches the backing better, and makes it so there's a difference between 'empty docs' and 'no docs'.
2021-01-22 14:30:14 +00:00
Mara Bos
950ed27e8b
Rollup merge of #81202 - lzutao:dbg_ipv6, r=Amanieu
Don't prefix 0x for each segments in `dbg!(Ipv6)`

Fixes #81182
2021-01-22 14:30:12 +00:00
Mara Bos
b59f6e05ef
Rollup merge of #81194 - m-ou-se:stabilize-panic-any, r=m-ou-se
Stabilize std::panic::panic_any.

This stabilizes `std::panic::panic_any`.
2021-01-22 14:30:11 +00:00
Mara Bos
226fe55057
Rollup merge of #81173 - lukaslueg:intersperse_docs, r=m-ou-se
Expand docs on Iterator::intersperse

Unstable feature in #79524. This expands on the docs to bring them more in line with how other methods of `Iterator` are demonstrated.
2021-01-22 14:30:09 +00:00
Mara Bos
98c03644b1
Rollup merge of #80573 - jyn514:tool-lints, r=GuillaumeGomez
Deny rustc::internal lints for rustdoc and clippy

- Fix rustc::internal lints for rustdoc
- Deny internal lints only for rustdoc and clippy (previously the lints were ignored for clippy because -Zunstable-options didn't get passed)
2021-01-22 14:30:03 +00:00
bors
f2de221b00 Auto merge of #81101 - tmiasko:combine-now, r=nagisa
Combine instructions immediately
2021-01-22 13:10:48 +00:00
bors
bbc01bb624 Auto merge of #80558 - lcnr:gat-variance, r=matthewjasper
require gat substs to be invariant

fixes #69184, fixes #80766

r? `@matthewjasper` probably
2021-01-22 10:12:05 +00:00
Ralf Jung
ccaabc9479 re-bless ui tests 2021-01-22 10:56:28 +01:00
Ralf Jung
0c7fd2c685 expand successful-promotion test a bit 2021-01-22 10:36:30 +01: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
69a997bef2 update const_err description 2021-01-22 10:21:52 +01:00
Ralf Jung
5be27b7a70 avoid promoting division, modulo and indexing operations that could fail 2021-01-22 10:21:49 +01:00
slo1
a4db851302 Update src/test/ui/command/command-setgroups.rs to ignore windows 2021-01-21 22:42:38 -08:00
slo1
23f9314327 Update src/test/ui/command/command-setgroups.rs
Co-authored-by: Ashley Mannix <kodraus@hey.com>
2021-01-21 22:42:38 -08:00
slo1
41e6b23000 Add setgroups to std::os::unix::process::CommandExt 2021-01-21 22:42:38 -08:00
bors
25f39fe802 Auto merge of #81135 - jyn514:no-backticks, r=flip1995
Fix formatting for removed lints

- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility

I split this out of https://github.com/rust-lang/rust/pull/80527/ because it kept causing tests to fail, and it's a good change to have anyway.

r? `@flip1995`
2021-01-22 06:13:19 +00:00
Esteban Küber
9e82329c8f Do not suggest using a break label when one is already present 2021-01-21 21:43:29 -08:00
Esteban Küber
7698807770 Fix clippy and comment 2021-01-21 21:43:28 -08:00
Esteban Küber
8c5dafdcb8 Parse loop labels missing a leading '
When encountering the following typo:

```rust
a: loop { break 'a; }
```

provide an appropriate suggestion.
2021-01-21 21:41:47 -08:00
Esteban Küber
74ddaf000c Avoid emitting redundant "unused label" lint 2021-01-21 21:41:46 -08:00
Esteban Küber
c065234b34 Add more misspelled label tests 2021-01-21 21:41:46 -08:00
Esteban Küber
8a13abba1d Tweak error for invalid break expr
Point at loop head on invalid `break expr`.
Suggest removing `expr` or using label if available.
2021-01-21 21:41:46 -08:00
Esteban Küber
060dba67b7 Add loop head span to hir 2021-01-21 21:41:46 -08:00
Esteban Küber
a701ff981d Suggest 'a when given a only when appropriate
When encountering a name `a` that isn't resolved, but a label `'a` is
found in the current ribs, only suggest `'a` if this name is the value
expression of a `break` statement.

Solve FIXME.
2021-01-21 21:41:46 -08:00
Esteban Küber
707ce2b798 Account for labels when suggesting loop instead of while true 2021-01-21 21:41:46 -08:00
Aaron Hill
ccfc292999
Refactor token collection to capture trailing token immediately 2021-01-22 00:33:03 -05:00
Joshua Nelson
0797ffec09 Deny internal lints for rustdoc 2021-01-21 23:05:52 -05:00