Commit Graph

166356 Commits

Author SHA1 Message Date
Mara Bos
6e16f9b10f Rename RWLock to RwLock in std::sys. 2022-04-06 16:33:53 +02:00
bors
b6ab1fae73 Auto merge of #95707 - RalfJung:initialized, r=oli-obk
interp/validity: enforce Scalar::Initialized

This is a follow-up to https://github.com/rust-lang/rust/pull/94527, to also account for the new kind of `Scalar` layout inside the validity checker.

r? `@oli-obk`
2022-04-06 14:07:27 +00:00
Yoav Lavi
1ad6442e91 update unnecessary_join documentation 2022-04-06 15:59:38 +02:00
Oli Scherer
b30bcfae38 Fix some fallout around type alias impl trait in associated types 2022-04-06 12:56:22 +00:00
J-ZhengLi
85b081b65a code refractor for [needless_match] 2022-04-06 20:44:54 +08:00
Martin Geisler
4f08d75375 Mention std::env::var in env!
When searching for how to read an environment variable, I first encountered the `env!` macro. It would have been useful to me if the documentation had included a link to `std::env::var`, which is what I was actually looking for.
2022-04-06 14:23:42 +02:00
bors
201cf3dba3 Auto merge of #95723 - SparrowLii:const_goto, r=fee1-dead
enhance `ConstGoto` mir-opt by moving up `StorageDead` statements

From the `FIXME` in the implementation of `ConstGoto` miropt. We can move `StorageDead` statements up to the predecessor. This can expand the scope of application of this opt.
2022-04-06 10:08:08 +00:00
bors
cf1e2e9c1c Auto merge of #8612 - SabrinaJewson:suggest-from-utf8-unchecked-in-const, r=flip1995
Suggest from_utf8_unchecked in const contexts

Unfortunately I couldn't figure out how to check whether a given expression is in an `unsafe` context or not, so I just unconditionally emit the wrapping `unsafe {}` block in the suggestion. If there is an easy way to get it to work better then I would love to hear it.

changelog: Suggest `from_utf8_unchecked` instead of `from_utf8` in const contexts for ``[`transmute_bytes_to_str`]``

refs: #8379
2022-04-06 09:32:51 +00:00
Sabrina Jewson
41ef4f729f
Report from_utf8 suggestion as maybe incorrect
Co-authored-by: Philipp Krones <hello@philkrones.com>
2022-04-06 10:14:20 +01:00
Pietro Albini
73dc13058d
remove ~const Drop from rustdoc test 2022-04-06 10:35:49 +02:00
bors
880ff2497d Auto merge of #8596 - Jaic1:unnecessary_cast, r=flip1995
Fix unnecessary_cast suggestion for type aliasses

Fix #6923. The [`unnecessary_cast`] lint now will skip casting to non-primitive type.

changelog: fix lint [`unnecessary_cast `]
2022-04-06 08:27:03 +00:00
bors
41f2eccf92 Auto merge of #8588 - pitaj:fix-8348, r=flip1995
`indexing_slicing` should not fire if a valid array index comes from a constant function that is evaluated at compile-time

fix #8348

changelog: [`indexing_slicing`] fewer false positives in `const` contexts and with `const` indices
2022-04-06 08:13:26 +00:00
Marijn Schouten
2b76da86ef
Message: Chunks cannot have a size of zero.
Add a message to the assertion that chunks cannot have a size of zero.
2022-04-06 09:54:43 +02:00
Pietro Albini
466720c777
bless tests 2022-04-06 09:29:58 +02:00
SparrowLii
a91b347768 enhance ConstGoto mir-opt by moving up StorageDead statements 2022-04-06 15:17:41 +08:00
bors
ce1a8131c6 Auto merge of #95720 - ehuss:update-cargo, r=ehuss
Update cargo

5 commits in 1ef1e0a12723ce9548d7da2b63119de9002bead8..e2e2dddebe66dfc1403a312653557e332445308b
2022-03-31 00:17:18 +0000 to 2022-04-05 17:04:53 +0000
- Part 2 of RFC2906 -- allow inheriting from a different `Cargo.toml` (rust-lang/cargo#10517)
- File Cache is valid if checkout or contents hasn't changed (rust-lang/cargo#10507)
- Fix how scrape-examples handles proc macros (rust-lang/cargo#10533)
- tools: update checkout action on CI (rust-lang/cargo#10521)
- Don't error if no binaries were installed (rust-lang/cargo#10508)
2022-04-06 06:08:47 +00:00
Cheng XU
48684097db
Fix typo in bootstrap/setup.rs 2022-04-05 22:52:30 -07:00
Eric Huss
43f80a6008 Update cargo 2022-04-05 21:19:53 -07:00
bors
5da76eeaad Auto merge of #95711 - Dylan-DPC:rollup-ujss3oi, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #95659 (Rely on #[link] attribute for unwind on Fuchsia.)
 - #95684 (rustdoc: Fix item info display overflow)
 - #95693 (interp: pass TyCtxt to Machine methods that do not take InterpCx)
 - #95699 (fix: Vec leak when capacity is 0)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-06 03:45:36 +00:00
kangarooCoder
c62d2106da Merge remote-tracking branch 'origin/master' 2022-04-05 21:50:12 -05:00
kangarooCoder
594a2fcc3f Add test for issue rust-lang/rust#83474 2022-04-05 21:45:07 -05:00
Dylan DPC
b4527492b1
Rollup merge of #95699 - SparkyPotato:master, r=dtolnay
fix: Vec leak when capacity is 0

When `RawVec::with_capacity_in` is called with capacity 0, an allocation of size 0 is allocated.
However, `<RawVec as Drop>::drop` doesn't deallocate, since it only checks if capacity was 0. Fixed by not allocating when capacity is 0.
2022-04-06 03:39:09 +02:00
Dylan DPC
acdba55b53
Rollup merge of #95693 - RalfJung:more-context, r=oli-obk
interp: pass TyCtxt to Machine methods that do not take InterpCx

This just seems like something you might need, so let's consistently have it.

One day we might have to add `ParamEnv` as well, though that seems less likely (and in Miri you can always use `reveal_all` anyway). It might make sense to have a type that packages `TyCtxt` and `ParamEnv`, this pairing occurs quite frequently in rustc...

r? `@oli-obk`
2022-04-06 03:39:08 +02:00
Dylan DPC
84e1aa2d59
Rollup merge of #95684 - GuillaumeGomez:fix-item-info-overflow, r=notriddle
rustdoc: Fix item info display overflow

I came across this issue when reading local `Iterator` docs (reproduced in this screenshot):

![Screenshot from 2022-04-05 17-45-13](https://user-images.githubusercontent.com/3050060/161798150-769ee838-4768-4df8-9d34-b02eb8104eed.png)

The problem comes from the fact that `span` isn't `display: block` by default. Since `item-info` was already present on `<div>` in other places, I moved the last one to `div` as well.

r? `@notriddle`
2022-04-06 03:39:08 +02:00
Dylan DPC
823bf7618a
Rollup merge of #95659 - anp:remove-link-print, r=tmandry
Rely on #[link] attribute for unwind on Fuchsia.

Closes #95575.
2022-04-06 03:39:07 +02:00
bors
26b5e0cbb9 Auto merge of #95469 - ChrisDenton:unsound-read-write, r=joshtriplett
Fix unsound `File` methods

This is a draft attempt to fix #81357. *EDIT*: this PR now tackles `read()`, `write()`, `read_at()`, `write_at()` and `read_buf`. Still needs more testing though.

cc `@jstarks,` can you confirm the the Windows team is ok with the Rust stdlib using `NtReadFile` and `NtWriteFile`?

~Also, I'm provisionally using `CancelIo` in a last ditch attempt to recover but I'm not sure that this is actually a good idea. Especially as getting into this state would be a programmer error so aborting the process is justified in any case.~ *EDIT*: removed, see comments.
2022-04-06 01:23:08 +00:00
Nicholas Nethercote
b72a7fbcdc Improve terse test output.
The current terse output gives 112 chars per line, which causes
wraparound for people using 100 char wide terminals, which is very
common.

This commit changes it to be exactly 100 wide, which makes the output
look much nicer.
2022-04-06 11:21:14 +10:00
Deadbeef
9a2d0e53f1
Update documentation for trim* and is_whitespace to include newlines 2022-04-06 11:03:36 +10:00
Nicholas Nethercote
238d9076fc Call compute_locs once per rule.
Currently it's called in `parse_tt` every time a match rule is invoked.
This commit moves it so it's called instead once per match rule, in
`compile_declarative_macro. This is a performance win.

The commit also moves `compute_locs` out of `TtParser`, because there's
no longer any reason for it to be in there.
2022-04-06 10:23:06 +10:00
Ralf Jung
d214b38755 interp/validity: enforce Scalar::Initialized 2022-04-05 19:46:51 -04:00
bors
bbe9d27b8f Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #88025 (ScmCredentials netbsd implementation.)
 - #95473 (track individual proc-macro expansions in the self-profiler)
 - #95547 (caution against ptr-to-int transmutes)
 - #95585 (Explain why `&T` is cloned when `T` is not `Clone`)
 - #95591 (Use revisions to track NLL test output (part 1))
 - #95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut)
 - #95673 (⬆️ rust-analyzer)
 - #95681 (resolve: Fix resolution of empty paths passed from rustdoc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-05 22:42:04 +00:00
Pietro Albini
9f70a7b111
rustdoc changes for ~const Drop 2022-04-05 23:18:43 +02:00
Pietro Albini
b744bb67fd
rustc_trait_selection changes 2022-04-05 23:18:41 +02:00
Pietro Albini
181d28bb61
trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
Dylan DPC
728f2636ac
Rollup merge of #95681 - petrochenkov:doclinkregr2, r=Dylan-DPC
resolve: Fix resolution of empty paths passed from rustdoc

Fixes https://github.com/rust-lang/rust/pull/95337#issuecomment-1088426179
2022-04-05 22:59:01 +02:00
Dylan DPC
eda2f815c2
Rollup merge of #95673 - lnicola:rust-analyzer-2022-04-05, r=lnicola
⬆️ rust-analyzer

r? ``@ghost``
2022-04-05 22:59:00 +02:00
Dylan DPC
1e555bac14
Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, r=compiler-errors
diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut

Fixes #90073
2022-04-05 22:58:59 +02:00
Dylan DPC
cbf54fad79
Rollup merge of #95591 - jackh726:nll-revisions-1, r=oli-obk
Use revisions to track NLL test output (part 1)

The idea here is 2 fold: 1) When we eventually do make NLL default on, that PR should be systematic in "delete revisions and corresponding error annotations" 2) This allows us to look at test NLL outputs in chunks. (Though, I've opted here not to "mark" these tests. There are some tests with NLL revisions *now* that will be missed. I expect we do a second pass once we have all the tests with NLL revisions; these tests should be easy enough to eyeball.)

The actual review here should be "easy", but a bit tedious. I expect we should manually go through each test output and confirm it's okay.

The majority of these are either: 1) Only span change (the one I see most common is highlighting an entire function call, rather than just the function name in that call) 2) "E0308 mismatched types" -> "lifetime does not live long enough" 3) "E0495 cannot infer an appropriate lifetime for lifetime parameter" -> "lifetime does not live long enough" 4) "E0312 lifetime of reference outlives lifetime of borrowed content" -> "lifetime does not live long enough" 5) "E0759 `XXX` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement" -> "lifetime does not live long enough" 6) "E0623 lifetime mismatch" -> "lifetime does not live long enough"

Other than the now lack of an error code, most of these look fine (with most giving more helpful suggestions now).

`rfc1623` output isn't great.

cc ``@marmeladema`` if you want to look through these

Let's r? ``@oli-obk`` since you've commented on the Zulip thread ;)
2022-04-05 22:58:58 +02:00
Dylan DPC
42ab448bb4
Rollup merge of #95585 - compiler-errors:ref-clone, r=estebank
Explain why `&T` is cloned when `T` is not `Clone`

Fixes #95535
2022-04-05 22:58:57 +02:00
Dylan DPC
e597d06144
Rollup merge of #95547 - RalfJung:ptr-int-transmutes, r=scottmcm
caution against ptr-to-int transmutes

I don't know how strong of a statement we want to make here, but I am very concerned that the current docs could be interpreted as saying that ptr-to-int transmutes are just as okay as transmuting `*mut T` into an `&mut T`.

Examples [like this](https://github.com/rust-lang/unsafe-code-guidelines/issues/286#issuecomment-1085144431) show that ptr-to-int transmutes are deeply suspicious -- they are either UB, or they don't round-trip properly, or we have to basically say that `transmute` will actively look for pointers and do all the things a ptr-to-int cast does (which includes a global side-effect of marking the pointed-to allocation as 'exposed').

Another alternative might be to simply not talk about them... but we *do* want people to use casts rather than transmutes for this.

Cc `@rust-lang/lang`
2022-04-05 22:58:56 +02:00
Dylan DPC
c5e7e95292
Rollup merge of #95473 - lqd:macro-expansion, r=petrochenkov
track individual proc-macro expansions in the self-profiler

As described in [this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Macro.20expansion.20performance.20on.20complex.20macros/near/275063190), users don't currently have a lot of information to diagnose macro expansion performance issues. That comment suggests using the macro names to add further timing information.

This PR starts to do this for proc-macros which have the same issue, and performance problems happening in the wild in [this other zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns) could be helped by such information.

It uses the available proc-macro name to track their individual expansions with self-profiling events.

r? `@Aaron1011` who mentioned this idea originally
2022-04-05 22:58:55 +02:00
Dylan DPC
d2e1e6dc75
Rollup merge of #88025 - devnexen:netbsd_scm_creds, r=Amanieu
ScmCredentials netbsd implementation.
2022-04-05 22:58:54 +02:00
Pietro Albini
e96538aeeb
bump stage0 to the latest beta 2022-04-05 22:24:32 +02:00
bors
306ba8357f Auto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieu
Replace Linux Mutex and Condvar with futex based ones.

Tracking issue: https://github.com/rust-lang/rust/issues/93740
2022-04-05 20:17:08 +00:00
SparkyPotato
83f659b4bb formatting 2022-04-06 01:36:46 +05:30
SparkyPotato
9e9881bcd8 cleanup 2022-04-06 01:36:24 +05:30
SparkyPotato
31e7990145 fix Vec leak with 0 capacity 2022-04-06 01:32:26 +05:30
ouz-a
1cf6d6940c kill temp early 2022-04-05 22:38:03 +03:00
Michael Howell
6d18fbbc3f diagnostics: tweak error message to give more rationale to unsafe Fn 2022-04-05 11:13:48 -07:00
Ralf Jung
fcdfc3e1c1 interp: pass TyCtxt to Machine methods that do not take InterpCx 2022-04-05 13:31:51 -04:00