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 7 pull requests #94469

Merged
merged 34 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
861a6e8
Add spectral_norm example from packed_simd
deantvv Nov 28, 2021
2f7b7d5
Don't use is_local to determine function cleaning method call intent
CraftSpider Jan 27, 2022
1c82e5e
Convert empty tuple to DefaultReturn in ty path
CraftSpider Jan 27, 2022
eae2026
Set visibility to inherited in trait impls to match HIR
CraftSpider Jan 27, 2022
d90138b
Remove now-unnecessary blanket impl HIR check
CraftSpider Jan 27, 2022
2d2163b
Same code for ty and hir impl items
CraftSpider Jan 27, 2022
01350a2
Merge portable-simd#203 - deantvv/add-spectral-norm
workingjubilee Feb 2, 2022
ebf65de
Delete outmoded fn round_from_int
workingjubilee Feb 3, 2022
4910274
Genericize to_int_unchecked
workingjubilee Feb 3, 2022
672bfeb
Remove overflow panic from divrem
workingjubilee Feb 8, 2022
e628a29
Document Simd is Simd<Wrapping<T>, N>
workingjubilee Feb 8, 2022
5d52455
Review for clarity and concision
workingjubilee Feb 9, 2022
6143bde
Merge rust-lang/portable-simd#243 from ./no-overflow-panic
workingjubilee Feb 9, 2022
dddfffc
Add some safety comments
calebzulawski Nov 5, 2021
78a18c3
rust-lang/portable-simd#245: Explain unsafe contracts of core::simd
workingjubilee Feb 10, 2022
3eb983e
Fix `setsockopt` and `getsockopt` parameter names.
chrisnc Feb 19, 2022
f2ebd0a
Remove assertion on output length for `getsockopt`.
chrisnc Feb 19, 2022
b02698c
use `BOOL` for `TCP_NODELAY` `setsockopt` value on Windows
chrisnc Feb 17, 2022
842ac87
Use bitmask trait
calebzulawski Jan 14, 2022
11c3eef
Manually implement for supported lanes
calebzulawski Feb 6, 2022
20fa4b7
Make internal mask implementation safe
calebzulawski Feb 9, 2022
d3d2a27
Add Atomic*::from_mut_slice
cuviper Feb 25, 2022
5f49d4c
rust-lang/portable-simd#239: Bitmask conversion trait
workingjubilee Feb 26, 2022
6dcf5d8
Lint against more useless `#[must_use]` attributes
PatchMixolydic Feb 12, 2022
5ce3f56
Make deref suggestion better
compiler-errors Dec 5, 2021
4de99e1
Sync rust-lang/portable-simd@5f49d4c8435a25d804b2f375e949cb25479f5be9
workingjubilee Feb 28, 2022
d956c8b
5 - Make more use of let_chains
c410-f3r Feb 28, 2022
4bd40d6
Rollup merge of #91545 - compiler-errors:deref-suggestion-improvement…
Dylan-DPC Mar 1, 2022
2fb5a16
Rollup merge of #93385 - CraftSpider:rustdoc-ty-fixes, r=camelid
Dylan-DPC Mar 1, 2022
daed864
Rollup merge of #93926 - PatchMixolydic:bugfix/must_use-on-exprs, r=c…
Dylan-DPC Mar 1, 2022
06d47a4
Rollup merge of #94094 - chrisnc:tcp-nodelay-windows-bool, r=dtolnay
Dylan-DPC Mar 1, 2022
5bd119d
Rollup merge of #94384 - cuviper:atomic-slice, r=dtolnay
Dylan-DPC Mar 1, 2022
bf6954b
Rollup merge of #94448 - c410-f3r:yet-more-let-chains, r=estebank
Dylan-DPC Mar 1, 2022
4001d98
Rollup merge of #94452 - workingjubilee:sync-simd-bitmasks, r=working…
Dylan-DPC Mar 1, 2022
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
1 change: 0 additions & 1 deletion compiler/rustc_macros/src/session_diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
// next call to `it.next()` retrieves the next character.
while let Some(c) = it.next() {
if c == '{' && *it.peek().unwrap_or(&'\0') != '{' {
#[must_use]
let mut eat_argument = || -> Option<String> {
let mut result = String::new();
// Format specifiers look like
Expand Down
65 changes: 48 additions & 17 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,24 +1111,55 @@ impl CheckAttrVisitor<'_> {
}

/// Warns against some misuses of `#[must_use]`
fn check_must_use(&self, hir_id: HirId, attr: &Attribute, span: Span, _target: Target) -> bool {
fn check_must_use(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
let node = self.tcx.hir().get(hir_id);
if let Some(fn_node) = node.fn_kind() {
if let rustc_hir::IsAsync::Async = fn_node.asyncness() {
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
lint.build(
"`must_use` attribute on `async` functions \
applies to the anonymous `Future` returned by the \
function, not the value within",
)
.span_label(
span,
"this attribute does nothing, the `Future`s \
returned by async functions are already `must_use`",
)
.emit();
});
}
if let Some(kind) = node.fn_kind() && let rustc_hir::IsAsync::Async = kind.asyncness() {
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
lint.build(
"`must_use` attribute on `async` functions \
applies to the anonymous `Future` returned by the \
function, not the value within",
)
.span_label(
span,
"this attribute does nothing, the `Future`s \
returned by async functions are already `must_use`",
)
.emit();
});
}

if !matches!(
target,
Target::Fn
| Target::Enum
| Target::Struct
| Target::Union
| Target::Method(_)
| Target::ForeignFn
// `impl Trait` in return position can trip
// `unused_must_use` if `Trait` is marked as
// `#[must_use]`
| Target::Trait
) {
let article = match target {
Target::ExternCrate
| Target::OpaqueTy
| Target::Enum
| Target::Impl
| Target::Expression
| Target::Arm
| Target::AssocConst
| Target::AssocTy => "an",
_ => "a",
};

self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
lint.build(&format!(
"`#[must_use]` has no effect when applied to {article} {target}"
))
.emit();
});
}

// For now, its always valid
Expand Down
55 changes: 27 additions & 28 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,34 +683,33 @@ impl<'tcx> DeadVisitor<'tcx> {
let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id());
let mut err = lint.build(&format!("{} is never {}: `{}`", descr, participle, name));
let hir = self.tcx.hir();
if let Some(encl_scope) = hir.get_enclosing_scope(id) {
if let Some(encl_def_id) = hir.opt_local_def_id(encl_scope) {
if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) {
let traits_str = ign_traits
.iter()
.map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id)))
.collect::<Vec<_>>()
.join(" and ");
let plural_s = pluralize!(ign_traits.len());
let article = if ign_traits.len() > 1 { "" } else { "a " };
let is_are = if ign_traits.len() > 1 { "these are" } else { "this is" };
let msg = format!(
"`{}` has {}derived impl{} for the trait{} {}, but {} \
intentionally ignored during dead code analysis",
self.tcx.item_name(encl_def_id.to_def_id()),
article,
plural_s,
plural_s,
traits_str,
is_are
);
let multispan = ign_traits
.iter()
.map(|(_, impl_id)| self.tcx.def_span(*impl_id))
.collect::<Vec<_>>();
err.span_note(multispan, &msg);
}
}
if let Some(encl_scope) = hir.get_enclosing_scope(id)
&& let Some(encl_def_id) = hir.opt_local_def_id(encl_scope)
&& let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id)
{
let traits_str = ign_traits
.iter()
.map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id)))
.collect::<Vec<_>>()
.join(" and ");
let plural_s = pluralize!(ign_traits.len());
let article = if ign_traits.len() > 1 { "" } else { "a " };
let is_are = if ign_traits.len() > 1 { "these are" } else { "this is" };
let msg = format!(
"`{}` has {}derived impl{} for the trait{} {}, but {} \
intentionally ignored during dead code analysis",
self.tcx.item_name(encl_def_id.to_def_id()),
article,
plural_s,
plural_s,
traits_str,
is_are
);
let multispan = ign_traits
.iter()
.map(|(_, impl_id)| self.tcx.def_span(*impl_id))
.collect::<Vec<_>>();
err.span_note(multispan, &msg);
}
err.emit();
});
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
//!
//! This API is completely unstable and subject to change.

#![allow(rustc::potential_query_instability)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(crate_visibility_modifier)]
#![feature(iter_intersperse)]
#![feature(let_else)]
#![feature(let_chains)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(nll)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)]

#[macro_use]
extern crate rustc_middle;
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,11 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
let def_id = local_def_id.to_def_id();

// Don't run unused pass for #[derive()]
if let Some(parent) = self.tcx.parent(def_id) {
if let DefKind::Impl = self.tcx.def_kind(parent.expect_local()) {
if self.tcx.has_attr(parent, sym::automatically_derived) {
return;
}
}
if let Some(parent) = self.tcx.parent(def_id)
&& let DefKind::Impl = self.tcx.def_kind(parent.expect_local())
&& self.tcx.has_attr(parent, sym::automatically_derived)
{
return;
}

// Don't run unused pass for #[naked]
Expand Down
32 changes: 15 additions & 17 deletions compiler/rustc_passes/src/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,22 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
_ => None,
};

if let Some(res) = res {
if let Some(def_id) = res.opt_def_id().and_then(|def_id| def_id.as_local()) {
if self.def_id_represents_local_inlined_item(def_id.to_def_id()) {
self.worklist.push(def_id);
} else {
match res {
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
Res::Def(DefKind::Const | DefKind::AssocConst, _) => {
self.worklist.push(def_id);
}
if let Some(res) = res && let Some(def_id) = res.opt_def_id().and_then(|el| el.as_local()) {
if self.def_id_represents_local_inlined_item(def_id.to_def_id()) {
self.worklist.push(def_id);
} else {
match res {
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
Res::Def(DefKind::Const | DefKind::AssocConst, _) => {
self.worklist.push(def_id);
}

// If this wasn't a static, then the destination is
// surely reachable.
_ => {
self.reachable_symbols.insert(def_id);
}
// If this wasn't a static, then the destination is
// surely reachable.
_ => {
self.reachable_symbols.insert(def_id);
}
}
}
Expand Down
Loading