Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #84947

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c185f08
Add doc alias for `chdir` to `std::env::set_current_dir`
joshtriplett Apr 29, 2021
fe68b1a
Fix linker_args with --target=sparcv9-sun-solaris
iladin Apr 30, 2021
dd43d13
Reduce duplication in `impl_dep_tracking_hash` macros
jyn514 Apr 22, 2021
1e89b58
Account for unsatisfied bounds in E0599
estebank May 2, 2021
2e559c8
use `else if` in std library
wcampbell0x2a May 3, 2021
b4bfb0e
Update RELEASES.md for 1.52.0
XAMPPRocky Apr 14, 2021
f9eda61
rustbuild: Pass a `threads` flag that works to windows-gnu lld
petrochenkov May 3, 2021
d53469c
Clarify documentation for `[T]::contains`. Fixes #84877.
jimblandy May 3, 2021
d459b5d
platform-support: Center the contents of the `std` and `host` columns
joshtriplett May 3, 2021
389333a
Update `ptr` docs with regards to `ptr::addr_of!`
jfrimmel Mar 27, 2021
450d121
Tests for field is never read diagnostic
sunjay Mar 11, 2021
67f228e
Added suggestion and note for when a field is never used
sunjay Mar 12, 2021
715a2d4
Updating test stderr files
sunjay Mar 12, 2021
d4c1ade
Trying out a new message that works a little better for values *and* …
sunjay Mar 12, 2021
bacfc34
New shorter diagnostic note that is different for items versus fields
sunjay Mar 13, 2021
0ba2c6a
Putting help message only under the identifier that needs to be prefixed
sunjay Mar 25, 2021
ee7a6c6
Remove `rustc_middle::mir::interpret::CheckInAllocMsg::NullPointerTest`
May 4, 2021
11379f0
Do not ICE on invalid const param
estebank May 4, 2021
be1a3af
Rollup merge of #83004 - sunjay:field-never-read-issue-81658, r=pnkfelix
RalfJung May 5, 2021
9bb9367
Rollup merge of #83553 - jfrimmel:addr-of, r=m-ou-se
RalfJung May 5, 2021
2f825a0
Rollup merge of #84183 - rust-lang:relnotes-1.52.0, r=pietroalbini
RalfJung May 5, 2021
c037962
Rollup merge of #84468 - iladin:iladin/fix-84467, r=petrochenkov
RalfJung May 5, 2021
36caecf
Rollup merge of #84709 - joshtriplett:doc-alias-chdir, r=dtolnay
RalfJung May 5, 2021
5ade333
Rollup merge of #84803 - jyn514:duplicate-macros, r=petrochenkov
RalfJung May 5, 2021
92d368b
Rollup merge of #84808 - estebank:issue-84769, r=petrochenkov
RalfJung May 5, 2021
7dbda89
Rollup merge of #84843 - wcampbell0x2a:use-else-if-let, r=dtolnay
RalfJung May 5, 2021
bbfa06a
Rollup merge of #84865 - petrochenkov:llthread, r=Mark-Simulacrum
RalfJung May 5, 2021
80d2c9a
Rollup merge of #84878 - jimblandy:contains-doc-fix, r=joshtriplett
RalfJung May 5, 2021
20ae5ce
Rollup merge of #84882 - joshtriplett:platform-support-formatting, r=…
RalfJung May 5, 2021
1dbc2dc
Rollup merge of #84903 - hyd-dev:dead-check-in-alloc-msg, r=RalfJung
RalfJung May 5, 2021
c86f510
Rollup merge of #84913 - estebank:issue-84831, r=varkor
RalfJung May 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,151 @@
Version 1.52.0 (2021-05-06)
============================

Language
--------
- [Added the `unsafe_op_in_unsafe_fn` lint, which checks whether the unsafe code
in an `unsafe fn` is wrapped in a `unsafe` block.][79208] This lint
is allowed by default, and may become a warning or hard error in a
future edition.
- [You can now cast mutable references to arrays to a pointer of the same type as
the element.][81479]

Compiler
--------
- [Upgraded the default LLVM to LLVM 12.][81451]

Added tier 3\* support for the following targets.

- [`s390x-unknown-linux-musl`][82166]
- [`riscv32gc-unknown-linux-musl` & `riscv64gc-unknown-linux-musl`][82202]
- [`powerpc-unknown-openbsd`][82733]

\* Refer to Rust's [platform support page][platform-support-doc] for more
information on Rust's tiered platform support.

Libraries
---------
- [`OsString` now implements `Extend` and `FromIterator`.][82121]
- [`cmp::Reverse` now has `#[repr(transparent)]` representation.][81879]
- [`Arc<impl Error>` now implements `error::Error`.][80553]
- [All integer division and remainder operations are now `const`.][80962]

Stabilised APIs
-------------
- [`Arguments::as_str`]
- [`char::MAX`]
- [`char::REPLACEMENT_CHARACTER`]
- [`char::UNICODE_VERSION`]
- [`char::decode_utf16`]
- [`char::from_digit`]
- [`char::from_u32_unchecked`]
- [`char::from_u32`]
- [`slice::partition_point`]
- [`str::rsplit_once`]
- [`str::split_once`]

The following previously stable APIs are now `const`.

- [`char::len_utf8`]
- [`char::len_utf16`]
- [`char::to_ascii_uppercase`]
- [`char::to_ascii_lowercase`]
- [`char::eq_ignore_ascii_case`]
- [`u8::to_ascii_uppercase`]
- [`u8::to_ascii_lowercase`]
- [`u8::eq_ignore_ascii_case`]

Rustdoc
-------
- [Rustdoc lints are now treated as a tool lint, meaning that
lints are now prefixed with `rustdoc::` (e.g. `#[warn(rustdoc::non_autolinks)]`).][80527]
Using the old style is still allowed, and will become a warning in
a future release.
- [Rustdoc now supports argument files.][82261]
- [Rustdoc now generates smart punctuation for documentation.][79423]
- [You can now use "task lists" in Rustdoc Markdown.][81766] E.g.
```markdown
- [x] Complete
- [ ] Todo
```

Misc
----
- [You can now pass multiple filters to tests.][81356] E.g.
`cargo test -- foo bar` will run all tests that match `foo` and `bar`.
- [Rustup now distributes PDB symbols for the `std` library on Windows,
allowing you to see `std` symbols when debugging.][82218]

Internal Only
-------------
These changes provide no direct user facing benefits, but represent significant
improvements to the internals and overall performance of rustc and
related tools.

- [Check the result cache before the DepGraph when ensuring queries][81855]
- [Try fast_reject::simplify_type in coherence before doing full check][81744]
- [Only store a LocalDefId in some HIR nodes][81611]
- [Store HIR attributes in a side table][79519]

Compatibility Notes
-------------------
- [Cargo build scripts are now forbidden from setting `RUSTC_BOOTSTRAP`.][cargo/9181]
- [Removed support for the `x86_64-rumprun-netbsd` target.][82594]
- [Deprecated the `x86_64-sun-solaris` target in favor of `x86_64-pc-solaris`.][82216]
- [Rustdoc now only accepts `,`, ` `, and `\t` as delimiters for specifying
languages in code blocks.][78429]
- [Rustc now catches more cases of `pub_use_of_private_extern_crate`][80763]
- [Changes in how proc macros handle whitespace may lead to panics when used
with older `proc-macro-hack` versions. A `cargo update` should be sufficient to fix this in all cases.][84136]

[84136]: https://github.com/rust-lang/rust/issues/84136
[80763]: https://github.com/rust-lang/rust/pull/80763
[82166]: https://github.com/rust-lang/rust/pull/82166
[82121]: https://github.com/rust-lang/rust/pull/82121
[81879]: https://github.com/rust-lang/rust/pull/81879
[82261]: https://github.com/rust-lang/rust/pull/82261
[82218]: https://github.com/rust-lang/rust/pull/82218
[82216]: https://github.com/rust-lang/rust/pull/82216
[82202]: https://github.com/rust-lang/rust/pull/82202
[81855]: https://github.com/rust-lang/rust/pull/81855
[81766]: https://github.com/rust-lang/rust/pull/81766
[81744]: https://github.com/rust-lang/rust/pull/81744
[81611]: https://github.com/rust-lang/rust/pull/81611
[81479]: https://github.com/rust-lang/rust/pull/81479
[81451]: https://github.com/rust-lang/rust/pull/81451
[81356]: https://github.com/rust-lang/rust/pull/81356
[80962]: https://github.com/rust-lang/rust/pull/80962
[80553]: https://github.com/rust-lang/rust/pull/80553
[80527]: https://github.com/rust-lang/rust/pull/80527
[79519]: https://github.com/rust-lang/rust/pull/79519
[79423]: https://github.com/rust-lang/rust/pull/79423
[79208]: https://github.com/rust-lang/rust/pull/79208
[78429]: https://github.com/rust-lang/rust/pull/78429
[82733]: https://github.com/rust-lang/rust/pull/82733
[82594]: https://github.com/rust-lang/rust/pull/82594
[cargo/9181]: https://github.com/rust-lang/cargo/pull/9181
[`char::MAX`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.MAX
[`char::REPLACEMENT_CHARACTER`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.REPLACEMENT_CHARACTER
[`char::UNICODE_VERSION`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.UNICODE_VERSION
[`char::decode_utf16`]: https://doc.rust-lang.org/std/primitive.char.html#method.decode_utf16
[`char::from_u32`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_u32
[`char::from_u32_unchecked`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_u32_unchecked
[`char::from_digit`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_digit
[`Peekable::next_if`]: https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html#method.next_if
[`Peekable::next_if_eq`]: https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html#method.next_if_eq
[`Arguments::as_str`]: https://doc.rust-lang.org/stable/std/fmt/struct.Arguments.html#method.as_str
[`str::split_once`]: https://doc.rust-lang.org/stable/std/primitive.str.html#method.split_once
[`str::rsplit_once`]: https://doc.rust-lang.org/stable/std/primitive.str.html#method.rsplit_once
[`slice::partition_point`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.partition_point
[`char::len_utf8`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.len_utf8
[`char::len_utf16`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.len_utf16
[`char::to_ascii_uppercase`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.to_ascii_uppercase
[`char::to_ascii_lowercase`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.to_ascii_lowercase
[`char::eq_ignore_ascii_case`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.eq_ignore_ascii_case
[`u8::to_ascii_uppercase`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_ascii_uppercase
[`u8::to_ascii_lowercase`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_ascii_lowercase
[`u8::eq_ignore_ascii_case`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.eq_ignore_ascii_case

Version 1.51.0 (2021-03-25)
============================

Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,6 @@ impl<'a> Linker for GccLinker<'a> {
// insert it here.
if self.sess.target.is_like_osx {
self.linker_arg("-dead_strip");
} else if self.sess.target.is_like_solaris {
self.linker_arg("-zignore");

// If we're building a dylib, we don't use --gc-sections because LLVM
// has already done the best it can do, and we also don't want to
Expand Down Expand Up @@ -655,6 +653,10 @@ impl<'a> Linker for GccLinker<'a> {
fn add_as_needed(&mut self) {
if self.sess.target.linker_is_gnu {
self.linker_arg("--as-needed");
} else if self.sess.target.is_like_solaris {
// -z ignore is the Solaris equivalent to the GNU ld --as-needed option
self.linker_arg("-z");
self.linker_arg("ignore");
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ impl fmt::Display for InvalidProgramInfo<'_> {
#[derive(Debug, Copy, Clone, TyEncodable, TyDecodable, HashStable)]
pub enum CheckInAllocMsg {
MemoryAccessTest,
NullPointerTest,
PointerArithmeticTest,
InboundsTest,
}
Expand All @@ -185,7 +184,6 @@ impl fmt::Display for CheckInAllocMsg {
"{}",
match *self {
CheckInAllocMsg::MemoryAccessTest => "memory access",
CheckInAllocMsg::NullPointerTest => "null pointer test",
CheckInAllocMsg::PointerArithmeticTest => "pointer arithmetic",
CheckInAllocMsg::InboundsTest => "inbounds test",
}
Expand Down Expand Up @@ -308,9 +306,6 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
ptr.alloc_id,
allocation_size.bytes()
),
DanglingIntPointer(_, CheckInAllocMsg::NullPointerTest) => {
write!(f, "null pointer is not allowed for this operation")
}
DanglingIntPointer(i, msg) => {
write!(f, "{} failed: 0x{:x} is not a valid pointer", msg, i)
}
Expand Down
61 changes: 52 additions & 9 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// from live codes are live, and everything else is dead.

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
Expand All @@ -15,7 +16,7 @@ use rustc_middle::middle::privacy;
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
use rustc_session::lint;

use rustc_span::symbol::{sym, Symbol};
use rustc_span::symbol::{sym, Ident, Symbol};

// Any local node that may call something in its body block should be
// explored. For example, if it's a live Node::Item that is a
Expand Down Expand Up @@ -507,6 +508,13 @@ fn find_live<'tcx>(
symbol_visitor.live_symbols
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum ExtraNote {
/// Use this to provide some examples in the diagnostic of potential other purposes for a value
/// or field that is dead code
OtherPurposeExamples,
}

struct DeadVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
live_symbols: FxHashSet<hir::HirId>,
Expand Down Expand Up @@ -572,14 +580,42 @@ impl DeadVisitor<'tcx> {
&mut self,
id: hir::HirId,
span: rustc_span::Span,
name: Symbol,
name: Ident,
participle: &str,
extra_note: Option<ExtraNote>,
) {
if !name.as_str().starts_with('_') {
self.tcx.struct_span_lint_hir(lint::builtin::DEAD_CODE, id, span, |lint| {
let def_id = self.tcx.hir().local_def_id(id);
let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id());
lint.build(&format!("{} is never {}: `{}`", descr, participle, name)).emit()

let prefixed = vec![(name.span, format!("_{}", name))];

let mut diag =
lint.build(&format!("{} is never {}: `{}`", descr, participle, name));

diag.multipart_suggestion(
"if this is intentional, prefix it with an underscore",
prefixed,
Applicability::MachineApplicable,
);

let mut note = format!(
"the leading underscore signals that this {} serves some other \
purpose even if it isn't used in a way that we can detect.",
descr,
);
if matches!(extra_note, Some(ExtraNote::OtherPurposeExamples)) {
note += " (e.g. for its effect when dropped or in foreign code)";
}

diag.note(&note);

// Force the note we added to the front, before any other subdiagnostics
// added in lint.build(...)
diag.children.rotate_right(1);

diag.emit()
});
}
}
Expand Down Expand Up @@ -625,7 +661,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
hir::ItemKind::Struct(..) => "constructed", // Issue #52325
_ => "used",
};
self.warn_dead_code(item.hir_id(), span, item.ident.name, participle);
self.warn_dead_code(item.hir_id(), span, item.ident, participle, None);
} else {
// Only continue if we didn't warn
intravisit::walk_item(self, item);
Expand All @@ -639,22 +675,28 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
id: hir::HirId,
) {
if self.should_warn_about_variant(&variant) {
self.warn_dead_code(variant.id, variant.span, variant.ident.name, "constructed");
self.warn_dead_code(variant.id, variant.span, variant.ident, "constructed", None);
} else {
intravisit::walk_variant(self, variant, g, id);
}
}

fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem<'tcx>) {
if self.should_warn_about_foreign_item(fi) {
self.warn_dead_code(fi.hir_id(), fi.span, fi.ident.name, "used");
self.warn_dead_code(fi.hir_id(), fi.span, fi.ident, "used", None);
}
intravisit::walk_foreign_item(self, fi);
}

fn visit_field_def(&mut self, field: &'tcx hir::FieldDef<'tcx>) {
if self.should_warn_about_field(&field) {
self.warn_dead_code(field.hir_id, field.span, field.ident.name, "read");
self.warn_dead_code(
field.hir_id,
field.span,
field.ident,
"read",
Some(ExtraNote::OtherPurposeExamples),
);
}
intravisit::walk_field_def(self, field);
}
Expand All @@ -666,8 +708,9 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
self.warn_dead_code(
impl_item.hir_id(),
impl_item.span,
impl_item.ident.name,
impl_item.ident,
"used",
None,
);
}
self.visit_nested_body(body_id)
Expand All @@ -685,7 +728,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
} else {
impl_item.ident.span
};
self.warn_dead_code(impl_item.hir_id(), span, impl_item.ident.name, "used");
self.warn_dead_code(impl_item.hir_id(), span, impl_item.ident, "used", None);
}
self.visit_nested_body(body_id)
}
Expand Down
Loading