mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-07 20:58:39 +00:00
Auto merge of #98066 - matthiaskrgr:rollup-wb9gs92, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #97709 (Normalize consts' tys when relating with `adt_const_params`) - #97875 (Remove the `infer_static_outlives_requirements` feature) - #97960 (interpret: unify offset_from check with offset check) - #97999 (Make `type_changing_struct_update` no longer an incomplete feature) - #98043 (Remove unnecessary `to_string` and `String::new`) - #98044 ([issues:97981] del unrelated comment) - #98049 (Document an edge case of `str::split_once`) - #98050 (Add some more regression tests for #67945) - #98054 (Fix error message for `download-ci-llvm`) - #98057 (Update miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ca122c7ebb
@ -1168,7 +1168,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
e.span,
|
e.span,
|
||||||
"consider removing the trailing pattern",
|
"consider removing the trailing pattern",
|
||||||
String::new(),
|
"",
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -139,7 +139,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
.span_suggestion_verbose(
|
.span_suggestion_verbose(
|
||||||
sp,
|
sp,
|
||||||
&format!("if you don't need to use the contents of {}, discard the tuple's remaining fields", ident),
|
&format!("if you don't need to use the contents of {}, discard the tuple's remaining fields", ident),
|
||||||
"..".to_string(),
|
"..",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -488,7 +488,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
replace_span,
|
replace_span,
|
||||||
&format!("provide a definition for the {}", ctx),
|
&format!("provide a definition for the {}", ctx),
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -522,7 +522,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!("remove the {}", remove_descr),
|
&format!("remove the {}", remove_descr),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.span_label(self.current_extern_span(), "`extern` block begins here")
|
.span_label(self.current_extern_span(), "`extern` block begins here")
|
||||||
@ -570,7 +570,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
body.span,
|
body.span,
|
||||||
"remove the invalid body",
|
"remove the invalid body",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.help(
|
.help(
|
||||||
@ -599,7 +599,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion_verbose(
|
.span_suggestion_verbose(
|
||||||
span.until(ident.span.shrink_to_lo()),
|
span.until(ident.span.shrink_to_lo()),
|
||||||
"remove the qualifiers",
|
"remove the qualifiers",
|
||||||
"fn ".to_string(),
|
"fn ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -703,7 +703,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
generics.span,
|
generics.span,
|
||||||
"remove the parameters",
|
"remove the parameters",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -721,7 +721,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"remove the super traits or lifetime bounds",
|
"remove the super traits or lifetime bounds",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -753,7 +753,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
total_span,
|
total_span,
|
||||||
"remove these associated items",
|
"remove these associated items",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.span_label(ident_span, "auto trait cannot have associated items")
|
.span_label(ident_span, "auto trait cannot have associated items")
|
||||||
@ -993,7 +993,7 @@ fn validate_generic_param_order(
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"reorder the parameters: lifetimes, then consts and types",
|
"reorder the parameters: lifetimes, then consts and types",
|
||||||
ordered_params.clone(),
|
&ordered_params,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -823,7 +823,7 @@ fn maybe_stage_features(sess: &Session, krate: &ast::Crate) {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
attr.span,
|
attr.span,
|
||||||
"remove the attribute",
|
"remove the attribute",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"consider removing the prefix",
|
"consider removing the prefix",
|
||||||
lint_str[1..].to_string(),
|
&lint_str[1..],
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -942,7 +942,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
item.span(),
|
item.span(),
|
||||||
"supply an argument here",
|
"supply an argument here",
|
||||||
"align(...)".to_string(),
|
"align(...)",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -225,7 +225,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
.map(|n| format!("`{}`", n))
|
.map(|n| format!("`{}`", n))
|
||||||
.unwrap_or_else(|| "the value".to_string())
|
.unwrap_or_else(|| "the value".to_string())
|
||||||
),
|
),
|
||||||
"ref ".to_string(),
|
"ref ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
in_pattern = true;
|
in_pattern = true;
|
||||||
@ -276,7 +276,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
.map(|n| format!("`{}`", n))
|
.map(|n| format!("`{}`", n))
|
||||||
.unwrap_or_else(|| "the mutable reference".to_string()),
|
.unwrap_or_else(|| "the mutable reference".to_string()),
|
||||||
),
|
),
|
||||||
"&mut *".to_string(),
|
"&mut *",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1519,15 +1519,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
Ok(string) => {
|
Ok(string) => {
|
||||||
if string.starts_with("async ") {
|
if string.starts_with("async ") {
|
||||||
let pos = args_span.lo() + BytePos(6);
|
let pos = args_span.lo() + BytePos(6);
|
||||||
(args_span.with_lo(pos).with_hi(pos), "move ".to_string())
|
(args_span.with_lo(pos).with_hi(pos), "move ")
|
||||||
} else if string.starts_with("async|") {
|
} else if string.starts_with("async|") {
|
||||||
let pos = args_span.lo() + BytePos(5);
|
let pos = args_span.lo() + BytePos(5);
|
||||||
(args_span.with_lo(pos).with_hi(pos), " move".to_string())
|
(args_span.with_lo(pos).with_hi(pos), " move")
|
||||||
} else {
|
} else {
|
||||||
(args_span.shrink_to_lo(), "move ".to_string())
|
(args_span.shrink_to_lo(), "move ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => (args_span, "move |<args>| <body>".to_string()),
|
Err(_) => (args_span, "move |<args>| <body>"),
|
||||||
};
|
};
|
||||||
let kind = match use_span.generator_kind() {
|
let kind = match use_span.generator_kind() {
|
||||||
Some(generator_kind) => match generator_kind {
|
Some(generator_kind) => match generator_kind {
|
||||||
|
@ -212,7 +212,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||||||
"consider adding semicolon after the expression so its \
|
"consider adding semicolon after the expression so its \
|
||||||
temporaries are dropped sooner, before the local variables \
|
temporaries are dropped sooner, before the local variables \
|
||||||
declared by the block are dropped",
|
declared by the block are dropped",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
avoid moving into the `for` loop",
|
avoid moving into the `for` loop",
|
||||||
ty,
|
ty,
|
||||||
),
|
),
|
||||||
"&".to_string(),
|
"&",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1049,7 +1049,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
.map(|n| format!("`{}`", n))
|
.map(|n| format!("`{}`", n))
|
||||||
.unwrap_or_else(|| "the mutable reference".to_string()),
|
.unwrap_or_else(|| "the mutable reference".to_string()),
|
||||||
),
|
),
|
||||||
"&mut *".to_string(),
|
"&mut *",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1067,7 +1067,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
fn_call_span.shrink_to_lo(),
|
fn_call_span.shrink_to_lo(),
|
||||||
"consider calling `.as_ref()` to borrow the type's contents",
|
"consider calling `.as_ref()` to borrow the type's contents",
|
||||||
"as_ref().".to_string(),
|
"as_ref().",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
&format!("consider borrowing the `{}`'s content", diag_name.unwrap()),
|
&format!("consider borrowing the `{}`'s content", diag_name.unwrap()),
|
||||||
".as_ref()".to_string(),
|
".as_ref()",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else if let Some(use_spans) = use_spans {
|
} else if let Some(use_spans) = use_spans {
|
||||||
|
@ -295,7 +295,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
source_info.span.with_hi(source_info.span.lo() + BytePos(5)),
|
source_info.span.with_hi(source_info.span.lo() + BytePos(5)),
|
||||||
"try removing `&mut` here",
|
"try removing `&mut` here",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -316,7 +316,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
decl.source_info.span.shrink_to_lo(),
|
decl.source_info.span.shrink_to_lo(),
|
||||||
"consider making the binding mutable",
|
"consider making the binding mutable",
|
||||||
"mut ".to_string(),
|
"mut ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"try removing `&mut` here",
|
"try removing `&mut` here",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -860,7 +860,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"consider relaxing the implicit `'static` requirement",
|
"consider relaxing the implicit `'static` requirement",
|
||||||
" + '_".to_string(),
|
" + '_",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
suggested = true;
|
suggested = true;
|
||||||
|
@ -426,7 +426,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
mut_span,
|
mut_span,
|
||||||
"remove this `mut`",
|
"remove this `mut`",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -363,7 +363,7 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
|
|||||||
err.tool_only_span_suggestion(
|
err.tool_only_span_suggestion(
|
||||||
full_span,
|
full_span,
|
||||||
"remove this option",
|
"remove this option",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ fn parse_assert<'a>(cx: &mut ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PRes
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
parser.token.span,
|
parser.token.span,
|
||||||
"try removing semicolon",
|
"try removing semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -153,7 +153,7 @@ fn parse_assert<'a>(cx: &mut ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PRes
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
comma_span,
|
comma_span,
|
||||||
"try adding a comma",
|
"try adding a comma",
|
||||||
", ".to_string(),
|
", ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -142,7 +142,7 @@ fn report_path_args(sess: &Session, meta: &ast::MetaItem) {
|
|||||||
let report_error = |title, action| {
|
let report_error = |title, action| {
|
||||||
let span = meta.span.with_lo(meta.path.span.hi());
|
let span = meta.span.with_lo(meta.path.span.hi());
|
||||||
sess.struct_span_err(span, title)
|
sess.struct_span_err(span, title)
|
||||||
.span_suggestion(span, action, String::new(), Applicability::MachineApplicable)
|
.span_suggestion(span, action, "", Applicability::MachineApplicable)
|
||||||
.emit();
|
.emit();
|
||||||
};
|
};
|
||||||
match meta.kind {
|
match meta.kind {
|
||||||
|
@ -330,7 +330,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||||||
err.tool_only_span_suggestion(
|
err.tool_only_span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
&format!("use the `{}` trait", name),
|
&format!("use the `{}` trait", name),
|
||||||
(*fmt).to_string(),
|
*fmt,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ pub fn expand_test_or_bench(
|
|||||||
};
|
};
|
||||||
err.span_label(attr_sp, "the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions")
|
err.span_label(attr_sp, "the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions")
|
||||||
.span_label(item.span, format!("expected a non-associated function, found {} {}", item.kind.article(), item.kind.descr()))
|
.span_label(item.span, format!("expected a non-associated function, found {} {}", item.kind.article(), item.kind.descr()))
|
||||||
.span_suggestion(attr_sp, "replace with conditional compilation to make the item only exist when tests are being run", String::from("#[cfg(test)]"), Applicability::MaybeIncorrect)
|
.span_suggestion(attr_sp, "replace with conditional compilation to make the item only exist when tests are being run", "#[cfg(test)]", Applicability::MaybeIncorrect)
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
return vec![Annotatable::Item(item)];
|
return vec![Annotatable::Item(item)];
|
||||||
|
@ -313,79 +313,83 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let a = self.read_pointer(&args[0])?;
|
let a = self.read_pointer(&args[0])?;
|
||||||
let b = self.read_pointer(&args[1])?;
|
let b = self.read_pointer(&args[1])?;
|
||||||
|
|
||||||
// Special case: if both scalars are *equal integers*
|
|
||||||
// and not null, we pretend there is an allocation of size 0 right there,
|
|
||||||
// and their offset is 0. (There's never a valid object at null, making it an
|
|
||||||
// exception from the exception.)
|
|
||||||
// This is the dual to the special exception for offset-by-0
|
|
||||||
// in the inbounds pointer offset operation (see `ptr_offset_inbounds` below).
|
|
||||||
match (self.ptr_try_get_alloc_id(a), self.ptr_try_get_alloc_id(b)) {
|
|
||||||
(Err(a), Err(b)) if a == b && a != 0 => {
|
|
||||||
// Both are the same non-null integer.
|
|
||||||
self.write_scalar(Scalar::from_machine_isize(0, self), dest)?;
|
|
||||||
}
|
|
||||||
(Err(offset), _) | (_, Err(offset)) => {
|
|
||||||
throw_ub!(DanglingIntPointer(offset, CheckInAllocMsg::OffsetFromTest));
|
|
||||||
}
|
|
||||||
(Ok((a_alloc_id, a_offset, _)), Ok((b_alloc_id, b_offset, _))) => {
|
|
||||||
// Both are pointers. They must be into the same allocation.
|
|
||||||
if a_alloc_id != b_alloc_id {
|
|
||||||
throw_ub_format!(
|
|
||||||
"{} cannot compute offset of pointers into different allocations.",
|
|
||||||
intrinsic_name,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// And they must both be valid for zero-sized accesses ("in-bounds or one past the end").
|
|
||||||
self.check_ptr_access_align(
|
|
||||||
a,
|
|
||||||
Size::ZERO,
|
|
||||||
Align::ONE,
|
|
||||||
CheckInAllocMsg::OffsetFromTest,
|
|
||||||
)?;
|
|
||||||
self.check_ptr_access_align(
|
|
||||||
b,
|
|
||||||
Size::ZERO,
|
|
||||||
Align::ONE,
|
|
||||||
CheckInAllocMsg::OffsetFromTest,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if intrinsic_name == sym::ptr_offset_from_unsigned && a_offset < b_offset {
|
|
||||||
throw_ub_format!(
|
|
||||||
"{} cannot compute a negative offset, but {} < {}",
|
|
||||||
intrinsic_name,
|
|
||||||
a_offset.bytes(),
|
|
||||||
b_offset.bytes(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute offset.
|
|
||||||
let usize_layout = self.layout_of(self.tcx.types.usize)?;
|
let usize_layout = self.layout_of(self.tcx.types.usize)?;
|
||||||
let isize_layout = self.layout_of(self.tcx.types.isize)?;
|
let isize_layout = self.layout_of(self.tcx.types.isize)?;
|
||||||
let ret_layout = if intrinsic_name == sym::ptr_offset_from {
|
|
||||||
isize_layout
|
// Get offsets for both that are at least relative to the same base.
|
||||||
} else {
|
let (a_offset, b_offset) =
|
||||||
usize_layout
|
match (self.ptr_try_get_alloc_id(a), self.ptr_try_get_alloc_id(b)) {
|
||||||
|
(Err(a), Err(b)) => {
|
||||||
|
// Neither poiner points to an allocation.
|
||||||
|
// If these are inequal or null, this *will* fail the deref check below.
|
||||||
|
(a, b)
|
||||||
|
}
|
||||||
|
(Err(_), _) | (_, Err(_)) => {
|
||||||
|
// We managed to find a valid allocation for one pointer, but not the other.
|
||||||
|
// That means they are definitely not pointing to the same allocation.
|
||||||
|
throw_ub_format!(
|
||||||
|
"{} called on pointers into different allocations",
|
||||||
|
intrinsic_name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
(Ok((a_alloc_id, a_offset, _)), Ok((b_alloc_id, b_offset, _))) => {
|
||||||
|
// Found allocation for both. They must be into the same allocation.
|
||||||
|
if a_alloc_id != b_alloc_id {
|
||||||
|
throw_ub_format!(
|
||||||
|
"{} called on pointers into different allocations",
|
||||||
|
intrinsic_name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Use these offsets for distance calculation.
|
||||||
|
(a_offset.bytes(), b_offset.bytes())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Compute distance.
|
||||||
|
let distance = {
|
||||||
// The subtraction is always done in `isize` to enforce
|
// The subtraction is always done in `isize` to enforce
|
||||||
// the "no more than `isize::MAX` apart" requirement.
|
// the "no more than `isize::MAX` apart" requirement.
|
||||||
let a_offset = ImmTy::from_uint(a_offset.bytes(), isize_layout);
|
let a_offset = ImmTy::from_uint(a_offset, isize_layout);
|
||||||
let b_offset = ImmTy::from_uint(b_offset.bytes(), isize_layout);
|
let b_offset = ImmTy::from_uint(b_offset, isize_layout);
|
||||||
let (val, overflowed, _ty) =
|
let (val, overflowed, _ty) =
|
||||||
self.overflowing_binary_op(BinOp::Sub, &a_offset, &b_offset)?;
|
self.overflowing_binary_op(BinOp::Sub, &a_offset, &b_offset)?;
|
||||||
if overflowed {
|
if overflowed {
|
||||||
throw_ub_format!("Pointers were too far apart for {}", intrinsic_name);
|
throw_ub_format!("pointers were too far apart for {}", intrinsic_name);
|
||||||
|
}
|
||||||
|
val.to_machine_isize(self)?
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check that the range between them is dereferenceable ("in-bounds or one past the
|
||||||
|
// end of the same allocation"). This is like the check in ptr_offset_inbounds.
|
||||||
|
let min_ptr = if distance >= 0 { b } else { a };
|
||||||
|
self.check_ptr_access_align(
|
||||||
|
min_ptr,
|
||||||
|
Size::from_bytes(distance.unsigned_abs()),
|
||||||
|
Align::ONE,
|
||||||
|
CheckInAllocMsg::OffsetFromTest,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
if intrinsic_name == sym::ptr_offset_from_unsigned && distance < 0 {
|
||||||
|
throw_ub_format!(
|
||||||
|
"{} called when first pointer has smaller offset than second: {} < {}",
|
||||||
|
intrinsic_name,
|
||||||
|
a_offset,
|
||||||
|
b_offset,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Perform division by size to compute return value.
|
||||||
|
let ret_layout = if intrinsic_name == sym::ptr_offset_from_unsigned {
|
||||||
|
usize_layout
|
||||||
|
} else {
|
||||||
|
isize_layout
|
||||||
|
};
|
||||||
let pointee_layout = self.layout_of(substs.type_at(0))?;
|
let pointee_layout = self.layout_of(substs.type_at(0))?;
|
||||||
// This re-interprets an isize at ret_layout, but we already checked
|
// If ret_layout is unsigned, we checked that so is the distance, so we are good.
|
||||||
// that if ret_layout is usize, then the result must be non-negative.
|
let val = ImmTy::from_int(distance, ret_layout);
|
||||||
let val = ImmTy::from_scalar(val, ret_layout);
|
|
||||||
let size = ImmTy::from_int(pointee_layout.size.bytes(), ret_layout);
|
let size = ImmTy::from_int(pointee_layout.size.bytes(), ret_layout);
|
||||||
self.exact_div(&val, &size, dest)?;
|
self.exact_div(&val, &size, dest)?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sym::transmute => {
|
sym::transmute => {
|
||||||
self.copy_op_transmute(&args[0], dest)?;
|
self.copy_op_transmute(&args[0], dest)?;
|
||||||
@ -575,11 +579,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
// memory between these pointers must be accessible. Note that we do not require the
|
// memory between these pointers must be accessible. Note that we do not require the
|
||||||
// pointers to be properly aligned (unlike a read/write operation).
|
// pointers to be properly aligned (unlike a read/write operation).
|
||||||
let min_ptr = if offset_bytes >= 0 { ptr } else { offset_ptr };
|
let min_ptr = if offset_bytes >= 0 { ptr } else { offset_ptr };
|
||||||
let size = offset_bytes.unsigned_abs();
|
|
||||||
// This call handles checking for integer/null pointers.
|
// This call handles checking for integer/null pointers.
|
||||||
self.check_ptr_access_align(
|
self.check_ptr_access_align(
|
||||||
min_ptr,
|
min_ptr,
|
||||||
Size::from_bytes(size),
|
Size::from_bytes(offset_bytes.unsigned_abs()),
|
||||||
Align::ONE,
|
Align::ONE,
|
||||||
CheckInAllocMsg::PointerArithmeticTest,
|
CheckInAllocMsg::PointerArithmeticTest,
|
||||||
)?;
|
)?;
|
||||||
|
@ -1035,7 +1035,7 @@ fn emit_unstable_in_stable_error(ccx: &ConstCx<'_, '_>, span: Span, gate: Symbol
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
attr_span,
|
attr_span,
|
||||||
"if it is not part of the public API, make this function unstably const",
|
"if it is not part of the public API, make this function unstably const",
|
||||||
concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n').to_owned(),
|
concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n'),
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
)
|
)
|
||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
|
@ -1194,7 +1194,7 @@ pub fn expr_to_spanned_string<'a>(
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
expr.span.shrink_to_lo(),
|
expr.span.shrink_to_lo(),
|
||||||
"consider removing the leading `b`",
|
"consider removing the leading `b`",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
Some((err, true))
|
Some((err, true))
|
||||||
|
@ -945,7 +945,7 @@ pub fn ensure_complete_parse<'a>(
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
semi_span,
|
semi_span,
|
||||||
"you might be missing a semicolon here",
|
"you might be missing a semicolon here",
|
||||||
";".to_owned(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ fn emit_frag_parse_err(
|
|||||||
e.span_suggestion_verbose(
|
e.span_suggestion_verbose(
|
||||||
site_span.shrink_to_hi(),
|
site_span.shrink_to_hi(),
|
||||||
"add `;` to interpret the expansion as a statement",
|
"add `;` to interpret the expansion as a statement",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ fn expand_macro<'cx>(
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
comma_span,
|
comma_span,
|
||||||
"missing comma here",
|
"missing comma here",
|
||||||
", ".to_string(),
|
", ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl MetaVarExpr {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
ident.span,
|
ident.span,
|
||||||
"supported expressions are count, ignore, index and length",
|
"supported expressions are count, ignore, index and length",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
@ -142,7 +142,7 @@ fn parse_ident<'sess>(
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
token.span,
|
token.span,
|
||||||
&format!("try removing `{}`", &token_str),
|
&format!("try removing `{}`", &token_str),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
|
@ -409,8 +409,6 @@ declare_features! (
|
|||||||
(active, if_let_guard, "1.47.0", Some(51114), None),
|
(active, if_let_guard, "1.47.0", Some(51114), None),
|
||||||
/// Allows using imported `main` function
|
/// Allows using imported `main` function
|
||||||
(active, imported_main, "1.53.0", Some(28937), None),
|
(active, imported_main, "1.53.0", Some(28937), None),
|
||||||
/// Allows inferring `'static` outlives requirements (RFC 2093).
|
|
||||||
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
|
|
||||||
/// Allows associated types in inherent impls.
|
/// Allows associated types in inherent impls.
|
||||||
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
|
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
|
||||||
/// Allow anonymous constants from an inline `const` block
|
/// Allow anonymous constants from an inline `const` block
|
||||||
@ -523,7 +521,7 @@ declare_features! (
|
|||||||
(active, type_ascription, "1.6.0", Some(23416), None),
|
(active, type_ascription, "1.6.0", Some(23416), None),
|
||||||
/// Allows creation of instances of a struct by moving fields that have
|
/// Allows creation of instances of a struct by moving fields that have
|
||||||
/// not changed from prior instances of the same struct (RFC #2528)
|
/// not changed from prior instances of the same struct (RFC #2528)
|
||||||
(incomplete, type_changing_struct_update, "1.58.0", Some(86555), None),
|
(active, type_changing_struct_update, "1.58.0", Some(86555), None),
|
||||||
/// Allows unsized fn parameters.
|
/// Allows unsized fn parameters.
|
||||||
(active, unsized_fn_params, "1.49.0", Some(48055), None),
|
(active, unsized_fn_params, "1.49.0", Some(48055), None),
|
||||||
/// Allows unsized rvalues at arguments and parameters.
|
/// Allows unsized rvalues at arguments and parameters.
|
||||||
|
@ -109,6 +109,9 @@ declare_features! (
|
|||||||
/// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
|
/// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
|
||||||
(removed, in_band_lifetimes, "1.23.0", Some(44524), None,
|
(removed, in_band_lifetimes, "1.23.0", Some(44524), None,
|
||||||
Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity")),
|
Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity")),
|
||||||
|
/// Allows inferring `'static` outlives requirements (RFC 2093).
|
||||||
|
(removed, infer_static_outlives_requirements, "1.63.0", Some(54185), None,
|
||||||
|
Some("removed as it caused some confusion and discussion was inactive for years")),
|
||||||
/// Lazily evaluate constants. This allows constants to depend on type parameters.
|
/// Lazily evaluate constants. This allows constants to depend on type parameters.
|
||||||
(removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")),
|
(removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")),
|
||||||
/// Allows using the `#[link_args]` attribute.
|
/// Allows using the `#[link_args]` attribute.
|
||||||
|
@ -670,7 +670,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
source_map.end_point(cause.span),
|
source_map.end_point(cause.span),
|
||||||
"try removing this `?`",
|
"try removing this `?`",
|
||||||
"".to_string(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -726,14 +726,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
"consider removing this semicolon and boxing the expressions",
|
"consider removing this semicolon and boxing the expressions",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
"consider removing this semicolon",
|
"consider removing this semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -776,7 +776,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
"consider removing this semicolon",
|
"consider removing this semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1935,7 +1935,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
exp_span.shrink_to_hi(),
|
exp_span.shrink_to_hi(),
|
||||||
"consider `await`ing on the `Future`",
|
"consider `await`ing on the `Future`",
|
||||||
".await".to_string(),
|
".await",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1945,7 +1945,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"consider `await`ing on the `Future`",
|
"consider `await`ing on the `Future`",
|
||||||
".await".to_string(),
|
".await",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"consider relaxing the implicit `'static` requirement",
|
"consider relaxing the implicit `'static` requirement",
|
||||||
" + '_".to_string(),
|
" + '_",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
new_ty_span,
|
new_ty_span,
|
||||||
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
|
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
|
||||||
new_ty.to_string(),
|
new_ty,
|
||||||
Applicability::Unspecified,
|
Applicability::Unspecified,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ pub fn suggest_new_region_bound(
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
&format!("{} `impl Trait`'s {}", consider, explicit_static),
|
&format!("{} `impl Trait`'s {}", consider, explicit_static),
|
||||||
lifetime_name.clone(),
|
&lifetime_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ pub fn suggest_new_region_bound(
|
|||||||
captures = captures,
|
captures = captures,
|
||||||
explicit = explicit,
|
explicit = explicit,
|
||||||
),
|
),
|
||||||
plus_lt.clone(),
|
&plus_lt,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ pub fn suggest_new_region_bound(
|
|||||||
captures = captures,
|
captures = captures,
|
||||||
explicit = explicit,
|
explicit = explicit,
|
||||||
),
|
),
|
||||||
plus_lt.clone(),
|
&plus_lt,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ pub fn suggest_new_region_bound(
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
lt.span,
|
lt.span,
|
||||||
&format!("{} trait object's {}", consider, explicit_static),
|
&format!("{} trait object's {}", consider, explicit_static),
|
||||||
lifetime_name.clone(),
|
&lifetime_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -535,7 +535,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"consider relaxing the implicit `'static` requirement",
|
"consider relaxing the implicit `'static` requirement",
|
||||||
" + '_".to_string(),
|
" + '_",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
suggested = true;
|
suggested = true;
|
||||||
|
@ -449,7 +449,7 @@ pub fn configure_and_expand(
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
first_span,
|
first_span,
|
||||||
"try using their name instead",
|
"try using their name instead",
|
||||||
"ferris".to_string(),
|
"ferris",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -136,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()),
|
receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()),
|
||||||
"or remove `.into_iter()` to iterate by value",
|
"or remove `.into_iter()` to iterate by value",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else if receiver_ty.is_array() {
|
} else if receiver_ty.is_array() {
|
||||||
|
@ -993,7 +993,7 @@ fn lint_deprecated_attr(
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
attr.span,
|
attr.span,
|
||||||
suggestion.unwrap_or("remove this attribute"),
|
suggestion.unwrap_or("remove this attribute"),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1182,7 +1182,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
no_mangle_attr.span,
|
no_mangle_attr.span,
|
||||||
"remove this attribute",
|
"remove this attribute",
|
||||||
String::new(),
|
"",
|
||||||
// Use of `#[no_mangle]` suggests FFI intent; correct
|
// Use of `#[no_mangle]` suggests FFI intent; correct
|
||||||
// fix may be to monomorphize source by hand
|
// fix may be to monomorphize source by hand
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
@ -1221,7 +1221,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
const_span,
|
const_span,
|
||||||
"try a static value",
|
"try a static value",
|
||||||
"pub static".to_owned(),
|
"pub static",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -1405,7 +1405,7 @@ impl UnreachablePub {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
vis_span,
|
vis_span,
|
||||||
"consider restricting its visibility",
|
"consider restricting its visibility",
|
||||||
"pub(crate)".to_owned(),
|
"pub(crate)",
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
if exportable {
|
if exportable {
|
||||||
@ -1566,7 +1566,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
type_alias_generics.where_clause_span,
|
type_alias_generics.where_clause_span,
|
||||||
"the clause will not be checked when the type alias is used, and should be removed",
|
"the clause will not be checked when the type alias is used, and should be removed",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
if !suggested_changing_assoc_types {
|
if !suggested_changing_assoc_types {
|
||||||
@ -1830,7 +1830,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let replace = "..=".to_owned();
|
let replace = "..=";
|
||||||
if join.edition() >= Edition::Edition2021 {
|
if join.edition() >= Edition::Edition2021 {
|
||||||
let mut err =
|
let mut err =
|
||||||
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
||||||
@ -2113,7 +2113,6 @@ impl ExplicitOutlivesRequirements {
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
bounds: &hir::GenericBounds<'_>,
|
bounds: &hir::GenericBounds<'_>,
|
||||||
inferred_outlives: &[ty::Region<'tcx>],
|
inferred_outlives: &[ty::Region<'tcx>],
|
||||||
infer_static: bool,
|
|
||||||
) -> Vec<(usize, Span)> {
|
) -> Vec<(usize, Span)> {
|
||||||
use rustc_middle::middle::resolve_lifetime::Region;
|
use rustc_middle::middle::resolve_lifetime::Region;
|
||||||
|
|
||||||
@ -2123,9 +2122,6 @@ impl ExplicitOutlivesRequirements {
|
|||||||
.filter_map(|(i, bound)| {
|
.filter_map(|(i, bound)| {
|
||||||
if let hir::GenericBound::Outlives(lifetime) = bound {
|
if let hir::GenericBound::Outlives(lifetime) = bound {
|
||||||
let is_inferred = match tcx.named_region(lifetime.hir_id) {
|
let is_inferred = match tcx.named_region(lifetime.hir_id) {
|
||||||
Some(Region::Static) if infer_static => {
|
|
||||||
inferred_outlives.iter().any(|r| matches!(**r, ty::ReStatic))
|
|
||||||
}
|
|
||||||
Some(Region::EarlyBound(index, ..)) => inferred_outlives.iter().any(|r| {
|
Some(Region::EarlyBound(index, ..)) => inferred_outlives.iter().any(|r| {
|
||||||
if let ty::ReEarlyBound(ebr) = **r { ebr.index == index } else { false }
|
if let ty::ReEarlyBound(ebr) = **r { ebr.index == index } else { false }
|
||||||
}),
|
}),
|
||||||
@ -2201,7 +2197,6 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
|||||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
||||||
use rustc_middle::middle::resolve_lifetime::Region;
|
use rustc_middle::middle::resolve_lifetime::Region;
|
||||||
|
|
||||||
let infer_static = cx.tcx.features().infer_static_outlives_requirements;
|
|
||||||
let def_id = item.def_id;
|
let def_id = item.def_id;
|
||||||
if let hir::ItemKind::Struct(_, ref hir_generics)
|
if let hir::ItemKind::Struct(_, ref hir_generics)
|
||||||
| hir::ItemKind::Enum(_, ref hir_generics)
|
| hir::ItemKind::Enum(_, ref hir_generics)
|
||||||
@ -2262,12 +2257,8 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bound_spans = self.collect_outlives_bound_spans(
|
let bound_spans =
|
||||||
cx.tcx,
|
self.collect_outlives_bound_spans(cx.tcx, bounds, &relevant_lifetimes);
|
||||||
bounds,
|
|
||||||
&relevant_lifetimes,
|
|
||||||
infer_static,
|
|
||||||
);
|
|
||||||
bound_count += bound_spans.len();
|
bound_count += bound_spans.len();
|
||||||
|
|
||||||
let drop_predicate = bound_spans.len() == bounds.len();
|
let drop_predicate = bound_spans.len() == bounds.len();
|
||||||
|
@ -718,7 +718,7 @@ pub trait LintContext: Sized {
|
|||||||
the macro must produce the documentation as part of its expansion");
|
the macro must produce the documentation as part of its expansion");
|
||||||
}
|
}
|
||||||
BuiltinLintDiagnostics::PatternsInFnsWithoutBody(span, ident) => {
|
BuiltinLintDiagnostics::PatternsInFnsWithoutBody(span, ident) => {
|
||||||
db.span_suggestion(span, "remove `mut` from the parameter", ident.to_string(), Applicability::MachineApplicable);
|
db.span_suggestion(span, "remove `mut` from the parameter", ident, Applicability::MachineApplicable);
|
||||||
}
|
}
|
||||||
BuiltinLintDiagnostics::MissingAbi(span, default_abi) => {
|
BuiltinLintDiagnostics::MissingAbi(span, default_abi) => {
|
||||||
db.span_label(span, "ABI should be specified here");
|
db.span_label(span, "ABI should be specified here");
|
||||||
@ -778,7 +778,7 @@ pub trait LintContext: Sized {
|
|||||||
|
|
||||||
// Suggest the most probable if we found one
|
// Suggest the most probable if we found one
|
||||||
if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
|
if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
|
||||||
db.span_suggestion(name_span, "did you mean", format!("{best_match}"), Applicability::MaybeIncorrect);
|
db.span_suggestion(name_span, "did you mean", best_match, Applicability::MaybeIncorrect);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BuiltinLintDiagnostics::UnexpectedCfg((name, name_span), Some((value, value_span))) => {
|
BuiltinLintDiagnostics::UnexpectedCfg((name, name_span), Some((value, value_span))) => {
|
||||||
@ -805,7 +805,7 @@ pub trait LintContext: Sized {
|
|||||||
} else {
|
} else {
|
||||||
db.note(&format!("no expected value for `{name}`"));
|
db.note(&format!("no expected value for `{name}`"));
|
||||||
if name != sym::feature {
|
if name != sym::feature {
|
||||||
db.span_suggestion(name_span.shrink_to_hi().to(value_span), "remove the value", String::new(), Applicability::MaybeIncorrect);
|
db.span_suggestion(name_span.shrink_to_hi().to(value_span), "remove the value", "", Applicability::MaybeIncorrect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -852,7 +852,7 @@ pub trait LintContext: Sized {
|
|||||||
db.span_suggestion(
|
db.span_suggestion(
|
||||||
deletion_span,
|
deletion_span,
|
||||||
"elide the unused lifetime",
|
"elide the unused lifetime",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"try using `ty::<kind>` directly",
|
"try using `ty::<kind>` directly",
|
||||||
"ty".to_string(),
|
"ty",
|
||||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -170,7 +170,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
path.span,
|
path.span,
|
||||||
"try using `ty::<kind>` directly",
|
"try using `ty::<kind>` directly",
|
||||||
"ty".to_string(),
|
"ty",
|
||||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -188,7 +188,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
path.span,
|
path.span,
|
||||||
"try using `ty::<kind>` directly",
|
"try using `ty::<kind>` directly",
|
||||||
"ty".to_string(),
|
"ty",
|
||||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -208,7 +208,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
path.span,
|
path.span,
|
||||||
"try using `ty::<kind>` directly",
|
"try using `ty::<kind>` directly",
|
||||||
"ty".to_string(),
|
"ty",
|
||||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -443,7 +443,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"change it to",
|
"change it to",
|
||||||
new_lint_name.to_string(),
|
new_lint_name,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -516,7 +516,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"use the new name",
|
"use the new name",
|
||||||
new_name.to_string(),
|
new_name,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||||||
db.span_suggestion(
|
db.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"did you mean",
|
"did you mean",
|
||||||
suggestion.to_string(),
|
suggestion,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,7 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo
|
|||||||
} else {
|
} else {
|
||||||
("unnecessary trailing semicolon", "remove this semicolon")
|
("unnecessary trailing semicolon", "remove this semicolon")
|
||||||
};
|
};
|
||||||
lint.build(msg)
|
lint.build(msg).span_suggestion(span, rem, "", Applicability::MaybeIncorrect).emit();
|
||||||
.span_suggestion(span, rem, String::new(), Applicability::MaybeIncorrect)
|
|
||||||
.emit();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||||||
lint.span_suggestion_verbose(
|
lint.span_suggestion_verbose(
|
||||||
expr.span.shrink_to_lo(),
|
expr.span.shrink_to_lo(),
|
||||||
"use `let _ = ...` to ignore the resulting value",
|
"use `let _ = ...` to ignore the resulting value",
|
||||||
"let _ = ".to_string(),
|
"let _ = ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
lint.emit();
|
lint.emit();
|
||||||
|
@ -153,7 +153,7 @@ pub fn deprecation_suggestion(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!("replace the use of the deprecated {}", kind),
|
&format!("replace the use of the deprecated {}", kind),
|
||||||
suggestion.to_string(),
|
suggestion,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -933,7 +933,7 @@ impl ObjectSafetyViolation {
|
|||||||
trait objects",
|
trait objects",
|
||||||
name
|
name
|
||||||
),
|
),
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -957,7 +957,7 @@ impl ObjectSafetyViolation {
|
|||||||
"consider changing method `{}`'s `self` parameter to be `&self`",
|
"consider changing method `{}`'s `self` parameter to be `&self`",
|
||||||
name
|
name
|
||||||
),
|
),
|
||||||
"&Self".to_string(),
|
"&Self",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -579,10 +579,15 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
|
|||||||
debug!("{}.super_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
|
debug!("{}.super_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
|
|
||||||
// FIXME(oli-obk): once const generics can have generic types, this assertion
|
let a_ty;
|
||||||
// will likely get triggered. Move to `normalize_erasing_regions` at that point.
|
let b_ty;
|
||||||
let a_ty = tcx.erase_regions(a.ty());
|
if relation.tcx().features().adt_const_params {
|
||||||
let b_ty = tcx.erase_regions(b.ty());
|
a_ty = tcx.normalize_erasing_regions(relation.param_env(), a.ty());
|
||||||
|
b_ty = tcx.normalize_erasing_regions(relation.param_env(), b.ty());
|
||||||
|
} else {
|
||||||
|
a_ty = tcx.erase_regions(a.ty());
|
||||||
|
b_ty = tcx.erase_regions(b.ty());
|
||||||
|
}
|
||||||
if a_ty != b_ty {
|
if a_ty != b_ty {
|
||||||
relation.tcx().sess.delay_span_bug(
|
relation.tcx().sess.delay_span_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
|
@ -105,7 +105,7 @@ pub(crate) fn emit_unescape_error(
|
|||||||
handler.span_suggestion(
|
handler.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"consider removing the non-printing characters",
|
"consider removing the non-printing characters",
|
||||||
ch.to_string(),
|
ch,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ pub(crate) fn emit_unescape_error(
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
char_span,
|
char_span,
|
||||||
"escape the character",
|
"escape the character",
|
||||||
c.escape_default().to_string(),
|
c.escape_default(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -157,7 +157,7 @@ pub(crate) fn emit_unescape_error(
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"escape the character",
|
"escape the character",
|
||||||
"\\r".to_string(),
|
"\\r",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -299,7 +299,7 @@ pub(crate) fn emit_unescape_error(
|
|||||||
.span_suggestion_verbose(
|
.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"terminate the unicode escape",
|
"terminate the unicode escape",
|
||||||
"}".to_string(),
|
"}",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -369,7 +369,7 @@ pub(super) fn check_for_substitution<'a>(
|
|||||||
"Unicode character '{}' ({}) looks like '{}' ({}), but it is not",
|
"Unicode character '{}' ({}) looks like '{}' ({}), but it is not",
|
||||||
ch, u_name, ascii_char, ascii_name
|
ch, u_name, ascii_char, ascii_name
|
||||||
);
|
);
|
||||||
err.span_suggestion(span, &msg, ascii_char.to_string(), Applicability::MaybeIncorrect);
|
err.span_suggestion(span, &msg, ascii_char, Applicability::MaybeIncorrect);
|
||||||
}
|
}
|
||||||
token.clone()
|
token.clone()
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ fn error_malformed_cfg_attr_missing(span: Span, parse_sess: &ParseSess) {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"missing condition and attribute",
|
"missing condition and attribute",
|
||||||
CFG_ATTR_GRAMMAR_HELP.to_string(),
|
CFG_ATTR_GRAMMAR_HELP,
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
)
|
)
|
||||||
.note(CFG_ATTR_NOTE_REF)
|
.note(CFG_ATTR_NOTE_REF)
|
||||||
|
@ -78,7 +78,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
replacement_span,
|
replacement_span,
|
||||||
"you might have meant to write a regular comment",
|
"you might have meant to write a regular comment",
|
||||||
String::new(),
|
"",
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -200,12 +200,11 @@ impl<'a> Parser<'a> {
|
|||||||
item.kind.descr(),
|
item.kind.descr(),
|
||||||
attr_name
|
attr_name
|
||||||
),
|
),
|
||||||
(match attr_type {
|
match attr_type {
|
||||||
OuterAttributeType::Attribute => "",
|
OuterAttributeType::Attribute => "",
|
||||||
OuterAttributeType::DocBlockComment => "*",
|
OuterAttributeType::DocBlockComment => "*",
|
||||||
OuterAttributeType::DocComment => "/",
|
OuterAttributeType::DocComment => "/",
|
||||||
})
|
},
|
||||||
.to_string(),
|
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return None;
|
return None;
|
||||||
|
@ -431,7 +431,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
ident.span.shrink_to_lo(),
|
ident.span.shrink_to_lo(),
|
||||||
&format!("escape `{}` to use it as an identifier", ident.name),
|
&format!("escape `{}` to use it as an identifier", ident.name),
|
||||||
"r#".to_owned(),
|
"r#",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"remove this comma",
|
"remove this comma",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -518,7 +518,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.bump();
|
self.bump();
|
||||||
let sp = self.prev_token.span;
|
let sp = self.prev_token.span;
|
||||||
self.struct_span_err(sp, &msg)
|
self.struct_span_err(sp, &msg)
|
||||||
.span_suggestion_short(sp, "change this to `;`", ";".to_string(), appl)
|
.span_suggestion_short(sp, "change this to `;`", ";", appl)
|
||||||
.emit();
|
.emit();
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
} else if self.look_ahead(0, |t| {
|
} else if self.look_ahead(0, |t| {
|
||||||
@ -537,7 +537,7 @@ impl<'a> Parser<'a> {
|
|||||||
let sp = self.prev_token.span.shrink_to_hi();
|
let sp = self.prev_token.span.shrink_to_hi();
|
||||||
self.struct_span_err(sp, &msg)
|
self.struct_span_err(sp, &msg)
|
||||||
.span_label(self.token.span, "unexpected token")
|
.span_label(self.token.span, "unexpected token")
|
||||||
.span_suggestion_short(sp, "add `;` here", ";".to_string(), appl)
|
.span_suggestion_short(sp, "add `;` here", ";", appl)
|
||||||
.emit();
|
.emit();
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
@ -664,7 +664,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!("remove the extra `#`{}", pluralize!(count)),
|
&format!("remove the extra `#`{}", pluralize!(count)),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.span_label(
|
err.span_label(
|
||||||
@ -761,7 +761,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"maybe write a path separator here",
|
"maybe write a path separator here",
|
||||||
"::".to_string(),
|
"::",
|
||||||
if allow_unstable {
|
if allow_unstable {
|
||||||
Applicability::MaybeIncorrect
|
Applicability::MaybeIncorrect
|
||||||
} else {
|
} else {
|
||||||
@ -773,7 +773,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"try using a semicolon",
|
"try using a semicolon",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else if allow_unstable {
|
} else if allow_unstable {
|
||||||
@ -917,7 +917,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!("remove extra angle bracket{}", pluralize!(total_num_of_gt)),
|
&format!("remove extra angle bracket{}", pluralize!(total_num_of_gt)),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -999,7 +999,7 @@ impl<'a> Parser<'a> {
|
|||||||
e.span_suggestion_verbose(
|
e.span_suggestion_verbose(
|
||||||
binop.span.shrink_to_lo(),
|
binop.span.shrink_to_lo(),
|
||||||
TURBOFISH_SUGGESTION_STR,
|
TURBOFISH_SUGGESTION_STR,
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1158,7 +1158,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
op.span.shrink_to_lo(),
|
op.span.shrink_to_lo(),
|
||||||
TURBOFISH_SUGGESTION_STR,
|
TURBOFISH_SUGGESTION_STR,
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -1701,7 +1701,7 @@ impl<'a> Parser<'a> {
|
|||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
err.span_suggestion(lo.shrink_to_lo(), &format!("{prefix}you can still access the deprecated `try!()` macro using the \"raw identifier\" syntax"), "r#".to_string(), Applicability::MachineApplicable);
|
err.span_suggestion(lo.shrink_to_lo(), &format!("{prefix}you can still access the deprecated `try!()` macro using the \"raw identifier\" syntax"), "r#", Applicability::MachineApplicable);
|
||||||
err.emit();
|
err.emit();
|
||||||
Ok(self.mk_expr_err(lo.to(hi)))
|
Ok(self.mk_expr_err(lo.to(hi)))
|
||||||
} else {
|
} else {
|
||||||
@ -1997,7 +1997,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"declare the type after the parameter binding",
|
"declare the type after the parameter binding",
|
||||||
String::from("<identifier>: <type>"),
|
"<identifier>: <type>",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
return Some(ident);
|
return Some(ident);
|
||||||
@ -2102,7 +2102,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
pat.span,
|
pat.span,
|
||||||
"give this argument a name or use an underscore to ignore it",
|
"give this argument a name or use an underscore to ignore it",
|
||||||
"_".to_owned(),
|
"_",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -2336,7 +2336,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
start.until(self.token.span),
|
start.until(self.token.span),
|
||||||
"the `const` keyword is only needed in the definition of the type",
|
"the `const` keyword is only needed in the definition of the type",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -2394,7 +2394,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
snapshot.token.span,
|
snapshot.token.span,
|
||||||
"if you meant to use an associated type binding, replace `==` with `=`",
|
"if you meant to use an associated type binding, replace `==` with `=`",
|
||||||
"=".to_string(),
|
"=",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
let value = self.mk_expr_err(start.to(expr.span));
|
let value = self.mk_expr_err(start.to(expr.span));
|
||||||
@ -2408,7 +2408,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
snapshot.token.span,
|
snapshot.token.span,
|
||||||
"write a path separator here",
|
"write a path separator here",
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -2461,7 +2461,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
move_async_span,
|
move_async_span,
|
||||||
"try switching the order",
|
"try switching the order",
|
||||||
"async move".to_owned(),
|
"async move",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err
|
err
|
||||||
@ -2566,7 +2566,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"maybe write a path separator here",
|
"maybe write a path separator here",
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -2596,7 +2596,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.tool_only_span_suggestion(
|
err.tool_only_span_suggestion(
|
||||||
label.ident.span.until(self.token.span),
|
label.ident.span.until(self.token.span),
|
||||||
"remove this block label",
|
"remove this block label",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -2669,7 +2669,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
between_span,
|
between_span,
|
||||||
"use single colon",
|
"use single colon",
|
||||||
": ".to_owned(),
|
": ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
|
@ -230,7 +230,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
&format!("`{s}=` is not a valid comparison operator, use `{s}`", s = sugg),
|
&format!("`{s}=` is not a valid comparison operator, use `{s}`", s = sugg),
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -247,7 +247,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
"`<>` is not a valid comparison operator, use `!=`",
|
"`<>` is not a valid comparison operator, use `!=`",
|
||||||
"!=".to_string(),
|
"!=",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -459,7 +459,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
&format!("use `{good}` to perform logical {english}"),
|
&format!("use `{good}` to perform logical {english}"),
|
||||||
good.to_string(),
|
good,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note("unlike in e.g., python and PHP, `&&` and `||` are used for logical operators")
|
.note("unlike in e.g., python and PHP, `&&` and `||` are used for logical operators")
|
||||||
@ -584,7 +584,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
lo,
|
lo,
|
||||||
"try removing the `+`",
|
"try removing the `+`",
|
||||||
"".to_string(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -634,7 +634,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
lo,
|
lo,
|
||||||
"use `!` to perform bitwise not",
|
"use `!` to perform bitwise not",
|
||||||
"!".to_owned(),
|
"!",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -673,7 +673,7 @@ impl<'a> Parser<'a> {
|
|||||||
// trailing whitespace after the `!` in our suggestion
|
// trailing whitespace after the `!` in our suggestion
|
||||||
self.sess.source_map().span_until_non_whitespace(lo.to(not_token.span)),
|
self.sess.source_map().span_until_non_whitespace(lo.to(not_token.span)),
|
||||||
"use `!` to perform logical negation",
|
"use `!` to perform logical negation",
|
||||||
"!".to_owned(),
|
"!",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -744,7 +744,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
label.ident.span,
|
label.ident.span,
|
||||||
"use the correct loop label format",
|
"use the correct loop label format",
|
||||||
label.ident.to_string(),
|
label.ident,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -885,7 +885,7 @@ impl<'a> Parser<'a> {
|
|||||||
"{}remove the type ascription",
|
"{}remove the type ascription",
|
||||||
if is_nightly { "alternatively, " } else { "" }
|
if is_nightly { "alternatively, " } else { "" }
|
||||||
),
|
),
|
||||||
String::new(),
|
"",
|
||||||
if is_nightly {
|
if is_nightly {
|
||||||
Applicability::MaybeIncorrect
|
Applicability::MaybeIncorrect
|
||||||
} else {
|
} else {
|
||||||
@ -929,7 +929,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
lt_span,
|
lt_span,
|
||||||
"remove the lifetime annotation",
|
"remove the lifetime annotation",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1626,7 +1626,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
lo.shrink_to_hi(),
|
lo.shrink_to_hi(),
|
||||||
"add `:` after the label",
|
"add `:` after the label",
|
||||||
": ".to_string(),
|
": ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")
|
.note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")
|
||||||
@ -1645,7 +1645,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span_dc,
|
span_dc,
|
||||||
"replace with the new syntax",
|
"replace with the new syntax",
|
||||||
"try".to_string(),
|
"try",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note("following RFC #2388, the new non-placeholder syntax is `try`")
|
.note("following RFC #2388, the new non-placeholder syntax is `try`")
|
||||||
@ -2088,7 +2088,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span_for,
|
span_for,
|
||||||
"remove the parameters",
|
"remove the parameters",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -2352,7 +2352,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
cond.span.shrink_to_lo(),
|
cond.span.shrink_to_lo(),
|
||||||
"add an `if` if this is the condition of a chained `else if` statement",
|
"add an `if` if this is the condition of a chained `else if` statement",
|
||||||
"if ".to_string(),
|
"if ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -2388,12 +2388,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.struct_span_err(last, "outer attributes are not allowed on `if` and `else` branches")
|
self.struct_span_err(last, "outer attributes are not allowed on `if` and `else` branches")
|
||||||
.span_label(branch_span, "the attributes are attached to this branch")
|
.span_label(branch_span, "the attributes are attached to this branch")
|
||||||
.span_label(ctx_span, format!("the branch belongs to this `{ctx}`"))
|
.span_label(ctx_span, format!("the branch belongs to this `{ctx}`"))
|
||||||
.span_suggestion(
|
.span_suggestion(span, "remove the attributes", "", Applicability::MachineApplicable)
|
||||||
span,
|
|
||||||
"remove the attributes",
|
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2502,7 +2497,7 @@ impl<'a> Parser<'a> {
|
|||||||
e.span_suggestion_short(
|
e.span_suggestion_short(
|
||||||
match_span,
|
match_span,
|
||||||
"try removing this `match`",
|
"try removing this `match`",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect, // speculative
|
Applicability::MaybeIncorrect, // speculative
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2578,7 +2573,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
semi_sp,
|
semi_sp,
|
||||||
"use a comma to end a `match` arm expression",
|
"use a comma to end a `match` arm expression",
|
||||||
",".to_string(),
|
",",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2679,7 +2674,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
this.token.span,
|
this.token.span,
|
||||||
"try using a fat arrow here",
|
"try using a fat arrow here",
|
||||||
"=>".to_string(),
|
"=>",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -2739,7 +2734,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
arm_start_span.shrink_to_hi(),
|
arm_start_span.shrink_to_hi(),
|
||||||
"missing a comma here to end this `match` arm",
|
"missing a comma here to end this `match` arm",
|
||||||
",".to_owned(),
|
",",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
@ -2768,7 +2763,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
hi.shrink_to_hi(),
|
hi.shrink_to_hi(),
|
||||||
"missing a comma here to end this `match` arm",
|
"missing a comma here to end this `match` arm",
|
||||||
",".to_owned(),
|
",",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -3049,7 +3044,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"remove this comma",
|
"remove this comma",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note("the base struct must always be the last field")
|
.note("the base struct must always be the last field")
|
||||||
@ -3103,7 +3098,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
field_name.span.shrink_to_hi().to(self.token.span),
|
field_name.span.shrink_to_hi().to(self.token.span),
|
||||||
"replace equals symbol with a colon",
|
"replace equals symbol with a colon",
|
||||||
":".to_string(),
|
":",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -3114,13 +3109,13 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"use `..` for an exclusive range",
|
"use `..` for an exclusive range",
|
||||||
"..".to_owned(),
|
"..",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"or `..=` for an inclusive range",
|
"or `..=` for an inclusive range",
|
||||||
"..=".to_owned(),
|
"..=",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -3132,7 +3127,7 @@ impl<'a> Parser<'a> {
|
|||||||
span,
|
span,
|
||||||
"if you meant to write a comparison against a negative value, add a \
|
"if you meant to write a comparison against a negative value, add a \
|
||||||
space in between `<` and `-`",
|
space in between `<` and `-`",
|
||||||
"< -".to_string(),
|
"< -",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -271,7 +271,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
prev_token.shrink_to_hi().to(self.prev_token.span),
|
prev_token.shrink_to_hi().to(self.prev_token.span),
|
||||||
"consider joining the two `where` clauses into one",
|
"consider joining the two `where` clauses into one",
|
||||||
",".to_owned(),
|
",",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -298,7 +298,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
span,
|
span,
|
||||||
"items are imported using the `use` keyword",
|
"items are imported using the `use` keyword",
|
||||||
"use".to_owned(),
|
"use",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -458,7 +458,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
path.span,
|
path.span,
|
||||||
"perhaps you meant to define a macro",
|
"perhaps you meant to define a macro",
|
||||||
"macro_rules".to_string(),
|
"macro_rules",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"consider removing this semicolon",
|
"consider removing this semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -606,7 +606,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
missing_for_span,
|
missing_for_span,
|
||||||
"add `for` here",
|
"add `for` here",
|
||||||
" for ".to_string(),
|
" for ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1082,7 +1082,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span.with_hi(ident.span.lo()),
|
span.with_hi(ident.span.lo()),
|
||||||
"try using a static value",
|
"try using a static value",
|
||||||
"static ".to_string(),
|
"static ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")
|
.note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")
|
||||||
@ -1121,7 +1121,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
const_span,
|
const_span,
|
||||||
"you might want to declare a static instead",
|
"you might want to declare a static instead",
|
||||||
"static".to_owned(),
|
"static",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1555,7 +1555,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"field names and their types are separated with `:`",
|
"field names and their types are separated with `:`",
|
||||||
":".to_string(),
|
":",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -1582,7 +1582,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_verbose(
|
.span_suggestion_verbose(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"write a path separator here",
|
"write a path separator here",
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1595,7 +1595,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"remove this unsupported default value",
|
"remove this unsupported default value",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1691,7 +1691,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
macro_rules_span,
|
macro_rules_span,
|
||||||
"add a `!`",
|
"add a `!`",
|
||||||
"macro_rules!".to_owned(),
|
"macro_rules!",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1720,12 +1720,7 @@ impl<'a> Parser<'a> {
|
|||||||
// Handle macro_rules! foo!
|
// Handle macro_rules! foo!
|
||||||
let span = self.prev_token.span;
|
let span = self.prev_token.span;
|
||||||
self.struct_span_err(span, "macro names aren't followed by a `!`")
|
self.struct_span_err(span, "macro names aren't followed by a `!`")
|
||||||
.span_suggestion(
|
.span_suggestion(span, "remove the `!`", "", Applicability::MachineApplicable)
|
||||||
span,
|
|
||||||
"remove the `!`",
|
|
||||||
"".to_owned(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1751,7 +1746,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
vis.span,
|
vis.span,
|
||||||
"try exporting the macro",
|
"try exporting the macro",
|
||||||
"#[macro_export]".to_owned(),
|
"#[macro_export]",
|
||||||
Applicability::MaybeIncorrect, // speculative
|
Applicability::MaybeIncorrect, // speculative
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1760,7 +1755,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
vis.span,
|
vis.span,
|
||||||
"remove the visibility",
|
"remove the visibility",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.help(&format!("try adjusting the macro to put `{vstr}` inside the invocation"))
|
.help(&format!("try adjusting the macro to put `{vstr}` inside the invocation"))
|
||||||
@ -1794,14 +1789,14 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"change the delimiters to curly braces",
|
"change the delimiters to curly braces",
|
||||||
" { /* items */ }".to_string(),
|
" { /* items */ }",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"add a semicolon",
|
"add a semicolon",
|
||||||
';'.to_string(),
|
';',
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -1826,7 +1821,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
item.unwrap().span,
|
item.unwrap().span,
|
||||||
&format!("consider creating a new `{kw_str}` definition instead of nesting"),
|
&format!("consider creating a new `{kw_str}` definition instead of nesting"),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -2086,7 +2081,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
self.token.uninterpolated_span(),
|
self.token.uninterpolated_span(),
|
||||||
&format!("`{original_kw}` already used earlier, remove this one"),
|
&format!("`{original_kw}` already used earlier, remove this one"),
|
||||||
"".to_string(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.span_note(original_sp, &format!("`{original_kw}` first seen here"));
|
.span_note(original_sp, &format!("`{original_kw}` first seen here"));
|
||||||
@ -2134,7 +2129,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
current_vis.span,
|
current_vis.span,
|
||||||
"there is already a visibility modifier, remove one",
|
"there is already a visibility modifier, remove one",
|
||||||
"".to_string(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.span_note(orig_vis.span, "explicit visibility first seen here");
|
.span_note(orig_vis.span, "explicit visibility first seen here");
|
||||||
|
@ -1350,7 +1350,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
lit.span,
|
lit.span,
|
||||||
"specify the ABI with a string literal",
|
"specify the ABI with a string literal",
|
||||||
"\"C\"".to_string(),
|
"\"C\"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -218,12 +218,7 @@ impl<'a> Parser<'a> {
|
|||||||
if let token::OrOr = self.token.kind {
|
if let token::OrOr = self.token.kind {
|
||||||
let span = self.token.span;
|
let span = self.token.span;
|
||||||
let mut err = self.struct_span_err(span, "unexpected `||` before function parameter");
|
let mut err = self.struct_span_err(span, "unexpected `||` before function parameter");
|
||||||
err.span_suggestion(
|
err.span_suggestion(span, "remove the `||`", "", Applicability::MachineApplicable);
|
||||||
span,
|
|
||||||
"remove the `||`",
|
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
err.note("alternatives in or-patterns are separated with `|`, not `||`");
|
err.note("alternatives in or-patterns are separated with `|`, not `||`");
|
||||||
err.emit();
|
err.emit();
|
||||||
self.bump();
|
self.bump();
|
||||||
@ -287,7 +282,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"use a single `|` to separate multiple alternative patterns",
|
"use a single `|` to separate multiple alternative patterns",
|
||||||
"|".to_owned(),
|
"|",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
if let Some(lo) = lo {
|
if let Some(lo) = lo {
|
||||||
@ -303,7 +298,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!("remove the `{}`", pprust::token_to_string(&self.token)),
|
&format!("remove the `{}`", pprust::token_to_string(&self.token)),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
if let Some(lo) = lo {
|
if let Some(lo) = lo {
|
||||||
@ -433,7 +428,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
lo,
|
lo,
|
||||||
"for a rest pattern, use `..` instead of `...`",
|
"for a rest pattern, use `..` instead of `...`",
|
||||||
"..".to_owned(),
|
"..",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -537,12 +532,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
let span = self.prev_token.span;
|
let span = self.prev_token.span;
|
||||||
self.struct_span_err(span, &format!("unexpected lifetime `{}` in pattern", name))
|
self.struct_span_err(span, &format!("unexpected lifetime `{}` in pattern", name))
|
||||||
.span_suggestion(
|
.span_suggestion(span, "remove the lifetime", "", Applicability::MachineApplicable)
|
||||||
span,
|
|
||||||
"remove the lifetime",
|
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -665,7 +655,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"remove the additional `mut`s",
|
"remove the additional `mut`s",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -759,24 +749,14 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
fn error_inclusive_range_with_extra_equals(&self, span: Span) {
|
fn error_inclusive_range_with_extra_equals(&self, span: Span) {
|
||||||
self.struct_span_err(span, "unexpected `=` after inclusive range")
|
self.struct_span_err(span, "unexpected `=` after inclusive range")
|
||||||
.span_suggestion_short(
|
.span_suggestion_short(span, "use `..=` instead", "..=", Applicability::MaybeIncorrect)
|
||||||
span,
|
|
||||||
"use `..=` instead",
|
|
||||||
"..=".to_string(),
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
)
|
|
||||||
.note("inclusive ranges end with a single equals sign (`..=`)")
|
.note("inclusive ranges end with a single equals sign (`..=`)")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_inclusive_range_with_no_end(&self, span: Span) {
|
fn error_inclusive_range_with_no_end(&self, span: Span) {
|
||||||
struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end")
|
struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end")
|
||||||
.span_suggestion_short(
|
.span_suggestion_short(span, "use `..` instead", "..", Applicability::MachineApplicable)
|
||||||
span,
|
|
||||||
"use `..` instead",
|
|
||||||
"..".to_string(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
|
.note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
@ -794,7 +774,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
re.span,
|
re.span,
|
||||||
"use `..=` instead",
|
"use `..=` instead",
|
||||||
"..=".to_string(),
|
"..=",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1035,7 +1015,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
"remove this comma",
|
"remove this comma",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1107,7 +1087,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"to omit remaining fields, use one fewer `.`",
|
"to omit remaining fields, use one fewer `.`",
|
||||||
"..".to_owned(),
|
"..",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -112,7 +112,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"use double colon",
|
"use double colon",
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -283,7 +283,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
arg.span().shrink_to_hi(),
|
arg.span().shrink_to_hi(),
|
||||||
"you might have meant to end the type parameters here",
|
"you might have meant to end the type parameters here",
|
||||||
">".to_string(),
|
">",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ impl<'a> Parser<'a> {
|
|||||||
"remove extra angle bracket{}",
|
"remove extra angle bracket{}",
|
||||||
pluralize!(snapshot.unmatched_angle_bracket_count)
|
pluralize!(snapshot.unmatched_angle_bracket_count)
|
||||||
),
|
),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -489,7 +489,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
self.prev_token.span.until(self.token.span),
|
self.prev_token.span.until(self.token.span),
|
||||||
"use a comma to separate type parameters",
|
"use a comma to separate type parameters",
|
||||||
", ".to_string(),
|
", ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -592,13 +592,13 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
self.sess.source_map().next_point(eq).to(before_next),
|
self.sess.source_map().next_point(eq).to(before_next),
|
||||||
"to constrain the associated type, add a type after `=`",
|
"to constrain the associated type, add a type after `=`",
|
||||||
" TheType".to_string(),
|
" TheType",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
eq.to(before_next),
|
eq.to(before_next),
|
||||||
&format!("remove the `=` if `{}` is a type", ident),
|
&format!("remove the `=` if `{}` is a type", ident),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -209,7 +209,7 @@ impl<'a> Parser<'a> {
|
|||||||
) -> PResult<'a, Stmt> {
|
) -> PResult<'a, Stmt> {
|
||||||
let stmt = self.recover_local_after_let(lo, attrs)?;
|
let stmt = self.recover_local_after_let(lo, attrs)?;
|
||||||
self.struct_span_err(lo, "invalid variable declaration")
|
self.struct_span_err(lo, "invalid variable declaration")
|
||||||
.span_suggestion(lo, msg, sugg.to_string(), Applicability::MachineApplicable)
|
.span_suggestion(lo, msg, sugg, Applicability::MachineApplicable)
|
||||||
.emit();
|
.emit();
|
||||||
Ok(stmt)
|
Ok(stmt)
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
colon_sp,
|
colon_sp,
|
||||||
"use `=` if you meant to assign",
|
"use `=` if you meant to assign",
|
||||||
" =".to_string(),
|
" =",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -391,7 +391,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"initialize the variable",
|
"initialize the variable",
|
||||||
"=".to_string(),
|
"=",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.help("if you meant to overwrite, remove the `let` binding")
|
.help("if you meant to overwrite, remove the `let` binding")
|
||||||
|
@ -216,7 +216,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"use `->` instead",
|
"use `->` instead",
|
||||||
"->".to_string(),
|
"->",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -479,7 +479,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"place `mut` before `dyn`",
|
"place `mut` before `dyn`",
|
||||||
"&mut dyn".to_string(),
|
"&mut dyn",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -548,7 +548,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
qual_span,
|
qual_span,
|
||||||
&format!("remove the `{}` qualifier", qual),
|
&format!("remove the `{}` qualifier", qual),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -648,7 +648,7 @@ impl<'a> Parser<'a> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
self.token.span,
|
self.token.span,
|
||||||
"remove this keyword",
|
"remove this keyword",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -918,7 +918,7 @@ impl CheckAttrVisitor<'_> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
replacement_span,
|
replacement_span,
|
||||||
"remove this attribute",
|
"remove this attribute",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -1158,7 +1158,7 @@ impl CheckAttrVisitor<'_> {
|
|||||||
diag.span_suggestion_short(
|
diag.span_suggestion_short(
|
||||||
i_meta.span,
|
i_meta.span,
|
||||||
"use `notable_trait` instead",
|
"use `notable_trait` instead",
|
||||||
String::from("notable_trait"),
|
"notable_trait",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
diag.note("`doc(spotlight)` is now a no-op");
|
diag.note("`doc(spotlight)` is now a no-op");
|
||||||
@ -1720,7 +1720,7 @@ impl CheckAttrVisitor<'_> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
attr.span,
|
attr.span,
|
||||||
"remove this attribute",
|
"remove this attribute",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -2259,7 +2259,7 @@ impl CheckAttrVisitor<'_> {
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
attr.span,
|
attr.span,
|
||||||
"remove this attribute",
|
"remove this attribute",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note(¬e)
|
.note(¬e)
|
||||||
@ -2487,7 +2487,7 @@ fn check_duplicates(
|
|||||||
db.span_note(other, "attribute also specified here").span_suggestion(
|
db.span_note(other, "attribute also specified here").span_suggestion(
|
||||||
this,
|
this,
|
||||||
"remove this attribute",
|
"remove this attribute",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
if matches!(duplicates, FutureWarnFollowing | FutureWarnPreceding) {
|
if matches!(duplicates, FutureWarnFollowing | FutureWarnPreceding) {
|
||||||
@ -2522,7 +2522,7 @@ fn check_duplicates(
|
|||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
this,
|
this,
|
||||||
"remove this attribute",
|
"remove this attribute",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -166,7 +166,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
|||||||
break_expr.span,
|
break_expr.span,
|
||||||
"alternatively, you might have meant to use the \
|
"alternatively, you might have meant to use the \
|
||||||
available loop label",
|
available loop label",
|
||||||
label.ident.to_string(),
|
label.ident,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> {
|
|||||||
last_span,
|
last_span,
|
||||||
"consider specifying that the asm block is responsible \
|
"consider specifying that the asm block is responsible \
|
||||||
for returning from the function",
|
for returning from the function",
|
||||||
String::from(", options(noreturn)"),
|
", options(noreturn)",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -125,7 +125,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
*span,
|
*span,
|
||||||
"remove the unnecessary deprecation attribute",
|
"remove the unnecessary deprecation attribute",
|
||||||
String::new(),
|
"",
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -271,7 +271,7 @@ impl<'a> Resolver<'a> {
|
|||||||
err.tool_only_span_suggestion(
|
err.tool_only_span_suggestion(
|
||||||
import.use_span_with_attributes,
|
import.use_span_with_attributes,
|
||||||
"remove unnecessary import",
|
"remove unnecessary import",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -396,19 +396,14 @@ impl<'a> Resolver<'a> {
|
|||||||
// previous imports.
|
// previous imports.
|
||||||
if found_closing_brace {
|
if found_closing_brace {
|
||||||
if let Some(span) = extend_span_to_previous_binding(self.session, span) {
|
if let Some(span) = extend_span_to_previous_binding(self.session, span) {
|
||||||
err.tool_only_span_suggestion(
|
err.tool_only_span_suggestion(span, message, "", Applicability::MaybeIncorrect);
|
||||||
span,
|
|
||||||
message,
|
|
||||||
String::new(),
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Remove the entire line if we cannot extend the span back, this indicates an
|
// Remove the entire line if we cannot extend the span back, this indicates an
|
||||||
// `issue_52891::{self}` case.
|
// `issue_52891::{self}` case.
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
import.use_span_with_attributes,
|
import.use_span_with_attributes,
|
||||||
message,
|
message,
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -416,7 +411,7 @@ impl<'a> Resolver<'a> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
err.span_suggestion(span, message, String::new(), Applicability::MachineApplicable);
|
err.span_suggestion(span, message, "", Applicability::MachineApplicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn lint_if_path_starts_with_module(
|
pub(crate) fn lint_if_path_starts_with_module(
|
||||||
@ -763,7 +758,7 @@ impl<'a> Resolver<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"try using similarly named label",
|
"try using similarly named label",
|
||||||
ident.name.to_string(),
|
ident.name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -796,7 +791,7 @@ impl<'a> Resolver<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"consider importing the module directly",
|
"consider importing the module directly",
|
||||||
"".to_string(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1007,7 +1002,7 @@ impl<'a> Resolver<'a> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"try using similarly named label",
|
"try using similarly named label",
|
||||||
ident.name.to_string(),
|
ident.name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1618,12 +1613,7 @@ impl<'a> Resolver<'a> {
|
|||||||
format!("maybe you meant this {}", suggestion.res.descr())
|
format!("maybe you meant this {}", suggestion.res.descr())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
err.span_suggestion(
|
err.span_suggestion(span, &msg, suggestion.candidate, Applicability::MaybeIncorrect);
|
||||||
span,
|
|
||||||
&msg,
|
|
||||||
suggestion.candidate.to_string(),
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2535,7 +2525,7 @@ fn show_candidates(
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
first.ident.span.until(last.ident.span),
|
first.ident.span.until(last.ident.span),
|
||||||
&format!("if you import `{}`, refer to it directly", last.ident),
|
&format!("if you import `{}`, refer to it directly", last.ident),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::Unspecified,
|
Applicability::Unspecified,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
expr_span.shrink_to_lo(),
|
expr_span.shrink_to_lo(),
|
||||||
"you might have meant to use pattern matching",
|
"you might have meant to use pattern matching",
|
||||||
"let ".to_string(),
|
"let ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
span,
|
span,
|
||||||
"you might have meant to use `self` here instead",
|
"you might have meant to use `self` here instead",
|
||||||
"self".to_string(),
|
"self",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
if !self.self_value_is_available(path[0].ident.span) {
|
if !self.self_value_is_available(path[0].ident.span) {
|
||||||
@ -317,7 +317,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
span,
|
span,
|
||||||
"if you meant to use `self`, you are also missing a `self` receiver \
|
"if you meant to use `self`, you are also missing a `self` receiver \
|
||||||
argument",
|
argument",
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -376,7 +376,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
"add a `self` receiver parameter to make the associated `fn` a method",
|
"add a `self` receiver parameter to make the associated `fn` a method",
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
"doesn't"
|
"doesn't"
|
||||||
@ -612,7 +612,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
pat_sp.between(ty_sp),
|
pat_sp.between(ty_sp),
|
||||||
"use `=` if you meant to assign",
|
"use `=` if you meant to assign",
|
||||||
" = ".to_string(),
|
" = ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"use the similarly named label",
|
"use the similarly named label",
|
||||||
label_ident.name.to_string(),
|
label_ident.name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
// Do not lint against unused label when we suggest them.
|
// Do not lint against unused label when we suggest them.
|
||||||
@ -656,7 +656,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"perhaps you intended to use this type",
|
"perhaps you intended to use this type",
|
||||||
correct.to_string(),
|
correct,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
constraint.ident.span.between(trait_ref.span),
|
constraint.ident.span.between(trait_ref.span),
|
||||||
"you might have meant to write a path instead of an associated type bound",
|
"you might have meant to write a path instead of an associated type bound",
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1079,7 +1079,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"use `!` to invoke the macro",
|
"use `!` to invoke the macro",
|
||||||
"!".to_string(),
|
"!",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
if path_str == "try" && span.rust_2015() {
|
if path_str == "try" && span.rust_2015() {
|
||||||
@ -1228,7 +1228,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"use this syntax instead",
|
"use this syntax instead",
|
||||||
path_str.to_string(),
|
path_str,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1507,7 +1507,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
colon_sp,
|
colon_sp,
|
||||||
"maybe you meant to write `;` here",
|
"maybe you meant to write `;` here",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1518,7 +1518,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
colon_sp,
|
colon_sp,
|
||||||
"maybe you meant to write a path separator here",
|
"maybe you meant to write a path separator here",
|
||||||
"::".to_string(),
|
"::",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
show_label = false;
|
show_label = false;
|
||||||
|
@ -144,7 +144,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
|||||||
.span_suggestion_verbose(
|
.span_suggestion_verbose(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
"consider enabling this feature",
|
"consider enabling this feature",
|
||||||
"#![feature(generic_const_exprs)]\n".to_string(),
|
"#![feature(generic_const_exprs)]\n",
|
||||||
rustc_errors::Applicability::MaybeIncorrect,
|
rustc_errors::Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit()
|
.emit()
|
||||||
|
@ -417,7 +417,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"consider converting the `Option<T>` into a `Result<T, _>` \
|
"consider converting the `Option<T>` into a `Result<T, _>` \
|
||||||
using `Option::ok_or` or `Option::ok_or_else`",
|
using `Option::ok_or` or `Option::ok_or_else`",
|
||||||
".ok_or_else(|| /* error value */)".to_string(),
|
".ok_or_else(|| /* error value */)",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
} else if should_convert_result_to_option {
|
} else if should_convert_result_to_option {
|
||||||
@ -425,7 +425,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"consider converting the `Result<T, _>` into an `Option<T>` \
|
"consider converting the `Result<T, _>` into an `Option<T>` \
|
||||||
using `Result::ok`",
|
using `Result::ok`",
|
||||||
".ok()".to_string(),
|
".ok()",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -701,7 +701,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"consider dereferencing here",
|
"consider dereferencing here",
|
||||||
"*".to_string(),
|
"*",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@ -1002,7 +1002,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&format!(
|
&format!(
|
||||||
"consider borrowing the value, since `&{self_ty}` can be coerced into `{object_ty}`"
|
"consider borrowing the value, since `&{self_ty}` can be coerced into `{object_ty}`"
|
||||||
),
|
),
|
||||||
"&".to_string(),
|
"&",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1059,12 +1059,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
format!("consider removing {} leading `&`-references", remove_refs)
|
format!("consider removing {} leading `&`-references", remove_refs)
|
||||||
};
|
};
|
||||||
|
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(sp, &msg, "", Applicability::MachineApplicable);
|
||||||
sp,
|
|
||||||
&msg,
|
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
suggested = true;
|
suggested = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1087,7 +1082,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
expr.span.shrink_to_hi().with_hi(span.hi()),
|
expr.span.shrink_to_hi().with_hi(span.hi()),
|
||||||
"remove the `.await`",
|
"remove the `.await`",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
// FIXME: account for associated `async fn`s.
|
// FIXME: account for associated `async fn`s.
|
||||||
@ -1115,14 +1110,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
&msg,
|
&msg,
|
||||||
"async ".to_string(),
|
"async ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
vis_span.shrink_to_hi(),
|
vis_span.shrink_to_hi(),
|
||||||
&msg,
|
&msg,
|
||||||
" async".to_string(),
|
" async",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1190,7 +1185,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
sp,
|
sp,
|
||||||
"consider changing this borrow's mutability",
|
"consider changing this borrow's mutability",
|
||||||
"&mut ".to_string(),
|
"&mut ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1241,7 +1236,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
self.tcx.sess.source_map().end_point(stmt.span),
|
self.tcx.sess.source_map().end_point(stmt.span),
|
||||||
"remove this semicolon",
|
"remove this semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@ -2275,7 +2270,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"consider borrowing here",
|
"consider borrowing here",
|
||||||
"&".to_owned(),
|
"&",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.note("all local variables must have a statically known size");
|
err.note("all local variables must have a statically known size");
|
||||||
@ -2285,7 +2280,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
param.ty_span.shrink_to_lo(),
|
param.ty_span.shrink_to_lo(),
|
||||||
"function arguments must have a statically known size, borrowed types \
|
"function arguments must have a statically known size, borrowed types \
|
||||||
always have a known size",
|
always have a known size",
|
||||||
"&".to_owned(),
|
"&",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2303,7 +2298,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"function arguments must have a statically known size, borrowed types \
|
"function arguments must have a statically known size, borrowed types \
|
||||||
always have a known size",
|
always have a known size",
|
||||||
"&".to_string(),
|
"&",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -2358,7 +2353,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"borrowed types always have a statically known size",
|
"borrowed types always have a statically known size",
|
||||||
"&".to_string(),
|
"&",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.multipart_suggestion(
|
err.multipart_suggestion(
|
||||||
@ -2759,7 +2754,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.with_hi(span.hi() - BytePos(1)).shrink_to_hi(),
|
span.with_hi(span.hi() - BytePos(1)).shrink_to_hi(),
|
||||||
"consider `await`ing on the `Future`",
|
"consider `await`ing on the `Future`",
|
||||||
".await".to_string(),
|
".await",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2785,7 +2780,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
rhs_span.shrink_to_hi(),
|
rhs_span.shrink_to_hi(),
|
||||||
"consider using a floating-point literal by writing it with `.0`",
|
"consider using a floating-point literal by writing it with `.0`",
|
||||||
String::from(".0"),
|
".0",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2965,7 +2960,7 @@ fn suggest_trait_object_return_type_alternatives(
|
|||||||
ret_ty,
|
ret_ty,
|
||||||
"use some type `T` that is `T: Sized` as the return type if all return paths have the \
|
"use some type `T` that is `T: Sized` as the return type if all return paths have the \
|
||||||
same type",
|
same type",
|
||||||
"T".to_string(),
|
"T",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
|
@ -161,7 +161,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
assoc_name.span,
|
assoc_name.span,
|
||||||
"there is an associated type with a similar name",
|
"there is an associated type with a similar name",
|
||||||
suggested_name.to_string(),
|
suggested_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1589,7 +1589,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"you are looking for the module in `std`, not the primitive type",
|
"you are looking for the module in `std`, not the primitive type",
|
||||||
"std::".to_string(),
|
"std::",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1820,7 +1820,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
args_span,
|
args_span,
|
||||||
&format!("{type_name} doesn't have generic parameters"),
|
&format!("{type_name} doesn't have generic parameters"),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -1946,7 +1946,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
assoc_ident.span,
|
assoc_ident.span,
|
||||||
"there is a variant with a similar name",
|
"there is a variant with a similar name",
|
||||||
suggested_name.to_string(),
|
suggested_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -2422,7 +2422,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
ident.span.shrink_to_hi().to(args.span_ext),
|
ident.span.shrink_to_hi().to(args.span_ext),
|
||||||
"the `Self` type doesn't accept type parameters",
|
"the `Self` type doesn't accept type parameters",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2473,7 +2473,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
segment.ident.span.shrink_to_hi().to(args.span_ext),
|
segment.ident.span.shrink_to_hi().to(args.span_ext),
|
||||||
"the `Self` type doesn't accept type parameters",
|
"the `Self` type doesn't accept type parameters",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -2549,7 +2549,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
segment.ident.span.shrink_to_hi().to(args.span_ext),
|
segment.ident.span.shrink_to_hi().to(args.span_ext),
|
||||||
&format!("primitive type `{name}` doesn't have generic parameters"),
|
&format!("primitive type `{name}` doesn't have generic parameters"),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.tool_only_span_suggestion(
|
err.tool_only_span_suggestion(
|
||||||
semi_span,
|
semi_span,
|
||||||
"remove this semicolon",
|
"remove this semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
@ -319,7 +319,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
start,
|
start,
|
||||||
"consider separating array elements with a comma",
|
"consider separating array elements with a comma",
|
||||||
",".to_string(),
|
",",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@ -406,7 +406,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
&format!(
|
&format!(
|
||||||
"`{path}` is a unit variant, you need to write it without the parentheses",
|
"`{path}` is a unit variant, you need to write it without the parentheses",
|
||||||
),
|
),
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
callee_expr.span.shrink_to_hi(),
|
callee_expr.span.shrink_to_hi(),
|
||||||
"consider using a semicolon here",
|
"consider using a semicolon here",
|
||||||
";".to_owned(),
|
";",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ fn compare_predicate_entailment<'tcx>(
|
|||||||
diag.span_suggestion_verbose(sp, msg, sugg, ap);
|
diag.span_suggestion_verbose(sp, msg, sugg, ap);
|
||||||
}
|
}
|
||||||
hir::FnRetTy::Return(hir_ty) => {
|
hir::FnRetTy::Return(hir_ty) => {
|
||||||
let sugg = trait_sig.output().to_string();
|
let sugg = trait_sig.output();
|
||||||
diag.span_suggestion(hir_ty.span, msg, sugg, ap);
|
diag.span_suggestion(hir_ty.span, msg, sugg, ap);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -365,7 +365,7 @@ fn compare_predicate_entailment<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
impl_err_span,
|
impl_err_span,
|
||||||
"change the parameter type to match the trait",
|
"change the parameter type to match the trait",
|
||||||
trait_ty.to_string(),
|
trait_ty,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -864,7 +864,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
expr.span.shrink_to_lo(),
|
expr.span.shrink_to_lo(),
|
||||||
"you might have meant to use pattern destructuring",
|
"you might have meant to use pattern destructuring",
|
||||||
"let ".to_string(),
|
"let ",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -1042,7 +1042,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
expr.span.shrink_to_lo(),
|
expr.span.shrink_to_lo(),
|
||||||
"you might have meant to use pattern matching",
|
"you might have meant to use pattern matching",
|
||||||
"let ".to_string(),
|
"let ",
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -1051,7 +1051,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
"you might have meant to compare for equality",
|
"you might have meant to compare for equality",
|
||||||
"==".to_string(),
|
"==",
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1086,7 +1086,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
lhs.span.shrink_to_lo(),
|
lhs.span.shrink_to_lo(),
|
||||||
"consider dereferencing here to assign to the mutably borrowed value",
|
"consider dereferencing here to assign to the mutably borrowed value",
|
||||||
"*".to_string(),
|
"*",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1790,7 +1790,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
range_start.span.shrink_to_hi(),
|
range_start.span.shrink_to_hi(),
|
||||||
&format!("to set the remaining fields{instead}, separate the last named field with a comma"),
|
&format!("to set the remaining fields{instead}, separate the last named field with a comma"),
|
||||||
",".to_string(),
|
",",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1912,7 +1912,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
field.ident.span,
|
field.ident.span,
|
||||||
"a field with a similar name exists",
|
"a field with a similar name exists",
|
||||||
field_name.to_string(),
|
field_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -2158,7 +2158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
base.span.shrink_to_hi(),
|
base.span.shrink_to_hi(),
|
||||||
"consider `await`ing on the `Future` and access the field of its `Output`",
|
"consider `await`ing on the `Future` and access the field of its `Output`",
|
||||||
".await".to_string(),
|
".await",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2358,7 +2358,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
field.span,
|
field.span,
|
||||||
"a field with a similar name exists",
|
"a field with a similar name exists",
|
||||||
suggested_field_name.to_string(),
|
suggested_field_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1310,7 +1310,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"use curly brackets",
|
"use curly brackets",
|
||||||
String::from("Self { /* fields */ }"),
|
"Self { /* fields */ }",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1458,14 +1458,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span_semi,
|
span_semi,
|
||||||
"consider removing this semicolon and boxing the expression",
|
"consider removing this semicolon and boxing the expression",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
span_semi,
|
span_semi,
|
||||||
"remove this semicolon",
|
"remove this semicolon",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
"consider using a semicolon here",
|
"consider using a semicolon here",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
fn_name.span,
|
fn_name.span,
|
||||||
"use `Box::pin` to pin and box this expression",
|
"use `Box::pin` to pin and box this expression",
|
||||||
"Box::pin".to_string(),
|
"Box::pin",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
@ -507,7 +507,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
expression.span.shrink_to_hi(),
|
expression.span.shrink_to_hi(),
|
||||||
"consider using a semicolon here",
|
"consider using a semicolon here",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"you are looking for the module in `std`, not the primitive type",
|
"you are looking for the module in `std`, not the primitive type",
|
||||||
"std::".to_string(),
|
"std::",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -453,7 +453,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
span,
|
span,
|
||||||
msg,
|
msg,
|
||||||
String::from("len"),
|
"len",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -893,7 +893,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
item_name.span,
|
item_name.span,
|
||||||
"because of the in-memory representation of `&str`, to obtain \
|
"because of the in-memory representation of `&str`, to obtain \
|
||||||
an `Iterator` over each of its codepoint use method `chars`",
|
an `Iterator` over each of its codepoint use method `chars`",
|
||||||
String::from("chars"),
|
"chars",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1006,7 +1006,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"there is a variant with a similar name",
|
"there is a variant with a similar name",
|
||||||
suggestion.to_string(),
|
suggestion,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1019,12 +1019,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let call_expr =
|
let call_expr =
|
||||||
self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(expr.hir_id));
|
self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(expr.hir_id));
|
||||||
if let Some(span) = call_expr.span.trim_start(expr.span) {
|
if let Some(span) = call_expr.span.trim_start(expr.span) {
|
||||||
err.span_suggestion(
|
err.span_suggestion(span, msg, "", Applicability::MachineApplicable);
|
||||||
span,
|
|
||||||
msg,
|
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
fallback_span = false;
|
fallback_span = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1043,7 +1038,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
def_kind.article(),
|
def_kind.article(),
|
||||||
def_kind.descr(lev_candidate.def_id),
|
def_kind.descr(lev_candidate.def_id),
|
||||||
),
|
),
|
||||||
lev_candidate.name.to_string(),
|
lev_candidate.name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1164,7 +1159,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"remove the arguments",
|
"remove the arguments",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1418,7 +1413,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
"use the `?` operator to extract the `{self_ty}` value, propagating \
|
"use the `?` operator to extract the `{self_ty}` value, propagating \
|
||||||
{article} `{kind}::{variant}` value to the caller"
|
{article} `{kind}::{variant}` value to the caller"
|
||||||
),
|
),
|
||||||
"?".to_owned(),
|
"?",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1428,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
"consider using `{kind}::expect` to unwrap the `{self_ty}` value, \
|
"consider using `{kind}::expect` to unwrap the `{self_ty}` value, \
|
||||||
panicking if the value is {article} `{kind}::{variant}`"
|
panicking if the value is {article} `{kind}::{variant}`"
|
||||||
),
|
),
|
||||||
".expect(\"REASON\")".to_owned(),
|
".expect(\"REASON\")",
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1632,7 +1627,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_lo(),
|
span.shrink_to_lo(),
|
||||||
"consider `await`ing on the `Future` and calling the method on its `Output`",
|
"consider `await`ing on the `Future` and calling the method on its `Output`",
|
||||||
"await.".to_string(),
|
"await.",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
lhs_expr.span.shrink_to_lo(),
|
lhs_expr.span.shrink_to_lo(),
|
||||||
msg,
|
msg,
|
||||||
"*".to_string(),
|
"*",
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -621,14 +621,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
lhs_expr.span.until(lhs_inner_expr.span),
|
lhs_expr.span.until(lhs_inner_expr.span),
|
||||||
rm_borrow_msg,
|
rm_borrow_msg,
|
||||||
"".to_owned(),
|
"",
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
lhs_expr.span.shrink_to_hi(),
|
lhs_expr.span.shrink_to_hi(),
|
||||||
to_owned_msg,
|
to_owned_msg,
|
||||||
".to_owned()".to_owned(),
|
".to_owned()",
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1150,14 +1150,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
all_fields_span,
|
all_fields_span,
|
||||||
"use `..` to ignore all fields",
|
"use `..` to ignore all fields",
|
||||||
String::from(".."),
|
"..",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
tail_span,
|
tail_span,
|
||||||
"use `..` to ignore the rest of the fields",
|
"use `..` to ignore the rest of the fields",
|
||||||
String::from(", .."),
|
", ..",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1428,7 +1428,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
sp_comma,
|
sp_comma,
|
||||||
"add `..` at the end of the field list to ignore all other fields",
|
"add `..` at the end of the field list to ignore all other fields",
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -1502,7 +1502,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
pat_field.ident.span,
|
pat_field.ident.span,
|
||||||
"a field with a similar name exists",
|
"a field with a similar name exists",
|
||||||
suggested_name.to_string(),
|
suggested_name,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1655,7 +1655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
field.span.shrink_to_hi(),
|
field.span.shrink_to_hi(),
|
||||||
"ignore the inaccessible and unused fields",
|
"ignore the inaccessible and unused fields",
|
||||||
", ..".to_string(),
|
", ..",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1670,7 +1670,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
"ignore the inaccessible and unused fields",
|
"ignore the inaccessible and unused fields",
|
||||||
" { .. }".to_string(),
|
" { .. }",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
|
|||||||
.span_suggestion_short(
|
.span_suggestion_short(
|
||||||
span_with_attrs,
|
span_with_attrs,
|
||||||
"remove it",
|
"remove it",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -1930,7 +1930,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
ty.span,
|
ty.span,
|
||||||
"replace with the correct return type",
|
"replace with the correct return type",
|
||||||
ret_ty.to_string(),
|
ret_ty,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else if matches!(ret_ty.kind(), ty::FnDef(..)) {
|
} else if matches!(ret_ty.kind(), ty::FnDef(..)) {
|
||||||
@ -1939,7 +1939,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
ty.span,
|
ty.span,
|
||||||
"replace with the correct return type",
|
"replace with the correct return type",
|
||||||
fn_sig.to_string(),
|
fn_sig,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2584,7 +2584,7 @@ fn from_target_feature(
|
|||||||
let Some(list) = attr.meta_item_list() else { return };
|
let Some(list) = attr.meta_item_list() else { return };
|
||||||
let bad_item = |span| {
|
let bad_item = |span| {
|
||||||
let msg = "malformed `target_feature` attribute input";
|
let msg = "malformed `target_feature` attribute input";
|
||||||
let code = "enable = \"..\"".to_owned();
|
let code = "enable = \"..\"";
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.span_suggestion(span, "must be of the form", code, Applicability::HasPlaceholders)
|
.span_suggestion(span, "must be of the form", code, Applicability::HasPlaceholders)
|
||||||
|
@ -756,7 +756,7 @@ fn infer_placeholder_type<'a>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"replace with the correct type",
|
"replace with the correct type",
|
||||||
sugg_ty.to_string(),
|
sugg_ty,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,7 @@ pub fn insert_outlives_predicate<'tcx>(
|
|||||||
) {
|
) {
|
||||||
// If the `'a` region is bound within the field type itself, we
|
// If the `'a` region is bound within the field type itself, we
|
||||||
// don't want to propagate this constraint to the header.
|
// don't want to propagate this constraint to the header.
|
||||||
if !is_free_region(tcx, outlived_region) {
|
if !is_free_region(outlived_region) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ pub fn insert_outlives_predicate<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
GenericArgKind::Lifetime(r) => {
|
GenericArgKind::Lifetime(r) => {
|
||||||
if !is_free_region(tcx, r) {
|
if !is_free_region(r) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
required_predicates.entry(ty::OutlivesPredicate(kind, outlived_region)).or_insert(span);
|
required_predicates.entry(ty::OutlivesPredicate(kind, outlived_region)).or_insert(span);
|
||||||
@ -131,7 +131,7 @@ pub fn insert_outlives_predicate<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
|
fn is_free_region(region: Region<'_>) -> bool {
|
||||||
// First, screen for regions that might appear in a type header.
|
// First, screen for regions that might appear in a type header.
|
||||||
match *region {
|
match *region {
|
||||||
// These correspond to `T: 'a` relationships:
|
// These correspond to `T: 'a` relationships:
|
||||||
@ -144,13 +144,12 @@ fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
|
|||||||
ty::ReEarlyBound(_) => true,
|
ty::ReEarlyBound(_) => true,
|
||||||
|
|
||||||
// These correspond to `T: 'static` relationships which can be
|
// These correspond to `T: 'static` relationships which can be
|
||||||
// rather surprising. We are therefore putting this behind a
|
// rather surprising.
|
||||||
// feature flag:
|
|
||||||
//
|
//
|
||||||
// struct Foo<'a, T> {
|
// struct Foo<'a, T> {
|
||||||
// field: &'static T, // this would generate a ReStatic
|
// field: &'static T, // this would generate a ReStatic
|
||||||
// }
|
// }
|
||||||
ty::ReStatic => tcx.sess.features_untracked().infer_static_outlives_requirements,
|
ty::ReStatic => false,
|
||||||
|
|
||||||
// Late-bound regions can appear in `fn` types:
|
// Late-bound regions can appear in `fn` types:
|
||||||
//
|
//
|
||||||
|
@ -715,7 +715,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span_redundant_lt_args,
|
span_redundant_lt_args,
|
||||||
&msg_lifetimes,
|
&msg_lifetimes,
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -757,7 +757,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span_redundant_type_or_const_args,
|
span_redundant_type_or_const_args,
|
||||||
&msg_types_or_consts,
|
&msg_types_or_consts,
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -797,7 +797,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||||||
if self.gen_args.parenthesized { "parenthetical " } else { "" },
|
if self.gen_args.parenthesized { "parenthetical " } else { "" },
|
||||||
);
|
);
|
||||||
|
|
||||||
err.span_suggestion(span, &msg, String::new(), Applicability::MaybeIncorrect);
|
err.span_suggestion(span, &msg, "", Applicability::MaybeIncorrect);
|
||||||
} else if redundant_lifetime_args && redundant_type_or_const_args {
|
} else if redundant_lifetime_args && redundant_type_or_const_args {
|
||||||
remove_lifetime_args(err);
|
remove_lifetime_args(err);
|
||||||
remove_type_or_const_args(err);
|
remove_type_or_const_args(err);
|
||||||
|
@ -1632,6 +1632,7 @@ impl str {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!("cfg".split_once('='), None);
|
/// assert_eq!("cfg".split_once('='), None);
|
||||||
|
/// assert_eq!("cfg=".split_once('='), Some(("cfg", "")));
|
||||||
/// assert_eq!("cfg=foo".split_once('='), Some(("cfg", "foo")));
|
/// assert_eq!("cfg=foo".split_once('='), Some(("cfg", "foo")));
|
||||||
/// assert_eq!("cfg=foo=bar".split_once('='), Some(("cfg", "foo=bar")));
|
/// assert_eq!("cfg=foo=bar".split_once('='), Some(("cfg", "foo=bar")));
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -179,13 +179,13 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) {
|
|||||||
let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple);
|
let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple);
|
||||||
let tarball = rustc_cache.join(&filename);
|
let tarball = rustc_cache.join(&filename);
|
||||||
if !tarball.exists() {
|
if !tarball.exists() {
|
||||||
let help_on_error = "error: failed to download llvm from ci\n
|
let help_on_error = "error: failed to download llvm from ci
|
||||||
\nhelp: old builds get deleted after a certain time
|
|
||||||
\nhelp: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml:
|
help: old builds get deleted after a certain time
|
||||||
\n
|
help: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml:
|
||||||
\n[llvm]
|
|
||||||
\ndownload-ci-llvm = false
|
[llvm]
|
||||||
\n
|
download-ci-llvm = false
|
||||||
";
|
";
|
||||||
builder.download_component(base, &format!("{}/{}", url, filename), &tarball, help_on_error);
|
builder.download_component(base, &format!("{}/{}", url, filename), &tarball, help_on_error);
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
# `infer_static_outlives_requirements`
|
|
||||||
|
|
||||||
The tracking issue for this feature is: [#54185]
|
|
||||||
|
|
||||||
[#54185]: https://github.com/rust-lang/rust/issues/54185
|
|
||||||
|
|
||||||
------------------------
|
|
||||||
The `infer_static_outlives_requirements` feature indicates that certain
|
|
||||||
`'static` outlives requirements can be inferred by the compiler rather than
|
|
||||||
stating them explicitly.
|
|
||||||
|
|
||||||
Note: It is an accompanying feature to `infer_outlives_requirements`,
|
|
||||||
which must be enabled to infer outlives requirements.
|
|
||||||
|
|
||||||
For example, currently generic struct definitions that contain
|
|
||||||
references, require where-clauses of the form T: 'static. By using
|
|
||||||
this feature the outlives predicates will be inferred, although
|
|
||||||
they may still be written explicitly.
|
|
||||||
|
|
||||||
```rust,ignore (pseudo-Rust)
|
|
||||||
struct Foo<U> where U: 'static { // <-- currently required
|
|
||||||
bar: Bar<U>
|
|
||||||
}
|
|
||||||
struct Bar<T: 'static> {
|
|
||||||
x: T,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Examples:
|
|
||||||
|
|
||||||
```rust,ignore (pseudo-Rust)
|
|
||||||
#![feature(infer_outlives_requirements)]
|
|
||||||
#![feature(infer_static_outlives_requirements)]
|
|
||||||
|
|
||||||
#[rustc_outlives]
|
|
||||||
// Implicitly infer U: 'static
|
|
||||||
struct Foo<U> {
|
|
||||||
bar: Bar<U>
|
|
||||||
}
|
|
||||||
struct Bar<T: 'static> {
|
|
||||||
x: T,
|
|
||||||
}
|
|
||||||
```
|
|
@ -122,7 +122,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
sp.from_inner(InnerSpan::new(0, 3)).shrink_to_hi(),
|
sp.from_inner(InnerSpan::new(0, 3)).shrink_to_hi(),
|
||||||
explanation,
|
explanation,
|
||||||
String::from("text"),
|
"text",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
88
src/test/ui/const-generics/issue-97007.rs
Normal file
88
src/test/ui/const-generics/issue-97007.rs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// check-pass
|
||||||
|
|
||||||
|
#![feature(adt_const_params, generic_const_exprs)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
mod lib {
|
||||||
|
const N_ISLANDS: usize = 4;
|
||||||
|
const N_BRIDGES: usize = 7;
|
||||||
|
const BRIDGES: [(usize, usize); 7] = [(0, 1), (0, 1), (0, 2), (0, 3), (0, 3), (1, 2), (2, 3)];
|
||||||
|
|
||||||
|
pub type Matrix = [[usize; N_ISLANDS]; N_ISLANDS];
|
||||||
|
|
||||||
|
const EMPTY_MATRIX: Matrix = [[0; N_ISLANDS]; N_ISLANDS];
|
||||||
|
|
||||||
|
const fn build(mut matrix: Matrix, (to, from): (usize, usize)) -> Matrix {
|
||||||
|
matrix[to][from] += 1;
|
||||||
|
matrix[from][to] += 1;
|
||||||
|
matrix
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn walk(mut matrix: Matrix, from: usize, to: usize) -> Matrix {
|
||||||
|
matrix[from][to] -= 1;
|
||||||
|
matrix[to][from] -= 1;
|
||||||
|
matrix
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn to_matrix(bridges: [(usize, usize); N_BRIDGES]) -> Matrix {
|
||||||
|
let matrix = EMPTY_MATRIX;
|
||||||
|
|
||||||
|
let matrix = build(matrix, bridges[0]);
|
||||||
|
let matrix = build(matrix, bridges[1]);
|
||||||
|
let matrix = build(matrix, bridges[2]);
|
||||||
|
let matrix = build(matrix, bridges[3]);
|
||||||
|
let matrix = build(matrix, bridges[4]);
|
||||||
|
let matrix = build(matrix, bridges[5]);
|
||||||
|
let matrix = build(matrix, bridges[6]);
|
||||||
|
|
||||||
|
matrix
|
||||||
|
}
|
||||||
|
|
||||||
|
const BRIDGE_MATRIX: [[usize; N_ISLANDS]; N_ISLANDS] = to_matrix(BRIDGES);
|
||||||
|
|
||||||
|
pub struct Walk<const CURRENT: usize, const REMAINING: Matrix> {
|
||||||
|
_p: (),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Walk<0, BRIDGE_MATRIX> {
|
||||||
|
pub const fn new() -> Self {
|
||||||
|
Self { _p: () }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<const CURRENT: usize, const REMAINING: Matrix> Walk<CURRENT, REMAINING> {
|
||||||
|
pub fn proceed_to<const NEXT: usize>(
|
||||||
|
self,
|
||||||
|
) -> Walk<NEXT, { walk(REMAINING, CURRENT, NEXT) }> {
|
||||||
|
Walk { _p: () }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Trophy {
|
||||||
|
_p: (),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<const CURRENT: usize> Walk<CURRENT, EMPTY_MATRIX> {
|
||||||
|
pub fn collect_prize(self) -> Trophy {
|
||||||
|
Trophy { _p: () }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use lib::{Trophy, Walk};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Example, taking the first step
|
||||||
|
let _ = Walk::new().proceed_to::<1>();
|
||||||
|
|
||||||
|
// Don't be so eager to collect the trophy
|
||||||
|
// let trophy = Walk::new()
|
||||||
|
// .proceed_to::<1>()
|
||||||
|
// .proceed_to::<0>()
|
||||||
|
// .collect_prize();
|
||||||
|
|
||||||
|
// Can't just make a Trophy out of thin air, you must earn it
|
||||||
|
// let trophy: Trophy = Trophy { _p: () };
|
||||||
|
|
||||||
|
// Can you collect the Trophy?
|
||||||
|
}
|
16
src/test/ui/const-generics/issues/issue-67945-3.full.stderr
Normal file
16
src/test/ui/const-generics/issues/issue-67945-3.full.stderr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
error: overly complex generic constant
|
||||||
|
--> $DIR/issue-67945-3.rs:10:13
|
||||||
|
|
|
||||||
|
LL | A: [(); {
|
||||||
|
| _____________^
|
||||||
|
LL | | let x: Option<S> = None;
|
||||||
|
LL | |
|
||||||
|
LL | | 0
|
||||||
|
LL | | }],
|
||||||
|
| |_____^ blocks are not supported in generic constant
|
||||||
|
|
|
||||||
|
= help: consider moving this anonymous constant into a `const` function
|
||||||
|
= note: this operation may be supported in the future
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
21
src/test/ui/const-generics/issues/issue-67945-3.min.stderr
Normal file
21
src/test/ui/const-generics/issues/issue-67945-3.min.stderr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
error: generic parameters may not be used in const operations
|
||||||
|
--> $DIR/issue-67945-3.rs:11:23
|
||||||
|
|
|
||||||
|
LL | let x: Option<S> = None;
|
||||||
|
| ^ cannot perform const operation using `S`
|
||||||
|
|
|
||||||
|
= note: type parameters may not be used in const expressions
|
||||||
|
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||||
|
|
||||||
|
error[E0392]: parameter `S` is never used
|
||||||
|
--> $DIR/issue-67945-3.rs:9:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
= help: if you intended `S` to be a const parameter, use `const S: usize` instead
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
17
src/test/ui/const-generics/issues/issue-67945-3.rs
Normal file
17
src/test/ui/const-generics/issues/issue-67945-3.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Regression test for
|
||||||
|
// https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285
|
||||||
|
// Make sure we don't emit an E0277 error.
|
||||||
|
|
||||||
|
// revisions: full min
|
||||||
|
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
|
||||||
|
struct Bug<S> { //[min]~ ERROR: parameter `S` is never used
|
||||||
|
A: [(); { //[full]~ ERROR: overly complex generic constant
|
||||||
|
let x: Option<S> = None;
|
||||||
|
//[min]~^ ERROR: generic parameters may not be used in const operations
|
||||||
|
0
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
16
src/test/ui/const-generics/issues/issue-67945-4.full.stderr
Normal file
16
src/test/ui/const-generics/issues/issue-67945-4.full.stderr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
error: overly complex generic constant
|
||||||
|
--> $DIR/issue-67945-4.rs:9:13
|
||||||
|
|
|
||||||
|
LL | A: [(); {
|
||||||
|
| _____________^
|
||||||
|
LL | | let x: Option<Box<S>> = None;
|
||||||
|
LL | |
|
||||||
|
LL | | 0
|
||||||
|
LL | | }],
|
||||||
|
| |_____^ blocks are not supported in generic constant
|
||||||
|
|
|
||||||
|
= help: consider moving this anonymous constant into a `const` function
|
||||||
|
= note: this operation may be supported in the future
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
21
src/test/ui/const-generics/issues/issue-67945-4.min.stderr
Normal file
21
src/test/ui/const-generics/issues/issue-67945-4.min.stderr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
error: generic parameters may not be used in const operations
|
||||||
|
--> $DIR/issue-67945-4.rs:10:27
|
||||||
|
|
|
||||||
|
LL | let x: Option<Box<S>> = None;
|
||||||
|
| ^ cannot perform const operation using `S`
|
||||||
|
|
|
||||||
|
= note: type parameters may not be used in const expressions
|
||||||
|
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||||
|
|
||||||
|
error[E0392]: parameter `S` is never used
|
||||||
|
--> $DIR/issue-67945-4.rs:8:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
= help: if you intended `S` to be a const parameter, use `const S: usize` instead
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
16
src/test/ui/const-generics/issues/issue-67945-4.rs
Normal file
16
src/test/ui/const-generics/issues/issue-67945-4.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Regression test for
|
||||||
|
// https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285
|
||||||
|
|
||||||
|
// revisions: full min
|
||||||
|
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
|
||||||
|
struct Bug<S> { //[min]~ ERROR: parameter `S` is never used
|
||||||
|
A: [(); { //[full]~ ERROR: overly complex generic constant
|
||||||
|
let x: Option<Box<S>> = None;
|
||||||
|
//[min]~^ ERROR: generic parameters may not be used in const operations
|
||||||
|
0
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -243,7 +243,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
| |
|
||||||
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
|
| ptr_offset_from_unsigned called on pointers into different allocations
|
||||||
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||||
@ -262,7 +262,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
| |
|
||||||
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
|
| ptr_offset_from_unsigned called on pointers into different allocations
|
||||||
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||||
|
@ -243,7 +243,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
| |
|
||||||
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
|
| ptr_offset_from_unsigned called on pointers into different allocations
|
||||||
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||||
@ -262,7 +262,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
| |
|
||||||
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
|
| ptr_offset_from_unsigned called on pointers into different allocations
|
||||||
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||||
|
@ -15,7 +15,7 @@ pub const DIFFERENT_ALLOC: usize = {
|
|||||||
let uninit2 = std::mem::MaybeUninit::<Struct>::uninit();
|
let uninit2 = std::mem::MaybeUninit::<Struct>::uninit();
|
||||||
let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct;
|
let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct;
|
||||||
let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed
|
let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed
|
||||||
//~| ptr_offset_from cannot compute offset of pointers into different allocations.
|
//~| pointers into different allocations
|
||||||
offset as usize
|
offset as usize
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ pub const DIFFERENT_INT: isize = { // offset_from with two different integers: l
|
|||||||
let ptr1 = 8 as *const u8;
|
let ptr1 = 8 as *const u8;
|
||||||
let ptr2 = 16 as *const u8;
|
let ptr2 = 16 as *const u8;
|
||||||
unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed
|
unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed
|
||||||
//~| 0x10 is not a valid pointer
|
//~| 0x8 is not a valid pointer
|
||||||
};
|
};
|
||||||
|
|
||||||
const OUT_OF_BOUNDS_1: isize = {
|
const OUT_OF_BOUNDS_1: isize = {
|
||||||
@ -50,7 +50,7 @@ const OUT_OF_BOUNDS_1: isize = {
|
|||||||
let end_ptr = (start_ptr).wrapping_add(length);
|
let end_ptr = (start_ptr).wrapping_add(length);
|
||||||
// First ptr is out of bounds
|
// First ptr is out of bounds
|
||||||
unsafe { ptr_offset_from(end_ptr, start_ptr) } //~ERROR evaluation of constant value failed
|
unsafe { ptr_offset_from(end_ptr, start_ptr) } //~ERROR evaluation of constant value failed
|
||||||
//~| pointer at offset 10 is out-of-bounds
|
//~| pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||||
};
|
};
|
||||||
|
|
||||||
const OUT_OF_BOUNDS_2: isize = {
|
const OUT_OF_BOUNDS_2: isize = {
|
||||||
@ -59,7 +59,7 @@ const OUT_OF_BOUNDS_2: isize = {
|
|||||||
let end_ptr = (start_ptr).wrapping_add(length);
|
let end_ptr = (start_ptr).wrapping_add(length);
|
||||||
// Second ptr is out of bounds
|
// Second ptr is out of bounds
|
||||||
unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed
|
unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed
|
||||||
//~| pointer at offset 10 is out-of-bounds
|
//~| pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||||
};
|
};
|
||||||
|
|
||||||
const OUT_OF_BOUNDS_SAME: isize = {
|
const OUT_OF_BOUNDS_SAME: isize = {
|
||||||
@ -76,7 +76,7 @@ pub const DIFFERENT_ALLOC_UNSIGNED: usize = {
|
|||||||
let uninit2 = std::mem::MaybeUninit::<Struct>::uninit();
|
let uninit2 = std::mem::MaybeUninit::<Struct>::uninit();
|
||||||
let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct;
|
let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct;
|
||||||
let offset = unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed
|
let offset = unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed
|
||||||
//~| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
|
//~| pointers into different allocations
|
||||||
offset as usize
|
offset as usize
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ const WRONG_ORDER_UNSIGNED: usize = {
|
|||||||
let a = ['a', 'b', 'c'];
|
let a = ['a', 'b', 'c'];
|
||||||
let p = a.as_ptr();
|
let p = a.as_ptr();
|
||||||
unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } //~ERROR evaluation of constant value failed
|
unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } //~ERROR evaluation of constant value failed
|
||||||
//~| cannot compute a negative offset, but 0 < 8
|
//~| first pointer has smaller offset than second: 0 < 8
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_from_ub.rs:17:27
|
--> $DIR/offset_from_ub.rs:17:27
|
||||||
|
|
|
|
||||||
LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
|
LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from called on pointers into different allocations
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@ -10,7 +10,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
|
LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
| |
|
||||||
| out-of-bounds offset_from: 0x2a is not a valid pointer
|
| ptr_offset_from called on pointers into different allocations
|
||||||
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $DIR/offset_from_ub.rs:23:14
|
::: $DIR/offset_from_ub.rs:23:14
|
||||||
@ -34,19 +34,19 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_from_ub.rs:43:14
|
--> $DIR/offset_from_ub.rs:43:14
|
||||||
|
|
|
|
||||||
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
|
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x10 is not a valid pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8 is not a valid pointer
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/offset_from_ub.rs:52:14
|
--> $DIR/offset_from_ub.rs:52:14
|
||||||
|
|
|
|
||||||
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
|
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer at offset 10 is out-of-bounds
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/offset_from_ub.rs:61:14
|
--> $DIR/offset_from_ub.rs:61:14
|
||||||
|
|
|
|
||||||
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
|
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/offset_from_ub.rs:69:14
|
--> $DIR/offset_from_ub.rs:69:14
|
||||||
@ -58,13 +58,13 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_from_ub.rs:78:27
|
--> $DIR/offset_from_ub.rs:78:27
|
||||||
|
|
|
|
||||||
LL | let offset = unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) };
|
LL | let offset = unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called on pointers into different allocations
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/offset_from_ub.rs:86:14
|
--> $DIR/offset_from_ub.rs:86:14
|
||||||
|
|
|
|
||||||
LL | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) }
|
LL | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned cannot compute a negative offset, but 0 < 8
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 8
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
// Needs an explicit where clause stating outlives condition. (RFC 2093)
|
|
||||||
|
|
||||||
// Type T needs to outlive lifetime 'static.
|
|
||||||
struct Foo<U> {
|
|
||||||
bar: Bar<U> //~ ERROR the parameter type `U` may not live long enough [E0310]
|
|
||||||
}
|
|
||||||
struct Bar<T: 'static> {
|
|
||||||
x: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn main() { }
|
|
@ -1,19 +0,0 @@
|
|||||||
error[E0310]: the parameter type `U` may not live long enough
|
|
||||||
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:10
|
|
||||||
|
|
|
||||||
LL | bar: Bar<U>
|
|
||||||
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
|
|
||||||
|
|
|
||||||
note: ...that is required by this bound
|
|
||||||
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:7:15
|
|
||||||
|
|
|
||||||
LL | struct Bar<T: 'static> {
|
|
||||||
| ^^^^^^^
|
|
||||||
help: consider adding an explicit lifetime bound...
|
|
||||||
|
|
|
||||||
LL | struct Foo<U: 'static> {
|
|
||||||
| +++++++++
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0310`.
|
|
@ -1,7 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* We don't infer `T: 'static` outlives relationships by default.
|
* We don't infer `T: 'static` outlives relationships.
|
||||||
* Instead an additional feature gate `infer_static_outlives_requirements`
|
|
||||||
* is required.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct Foo<U> {
|
struct Foo<U> {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
error[E0310]: the parameter type `U` may not live long enough
|
error[E0310]: the parameter type `U` may not live long enough
|
||||||
--> $DIR/dont-infer-static.rs:8:10
|
--> $DIR/dont-infer-static.rs:6:10
|
||||||
|
|
|
|
||||||
LL | bar: Bar<U>
|
LL | bar: Bar<U>
|
||||||
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
|
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
|
||||||
|
|
|
|
||||||
note: ...that is required by this bound
|
note: ...that is required by this bound
|
||||||
--> $DIR/dont-infer-static.rs:10:15
|
--> $DIR/dont-infer-static.rs:8:15
|
||||||
|
|
|
|
||||||
LL | struct Bar<T: 'static> {
|
LL | struct Bar<T: 'static> {
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#![feature(rustc_attrs)]
|
|
||||||
#![feature(infer_static_outlives_requirements)]
|
|
||||||
|
|
||||||
#[rustc_outlives]
|
|
||||||
struct Foo<U> { //~ ERROR rustc_outlives
|
|
||||||
bar: Bar<U>
|
|
||||||
}
|
|
||||||
struct Bar<T: 'static> {
|
|
||||||
x: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
@ -1,12 +0,0 @@
|
|||||||
error: rustc_outlives
|
|
||||||
--> $DIR/infer-static.rs:5:1
|
|
||||||
|
|
|
||||||
LL | / struct Foo<U> {
|
|
||||||
LL | | bar: Bar<U>
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
|
||||||
= note: U: 'static
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user