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 6 pull requests #119009

Merged
merged 13 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,9 +1260,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
);

// `a = lhs1; b = lhs2;`.
let stmts = self
.arena
.alloc_from_iter(std::iter::once(destructure_let).chain(assignments.into_iter()));
let stmts = self.arena.alloc_from_iter(std::iter::once(destructure_let).chain(assignments));

// Wrap everything in a block.
hir::ExprKind::Block(self.block_all(whole_span, stmts, None), None)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
let new_kind = match ty.kind() {
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)),
Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.pointer_width)),
t @ (Uint(_) | Int(_)) => t.clone(),
t @ (Uint(_) | Int(_)) => *t,
_ => panic!("tried to get overflow intrinsic for op applied to non-int type"),
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->

if let Ok(rel_path) = abs_path.strip_prefix(working_directory) {
(
working_directory.to_string_lossy().into(),
working_directory.to_string_lossy(),
rel_path.to_string_lossy().into_owned(),
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
})
.collect();

state_specific_fields.into_iter().chain(common_fields.into_iter()).collect()
state_specific_fields.into_iter().chain(common_fields).collect()
},
|cx| build_generic_type_param_di_nodes(cx, coroutine_type_and_layout.ty),
)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/sorted_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<K: Ord, V> SortedMap<K, V> {
if index == self.data.len() || elements.last().unwrap().0 < self.data[index].0 {
// We can copy the whole range without having to mix with
// existing elements.
self.data.splice(index..index, elements.into_iter());
self.data.splice(index..index, elements);
return;
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ where
#[rustc_diagnostic_item = "DecorateLint"]
pub trait DecorateLint<'a, G: EmissionGuarantee> {
/// Decorate and emit a lint.
fn decorate_lint<'b>(
self,
diag: &'b mut DiagnosticBuilder<'a, G>,
) -> &'b mut DiagnosticBuilder<'a, G>;
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, G>);

fn msg(&self) -> DiagnosticMessage;
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2677,10 +2677,7 @@ fn from_stderr(color: ColorConfig) -> Destination {
/// On Windows, BRIGHT_BLUE is hard to read on black. Use cyan instead.
///
/// See #36178.
#[cfg(windows)]
const BRIGHT_BLUE: Color = Color::Cyan;
#[cfg(not(windows))]
const BRIGHT_BLUE: Color = Color::Blue;
const BRIGHT_BLUE: Color = if cfg!(windows) { Color::Cyan } else { Color::Blue };

impl Style {
fn color_spec(&self, lvl: Level) -> ColorSpec {
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ impl Expr<'_> {
ExprKind::Call(..) => ExprPrecedence::Call,
ExprKind::MethodCall(..) => ExprPrecedence::MethodCall,
ExprKind::Tup(_) => ExprPrecedence::Tup,
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node.into()),
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
ExprKind::Unary(..) => ExprPrecedence::Unary,
ExprKind::Lit(_) => ExprPrecedence::Lit,
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
Expand Down Expand Up @@ -1697,11 +1697,9 @@ impl Expr<'_> {
// them being used only for its side-effects.
base.can_have_side_effects()
}
ExprKind::Struct(_, fields, init) => fields
.iter()
.map(|field| field.expr)
.chain(init.into_iter())
.any(|e| e.can_have_side_effects()),
ExprKind::Struct(_, fields, init) => {
fields.iter().map(|field| field.expr).chain(init).any(|e| e.can_have_side_effects())
}

ExprKind::Array(args)
| ExprKind::Tup(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
// Nested poly trait refs have the binders concatenated
let mut full_binders =
self.map.late_bound_vars.entry(*hir_id).or_default().clone();
full_binders.extend(supertrait_bound_vars.into_iter());
full_binders.extend(supertrait_bound_vars);
break (full_binders, BinderScopeType::Concatenating);
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,13 @@ impl rustc_errors::AddToDiagnostic for CastUnknownPointerSub {
{
match self {
CastUnknownPointerSub::To(span) => {
let msg = f(diag, crate::fluent_generated::hir_typeck_label_to.into());
let msg = f(diag, crate::fluent_generated::hir_typeck_label_to);
diag.span_label(span, msg);
let msg = f(diag, crate::fluent_generated::hir_typeck_note.into());
let msg = f(diag, crate::fluent_generated::hir_typeck_note);
diag.note(msg);
}
CastUnknownPointerSub::From(span) => {
let msg = f(diag, crate::fluent_generated::hir_typeck_label_from.into());
let msg = f(diag, crate::fluent_generated::hir_typeck_label_from);
diag.span_label(span, msg);
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,9 +1546,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
);

let candidate_obligations = impl_obligations
.chain(norm_obligations.into_iter())
.chain(norm_obligations)
.chain(ref_obligations.iter().cloned())
.chain(normalization_obligations.into_iter());
.chain(normalization_obligations);

// Evaluate those obligations to see if they might possibly hold.
for o in candidate_obligations {
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_infer/src/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
// see the extensive comment in projection_must_outlive
let recursive_bound = {
let mut components = smallvec![];
compute_alias_components_recursive(
self.tcx,
alias_ty_as_ty.into(),
&mut components,
visited,
);
compute_alias_components_recursive(self.tcx, alias_ty_as_ty, &mut components, visited);
self.bound_from_components(&components, visited)
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/relate/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
}

pub fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
self.obligations.extend(obligations.into_iter());
self.obligations.extend(obligations);
}

pub fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>) {
Expand Down
56 changes: 11 additions & 45 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,8 @@ pub struct BuiltinMissingDebugImpl<'a> {

// Needed for def_path_str
impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("debug", self.tcx.def_path_str(self.def_id));
diag
}

fn msg(&self) -> DiagnosticMessage {
Expand Down Expand Up @@ -243,17 +239,13 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
}

impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.span_label(self.label, fluent::lint_label);
rustc_session::parse::add_feature_diagnostics(
diag,
self.parse_sess,
sym::async_fn_track_caller,
);
diag
}

fn msg(&self) -> DiagnosticMessage {
Expand Down Expand Up @@ -433,10 +425,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
}

impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("ty", self.ty);
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
Expand All @@ -447,7 +436,6 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
);
}
self.sub.add_to_diagnostic(diag);
diag
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down Expand Up @@ -1159,10 +1147,7 @@ pub struct NonFmtPanicUnused {

// Used because of two suggestions based on one Option<Span>
impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("count", self.count);
diag.note(fluent::lint_note);
if let Some(span) = self.suggestion {
Expand All @@ -1179,7 +1164,6 @@ impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
Applicability::MachineApplicable,
);
}
diag
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down Expand Up @@ -1358,12 +1342,9 @@ pub struct DropTraitConstraintsDiag<'a> {

// Needed for def_path_str
impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("predicate", self.predicate);
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id));
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand All @@ -1378,11 +1359,8 @@ pub struct DropGlue<'a> {

// Needed for def_path_str
impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id));
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down Expand Up @@ -1655,10 +1633,7 @@ pub struct ImproperCTypes<'a> {

// Used because of the complexity of Option<DiagnosticMessage>, DiagnosticMessage, and Option<Span>
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("ty", self.ty);
diag.set_arg("desc", self.desc);
diag.span_label(self.label, fluent::lint_label);
Expand All @@ -1669,7 +1644,6 @@ impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
if let Some(note) = self.span_note {
diag.span_note(note, fluent::lint_note);
}
diag
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down Expand Up @@ -1802,10 +1776,7 @@ pub enum UnusedDefSuggestion {

// Needed because of def_path_str
impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.set_arg("pre", self.pre);
diag.set_arg("post", self.post);
diag.set_arg("def", self.cx.tcx.def_path_str(self.def_id));
Expand All @@ -1816,7 +1787,6 @@ impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
if let Some(sugg) = self.suggestion {
diag.subdiagnostic(sugg);
}
diag
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down Expand Up @@ -1889,15 +1859,11 @@ pub struct AsyncFnInTraitDiag {
}

impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
fn decorate_lint<'b>(
self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
diag.note(fluent::lint_note);
if let Some(sugg) = self.sugg {
diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect);
}
diag
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_macros/src/diagnostics/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ impl<'a> LintDiagnosticDerive<'a> {
fn decorate_lint<'__b>(
self,
#diag: &'__b mut rustc_errors::DiagnosticBuilder<'__a, ()>
) -> &'__b mut rustc_errors::DiagnosticBuilder<'__a, ()> {
) {
use rustc_errors::IntoDiagnosticArg;
#implementation
#implementation;
}

fn msg(&self) -> rustc_errors::DiagnosticMessage {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/infer/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ impl<'tcx> CanonicalParamEnvCache<'tcx> {
Entry::Occupied(e) => {
let (canonical, var_values) = e.get();
state.var_values.extend_from_slice(var_values);
canonical.clone()
*canonical
}
Entry::Vacant(e) => {
let canonical = canonicalize_op(tcx, key, state);
let OriginalQueryValues { var_values, universe_map } = state;
assert_eq!(universe_map.len(), 1);
e.insert((canonical.clone(), tcx.arena.alloc_slice(var_values)));
e.insert((canonical, tcx.arena.alloc_slice(var_values)));
canonical
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'tcx> Const<'tcx> {

#[inline]
pub fn kind(self) -> ConstKind<'tcx> {
self.0.kind.clone()
self.0.kind
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl<'tcx> IntoKind for Ty<'tcx> {
type Kind = TyKind<'tcx>;

fn kind(self) -> TyKind<'tcx> {
self.kind().clone()
*self.kind()
}
}

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_mir_dataflow/src/value_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,11 +956,7 @@ impl Map {
// The local is not tracked at all, so it does not alias anything.
return;
};
let elems = place
.projection
.iter()
.map(|&elem| elem.try_into())
.chain(tail_elem.map(Ok).into_iter());
let elems = place.projection.iter().map(|&elem| elem.try_into()).chain(tail_elem.map(Ok));
for elem in elems {
// A field aliases the parent place.
if let Some(vi) = self.places[index].value_index {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/dataflow_const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
FlatSet::Elem(scalar) => {
let ty = op.ty(self.local_decls, self.tcx);
self.tcx.layout_of(self.param_env.and(ty)).map_or(FlatSet::Top, |layout| {
FlatSet::Elem(ImmTy::from_scalar(scalar.into(), layout))
FlatSet::Elem(ImmTy::from_scalar(scalar, layout))
})
}
FlatSet::Bottom => FlatSet::Bottom,
Expand Down
Loading
Loading