Skip to content

Rollup of 9 pull requests #120824

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

Closed
wants to merge 110 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
b587871
Simplify `get_enclosing_loop_or_multi_call_closure`
Jarcho Nov 15, 2023
cdc4c69
Make `expr_use_ctxt` always return `Some` unless the syntax context c…
Jarcho Nov 15, 2023
57dd25e
FP: `needless_return_with_question_mark` with implicit Error Conversion
PartiallyUntyped Dec 26, 2023
090c228
Fix/Issue11932: assert* in multi-condition after unrolling will cause…
cocodery Jan 3, 2024
b5a2192
fix: incorrect suggestions generated by `manual_retain` lint
yuxqiu Jan 3, 2024
03b3a16
test: add more test cases
yuxqiu Jan 4, 2024
bd6e920
modify check that any macros will be ingored in this lint, and add test
cocodery Jan 6, 2024
e0228ee
Fixes FP in `redundant_closure_call` when closures are passed to macros
PartiallyUntyped Jan 3, 2024
3b8f62f
Add new `unnecessary_result_map_or_else` lint
GuillaumeGomez Jan 18, 2024
32bbeba
Add ui test for `unnecessary_result_map_or_else`
GuillaumeGomez Jan 18, 2024
e86da9e
Update CHANGELOG
GuillaumeGomez Jan 18, 2024
0b6cf3b
We don't look into static items anymore during const prop
oli-obk Jan 8, 2024
99d8d33
remove StructuralEq trait
RalfJung Sep 26, 2023
8a850cd
std/time: avoid divisions in Duration::new
utkarshgupta137 Jan 24, 2024
9cbc582
Rename the unescaping functions.
nnethercote Jan 24, 2024
e456c28
Don't warn about modulo arithmetic when comparing to zero
mdm Jan 19, 2024
58de630
Remove an unused error count check
oli-obk Jan 25, 2024
798865c
Merge commit '66c29b973b3b10278bd39f4e26b08522a379c2c9' into clippy-s…
flip1995 Jan 25, 2024
42d13f8
[`unconditional_recursion`]: compare by types instead of `DefId`s
y21 Jan 20, 2024
87a6300
add a test for rust-lang/rust-clippy#12181
y21 Jan 21, 2024
fd3e966
avoid linting on `#[track_caller]` functions in `redundant_closure`
y21 Jan 25, 2024
a65fe78
Auto merge of #116167 - RalfJung:structural-eq, r=lcnr
bors Jan 26, 2024
ed74c22
Auto merge of #12202 - y21:issue12199, r=Jarcho
bors Jan 26, 2024
9ce0b83
Clippy: Fix empty suggestion in from_over_into
flip1995 Jan 26, 2024
14e1520
Warn if an item coming from more recent version than MSRV is used
GuillaumeGomez Jan 17, 2024
8de9d8c
Auto merge of #12160 - GuillaumeGomez:incompatible-msrv, r=blyxyas
bors Jan 26, 2024
f096e91
Rollup merge of #120329 - nnethercote:3349-precursors, r=fee1-dead
matthiaskrgr Jan 26, 2024
57f63a3
Rollup merge of #120345 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Jan 26, 2024
1d94cc3
remove illegal_floating_point_literal_pattern lint
RalfJung Jan 6, 2024
f58950d
correct lint case
PartiallyUntyped Jan 26, 2024
6d76d14
add to_string_trait_impl lint
andrewbanchich Jan 10, 2024
8905f78
Auto merge of #12082 - PartiallyTyped:1553, r=dswij
bors Jan 27, 2024
855aa08
Auto merge of #12178 - mdm:modulo-arithmetic-comparison-to-zero, r=ll…
bors Jan 27, 2024
79f10cf
Auto merge of #12122 - andrewbanchich:tostring-impl, r=llogiq
bors Jan 27, 2024
85e08cd
Auto merge of #12169 - GuillaumeGomez:unnecessary_result_map_or_else,…
bors Jan 27, 2024
a51fc2a
Fix `NonZero` clippy lints.
reitermarkus May 12, 2023
ff5afac
[`never_loop`]: recognize `?` desugaring in try blocks
y21 Jan 27, 2024
18e1f25
Auto merge of #12206 - y21:issue12205, r=Alexendoo
bors Jan 27, 2024
276ce39
Auto merge of #12083 - cocodery:fix/issue11932, r=Alexendoo
bors Jan 27, 2024
8ccf6a6
Auto merge of #12084 - yuxqiu:manual_retain, r=Alexendoo
bors Jan 27, 2024
3aa2c27
rewrote to match only Result::err cons
PartiallyUntyped Jan 28, 2024
e7a3cb7
Auto merge of #12021 - PartiallyTyped:11982, r=flip1995
bors Jan 29, 2024
b3d5377
Make `redundant_closure_for_method_calls` suggest relative paths
modelflat Aug 21, 2023
b2f2080
Add regression test for #2371
GuillaumeGomez Jan 29, 2024
ce8b4b6
Remove fixed FIXME
GuillaumeGomez Jan 29, 2024
3cd713a
Auto merge of #11370 - modelflat:suggest-relpath-in-redundant-closure…
bors Jan 29, 2024
73706e8
Makes clippy-driver check for --sysroot in arg files
Jan 26, 2024
1156375
Auto merge of #12203 - daivinhtran:fix-clippy-driver-to-accept-param-…
bors Jan 29, 2024
455c07b
Auto merge of #12210 - GuillaumeGomez:add-regression-test-2371, r=bly…
bors Jan 29, 2024
d02df12
add configuration for [`wildcard_imports`] to ignore certain imports
J-ZhengLi Dec 18, 2023
314bdde
add more test cases & improve docs & replace `Vec` with `FxHashSet` f…
J-ZhengLi Jan 29, 2024
c0f49a9
hir: Simplify `hir_owner_nodes` query
petrochenkov Jan 25, 2024
7539054
hir: Add non-optional `hir_owner_nodes` for real `OwnerId`s
petrochenkov Jan 25, 2024
233c8c9
hir: Remove `hir::Map::{owner,expect_owner}`
petrochenkov Jan 25, 2024
f0dbf68
Rollup merge of #120342 - oli-obk:track_errors6, r=nnethercote
GuillaumeGomez Jan 30, 2024
3106219
Don't lint slice type annotations for byte strings
bpandreotti Jan 30, 2024
ae0f0fd
Don't hash lints differently to non-lints.
nnethercote Jan 30, 2024
9e3bb89
Auto merge of #120346 - petrochenkov:ownodes, r=oli-obk
bors Jan 31, 2024
7836678
Rollup merge of #120490 - nnethercote:Diagnostic-hashing, r=estebank
Nadrieril Jan 31, 2024
6619e8c
Add `lint_groups_priority` lint
Alexendoo Jan 31, 2024
b58b88c
Auto merge of #11832 - Alexendoo:lint-groups-priority, r=flip1995
bors Jan 31, 2024
fe8c2e2
Fixed FP in `unused_io_amount` for `Ok(lit)`, `unrachable!`
PartiallyUntyped Jan 30, 2024
46dd826
rename conf option to `allowed_wildcard_imports`
J-ZhengLi Feb 2, 2024
9b6f866
Auto merge of #12217 - PartiallyTyped:12208, r=blyxyas
bors Feb 2, 2024
c82162e
Auto merge of #11979 - J-ZhengLi:issue11428, r=Alexendoo
bors Feb 2, 2024
0bfcafd
std::thread::available_parallelism merging linux/android/freebsd version
devnexen Feb 2, 2024
abced20
Avoid deleting labeled blocks
sanxiyn Jan 31, 2024
9fb4107
Auto merge of #12219 - sanxiyn:labeled-block, r=blyxyas
bors Feb 3, 2024
be47e32
Update version attributes for 1.76 lints
xFrednet Feb 4, 2024
aa1de4d
Changelog for Clippy 1.76 :cat2:
xFrednet Feb 4, 2024
a3baebc
Add ref_as_ptr lint
marcin-serwin Jan 2, 2024
34e4c9f
Auto merge of #12087 - marcin-serwin:ref_as_ptr_cast, r=blyxyas
bors Feb 4, 2024
7c3908f
[`redundant_locals`]: take by-value closure captures into account
y21 Feb 4, 2024
8baeb26
Auto merge of #12224 - xFrednet:chaneglog-1-76, r=Manishearth
bors Feb 5, 2024
d13ce19
Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillot
matthiaskrgr Feb 5, 2024
ff3fd6a
std::thread update freensd stack guard handling.
devnexen Feb 5, 2024
6807977
also check for coroutines
y21 Feb 5, 2024
7f80b44
new lint: `manual_c_str_literals`
y21 Dec 3, 2023
005b6c2
Auto merge of #11919 - y21:manual_c_str_literals, r=xFrednet
bors Feb 5, 2024
fdf819d
Auto merge of #12227 - y21:issue12225, r=Manishearth
bors Feb 5, 2024
0ac1195
Invert diagnostic lints.
nnethercote Feb 5, 2024
7895b98
Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs
compiler-errors Jan 24, 2024
36f7248
Fix release year in CHANGELOG.md
nyurik Feb 6, 2024
d910f77
Auto merge of #12235 - nyurik:patch-1, r=flip1995
bors Feb 6, 2024
ad3d04c
A drive-by rewrite of give_region_a_name()
amandasystems Feb 6, 2024
b1e5a58
Auto merge of #11812 - Jarcho:issue_11786, r=Alexendoo
bors Feb 6, 2024
08c8cd5
Auto merge of #12216 - bpandreotti:redundant-type-annotations-fix, r=…
bors Feb 7, 2024
62dcbd6
Auto merge of #12177 - y21:issue12154, r=Jarcho
bors Feb 7, 2024
795be51
Make `RegionName` `Copy` by (transitively) interning the few string v…
amandasystems Feb 7, 2024
9224387
Correctly generate path for non-local items in source code pages
GuillaumeGomez Feb 2, 2024
41f9b57
Add regression test for non local items link generation
GuillaumeGomez Feb 3, 2024
11bd2ea
Unify item relative path computation in one function
GuillaumeGomez Feb 3, 2024
d2f76f7
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Feb 8, 2024
031c46d
Bump nightly version -> 2024-02-08
flip1995 Feb 8, 2024
2ca6c84
Bump Clippy version -> 0.1.78
flip1995 Feb 8, 2024
60cb29c
Auto merge of #12246 - flip1995:rustup, r=flip1995
bors Feb 8, 2024
beb4f7d
Merge commit '60cb29c5e4f9772685c9873752196725c946a849' into clippyup
flip1995 Feb 8, 2024
4ec9eec
Update Cargo.lock
flip1995 Feb 8, 2024
d70d320
Use `transmute_unchecked` in `NonZero::new`.
reitermarkus Feb 8, 2024
698a3c7
Don't ICE in ByMoveBody when coroutine is tainted
compiler-errors Feb 8, 2024
e32c1dd
Don't ice in validation when error body is created
compiler-errors Feb 9, 2024
ec73183
Rollup merge of #120308 - utkarshgupta137:duration-opt, r=m-ou-se
matthiaskrgr Feb 9, 2024
2bb518e
Rollup merge of #120589 - devnexen:cpuaff_fbsd_upd, r=m-ou-se
matthiaskrgr Feb 9, 2024
330b494
Rollup merge of #120596 - GuillaumeGomez:jump-to-def-non-local-link, …
matthiaskrgr Feb 9, 2024
b65f8ec
Rollup merge of #120672 - devnexen:update_thread_stack_guardpages_fbs…
matthiaskrgr Feb 9, 2024
69c0b8c
Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davi…
matthiaskrgr Feb 9, 2024
d9edc71
Rollup merge of #120704 - amandasystems:silly-region-name-rewrite, r=…
matthiaskrgr Feb 9, 2024
5eefb2e
Rollup merge of #120806 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Feb 9, 2024
222daa8
Rollup merge of #120809 - reitermarkus:generic-nonzero-constructors, …
matthiaskrgr Feb 9, 2024
0c36d65
Rollup merge of #120817 - compiler-errors:more-mir-errors, r=oli-obk
matthiaskrgr Feb 9, 2024
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
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"

[[package]]
name = "clippy"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"anstream",
"clippy_config",
Expand Down Expand Up @@ -584,7 +584,7 @@ dependencies = [

[[package]]
name = "clippy_config"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"rustc-semver",
"serde",
Expand All @@ -607,7 +607,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.0",
Expand All @@ -632,7 +632,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"arrayvec",
"clippy_config",
Expand Down Expand Up @@ -1003,7 +1003,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"

[[package]]
name = "declare_clippy_lint"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"itertools",
"quote",
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#![cfg_attr(test, feature(test))]
#![feature(strict_provenance)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![allow(internal_features)]
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(stmt_expr_attributes)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

#[macro_use]
extern crate rustc_macros;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(let_chains)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#![feature(if_let_guard)]
#![feature(iter_is_partitioned)]
#![feature(let_chains)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

pub mod ast_validation;
mod errors;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_pretty/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![allow(internal_features)]
#![feature(rustdoc_internals)]
#![doc(rust_logo)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![feature(box_patterns)]

mod helpers;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#![feature(rustdoc_internals)]
#![doc(rust_logo)]
#![feature(let_chains)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

#[macro_use]
extern crate rustc_macros;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use crate::path_utils::allow_two_phase_borrow;
use crate::place_ext::PlaceExt;
use crate::BorrowIndex;
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_borrowck/src/borrowck_errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use rustc_errors::{codes::*, struct_span_code_err, DiagCtxt, DiagnosticBuilder};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_borrowck/src/constraints/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

use rustc_data_structures::graph::scc::Sccs;
use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::mir::ConstraintCategory;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/consumers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
//! This file provides API for compiler consumers.

use rustc_hir::def_id::LocalDefId;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::graph::WithSuccessors;
use rustc_index::bit_set::BitSet;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/def_use.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use rustc_middle::mir::visit::{
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

use rustc_errors::DiagnosticBuilder;
use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// ignore-tidy-filelength

#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use either::Either;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexSet;
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Print diagnostics to explain why values are borrowed.

#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use rustc_errors::{Applicability, Diagnostic};
use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

use std::collections::BTreeSet;

use rustc_middle::mir::visit::{PlaceContext, Visitor};
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/find_use.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

use std::collections::VecDeque;
use std::rc::Rc;

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder};
use rustc_middle::mir::*;
use rustc_middle::ty::{self, Ty};
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use hir::ExprKind;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder};
use rustc_hir as hir;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.

#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::Diagnostic;
use rustc_middle::ty::RegionVid;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
//! Error reporting machinery for lifetime errors.

use rustc_data_structures::fx::FxIndexSet;
Expand Down
61 changes: 34 additions & 27 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use std::fmt::{self, Display};
use std::iter;

use rustc_data_structures::fx::IndexEntry;
use rustc_errors::Diagnostic;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
Expand All @@ -14,7 +18,7 @@ use crate::{universal_regions::DefiningTy, MirBorrowckCtxt};

/// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub(crate) struct RegionName {
/// The name of the region (interned).
pub(crate) name: Symbol,
Expand All @@ -25,7 +29,7 @@ pub(crate) struct RegionName {
/// Denotes the source of a region that is named by a `RegionName`. For example, a free region that
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get `Static`.
/// This helps to print the right kinds of diagnostics.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub(crate) enum RegionNameSource {
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
NamedEarlyParamRegion(Span),
Expand All @@ -42,7 +46,7 @@ pub(crate) enum RegionNameSource {
/// The region corresponding to the return type of a closure.
AnonRegionFromOutput(RegionNameHighlight, &'static str),
/// The region from a type yielded by a coroutine.
AnonRegionFromYieldTy(Span, String),
AnonRegionFromYieldTy(Span, Symbol),
/// An anonymous region from an async fn.
AnonRegionFromAsyncFn(Span),
/// An anonymous region from an impl self type or trait
Expand All @@ -51,19 +55,19 @@ pub(crate) enum RegionNameSource {

/// Describes what to highlight to explain to the user that we're giving an anonymous region a
/// synthesized name, and how to highlight it.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub(crate) enum RegionNameHighlight {
/// The anonymous region corresponds to a reference that was found by traversing the type in the HIR.
MatchedHirTy(Span),
/// The anonymous region corresponds to a `'_` in the generics list of a struct/enum/union.
MatchedAdtAndSegment(Span),
/// The anonymous region corresponds to a region where the type annotation is completely missing
/// from the code, e.g. in a closure arguments `|x| { ... }`, where `x` is a reference.
CannotMatchHirTy(Span, String),
CannotMatchHirTy(Span, Symbol),
/// The anonymous region corresponds to a region where the type annotation is completely missing
/// from the code, and *even if* we print out the full name of the type, the region name won't
/// be included. This currently occurs for opaque types like `impl Future`.
Occluded(Span, String),
Occluded(Span, Symbol),
}

impl RegionName {
Expand Down Expand Up @@ -247,25 +251,28 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

assert!(self.regioncx.universal_regions().is_universal_region(fr));

if let Some(value) = self.region_names.try_borrow_mut().unwrap().get(&fr) {
return Some(value.clone());
}
match self.region_names.borrow_mut().entry(fr) {
IndexEntry::Occupied(precomputed_name) => Some(*precomputed_name.get()),
IndexEntry::Vacant(slot) => {
let new_name = self
.give_name_from_error_region(fr)
.or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_upvars(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_output(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_yield_ty(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_impl_signature(fr))
.or_else(|| {
self.give_name_if_anonymous_region_appears_in_arg_position_impl_trait(fr)
});

if let Some(new_name) = new_name {
slot.insert(new_name);
}
debug!("give_region_a_name: gave name {:?}", new_name);

let value = self
.give_name_from_error_region(fr)
.or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_upvars(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_output(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_yield_ty(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_impl_signature(fr))
.or_else(|| self.give_name_if_anonymous_region_appears_in_arg_position_impl_trait(fr));

if let Some(value) = &value {
self.region_names.try_borrow_mut().unwrap().insert(fr, value.clone());
new_name
}
}

debug!("give_region_a_name: gave name {:?}", value);
value
}

/// Checks for the case where `fr` maps to something that the
Expand Down Expand Up @@ -457,9 +464,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
);
if type_name.contains(&format!("'{counter}")) {
// Only add a label if we can confirm that a region was labelled.
RegionNameHighlight::CannotMatchHirTy(span, type_name)
RegionNameHighlight::CannotMatchHirTy(span, Symbol::intern(&type_name))
} else {
RegionNameHighlight::Occluded(span, type_name)
RegionNameHighlight::Occluded(span, Symbol::intern(&type_name))
}
}

Expand Down Expand Up @@ -888,7 +895,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

Some(RegionName {
name: self.synthesize_region_name(),
source: RegionNameSource::AnonRegionFromYieldTy(yield_span, type_name),
source: RegionNameSource::AnonRegionFromYieldTy(yield_span, Symbol::intern(&type_name)),
})
}

Expand Down Expand Up @@ -980,7 +987,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
Some(RegionName {
name: region_name,
source: RegionNameSource::AnonRegionFromArgument(
RegionNameHighlight::CannotMatchHirTy(arg_span, arg_name?.to_string()),
RegionNameHighlight::CannotMatchHirTy(arg_span, arg_name?),
),
})
} else {
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/var_name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

use crate::region_infer::RegionInferenceContext;
use rustc_index::IndexSlice;
use rustc_middle::mir::{Body, Local};
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/facts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use crate::location::{LocationIndex, LocationTable};
use crate::BorrowIndex;
use polonius_engine::AllFacts as PoloniusFacts;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/location.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use rustc_index::IndexVec;
use rustc_middle::mir::{BasicBlock, Body, Location};

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/member_constraints.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexMap;
use rustc_index::{IndexSlice, IndexVec};
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
//! The entry point of the NLL borrow checker.

use polonius_engine::{Algorithm, Output};
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/path_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
use crate::places_conflict;
use crate::AccessDepth;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/place_ext.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use crate::borrow_set::LocalsStateAtExit;
use rustc_hir as hir;
use rustc_middle::mir::ProjectionElem;
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/places_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
//! and either equal or disjoint.
//! - If we did run out of access, the borrow can access a part of it.

#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
use crate::ArtificialField;
use crate::Overlap;
use crate::{AccessDepth, Deep, Shallow};
Expand Down
Loading