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 9 pull requests #120375

Merged
merged 137 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
42b1406
Make `allow_internal_unstable` work with `stmt_expr_attributes`
Jules-Bertholet Oct 31, 2023
8c79f78
`read_zero_byte_vec` refactor for better heuristics
dswij Nov 7, 2023
0bccdb3
Stabilize `slice_group_by`
niklasf Nov 7, 2023
c5c2fb1
Improve slice_group_by doc wording
niklasf Nov 17, 2023
543d569
Make `HirEqInterExpr::eq_block` take comments into account
ARandomDev99 Jan 2, 2024
c2d071c
Documentation edits for arc_with_non_send_sync
talagrand Jan 9, 2024
7c389ac
Fix error warning span for issue12045
cocodery Jan 11, 2024
fb83ef6
Stop using `DiagnosticBuilder::buffer` in the parser.
nnethercote Jan 11, 2024
aa220c7
Merge commit '26ac6aab023393c94edf42f38f6ad31196009643'
flip1995 Jan 11, 2024
82841aa
Fix suggestion for `map_clone` on types implementing `Copy`
GuillaumeGomez Jan 11, 2024
74db4b7
Add new ui tests for `map_clone` lint on types implementing `Copy`
GuillaumeGomez Jan 11, 2024
85364e5
I'm not on vacation (again)
blyxyas Jan 11, 2024
6baa129
Auto merge of #119864 - matthiaskrgr:rollup-mc2qz13, r=matthiaskrgr
bors Jan 11, 2024
c537134
Auto merge of #12132 - blyxyas:not-on-vacation-again, r=xFrednet
bors Jan 11, 2024
88b5d51
Auto merge of #12129 - GuillaumeGomez:map-clone-copy, r=llogiq
bors Jan 11, 2024
1485e5c
check rust lints when an unknown lint is detected
chenyukang Jan 10, 2024
09d0241
Delegation implementation: step 1
Bryanskiy Nov 26, 2023
153b83f
[`useless_asref`]: check that the clone receiver is the local
y21 Jan 12, 2024
e9f8713
Rollup merge of #119819 - chenyukang:yukang-fix-118183-lint, r=davidtwco
GuillaumeGomez Jan 12, 2024
c8cd09a
Fix false positive in `PartialEq` check in `unconditional_recursion` …
GuillaumeGomez Jan 12, 2024
1326672
Add regression ui test for `unconditional_recursion` lint on `PartialEq`
GuillaumeGomez Jan 12, 2024
7eca5af
Auto merge of #12137 - GuillaumeGomez:fix-unconditional_recursion-fal…
bors Jan 12, 2024
68aceee
Improve help message for `search_is_some` lint
GuillaumeGomez Jan 12, 2024
37947ff
Update ui tests for `search_is_some` lint
GuillaumeGomez Jan 12, 2024
3b7ba1d
Improve `let_underscore_lock`
Noratrieb Jan 7, 2024
a71211d
Auto merge of #12140 - GuillaumeGomez:improve-message-search_is_some,…
bors Jan 12, 2024
5a45dbe
Auto merge of #118947 - Bryanskiy:delegStep1, r=petrochenkov,lcnr
bors Jan 13, 2024
a655558
Remove special-case handling of `vec.split_off(0)`
Zalathar Jan 13, 2024
e025356
from_over_into: suggest a correct conversion to ()
samueltardieu Jan 13, 2024
be5707c
lint on `.map(|&x| x.clone())`
y21 Jan 13, 2024
2469784
Add `.` to end of lint lists in configuration
blyxyas Jan 14, 2024
44f5d96
Change `PublicallyExported` -> `PubliclyExported`
blyxyas Jan 14, 2024
5769c21
chore: negative test for multiple crate versions not working when nam…
kristof-mattei Jan 14, 2024
d975e26
fix: add fix for bug, fix test name
kristof-mattei Jan 14, 2024
0774489
find function path references early in the lint pass
y21 Jan 14, 2024
1bcaf29
Correctly suggest `std` or `core` path depending if this is a `no_std…
GuillaumeGomez Jan 14, 2024
40a45a4
Update and add ui tests for core/std suggestions
GuillaumeGomez Jan 14, 2024
5d06fbb
fix: don't allocate new string when not needed
kristof-mattei Jan 14, 2024
b1c52d5
chore: add comments to explain reasoning
kristof-mattei Jan 14, 2024
ea585ef
chore: remove unneeded into_iter
kristof-mattei Jan 14, 2024
e8ec998
fix: crates are limited to ASCII values
kristof-mattei Jan 14, 2024
a9fa2f5
Auto merge of #12074 - ARandomDev99:12044-include-comments-while-chec…
bors Jan 15, 2024
37b8ae7
Auto merge of #12114 - talagrand:patch-1, r=Jarcho
bors Jan 15, 2024
d6ff2d2
Auto merge of #12141 - samueltardieu:issue-12138, r=Jarcho
bors Jan 15, 2024
692f53f
Auto merge of #12136 - y21:issue12135, r=Jarcho
bors Jan 15, 2024
33d8e47
Try to improve wording and fix dead link in description of arc_with_n…
adamreichold Dec 10, 2023
a16a850
Add "OpenTelemetry" to default `doc_valid_idents`
edmorley Dec 4, 2023
6c201db
Add suspicious_open_options lint.
atwam Oct 4, 2023
6fb471d
More helpful text, small style changes.
atwam Oct 10, 2023
2ec8729
PR Fixes
atwam Oct 10, 2023
84588a8
Add suggestion/fix to suspicious_open_options
atwam Oct 26, 2023
515fe65
Fix conflicts
atwam Jan 11, 2024
f09cd88
fix false positive in `suspicious_open_options`, make paths work
y21 Jan 13, 2024
ad2a2ba
Ensure `callee_id`s are body owners
smoelius Jan 15, 2024
771a2a9
Auto merge of #11926 - edmorley:update-default-doc_valid_idents, r=bl…
bors Jan 15, 2024
6a74a0e
compiler: Lower fn call arg spans down to MIR
Enselic Jan 12, 2024
874f851
Use `std_or_core` instead of doing check by hand every time
GuillaumeGomez Jan 15, 2024
a198904
Don't emit `derive_partial_eq_without_eq` lint if the type has the `n…
GuillaumeGomez Jan 15, 2024
136a582
Add `non_exhaustive` checks in `derive_partial_eq_without_eq.rs` ui test
GuillaumeGomez Jan 15, 2024
ecb0311
Auto merge of #12149 - GuillaumeGomez:core-std-suggestions, r=llogiq
bors Jan 16, 2024
169e2ab
Correctly handle type relative in `trait_duplication_in_bounds` lint
GuillaumeGomez Jan 16, 2024
7217c22
Update `trait_duplication_in_bounds.rs` ui test to add regression for…
GuillaumeGomez Jan 16, 2024
f7376a0
Deal with additional wrapping of async closure body in clippy
compiler-errors Jan 15, 2024
ca7b54b
Auto merge of #11945 - adamreichold:fix-lint-comments, r=Alexendoo
bors Jan 16, 2024
5f3a060
Auto merge of #11608 - atwam:suspicious-open-options, r=y21
bors Jan 16, 2024
33e1e6f
Add `PatKind::Err`
ShE3py Jan 17, 2024
4488653
Fix clippy
oli-obk Jan 12, 2024
e27ebf2
Auto merge of #11766 - dswij:issue-9274, r=blyxyas
bors Jan 17, 2024
2067fe4
Auto merge of #12155 - GuillaumeGomez:fix-9961, r=blyxyas
bors Jan 17, 2024
bb2d497
Auto merge of #12146 - kristof-mattei:multiple-crate-versions-with-da…
bors Jan 17, 2024
cc629f0
Rollup merge of #119978 - compiler-errors:async-closure-captures, r=o…
matthiaskrgr Jan 18, 2024
9fe7c6a
finally came up with some repro code
J-ZhengLi Jan 18, 2024
0e961cd
fix suggestion error with attr macros
J-ZhengLi Jan 18, 2024
6a331e3
Apply suggestions from code review
smoelius Jan 18, 2024
7a1e7d7
Don't forget that the lifetime on hir types is `'tcx`
oli-obk Feb 1, 2023
efd8daf
[`default_numeric_fallback`]: improve const context detection
y21 Jan 18, 2024
b08ffee
Auto merge of #12168 - y21:issue12159, r=blyxyas
bors Jan 18, 2024
4b3a9c0
Auto merge of #12167 - J-ZhengLi:issue12133, r=Alexendoo
bors Jan 18, 2024
21d719d
Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasper
matthiaskrgr Jan 18, 2024
baa2cf5
Update `std::io::Error::downcast` return type
NobodyXu Jan 18, 2024
c6079a6
blocks_in_conditions: do not warn if condition comes from macro
samueltardieu Jan 19, 2024
6fd0258
Auto merge of #12173 - samueltardieu:issue-12162, r=Manishearth
bors Jan 19, 2024
9661f9b
Add new condition to avoid derived code trigger lint
cocodery Jan 19, 2024
73d7ce6
Move the new check to the end of checks
cocodery Jan 19, 2024
989ce17
Auto merge of #12125 - cocodery:issue12045, r=xFrednet
bors Jan 19, 2024
6267b6c
no_effect_underscore_binding: _ prefixed variables can be used
samueltardieu Jan 19, 2024
eb42f3e
Pack the u128 in LitKind::Int
cuviper Jan 17, 2024
70573af
Auto merge of #12147 - y21:needless_pass_by_ref_mut_rm_visitor, r=llogiq
bors Jan 20, 2024
49b0c3f
Improve wording for suggestion messages
GuillaumeGomez Jan 18, 2024
38d9585
Update ui tests
GuillaumeGomez Jan 18, 2024
fd6e752
Move `has_non_exhaustive_attr` function into `clippy_utils`
GuillaumeGomez Jan 20, 2024
8b0931a
Rollup merge of #120000 - smoelius:fix-clippy, r=fee1-dead
GuillaumeGomez Jan 20, 2024
fe3e682
Auto merge of #12144 - blyxyas:10283-postfix, r=llogiq
bors Jan 20, 2024
7386856
Auto merge of #12172 - samueltardieu:issue-12166, r=Alexendoo
bors Jan 21, 2024
833cbd6
Auto merge of #120100 - oli-obk:astconv_lifetimes, r=BoxyUwU
bors Jan 21, 2024
f73879e
`unused_io_amount` captures `Ok(_)`s
m-rph Dec 21, 2023
64d08a8
Auto merge of #12005 - PartiallyTyped:11713, r=blyxyas
bors Jan 21, 2024
95a084f
[`multiple_crate_versions`]: add a configuration option for allowed d…
y21 Jan 21, 2024
99423e8
Auto merge of #12170 - GuillaumeGomez:improve-suggestions-wording, r=…
bors Jan 21, 2024
ad4d90b
respect `#[allow]` attribute in `single_call_fn` lint
y21 Jan 21, 2024
af76e3e
Updating dependencies
michaelciraci Jan 21, 2024
a417366
Rollup merge of #119710 - Nilstrieb:let-_-=-oops, r=TaKO8Ki
matthiaskrgr Jan 22, 2024
93955e0
Auto merge of #120080 - cuviper:128-align-packed, r=nikic
bors Jan 22, 2024
a8017ae
Auto merge of #12153 - GuillaumeGomez:non-exhaustive, r=llogiq
bors Jan 22, 2024
0b6e7e2
Auto merge of #12183 - y21:issue12182, r=dswij
bors Jan 22, 2024
cf355c6
Rename `LintContext::struct_span_lint` as `LintContext::span_lint`.
nnethercote Jan 16, 2024
6b359b7
Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.
nnethercote Jan 16, 2024
76a75bf
Auto merge of #12179 - y21:issue12176, r=dswij
bors Jan 24, 2024
4780637
suggest similar config option if one is found
y21 Jan 21, 2024
900a5aa
Auto merge of #12180 - y21:conf_lev_distance, r=blyxyas
bors Jan 24, 2024
314dbc7
Avoid useless checking in `from_token_lit`.
nnethercote Jan 22, 2024
4b4bdb5
Fix copy/paste error.
nnethercote Jan 24, 2024
ef1e222
Use `from` instead of `into` in unescaping code.
nnethercote Jan 22, 2024
a1c0721
Rework `CStrUnit`.
nnethercote Jan 23, 2024
5e5aa6d
Rename and invert sense of `Mode` predicates.
nnethercote Jan 23, 2024
86f371e
Rename the unescaping functions.
nnethercote Jan 24, 2024
6be2e56
Use `unescape_unicode` for raw C string literals.
nnethercote Jan 24, 2024
2aa7469
Don't fire OPAQUE_HIDDEN_INFERRED_BOUND on sized return of AFIT
compiler-errors Jan 25, 2024
15dbdab
privacy: Refactor top-level visiting in `NamePrivacyVisitor`
petrochenkov Jan 25, 2024
8a17125
Auto merge of #12184 - michaelciraci:merge-deps, r=llogiq
bors Jan 25, 2024
1534e08
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 25, 2024
c08c756
Bump nightly version -> 2024-01-25
flip1995 Jan 25, 2024
66c29b9
Auto merge of #12200 - flip1995:rustup, r=flip1995
bors Jan 25, 2024
41e1231
Merge commit '66c29b973b3b10278bd39f4e26b08522a379c2c9' into clippy-s…
flip1995 Jan 25, 2024
d7a0182
Update Cargo.lock
flip1995 Jan 25, 2024
97a720b
Rebase slice_group_by stabilization PR
dtolnay Jan 26, 2024
de8ccdb
Clippy: Fix empty suggestion in from_over_into
flip1995 Jan 26, 2024
1f994c7
Fix outdated comment on Box
bjorn3 Jan 26, 2024
4808aa8
Rollup merge of #117420 - Jules-Bertholet:internal-unstable-stmt-expr…
matthiaskrgr Jan 26, 2024
a5b60c9
Rollup merge of #117678 - niklasf:stabilize-slice_group_by, r=dtolnay
matthiaskrgr Jan 26, 2024
772e80a
Rollup merge of #119917 - Zalathar:split-off, r=cuviper
matthiaskrgr Jan 26, 2024
b09f232
Rollup merge of #120117 - NobodyXu:99262/update-api-and-doc, r=m-ou-se
matthiaskrgr Jan 26, 2024
5f1f617
Rollup merge of #120329 - nnethercote:3349-precursors, r=fee1-dead
matthiaskrgr Jan 26, 2024
c48c77e
Rollup merge of #120339 - petrochenkov:nameprivisit, r=michaelwoerister
matthiaskrgr Jan 26, 2024
37b9022
Rollup merge of #120345 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Jan 26, 2024
b4b4835
Rollup merge of #120360 - compiler-errors:afit-sized-lol, r=lcnr
matthiaskrgr Jan 26, 2024
d1c3dde
Rollup merge of #120372 - bjorn3:fix_outdated_comment, r=Nilstrieb
matthiaskrgr Jan 26, 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
18 changes: 4 additions & 14 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,11 @@ dependencies = [
name = "clippy_dev"
version = "0.0.1"
dependencies = [
"aho-corasick 0.7.20",
"aho-corasick 1.0.2",
"clap",
"indoc",
"itertools",
"opener 0.5.2",
"opener",
"shell-escape",
"walkdir",
]
Expand All @@ -610,7 +610,7 @@ name = "clippy_lints"
version = "0.1.77"
dependencies = [
"arrayvec",
"cargo_metadata 0.15.4",
"cargo_metadata 0.18.0",
"clippy_config",
"clippy_utils",
"declare_clippy_lint",
Expand Down Expand Up @@ -2351,7 +2351,7 @@ dependencies = [
"log",
"memchr",
"once_cell",
"opener 0.6.1",
"opener",
"pathdiff",
"pulldown-cmark",
"regex",
Expand Down Expand Up @@ -2626,16 +2626,6 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"

[[package]]
name = "opener"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "293c15678e37254c15bd2f092314abb4e51d7fdde05c2021279c12631b54f005"
dependencies = [
"bstr",
"winapi",
]

[[package]]
name = "opener"
version = "0.6.1"
Expand Down
96 changes: 27 additions & 69 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use crate::ast::{self, LitKind, MetaItemLit, StrStyle};
use crate::token::{self, Token};
use rustc_lexer::unescape::{
byte_from_char, unescape_byte, unescape_c_string, unescape_char, unescape_literal, CStrUnit,
Mode,
byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode,
};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
Expand Down Expand Up @@ -48,6 +47,9 @@ impl LitKind {
return Err(LitError::InvalidSuffix);
}

// For byte/char/string literals, chars and escapes have already been
// checked in the lexer (in `cook_lexer_literal`). So we can assume all
// chars and escapes are valid here.
Ok(match kind {
token::Bool => {
assert!(symbol.is_bool_lit());
Expand All @@ -56,12 +58,12 @@ impl LitKind {
token::Byte => {
return unescape_byte(symbol.as_str())
.map(LitKind::Byte)
.map_err(|_| LitError::LexerError);
.map_err(|_| panic!("failed to unescape byte literal"));
}
token::Char => {
return unescape_char(symbol.as_str())
.map(LitKind::Char)
.map_err(|_| LitError::LexerError);
.map_err(|_| panic!("failed to unescape char literal"));
}

// There are some valid suffixes for integer and float literals,
Expand All @@ -77,113 +79,69 @@ impl LitKind {
let s = symbol.as_str();
// Vanilla strings are so common we optimize for the common case where no chars
// requiring special behaviour are present.
let symbol = if s.contains(['\\', '\r']) {
let symbol = if s.contains('\\') {
let mut buf = String::with_capacity(s.len());
let mut error = Ok(());
// Force-inlining here is aggressive but the closure is
// called on every char in the string, so it can be
// hot in programs with many long strings.
unescape_literal(
// called on every char in the string, so it can be hot in
// programs with many long strings containing escapes.
unescape_unicode(
s,
Mode::Str,
&mut #[inline(always)]
|_, unescaped_char| match unescaped_char {
|_, c| match c {
Ok(c) => buf.push(c),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
assert!(!err.is_fatal(), "failed to unescape string literal")
}
},
);
error?;
Symbol::intern(&buf)
} else {
symbol
};
LitKind::Str(symbol, ast::StrStyle::Cooked)
}
token::StrRaw(n) => {
// Raw strings have no escapes, so we only need to check for invalid chars, and we
// can reuse the symbol on success.
let mut error = Ok(());
unescape_literal(symbol.as_str(), Mode::RawStr, &mut |_, unescaped_char| {
match unescaped_char {
Ok(_) => {}
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
}
}
});
error?;
// Raw strings have no escapes so no work is needed here.
LitKind::Str(symbol, ast::StrStyle::Raw(n))
}
token::ByteStr => {
let s = symbol.as_str();
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_literal(s, Mode::ByteStr, &mut |_, c| match c {
unescape_unicode(s, Mode::ByteStr, &mut |_, c| match c {
Ok(c) => buf.push(byte_from_char(c)),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
assert!(!err.is_fatal(), "failed to unescape string literal")
}
});
error?;
LitKind::ByteStr(buf.into(), StrStyle::Cooked)
}
token::ByteStrRaw(n) => {
// Raw strings have no escapes, so we only need to check for invalid chars, and we
// can convert the symbol directly to a `Lrc<u8>` on success.
let s = symbol.as_str();
let mut error = Ok(());
unescape_literal(s, Mode::RawByteStr, &mut |_, c| match c {
Ok(_) => {}
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
}
});
LitKind::ByteStr(s.to_owned().into_bytes().into(), StrStyle::Raw(n))
// Raw strings have no escapes so we can convert the symbol
// directly to a `Lrc<u8>`.
let buf = symbol.as_str().to_owned().into_bytes();
LitKind::ByteStr(buf.into(), StrStyle::Raw(n))
}
token::CStr => {
let s = symbol.as_str();
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_c_string(s, Mode::CStr, &mut |_span, c| match c {
Ok(CStrUnit::Byte(b)) => buf.push(b),
Ok(CStrUnit::Char(c)) => {
unescape_mixed(s, Mode::CStr, &mut |_span, c| match c {
Ok(MixedUnit::Char(c)) => {
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
}
Ok(MixedUnit::HighByte(b)) => buf.push(b),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
assert!(!err.is_fatal(), "failed to unescape C string literal")
}
});
error?;
buf.push(0);
LitKind::CStr(buf.into(), StrStyle::Cooked)
}
token::CStrRaw(n) => {
// Raw strings have no escapes, so we only need to check for invalid chars, and we
// can convert the symbol directly to a `Lrc<u8>` on success.
let s = symbol.as_str();
let mut error = Ok(());
unescape_c_string(s, Mode::RawCStr, &mut |_, c| match c {
Ok(_) => {}
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
}
});
error?;
let mut buf = s.to_owned().into_bytes();
// Raw strings have no escapes so we can convert the symbol
// directly to a `Lrc<u8>` after appending the terminating NUL
// char.
let mut buf = symbol.as_str().to_owned().into_bytes();
buf.push(0);
LitKind::CStr(buf.into(), StrStyle::Raw(n))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ index 897a5e9..331f66f 100644
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
#![cfg_attr(test, feature(cfg_match))]
#![feature(int_roundings)]
#![feature(slice_group_by)]
#![feature(split_array)]
diff --git a/atomic.rs b/atomic.rs
index b735957..ea728b6 100644
--- a/atomic.rs
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ impl<'a> StripUnconfigured<'a> {
/// If attributes are not allowed on expressions, emit an error for `attr`
#[instrument(level = "trace", skip(self))]
pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
if self.features.is_some_and(|features| !features.stmt_expr_attributes) {
if self.features.is_some_and(|features| !features.stmt_expr_attributes)
&& !attr.span.allows_unstable(sym::stmt_expr_attributes)
{
let mut err = feature_err(
&self.sess,
sym::stmt_expr_attributes,
Expand Down
Loading
Loading