]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoUpdate RLS
Igor Matuszewski [Thu, 11 Mar 2021 18:01:01 +0000 (19:01 +0100)]
Update RLS

3 years agoAuto merge of #83009 - RalfJung:miri, r=RalfJung
bors [Thu, 11 Mar 2021 11:37:36 +0000 (11:37 +0000)]
Auto merge of #83009 - RalfJung:miri, r=RalfJung

bump Miri

Fixes https://github.com/rust-lang/rust/issues/82961
Cc `@rust-lang/miri` r? `@ghost`

3 years agoAuto merge of #82947 - GuillaumeGomez:fix-nojs-style-issues, r=Nemo157
bors [Thu, 11 Mar 2021 09:08:57 +0000 (09:08 +0000)]
Auto merge of #82947 - GuillaumeGomez:fix-nojs-style-issues, r=Nemo157

Fix nojs style issues

There are two issues fixed here:
 1. The position of "{version}" and "[src]" spans.
 2. The position of attributes (on top of functions)

Please note that these issues only happen if you have disabled javascript.

Before:

![Screenshot from 2021-03-09 20-45-54](https://user-images.githubusercontent.com/3050060/110534652-9e048e00-811f-11eb-979e-6d85545edd65.png)

After:

![Screenshot from 2021-03-09 21-01-32](https://user-images.githubusercontent.com/3050060/110534667-a1981500-811f-11eb-8a19-32f4d5381a2b.png)

In the last commit, I added a test to enforce the attributes position. I need to think how to enforce it for the spans but that can comes later on.

r? `@Nemo157`

3 years agobump Miri
Ralf Jung [Thu, 11 Mar 2021 08:29:12 +0000 (09:29 +0100)]
bump Miri

3 years agoAuto merge of #82641 - camelid:lang-item-docs, r=jyn514
bors [Thu, 11 Mar 2021 06:38:22 +0000 (06:38 +0000)]
Auto merge of #82641 - camelid:lang-item-docs, r=jyn514

Improve lang item generated docs

cc https://rust-lang.zulipchat.com/#narrow/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F/near/226738260

r? `@jyn514`

3 years agoAuto merge of #82964 - Nicholas-Baron:shorten_middle_ty, r=jackh726
bors [Thu, 11 Mar 2021 04:09:44 +0000 (04:09 +0000)]
Auto merge of #82964 - Nicholas-Baron:shorten_middle_ty, r=jackh726

Shorten `rustc_middle::ty::mod`

Related to #60302.

This PR moves all `Adt*`, `Assoc*`, `Generic*`, and `UpVar*` types to separate files.
This, alongside some `use` reordering, puts `mod.rs` at ~2,200 lines, thus removing the `// ignore-tidy-filelength`.

The particular groups were chosen as they had 4 or more "substantive" members.

3 years agoMoved more of the capture related types into closure.rs
Nicholas-Baron [Wed, 10 Mar 2021 22:23:37 +0000 (14:23 -0800)]
Moved more of the capture related types into closure.rs

3 years agoMoved more types into upvar.rs (now named closure.rs)
Nicholas-Baron [Wed, 10 Mar 2021 20:55:00 +0000 (12:55 -0800)]
Moved more types into upvar.rs (now named closure.rs)

3 years agoMoved all Adt* types to adt.rs
Nicholas-Baron [Wed, 10 Mar 2021 05:47:12 +0000 (21:47 -0800)]
Moved all Adt* types to adt.rs

3 years agoMoved all Assoc* types to assoc.rs.
Nicholas-Baron [Wed, 10 Mar 2021 05:27:03 +0000 (21:27 -0800)]
Moved all Assoc* types to assoc.rs.

3 years agoMoved types starting with 'Generic' into generics.rs.
Nicholas-Baron [Wed, 10 Mar 2021 05:10:07 +0000 (21:10 -0800)]
Moved types starting with 'Generic' into generics.rs.

3 years agoMoved UpVar* types to a separate file.
Nicholas-Baron [Wed, 10 Mar 2021 04:47:03 +0000 (20:47 -0800)]
Moved UpVar* types to a separate file.

3 years agoGrouped some ungrouped use and mod lines.
Nicholas-Baron [Wed, 10 Mar 2021 04:53:48 +0000 (20:53 -0800)]
Grouped some ungrouped use and mod lines.

3 years agoAuto merge of #82960 - camelid:masked_crates, r=jyn514
bors [Wed, 10 Mar 2021 21:54:06 +0000 (21:54 +0000)]
Auto merge of #82960 - camelid:masked_crates, r=jyn514

Remove `masked_crates` from `clean::Crate`

Previously, `masked_crates` existed both on `Cache` and on
`clean::Crate`. During cache population, the `clean::Crate` version was
`take`n and moved to `Cache`.

This change removes the version on `clean::Crate` and instead directly
mutates `Cache.masked_crates` to initialize it. This has the advantage
of avoiding duplication and avoiding unnecessary allocation, as well as
making the flow of information through rustdoc less confusing.

The one downside I see is that `clean::utils::krate()` now uses the side
effect of mutating `DocContext.cache` instead of returning the data
directly, but it already mutated the `Cache` for other things (e.g.,
`deref_trait_did`) so it's not really new behavior. Also,
`clean::utils::krate()` is only called once (and is meant to only be
called once since it performs expensive and potentially destructive
operations) so the mutation shouldn't be an issue.

Follow-up to https://github.com/rust-lang/rust/pull/82018#discussion_r584197747.

cc `@jyn514`

3 years agoAuto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPC
bors [Wed, 10 Mar 2021 19:12:53 +0000 (19:12 +0000)]
Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #81309 (always eagerly eval consts in Relate)
 - #82217 (Edition-specific preludes)
 - #82807 (rustdoc: Remove redundant enableSearchInput function)
 - #82924 (WASI: Switch to crt1-command.o to enable support for new-style commands)
 - #82949 (Do not attempt to unlock envlock in child process after a fork.)
 - #82955 (fix: wrong word)
 - #82962 (Treat header as first paragraph for shortened markdown descriptions)
 - #82976 (fix error message for copy(_nonoverlapping) overflow)
 - #82977 (Rename `Option::get_or_default` to `get_or_insert_default`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRemove unnecessary `#[allow(dead_code)]`
Camelid [Wed, 10 Mar 2021 18:27:04 +0000 (10:27 -0800)]
Remove unnecessary `#[allow(dead_code)]`

3 years agoClarify docs
Camelid [Wed, 10 Mar 2021 17:20:12 +0000 (09:20 -0800)]
Clarify docs

3 years agoRemove `sym::` and `kw::` from generated docs
Camelid [Wed, 10 Mar 2021 17:05:59 +0000 (09:05 -0800)]
Remove `sym::` and `kw::` from generated docs

3 years agoFix bug
Camelid [Wed, 10 Mar 2021 17:02:40 +0000 (09:02 -0800)]
Fix bug

It needs to be a variable!

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoRollup merge of #82977 - camsteffen:opt-get-insert-def, r=m-ou-se
Dylan DPC [Wed, 10 Mar 2021 16:55:47 +0000 (17:55 +0100)]
Rollup merge of #82977 - camsteffen:opt-get-insert-def, r=m-ou-se

Rename `Option::get_or_default` to `get_or_insert_default`

...as [suggested](https://github.com/rust-lang/rust/issues/82901#issuecomment-793548515) by `@m-ou-se.` In hindsight this seems rather obvious, at least to me.

r? `@joshtriplett`

3 years agoRollup merge of #82976 - RalfJung:copy-nonoverlapping, r=oli-obk
Dylan DPC [Wed, 10 Mar 2021 16:55:46 +0000 (17:55 +0100)]
Rollup merge of #82976 - RalfJung:copy-nonoverlapping, r=oli-obk

fix error message for copy(_nonoverlapping) overflow

Fixes an error message regression introduced in https://github.com/rust-lang/rust/pull/77511 (and adds tests).

r? `@oli-obk`

3 years agoRollup merge of #82962 - notriddle:cleanup-index, r=jyn514
Dylan DPC [Wed, 10 Mar 2021 16:55:45 +0000 (17:55 +0100)]
Rollup merge of #82962 - notriddle:cleanup-index, r=jyn514

Treat header as first paragraph for shortened markdown descriptions

"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.

3 years agoRollup merge of #82955 - ltoddy:fix/wrong, r=jonas-schievink
Dylan DPC [Wed, 10 Mar 2021 16:55:44 +0000 (17:55 +0100)]
Rollup merge of #82955 - ltoddy:fix/wrong, r=jonas-schievink

fix: wrong word

3 years agoRollup merge of #82949 - the8472:forget-envlock-on-fork, r=joshtriplett
Dylan DPC [Wed, 10 Mar 2021 16:55:43 +0000 (17:55 +0100)]
Rollup merge of #82949 - the8472:forget-envlock-on-fork, r=joshtriplett

Do not attempt to unlock envlock in child process after a fork.

This implements the first two points from https://github.com/rust-lang/rust/issues/64718#issuecomment-793030479

This is a breaking change for cases where the environment is accessed in a Command::pre_exec closure. Except for single-threaded programs these uses were not correct anyway since they aren't async-signal safe.

Note that we had a ui test that explicitly tried `env::set_var` in `pre_exec`. As expected it failed with these changes when I tested locally.

3 years agoRollup merge of #82924 - sunfishcode:wasi-command, r=alexcrichton
Dylan DPC [Wed, 10 Mar 2021 16:55:41 +0000 (17:55 +0100)]
Rollup merge of #82924 - sunfishcode:wasi-command, r=alexcrichton

WASI: Switch to crt1-command.o to enable support for new-style commands

This switches Rust's WASI target to use crt1-command.o instead of
crt1.o, which enables support for new-style commands. By default,
new-style commands work the same way as old-style commands, so nothing
immediately changes here, but this will be needed by later changes to
enable support for typed arguments.

See here for more information on new-style commands:
 - https://github.com/WebAssembly/wasi-libc/pull/203
 - https://reviews.llvm.org/D81689

r? ```@alexcrichton```

3 years agoRollup merge of #82807 - notriddle:cleanup-js, r=jyn514
Dylan DPC [Wed, 10 Mar 2021 16:55:40 +0000 (17:55 +0100)]
Rollup merge of #82807 - notriddle:cleanup-js, r=jyn514

rustdoc: Remove redundant enableSearchInput function

enableSearchInput was called from two places:

- setupSearchLoader
- addSearchOptions, which is itself called from setupSearchLoader only

This commit can safely get rid of the addSearchOptions calls entirely, and since the setupSearchLoader call is immediately preceded by other method calls on search_input, there's no need to check if it's set.

3 years agoRollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakis
Dylan DPC [Wed, 10 Mar 2021 16:55:38 +0000 (17:55 +0100)]
Rollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakis

Edition-specific preludes

This changes `{std,core}::prelude` to export edition-specific preludes under `rust_2015`, `rust_2018` and `rust_2021`. (As suggested in https://github.com/rust-lang/rust/issues/51418#issuecomment-395630382.) For now they all just re-export `v1::*`, but this allows us to add things to the 2021edition prelude soon.

This also changes the compiler to make the automatically injected prelude import dependent on the selected edition.

cc `@rust-lang/libs` `@djc`

3 years agoRollup merge of #81309 - lcnr:lazy-norm-err-msgh, r=nikomatsakis
Dylan DPC [Wed, 10 Mar 2021 16:55:37 +0000 (17:55 +0100)]
Rollup merge of #81309 - lcnr:lazy-norm-err-msgh, r=nikomatsakis

always eagerly eval consts in Relate

r? ```@nikomatsakis``` cc ```@varkor```

3 years agoAuto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieu
bors [Wed, 10 Mar 2021 16:44:04 +0000 (16:44 +0000)]
Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieu

Implement RFC 2945: "C-unwind" ABI

## Implement RFC 2945: "C-unwind" ABI

This branch implements [RFC 2945]. The tracking issue for this RFC is #74990.

The feature gate for the issue is `#![feature(c_unwind)]`.

This RFC was created as part of the ffi-unwind project group tracked at rust-lang/lang-team#19.

### Changes

Further details will be provided in commit messages, but a high-level overview
of the changes follows:

* A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI boundaries is
acceptable. The cases where each of these variants' `unwind` member is true
correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and
`thiscall-unwind` ABI strings introduced in RFC 2945 [3].

* This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`, which
ensure that this feature gate works correctly for each of the new ABIs.
A new language features entry in the unstable book is added as well.

* We adjust the `rustc_middle::ty::layout::fn_can_unwind` function,
used to compute whether or not a `FnAbi` object represents a function that
should be able to unwind when `panic=unwind` is in use.

* Changes are also made to
`rustc_mir_build::build::should_abort_on_panic` so that the function ABI is
used to determind whether it should abort, assuming that the `panic=unwind`
strategy is being used, and no explicit unwind attribute was provided.

[RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md

3 years agoRename Option::get_or_insert_default
Cameron Steffen [Wed, 10 Mar 2021 14:48:09 +0000 (08:48 -0600)]
Rename Option::get_or_insert_default

3 years agofix error message for copy(_nonoverlapping) overflow
Ralf Jung [Wed, 10 Mar 2021 14:50:44 +0000 (15:50 +0100)]
fix error message for copy(_nonoverlapping) overflow

3 years agoAuto merge of #82884 - nagisa:nagisa/remove-most-of-sideeffect-inserts, r=nikic
bors [Wed, 10 Mar 2021 14:03:00 +0000 (14:03 +0000)]
Auto merge of #82884 - nagisa:nagisa/remove-most-of-sideeffect-inserts, r=nikic

Remove the -Zinsert-sideeffect

This removes all of the code we had in place to work-around LLVM's
handling of forward progress. From this removal excluded is a workaround
where we'd insert a `sideeffect` into clearly infinite loops such as
`loop {}`. This code remains conditionally effective when the LLVM
version is earlier than 12.0, which fixed the forward progress related
miscompilations at their root.

3 years agoAuto merge of #82967 - RalfJung:copy-nonoverlap, r=oli-obk
bors [Wed, 10 Mar 2021 11:21:46 +0000 (11:21 +0000)]
Auto merge of #82967 - RalfJung:copy-nonoverlap, r=oli-obk

fix copy_nonoverlapping

Fixes a bug introduced by https://github.com/rust-lang/rust/pull/77511

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/82961

3 years agoRemove the -Zinsert-sideeffect
Simonas Kazlauskas [Sun, 7 Mar 2021 23:59:10 +0000 (01:59 +0200)]
Remove the -Zinsert-sideeffect

This removes all of the code we had in place to work-around LLVM's
handling of forward progress. From this removal excluded is a workaround
where we'd insert a `sideeffect` into clearly infinite loops such as
`loop {}`. This code remains conditionally effective when the LLVM
version is earlier than 12.0, which fixed the forward progress related
miscompilations at their root.

3 years agoadd regression test
Ralf Jung [Wed, 10 Mar 2021 09:02:39 +0000 (10:02 +0100)]
add regression test

3 years agoAuto merge of #79519 - cjgillot:noattr, r=wesleywiser
bors [Wed, 10 Mar 2021 08:40:51 +0000 (08:40 +0000)]
Auto merge of #79519 - cjgillot:noattr, r=wesleywiser

Store HIR attributes in a side table

Same idea as #72015 but for attributes.
The objective is to reduce incr-comp invalidations due to modified attributes.
Notably, those due to modified doc comments.

Implementation:
- collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables;
- access the attributes through a `hir_owner_attrs` query;
- local refactorings to use this access;
- remove `attrs` from HIR data structures one-by-one.

Change in behaviour:
- the HIR visitor traverses all attributes at once instead of parent-by-parent;
- attribute arrays are sometimes duplicated: for statements and variant constructors;
- as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints.

~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~

3 years agofix copy_nonoverlapping
Ralf Jung [Wed, 10 Mar 2021 08:21:18 +0000 (09:21 +0100)]
fix copy_nonoverlapping

3 years agoSimplify some of the rendering code in the index
Michael Howell [Wed, 10 Mar 2021 02:16:32 +0000 (19:16 -0700)]
Simplify some of the rendering code in the index

It's kinda silly using serde seq for fixed-length stuff.

3 years agoRemove `masked_crates` from `clean::Crate`
Camelid [Wed, 10 Mar 2021 03:55:35 +0000 (19:55 -0800)]
Remove `masked_crates` from `clean::Crate`

Previously, `masked_crates` existed both on `Cache` and on
`clean::Crate`. During cache population, the `clean::Crate` version was
`take`n and moved to `Cache`.

This change removes the version on `clean::Crate` and instead directly
mutates `Cache.masked_crates` to initialize it. This has the advantage
of avoiding duplication and avoiding unnecessary allocation, as well as
making the flow of information through rustdoc less confusing.

The one downside I see is that `clean::utils::krate()` now uses the side
effect of mutating `DocContext.cache` instead of returning the data
directly, but it already mutated the `Cache` for other things (e.g.,
`deref_trait_did`) so it's not really new behavior. Also,
`clean::utils::krate()` is only called once (and is meant to only be
called once since it performs expensive and potentially destructive
operations) so the mutation shouldn't be an issue.

3 years agoAuto merge of #82953 - JohnTitor:rollup-8rtk5g2, r=JohnTitor
bors [Wed, 10 Mar 2021 01:25:43 +0000 (01:25 +0000)]
Auto merge of #82953 - JohnTitor:rollup-8rtk5g2, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #77511 (Add StatementKind::CopyNonOverlapping)
 - #79208 (Stabilize `unsafe_op_in_unsafe_fn` lint)
 - #82411 (Fixes to ExitStatus and its docs)
 - #82733 (Add powerpc-unknown-openbsd target)
 - #82802 (Build rustdoc for run-make tests, not just run-make-fulldeps)
 - #82849 (Add Option::get_or_default)
 - #82908 (:arrow_up: rust-analyzer)
 - #82937 (Update README.md to use the correct cmake version number)
 - #82938 (Bump tracing-tree dependency)
 - #82942 (Don't hardcode the `v1` prelude in diagnostics, to allow for new preludes.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agofix: wrong word
ltoddy [Wed, 10 Mar 2021 01:09:37 +0000 (09:09 +0800)]
fix: wrong word

3 years agoTreat header as first paragraph for shortened markdown descriptions
Michael Howell [Wed, 10 Mar 2021 00:48:14 +0000 (17:48 -0700)]
Treat header as first paragraph for shortened markdown descriptions

"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.

3 years agoRollup merge of #82942 - m-ou-se:diagnostics-hardcoded-prelude-v1, r=estebank
Yuki Okushi [Tue, 9 Mar 2021 23:01:37 +0000 (08:01 +0900)]
Rollup merge of #82942 - m-ou-se:diagnostics-hardcoded-prelude-v1, r=estebank

Don't hardcode the `v1` prelude in diagnostics, to allow for new preludes.

Instead of looking for `std::prelude::v1`, this changes the two places where that was hardcoded to look for `std::prelude::<anything>` instead.

This is needed for https://github.com/rust-lang/rust/pull/82217.

r? `@estebank`

3 years agoRollup merge of #82938 - oli-obk:tracing_tree_bump, r=Mark-Simulacrum
Yuki Okushi [Tue, 9 Mar 2021 23:01:36 +0000 (08:01 +0900)]
Rollup merge of #82938 - oli-obk:tracing_tree_bump, r=Mark-Simulacrum

Bump tracing-tree dependency

This bump fixes two small rendering things that were annoying me:

* The first level didn't have an opening line
* When wraparound happens, there was no warning, the levels just disappeared. Now there is a line that shows that wraparound is happening

See https://github.com/davidbarsky/tracing-tree/pull/31/files for how the look changes

3 years agoRollup merge of #82937 - wesleywiser:update_cmake_version_in_readme, r=Mark-Simulacrum
Yuki Okushi [Tue, 9 Mar 2021 23:01:34 +0000 (08:01 +0900)]
Rollup merge of #82937 - wesleywiser:update_cmake_version_in_readme, r=Mark-Simulacrum

Update README.md to use the correct cmake version number

LLVM requires at least cmake 3.13.4 and cmake is only required to build
LLVM.

https://www.llvm.org/docs/CMake.html

Also closes #42555

3 years agoRollup merge of #82908 - lnicola:rust-analyzer-2021-03-08, r=jonas-schievink
Yuki Okushi [Tue, 9 Mar 2021 23:01:33 +0000 (08:01 +0900)]
Rollup merge of #82908 - lnicola:rust-analyzer-2021-03-08, r=jonas-schievink

:arrow_up: rust-analyzer

3 years agoRollup merge of #82849 - camsteffen:option-get-or-default, r=joshtriplett
Yuki Okushi [Tue, 9 Mar 2021 23:01:32 +0000 (08:01 +0900)]
Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtriplett

Add Option::get_or_default

Tracking issue: #82901

The original issue is #55042, which was closed, but for an invalid reason (see discussion there). Opening this to reconsider (I hope that's okay). It seems like the only gap for `Option` being "entry-like".

I ran into a need for this method where I had a `Vec<Option<MyData>>` and wanted to do `vec[n].get_or_default().my_data_method()`. Using an `Option` as an inner component of a data structure is probably where the need for this will normally arise.

3 years agoRollup merge of #82802 - jyn514:build-rustdoc-fullmake, r=Mark-Simulacrum
Yuki Okushi [Tue, 9 Mar 2021 23:01:30 +0000 (08:01 +0900)]
Rollup merge of #82802 - jyn514:build-rustdoc-fullmake, r=Mark-Simulacrum

Build rustdoc for run-make tests, not just run-make-fulldeps

Rustdoc almost never needs a full stage 2 compiler, and requiring
rustdoc tests to be in run-make-fulldeps adds a lot of compile time for
no reason.

This is the same change from https://github.com/rust-lang/rust/pull/81197, but separated into its own PR. I ran into this again today while working on https://github.com/rust-lang/docs.rs/issues/1302.
r? ```@Mark-Simulacrum```

3 years agoRollup merge of #82733 - Yn0ga:master, r=estebank
Yuki Okushi [Tue, 9 Mar 2021 23:01:29 +0000 (08:01 +0900)]
Rollup merge of #82733 - Yn0ga:master, r=estebank

Add powerpc-unknown-openbsd target

3 years agoRollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay
Yuki Okushi [Tue, 9 Mar 2021 23:01:27 +0000 (08:01 +0900)]
Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay

Fixes to ExitStatus and its docs

* On Unix, properly display every possible wait status (and don't panic on weird values)
* In the documentation, be clear and consistent about "exit status" vs "wait status".

3 years agoRollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis
Yuki Okushi [Tue, 9 Mar 2021 23:01:25 +0000 (08:01 +0900)]
Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis

Stabilize `unsafe_op_in_unsafe_fn` lint

This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896.

Tracking issue: #71668
r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung```

# Stabilization report

This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`.

## Summary

Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside.

The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block.

For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level.

For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md)

### Example

```rust
// An `unsafe fn` for demonstration purposes.
// Calling this is an unsafe operation.
unsafe fn unsf() {}

// #[allow(unsafe_op_in_unsafe_fn)] by default,
// the behavior of `unsafe fn` is unchanged
unsafe fn allowed() {
    // Here, no `unsafe` block is needed to
    // perform unsafe operations...
    unsf();

    // ...and any `unsafe` block is considered
    // unused and is warned on by the compiler.
    unsafe {
        unsf();
    }
}

#[warn(unsafe_op_in_unsafe_fn)]
unsafe fn warned() {
    // Removing this `unsafe` block will
    // cause the compiler to emit a warning.
    // (Also, no "unused unsafe" warning will be emitted here.)
    unsafe {
        unsf();
    }
}

#[deny(unsafe_op_in_unsafe_fn)]
unsafe fn denied() {
    // Removing this `unsafe` block will
    // cause a compilation error.
    // (Also, no "unused unsafe" warning will be emitted here.)
    unsafe {
        unsf();
    }
}
```

3 years agoRollup merge of #77511 - JulianKnodt:st_kind_cpy, r=oli-obk
Yuki Okushi [Tue, 9 Mar 2021 23:01:24 +0000 (08:01 +0900)]
Rollup merge of #77511 - JulianKnodt:st_kind_cpy, r=oli-obk

Add StatementKind::CopyNonOverlapping

Implements https://github.com/rust-lang/compiler-team/issues/348

r? `@nagisa`

3 years agoDo not attempt to unlock envlock in child process after a fork.
The8472 [Tue, 9 Mar 2021 20:42:38 +0000 (21:42 +0100)]
Do not attempt to unlock envlock in child process after a fork.

This is a breaking change for cases where the environment is
accessed in a Command::pre_exec closure. Except for
single-threaded programs these uses were not correct
anyway since they aren't async-signal safe.

3 years agoAdd test to ensure the attributes position when js is disabled
Guillaume Gomez [Tue, 9 Mar 2021 20:33:39 +0000 (21:33 +0100)]
Add test to ensure the attributes position when js is disabled

3 years agoFix typo
Guillaume Gomez [Tue, 9 Mar 2021 20:14:43 +0000 (21:14 +0100)]
Fix typo

3 years agoFix CSS issues when javascript is disabled
Guillaume Gomez [Tue, 9 Mar 2021 20:02:56 +0000 (21:02 +0100)]
Fix CSS issues when javascript is disabled

3 years agoaddress pr review comments
katelyn a. martin [Fri, 23 Oct 2020 22:49:34 +0000 (18:49 -0400)]
address pr review comments

 ### Add debug assertion to check `AbiDatas` ordering

    This makes a small alteration to `Abi::index`, so that we include a
    debug assertion to check that the index we are returning corresponds
    with the same abi in our data array.

    This will help prevent ordering bugs in the future, which can
    manifest in rather strange errors.

 ### Using exhaustive ABI matches

    This slightly modifies the changes from our previous commits,
    favoring exhaustive matches in place of `_ => ...` fall-through
    arms.

    This should help with maintenance in the future, when additional
    ABI's are added, or when existing ABI's are modified.

 ### List all `-unwind` ABI's in unstable book

    This updates the `c-unwind` page in the unstable book to list _all_
    of the other ABI strings that are introduced by this feature gate.

    Now, all of the ABI's specified by RFC 2945 are shown.

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
3 years agoadd integration tests, unwind across FFI boundary
katelyn a. martin [Sat, 12 Dec 2020 01:54:47 +0000 (20:54 -0500)]
add integration tests, unwind across FFI boundary

 ### Integration Tests

    This commit introduces some new fixtures to the `run-make-fulldeps`
    test suite.

        * c-unwind-abi-catch-panic: Exercise unwinding a panic. This
          catches a panic across an FFI boundary and downcasts it into
          an integer.

        * c-unwind-abi-catch-lib-panic: This is similar to the previous
         `*catch-panic` test, however in this case the Rust code that
         panics resides in a separate crate.

 ### Add `rust_eh_personality` to `#[no_std]` alloc tests

    This commit addresses some test failures that now occur in the
    following two tests:

        * no_std-alloc-error-handler-custom.rs
        * no_std-alloc-error-handler-default.rs

    Each test now defines a `rust_eh_personality` extern function, in
    the same manner as shown in the "Writing an executable without
    stdlib" section of the `lang_items` documentation here:
    https://doc.rust-lang.org/unstable-book/language-features/lang-items.html#writing-an-executable-without-stdlib

    Without this change, these tests would fail to compile due to a
    linking error explaining that there was an "undefined reference
    to `rust_eh_personality'."

 ### Updated hash

    * update 32-bit hash in `impl1` test

 ### Panics

    This commit uses `panic!` macro invocations that return a string,
    rather than using an integer as a panic payload.

    Doing so avoids the following warnings that were observed during
    rollup for the `*-msvc-1` targets:

    ```
    warning: panic message is not a string literal
      --> panic.rs:10:16
       |
    10 |         panic!(x); // That is too big!
       |                ^
       |
       = note: `#[warn(non_fmt_panic)]` on by default
       = note: this is no longer accepted in Rust 2021
    help: add a "{}" format string to Display the message
       |
    10 |         panic!("{}", x); // That is too big!
       |                ^^^^^
    help: or use std::panic::panic_any instead
       |
    10 |         std::panic::panic_any(x); // That is too big!
       |         ^^^^^^^^^^^^^^^^^^^^^

    warning: 1 warning emitted
    ```

    See: https://github.com/rust-lang-ci/rust/runs/1992118428

    As these errors imply, panicking without a format string will be
    disallowed in Rust 2021, per #78500.

3 years agoimplement unwinding abi's (RFC 2945)
katelyn a. martin [Thu, 10 Sep 2020 17:38:39 +0000 (13:38 -0400)]
implement unwinding abi's (RFC 2945)

 ### Changes

    This commit implements unwind ABI's, specified in RFC 2945.

    We adjust the `rustc_middle::ty::layout::fn_can_unwind` function,
    used to compute whether or not a `FnAbi` object represents a
    function that should be able to unwind when `panic=unwind` is in
    use.

    Changes are also made to
    `rustc_mir_build::build::should_abort_on_panic` so that the
    function ABI is used to determind whether it should abort, assuming
    that the `panic=unwind` strategy is being used, and no explicit
    unwind attribute was provided.

 ### Tests

    Unit tests, checking that the behavior is correct for `C-unwind`,
    `stdcall-unwind`, `system-unwind`, and `thiscall-unwind`, are
    included. These alternative `unwind` ABI strings are specified in
    RFC 2945, in the "_Other `unwind` ABI strings_" section.

    Additionally, a test case is included to assert that the LLVM IR
    generated for an external function defined with the `C-unwind` ABI
    will be appropriately labeled with the `nounwind` LLVM attribute
    when the `panic=abort` compilation flag is used.

 ### Ignore Directives

    This commit uses `ignore-*` directives in two of our `*-unwind` ABI
    test cases.

    Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
    ignore architectures that do not support `stdcall` and `thiscall`,
    respectively.

    These directives are cribbed from
    `src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
    `src/test/ui/extern/extern-thiscall.rs` for `thiscall`.

3 years agorustc_target: add "unwind" payloads to `Abi`
katelyn a. martin [Thu, 27 Aug 2020 15:49:18 +0000 (11:49 -0400)]
rustc_target: add "unwind" payloads to `Abi`

 ### Overview

    This commit begins the implementation work for RFC 2945. For more
    information, see the rendered RFC [1] and tracking issue [2].

    A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
    and `Thiscall` variants, marking whether unwinding across FFI
    boundaries is acceptable. The cases where each of these variants'
    `unwind` member is true correspond with the `C-unwind`,
    `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
    introduced in RFC 2945 [3].

 ### Feature Gate and Unstable Book

    This commit adds a `c_unwind` feature gate for the new ABI strings.
    Tests for this feature gate are included in `src/test/ui/c-unwind/`,
    which ensure that this feature gate works correctly for each of the
    new ABIs.

    A new language features entry in the unstable book is added as well.

 ### Further Work To Be Done

    This commit does not proceed to implement the new unwinding ABIs,
    and is intentionally scoped specifically to *defining* the ABIs and
    their feature flag.

 ### One Note on Test Churn

    This will lead to some test churn, in re-blessing hash tests, as the
    deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
    because we can no longer guarantee the ordering of the `Abi`
    variants.

    While this is a downside, this decision was made bearing in mind
    that RFC 2945 states the following, in the "Other `unwind` Strings"
    section [3]:

    >  More unwind variants of existing ABI strings may be introduced,
    >  with the same semantics, without an additional RFC.

    Adding a new variant for each of these cases, rather than specifying
    a payload for a given ABI, would quickly become untenable, and make
    working with the `Abi` enum prone to mistakes.

    This approach encodes the unwinding information *into* a given ABI,
    to account for the future possibility of other `-unwind` ABI
    strings.

 ### Ignore Directives

    `ignore-*` directives are used in two of our `*-unwind` ABI test
    cases.

    Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
    ignore architectures that do not support `stdcall` and
    `thiscall`, respectively.

    These directives are cribbed from
    `src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
    `src/test/ui/extern/extern-thiscall.rs` for `thiscall`.

    This would otherwise fail on some targets, see:
    https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60

 ### Footnotes

[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings

3 years agoClean up todos
kadmin [Fri, 26 Feb 2021 16:42:51 +0000 (16:42 +0000)]
Clean up todos

Also add some span_bugs where it is unreachable

3 years agoDon't hardcode the `v1` prelude in diagnostics.
Mara Bos [Tue, 9 Mar 2021 18:40:01 +0000 (19:40 +0100)]
Don't hardcode the `v1` prelude in diagnostics.

Instead of looking for `std::prelude::v1`, this changes it to look for
`std::prelude::<anything>`.

3 years agoRebase fallout.
Camille GILLOT [Fri, 19 Feb 2021 08:07:58 +0000 (09:07 +0100)]
Rebase fallout.

3 years agoUse BTreeMap to store attributes.
Camille GILLOT [Sun, 24 Jan 2021 16:14:17 +0000 (17:14 +0100)]
Use BTreeMap to store attributes.

3 years agoDeduplicate unchecked_attrs errors.
Camille GILLOT [Mon, 7 Dec 2020 21:46:35 +0000 (22:46 +0100)]
Deduplicate unchecked_attrs errors.

3 years agoAlias attributes of hir::Stmt.
Camille GILLOT [Sun, 6 Dec 2020 20:59:44 +0000 (21:59 +0100)]
Alias attributes of hir::Stmt.

The attributes for statements and those of the statements' content.

3 years agoFix ui-fulldeps tests.
Camille GILLOT [Sat, 5 Dec 2020 20:23:37 +0000 (21:23 +0100)]
Fix ui-fulldeps tests.

3 years agoTrack HirId when visiting attributes.
Camille GILLOT [Sat, 5 Dec 2020 16:40:19 +0000 (17:40 +0100)]
Track HirId when visiting attributes.

3 years agoBless tests.
Camille GILLOT [Sat, 28 Nov 2020 19:56:52 +0000 (20:56 +0100)]
Bless tests.

3 years agoRemove hir::Expr::attrs.
Camille GILLOT [Fri, 27 Nov 2020 16:41:05 +0000 (17:41 +0100)]
Remove hir::Expr::attrs.

3 years agoRemove hir::Item::attrs.
Camille GILLOT [Sun, 24 Jan 2021 12:17:54 +0000 (13:17 +0100)]
Remove hir::Item::attrs.

3 years agoRemove hir::ImplItem::attrs.
Camille GILLOT [Fri, 27 Nov 2020 08:55:10 +0000 (09:55 +0100)]
Remove hir::ImplItem::attrs.

3 years agoRemove hir::TraitItem::attrs.
Camille GILLOT [Fri, 27 Nov 2020 08:41:53 +0000 (09:41 +0100)]
Remove hir::TraitItem::attrs.

3 years agoRemove hir::ForeignItem::attrs.
Camille GILLOT [Thu, 26 Nov 2020 23:35:22 +0000 (00:35 +0100)]
Remove hir::ForeignItem::attrs.

3 years agoRemove hir::StructField::attrs.
Camille GILLOT [Thu, 26 Nov 2020 23:27:34 +0000 (00:27 +0100)]
Remove hir::StructField::attrs.

3 years agoRemove hir::Variant::attrs.
Camille GILLOT [Thu, 26 Nov 2020 23:07:36 +0000 (00:07 +0100)]
Remove hir::Variant::attrs.

3 years agoRemove hir::Param::attrs.
Camille GILLOT [Thu, 26 Nov 2020 22:51:27 +0000 (23:51 +0100)]
Remove hir::Param::attrs.

3 years agoRemove hir::Arm::attrs.
Camille GILLOT [Thu, 26 Nov 2020 22:46:48 +0000 (23:46 +0100)]
Remove hir::Arm::attrs.

3 years agoRemove hir::Crate::attrs.
Camille GILLOT [Thu, 26 Nov 2020 22:38:53 +0000 (23:38 +0100)]
Remove hir::Crate::attrs.

3 years agoRemove hir::MacroDef::attrs.
Camille GILLOT [Thu, 18 Feb 2021 18:34:40 +0000 (19:34 +0100)]
Remove hir::MacroDef::attrs.

3 years agoRemove hir::GenericParam::attrs.
Camille GILLOT [Fri, 27 Nov 2020 17:01:40 +0000 (18:01 +0100)]
Remove hir::GenericParam::attrs.

3 years agoRemove hir::Local::attrs.
Camille GILLOT [Wed, 25 Nov 2020 21:45:24 +0000 (22:45 +0100)]
Remove hir::Local::attrs.

3 years agoRemove hir::StmtKind::attrs.
Camille GILLOT [Wed, 25 Nov 2020 21:07:09 +0000 (22:07 +0100)]
Remove hir::StmtKind::attrs.

3 years agoVisit attributes in one go.
Camille GILLOT [Wed, 25 Nov 2020 22:04:38 +0000 (23:04 +0100)]
Visit attributes in one go.

3 years agoDo not store attrs in FnKind.
Camille GILLOT [Fri, 27 Nov 2020 08:24:42 +0000 (09:24 +0100)]
Do not store attrs in FnKind.

3 years agoSimplify clippy author.
Camille GILLOT [Sun, 6 Dec 2020 21:00:24 +0000 (22:00 +0100)]
Simplify clippy author.

3 years agoAccess attrs directly from HirId in rustdoc::doctest.
Camille GILLOT [Thu, 18 Feb 2021 18:35:12 +0000 (19:35 +0100)]
Access attrs directly from HirId in rustdoc::doctest.

3 years agoAccess attrs directly from HirId in rustc_passes::diagnostic_item.
Camille GILLOT [Thu, 26 Nov 2020 23:34:23 +0000 (00:34 +0100)]
Access attrs directly from HirId in rustc_passes::diagnostic_item.

3 years agoAccess attrs directly from HirId in rustc_lint::builtin.
Camille GILLOT [Thu, 26 Nov 2020 23:05:29 +0000 (00:05 +0100)]
Access attrs directly from HirId in rustc_lint::builtin.

3 years agoAccess attrs directly from HirId in rustc_passes::lang_items.
Camille GILLOT [Thu, 26 Nov 2020 23:01:36 +0000 (00:01 +0100)]
Access attrs directly from HirId in rustc_passes::lang_items.

3 years agoAccess attrs directly from HirId in rustc_passes::dead.
Camille GILLOT [Thu, 26 Nov 2020 23:00:02 +0000 (00:00 +0100)]
Access attrs directly from HirId in rustc_passes::dead.

3 years agoAccess attrs directly from HirId in rustc_passes::stability.
Camille GILLOT [Thu, 26 Nov 2020 22:25:07 +0000 (23:25 +0100)]
Access attrs directly from HirId in rustc_passes::stability.

3 years agoAccess attrs directly from HirId in rustc_incremental::assert_dep_graph.
Camille GILLOT [Thu, 26 Nov 2020 22:23:01 +0000 (23:23 +0100)]
Access attrs directly from HirId in rustc_incremental::assert_dep_graph.

3 years agoAccess attrs directly from HirId in rustc_passes::check_attr.
Camille GILLOT [Wed, 25 Nov 2020 22:27:23 +0000 (23:27 +0100)]
Access attrs directly from HirId in rustc_passes::check_attr.

3 years agoAccess attrs directly from HirId in rustc_lint::levels.
Camille GILLOT [Wed, 25 Nov 2020 22:25:57 +0000 (23:25 +0100)]
Access attrs directly from HirId in rustc_lint::levels.

3 years agoAccess attrs directly from HirId in rustc_lint::late.
Camille GILLOT [Wed, 25 Nov 2020 22:19:54 +0000 (23:19 +0100)]
Access attrs directly from HirId in rustc_lint::late.

3 years agoTake a slice in stmt_let_pat.
Camille GILLOT [Mon, 4 Jan 2021 20:50:45 +0000 (21:50 +0100)]
Take a slice in stmt_let_pat.

3 years agoCollect attributes during HIR lowering.
Camille GILLOT [Tue, 24 Nov 2020 17:12:42 +0000 (18:12 +0100)]
Collect attributes during HIR lowering.

3 years agoIntroduce HirIdVec.
Camille GILLOT [Tue, 19 May 2020 10:05:19 +0000 (12:05 +0200)]
Introduce HirIdVec.

3 years agoRemove useless Clone bound in IndexVec.
Camille GILLOT [Tue, 19 May 2020 10:04:33 +0000 (12:04 +0200)]
Remove useless Clone bound in IndexVec.