mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514
Remove useless borrows and derefs They are nothing more than noise. <sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
This commit is contained in:
commit
1a2f79b82c
@ -354,7 +354,7 @@ pub trait LayoutCalculator {
|
||||
if !always_sized { StructKind::MaybeUnsized } else { StructKind::AlwaysSized }
|
||||
};
|
||||
|
||||
let mut st = self.univariant(dl, &variants[v], &repr, kind)?;
|
||||
let mut st = self.univariant(dl, &variants[v], repr, kind)?;
|
||||
st.variants = Variants::Single { index: v };
|
||||
|
||||
if is_unsafe_cell {
|
||||
@ -457,7 +457,7 @@ pub trait LayoutCalculator {
|
||||
let mut variant_layouts = variants
|
||||
.iter_enumerated()
|
||||
.map(|(j, v)| {
|
||||
let mut st = self.univariant(dl, v, &repr, StructKind::AlwaysSized)?;
|
||||
let mut st = self.univariant(dl, v, repr, StructKind::AlwaysSized)?;
|
||||
st.variants = Variants::Single { index: j };
|
||||
|
||||
align = align.max(st.align);
|
||||
@ -647,8 +647,8 @@ pub trait LayoutCalculator {
|
||||
.map(|(i, field_layouts)| {
|
||||
let mut st = self.univariant(
|
||||
dl,
|
||||
&field_layouts,
|
||||
&repr,
|
||||
field_layouts,
|
||||
repr,
|
||||
StructKind::Prefixed(min_ity.size(), prefix_align),
|
||||
)?;
|
||||
st.variants = Variants::Single { index: i };
|
||||
@ -755,7 +755,7 @@ pub trait LayoutCalculator {
|
||||
// Try to use a ScalarPair for all tagged enums.
|
||||
let mut common_prim = None;
|
||||
let mut common_prim_initialized_in_all_variants = true;
|
||||
for (field_layouts, layout_variant) in iter::zip(&*variants, &layout_variants) {
|
||||
for (field_layouts, layout_variant) in iter::zip(variants, &layout_variants) {
|
||||
let FieldsShape::Arbitrary { ref offsets, .. } = layout_variant.fields else {
|
||||
panic!();
|
||||
};
|
||||
|
@ -1179,7 +1179,7 @@ impl Expr {
|
||||
pub fn peel_parens(&self) -> &Expr {
|
||||
let mut expr = self;
|
||||
while let ExprKind::Paren(inner) = &expr.kind {
|
||||
expr = &inner;
|
||||
expr = inner;
|
||||
}
|
||||
expr
|
||||
}
|
||||
@ -2029,7 +2029,7 @@ impl Ty {
|
||||
pub fn peel_refs(&self) -> &Self {
|
||||
let mut final_ty = self;
|
||||
while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind {
|
||||
final_ty = &ty;
|
||||
final_ty = ty;
|
||||
}
|
||||
final_ty
|
||||
}
|
||||
|
@ -736,8 +736,7 @@ pub fn visit_token<T: MutVisitor>(t: &mut Token, vis: &mut T) {
|
||||
return; // Avoid visiting the span for the second time.
|
||||
}
|
||||
token::Interpolated(nt) => {
|
||||
let mut nt = Lrc::make_mut(nt);
|
||||
visit_nonterminal(&mut nt, vis);
|
||||
visit_nonterminal(Lrc::make_mut(nt), vis);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ impl TokenTree {
|
||||
match (self, other) {
|
||||
(TokenTree::Token(token, _), TokenTree::Token(token2, _)) => token.kind == token2.kind,
|
||||
(TokenTree::Delimited(_, delim, tts), TokenTree::Delimited(_, delim2, tts2)) => {
|
||||
delim == delim2 && tts.eq_unspanned(&tts2)
|
||||
delim == delim2 && tts.eq_unspanned(tts2)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
@ -402,7 +402,7 @@ impl TokenStream {
|
||||
let mut t1 = self.trees();
|
||||
let mut t2 = other.trees();
|
||||
for (t1, t2) in iter::zip(&mut t1, &mut t2) {
|
||||
if !t1.eq_unspanned(&t2) {
|
||||
if !t1.eq_unspanned(t2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -475,7 +475,7 @@ impl TokenStream {
|
||||
token::Interpolated(nt) => TokenTree::Delimited(
|
||||
DelimSpan::from_single(token.span),
|
||||
Delimiter::Invisible,
|
||||
TokenStream::from_nonterminal_ast(&nt).flattened(),
|
||||
TokenStream::from_nonterminal_ast(nt).flattened(),
|
||||
),
|
||||
_ => TokenTree::Token(token.clone(), spacing),
|
||||
}
|
||||
@ -511,7 +511,7 @@ impl TokenStream {
|
||||
fn try_glue_to_last(vec: &mut Vec<TokenTree>, tt: &TokenTree) -> bool {
|
||||
if let Some(TokenTree::Token(last_tok, Spacing::Joint)) = vec.last()
|
||||
&& let TokenTree::Token(tok, spacing) = tt
|
||||
&& let Some(glued_tok) = last_tok.glue(&tok)
|
||||
&& let Some(glued_tok) = last_tok.glue(tok)
|
||||
{
|
||||
// ...then overwrite the last token tree in `vec` with the
|
||||
// glued token, and skip the first token tree from `stream`.
|
||||
|
@ -110,7 +110,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
|
||||
} else {
|
||||
&mut lines
|
||||
};
|
||||
if let Some(horizontal) = get_horizontal_trim(&lines, kind) {
|
||||
if let Some(horizontal) = get_horizontal_trim(lines, kind) {
|
||||
changes = true;
|
||||
// remove a "[ \t]*\*" block from each line, if possible
|
||||
for line in lines.iter_mut() {
|
||||
@ -147,7 +147,7 @@ fn all_whitespace(s: &str, col: CharPos) -> Option<usize> {
|
||||
|
||||
fn trim_whitespace_prefix(s: &str, col: CharPos) -> &str {
|
||||
let len = s.len();
|
||||
match all_whitespace(&s, col) {
|
||||
match all_whitespace(s, col) {
|
||||
Some(col) => {
|
||||
if col < len {
|
||||
&s[col..]
|
||||
|
@ -52,14 +52,14 @@ impl LitKind {
|
||||
// new symbol because the string in the LitKind is different to the
|
||||
// string in the token.
|
||||
let s = symbol.as_str();
|
||||
let symbol = if s.contains(&['\\', '\r']) {
|
||||
let symbol = if s.contains(['\\', '\r']) {
|
||||
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(
|
||||
&s,
|
||||
s,
|
||||
Mode::Str,
|
||||
&mut #[inline(always)]
|
||||
|_, unescaped_char| match unescaped_char {
|
||||
@ -85,7 +85,7 @@ impl LitKind {
|
||||
if s.contains('\r') {
|
||||
let mut buf = String::with_capacity(s.len());
|
||||
let mut error = Ok(());
|
||||
unescape_literal(&s, Mode::RawStr, &mut |_, unescaped_char| {
|
||||
unescape_literal(s, Mode::RawStr, &mut |_, unescaped_char| {
|
||||
match unescaped_char {
|
||||
Ok(c) => buf.push(c),
|
||||
Err(err) => {
|
||||
@ -106,7 +106,7 @@ impl LitKind {
|
||||
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_literal(s, Mode::ByteStr, &mut |_, c| match c {
|
||||
Ok(c) => buf.push(byte_from_char(c)),
|
||||
Err(err) => {
|
||||
if err.is_fatal() {
|
||||
@ -122,7 +122,7 @@ impl LitKind {
|
||||
let bytes = if s.contains('\r') {
|
||||
let mut buf = Vec::with_capacity(s.len());
|
||||
let mut error = Ok(());
|
||||
unescape_literal(&s, Mode::RawByteStr, &mut |_, c| match c {
|
||||
unescape_literal(s, Mode::RawByteStr, &mut |_, c| match c {
|
||||
Ok(c) => buf.push(byte_from_char(c)),
|
||||
Err(err) => {
|
||||
if err.is_fatal() {
|
||||
|
@ -384,7 +384,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
|
||||
| ast::ExprKind::AssignOp(_, lhs, rhs)
|
||||
| ast::ExprKind::Binary(_, lhs, rhs) => {
|
||||
// X { y: 1 } + X { y: 2 }
|
||||
contains_exterior_struct_lit(&lhs) || contains_exterior_struct_lit(&rhs)
|
||||
contains_exterior_struct_lit(lhs) || contains_exterior_struct_lit(rhs)
|
||||
}
|
||||
ast::ExprKind::Await(x)
|
||||
| ast::ExprKind::Unary(_, x)
|
||||
@ -393,12 +393,12 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
|
||||
| ast::ExprKind::Field(x, _)
|
||||
| ast::ExprKind::Index(x, _) => {
|
||||
// &X { y: 1 }, X { y: 1 }.y
|
||||
contains_exterior_struct_lit(&x)
|
||||
contains_exterior_struct_lit(x)
|
||||
}
|
||||
|
||||
ast::ExprKind::MethodCall(box ast::MethodCall { receiver, .. }) => {
|
||||
// X { y: 1 }.bar(...)
|
||||
contains_exterior_struct_lit(&receiver)
|
||||
contains_exterior_struct_lit(receiver)
|
||||
}
|
||||
|
||||
_ => false,
|
||||
|
@ -17,7 +17,7 @@ pub fn contains_text_flow_control_chars(s: &str) -> bool {
|
||||
// U+2069 - E2 81 A9
|
||||
let mut bytes = s.as_bytes();
|
||||
loop {
|
||||
match core::slice::memchr::memchr(0xE2, &bytes) {
|
||||
match core::slice::memchr::memchr(0xE2, bytes) {
|
||||
Some(idx) => {
|
||||
// bytes are valid UTF-8 -> E2 must be followed by two bytes
|
||||
let ch = &bytes[idx..idx + 3];
|
||||
|
@ -519,7 +519,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
||||
ast::MetaItemKind::List(items) => {
|
||||
self.print_path(&item.path, false, 0);
|
||||
self.popen();
|
||||
self.commasep(Consistent, &items, |s, i| s.print_meta_list_item(i));
|
||||
self.commasep(Consistent, items, |s, i| s.print_meta_list_item(i));
|
||||
self.pclose();
|
||||
}
|
||||
}
|
||||
@ -536,7 +536,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
||||
fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) {
|
||||
match tt {
|
||||
TokenTree::Token(token, _) => {
|
||||
let token_str = self.token_to_string_ext(&token, convert_dollar_crate);
|
||||
let token_str = self.token_to_string_ext(token, convert_dollar_crate);
|
||||
self.word(token_str);
|
||||
if let token::DocComment(..) = token.kind {
|
||||
self.hardbreak()
|
||||
@ -998,7 +998,7 @@ impl<'a> State<'a> {
|
||||
ast::AssocConstraintKind::Bound { bounds } => {
|
||||
if !bounds.is_empty() {
|
||||
self.word_nbsp(":");
|
||||
self.print_type_bounds(&bounds);
|
||||
self.print_type_bounds(bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1035,7 +1035,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
ast::TyKind::Tup(elts) => {
|
||||
self.popen();
|
||||
self.commasep(Inconsistent, &elts, |s, ty| s.print_type(ty));
|
||||
self.commasep(Inconsistent, elts, |s, ty| s.print_type(ty));
|
||||
if elts.len() == 1 {
|
||||
self.word(",");
|
||||
}
|
||||
@ -1254,7 +1254,7 @@ impl<'a> State<'a> {
|
||||
|
||||
self.popen();
|
||||
self.commasep(Consistent, &args, |s, arg| match arg {
|
||||
AsmArg::Template(template) => s.print_string(&template, ast::StrStyle::Cooked),
|
||||
AsmArg::Template(template) => s.print_string(template, ast::StrStyle::Cooked),
|
||||
AsmArg::Operand(op) => {
|
||||
let print_reg_or_class = |s: &mut Self, r: &InlineAsmRegOrRegClass| match r {
|
||||
InlineAsmRegOrRegClass::Reg(r) => s.print_symbol(*r, ast::StrStyle::Cooked),
|
||||
@ -1424,11 +1424,11 @@ impl<'a> State<'a> {
|
||||
self.print_path(path, true, 0);
|
||||
}
|
||||
self.popen();
|
||||
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
|
||||
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));
|
||||
self.pclose();
|
||||
}
|
||||
PatKind::Or(pats) => {
|
||||
self.strsep("|", true, Inconsistent, &pats, |s, p| s.print_pat(p));
|
||||
self.strsep("|", true, Inconsistent, pats, |s, p| s.print_pat(p));
|
||||
}
|
||||
PatKind::Path(None, path) => {
|
||||
self.print_path(path, true, 0);
|
||||
@ -1450,7 +1450,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
self.commasep_cmnt(
|
||||
Consistent,
|
||||
&fields,
|
||||
fields,
|
||||
|s, f| {
|
||||
s.cbox(INDENT_UNIT);
|
||||
if !f.is_shorthand {
|
||||
@ -1475,7 +1475,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
PatKind::Tuple(elts) => {
|
||||
self.popen();
|
||||
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
|
||||
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));
|
||||
if elts.len() == 1 {
|
||||
self.word(",");
|
||||
}
|
||||
@ -1498,7 +1498,7 @@ impl<'a> State<'a> {
|
||||
self.print_pat(inner);
|
||||
}
|
||||
}
|
||||
PatKind::Lit(e) => self.print_expr(&**e),
|
||||
PatKind::Lit(e) => self.print_expr(e),
|
||||
PatKind::Range(begin, end, Spanned { node: end_kind, .. }) => {
|
||||
if let Some(e) = begin {
|
||||
self.print_expr(e);
|
||||
@ -1514,7 +1514,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
PatKind::Slice(elts) => {
|
||||
self.word("[");
|
||||
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
|
||||
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));
|
||||
self.word("]");
|
||||
}
|
||||
PatKind::Rest => self.word(".."),
|
||||
@ -1600,7 +1600,7 @@ impl<'a> State<'a> {
|
||||
|
||||
self.word("<");
|
||||
|
||||
self.commasep(Inconsistent, &generic_params, |s, param| {
|
||||
self.commasep(Inconsistent, generic_params, |s, param| {
|
||||
s.print_outer_attributes_inline(¶m.attrs);
|
||||
|
||||
match ¶m.kind {
|
||||
|
@ -305,10 +305,10 @@ impl<'a> State<'a> {
|
||||
self.print_expr_tup(exprs);
|
||||
}
|
||||
ast::ExprKind::Call(func, args) => {
|
||||
self.print_expr_call(func, &args);
|
||||
self.print_expr_call(func, args);
|
||||
}
|
||||
ast::ExprKind::MethodCall(box ast::MethodCall { seg, receiver, args, .. }) => {
|
||||
self.print_expr_method_call(seg, &receiver, &args);
|
||||
self.print_expr_method_call(seg, receiver, args);
|
||||
}
|
||||
ast::ExprKind::Binary(op, lhs, rhs) => {
|
||||
self.print_expr_binary(*op, lhs, rhs);
|
||||
@ -606,7 +606,7 @@ impl<'a> State<'a> {
|
||||
match binder {
|
||||
ast::ClosureBinder::NotPresent => {}
|
||||
ast::ClosureBinder::For { generic_params, .. } => {
|
||||
self.print_formal_generic_params(&generic_params)
|
||||
self.print_formal_generic_params(generic_params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ impl<'a, T: PartialOrd> PartialOrd for Interned<'a, T> {
|
||||
if ptr::eq(self.0, other.0) {
|
||||
Some(Ordering::Equal)
|
||||
} else {
|
||||
let res = self.0.partial_cmp(&other.0);
|
||||
let res = self.0.partial_cmp(other.0);
|
||||
debug_assert_ne!(res, Some(Ordering::Equal));
|
||||
res
|
||||
}
|
||||
@ -86,7 +86,7 @@ impl<'a, T: Ord> Ord for Interned<'a, T> {
|
||||
if ptr::eq(self.0, other.0) {
|
||||
Ordering::Equal
|
||||
} else {
|
||||
let res = self.0.cmp(&other.0);
|
||||
let res = self.0.cmp(other.0);
|
||||
debug_assert_ne!(res, Ordering::Equal);
|
||||
res
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ impl Deref for Mmap {
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,13 +96,13 @@ impl Deref for MmapMut {
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for MmapMut {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
&mut *self.0
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
@ -899,25 +899,25 @@ unsafe impl<O, T: ?Sized> StableAddress for OwningRef<O, T> {}
|
||||
|
||||
impl<O, T: ?Sized> AsRef<T> for OwningRef<O, T> {
|
||||
fn as_ref(&self) -> &T {
|
||||
&*self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<O, T: ?Sized> AsRef<T> for OwningRefMut<O, T> {
|
||||
fn as_ref(&self) -> &T {
|
||||
&*self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<O, T: ?Sized> AsMut<T> for OwningRefMut<O, T> {
|
||||
fn as_mut(&mut self) -> &mut T {
|
||||
&mut *self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<O, T: ?Sized> Borrow<T> for OwningRef<O, T> {
|
||||
fn borrow(&self) -> &T {
|
||||
&*self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,7 +1021,7 @@ where
|
||||
T: PartialEq,
|
||||
{
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
(&*self as &T).eq(&*other as &T)
|
||||
self.deref().eq(other.deref())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1032,7 +1032,7 @@ where
|
||||
T: PartialOrd,
|
||||
{
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
(&*self as &T).partial_cmp(&*other as &T)
|
||||
self.deref().partial_cmp(other.deref())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1041,7 +1041,7 @@ where
|
||||
T: Ord,
|
||||
{
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
(&*self as &T).cmp(&*other as &T)
|
||||
self.deref().cmp(other.deref())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1050,7 +1050,7 @@ where
|
||||
T: Hash,
|
||||
{
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
(&*self as &T).hash(state);
|
||||
self.deref().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1059,7 +1059,7 @@ where
|
||||
T: PartialEq,
|
||||
{
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
(&*self as &T).eq(&*other as &T)
|
||||
self.deref().eq(other.deref())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1070,7 +1070,7 @@ where
|
||||
T: PartialOrd,
|
||||
{
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
(&*self as &T).partial_cmp(&*other as &T)
|
||||
self.deref().partial_cmp(other.deref())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1079,7 +1079,7 @@ where
|
||||
T: Ord,
|
||||
{
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
(&*self as &T).cmp(&*other as &T)
|
||||
self.deref().cmp(other.deref())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1088,7 +1088,7 @@ where
|
||||
T: Hash,
|
||||
{
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
(&*self as &T).hash(state);
|
||||
self.deref().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ impl SelfProfilerRef {
|
||||
F: for<'a> FnOnce(&'a SelfProfiler) -> TimingGuard<'a>,
|
||||
{
|
||||
let profiler = profiler_ref.profiler.as_ref().unwrap();
|
||||
f(&**profiler)
|
||||
f(profiler)
|
||||
}
|
||||
|
||||
if self.event_filter_mask.contains(event_filter) {
|
||||
@ -466,7 +466,7 @@ impl SelfProfilerRef {
|
||||
|
||||
pub fn with_profiler(&self, f: impl FnOnce(&SelfProfiler)) {
|
||||
if let Some(profiler) = &self.profiler {
|
||||
f(&profiler)
|
||||
f(profiler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,7 +733,7 @@ impl Drop for VerboseTimingGuard<'_> {
|
||||
if let Some((start_time, start_rss, ref message)) = self.start_and_message {
|
||||
let end_rss = get_resident_set_size();
|
||||
let dur = start_time.elapsed();
|
||||
print_time_passes_entry(&message, dur, start_rss, end_rss);
|
||||
print_time_passes_entry(message, dur, start_rss, end_rss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ impl<CTX> HashStable<CTX> for [u8] {
|
||||
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
|
||||
#[inline]
|
||||
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
|
||||
(&self[..]).hash_stable(ctx, hasher);
|
||||
self[..].hash_stable(ctx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ where
|
||||
{
|
||||
#[inline]
|
||||
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
|
||||
(&self[..]).hash_stable(ctx, hasher);
|
||||
self[..].hash_stable(ctx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ impl<CTX> HashStable<CTX> for str {
|
||||
impl<CTX> HashStable<CTX> for String {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
(&self[..]).hash_stable(hcx, hasher);
|
||||
self[..].hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ cfg_if! {
|
||||
|
||||
#[inline(always)]
|
||||
fn deref(&self) -> &T {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ impl Translate for AnnotateSnippetEmitterWriter {
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
&self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
|
||||
let fluent_args = to_fluent_args(diag.args());
|
||||
|
||||
let mut children = diag.children.clone();
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(diag, &fluent_args);
|
||||
|
||||
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
&mut primary_span,
|
||||
@ -65,7 +65,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
|
||||
&diag.code,
|
||||
&primary_span,
|
||||
&children,
|
||||
&suggestions,
|
||||
suggestions,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ impl Diagnostic {
|
||||
let lint_index = expectation_id.get_lint_index();
|
||||
expectation_id.set_lint_index(None);
|
||||
let mut stable_id = unstable_to_stable
|
||||
.get(&expectation_id)
|
||||
.get(expectation_id)
|
||||
.expect("each unstable `LintExpectationId` must have a matching stable id")
|
||||
.normalize();
|
||||
|
||||
|
@ -283,7 +283,7 @@ pub trait Emitter: Translate {
|
||||
if self
|
||||
.source_map()
|
||||
.map(|sm| is_case_difference(
|
||||
&**sm,
|
||||
sm,
|
||||
substitution,
|
||||
sugg.substitutions[0].parts[0].span,
|
||||
))
|
||||
@ -525,7 +525,7 @@ impl Translate for EmitterWriter {
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
&self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
@ -538,7 +538,7 @@ impl Emitter for EmitterWriter {
|
||||
let fluent_args = to_fluent_args(diag.args());
|
||||
|
||||
let mut children = diag.children.clone();
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(diag, &fluent_args);
|
||||
debug!("emit_diagnostic: suggestions={:?}", suggestions);
|
||||
|
||||
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
@ -555,7 +555,7 @@ impl Emitter for EmitterWriter {
|
||||
&diag.code,
|
||||
&primary_span,
|
||||
&children,
|
||||
&suggestions,
|
||||
suggestions,
|
||||
self.track_diagnostics.then_some(&diag.emitted_at),
|
||||
);
|
||||
}
|
||||
@ -801,7 +801,7 @@ impl EmitterWriter {
|
||||
}
|
||||
|
||||
let source_string = match file.get_line(line.line_index - 1) {
|
||||
Some(s) => normalize_whitespace(&*s),
|
||||
Some(s) => normalize_whitespace(&s),
|
||||
None => return Vec::new(),
|
||||
};
|
||||
|
||||
@ -1148,7 +1148,7 @@ impl EmitterWriter {
|
||||
(pos + 2, annotation.start_col.saturating_sub(left))
|
||||
};
|
||||
if let Some(ref label) = annotation.label {
|
||||
buffer.puts(line_offset + pos, code_offset + col, &label, style);
|
||||
buffer.puts(line_offset + pos, code_offset + col, label, style);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1358,7 +1358,7 @@ impl EmitterWriter {
|
||||
// only render error codes, not lint codes
|
||||
if let Some(DiagnosticId::Error(ref code)) = *code {
|
||||
buffer.append(0, "[", Style::Level(*level));
|
||||
buffer.append(0, &code, Style::Level(*level));
|
||||
buffer.append(0, code, Style::Level(*level));
|
||||
buffer.append(0, "]", Style::Level(*level));
|
||||
label_width += 2 + code.len();
|
||||
}
|
||||
@ -1683,7 +1683,7 @@ impl EmitterWriter {
|
||||
};
|
||||
|
||||
// Render the replacements for each suggestion
|
||||
let suggestions = suggestion.splice_lines(&**sm);
|
||||
let suggestions = suggestion.splice_lines(sm);
|
||||
debug!("emit_suggestion_default: suggestions={:?}", suggestions);
|
||||
|
||||
if suggestions.is_empty() {
|
||||
@ -1784,7 +1784,7 @@ impl EmitterWriter {
|
||||
buffer.puts(
|
||||
row_num - 1 + line - line_start,
|
||||
max_line_num_len + 3,
|
||||
&normalize_whitespace(&*file_lines.file.get_line(line - 1).unwrap()),
|
||||
&normalize_whitespace(&file_lines.file.get_line(line - 1).unwrap()),
|
||||
Style::Removal,
|
||||
);
|
||||
}
|
||||
@ -1926,7 +1926,7 @@ impl EmitterWriter {
|
||||
buffer.putc(
|
||||
row_num,
|
||||
(padding as isize + p) as usize,
|
||||
if part.is_addition(&sm) { '+' } else { '~' },
|
||||
if part.is_addition(sm) { '+' } else { '~' },
|
||||
Style::Addition,
|
||||
);
|
||||
}
|
||||
@ -1973,7 +1973,7 @@ impl EmitterWriter {
|
||||
buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle);
|
||||
} else if notice_capitalization {
|
||||
let msg = "notice the capitalization difference";
|
||||
buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle);
|
||||
buffer.puts(row_num, max_line_num_len + 3, msg, Style::NoStyle);
|
||||
}
|
||||
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
|
||||
Ok(())
|
||||
@ -2028,7 +2028,7 @@ impl EmitterWriter {
|
||||
for child in children {
|
||||
let span = child.render_span.as_ref().unwrap_or(&child.span);
|
||||
if let Err(err) = self.emit_message_default(
|
||||
&span,
|
||||
span,
|
||||
&child.message,
|
||||
args,
|
||||
&None,
|
||||
@ -2113,7 +2113,7 @@ impl EmitterWriter {
|
||||
*row_num - 1,
|
||||
max_line_num_len + 3,
|
||||
&normalize_whitespace(
|
||||
&*file_lines.file.get_line(file_lines.lines[line_pos].line_index).unwrap(),
|
||||
&file_lines.file.get_line(file_lines.lines[line_pos].line_index).unwrap(),
|
||||
),
|
||||
Style::NoStyle,
|
||||
);
|
||||
|
@ -136,7 +136,7 @@ impl Translate for JsonEmitter {
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
&self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ impl HandlerInner {
|
||||
|
||||
diagnostic.children.drain_filter(already_emitted_sub).for_each(|_| {});
|
||||
|
||||
self.emitter.emit_diagnostic(&diagnostic);
|
||||
self.emitter.emit_diagnostic(diagnostic);
|
||||
if diagnostic.is_error() {
|
||||
self.deduplicated_err_count += 1;
|
||||
} else if let Warning(_) = diagnostic.level {
|
||||
|
@ -59,13 +59,13 @@ pub trait Translate {
|
||||
trace!(?message, ?args);
|
||||
let (identifier, attr) = match message {
|
||||
DiagnosticMessage::Str(msg) | DiagnosticMessage::Eager(msg) => {
|
||||
return Cow::Borrowed(&msg);
|
||||
return Cow::Borrowed(msg);
|
||||
}
|
||||
DiagnosticMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
|
||||
};
|
||||
|
||||
let translate_with_bundle = |bundle: &'a FluentBundle| -> Option<(Cow<'_, str>, Vec<_>)> {
|
||||
let message = bundle.get_message(&identifier)?;
|
||||
let message = bundle.get_message(identifier)?;
|
||||
let value = match attr {
|
||||
Some(attr) => message.get_attribute(attr)?.value(),
|
||||
None => message.value()?,
|
||||
@ -73,7 +73,7 @@ pub trait Translate {
|
||||
debug!(?message, ?value);
|
||||
|
||||
let mut errs = vec![];
|
||||
let translated = bundle.format_pattern(value, Some(&args), &mut errs);
|
||||
let translated = bundle.format_pattern(value, Some(args), &mut errs);
|
||||
debug!(?translated, ?errs);
|
||||
Some((translated, errs))
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ pub enum LinkOrCopy {
|
||||
pub fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(p: P, q: Q) -> io::Result<LinkOrCopy> {
|
||||
let p = p.as_ref();
|
||||
let q = q.as_ref();
|
||||
match fs::remove_file(&q) {
|
||||
match fs::remove_file(q) {
|
||||
Ok(()) => (),
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => (),
|
||||
Err(err) => return Err(err),
|
||||
|
@ -410,7 +410,7 @@ impl<'a> Id<'a> {
|
||||
}
|
||||
|
||||
pub fn as_slice(&'a self) -> &'a str {
|
||||
&*self.name
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ impl<'a> LabelText<'a> {
|
||||
pub fn to_dot_string(&self) -> String {
|
||||
match *self {
|
||||
LabelStr(ref s) => format!("\"{}\"", s.escape_default()),
|
||||
EscStr(ref s) => format!("\"{}\"", LabelText::escape_str(&s)),
|
||||
EscStr(ref s) => format!("\"{}\"", LabelText::escape_str(s)),
|
||||
HtmlStr(ref s) => format!("<{}>", s),
|
||||
}
|
||||
}
|
||||
@ -529,7 +529,7 @@ impl<'a> LabelText<'a> {
|
||||
EscStr(s) => s,
|
||||
LabelStr(s) => {
|
||||
if s.contains('\\') {
|
||||
(&*s).escape_default().to_string().into()
|
||||
s.escape_default().to_string().into()
|
||||
} else {
|
||||
s
|
||||
}
|
||||
|
@ -2437,7 +2437,7 @@ impl<'hir> Ty<'hir> {
|
||||
pub fn peel_refs(&self) -> &Self {
|
||||
let mut final_ty = self;
|
||||
while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind {
|
||||
final_ty = &ty;
|
||||
final_ty = ty;
|
||||
}
|
||||
final_ty
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ impl Ord for HirId {
|
||||
|
||||
impl PartialOrd for HirId {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(&other))
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ pub trait Visitor<'v>: Sized {
|
||||
|
||||
pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) {
|
||||
visitor.visit_id(param.hir_id);
|
||||
visitor.visit_pat(¶m.pat);
|
||||
visitor.visit_pat(param.pat);
|
||||
}
|
||||
|
||||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
|
||||
@ -470,7 +470,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
|
||||
}
|
||||
ItemKind::Fn(ref sig, ref generics, body_id) => visitor.visit_fn(
|
||||
FnKind::ItemFn(item.ident, generics, sig.header),
|
||||
&sig.decl,
|
||||
sig.decl,
|
||||
body_id,
|
||||
item.span,
|
||||
item.hir_id(),
|
||||
@ -544,7 +544,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
|
||||
|
||||
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
|
||||
walk_list!(visitor, visit_param, body.params);
|
||||
visitor.visit_expr(&body.value);
|
||||
visitor.visit_expr(body.value);
|
||||
}
|
||||
|
||||
pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) {
|
||||
@ -580,7 +580,7 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local<'v>) {
|
||||
// dominates the local's definition.
|
||||
walk_list!(visitor, visit_expr, &local.init);
|
||||
visitor.visit_id(local.hir_id);
|
||||
visitor.visit_pat(&local.pat);
|
||||
visitor.visit_pat(local.pat);
|
||||
if let Some(els) = local.els {
|
||||
visitor.visit_block(els);
|
||||
}
|
||||
@ -606,7 +606,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) {
|
||||
|
||||
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
|
||||
visitor.visit_id(arm.hir_id);
|
||||
visitor.visit_pat(&arm.pat);
|
||||
visitor.visit_pat(arm.pat);
|
||||
if let Some(ref g) = arm.guard {
|
||||
match g {
|
||||
Guard::If(ref e) => visitor.visit_expr(e),
|
||||
@ -615,7 +615,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
visitor.visit_expr(&arm.body);
|
||||
visitor.visit_expr(arm.body);
|
||||
}
|
||||
|
||||
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
|
||||
@ -660,7 +660,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
|
||||
pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'v>) {
|
||||
visitor.visit_id(field.hir_id);
|
||||
visitor.visit_ident(field.ident);
|
||||
visitor.visit_pat(&field.pat)
|
||||
visitor.visit_pat(field.pat)
|
||||
}
|
||||
|
||||
pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) {
|
||||
@ -800,7 +800,7 @@ pub fn walk_let_expr<'v, V: Visitor<'v>>(visitor: &mut V, let_expr: &'v Let<'v>)
|
||||
pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) {
|
||||
visitor.visit_id(field.hir_id);
|
||||
visitor.visit_ident(field.ident);
|
||||
visitor.visit_expr(&field.expr)
|
||||
visitor.visit_expr(field.expr)
|
||||
}
|
||||
|
||||
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
|
||||
@ -808,10 +808,10 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
|
||||
|
||||
match typ.kind {
|
||||
TyKind::Slice(ref ty) => visitor.visit_ty(ty),
|
||||
TyKind::Ptr(ref mutable_type) => visitor.visit_ty(&mutable_type.ty),
|
||||
TyKind::Ptr(ref mutable_type) => visitor.visit_ty(mutable_type.ty),
|
||||
TyKind::Rptr(ref lifetime, ref mutable_type) => {
|
||||
visitor.visit_lifetime(lifetime);
|
||||
visitor.visit_ty(&mutable_type.ty)
|
||||
visitor.visit_ty(mutable_type.ty)
|
||||
}
|
||||
TyKind::Never => {}
|
||||
TyKind::Tup(tuple_element_types) => {
|
||||
@ -819,7 +819,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
|
||||
}
|
||||
TyKind::BareFn(ref function_declaration) => {
|
||||
walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
|
||||
visitor.visit_fn_decl(&function_declaration.decl);
|
||||
visitor.visit_fn_decl(function_declaration.decl);
|
||||
}
|
||||
TyKind::Path(ref qpath) => {
|
||||
visitor.visit_qpath(qpath, typ.hir_id, typ.span);
|
||||
@ -952,8 +952,8 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item;
|
||||
let hir_id = trait_item.hir_id();
|
||||
visitor.visit_ident(ident);
|
||||
visitor.visit_generics(&generics);
|
||||
visitor.visit_defaultness(&defaultness);
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_defaultness(defaultness);
|
||||
match *kind {
|
||||
TraitItemKind::Const(ref ty, default) => {
|
||||
visitor.visit_id(hir_id);
|
||||
@ -962,13 +962,13 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
}
|
||||
TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
|
||||
visitor.visit_id(hir_id);
|
||||
visitor.visit_fn_decl(&sig.decl);
|
||||
visitor.visit_fn_decl(sig.decl);
|
||||
for ¶m_name in param_names {
|
||||
visitor.visit_ident(param_name);
|
||||
}
|
||||
}
|
||||
TraitItemKind::Fn(ref sig, TraitFn::Provided(body_id)) => {
|
||||
visitor.visit_fn(FnKind::Method(ident, sig), &sig.decl, body_id, span, hir_id);
|
||||
visitor.visit_fn(FnKind::Method(ident, sig), sig.decl, body_id, span, hir_id);
|
||||
}
|
||||
TraitItemKind::Type(bounds, ref default) => {
|
||||
visitor.visit_id(hir_id);
|
||||
@ -1010,7 +1010,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
||||
ImplItemKind::Fn(ref sig, body_id) => {
|
||||
visitor.visit_fn(
|
||||
FnKind::Method(impl_item.ident, sig),
|
||||
&sig.decl,
|
||||
sig.decl,
|
||||
body_id,
|
||||
impl_item.span,
|
||||
impl_item.hir_id(),
|
||||
@ -1043,7 +1043,7 @@ pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'
|
||||
|
||||
pub fn walk_trait_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v TraitRef<'v>) {
|
||||
visitor.visit_id(trait_ref.hir_ref_id);
|
||||
visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
|
||||
visitor.visit_path(trait_ref.path, trait_ref.hir_ref_id)
|
||||
}
|
||||
|
||||
pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound<'v>) {
|
||||
@ -1075,7 +1075,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(
|
||||
pub fn walk_field_def<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v FieldDef<'v>) {
|
||||
visitor.visit_id(field.hir_id);
|
||||
visitor.visit_ident(field.ident);
|
||||
visitor.visit_ty(&field.ty);
|
||||
visitor.visit_ty(field.ty);
|
||||
}
|
||||
|
||||
pub fn walk_enum_def<'v, V: Visitor<'v>>(
|
||||
|
@ -29,8 +29,8 @@ impl<'a> DiagnosticDerive<'a> {
|
||||
let DiagnosticDerive { mut structure, mut builder } = self;
|
||||
|
||||
let implementation = builder.each_variant(&mut structure, |mut builder, variant| {
|
||||
let preamble = builder.preamble(&variant);
|
||||
let body = builder.body(&variant);
|
||||
let preamble = builder.preamble(variant);
|
||||
let body = builder.body(variant);
|
||||
|
||||
let diag = &builder.parent.diag;
|
||||
let DiagnosticDeriveKind::Diagnostic { handler } = &builder.parent.kind else {
|
||||
@ -39,7 +39,7 @@ impl<'a> DiagnosticDerive<'a> {
|
||||
let init = match builder.slug.value_ref() {
|
||||
None => {
|
||||
span_err(builder.span, "diagnostic slug not specified")
|
||||
.help(&format!(
|
||||
.help(format!(
|
||||
"specify the slug as the first argument to the `#[diag(...)]` \
|
||||
attribute, such as `#[diag(hir_analysis_example_error)]`",
|
||||
))
|
||||
@ -48,10 +48,10 @@ impl<'a> DiagnosticDerive<'a> {
|
||||
}
|
||||
Some(slug) if let Some( Mismatch { slug_name, crate_name, slug_prefix }) = Mismatch::check(slug) => {
|
||||
span_err(slug.span().unwrap(), "diagnostic slug and crate name do not match")
|
||||
.note(&format!(
|
||||
.note(format!(
|
||||
"slug is `{slug_name}` but the crate name is `{crate_name}`"
|
||||
))
|
||||
.help(&format!(
|
||||
.help(format!(
|
||||
"expected a slug starting with `{slug_prefix}_...`"
|
||||
))
|
||||
.emit();
|
||||
@ -113,8 +113,8 @@ impl<'a> LintDiagnosticDerive<'a> {
|
||||
let LintDiagnosticDerive { mut structure, mut builder } = self;
|
||||
|
||||
let implementation = builder.each_variant(&mut structure, |mut builder, variant| {
|
||||
let preamble = builder.preamble(&variant);
|
||||
let body = builder.body(&variant);
|
||||
let preamble = builder.preamble(variant);
|
||||
let body = builder.body(variant);
|
||||
|
||||
let diag = &builder.parent.diag;
|
||||
let formatting_init = &builder.formatting_init;
|
||||
@ -128,28 +128,28 @@ impl<'a> LintDiagnosticDerive<'a> {
|
||||
|
||||
let msg = builder.each_variant(&mut structure, |mut builder, variant| {
|
||||
// Collect the slug by generating the preamble.
|
||||
let _ = builder.preamble(&variant);
|
||||
let _ = builder.preamble(variant);
|
||||
|
||||
match builder.slug.value_ref() {
|
||||
None => {
|
||||
span_err(builder.span, "diagnostic slug not specified")
|
||||
.help(&format!(
|
||||
.help(format!(
|
||||
"specify the slug as the first argument to the attribute, such as \
|
||||
`#[diag(compiletest_example)]`",
|
||||
))
|
||||
.emit();
|
||||
return DiagnosticDeriveError::ErrorHandled.to_compile_error();
|
||||
DiagnosticDeriveError::ErrorHandled.to_compile_error()
|
||||
}
|
||||
Some(slug) if let Some( Mismatch { slug_name, crate_name, slug_prefix }) = Mismatch::check(slug) => {
|
||||
span_err(slug.span().unwrap(), "diagnostic slug and crate name do not match")
|
||||
.note(&format!(
|
||||
.note(format!(
|
||||
"slug is `{slug_name}` but the crate name is `{crate_name}`"
|
||||
))
|
||||
.help(&format!(
|
||||
.help(format!(
|
||||
"expected a slug starting with `{slug_prefix}_...`"
|
||||
))
|
||||
.emit();
|
||||
return DiagnosticDeriveError::ErrorHandled.to_compile_error();
|
||||
DiagnosticDeriveError::ErrorHandled.to_compile_error()
|
||||
}
|
||||
Some(slug) => {
|
||||
quote! {
|
||||
|
@ -100,7 +100,7 @@ impl DiagnosticDeriveBuilder {
|
||||
_ => variant.ast().ident.span().unwrap(),
|
||||
};
|
||||
let builder = DiagnosticDeriveVariantBuilder {
|
||||
parent: &self,
|
||||
parent: self,
|
||||
span,
|
||||
field_map: build_field_mapping(variant),
|
||||
formatting_init: TokenStream::new(),
|
||||
@ -211,7 +211,7 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||
nested_iter.next();
|
||||
}
|
||||
Some(NestedMeta::Meta(Meta::NameValue { .. })) => {}
|
||||
Some(nested_attr) => throw_invalid_nested_attr!(attr, &nested_attr, |diag| diag
|
||||
Some(nested_attr) => throw_invalid_nested_attr!(attr, nested_attr, |diag| diag
|
||||
.help("a diagnostic slug is required as the first argument")),
|
||||
None => throw_invalid_attr!(attr, &meta, |diag| diag
|
||||
.help("a diagnostic slug is required as the first argument")),
|
||||
@ -227,13 +227,13 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||
..
|
||||
})) => (value, path),
|
||||
NestedMeta::Meta(Meta::Path(_)) => {
|
||||
invalid_nested_attr(attr, &nested_attr)
|
||||
invalid_nested_attr(attr, nested_attr)
|
||||
.help("diagnostic slug must be the first argument")
|
||||
.emit();
|
||||
continue;
|
||||
}
|
||||
_ => {
|
||||
invalid_nested_attr(attr, &nested_attr).emit();
|
||||
invalid_nested_attr(attr, nested_attr).emit();
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@ -251,7 +251,7 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||
#diag.code(rustc_errors::DiagnosticId::Error(#code.to_string()));
|
||||
});
|
||||
}
|
||||
_ => invalid_nested_attr(attr, &nested_attr)
|
||||
_ => invalid_nested_attr(attr, nested_attr)
|
||||
.help("only `code` is a valid nested attributes following the slug")
|
||||
.emit(),
|
||||
}
|
||||
@ -427,9 +427,9 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||
Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug))
|
||||
}
|
||||
SubdiagnosticKind::Note | SubdiagnosticKind::Help | SubdiagnosticKind::Warn => {
|
||||
if type_matches_path(&info.ty, &["rustc_span", "Span"]) {
|
||||
if type_matches_path(info.ty, &["rustc_span", "Span"]) {
|
||||
Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug))
|
||||
} else if type_is_unit(&info.ty) {
|
||||
} else if type_is_unit(info.ty) {
|
||||
Ok(self.add_subdiagnostic(&fn_ident, slug))
|
||||
} else {
|
||||
report_type_error(attr, "`Span` or `()`")?
|
||||
|
@ -409,7 +409,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
||||
let mut code = None;
|
||||
for nested_attr in list.nested.iter() {
|
||||
let NestedMeta::Meta(ref meta) = nested_attr else {
|
||||
throw_invalid_nested_attr!(attr, &nested_attr);
|
||||
throw_invalid_nested_attr!(attr, nested_attr);
|
||||
};
|
||||
|
||||
let span = meta.span().unwrap();
|
||||
@ -427,7 +427,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
||||
);
|
||||
code.set_once((code_field, formatting_init), span);
|
||||
}
|
||||
_ => throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
|
||||
_ => throw_invalid_nested_attr!(attr, nested_attr, |diag| {
|
||||
diag.help("`code` is the only valid nested attribute")
|
||||
}),
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ fn report_error_if_not_applied_to_ty(
|
||||
path: &[&str],
|
||||
ty_name: &str,
|
||||
) -> Result<(), DiagnosticDeriveError> {
|
||||
if !type_matches_path(&info.ty, path) {
|
||||
if !type_matches_path(info.ty, path) {
|
||||
report_type_error(attr, ty_name)?;
|
||||
}
|
||||
|
||||
@ -105,8 +105,8 @@ pub(crate) fn report_error_if_not_applied_to_span(
|
||||
attr: &Attribute,
|
||||
info: &FieldInfo<'_>,
|
||||
) -> Result<(), DiagnosticDeriveError> {
|
||||
if !type_matches_path(&info.ty, &["rustc_span", "Span"])
|
||||
&& !type_matches_path(&info.ty, &["rustc_errors", "MultiSpan"])
|
||||
if !type_matches_path(info.ty, &["rustc_span", "Span"])
|
||||
&& !type_matches_path(info.ty, &["rustc_errors", "MultiSpan"])
|
||||
{
|
||||
report_type_error(attr, "`Span` or `MultiSpan`")?;
|
||||
}
|
||||
@ -686,7 +686,7 @@ impl SubdiagnosticKind {
|
||||
let meta = match nested_attr {
|
||||
NestedMeta::Meta(ref meta) => meta,
|
||||
NestedMeta::Lit(_) => {
|
||||
invalid_nested_attr(attr, &nested_attr).emit();
|
||||
invalid_nested_attr(attr, nested_attr).emit();
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@ -698,7 +698,7 @@ impl SubdiagnosticKind {
|
||||
let string_value = match meta {
|
||||
Meta::NameValue(MetaNameValue { lit: syn::Lit::Str(value), .. }) => Some(value),
|
||||
|
||||
Meta::Path(_) => throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
|
||||
Meta::Path(_) => throw_invalid_nested_attr!(attr, nested_attr, |diag| {
|
||||
diag.help("a diagnostic slug must be the first argument to the attribute")
|
||||
}),
|
||||
_ => None,
|
||||
@ -720,7 +720,7 @@ impl SubdiagnosticKind {
|
||||
| SubdiagnosticKind::MultipartSuggestion { ref mut applicability, .. },
|
||||
) => {
|
||||
let Some(value) = string_value else {
|
||||
invalid_nested_attr(attr, &nested_attr).emit();
|
||||
invalid_nested_attr(attr, nested_attr).emit();
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -736,7 +736,7 @@ impl SubdiagnosticKind {
|
||||
| SubdiagnosticKind::MultipartSuggestion { .. },
|
||||
) => {
|
||||
let Some(value) = string_value else {
|
||||
invalid_nested_attr(attr, &nested_attr).emit();
|
||||
invalid_nested_attr(attr, nested_attr).emit();
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -752,19 +752,19 @@ impl SubdiagnosticKind {
|
||||
|
||||
// Invalid nested attribute
|
||||
(_, SubdiagnosticKind::Suggestion { .. }) => {
|
||||
invalid_nested_attr(attr, &nested_attr)
|
||||
invalid_nested_attr(attr, nested_attr)
|
||||
.help(
|
||||
"only `style`, `code` and `applicability` are valid nested attributes",
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
(_, SubdiagnosticKind::MultipartSuggestion { .. }) => {
|
||||
invalid_nested_attr(attr, &nested_attr)
|
||||
invalid_nested_attr(attr, nested_attr)
|
||||
.help("only `style` and `applicability` are valid nested attributes")
|
||||
.emit()
|
||||
}
|
||||
_ => {
|
||||
invalid_nested_attr(attr, &nested_attr).emit();
|
||||
invalid_nested_attr(attr, nested_attr).emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ impl CguReuseTracker {
|
||||
let at_least = if at_least { 1 } else { 0 };
|
||||
IncorrectCguReuseType {
|
||||
span: error_span.0,
|
||||
cgu_user_name: &cgu_user_name,
|
||||
cgu_user_name,
|
||||
actual_reuse,
|
||||
expected_reuse,
|
||||
at_least,
|
||||
|
@ -622,7 +622,7 @@ impl OutputFilenames {
|
||||
/// should be placed on disk.
|
||||
pub fn output_path(&self, flavor: OutputType) -> PathBuf {
|
||||
let extension = flavor.extension();
|
||||
self.with_directory_and_extension(&self.out_directory, &extension)
|
||||
self.with_directory_and_extension(&self.out_directory, extension)
|
||||
}
|
||||
|
||||
/// Gets the path where a compilation artifact of the given type for the
|
||||
@ -659,7 +659,7 @@ impl OutputFilenames {
|
||||
|
||||
let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
|
||||
|
||||
self.with_directory_and_extension(&temps_directory, &extension)
|
||||
self.with_directory_and_extension(temps_directory, &extension)
|
||||
}
|
||||
|
||||
pub fn with_extension(&self, extension: &str) -> PathBuf {
|
||||
@ -1159,7 +1159,7 @@ impl CrateCheckConfig {
|
||||
values_target_family
|
||||
.extend(target.options.families.iter().map(|family| Symbol::intern(family)));
|
||||
values_target_arch.insert(Symbol::intern(&target.arch));
|
||||
values_target_endian.insert(Symbol::intern(&target.options.endian.as_str()));
|
||||
values_target_endian.insert(Symbol::intern(target.options.endian.as_str()));
|
||||
values_target_env.insert(Symbol::intern(&target.options.env));
|
||||
values_target_abi.insert(Symbol::intern(&target.options.abi));
|
||||
values_target_vendor.insert(Symbol::intern(&target.options.vendor));
|
||||
@ -1846,7 +1846,7 @@ pub fn parse_target_triple(
|
||||
match matches.opt_str("target") {
|
||||
Some(target) if target.ends_with(".json") => {
|
||||
let path = Path::new(&target);
|
||||
TargetTriple::from_path(&path).unwrap_or_else(|_| {
|
||||
TargetTriple::from_path(path).unwrap_or_else(|_| {
|
||||
early_error(error_format, &format!("target file {path:?} does not exist"))
|
||||
})
|
||||
}
|
||||
@ -1992,7 +1992,7 @@ fn parse_native_lib_modifiers(
|
||||
) -> (NativeLibKind, Option<bool>) {
|
||||
let mut verbatim = None;
|
||||
for modifier in modifiers.split(',') {
|
||||
let (modifier, value) = match modifier.strip_prefix(&['+', '-']) {
|
||||
let (modifier, value) = match modifier.strip_prefix(['+', '-']) {
|
||||
Some(m) => (m, modifier.starts_with('+')),
|
||||
None => early_error(
|
||||
error_format,
|
||||
@ -2421,7 +2421,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
|
||||
let mut search_paths = vec![];
|
||||
for s in &matches.opt_strs("L") {
|
||||
search_paths.push(SearchPath::from_cli_opt(&s, error_format));
|
||||
search_paths.push(SearchPath::from_cli_opt(s, error_format));
|
||||
}
|
||||
|
||||
let libs = parse_libs(matches, error_format);
|
||||
|
@ -317,7 +317,7 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span:
|
||||
LitError::InvalidIntSuffix => {
|
||||
let suf = suffix.expect("suffix error with no suffix");
|
||||
let suf = suf.as_str();
|
||||
if looks_like_width_suffix(&['i', 'u'], &suf) {
|
||||
if looks_like_width_suffix(&['i', 'u'], suf) {
|
||||
// If it looks like a width, try to be helpful.
|
||||
sess.emit_err(InvalidIntLiteralWidth { span, width: suf[1..].into() });
|
||||
} else if let Some(fixed) = fix_base_capitalisation(suf) {
|
||||
|
@ -247,7 +247,7 @@ fn analyze_source_file_generic(
|
||||
// The slow path:
|
||||
// This is either ASCII control character "DEL" or the beginning of
|
||||
// a multibyte char. Just decode to `char`.
|
||||
let c = (&src[i..]).chars().next().unwrap();
|
||||
let c = src[i..].chars().next().unwrap();
|
||||
char_len = c.len_utf8();
|
||||
|
||||
let pos = BytePos::from_usize(i) + output_offset;
|
||||
|
@ -165,7 +165,7 @@ impl<'sm> CachingSourceMapView<'sm> {
|
||||
Some(new_file_and_idx)
|
||||
} else {
|
||||
let file = &self.line_cache[oldest].file;
|
||||
if !file_contains(&file, span_data.hi) {
|
||||
if !file_contains(file, span_data.hi) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ impl HygieneData {
|
||||
}
|
||||
|
||||
pub fn with<T, F: FnOnce(&mut HygieneData) -> T>(f: F) -> T {
|
||||
with_session_globals(|session_globals| f(&mut *session_globals.hygiene_data.borrow_mut()))
|
||||
with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow_mut()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -238,7 +238,7 @@ impl RealFileName {
|
||||
pub fn remapped_path_if_available(&self) -> &Path {
|
||||
match self {
|
||||
RealFileName::LocalPath(p)
|
||||
| RealFileName::Remapped { local_path: _, virtual_name: p } => &p,
|
||||
| RealFileName::Remapped { local_path: _, virtual_name: p } => p,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,5 +166,5 @@ impl SpanInterner {
|
||||
// If an interner exists, return it. Otherwise, prepare a fresh one.
|
||||
#[inline]
|
||||
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
|
||||
crate::with_session_globals(|session_globals| f(&mut *session_globals.span_interner.lock()))
|
||||
crate::with_session_globals(|session_globals| f(&mut session_globals.span_interner.lock()))
|
||||
}
|
||||
|
@ -1877,7 +1877,7 @@ impl<S: Encoder> Encodable<S> for Symbol {
|
||||
impl<D: Decoder> Decodable<D> for Symbol {
|
||||
#[inline]
|
||||
default fn decode(d: &mut D) -> Symbol {
|
||||
Symbol::intern(&d.read_str())
|
||||
Symbol::intern(d.read_str())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ fn arg_scalar_pair<C>(
|
||||
where
|
||||
C: HasDataLayout,
|
||||
{
|
||||
data = arg_scalar(cx, &scalar1, offset, data);
|
||||
data = arg_scalar(cx, scalar1, offset, data);
|
||||
match (scalar1.primitive(), scalar2.primitive()) {
|
||||
(abi::F32, _) => offset += Reg::f32().size,
|
||||
(_, abi::F64) => offset += Reg::f64().size,
|
||||
@ -90,7 +90,7 @@ where
|
||||
if (offset.bytes() % 4) != 0 && scalar2.primitive().is_float() {
|
||||
offset += Size::from_bytes(4 - (offset.bytes() % 4));
|
||||
}
|
||||
data = arg_scalar(cx, &scalar2, offset, data);
|
||||
data = arg_scalar(cx, scalar2, offset, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -2658,7 +2658,7 @@ impl Target {
|
||||
|
||||
// Additionally look in the sysroot under `lib/rustlib/<triple>/target.json`
|
||||
// as a fallback.
|
||||
let rustlib_path = crate::target_rustlib_path(&sysroot, &target_triple);
|
||||
let rustlib_path = crate::target_rustlib_path(sysroot, target_triple);
|
||||
let p = PathBuf::from_iter([
|
||||
Path::new(sysroot),
|
||||
Path::new(&rustlib_path),
|
||||
|
Loading…
Reference in New Issue
Block a user