Auto merge of #111380 - Dylan-DPC:rollup-xiptbhn, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #110304 (Add GNU Property Note) - #110504 (Tweak borrow suggestion span) - #110583 (tweak "make mut" spans when assigning to locals) - #110694 (Implement builtin # syntax and use it for offset_of!(...)) - #111120 (Suggest let for possible binding with ty) - #111252 (Min specialization improvements) - #111361 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ecd3dbab4e
134 changed files with 1739 additions and 919 deletions
|
@ -603,6 +603,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
|
||||||
gate_all!(yeet_expr, "`do yeet` expression is experimental");
|
gate_all!(yeet_expr, "`do yeet` expression is experimental");
|
||||||
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
|
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
|
||||||
gate_all!(const_closures, "const closures are experimental");
|
gate_all!(const_closures, "const closures are experimental");
|
||||||
|
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");
|
||||||
|
|
||||||
if !visitor.features.negative_bounds {
|
if !visitor.features.negative_bounds {
|
||||||
for &span in spans.get(&sym::negative_bounds).iter().copied().flatten() {
|
for &span in spans.get(&sym::negative_bounds).iter().copied().flatten() {
|
||||||
|
|
|
@ -556,8 +556,7 @@ impl<'a> State<'a> {
|
||||||
self.pclose();
|
self.pclose();
|
||||||
}
|
}
|
||||||
ast::ExprKind::OffsetOf(container, fields) => {
|
ast::ExprKind::OffsetOf(container, fields) => {
|
||||||
// FIXME: This should have its own syntax, distinct from a macro invocation.
|
self.word("builtin # offset_of");
|
||||||
self.word("offset_of!");
|
|
||||||
self.popen();
|
self.popen();
|
||||||
self.rbox(0, Inconsistent);
|
self.rbox(0, Inconsistent);
|
||||||
self.print_type(container);
|
self.print_type(container);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use rustc_errors::{Applicability, Diagnostic};
|
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_hir::Node;
|
use rustc_hir::Node;
|
||||||
|
@ -478,179 +478,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
match self.local_names[local] {
|
match self.local_names[local] {
|
||||||
Some(name) if !local_decl.from_compiler_desugaring() => {
|
Some(name) if !local_decl.from_compiler_desugaring() => {
|
||||||
let label = match *local_decl.local_info() {
|
|
||||||
LocalInfo::User(mir::BindingForm::ImplicitSelf(_)) => {
|
|
||||||
let (span, suggestion) =
|
|
||||||
suggest_ampmut_self(self.infcx.tcx, local_decl);
|
|
||||||
Some((true, span, suggestion))
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
|
|
||||||
binding_mode: ty::BindingMode::BindByValue(_),
|
|
||||||
opt_ty_info,
|
|
||||||
..
|
|
||||||
})) => {
|
|
||||||
// check if the RHS is from desugaring
|
|
||||||
let opt_assignment_rhs_span =
|
|
||||||
self.body.find_assignments(local).first().map(|&location| {
|
|
||||||
if let Some(mir::Statement {
|
|
||||||
source_info: _,
|
|
||||||
kind:
|
|
||||||
mir::StatementKind::Assign(box (
|
|
||||||
_,
|
|
||||||
mir::Rvalue::Use(mir::Operand::Copy(place)),
|
|
||||||
)),
|
|
||||||
}) = self.body[location.block]
|
|
||||||
.statements
|
|
||||||
.get(location.statement_index)
|
|
||||||
{
|
|
||||||
self.body.local_decls[place.local].source_info.span
|
|
||||||
} else {
|
|
||||||
self.body.source_info(location).span
|
|
||||||
}
|
|
||||||
});
|
|
||||||
match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) {
|
|
||||||
// on for loops, RHS points to the iterator part
|
|
||||||
Some(DesugaringKind::ForLoop) => {
|
|
||||||
self.suggest_similar_mut_method_for_for_loop(&mut err);
|
|
||||||
err.span_label(opt_assignment_rhs_span.unwrap(), format!(
|
|
||||||
"this iterator yields `{pointer_sigil}` {pointer_desc}s",
|
|
||||||
));
|
|
||||||
None
|
|
||||||
}
|
|
||||||
// don't create labels for compiler-generated spans
|
|
||||||
Some(_) => None,
|
|
||||||
None => {
|
|
||||||
let label = if name != kw::SelfLower {
|
|
||||||
suggest_ampmut(
|
|
||||||
self.infcx.tcx,
|
|
||||||
local_decl,
|
|
||||||
opt_assignment_rhs_span,
|
|
||||||
opt_ty_info,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
match local_decl.local_info() {
|
|
||||||
LocalInfo::User(mir::BindingForm::Var(
|
|
||||||
mir::VarBindingForm {
|
|
||||||
opt_ty_info: None, ..
|
|
||||||
},
|
|
||||||
)) => {
|
|
||||||
let (span, sugg) = suggest_ampmut_self(
|
|
||||||
self.infcx.tcx,
|
|
||||||
local_decl,
|
|
||||||
);
|
|
||||||
(true, span, sugg)
|
|
||||||
}
|
|
||||||
// explicit self (eg `self: &'a Self`)
|
|
||||||
_ => suggest_ampmut(
|
|
||||||
self.infcx.tcx,
|
|
||||||
local_decl,
|
|
||||||
opt_assignment_rhs_span,
|
|
||||||
opt_ty_info,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Some(label)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
|
|
||||||
binding_mode: ty::BindingMode::BindByReference(_),
|
|
||||||
..
|
|
||||||
})) => {
|
|
||||||
let pattern_span = local_decl.source_info.span;
|
|
||||||
suggest_ref_mut(self.infcx.tcx, pattern_span)
|
|
||||||
.map(|replacement| (true, pattern_span, replacement))
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
match label {
|
|
||||||
Some((true, err_help_span, suggested_code)) => {
|
|
||||||
let (is_trait_sig, local_trait) = self.is_error_in_trait(local);
|
|
||||||
if !is_trait_sig {
|
|
||||||
err.span_suggestion_verbose(
|
|
||||||
err_help_span,
|
|
||||||
format!(
|
|
||||||
"consider changing this to be a mutable {pointer_desc}"
|
|
||||||
),
|
|
||||||
suggested_code,
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
} else if let Some(x) = local_trait {
|
|
||||||
err.span_suggestion_verbose(
|
|
||||||
x,
|
|
||||||
format!(
|
|
||||||
"consider changing that to be a mutable {pointer_desc}"
|
|
||||||
),
|
|
||||||
suggested_code,
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some((false, err_label_span, message)) => {
|
|
||||||
struct BindingFinder {
|
|
||||||
span: Span,
|
|
||||||
hir_id: Option<hir::HirId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for BindingFinder {
|
|
||||||
fn visit_stmt(&mut self, s: &'tcx hir::Stmt<'tcx>) {
|
|
||||||
if let hir::StmtKind::Local(local) = s.kind {
|
|
||||||
if local.pat.span == self.span {
|
|
||||||
self.hir_id = Some(local.hir_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hir::intravisit::walk_stmt(self, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let hir_map = self.infcx.tcx.hir();
|
|
||||||
let def_id = self.body.source.def_id();
|
|
||||||
let hir_id = hir_map.local_def_id_to_hir_id(def_id.expect_local());
|
|
||||||
let node = hir_map.find(hir_id);
|
|
||||||
let hir_id = if let Some(hir::Node::Item(item)) = node
|
|
||||||
&& let hir::ItemKind::Fn(.., body_id) = item.kind
|
|
||||||
{
|
|
||||||
let body = hir_map.body(body_id);
|
|
||||||
let mut v = BindingFinder {
|
|
||||||
span: err_label_span,
|
|
||||||
hir_id: None,
|
|
||||||
};
|
|
||||||
v.visit_body(body);
|
|
||||||
v.hir_id
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
if let Some(hir_id) = hir_id
|
|
||||||
&& let Some(hir::Node::Local(local)) = hir_map.find(hir_id)
|
|
||||||
{
|
|
||||||
let (changing, span, sugg) = match local.ty {
|
|
||||||
Some(ty) => ("changing", ty.span, message),
|
|
||||||
None => (
|
|
||||||
"specifying",
|
|
||||||
local.pat.span.shrink_to_hi(),
|
|
||||||
format!(": {message}"),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
err.span_suggestion_verbose(
|
|
||||||
span,
|
|
||||||
format!("consider {changing} this binding's type"),
|
|
||||||
sugg,
|
|
||||||
Applicability::HasPlaceholders,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
err.span_label(
|
|
||||||
err_label_span,
|
|
||||||
format!(
|
|
||||||
"consider changing this binding's type to be: `{message}`"
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
err.span_label(
|
err.span_label(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
|
@ -658,6 +485,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
so the data it refers to cannot be {acted_on}",
|
so the data it refers to cannot be {acted_on}",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.suggest_make_local_mut(&mut err, local, name);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
err.span_label(
|
err.span_label(
|
||||||
|
@ -1131,6 +960,184 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn suggest_make_local_mut(
|
||||||
|
&self,
|
||||||
|
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
|
||||||
|
local: Local,
|
||||||
|
name: Symbol,
|
||||||
|
) {
|
||||||
|
let local_decl = &self.body.local_decls[local];
|
||||||
|
|
||||||
|
let (pointer_sigil, pointer_desc) =
|
||||||
|
if local_decl.ty.is_ref() { ("&", "reference") } else { ("*const", "pointer") };
|
||||||
|
|
||||||
|
let (is_trait_sig, local_trait) = self.is_error_in_trait(local);
|
||||||
|
if is_trait_sig && local_trait.is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let decl_span = match local_trait {
|
||||||
|
Some(span) => span,
|
||||||
|
None => local_decl.source_info.span,
|
||||||
|
};
|
||||||
|
|
||||||
|
let label = match *local_decl.local_info() {
|
||||||
|
LocalInfo::User(mir::BindingForm::ImplicitSelf(_)) => {
|
||||||
|
let suggestion = suggest_ampmut_self(self.infcx.tcx, decl_span);
|
||||||
|
Some((true, decl_span, suggestion))
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
|
||||||
|
binding_mode: ty::BindingMode::BindByValue(_),
|
||||||
|
opt_ty_info,
|
||||||
|
..
|
||||||
|
})) => {
|
||||||
|
// check if the RHS is from desugaring
|
||||||
|
let opt_assignment_rhs_span =
|
||||||
|
self.body.find_assignments(local).first().map(|&location| {
|
||||||
|
if let Some(mir::Statement {
|
||||||
|
source_info: _,
|
||||||
|
kind:
|
||||||
|
mir::StatementKind::Assign(box (
|
||||||
|
_,
|
||||||
|
mir::Rvalue::Use(mir::Operand::Copy(place)),
|
||||||
|
)),
|
||||||
|
}) = self.body[location.block].statements.get(location.statement_index)
|
||||||
|
{
|
||||||
|
self.body.local_decls[place.local].source_info.span
|
||||||
|
} else {
|
||||||
|
self.body.source_info(location).span
|
||||||
|
}
|
||||||
|
});
|
||||||
|
match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) {
|
||||||
|
// on for loops, RHS points to the iterator part
|
||||||
|
Some(DesugaringKind::ForLoop) => {
|
||||||
|
self.suggest_similar_mut_method_for_for_loop(err);
|
||||||
|
err.span_label(
|
||||||
|
opt_assignment_rhs_span.unwrap(),
|
||||||
|
format!("this iterator yields `{pointer_sigil}` {pointer_desc}s",),
|
||||||
|
);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
// don't create labels for compiler-generated spans
|
||||||
|
Some(_) => None,
|
||||||
|
None => {
|
||||||
|
let label = if name != kw::SelfLower {
|
||||||
|
suggest_ampmut(
|
||||||
|
self.infcx.tcx,
|
||||||
|
local_decl.ty,
|
||||||
|
decl_span,
|
||||||
|
opt_assignment_rhs_span,
|
||||||
|
opt_ty_info,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
match local_decl.local_info() {
|
||||||
|
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
|
||||||
|
opt_ty_info: None,
|
||||||
|
..
|
||||||
|
})) => {
|
||||||
|
let sugg = suggest_ampmut_self(self.infcx.tcx, decl_span);
|
||||||
|
(true, decl_span, sugg)
|
||||||
|
}
|
||||||
|
// explicit self (eg `self: &'a Self`)
|
||||||
|
_ => suggest_ampmut(
|
||||||
|
self.infcx.tcx,
|
||||||
|
local_decl.ty,
|
||||||
|
decl_span,
|
||||||
|
opt_assignment_rhs_span,
|
||||||
|
opt_ty_info,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Some(label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
|
||||||
|
binding_mode: ty::BindingMode::BindByReference(_),
|
||||||
|
..
|
||||||
|
})) => {
|
||||||
|
let pattern_span: Span = local_decl.source_info.span;
|
||||||
|
suggest_ref_mut(self.infcx.tcx, pattern_span)
|
||||||
|
.map(|span| (true, span, "mut ".to_owned()))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
match label {
|
||||||
|
Some((true, err_help_span, suggested_code)) => {
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
err_help_span,
|
||||||
|
format!("consider changing this to be a mutable {pointer_desc}"),
|
||||||
|
suggested_code,
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Some((false, err_label_span, message)) => {
|
||||||
|
struct BindingFinder {
|
||||||
|
span: Span,
|
||||||
|
hir_id: Option<hir::HirId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> Visitor<'tcx> for BindingFinder {
|
||||||
|
fn visit_stmt(&mut self, s: &'tcx hir::Stmt<'tcx>) {
|
||||||
|
if let hir::StmtKind::Local(local) = s.kind {
|
||||||
|
if local.pat.span == self.span {
|
||||||
|
self.hir_id = Some(local.hir_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hir::intravisit::walk_stmt(self, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let hir_map = self.infcx.tcx.hir();
|
||||||
|
let def_id = self.body.source.def_id();
|
||||||
|
let hir_id = hir_map.local_def_id_to_hir_id(def_id.expect_local());
|
||||||
|
let node = hir_map.find(hir_id);
|
||||||
|
let hir_id = if let Some(hir::Node::Item(item)) = node
|
||||||
|
&& let hir::ItemKind::Fn(.., body_id) = item.kind
|
||||||
|
{
|
||||||
|
let body = hir_map.body(body_id);
|
||||||
|
let mut v = BindingFinder {
|
||||||
|
span: err_label_span,
|
||||||
|
hir_id: None,
|
||||||
|
};
|
||||||
|
v.visit_body(body);
|
||||||
|
v.hir_id
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
if let Some(hir_id) = hir_id
|
||||||
|
&& let Some(hir::Node::Local(local)) = hir_map.find(hir_id)
|
||||||
|
{
|
||||||
|
let (changing, span, sugg) = match local.ty {
|
||||||
|
Some(ty) => ("changing", ty.span, message),
|
||||||
|
None => (
|
||||||
|
"specifying",
|
||||||
|
local.pat.span.shrink_to_hi(),
|
||||||
|
format!(": {message}"),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
span,
|
||||||
|
format!("consider {changing} this binding's type"),
|
||||||
|
sugg,
|
||||||
|
Applicability::HasPlaceholders,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
err.span_label(
|
||||||
|
err_label_span,
|
||||||
|
format!(
|
||||||
|
"consider changing this binding's type to be: `{message}`"
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symbol>) -> bool {
|
pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symbol>) -> bool {
|
||||||
|
@ -1160,14 +1167,8 @@ pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn suggest_ampmut_self<'tcx>(
|
fn suggest_ampmut_self<'tcx>(tcx: TyCtxt<'tcx>, span: Span) -> String {
|
||||||
tcx: TyCtxt<'tcx>,
|
match tcx.sess.source_map().span_to_snippet(span) {
|
||||||
local_decl: &mir::LocalDecl<'tcx>,
|
|
||||||
) -> (Span, String) {
|
|
||||||
let sp = local_decl.source_info.span;
|
|
||||||
(
|
|
||||||
sp,
|
|
||||||
match tcx.sess.source_map().span_to_snippet(sp) {
|
|
||||||
Ok(snippet) => {
|
Ok(snippet) => {
|
||||||
let lt_pos = snippet.find('\'');
|
let lt_pos = snippet.find('\'');
|
||||||
if let Some(lt_pos) = lt_pos {
|
if let Some(lt_pos) = lt_pos {
|
||||||
|
@ -1177,8 +1178,7 @@ fn suggest_ampmut_self<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => "&mut self".to_string(),
|
_ => "&mut self".to_string(),
|
||||||
},
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we want to suggest a user change a local variable to be a `&mut`, there
|
// When we want to suggest a user change a local variable to be a `&mut`, there
|
||||||
|
@ -1198,15 +1198,24 @@ fn suggest_ampmut_self<'tcx>(
|
||||||
// by trying (3.), then (2.) and finally falling back on (1.).
|
// by trying (3.), then (2.) and finally falling back on (1.).
|
||||||
fn suggest_ampmut<'tcx>(
|
fn suggest_ampmut<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
local_decl: &mir::LocalDecl<'tcx>,
|
decl_ty: Ty<'tcx>,
|
||||||
|
decl_span: Span,
|
||||||
opt_assignment_rhs_span: Option<Span>,
|
opt_assignment_rhs_span: Option<Span>,
|
||||||
opt_ty_info: Option<Span>,
|
opt_ty_info: Option<Span>,
|
||||||
) -> (bool, Span, String) {
|
) -> (bool, Span, String) {
|
||||||
|
// if there is a RHS and it starts with a `&` from it, then check if it is
|
||||||
|
// mutable, and if not, put suggest putting `mut ` to make it mutable.
|
||||||
|
// we don't have to worry about lifetime annotations here because they are
|
||||||
|
// not valid when taking a reference. For example, the following is not valid Rust:
|
||||||
|
//
|
||||||
|
// let x: &i32 = &'a 5;
|
||||||
|
// ^^ lifetime annotation not allowed
|
||||||
|
//
|
||||||
if let Some(assignment_rhs_span) = opt_assignment_rhs_span
|
if let Some(assignment_rhs_span) = opt_assignment_rhs_span
|
||||||
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
|
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
|
||||||
|
&& let Some(stripped) = src.strip_prefix('&')
|
||||||
{
|
{
|
||||||
let is_mutbl = |ty: &str| -> bool {
|
let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") {
|
||||||
if let Some(rest) = ty.strip_prefix("mut") {
|
|
||||||
match rest.chars().next() {
|
match rest.chars().next() {
|
||||||
// e.g. `&mut x`
|
// e.g. `&mut x`
|
||||||
Some(c) if c.is_whitespace() => true,
|
Some(c) if c.is_whitespace() => true,
|
||||||
|
@ -1219,52 +1228,60 @@ fn suggest_ampmut<'tcx>(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if let (true, Some(ws_pos)) = (src.starts_with("&'"), src.find(char::is_whitespace)) {
|
// if the reference is already mutable then there is nothing we can do
|
||||||
let lt_name = &src[1..ws_pos];
|
// here.
|
||||||
let ty = src[ws_pos..].trim_start();
|
if !is_mut {
|
||||||
if !is_mutbl(ty) {
|
let span = assignment_rhs_span;
|
||||||
return (true, assignment_rhs_span, format!("&{lt_name} mut {ty}"));
|
// shrink the span to just after the `&` in `&variable`
|
||||||
}
|
let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo();
|
||||||
} else if let Some(stripped) = src.strip_prefix('&') {
|
|
||||||
let stripped = stripped.trim_start();
|
// FIXME(Ezrashaw): returning is bad because we still might want to
|
||||||
if !is_mutbl(stripped) {
|
// update the annotated type, see #106857.
|
||||||
return (true, assignment_rhs_span, format!("&mut {stripped}"));
|
return (true, span, "mut ".to_owned());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (suggestibility, highlight_span) = match opt_ty_info {
|
let (binding_exists, span) = match opt_ty_info {
|
||||||
// if this is a variable binding with an explicit type,
|
// if this is a variable binding with an explicit type,
|
||||||
// try to highlight that for the suggestion.
|
// then we will suggest changing it to be mutable.
|
||||||
|
// this is `Applicability::MachineApplicable`.
|
||||||
Some(ty_span) => (true, ty_span),
|
Some(ty_span) => (true, ty_span),
|
||||||
|
|
||||||
// otherwise, just highlight the span associated with
|
// otherwise, we'll suggest *adding* an annotated type, we'll suggest
|
||||||
// the (MIR) LocalDecl.
|
// the RHS's type for that.
|
||||||
None => (false, local_decl.source_info.span),
|
// this is `Applicability::HasPlaceholders`.
|
||||||
|
None => (false, decl_span),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(src) = tcx.sess.source_map().span_to_snippet(highlight_span)
|
// if the binding already exists and is a reference with a explicit
|
||||||
&& let (true, Some(ws_pos)) = (src.starts_with("&'"), src.find(char::is_whitespace))
|
// lifetime, then we can suggest adding ` mut`. this is special-cased from
|
||||||
|
// the path without a explicit lifetime.
|
||||||
|
if let Ok(src) = tcx.sess.source_map().span_to_snippet(span)
|
||||||
|
&& src.starts_with("&'")
|
||||||
|
// note that `& 'a T` is invalid so this is correct.
|
||||||
|
&& let Some(ws_pos) = src.find(char::is_whitespace)
|
||||||
{
|
{
|
||||||
let lt_name = &src[1..ws_pos];
|
let span = span.with_lo(span.lo() + BytePos(ws_pos as u32)).shrink_to_lo();
|
||||||
let ty = &src[ws_pos..];
|
(true, span, " mut".to_owned())
|
||||||
return (true, highlight_span, format!("&{lt_name} mut{ty}"));
|
// if there is already a binding, we modify it to be `mut`
|
||||||
}
|
} else if binding_exists {
|
||||||
|
// shrink the span to just after the `&` in `&variable`
|
||||||
let ty_mut = local_decl.ty.builtin_deref(true).unwrap();
|
let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo();
|
||||||
assert_eq!(ty_mut.mutbl, hir::Mutability::Not);
|
(true, span, "mut ".to_owned())
|
||||||
(
|
|
||||||
suggestibility,
|
|
||||||
highlight_span,
|
|
||||||
if local_decl.ty.is_ref() {
|
|
||||||
format!("&mut {}", ty_mut.ty)
|
|
||||||
} else {
|
} else {
|
||||||
format!("*mut {}", ty_mut.ty)
|
// otherwise, suggest that the user annotates the binding; we provide the
|
||||||
},
|
// type of the local.
|
||||||
|
let ty_mut = decl_ty.builtin_deref(true).unwrap();
|
||||||
|
assert_eq!(ty_mut.mutbl, hir::Mutability::Not);
|
||||||
|
|
||||||
|
(
|
||||||
|
false,
|
||||||
|
span,
|
||||||
|
format!("{}mut {}", if decl_ty.is_ref() {"&"} else {"*"}, ty_mut.ty)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn is_closure_or_generator(ty: Ty<'_>) -> bool {
|
fn is_closure_or_generator(ty: Ty<'_>) -> bool {
|
||||||
ty.is_closure() || ty.is_generator()
|
ty.is_closure() || ty.is_generator()
|
||||||
|
@ -1300,11 +1317,13 @@ fn get_mut_span_in_struct_field<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If possible, suggest replacing `ref` with `ref mut`.
|
/// If possible, suggest replacing `ref` with `ref mut`.
|
||||||
fn suggest_ref_mut(tcx: TyCtxt<'_>, binding_span: Span) -> Option<String> {
|
fn suggest_ref_mut(tcx: TyCtxt<'_>, span: Span) -> Option<Span> {
|
||||||
let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).ok()?;
|
let pattern_str = tcx.sess.source_map().span_to_snippet(span).ok()?;
|
||||||
if hi_src.starts_with("ref") && hi_src["ref".len()..].starts_with(rustc_lexer::is_whitespace) {
|
if pattern_str.starts_with("ref")
|
||||||
let replacement = format!("ref mut{}", &hi_src["ref".len()..]);
|
&& pattern_str["ref".len()..].starts_with(rustc_lexer::is_whitespace)
|
||||||
Some(replacement)
|
{
|
||||||
|
let span = span.with_lo(span.lo() + BytePos(4)).shrink_to_lo();
|
||||||
|
Some(span)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,10 +150,6 @@ builtin_macros_format_pos_mismatch = {$n} positional {$n ->
|
||||||
*[more] arguments
|
*[more] arguments
|
||||||
} in format string, but {$desc}
|
} in format string, but {$desc}
|
||||||
|
|
||||||
builtin_macros_offset_of_expected_field = expected field
|
|
||||||
|
|
||||||
builtin_macros_offset_of_expected_two_args = expected 2 arguments
|
|
||||||
|
|
||||||
builtin_macros_test_case_non_item = `#[test_case]` attribute is only allowed on items
|
builtin_macros_test_case_non_item = `#[test_case]` attribute is only allowed on items
|
||||||
|
|
||||||
builtin_macros_test_bad_fn = {$kind} functions cannot be used for tests
|
builtin_macros_test_bad_fn = {$kind} functions cannot be used for tests
|
||||||
|
|
|
@ -44,7 +44,6 @@ mod format;
|
||||||
mod format_foreign;
|
mod format_foreign;
|
||||||
mod global_allocator;
|
mod global_allocator;
|
||||||
mod log_syntax;
|
mod log_syntax;
|
||||||
mod offset_of;
|
|
||||||
mod source_util;
|
mod source_util;
|
||||||
mod test;
|
mod test;
|
||||||
mod trace_macros;
|
mod trace_macros;
|
||||||
|
@ -92,7 +91,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
|
||||||
line: source_util::expand_line,
|
line: source_util::expand_line,
|
||||||
log_syntax: log_syntax::expand_log_syntax,
|
log_syntax: log_syntax::expand_log_syntax,
|
||||||
module_path: source_util::expand_mod,
|
module_path: source_util::expand_mod,
|
||||||
offset_of: offset_of::expand_offset_of,
|
|
||||||
option_env: env::expand_option_env,
|
option_env: env::expand_option_env,
|
||||||
core_panic: edition_panic::expand_panic,
|
core_panic: edition_panic::expand_panic,
|
||||||
std_panic: edition_panic::expand_panic,
|
std_panic: edition_panic::expand_panic,
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
use rustc_ast as ast;
|
|
||||||
use rustc_ast::ptr::P;
|
|
||||||
use rustc_ast::token;
|
|
||||||
use rustc_ast::tokenstream::TokenStream;
|
|
||||||
use rustc_errors::PResult;
|
|
||||||
use rustc_expand::base::{self, *};
|
|
||||||
use rustc_macros::Diagnostic;
|
|
||||||
use rustc_parse::parser::Parser;
|
|
||||||
use rustc_span::{symbol::Ident, Span};
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(builtin_macros_offset_of_expected_field)]
|
|
||||||
struct ExpectedField {
|
|
||||||
#[primary_span]
|
|
||||||
span: Span,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(builtin_macros_offset_of_expected_two_args)]
|
|
||||||
struct ExpectedTwoArgs {
|
|
||||||
#[primary_span]
|
|
||||||
span: Span,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_field<'a>(cx: &ExtCtxt<'a>, p: &mut Parser<'a>) -> PResult<'a, Ident> {
|
|
||||||
let token = p.token.uninterpolate();
|
|
||||||
let field = match token.kind {
|
|
||||||
token::Ident(name, _) => Ident::new(name, token.span),
|
|
||||||
token::Literal(token::Lit { kind: token::Integer, symbol, suffix: None }) => {
|
|
||||||
Ident::new(symbol, token.span)
|
|
||||||
}
|
|
||||||
_ => return Err(cx.create_err(ExpectedField { span: p.token.span })),
|
|
||||||
};
|
|
||||||
|
|
||||||
p.bump();
|
|
||||||
|
|
||||||
Ok(field)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_args<'a>(
|
|
||||||
cx: &mut ExtCtxt<'a>,
|
|
||||||
sp: Span,
|
|
||||||
tts: TokenStream,
|
|
||||||
) -> PResult<'a, (P<ast::Ty>, P<[Ident]>)> {
|
|
||||||
let mut p = cx.new_parser_from_tts(tts);
|
|
||||||
|
|
||||||
let container = p.parse_ty()?;
|
|
||||||
|
|
||||||
p.expect(&token::Comma)?;
|
|
||||||
|
|
||||||
if p.eat(&token::Eof) {
|
|
||||||
return Err(cx.create_err(ExpectedTwoArgs { span: sp }));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut fields = Vec::new();
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let field = parse_field(cx, &mut p)?;
|
|
||||||
fields.push(field);
|
|
||||||
|
|
||||||
if p.eat(&token::Dot) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.eat(&token::Comma);
|
|
||||||
|
|
||||||
if !p.eat(&token::Eof) {
|
|
||||||
return Err(cx.create_err(ExpectedTwoArgs { span: sp }));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((container, fields.into()))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn expand_offset_of<'cx>(
|
|
||||||
cx: &'cx mut ExtCtxt<'_>,
|
|
||||||
sp: Span,
|
|
||||||
tts: TokenStream,
|
|
||||||
) -> Box<dyn base::MacResult + 'cx> {
|
|
||||||
match parse_args(cx, sp, tts) {
|
|
||||||
Ok((container, fields)) => {
|
|
||||||
let expr = P(ast::Expr {
|
|
||||||
id: ast::DUMMY_NODE_ID,
|
|
||||||
kind: ast::ExprKind::OffsetOf(container, fields),
|
|
||||||
span: sp,
|
|
||||||
attrs: ast::AttrVec::new(),
|
|
||||||
tokens: None,
|
|
||||||
});
|
|
||||||
|
|
||||||
MacEager::expr(expr)
|
|
||||||
}
|
|
||||||
Err(mut err) => {
|
|
||||||
err.emit();
|
|
||||||
DummyResult::any(sp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,6 +12,7 @@ use object::{
|
||||||
|
|
||||||
use snap::write::FrameEncoder;
|
use snap::write::FrameEncoder;
|
||||||
|
|
||||||
|
use object::elf::NT_GNU_PROPERTY_TYPE_0;
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::owned_slice::try_slice_owned;
|
use rustc_data_structures::owned_slice::try_slice_owned;
|
||||||
use rustc_data_structures::sync::MetadataRef;
|
use rustc_data_structures::sync::MetadataRef;
|
||||||
|
@ -93,6 +94,54 @@ pub(super) fn search_for_section<'a>(
|
||||||
.map_err(|e| format!("failed to read {} section in '{}': {}", section, path.display(), e))
|
.map_err(|e| format!("failed to read {} section in '{}': {}", section, path.display(), e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_gnu_property_note(
|
||||||
|
file: &mut write::Object<'static>,
|
||||||
|
architecture: Architecture,
|
||||||
|
binary_format: BinaryFormat,
|
||||||
|
endianness: Endianness,
|
||||||
|
) {
|
||||||
|
// check bti protection
|
||||||
|
if binary_format != BinaryFormat::Elf
|
||||||
|
|| !matches!(architecture, Architecture::X86_64 | Architecture::Aarch64)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let section = file.add_section(
|
||||||
|
file.segment_name(StandardSegment::Data).to_vec(),
|
||||||
|
b".note.gnu.property".to_vec(),
|
||||||
|
SectionKind::Note,
|
||||||
|
);
|
||||||
|
let mut data: Vec<u8> = Vec::new();
|
||||||
|
let n_namsz: u32 = 4; // Size of the n_name field
|
||||||
|
let n_descsz: u32 = 16; // Size of the n_desc field
|
||||||
|
let n_type: u32 = NT_GNU_PROPERTY_TYPE_0; // Type of note descriptor
|
||||||
|
let header_values = [n_namsz, n_descsz, n_type];
|
||||||
|
header_values.iter().for_each(|v| {
|
||||||
|
data.extend_from_slice(&match endianness {
|
||||||
|
Endianness::Little => v.to_le_bytes(),
|
||||||
|
Endianness::Big => v.to_be_bytes(),
|
||||||
|
})
|
||||||
|
});
|
||||||
|
data.extend_from_slice(b"GNU\0"); // Owner of the program property note
|
||||||
|
let pr_type: u32 = match architecture {
|
||||||
|
Architecture::X86_64 => 0xc0000002,
|
||||||
|
Architecture::Aarch64 => 0xc0000000,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
let pr_datasz: u32 = 4; //size of the pr_data field
|
||||||
|
let pr_data: u32 = 3; //program property descriptor
|
||||||
|
let pr_padding: u32 = 0;
|
||||||
|
let property_values = [pr_type, pr_datasz, pr_data, pr_padding];
|
||||||
|
property_values.iter().for_each(|v| {
|
||||||
|
data.extend_from_slice(&match endianness {
|
||||||
|
Endianness::Little => v.to_le_bytes(),
|
||||||
|
Endianness::Big => v.to_be_bytes(),
|
||||||
|
})
|
||||||
|
});
|
||||||
|
file.append_section_data(section, &data, 8);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
|
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
|
||||||
let endianness = match sess.target.options.endian {
|
let endianness = match sess.target.options.endian {
|
||||||
Endian::Little => Endianness::Little,
|
Endian::Little => Endianness::Little,
|
||||||
|
@ -205,6 +254,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
|
||||||
_ => elf::ELFOSABI_NONE,
|
_ => elf::ELFOSABI_NONE,
|
||||||
};
|
};
|
||||||
let abi_version = 0;
|
let abi_version = 0;
|
||||||
|
add_gnu_property_note(&mut file, architecture, binary_format, endianness);
|
||||||
file.flags = FileFlags::Elf { os_abi, abi_version, e_flags };
|
file.flags = FileFlags::Elf { os_abi, abi_version, e_flags };
|
||||||
Some(file)
|
Some(file)
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,9 +109,11 @@ impl Borrow<[u8]> for OwnedSlice {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Box<dyn Send + Sync>)`, which is `Send`
|
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Box<dyn Send + Sync>)`, which is `Send`
|
||||||
|
#[cfg(parallel_compiler)]
|
||||||
unsafe impl Send for OwnedSlice {}
|
unsafe impl Send for OwnedSlice {}
|
||||||
|
|
||||||
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Box<dyn Send + Sync>)`, which is `Sync`
|
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Box<dyn Send + Sync>)`, which is `Sync`
|
||||||
|
#[cfg(parallel_compiler)]
|
||||||
unsafe impl Sync for OwnedSlice {}
|
unsafe impl Sync for OwnedSlice {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -313,6 +313,8 @@ declare_features! (
|
||||||
(active, async_closure, "1.37.0", Some(62290), None),
|
(active, async_closure, "1.37.0", Some(62290), None),
|
||||||
/// Allows async functions to be declared, implemented, and used in traits.
|
/// Allows async functions to be declared, implemented, and used in traits.
|
||||||
(active, async_fn_in_trait, "1.66.0", Some(91611), None),
|
(active, async_fn_in_trait, "1.66.0", Some(91611), None),
|
||||||
|
/// Allows builtin # foo() syntax
|
||||||
|
(active, builtin_syntax, "CURRENT_RUSTC_VERSION", Some(110680), None),
|
||||||
/// Allows `c"foo"` literals.
|
/// Allows `c"foo"` literals.
|
||||||
(active, c_str_literals, "CURRENT_RUSTC_VERSION", Some(105723), None),
|
(active, c_str_literals, "CURRENT_RUSTC_VERSION", Some(105723), None),
|
||||||
/// Treat `extern "C"` function as nounwind.
|
/// Treat `extern "C"` function as nounwind.
|
||||||
|
|
|
@ -279,6 +279,9 @@ hir_analysis_specialization_trait = implementing `rustc_specialization_trait` tr
|
||||||
hir_analysis_closure_implicit_hrtb = implicit types in closure signatures are forbidden when `for<...>` is present
|
hir_analysis_closure_implicit_hrtb = implicit types in closure signatures are forbidden when `for<...>` is present
|
||||||
.label = `for<...>` is here
|
.label = `for<...>` is here
|
||||||
|
|
||||||
|
hir_analysis_empty_specialization = specialization impl does not specialize any associated items
|
||||||
|
.note = impl is a specialization of this impl
|
||||||
|
|
||||||
hir_analysis_const_specialize = cannot specialize on const impl with non-const impl
|
hir_analysis_const_specialize = cannot specialize on const impl with non-const impl
|
||||||
|
|
||||||
hir_analysis_static_specialize = cannot specialize on `'static` lifetime
|
hir_analysis_static_specialize = cannot specialize on `'static` lifetime
|
||||||
|
|
|
@ -814,6 +814,15 @@ pub(crate) struct ClosureImplicitHrtb {
|
||||||
pub for_sp: Span,
|
pub for_sp: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_empty_specialization)]
|
||||||
|
pub(crate) struct EmptySpecialization {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[note]
|
||||||
|
pub base_impl_span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(hir_analysis_const_specialize)]
|
#[diag(hir_analysis_const_specialize)]
|
||||||
pub(crate) struct ConstSpecialize {
|
pub(crate) struct ConstSpecialize {
|
||||||
|
|
|
@ -80,7 +80,7 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
||||||
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
|
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::{self, translate_substs, wf, ObligationCtxt};
|
use rustc_trait_selection::traits::{self, translate_substs_with_cause, wf, ObligationCtxt};
|
||||||
|
|
||||||
pub(super) fn check_min_specialization(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) {
|
pub(super) fn check_min_specialization(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) {
|
||||||
if let Some(node) = parent_specialization_node(tcx, impl_def_id) {
|
if let Some(node) = parent_specialization_node(tcx, impl_def_id) {
|
||||||
|
@ -100,12 +100,19 @@ fn parent_specialization_node(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId) -> Opti
|
||||||
// Implementing a normal trait isn't a specialization.
|
// Implementing a normal trait isn't a specialization.
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
if trait_def.is_marker {
|
||||||
|
// Overlapping marker implementations are not really specializations.
|
||||||
|
return None;
|
||||||
|
}
|
||||||
Some(impl2_node)
|
Some(impl2_node)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check that `impl1` is a sound specialization
|
/// Check that `impl1` is a sound specialization
|
||||||
#[instrument(level = "debug", skip(tcx))]
|
#[instrument(level = "debug", skip(tcx))]
|
||||||
fn check_always_applicable(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node) {
|
fn check_always_applicable(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node) {
|
||||||
|
let span = tcx.def_span(impl1_def_id);
|
||||||
|
check_has_items(tcx, impl1_def_id, impl2_node, span);
|
||||||
|
|
||||||
if let Some((impl1_substs, impl2_substs)) = get_impl_substs(tcx, impl1_def_id, impl2_node) {
|
if let Some((impl1_substs, impl2_substs)) = get_impl_substs(tcx, impl1_def_id, impl2_node) {
|
||||||
let impl2_def_id = impl2_node.def_id();
|
let impl2_def_id = impl2_node.def_id();
|
||||||
debug!(?impl2_def_id, ?impl2_substs);
|
debug!(?impl2_def_id, ?impl2_substs);
|
||||||
|
@ -116,7 +123,6 @@ fn check_always_applicable(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node
|
||||||
unconstrained_parent_impl_substs(tcx, impl2_def_id, impl2_substs)
|
unconstrained_parent_impl_substs(tcx, impl2_def_id, impl2_substs)
|
||||||
};
|
};
|
||||||
|
|
||||||
let span = tcx.def_span(impl1_def_id);
|
|
||||||
check_constness(tcx, impl1_def_id, impl2_node, span);
|
check_constness(tcx, impl1_def_id, impl2_node, span);
|
||||||
check_static_lifetimes(tcx, &parent_substs, span);
|
check_static_lifetimes(tcx, &parent_substs, span);
|
||||||
check_duplicate_params(tcx, impl1_substs, &parent_substs, span);
|
check_duplicate_params(tcx, impl1_substs, &parent_substs, span);
|
||||||
|
@ -124,6 +130,13 @@ fn check_always_applicable(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_has_items(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node, span: Span) {
|
||||||
|
if let Node::Impl(impl2_id) = impl2_node && tcx.associated_item_def_ids(impl1_def_id).is_empty() {
|
||||||
|
let base_impl_span = tcx.def_span(impl2_id);
|
||||||
|
tcx.sess.emit_err(errors::EmptySpecialization { span, base_impl_span });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Check that the specializing impl `impl1` is at least as const as the base
|
/// Check that the specializing impl `impl1` is at least as const as the base
|
||||||
/// impl `impl2`
|
/// impl `impl2`
|
||||||
fn check_constness(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node, span: Span) {
|
fn check_constness(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node, span: Span) {
|
||||||
|
@ -167,8 +180,21 @@ fn get_impl_substs(
|
||||||
ocx.assumed_wf_types(param_env, tcx.def_span(impl1_def_id), impl1_def_id);
|
ocx.assumed_wf_types(param_env, tcx.def_span(impl1_def_id), impl1_def_id);
|
||||||
|
|
||||||
let impl1_substs = InternalSubsts::identity_for_item(tcx, impl1_def_id);
|
let impl1_substs = InternalSubsts::identity_for_item(tcx, impl1_def_id);
|
||||||
let impl2_substs =
|
let impl1_span = tcx.def_span(impl1_def_id);
|
||||||
translate_substs(infcx, param_env, impl1_def_id.to_def_id(), impl1_substs, impl2_node);
|
let impl2_substs = translate_substs_with_cause(
|
||||||
|
infcx,
|
||||||
|
param_env,
|
||||||
|
impl1_def_id.to_def_id(),
|
||||||
|
impl1_substs,
|
||||||
|
impl2_node,
|
||||||
|
|_, span| {
|
||||||
|
traits::ObligationCause::new(
|
||||||
|
impl1_span,
|
||||||
|
impl1_def_id,
|
||||||
|
traits::ObligationCauseCode::BindingObligation(impl2_node.def_id(), span),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let errors = ocx.select_all_or_error();
|
let errors = ocx.select_all_or_error();
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
|
|
|
@ -86,9 +86,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.emit_type_mismatch_suggestions(err, expr, expr_ty, expected, expected_ty_expr, error);
|
self.emit_type_mismatch_suggestions(err, expr, expr_ty, expected, expected_ty_expr, error);
|
||||||
self.note_type_is_not_clone(err, expected, expr_ty, expr);
|
self.note_type_is_not_clone(err, expected, expr_ty, expr);
|
||||||
self.note_internal_mutation_in_method(err, expr, Some(expected), expr_ty);
|
self.note_internal_mutation_in_method(err, expr, Some(expected), expr_ty);
|
||||||
self.check_for_range_as_method_call(err, expr, expr_ty, expected);
|
self.suggest_method_call_on_range_literal(err, expr, expr_ty, expected);
|
||||||
self.check_for_binding_assigned_block_without_tail_expression(err, expr, expr_ty, expected);
|
self.suggest_return_binding_for_missing_tail_expr(err, expr, expr_ty, expected);
|
||||||
self.check_wrong_return_type_due_to_generic_arg(err, expr, expr_ty);
|
self.note_wrong_return_ty_due_to_generic_arg(err, expr, expr_ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Requires that the two types unify, and prints an error message if
|
/// Requires that the two types unify, and prints an error message if
|
||||||
|
@ -1087,7 +1087,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
/// ```ignore (illustrative)
|
/// ```ignore (illustrative)
|
||||||
/// opt.map(|param| { takes_ref(param) });
|
/// opt.map(|param| { takes_ref(param) });
|
||||||
/// ```
|
/// ```
|
||||||
fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Span, &'static str, String)> {
|
fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Vec<(Span, String)>, &'static str)> {
|
||||||
let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.kind else {
|
let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.kind else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
@ -1133,12 +1133,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
match (is_as_ref_able, self.sess().source_map().span_to_snippet(method_path.ident.span)) {
|
if is_as_ref_able {
|
||||||
(true, Ok(src)) => {
|
Some((
|
||||||
let suggestion = format!("as_ref().{}", src);
|
vec![(method_path.ident.span.shrink_to_lo(), "as_ref().".to_string())],
|
||||||
Some((method_path.ident.span, "consider using `as_ref` instead", suggestion))
|
"consider using `as_ref` instead",
|
||||||
}
|
))
|
||||||
_ => None,
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,14 +1218,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
/// In addition of this check, it also checks between references mutability state. If the
|
/// In addition of this check, it also checks between references mutability state. If the
|
||||||
/// expected is mutable but the provided isn't, maybe we could just say "Hey, try with
|
/// expected is mutable but the provided isn't, maybe we could just say "Hey, try with
|
||||||
/// `&mut`!".
|
/// `&mut`!".
|
||||||
pub fn check_ref(
|
pub fn suggest_deref_or_ref(
|
||||||
&self,
|
&self,
|
||||||
expr: &hir::Expr<'tcx>,
|
expr: &hir::Expr<'tcx>,
|
||||||
checked_ty: Ty<'tcx>,
|
checked_ty: Ty<'tcx>,
|
||||||
expected: Ty<'tcx>,
|
expected: Ty<'tcx>,
|
||||||
) -> Option<(
|
) -> Option<(
|
||||||
Span,
|
Vec<(Span, String)>,
|
||||||
String,
|
|
||||||
String,
|
String,
|
||||||
Applicability,
|
Applicability,
|
||||||
bool, /* verbose */
|
bool, /* verbose */
|
||||||
|
@ -1256,9 +1256,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
{
|
{
|
||||||
let pos = sp.lo() + BytePos(1);
|
let pos = sp.lo() + BytePos(1);
|
||||||
return Some((
|
return Some((
|
||||||
sp.with_hi(pos),
|
vec![(sp.with_hi(pos), String::new())],
|
||||||
"consider removing the leading `b`".to_string(),
|
"consider removing the leading `b`".to_string(),
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -1271,9 +1270,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
&& replace_prefix(&src, "\"", "b\"").is_some()
|
&& replace_prefix(&src, "\"", "b\"").is_some()
|
||||||
{
|
{
|
||||||
return Some((
|
return Some((
|
||||||
sp.shrink_to_lo(),
|
vec![(sp.shrink_to_lo(), "b".to_string())],
|
||||||
"consider adding a leading `b`".to_string(),
|
"consider adding a leading `b`".to_string(),
|
||||||
"b".to_string(),
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -1320,21 +1318,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let hir::ExprKind::Unary(hir::UnOp::Deref, ref inner) = expr.kind
|
if let hir::ExprKind::Unary(hir::UnOp::Deref, ref inner) = expr.kind
|
||||||
&& let Some(1) = self.deref_steps(expected, checked_ty) {
|
&& let Some(1) = self.deref_steps(expected, checked_ty)
|
||||||
|
{
|
||||||
// We have `*&T`, check if what was expected was `&T`.
|
// We have `*&T`, check if what was expected was `&T`.
|
||||||
// If so, we may want to suggest removing a `*`.
|
// If so, we may want to suggest removing a `*`.
|
||||||
sugg_sp = sugg_sp.with_hi(inner.span.lo());
|
sugg_sp = sugg_sp.with_hi(inner.span.lo());
|
||||||
return Some((
|
return Some((
|
||||||
sugg_sp,
|
vec![(sugg_sp, String::new())],
|
||||||
"consider removing deref here".to_string(),
|
"consider removing deref here".to_string(),
|
||||||
"".to_string(),
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(src) = sm.span_to_snippet(sugg_sp) {
|
|
||||||
let needs_parens = match expr.kind {
|
let needs_parens = match expr.kind {
|
||||||
// parenthesize if needed (Issue #46756)
|
// parenthesize if needed (Issue #46756)
|
||||||
hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => true,
|
hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => true,
|
||||||
|
@ -1343,13 +1340,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(sugg) = self.can_use_as_ref(expr) {
|
if let Some((sugg, msg)) = self.can_use_as_ref(expr) {
|
||||||
return Some((
|
return Some((
|
||||||
sugg.0,
|
sugg,
|
||||||
sugg.1.to_string(),
|
msg.to_string(),
|
||||||
sugg.2,
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
false,
|
true,
|
||||||
false,
|
false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1370,18 +1366,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sugg_expr = if needs_parens { format!("({src})") } else { src };
|
let sugg = mutability.ref_prefix_str();
|
||||||
return Some((
|
let (sugg, verbose) = if needs_parens {
|
||||||
sp,
|
(
|
||||||
format!("consider {}borrowing here", mutability.mutably_str()),
|
vec![
|
||||||
format!("{prefix}{}{sugg_expr}", mutability.ref_prefix_str()),
|
(sp.shrink_to_lo(), format!("{prefix}{sugg}(")),
|
||||||
Applicability::MachineApplicable,
|
(sp.shrink_to_hi(), ")".to_string()),
|
||||||
|
],
|
||||||
false,
|
false,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(vec![(sp.shrink_to_lo(), format!("{prefix}{sugg}"))], true)
|
||||||
|
};
|
||||||
|
return Some((
|
||||||
|
sugg,
|
||||||
|
format!("consider {}borrowing here", mutability.mutably_str()),
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
verbose,
|
||||||
false,
|
false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
(
|
(
|
||||||
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr),
|
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr),
|
||||||
_,
|
_,
|
||||||
|
@ -1401,23 +1406,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
&& sm.is_span_accessible(call_span)
|
&& sm.is_span_accessible(call_span)
|
||||||
{
|
{
|
||||||
return Some((
|
return Some((
|
||||||
sp.with_hi(call_span.lo()),
|
vec![(sp.with_hi(call_span.lo()), String::new())],
|
||||||
"consider removing the borrow".to_string(),
|
"consider removing the borrow".to_string(),
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
true,
|
true,
|
||||||
true
|
true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if sp.contains(expr.span)
|
if sp.contains(expr.span) && sm.is_span_accessible(expr.span) {
|
||||||
&& sm.is_span_accessible(expr.span)
|
|
||||||
{
|
|
||||||
return Some((
|
return Some((
|
||||||
sp.with_hi(expr.span.lo()),
|
vec![(sp.with_hi(expr.span.lo()), String::new())],
|
||||||
"consider removing the borrow".to_string(),
|
"consider removing the borrow".to_string(),
|
||||||
String::new(),
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
@ -1441,23 +1442,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let suggestion = replace_prefix(&src, old_prefix, &new_prefix).map(|_| {
|
let suggestion = replace_prefix(&src, old_prefix, &new_prefix).map(|_| {
|
||||||
// skip `&` or `&mut ` if both mutabilities are mutable
|
// skip `&` or `&mut ` if both mutabilities are mutable
|
||||||
let lo = sp.lo() + BytePos(min(old_prefix.len(), mutbl_b.ref_prefix_str().len()) as _);
|
let lo = sp.lo()
|
||||||
|
+ BytePos(min(old_prefix.len(), mutbl_b.ref_prefix_str().len()) as _);
|
||||||
// skip `&` or `&mut `
|
// skip `&` or `&mut `
|
||||||
let hi = sp.lo() + BytePos(old_prefix.len() as _);
|
let hi = sp.lo() + BytePos(old_prefix.len() as _);
|
||||||
let sp = sp.with_lo(lo).with_hi(hi);
|
let sp = sp.with_lo(lo).with_hi(hi);
|
||||||
|
|
||||||
(
|
(
|
||||||
sp,
|
sp,
|
||||||
format!("{}{derefs}", if mutbl_a != mutbl_b { mutbl_b.prefix_str() } else { "" }),
|
format!(
|
||||||
if mutbl_b <= mutbl_a { Applicability::MachineApplicable } else { Applicability::MaybeIncorrect }
|
"{}{derefs}",
|
||||||
|
if mutbl_a != mutbl_b { mutbl_b.prefix_str() } else { "" }
|
||||||
|
),
|
||||||
|
if mutbl_b <= mutbl_a {
|
||||||
|
Applicability::MachineApplicable
|
||||||
|
} else {
|
||||||
|
Applicability::MaybeIncorrect
|
||||||
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some((span, src, applicability)) = suggestion {
|
if let Some((span, src, applicability)) = suggestion {
|
||||||
return Some((
|
return Some((
|
||||||
span,
|
vec![(span, src)],
|
||||||
"consider dereferencing".to_string(),
|
"consider dereferencing".to_string(),
|
||||||
src,
|
|
||||||
applicability,
|
applicability,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -1486,9 +1494,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// If we've reached our target type with just removing `&`, then just print now.
|
// If we've reached our target type with just removing `&`, then just print now.
|
||||||
if steps == 0 && !remove.trim().is_empty() {
|
if steps == 0 && !remove.trim().is_empty() {
|
||||||
return Some((
|
return Some((
|
||||||
prefix_span,
|
vec![(prefix_span, String::new())],
|
||||||
format!("consider removing the `{}`", remove.trim()),
|
format!("consider removing the `{}`", remove.trim()),
|
||||||
String::new(),
|
|
||||||
// Do not remove `&&` to get to bool, because it might be something like
|
// Do not remove `&&` to get to bool, because it might be something like
|
||||||
// { a } && b, which we have a separate fixup suggestion that is more
|
// { a } && b, which we have a separate fixup suggestion that is more
|
||||||
// likely correct...
|
// likely correct...
|
||||||
|
@ -1554,9 +1561,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some((
|
return Some((
|
||||||
span,
|
vec![(span, suggestion)],
|
||||||
message,
|
message,
|
||||||
suggestion,
|
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -1569,7 +1575,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_for_cast(
|
pub fn suggest_cast(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
expr: &hir::Expr<'_>,
|
expr: &hir::Expr<'_>,
|
||||||
|
@ -1936,7 +1942,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Identify when the user has written `foo..bar()` instead of `foo.bar()`.
|
/// Identify when the user has written `foo..bar()` instead of `foo.bar()`.
|
||||||
pub fn check_for_range_as_method_call(
|
pub fn suggest_method_call_on_range_literal(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
expr: &hir::Expr<'tcx>,
|
expr: &hir::Expr<'tcx>,
|
||||||
|
@ -2005,7 +2011,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
/// Identify when the type error is because `()` is found in a binding that was assigned a
|
/// Identify when the type error is because `()` is found in a binding that was assigned a
|
||||||
/// block without a tail expression.
|
/// block without a tail expression.
|
||||||
fn check_for_binding_assigned_block_without_tail_expression(
|
fn suggest_return_binding_for_missing_tail_expr(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
expr: &hir::Expr<'_>,
|
expr: &hir::Expr<'_>,
|
||||||
|
@ -2047,7 +2053,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_wrong_return_type_due_to_generic_arg(
|
fn note_wrong_return_ty_due_to_generic_arg(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
expr: &hir::Expr<'_>,
|
expr: &hir::Expr<'_>,
|
||||||
|
|
|
@ -275,13 +275,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
|
expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let expr = expr.peel_blocks();
|
let expr = expr.peel_blocks();
|
||||||
if let Some((sp, msg, suggestion, applicability, verbose, annotation)) =
|
if let Some((suggestion, msg, applicability, verbose, annotation)) =
|
||||||
self.check_ref(expr, found, expected)
|
self.suggest_deref_or_ref(expr, found, expected)
|
||||||
{
|
{
|
||||||
if verbose {
|
if verbose {
|
||||||
err.span_suggestion_verbose(sp, msg, suggestion, applicability);
|
err.multipart_suggestion_verbose(msg, suggestion, applicability);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion(sp, msg, suggestion, applicability);
|
err.multipart_suggestion(msg, suggestion, applicability);
|
||||||
}
|
}
|
||||||
if annotation {
|
if annotation {
|
||||||
let suggest_annotation = match expr.peel_drop_temps().kind {
|
let suggest_annotation = match expr.peel_drop_temps().kind {
|
||||||
|
@ -343,7 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
err.span_label(sp, format!("{descr} `{name}` defined here"));
|
err.span_label(sp, format!("{descr} `{name}` defined here"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if self.check_for_cast(err, expr, found, expected, expected_ty_expr) {
|
} else if self.suggest_cast(err, expr, found, expected, expected_ty_expr) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);
|
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_for_inner_self(&mut err, source, rcvr_ty, item_name);
|
self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name);
|
||||||
|
|
||||||
bound_spans.sort();
|
bound_spans.sort();
|
||||||
bound_spans.dedup();
|
bound_spans.dedup();
|
||||||
|
@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_for_deref_method(&mut err, source, rcvr_ty, item_name, expected);
|
self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected);
|
||||||
return Some(err);
|
return Some(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1805,7 +1805,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_for_inner_self(
|
fn suggest_unwrapping_inner_self(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
source: SelfSource<'tcx>,
|
source: SelfSource<'tcx>,
|
||||||
|
@ -2175,7 +2175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_for_deref_method(
|
fn note_derefed_ty_has_method(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
self_source: SelfSource<'tcx>,
|
self_source: SelfSource<'tcx>,
|
||||||
|
|
|
@ -140,7 +140,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
/// ```fluent
|
/// ```fluent
|
||||||
/// parser_expected_identifier = expected identifier
|
/// parser_expected_identifier = expected identifier
|
||||||
///
|
///
|
||||||
/// parser_expected_identifier-found = expected identifier, found {$found}
|
/// parser_expected_identifier_found = expected identifier, found {$found}
|
||||||
///
|
///
|
||||||
/// parser_raw_identifier = escape `{$ident}` to use it as an identifier
|
/// parser_raw_identifier = escape `{$ident}` to use it as an identifier
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -2728,8 +2728,6 @@ pub struct UserTypeProjection {
|
||||||
pub projs: Vec<ProjectionKind>,
|
pub projs: Vec<ProjectionKind>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for ProjectionKind {}
|
|
||||||
|
|
||||||
impl UserTypeProjection {
|
impl UserTypeProjection {
|
||||||
pub(crate) fn index(mut self) -> Self {
|
pub(crate) fn index(mut self) -> Self {
|
||||||
self.projs.push(ProjectionElem::Index(()));
|
self.projs.push(ProjectionElem::Index(()));
|
||||||
|
|
|
@ -257,6 +257,10 @@ parse_invalid_literal_suffix_on_tuple_index = suffixes on a tuple index are inva
|
||||||
.tuple_exception_line_2 = on proc macros, you'll want to use `syn::Index::from` or `proc_macro::Literal::*_unsuffixed` for code that will desugar to tuple field access
|
.tuple_exception_line_2 = on proc macros, you'll want to use `syn::Index::from` or `proc_macro::Literal::*_unsuffixed` for code that will desugar to tuple field access
|
||||||
.tuple_exception_line_3 = see issue #60210 <https://github.com/rust-lang/rust/issues/60210> for more information
|
.tuple_exception_line_3 = see issue #60210 <https://github.com/rust-lang/rust/issues/60210> for more information
|
||||||
|
|
||||||
|
parse_expected_builtin_ident = expected identifier after `builtin #`
|
||||||
|
|
||||||
|
parse_unknown_builtin_construct = unknown `builtin #` construct `{$name}`
|
||||||
|
|
||||||
parse_non_string_abi_literal = non-string ABI literal
|
parse_non_string_abi_literal = non-string ABI literal
|
||||||
.suggestion = specify the ABI with a string literal
|
.suggestion = specify the ABI with a string literal
|
||||||
|
|
||||||
|
@ -339,6 +343,7 @@ parse_expected_identifier = expected identifier
|
||||||
parse_sugg_escape_identifier = escape `{$ident_name}` to use it as an identifier
|
parse_sugg_escape_identifier = escape `{$ident_name}` to use it as an identifier
|
||||||
|
|
||||||
parse_sugg_remove_comma = remove this comma
|
parse_sugg_remove_comma = remove this comma
|
||||||
|
parse_sugg_add_let_for_stmt = you might have meant to introduce a new binding
|
||||||
|
|
||||||
parse_expected_semi_found_reserved_identifier_str = expected `;`, found reserved identifier `{$token}`
|
parse_expected_semi_found_reserved_identifier_str = expected `;`, found reserved identifier `{$token}`
|
||||||
parse_expected_semi_found_keyword_str = expected `;`, found keyword `{$token}`
|
parse_expected_semi_found_keyword_str = expected `;`, found keyword `{$token}`
|
||||||
|
|
|
@ -906,6 +906,18 @@ pub(crate) struct SuggRemoveComma {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[suggestion(
|
||||||
|
parse_sugg_add_let_for_stmt,
|
||||||
|
style = "verbose",
|
||||||
|
applicability = "maybe-incorrect",
|
||||||
|
code = "let "
|
||||||
|
)]
|
||||||
|
pub(crate) struct SuggAddMissingLetStmt {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub(crate) enum ExpectedIdentifierFound {
|
pub(crate) enum ExpectedIdentifierFound {
|
||||||
#[label(parse_expected_identifier_found_reserved_identifier)]
|
#[label(parse_expected_identifier_found_reserved_identifier)]
|
||||||
|
@ -2644,3 +2656,18 @@ pub(crate) struct MalformedCfgAttr {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub sugg: &'static str,
|
pub sugg: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_unknown_builtin_construct)]
|
||||||
|
pub(crate) struct UnknownBuiltinConstruct {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub name: Symbol,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_expected_builtin_ident)]
|
||||||
|
pub(crate) struct ExpectedBuiltinIdent {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::errors::{
|
||||||
IncorrectUseOfAwait, ParenthesesInForHead, ParenthesesInForHeadSugg,
|
IncorrectUseOfAwait, ParenthesesInForHead, ParenthesesInForHeadSugg,
|
||||||
PatternMethodParamWithoutBody, QuestionMarkInType, QuestionMarkInTypeSugg, SelfParamNotFirst,
|
PatternMethodParamWithoutBody, QuestionMarkInType, QuestionMarkInTypeSugg, SelfParamNotFirst,
|
||||||
StructLiteralBodyWithoutPath, StructLiteralBodyWithoutPathSugg, StructLiteralNeedingParens,
|
StructLiteralBodyWithoutPath, StructLiteralBodyWithoutPathSugg, StructLiteralNeedingParens,
|
||||||
StructLiteralNeedingParensSugg, SuggEscapeIdentifier, SuggRemoveComma,
|
StructLiteralNeedingParensSugg, SuggAddMissingLetStmt, SuggEscapeIdentifier, SuggRemoveComma,
|
||||||
UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
|
UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
|
||||||
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead,
|
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead,
|
||||||
};
|
};
|
||||||
|
@ -32,8 +32,8 @@ use rustc_ast::{
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed,
|
pluralize, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticMessage,
|
||||||
FatalError, Handler, IntoDiagnostic, MultiSpan, PResult,
|
ErrorGuaranteed, FatalError, Handler, IntoDiagnostic, MultiSpan, PResult,
|
||||||
};
|
};
|
||||||
use rustc_session::errors::ExprParenthesesNeeded;
|
use rustc_session::errors::ExprParenthesesNeeded;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
|
@ -1006,6 +1006,31 @@ impl<'a> Parser<'a> {
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Suggest add the missing `let` before the identifier in stmt
|
||||||
|
/// `a: Ty = 1` -> `let a: Ty = 1`
|
||||||
|
pub(super) fn suggest_add_missing_let_for_stmt(
|
||||||
|
&mut self,
|
||||||
|
err: &mut DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||||
|
) {
|
||||||
|
if self.token == token::Colon {
|
||||||
|
let prev_span = self.prev_token.span.shrink_to_lo();
|
||||||
|
let snapshot = self.create_snapshot_for_diagnostic();
|
||||||
|
self.bump();
|
||||||
|
match self.parse_ty() {
|
||||||
|
Ok(_) => {
|
||||||
|
if self.token == token::Eq {
|
||||||
|
let sugg = SuggAddMissingLetStmt { span: prev_span };
|
||||||
|
sugg.add_to_diagnostic(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
e.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.restore_snapshot(snapshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Check to see if a pair of chained operators looks like an attempt at chained comparison,
|
/// Check to see if a pair of chained operators looks like an attempt at chained comparison,
|
||||||
/// e.g. `1 < x <= 3`. If so, suggest either splitting the comparison into two, or
|
/// e.g. `1 < x <= 3`. If so, suggest either splitting the comparison into two, or
|
||||||
/// parenthesising the leftmost comparison.
|
/// parenthesising the leftmost comparison.
|
||||||
|
|
|
@ -1300,6 +1300,8 @@ impl<'a> Parser<'a> {
|
||||||
})
|
})
|
||||||
} else if self.check(&token::OpenDelim(Delimiter::Bracket)) {
|
} else if self.check(&token::OpenDelim(Delimiter::Bracket)) {
|
||||||
self.parse_expr_array_or_repeat(Delimiter::Bracket)
|
self.parse_expr_array_or_repeat(Delimiter::Bracket)
|
||||||
|
} else if self.is_builtin() {
|
||||||
|
self.parse_expr_builtin()
|
||||||
} else if self.check_path() {
|
} else if self.check_path() {
|
||||||
self.parse_expr_path_start()
|
self.parse_expr_path_start()
|
||||||
} else if self.check_keyword(kw::Move)
|
} else if self.check_keyword(kw::Move)
|
||||||
|
@ -1766,6 +1768,61 @@ impl<'a> Parser<'a> {
|
||||||
self.maybe_recover_from_bad_qpath(expr)
|
self.maybe_recover_from_bad_qpath(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parse `builtin # ident(args,*)`.
|
||||||
|
fn parse_expr_builtin(&mut self) -> PResult<'a, P<Expr>> {
|
||||||
|
self.parse_builtin(|this, lo, ident| {
|
||||||
|
if ident.name == sym::offset_of {
|
||||||
|
return Ok(Some(this.parse_expr_offset_of(lo)?));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn parse_builtin<T>(
|
||||||
|
&mut self,
|
||||||
|
parse: impl FnOnce(&mut Parser<'a>, Span, Ident) -> PResult<'a, Option<T>>,
|
||||||
|
) -> PResult<'a, T> {
|
||||||
|
let lo = self.token.span;
|
||||||
|
|
||||||
|
self.bump(); // `builtin`
|
||||||
|
self.bump(); // `#`
|
||||||
|
|
||||||
|
let Some((ident, false)) = self.token.ident() else {
|
||||||
|
let err = errors::ExpectedBuiltinIdent { span: self.token.span }
|
||||||
|
.into_diagnostic(&self.sess.span_diagnostic);
|
||||||
|
return Err(err);
|
||||||
|
};
|
||||||
|
self.sess.gated_spans.gate(sym::builtin_syntax, ident.span);
|
||||||
|
self.bump();
|
||||||
|
|
||||||
|
self.expect(&TokenKind::OpenDelim(Delimiter::Parenthesis))?;
|
||||||
|
let ret = if let Some(res) = parse(self, lo, ident)? {
|
||||||
|
Ok(res)
|
||||||
|
} else {
|
||||||
|
let err = errors::UnknownBuiltinConstruct { span: lo.to(ident.span), name: ident.name }
|
||||||
|
.into_diagnostic(&self.sess.span_diagnostic);
|
||||||
|
return Err(err);
|
||||||
|
};
|
||||||
|
self.expect(&TokenKind::CloseDelim(Delimiter::Parenthesis))?;
|
||||||
|
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn parse_expr_offset_of(&mut self, lo: Span) -> PResult<'a, P<Expr>> {
|
||||||
|
let container = self.parse_ty()?;
|
||||||
|
self.expect(&TokenKind::Comma)?;
|
||||||
|
|
||||||
|
let seq_sep = SeqSep { sep: Some(token::Dot), trailing_sep_allowed: false };
|
||||||
|
let (fields, _trailing, _recovered) = self.parse_seq_to_before_end(
|
||||||
|
&TokenKind::CloseDelim(Delimiter::Parenthesis),
|
||||||
|
seq_sep,
|
||||||
|
Parser::parse_field_name,
|
||||||
|
)?;
|
||||||
|
let span = lo.to(self.token.span);
|
||||||
|
Ok(self.mk_expr(span, ExprKind::OffsetOf(container, fields.to_vec().into())))
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a string literal if the next token is a string literal.
|
/// Returns a string literal if the next token is a string literal.
|
||||||
/// In case of error returns `Some(lit)` if the next token is a literal with a wrong kind,
|
/// In case of error returns `Some(lit)` if the next token is a literal with a wrong kind,
|
||||||
/// and returns `None` if the next token is not literal at all.
|
/// and returns `None` if the next token is not literal at all.
|
||||||
|
@ -2835,6 +2892,10 @@ impl<'a> Parser<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn is_builtin(&self) -> bool {
|
||||||
|
self.token.is_keyword(kw::Builtin) && self.look_ahead(1, |t| *t == token::Pound)
|
||||||
|
}
|
||||||
|
|
||||||
/// Parses a `try {...}` expression (`try` token already eaten).
|
/// Parses a `try {...}` expression (`try` token already eaten).
|
||||||
fn parse_try_block(&mut self, span_lo: Span) -> PResult<'a, P<Expr>> {
|
fn parse_try_block(&mut self, span_lo: Span) -> PResult<'a, P<Expr>> {
|
||||||
let (attrs, body) = self.parse_inner_attrs_and_block()?;
|
let (attrs, body) = self.parse_inner_attrs_and_block()?;
|
||||||
|
|
|
@ -265,6 +265,9 @@ impl<'a> Parser<'a> {
|
||||||
// UNION ITEM
|
// UNION ITEM
|
||||||
self.bump(); // `union`
|
self.bump(); // `union`
|
||||||
self.parse_item_union()?
|
self.parse_item_union()?
|
||||||
|
} else if self.is_builtin() {
|
||||||
|
// BUILTIN# ITEM
|
||||||
|
return self.parse_item_builtin();
|
||||||
} else if self.eat_keyword(kw::Macro) {
|
} else if self.eat_keyword(kw::Macro) {
|
||||||
// MACROS 2.0 ITEM
|
// MACROS 2.0 ITEM
|
||||||
self.parse_item_decl_macro(lo)?
|
self.parse_item_decl_macro(lo)?
|
||||||
|
@ -434,6 +437,11 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_item_builtin(&mut self) -> PResult<'a, Option<ItemInfo>> {
|
||||||
|
// To be expanded
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
/// Parses an item macro, e.g., `item!();`.
|
/// Parses an item macro, e.g., `item!();`.
|
||||||
fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, MacCall> {
|
fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, MacCall> {
|
||||||
let path = self.parse_path(PathStyle::Mod)?; // `foo::bar`
|
let path = self.parse_path(PathStyle::Mod)?; // `foo::bar`
|
||||||
|
|
|
@ -90,7 +90,11 @@ impl<'a> Parser<'a> {
|
||||||
attrs,
|
attrs,
|
||||||
errors::InvalidVariableDeclarationSub::UseLetNotVar,
|
errors::InvalidVariableDeclarationSub::UseLetNotVar,
|
||||||
)?
|
)?
|
||||||
} else if self.check_path() && !self.token.is_qpath_start() && !self.is_path_start_item() {
|
} else if self.check_path()
|
||||||
|
&& !self.token.is_qpath_start()
|
||||||
|
&& !self.is_path_start_item()
|
||||||
|
&& !self.is_builtin()
|
||||||
|
{
|
||||||
// We have avoided contextual keywords like `union`, items with `crate` visibility,
|
// We have avoided contextual keywords like `union`, items with `crate` visibility,
|
||||||
// or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
|
// or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
|
||||||
// that starts like a path (1 token), but it fact not a path.
|
// that starts like a path (1 token), but it fact not a path.
|
||||||
|
@ -99,7 +103,13 @@ impl<'a> Parser<'a> {
|
||||||
ForceCollect::Yes => {
|
ForceCollect::Yes => {
|
||||||
self.collect_tokens_no_attrs(|this| this.parse_stmt_path_start(lo, attrs))?
|
self.collect_tokens_no_attrs(|this| this.parse_stmt_path_start(lo, attrs))?
|
||||||
}
|
}
|
||||||
ForceCollect::No => self.parse_stmt_path_start(lo, attrs)?,
|
ForceCollect::No => match self.parse_stmt_path_start(lo, attrs) {
|
||||||
|
Ok(stmt) => stmt,
|
||||||
|
Err(mut err) => {
|
||||||
|
self.suggest_add_missing_let_for_stmt(&mut err);
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
} else if let Some(item) = self.parse_item_common(
|
} else if let Some(item) = self.parse_item_common(
|
||||||
attrs.clone(),
|
attrs.clone(),
|
||||||
|
@ -555,7 +565,6 @@ impl<'a> Parser<'a> {
|
||||||
if self.token == token::Colon {
|
if self.token == token::Colon {
|
||||||
// if next token is following a colon, it's likely a path
|
// if next token is following a colon, it's likely a path
|
||||||
// and we can suggest a path separator
|
// and we can suggest a path separator
|
||||||
let ident_span = self.prev_token.span;
|
|
||||||
self.bump();
|
self.bump();
|
||||||
if self.token.span.lo() == self.prev_token.span.hi() {
|
if self.token.span.lo() == self.prev_token.span.hi() {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
|
@ -565,14 +574,6 @@ impl<'a> Parser<'a> {
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if self.look_ahead(1, |token| token == &token::Eq) {
|
|
||||||
err.span_suggestion_verbose(
|
|
||||||
ident_span.shrink_to_lo(),
|
|
||||||
"you might have meant to introduce a new binding",
|
|
||||||
"let ",
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if self.sess.unstable_features.is_nightly_build() {
|
if self.sess.unstable_features.is_nightly_build() {
|
||||||
// FIXME(Nilstrieb): Remove this again after a few months.
|
// FIXME(Nilstrieb): Remove this again after a few months.
|
||||||
err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
|
err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
|
||||||
|
|
|
@ -95,6 +95,7 @@ symbols! {
|
||||||
|
|
||||||
// Weak keywords, have special meaning only in specific contexts.
|
// Weak keywords, have special meaning only in specific contexts.
|
||||||
Auto: "auto",
|
Auto: "auto",
|
||||||
|
Builtin: "builtin",
|
||||||
Catch: "catch",
|
Catch: "catch",
|
||||||
Default: "default",
|
Default: "default",
|
||||||
MacroRules: "macro_rules",
|
MacroRules: "macro_rules",
|
||||||
|
@ -440,6 +441,7 @@ symbols! {
|
||||||
breakpoint,
|
breakpoint,
|
||||||
bridge,
|
bridge,
|
||||||
bswap,
|
bswap,
|
||||||
|
builtin_syntax,
|
||||||
c_str,
|
c_str,
|
||||||
c_str_literals,
|
c_str_literals,
|
||||||
c_unwind,
|
c_unwind,
|
||||||
|
|
|
@ -322,7 +322,9 @@ fn negative_impl(tcx: TyCtxt<'_>, impl1_def_id: DefId, impl2_def_id: DefId) -> b
|
||||||
let selcx = &mut SelectionContext::new(&infcx);
|
let selcx = &mut SelectionContext::new(&infcx);
|
||||||
let impl2_substs = infcx.fresh_substs_for_item(DUMMY_SP, impl2_def_id);
|
let impl2_substs = infcx.fresh_substs_for_item(DUMMY_SP, impl2_def_id);
|
||||||
let (subject2, obligations) =
|
let (subject2, obligations) =
|
||||||
impl_subject_and_oblig(selcx, impl_env, impl2_def_id, impl2_substs);
|
impl_subject_and_oblig(selcx, impl_env, impl2_def_id, impl2_substs, |_, _| {
|
||||||
|
ObligationCause::dummy()
|
||||||
|
});
|
||||||
|
|
||||||
!equate(&infcx, impl_env, subject1, subject2, obligations, impl1_def_id)
|
!equate(&infcx, impl_env, subject1, subject2, obligations, impl1_def_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,9 @@ pub use self::select::{EvaluationCache, SelectionCache, SelectionContext};
|
||||||
pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError};
|
pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError};
|
||||||
pub use self::specialize::specialization_graph::FutureCompatOverlapError;
|
pub use self::specialize::specialization_graph::FutureCompatOverlapError;
|
||||||
pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
|
pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
|
||||||
pub use self::specialize::{specialization_graph, translate_substs, OverlapError};
|
pub use self::specialize::{
|
||||||
|
specialization_graph, translate_substs, translate_substs_with_cause, OverlapError,
|
||||||
|
};
|
||||||
pub use self::structural_match::{
|
pub use self::structural_match::{
|
||||||
search_for_adt_const_param_violation, search_for_structural_match_violation,
|
search_for_adt_const_param_violation, search_for_structural_match_violation,
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,6 +82,30 @@ pub fn translate_substs<'tcx>(
|
||||||
source_impl: DefId,
|
source_impl: DefId,
|
||||||
source_substs: SubstsRef<'tcx>,
|
source_substs: SubstsRef<'tcx>,
|
||||||
target_node: specialization_graph::Node,
|
target_node: specialization_graph::Node,
|
||||||
|
) -> SubstsRef<'tcx> {
|
||||||
|
translate_substs_with_cause(
|
||||||
|
infcx,
|
||||||
|
param_env,
|
||||||
|
source_impl,
|
||||||
|
source_substs,
|
||||||
|
target_node,
|
||||||
|
|_, _| ObligationCause::dummy(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Like [translate_substs], but obligations from the parent implementation
|
||||||
|
/// are registered with the provided `ObligationCause`.
|
||||||
|
///
|
||||||
|
/// This is for reporting *region* errors from those bounds. Type errors should
|
||||||
|
/// not happen because the specialization graph already checks for those, and
|
||||||
|
/// will result in an ICE.
|
||||||
|
pub fn translate_substs_with_cause<'tcx>(
|
||||||
|
infcx: &InferCtxt<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
source_impl: DefId,
|
||||||
|
source_substs: SubstsRef<'tcx>,
|
||||||
|
target_node: specialization_graph::Node,
|
||||||
|
cause: impl Fn(usize, Span) -> ObligationCause<'tcx>,
|
||||||
) -> SubstsRef<'tcx> {
|
) -> SubstsRef<'tcx> {
|
||||||
debug!(
|
debug!(
|
||||||
"translate_substs({:?}, {:?}, {:?}, {:?})",
|
"translate_substs({:?}, {:?}, {:?}, {:?})",
|
||||||
|
@ -99,14 +123,13 @@ pub fn translate_substs<'tcx>(
|
||||||
return source_substs;
|
return source_substs;
|
||||||
}
|
}
|
||||||
|
|
||||||
fulfill_implication(infcx, param_env, source_trait_ref, target_impl).unwrap_or_else(
|
fulfill_implication(infcx, param_env, source_trait_ref, source_impl, target_impl, cause)
|
||||||
|()| {
|
.unwrap_or_else(|()| {
|
||||||
bug!(
|
bug!(
|
||||||
"When translating substitutions from {source_impl:?} to {target_impl:?}, \
|
"When translating substitutions from {source_impl:?} to {target_impl:?}, \
|
||||||
the expected specialization failed to hold"
|
the expected specialization failed to hold"
|
||||||
)
|
)
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
specialization_graph::Node::Trait(..) => source_trait_ref.substs,
|
specialization_graph::Node::Trait(..) => source_trait_ref.substs,
|
||||||
};
|
};
|
||||||
|
@ -153,20 +176,12 @@ pub(super) fn specializes(tcx: TyCtxt<'_>, (impl1_def_id, impl2_def_id): (DefId,
|
||||||
|
|
||||||
// Create an infcx, taking the predicates of impl1 as assumptions:
|
// Create an infcx, taking the predicates of impl1 as assumptions:
|
||||||
let infcx = tcx.infer_ctxt().build();
|
let infcx = tcx.infer_ctxt().build();
|
||||||
let impl1_trait_ref =
|
|
||||||
match traits::fully_normalize(&infcx, ObligationCause::dummy(), penv, impl1_trait_ref) {
|
|
||||||
Ok(impl1_trait_ref) => impl1_trait_ref,
|
|
||||||
Err(_errors) => {
|
|
||||||
tcx.sess.delay_span_bug(
|
|
||||||
tcx.def_span(impl1_def_id),
|
|
||||||
format!("failed to fully normalize {impl1_trait_ref}"),
|
|
||||||
);
|
|
||||||
impl1_trait_ref
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Attempt to prove that impl2 applies, given all of the above.
|
// Attempt to prove that impl2 applies, given all of the above.
|
||||||
fulfill_implication(&infcx, penv, impl1_trait_ref, impl2_def_id).is_ok()
|
fulfill_implication(&infcx, penv, impl1_trait_ref, impl1_def_id, impl2_def_id, |_, _| {
|
||||||
|
ObligationCause::dummy()
|
||||||
|
})
|
||||||
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to fulfill all obligations of `target_impl` after unification with
|
/// Attempt to fulfill all obligations of `target_impl` after unification with
|
||||||
|
@ -178,23 +193,41 @@ fn fulfill_implication<'tcx>(
|
||||||
infcx: &InferCtxt<'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
source_trait_ref: ty::TraitRef<'tcx>,
|
source_trait_ref: ty::TraitRef<'tcx>,
|
||||||
|
source_impl: DefId,
|
||||||
target_impl: DefId,
|
target_impl: DefId,
|
||||||
|
error_cause: impl Fn(usize, Span) -> ObligationCause<'tcx>,
|
||||||
) -> Result<SubstsRef<'tcx>, ()> {
|
) -> Result<SubstsRef<'tcx>, ()> {
|
||||||
debug!(
|
debug!(
|
||||||
"fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)",
|
"fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)",
|
||||||
param_env, source_trait_ref, target_impl
|
param_env, source_trait_ref, target_impl
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let source_trait_ref = match traits::fully_normalize(
|
||||||
|
&infcx,
|
||||||
|
ObligationCause::dummy(),
|
||||||
|
param_env,
|
||||||
|
source_trait_ref,
|
||||||
|
) {
|
||||||
|
Ok(source_trait_ref) => source_trait_ref,
|
||||||
|
Err(_errors) => {
|
||||||
|
infcx.tcx.sess.delay_span_bug(
|
||||||
|
infcx.tcx.def_span(source_impl),
|
||||||
|
format!("failed to fully normalize {source_trait_ref}"),
|
||||||
|
);
|
||||||
|
source_trait_ref
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let source_trait = ImplSubject::Trait(source_trait_ref);
|
let source_trait = ImplSubject::Trait(source_trait_ref);
|
||||||
|
|
||||||
let selcx = &mut SelectionContext::new(&infcx);
|
let selcx = &mut SelectionContext::new(&infcx);
|
||||||
let target_substs = infcx.fresh_substs_for_item(DUMMY_SP, target_impl);
|
let target_substs = infcx.fresh_substs_for_item(DUMMY_SP, target_impl);
|
||||||
let (target_trait, obligations) =
|
let (target_trait, obligations) =
|
||||||
util::impl_subject_and_oblig(selcx, param_env, target_impl, target_substs);
|
util::impl_subject_and_oblig(selcx, param_env, target_impl, target_substs, error_cause);
|
||||||
|
|
||||||
// do the impls unify? If not, no specialization.
|
// do the impls unify? If not, no specialization.
|
||||||
let Ok(InferOk { obligations: more_obligations, .. }) =
|
let Ok(InferOk { obligations: more_obligations, .. }) =
|
||||||
infcx.at(&ObligationCause::dummy(), param_env, ).eq(DefineOpaqueTypes::No,source_trait, target_trait)
|
infcx.at(&ObligationCause::dummy(), param_env).eq(DefineOpaqueTypes::No, source_trait, target_trait)
|
||||||
else {
|
else {
|
||||||
debug!(
|
debug!(
|
||||||
"fulfill_implication: {:?} does not unify with {:?}",
|
"fulfill_implication: {:?} does not unify with {:?}",
|
||||||
|
|
|
@ -197,6 +197,7 @@ pub fn impl_subject_and_oblig<'a, 'tcx>(
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
impl_def_id: DefId,
|
impl_def_id: DefId,
|
||||||
impl_substs: SubstsRef<'tcx>,
|
impl_substs: SubstsRef<'tcx>,
|
||||||
|
cause: impl Fn(usize, Span) -> ObligationCause<'tcx>,
|
||||||
) -> (ImplSubject<'tcx>, impl Iterator<Item = PredicateObligation<'tcx>>) {
|
) -> (ImplSubject<'tcx>, impl Iterator<Item = PredicateObligation<'tcx>>) {
|
||||||
let subject = selcx.tcx().impl_subject(impl_def_id);
|
let subject = selcx.tcx().impl_subject(impl_def_id);
|
||||||
let subject = subject.subst(selcx.tcx(), impl_substs);
|
let subject = subject.subst(selcx.tcx(), impl_substs);
|
||||||
|
@ -208,8 +209,7 @@ pub fn impl_subject_and_oblig<'a, 'tcx>(
|
||||||
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
|
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
|
||||||
let InferOk { value: predicates, obligations: normalization_obligations2 } =
|
let InferOk { value: predicates, obligations: normalization_obligations2 } =
|
||||||
selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(predicates);
|
selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(predicates);
|
||||||
let impl_obligations =
|
let impl_obligations = super::predicates_for_generics(cause, param_env, predicates);
|
||||||
super::predicates_for_generics(|_, _| ObligationCause::dummy(), param_env, predicates);
|
|
||||||
|
|
||||||
let impl_obligations = impl_obligations
|
let impl_obligations = impl_obligations
|
||||||
.chain(normalization_obligations1.into_iter())
|
.chain(normalization_obligations1.into_iter())
|
||||||
|
|
|
@ -1315,9 +1315,9 @@ impl<T> SizedTypeProperties for T {}
|
||||||
///
|
///
|
||||||
/// assert_eq!(mem::offset_of!(NestedA, b.0), 0);
|
/// assert_eq!(mem::offset_of!(NestedA, b.0), 0);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "offset_of", issue = "106655")]
|
|
||||||
#[rustc_builtin_macro]
|
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
|
#[unstable(feature = "offset_of", issue = "106655")]
|
||||||
|
#[allow_internal_unstable(builtin_syntax)]
|
||||||
pub macro offset_of($Container:ty, $($fields:tt).+ $(,)?) {
|
pub macro offset_of($Container:ty, $($fields:tt).+ $(,)?) {
|
||||||
/* compiler built-in */
|
builtin # offset_of($Container, $($fields).+)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6038be9d37d7251c966b486154af621d1794d7af
|
Subproject commit f63e578b92ff43e8cc38fcaa257b660f45c8a8c2
|
|
@ -1 +1 @@
|
||||||
Subproject commit 897fcf566f16bf87bf37199bdddec1801fd00532
|
Subproject commit d9eb4c3f75435b008881062ffa77bf0d1527b37d
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1f8dc727e94ae4ef92adf70df979521a1ea1143e
|
Subproject commit 28dc0f3576b55f5e57c5d6e65cd68ba3161e9fd5
|
|
@ -1 +1 @@
|
||||||
Subproject commit 31961fe22521a779070a44a8f30a2b00a20b6212
|
Subproject commit 8ee9528b72b927cff8fd32346db8bbd1198816f0
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2a5eb92197e9cf8fe91164dcbf4f9b88c0d7e73d
|
Subproject commit 28dbeaf5c44bc7f5111ad412e99f2d7c5cec6c90
|
|
@ -22,17 +22,17 @@
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:10
|
StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:10
|
||||||
- _1 = OffsetOf(Alpha, [0]); // scope 0 at $DIR/offset_of.rs:+1:13: +1:33
|
- _1 = OffsetOf(Alpha, [0]); // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
+ _1 = const 4_usize; // scope 0 at $DIR/offset_of.rs:+1:13: +1:33
|
+ _1 = const 4_usize; // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:10
|
StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:10
|
||||||
- _2 = OffsetOf(Alpha, [1]); // scope 1 at $DIR/offset_of.rs:+2:13: +2:33
|
- _2 = OffsetOf(Alpha, [1]); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
+ _2 = const 0_usize; // scope 1 at $DIR/offset_of.rs:+2:13: +2:33
|
+ _2 = const 0_usize; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11
|
StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11
|
||||||
- _3 = OffsetOf(Alpha, [2, 0]); // scope 2 at $DIR/offset_of.rs:+3:14: +3:36
|
- _3 = OffsetOf(Alpha, [2, 0]); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
+ _3 = const 2_usize; // scope 2 at $DIR/offset_of.rs:+3:14: +3:36
|
+ _3 = const 2_usize; // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11
|
StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11
|
||||||
- _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:36
|
- _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
+ _4 = const 3_usize; // scope 3 at $DIR/offset_of.rs:+4:14: +4:36
|
+ _4 = const 3_usize; // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
_0 = const (); // scope 0 at $DIR/offset_of.rs:+0:15: +5:2
|
_0 = const (); // scope 0 at $DIR/offset_of.rs:+0:15: +5:2
|
||||||
StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2
|
StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2
|
||||||
StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2
|
StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2
|
||||||
|
|
|
@ -22,13 +22,13 @@
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:11
|
StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:11
|
||||||
_1 = OffsetOf(Gamma<T>, [0]); // scope 0 at $DIR/offset_of.rs:+1:14: +1:37
|
_1 = OffsetOf(Gamma<T>, [0]); // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:11
|
StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:11
|
||||||
_2 = OffsetOf(Gamma<T>, [1]); // scope 1 at $DIR/offset_of.rs:+2:14: +2:37
|
_2 = OffsetOf(Gamma<T>, [1]); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11
|
StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11
|
||||||
_3 = OffsetOf(Delta<T>, [1]); // scope 2 at $DIR/offset_of.rs:+3:14: +3:37
|
_3 = OffsetOf(Delta<T>, [1]); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11
|
StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11
|
||||||
_4 = OffsetOf(Delta<T>, [2]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:37
|
_4 = OffsetOf(Delta<T>, [2]); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
_0 = const (); // scope 0 at $DIR/offset_of.rs:+0:17: +5:2
|
_0 = const (); // scope 0 at $DIR/offset_of.rs:+0:17: +5:2
|
||||||
StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2
|
StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2
|
||||||
StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2
|
StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2
|
||||||
|
|
15
tests/run-make/branch-protection-check-IBT/Makefile
Normal file
15
tests/run-make/branch-protection-check-IBT/Makefile
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# Check for GNU Property Note
|
||||||
|
|
||||||
|
include ../tools.mk
|
||||||
|
|
||||||
|
# How to run this
|
||||||
|
# python3 x.py test --target x86_64-unknown-linux-gnu tests/run-make/branch-protection-check-IBT/
|
||||||
|
|
||||||
|
# only-x86_64
|
||||||
|
|
||||||
|
all:
|
||||||
|
ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86_64)
|
||||||
|
$(RUSTC) --target x86_64-unknown-linux-gnu -Z cf-protection=branch -L$(TMPDIR) -C link-args='-nostartfiles' -C save-temps ./main.rs -o $(TMPDIR)/rsmain
|
||||||
|
readelf -nW $(TMPDIR)/rsmain | $(CGREP) -e ".note.gnu.property"
|
||||||
|
endif
|
||||||
|
|
3
tests/run-make/branch-protection-check-IBT/main.rs
Normal file
3
tests/run-make/branch-protection-check-IBT/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("hello world");
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ LL | fn foo(a: &A, d: D, e: &E, g: G) {}
|
||||||
help: consider borrowing here
|
help: consider borrowing here
|
||||||
|
|
|
|
||||||
LL | foo(&&A, B, C, D, &E, F, G);
|
LL | foo(&&A, B, C, D, &E, F, G);
|
||||||
| ~~
|
| +
|
||||||
help: remove the extra arguments
|
help: remove the extra arguments
|
||||||
|
|
|
|
||||||
LL - foo(&&A, B, C, D, E, F, G);
|
LL - foo(&&A, B, C, D, E, F, G);
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | let _ = &mut x[2..4];
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let x: &[isize] = &mut [1, 2, 3, 4, 5];
|
LL | let x: &[isize] = &mut [1, 2, 3, 4, 5];
|
||||||
| ~~~~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,16 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-102206.rs:6:27
|
--> $DIR/issue-102206.rs:6:27
|
||||||
|
|
|
|
||||||
LL | std::mem::size_of_val(foo());
|
LL | std::mem::size_of_val(foo());
|
||||||
| --------------------- ^^^^^
|
| --------------------- ^^^^^ expected `&_`, found future
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found future
|
|
||||||
| | help: consider borrowing here: `&foo()`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | std::mem::size_of_val(&foo());
|
||||||
|
| +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | let q = &raw mut *x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let x = &mut 0;
|
LL | let x = &mut 0;
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
|
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
|
||||||
--> $DIR/borrow-raw-address-of-deref-mutability.rs:14:13
|
--> $DIR/borrow-raw-address-of-deref-mutability.rs:14:13
|
||||||
|
@ -18,7 +18,7 @@ LL | let q = &raw mut *x;
|
||||||
help: consider changing this to be a mutable pointer
|
help: consider changing this to be a mutable pointer
|
||||||
|
|
|
|
||||||
LL | let x = &mut 0 as *const i32;
|
LL | let x = &mut 0 as *const i32;
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ LL | let _y1 = &mut *ref_x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let ref_x = &mut x;
|
LL | let ref_x = &mut x;
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
|
error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
|
||||||
--> $DIR/borrowck-access-permissions.rs:39:23
|
--> $DIR/borrowck-access-permissions.rs:39:23
|
||||||
|
@ -46,7 +46,7 @@ LL | let _y1 = &mut *ptr_x;
|
||||||
help: consider changing this to be a mutable pointer
|
help: consider changing this to be a mutable pointer
|
||||||
|
|
|
|
||||||
LL | let ptr_x : *const _ = &mut x;
|
LL | let ptr_x : *const _ = &mut x;
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/borrowck-access-permissions.rs:48:18
|
--> $DIR/borrowck-access-permissions.rs:48:18
|
||||||
|
@ -57,7 +57,7 @@ LL | let _y = &mut *foo_ref.f;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let foo_ref = &mut foo;
|
LL | let foo_ref = &mut foo;
|
||||||
| ~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ LL | *s.pointer += 1;
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn a(s: &mut S<'_>) {
|
LL | fn a(s: &mut S) {
|
||||||
| ~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference
|
error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference
|
||||||
--> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5
|
--> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5
|
||||||
|
@ -17,8 +17,8 @@ LL | *s.pointer += 1;
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn c(s: &mut &mut S<'_>) {
|
LL | fn c(s: &mut &mut S) {
|
||||||
| ~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ LL | let x: &mut isize = &mut **t0;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn foo4(t0: &mut &mut isize) {
|
LL | fn foo4(t0: &mut &mut isize) {
|
||||||
| ~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | ***p = 2;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let p = &mut y;
|
LL | let p = &mut y;
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0506]: cannot assign to `**y` because it is borrowed
|
error[E0506]: cannot assign to `**y` because it is borrowed
|
||||||
--> $DIR/borrowck-issue-14498.rs:25:5
|
--> $DIR/borrowck-issue-14498.rs:25:5
|
||||||
|
|
|
@ -111,7 +111,7 @@ LL | let _bar1 = &mut foo.bar1;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn borrow_mut_from_imm(foo: &mut Foo) {
|
LL | fn borrow_mut_from_imm(foo: &mut Foo) {
|
||||||
| ~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 11 previous errors
|
error: aborting due to 11 previous errors
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ LL | *r = 0;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let r = &mut mutvar;
|
LL | let r = &mut mutvar;
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `*x`, which is behind a `&` reference
|
error[E0594]: cannot assign to `*x`, which is behind a `&` reference
|
||||||
--> $DIR/issue-85765.rs:19:5
|
--> $DIR/issue-85765.rs:19:5
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | *x = (1,);
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn named_ref(x: &mut (i32,)) {
|
LL | fn named_ref(x: &mut (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `x.0`, which is behind a `&` reference
|
error[E0594]: cannot assign to `x.0`, which is behind a `&` reference
|
||||||
--> $DIR/mutability-errors.rs:10:5
|
--> $DIR/mutability-errors.rs:10:5
|
||||||
|
@ -18,7 +18,7 @@ LL | x.0 = 1;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn named_ref(x: &mut (i32,)) {
|
LL | fn named_ref(x: &mut (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/mutability-errors.rs:11:5
|
--> $DIR/mutability-errors.rs:11:5
|
||||||
|
@ -29,7 +29,7 @@ LL | &mut *x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn named_ref(x: &mut (i32,)) {
|
LL | fn named_ref(x: &mut (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/mutability-errors.rs:12:5
|
--> $DIR/mutability-errors.rs:12:5
|
||||||
|
@ -40,7 +40,7 @@ LL | &mut x.0;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn named_ref(x: &mut (i32,)) {
|
LL | fn named_ref(x: &mut (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to data in a `&` reference
|
error[E0594]: cannot assign to data in a `&` reference
|
||||||
--> $DIR/mutability-errors.rs:16:5
|
--> $DIR/mutability-errors.rs:16:5
|
||||||
|
@ -74,8 +74,8 @@ LL | *x = (1,);
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable pointer
|
help: consider changing this to be a mutable pointer
|
||||||
|
|
|
|
||||||
LL | unsafe fn named_ptr(x: *mut (i32,)) {
|
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer
|
error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer
|
||||||
--> $DIR/mutability-errors.rs:24:5
|
--> $DIR/mutability-errors.rs:24:5
|
||||||
|
@ -85,8 +85,8 @@ LL | (*x).0 = 1;
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable pointer
|
help: consider changing this to be a mutable pointer
|
||||||
|
|
|
|
||||||
LL | unsafe fn named_ptr(x: *mut (i32,)) {
|
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
|
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
|
||||||
--> $DIR/mutability-errors.rs:25:5
|
--> $DIR/mutability-errors.rs:25:5
|
||||||
|
@ -96,8 +96,8 @@ LL | &mut *x;
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable pointer
|
help: consider changing this to be a mutable pointer
|
||||||
|
|
|
|
||||||
LL | unsafe fn named_ptr(x: *mut (i32,)) {
|
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer
|
error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer
|
||||||
--> $DIR/mutability-errors.rs:26:5
|
--> $DIR/mutability-errors.rs:26:5
|
||||||
|
@ -107,8 +107,8 @@ LL | &mut (*x).0;
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable pointer
|
help: consider changing this to be a mutable pointer
|
||||||
|
|
|
|
||||||
LL | unsafe fn named_ptr(x: *mut (i32,)) {
|
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to data in a `*const` pointer
|
error[E0594]: cannot assign to data in a `*const` pointer
|
||||||
--> $DIR/mutability-errors.rs:30:5
|
--> $DIR/mutability-errors.rs:30:5
|
||||||
|
|
|
@ -10,7 +10,7 @@ LL | **ref_mref_x = y;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let ref_mref_x = &mut mref_x;
|
LL | let ref_mref_x = &mut mref_x;
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `**mref_ref_x` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `**mref_ref_x` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/mut_ref.rs:26:13
|
--> $DIR/mut_ref.rs:26:13
|
||||||
|
|
|
@ -2,11 +2,14 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/coercion-slice.rs:4:21
|
--> $DIR/coercion-slice.rs:4:21
|
||||||
|
|
|
|
||||||
LL | let _: &[i32] = [0];
|
LL | let _: &[i32] = [0];
|
||||||
| ------ ^^^
|
| ------ ^^^ expected `&[i32]`, found `[{integer}; 1]`
|
||||||
| | |
|
| |
|
||||||
| | expected `&[i32]`, found `[{integer}; 1]`
|
|
||||||
| | help: consider borrowing here: `&[0]`
|
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | let _: &[i32] = &[0];
|
||||||
|
| +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ LL | f.s.push('x');
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn f(x: usize, f: &mut Foo<'_>) {
|
LL | fn f(x: usize, f: &mut Foo) {
|
||||||
| ~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ LL | let _ = &mut other.x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn foo1(&self, other: &mut Z) {
|
LL | fn foo1(&self, other: &mut Z) {
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/issue-39544.rs:25:17
|
--> $DIR/issue-39544.rs:25:17
|
||||||
|
@ -62,7 +62,7 @@ LL | let _ = &mut other.x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn foo2<'a>(&'a self, other: &mut Z) {
|
LL | fn foo2<'a>(&'a self, other: &mut Z) {
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/issue-39544.rs:30:17
|
--> $DIR/issue-39544.rs:30:17
|
||||||
|
@ -73,7 +73,7 @@ LL | let _ = &mut self.x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn foo3<'a>(self: &'a mut Self, other: &Z) {
|
LL | fn foo3<'a>(self: &'a mut Self, other: &Z) {
|
||||||
| ~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/issue-39544.rs:31:17
|
--> $DIR/issue-39544.rs:31:17
|
||||||
|
@ -84,7 +84,7 @@ LL | let _ = &mut other.x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn foo3<'a>(self: &'a Self, other: &mut Z) {
|
LL | fn foo3<'a>(self: &'a Self, other: &mut Z) {
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/issue-39544.rs:35:17
|
--> $DIR/issue-39544.rs:35:17
|
||||||
|
@ -95,7 +95,7 @@ LL | let _ = &mut other.x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn foo4(other: &mut Z) {
|
LL | fn foo4(other: &mut Z) {
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable
|
error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable
|
||||||
--> $DIR/issue-39544.rs:41:13
|
--> $DIR/issue-39544.rs:41:13
|
||||||
|
@ -117,7 +117,7 @@ LL | let _ = &mut w.x;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | pub fn with_arg(z: Z, w: &mut Z) {
|
LL | pub fn with_arg(z: Z, w: &mut Z) {
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `*x.0`, which is behind a `&` reference
|
error[E0594]: cannot assign to `*x.0`, which is behind a `&` reference
|
||||||
--> $DIR/issue-39544.rs:48:5
|
--> $DIR/issue-39544.rs:48:5
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | buf.iter_mut();
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let mut buf = &mut [1, 2, 3, 4];
|
LL | let mut buf = &mut [1, 2, 3, 4];
|
||||||
| ~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | fancy_ref.num = 6;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let fancy_ref = &mut (&mut fancy);
|
LL | let fancy_ref = &mut (&mut fancy);
|
||||||
| ~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
7
tests/ui/feature-gates/feature-gate-builtin_syntax.rs
Normal file
7
tests/ui/feature-gates/feature-gate-builtin_syntax.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
struct Foo {
|
||||||
|
v: u8,
|
||||||
|
w: u8,
|
||||||
|
}
|
||||||
|
fn main() {
|
||||||
|
builtin # offset_of(Foo, v); //~ ERROR `builtin #` syntax is unstable
|
||||||
|
}
|
12
tests/ui/feature-gates/feature-gate-builtin_syntax.stderr
Normal file
12
tests/ui/feature-gates/feature-gate-builtin_syntax.stderr
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
error[E0658]: `builtin #` syntax is unstable
|
||||||
|
--> $DIR/feature-gate-builtin_syntax.rs:6:15
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(Foo, v);
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #110680 <https://github.com/rust-lang/rust/issues/110680> for more information
|
||||||
|
= help: add `#![feature(builtin_syntax)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
|
@ -98,19 +98,23 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/deref-suggestion.rs:40:17
|
--> $DIR/deref-suggestion.rs:40:17
|
||||||
|
|
|
|
||||||
LL | let s = S { u };
|
LL | let s = S { u };
|
||||||
| ^
|
| ^ expected `&u32`, found integer
|
||||||
| |
|
|
|
||||||
| expected `&u32`, found integer
|
help: consider borrowing here
|
||||||
| help: consider borrowing here: `u: &u`
|
|
|
||||||
|
LL | let s = S { u: &u };
|
||||||
|
| ++++
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/deref-suggestion.rs:42:20
|
--> $DIR/deref-suggestion.rs:42:20
|
||||||
|
|
|
|
||||||
LL | let s = S { u: u };
|
LL | let s = S { u: u };
|
||||||
| ^
|
| ^ expected `&u32`, found integer
|
||||||
| |
|
|
|
||||||
| expected `&u32`, found integer
|
help: consider borrowing here
|
||||||
| help: consider borrowing here: `&u`
|
|
|
||||||
|
LL | let s = S { u: &u };
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/deref-suggestion.rs:45:17
|
--> $DIR/deref-suggestion.rs:45:17
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-11374.rs:26:15
|
--> $DIR/issue-11374.rs:26:15
|
||||||
|
|
|
|
||||||
LL | c.read_to(v);
|
LL | c.read_to(v);
|
||||||
| ------- ^
|
| ------- ^ expected `&mut [u8]`, found `Vec<_>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&mut [u8]`, found `Vec<_>`
|
|
||||||
| | help: consider mutably borrowing here: `&mut v`
|
|
||||||
| arguments to this method are incorrect
|
| arguments to this method are incorrect
|
||||||
|
|
|
|
||||||
= note: expected mutable reference `&mut [u8]`
|
= note: expected mutable reference `&mut [u8]`
|
||||||
|
@ -15,6 +13,10 @@ note: method defined here
|
||||||
|
|
|
|
||||||
LL | pub fn read_to(&mut self, vec: &mut [u8]) {
|
LL | pub fn read_to(&mut self, vec: &mut [u8]) {
|
||||||
| ^^^^^^^ --------------
|
| ^^^^^^^ --------------
|
||||||
|
help: consider mutably borrowing here
|
||||||
|
|
|
||||||
|
LL | c.read_to(&mut v);
|
||||||
|
| ++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,14 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-17033.rs:2:10
|
--> $DIR/issue-17033.rs:2:10
|
||||||
|
|
|
|
||||||
LL | (*p)(())
|
LL | (*p)(())
|
||||||
| ---- ^^
|
| ---- ^^ expected `&mut ()`, found `()`
|
||||||
| | |
|
| |
|
||||||
| | expected `&mut ()`, found `()`
|
|
||||||
| | help: consider mutably borrowing here: `&mut ()`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
||||||
|
help: consider mutably borrowing here
|
||||||
|
|
|
||||||
|
LL | (*p)(&mut ())
|
||||||
|
| ++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) {
|
||||||
help: consider borrowing here
|
help: consider borrowing here
|
||||||
|
|
|
|
||||||
LL | print_x(&X);
|
LL | print_x(&X);
|
||||||
| ~~
|
| +
|
||||||
help: provide the argument
|
help: provide the argument
|
||||||
|
|
|
|
||||||
LL | print_x(/* &dyn Foo<Item = bool> */, /* &str */);
|
LL | print_x(/* &dyn Foo<Item = bool> */, /* &str */);
|
||||||
|
|
|
@ -2,10 +2,12 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-46302.rs:3:27
|
--> $DIR/issue-46302.rs:3:27
|
||||||
|
|
|
|
||||||
LL | let u: &str = if true { s[..2] } else { s };
|
LL | let u: &str = if true { s[..2] } else { s };
|
||||||
| ^^^^^^
|
| ^^^^^^ expected `&str`, found `str`
|
||||||
| |
|
|
|
||||||
| expected `&str`, found `str`
|
help: consider borrowing here
|
||||||
| help: consider borrowing here: `&s[..2]`
|
|
|
||||||
|
LL | let u: &str = if true { &s[..2] } else { s };
|
||||||
|
| +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:12:42
|
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:12:42
|
||||||
|
|
|
|
||||||
LL | light_flows_our_war_of_mocking_words(behold as usize);
|
LL | light_flows_our_war_of_mocking_words(behold as usize);
|
||||||
| ------------------------------------ ^^^^^^^^^^^^^^^
|
| ------------------------------------ ^^^^^^^^^^^^^^^ expected `&usize`, found `usize`
|
||||||
| | |
|
| |
|
||||||
| | expected `&usize`, found `usize`
|
|
||||||
| | help: consider borrowing here: `&(behold as usize)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
|
@ -13,15 +11,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
|
LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | light_flows_our_war_of_mocking_words(&(behold as usize));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:42
|
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:42
|
||||||
|
|
|
|
||||||
LL | light_flows_our_war_of_mocking_words(with_tears + 4);
|
LL | light_flows_our_war_of_mocking_words(with_tears + 4);
|
||||||
| ------------------------------------ ^^^^^^^^^^^^^^
|
| ------------------------------------ ^^^^^^^^^^^^^^ expected `&usize`, found `usize`
|
||||||
| | |
|
| |
|
||||||
| | expected `&usize`, found `usize`
|
|
||||||
| | help: consider borrowing here: `&(with_tears + 4)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
|
@ -29,6 +29,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
|
LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | light_flows_our_war_of_mocking_words(&(with_tears + 4));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let foo = &16;
|
let foo = &16;
|
||||||
//~^ HELP consider changing this to be a mutable reference
|
//~^ HELP consider changing this to be a mutable reference
|
||||||
//~| SUGGESTION &mut 16
|
|
||||||
*foo = 32;
|
*foo = 32;
|
||||||
//~^ ERROR cannot assign to `*foo`, which is behind a `&` reference
|
//~^ ERROR cannot assign to `*foo`, which is behind a `&` reference
|
||||||
let bar = foo;
|
let bar = foo;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
|
error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
|
||||||
--> $DIR/issue-51515.rs:5:5
|
--> $DIR/issue-51515.rs:4:5
|
||||||
|
|
|
|
||||||
LL | *foo = 32;
|
LL | *foo = 32;
|
||||||
| ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
|
| ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
|
||||||
|
@ -7,10 +7,10 @@ LL | *foo = 32;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let foo = &mut 16;
|
LL | let foo = &mut 16;
|
||||||
| ~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `*bar`, which is behind a `&` reference
|
error[E0594]: cannot assign to `*bar`, which is behind a `&` reference
|
||||||
--> $DIR/issue-51515.rs:9:5
|
--> $DIR/issue-51515.rs:8:5
|
||||||
|
|
|
|
||||||
LL | *bar = 64;
|
LL | *bar = 64;
|
||||||
| ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
|
| ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-61106.rs:3:9
|
--> $DIR/issue-61106.rs:3:9
|
||||||
|
|
|
|
||||||
LL | foo(x.clone());
|
LL | foo(x.clone());
|
||||||
| --- ^^^^^^^^^
|
| --- ^^^^^^^^^ expected `&str`, found `String`
|
||||||
| | |
|
| |
|
||||||
| | expected `&str`, found `String`
|
|
||||||
| | help: consider borrowing here: `&x`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
|
@ -13,6 +11,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn foo(_: &str) {}
|
LL | fn foo(_: &str) {}
|
||||||
| ^^^ -------
|
| ^^^ -------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | foo(&x.clone());
|
||||||
|
| +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | f2(|| x.0, f1(x.1))
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn f3<'a>(x: &'a mut ((), &'a mut ())) {
|
LL | fn f3<'a>(x: &'a mut ((), &'a mut ())) {
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/method-self-arg-1.rs:11:14
|
--> $DIR/method-self-arg-1.rs:11:14
|
||||||
|
|
|
|
||||||
LL | Foo::bar(x);
|
LL | Foo::bar(x);
|
||||||
| -------- ^
|
| -------- ^ expected `&Foo`, found `Foo`
|
||||||
| | |
|
| |
|
||||||
| | expected `&Foo`, found `Foo`
|
|
||||||
| | help: consider borrowing here: `&x`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
note: method defined here
|
note: method defined here
|
||||||
|
@ -13,6 +11,10 @@ note: method defined here
|
||||||
|
|
|
|
||||||
LL | fn bar(&self) {}
|
LL | fn bar(&self) {}
|
||||||
| ^^^ -----
|
| ^^^ -----
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | Foo::bar(&x);
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/method-self-arg-1.rs:13:14
|
--> $DIR/method-self-arg-1.rs:13:14
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/dont-point-return-on-E0308.rs:11:11
|
--> $DIR/dont-point-return-on-E0308.rs:11:11
|
||||||
|
|
|
|
||||||
LL | f(());
|
LL | f(());
|
||||||
| - ^^
|
| - ^^ expected `&()`, found `()`
|
||||||
| | |
|
| |
|
||||||
| | expected `&()`, found `()`
|
|
||||||
| | help: consider borrowing here: `&()`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
|
@ -13,6 +11,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | async fn f(_: &()) {}
|
LL | async fn f(_: &()) {}
|
||||||
| ^ ------
|
| ^ ------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | f(&());
|
||||||
|
| +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/mut-cross-borrowing.rs:7:7
|
--> $DIR/mut-cross-borrowing.rs:7:7
|
||||||
|
|
|
|
||||||
LL | f(x)
|
LL | f(x)
|
||||||
| - ^
|
| - ^ expected `&mut isize`, found `Box<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&mut isize`, found `Box<{integer}>`
|
|
||||||
| | help: consider mutably borrowing here: `&mut x`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected mutable reference `&mut isize`
|
= note: expected mutable reference `&mut isize`
|
||||||
|
@ -15,6 +13,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn f(_: &mut isize) {}
|
LL | fn f(_: &mut isize) {}
|
||||||
| ^ -------------
|
| ^ -------------
|
||||||
|
help: consider mutably borrowing here
|
||||||
|
|
|
||||||
|
LL | f(&mut x)
|
||||||
|
| ++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | fancy_ref.num = 6;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let fancy_ref = &mut (&mut fancy);
|
LL | let fancy_ref = &mut (&mut fancy);
|
||||||
| ~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | *my_ref = 0;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let ref mut my_ref @ _ = 0;
|
LL | let ref mut my_ref @ _ = 0;
|
||||||
| ~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | *x = 0;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn f(x: &mut i32) {
|
LL | fn f(x: &mut i32) {
|
||||||
| ~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0506]: cannot assign to `*x` because it is borrowed
|
error[E0506]: cannot assign to `*x` because it is borrowed
|
||||||
--> $DIR/issue-57989.rs:5:5
|
--> $DIR/issue-57989.rs:5:5
|
||||||
|
|
|
@ -3,7 +3,15 @@
|
||||||
use std::mem::offset_of;
|
use std::mem::offset_of;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
offset_of!(NotEnoughArguments); //~ ERROR expected one of
|
offset_of!(NotEnoughArguments); //~ ERROR unexpected end of macro invocation
|
||||||
offset_of!(NotEnoughArgumentsWithAComma, ); //~ ERROR expected 2 arguments
|
offset_of!(NotEnoughArgumentsWithAComma, ); //~ ERROR unexpected end of macro invocation
|
||||||
offset_of!(Container, field, too many arguments); //~ ERROR expected 2 arguments
|
offset_of!(Container, field, too many arguments); //~ ERROR no rules expected the token `too`
|
||||||
|
offset_of!(S, f); // compiles fine
|
||||||
|
offset_of!(S, f,); // also compiles fine
|
||||||
|
offset_of!(S, f.); //~ ERROR unexpected end of macro invocation
|
||||||
|
offset_of!(S, f.,); //~ ERROR expected identifier
|
||||||
|
offset_of!(S, f..); //~ ERROR no rules expected the token
|
||||||
|
offset_of!(S, f..,); //~ ERROR no rules expected the token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct S { f: u8, }
|
||||||
|
|
|
@ -1,20 +1,59 @@
|
||||||
error: expected one of `!`, `(`, `+`, `,`, `::`, or `<`, found `<eof>`
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/offset-of-arg-count.rs:6:16
|
--> $DIR/offset-of-arg-count.rs:6:34
|
||||||
|
|
|
|
||||||
LL | offset_of!(NotEnoughArguments);
|
LL | offset_of!(NotEnoughArguments);
|
||||||
| ^^^^^^^^^^^^^^^^^^ expected one of `!`, `(`, `+`, `,`, `::`, or `<`
|
| ^ missing tokens in macro arguments
|
||||||
|
|
|
||||||
|
note: while trying to match `,`
|
||||||
|
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
|
|
||||||
error: expected 2 arguments
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/offset-of-arg-count.rs:7:5
|
--> $DIR/offset-of-arg-count.rs:7:45
|
||||||
|
|
|
|
||||||
LL | offset_of!(NotEnoughArgumentsWithAComma, );
|
LL | offset_of!(NotEnoughArgumentsWithAComma, );
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^ missing tokens in macro arguments
|
||||||
|
|
|
||||||
|
note: while trying to match meta-variable `$fields:tt`
|
||||||
|
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
|
|
||||||
error: expected 2 arguments
|
error: no rules expected the token `too`
|
||||||
--> $DIR/offset-of-arg-count.rs:8:5
|
--> $DIR/offset-of-arg-count.rs:8:34
|
||||||
|
|
|
|
||||||
LL | offset_of!(Container, field, too many arguments);
|
LL | offset_of!(Container, field, too many arguments);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^ no rules expected this token in macro call
|
||||||
|
|
|
||||||
|
= note: while trying to match sequence end
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: unexpected end of macro invocation
|
||||||
|
--> $DIR/offset-of-arg-count.rs:11:21
|
||||||
|
|
|
||||||
|
LL | offset_of!(S, f.);
|
||||||
|
| ^ missing tokens in macro arguments
|
||||||
|
|
|
||||||
|
note: while trying to match meta-variable `$fields:tt`
|
||||||
|
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
|
|
||||||
|
error: expected identifier, found `,`
|
||||||
|
--> $DIR/offset-of-arg-count.rs:12:21
|
||||||
|
|
|
||||||
|
LL | offset_of!(S, f.,);
|
||||||
|
| ^ expected identifier
|
||||||
|
|
||||||
|
error: no rules expected the token `..`
|
||||||
|
--> $DIR/offset-of-arg-count.rs:13:20
|
||||||
|
|
|
||||||
|
LL | offset_of!(S, f..);
|
||||||
|
| ^^ no rules expected this token in macro call
|
||||||
|
|
|
||||||
|
= note: while trying to match sequence start
|
||||||
|
|
||||||
|
error: no rules expected the token `..`
|
||||||
|
--> $DIR/offset-of-arg-count.rs:14:20
|
||||||
|
|
|
||||||
|
LL | offset_of!(S, f..,);
|
||||||
|
| ^^ no rules expected this token in macro call
|
||||||
|
|
|
||||||
|
= note: while trying to match sequence start
|
||||||
|
|
||||||
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
|
44
tests/ui/offset-of/offset-of-builtin.rs
Normal file
44
tests/ui/offset-of/offset-of-builtin.rs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#![feature(builtin_syntax)]
|
||||||
|
|
||||||
|
// For the exposed macro we already test these errors in the other files,
|
||||||
|
// but this test helps to make sure the builtin construct also errors.
|
||||||
|
// This has the same examples as offset-of-arg-count.rs
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
builtin # offset_of(NotEnoughArguments); //~ ERROR expected one of
|
||||||
|
}
|
||||||
|
fn t1() {
|
||||||
|
// Already errored upon at the macro level. Yielding an error would require
|
||||||
|
// extra effort.
|
||||||
|
builtin # offset_of(NotEnoughArgumentsWithAComma, );
|
||||||
|
}
|
||||||
|
fn t2() {
|
||||||
|
builtin # offset_of(Container, field, too many arguments); //~ ERROR expected identifier, found
|
||||||
|
//~| ERROR found `,`
|
||||||
|
//~| ERROR found `many`
|
||||||
|
//~| ERROR found `arguments`
|
||||||
|
}
|
||||||
|
fn t3() {
|
||||||
|
builtin # offset_of(S, f); // compiles fine
|
||||||
|
}
|
||||||
|
fn t4() {
|
||||||
|
// Already errored upon at the macro level. Yielding an error would require
|
||||||
|
// extra effort.
|
||||||
|
builtin # offset_of(S, f);
|
||||||
|
}
|
||||||
|
fn t5() {
|
||||||
|
builtin # offset_of(S, f.); //~ ERROR expected identifier
|
||||||
|
}
|
||||||
|
fn t6() {
|
||||||
|
builtin # offset_of(S, f.,); //~ ERROR expected identifier
|
||||||
|
}
|
||||||
|
fn t7() {
|
||||||
|
builtin # offset_of(S, f..); //~ ERROR expected one of
|
||||||
|
}
|
||||||
|
fn t8() {
|
||||||
|
// Already errored upon at the macro level. Yielding an error would require
|
||||||
|
// extra effort.
|
||||||
|
builtin # offset_of(S, f..,);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S { f: u8, }
|
65
tests/ui/offset-of/offset-of-builtin.stderr
Normal file
65
tests/ui/offset-of/offset-of-builtin.stderr
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
error: expected one of `!`, `(`, `+`, `,`, `::`, or `<`, found `)`
|
||||||
|
--> $DIR/offset-of-builtin.rs:8:43
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(NotEnoughArguments);
|
||||||
|
| ^ expected one of `!`, `(`, `+`, `,`, `::`, or `<`
|
||||||
|
|
||||||
|
error: expected identifier, found `,`
|
||||||
|
--> $DIR/offset-of-builtin.rs:16:41
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(Container, field, too many arguments);
|
||||||
|
| ^
|
||||||
|
| |
|
||||||
|
| expected identifier
|
||||||
|
| help: remove this comma
|
||||||
|
|
||||||
|
error: expected one of `)` or `.`, found `,`
|
||||||
|
--> $DIR/offset-of-builtin.rs:16:41
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(Container, field, too many arguments);
|
||||||
|
| ^
|
||||||
|
| |
|
||||||
|
| expected one of `)` or `.`
|
||||||
|
| help: missing `.`
|
||||||
|
|
||||||
|
error: expected one of `)` or `.`, found `many`
|
||||||
|
--> $DIR/offset-of-builtin.rs:16:47
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(Container, field, too many arguments);
|
||||||
|
| -^^^^ expected one of `)` or `.`
|
||||||
|
| |
|
||||||
|
| help: missing `.`
|
||||||
|
|
||||||
|
error: expected one of `)` or `.`, found `arguments`
|
||||||
|
--> $DIR/offset-of-builtin.rs:16:52
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(Container, field, too many arguments);
|
||||||
|
| -^^^^^^^^^ expected one of `)` or `.`
|
||||||
|
| |
|
||||||
|
| help: missing `.`
|
||||||
|
|
||||||
|
error: expected identifier, found `)`
|
||||||
|
--> $DIR/offset-of-builtin.rs:30:30
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(S, f.);
|
||||||
|
| ^ expected identifier
|
||||||
|
|
||||||
|
error: expected identifier, found `,`
|
||||||
|
--> $DIR/offset-of-builtin.rs:33:30
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(S, f.,);
|
||||||
|
| ^ expected identifier
|
||||||
|
|
||||||
|
error: expected one of `)` or `.`, found `..`
|
||||||
|
--> $DIR/offset-of-builtin.rs:36:29
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(S, f..);
|
||||||
|
| ^^ expected one of `)` or `.`
|
||||||
|
|
|
||||||
|
help: if you meant to bind the contents of the rest of the array pattern into `f`, use `@`
|
||||||
|
|
|
||||||
|
LL | builtin # offset_of(S, f @ ..);
|
||||||
|
| +
|
||||||
|
|
||||||
|
error: aborting due to 8 previous errors
|
||||||
|
|
|
@ -5,6 +5,7 @@ LL | offset_of!(Alpha, z);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `[u8]`
|
= help: the trait `Sized` is not implemented for `[u8]`
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/offset-of-dst-field.rs:31:5
|
--> $DIR/offset-of-dst-field.rs:31:5
|
||||||
|
@ -13,6 +14,7 @@ LL | offset_of!(Beta, z);
|
||||||
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0277]: the size for values of type `Extern` cannot be known at compilation time
|
error[E0277]: the size for values of type `Extern` cannot be known at compilation time
|
||||||
--> $DIR/offset-of-dst-field.rs:32:5
|
--> $DIR/offset-of-dst-field.rs:32:5
|
||||||
|
@ -21,6 +23,7 @@ LL | offset_of!(Gamma, z);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `Extern`
|
= help: the trait `Sized` is not implemented for `Extern`
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ LL | | );
|
||||||
| |_____^
|
| |_____^
|
||||||
|
|
|
|
||||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
||||||
--> $DIR/offset-of-unstable.rs:18:5
|
--> $DIR/offset-of-unstable.rs:18:5
|
||||||
|
@ -41,6 +42,7 @@ LL | offset_of!(StableWithUnstableField, unstable);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
||||||
--> $DIR/offset-of-unstable.rs:20:5
|
--> $DIR/offset-of-unstable.rs:20:5
|
||||||
|
@ -49,6 +51,7 @@ LL | offset_of!(StableWithUnstableFieldType, stable.unstable);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
||||||
--> $DIR/offset-of-unstable.rs:21:5
|
--> $DIR/offset-of-unstable.rs:21:5
|
||||||
|
@ -61,6 +64,7 @@ LL | | );
|
||||||
| |_____^
|
| |_____^
|
||||||
|
|
|
|
||||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
||||||
--> $DIR/offset-of-unstable.rs:26:5
|
--> $DIR/offset-of-unstable.rs:26:5
|
||||||
|
@ -73,6 +77,7 @@ LL | | );
|
||||||
| |_____^
|
| |_____^
|
||||||
|
|
|
|
||||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||||
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
9
tests/ui/parser/builtin-syntax.rs
Normal file
9
tests/ui/parser/builtin-syntax.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#![feature(builtin_syntax)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
builtin # foobar(); //~ ERROR unknown `builtin #` construct
|
||||||
|
}
|
||||||
|
|
||||||
|
fn not_identifier() {
|
||||||
|
builtin # {}(); //~ ERROR expected identifier after
|
||||||
|
}
|
14
tests/ui/parser/builtin-syntax.stderr
Normal file
14
tests/ui/parser/builtin-syntax.stderr
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
error: unknown `builtin #` construct `foobar`
|
||||||
|
--> $DIR/builtin-syntax.rs:4:5
|
||||||
|
|
|
||||||
|
LL | builtin # foobar();
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: expected identifier after `builtin #`
|
||||||
|
--> $DIR/builtin-syntax.rs:8:15
|
||||||
|
|
|
||||||
|
LL | builtin # {}();
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -112,7 +112,7 @@ LL | *_x0 = U;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let (ref mut _x0, _x1, ref _x2, ..) = tup;
|
LL | let (ref mut _x0, _x1, ref _x2, ..) = tup;
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
|
error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
|
||||||
--> $DIR/borrowck-move-ref-pattern.rs:27:5
|
--> $DIR/borrowck-move-ref-pattern.rs:27:5
|
||||||
|
@ -123,7 +123,7 @@ LL | *_x2 = U;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | let (ref _x0, _x1, ref mut _x2, ..) = tup;
|
LL | let (ref _x0, _x1, ref mut _x2, ..) = tup;
|
||||||
| ~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0382]: use of moved value: `tup.1`
|
error[E0382]: use of moved value: `tup.1`
|
||||||
--> $DIR/borrowck-move-ref-pattern.rs:28:10
|
--> $DIR/borrowck-move-ref-pattern.rs:28:10
|
||||||
|
|
|
@ -16,60 +16,60 @@ fn main() {
|
||||||
take_range(&std::ops::Range { start: 0, end: 1 });
|
take_range(&std::ops::Range { start: 0, end: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::Range { start: 0, end: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&::std::ops::Range { start: 0, end: 1 });
|
take_range(&::std::ops::Range { start: 0, end: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::Range { start: 0, end: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&std::ops::RangeFrom { start: 1 });
|
take_range(&std::ops::RangeFrom { start: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeFrom { start: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&::std::ops::RangeFrom { start: 1 });
|
take_range(&::std::ops::RangeFrom { start: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeFrom { start: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&std::ops::RangeFull {});
|
take_range(&std::ops::RangeFull {});
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeFull {}
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&::std::ops::RangeFull {});
|
take_range(&::std::ops::RangeFull {});
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeFull {}
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&std::ops::RangeInclusive::new(0, 1));
|
take_range(&std::ops::RangeInclusive::new(0, 1));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeInclusive::new(0, 1)
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&::std::ops::RangeInclusive::new(0, 1));
|
take_range(&::std::ops::RangeInclusive::new(0, 1));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1)
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&std::ops::RangeTo { end: 5 });
|
take_range(&std::ops::RangeTo { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeTo { end: 5 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&::std::ops::RangeTo { end: 5 });
|
take_range(&::std::ops::RangeTo { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeTo { end: 5 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&std::ops::RangeToInclusive { end: 5 });
|
take_range(&std::ops::RangeToInclusive { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeToInclusive { end: 5 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(&::std::ops::RangeToInclusive { end: 5 });
|
take_range(&::std::ops::RangeToInclusive { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 }
|
//~| SUGGESTION &
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,60 +16,60 @@ fn main() {
|
||||||
take_range(std::ops::Range { start: 0, end: 1 });
|
take_range(std::ops::Range { start: 0, end: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::Range { start: 0, end: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(::std::ops::Range { start: 0, end: 1 });
|
take_range(::std::ops::Range { start: 0, end: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::Range { start: 0, end: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(std::ops::RangeFrom { start: 1 });
|
take_range(std::ops::RangeFrom { start: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeFrom { start: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(::std::ops::RangeFrom { start: 1 });
|
take_range(::std::ops::RangeFrom { start: 1 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeFrom { start: 1 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(std::ops::RangeFull {});
|
take_range(std::ops::RangeFull {});
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeFull {}
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(::std::ops::RangeFull {});
|
take_range(::std::ops::RangeFull {});
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeFull {}
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(std::ops::RangeInclusive::new(0, 1));
|
take_range(std::ops::RangeInclusive::new(0, 1));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeInclusive::new(0, 1)
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(::std::ops::RangeInclusive::new(0, 1));
|
take_range(::std::ops::RangeInclusive::new(0, 1));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1)
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(std::ops::RangeTo { end: 5 });
|
take_range(std::ops::RangeTo { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeTo { end: 5 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(::std::ops::RangeTo { end: 5 });
|
take_range(::std::ops::RangeTo { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeTo { end: 5 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(std::ops::RangeToInclusive { end: 5 });
|
take_range(std::ops::RangeToInclusive { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &std::ops::RangeToInclusive { end: 5 }
|
//~| SUGGESTION &
|
||||||
|
|
||||||
take_range(::std::ops::RangeToInclusive { end: 5 });
|
take_range(::std::ops::RangeToInclusive { end: 5 });
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 }
|
//~| SUGGESTION &
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:16:16
|
--> $DIR/issue-54505-no-literals.rs:16:16
|
||||||
|
|
|
|
||||||
LL | take_range(std::ops::Range { start: 0, end: 1 });
|
LL | take_range(std::ops::Range { start: 0, end: 1 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `Range<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&std::ops::Range { start: 0, end: 1 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -15,15 +13,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&std::ops::Range { start: 0, end: 1 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:21:16
|
--> $DIR/issue-54505-no-literals.rs:21:16
|
||||||
|
|
|
|
||||||
LL | take_range(::std::ops::Range { start: 0, end: 1 });
|
LL | take_range(::std::ops::Range { start: 0, end: 1 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `Range<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&::std::ops::Range { start: 0, end: 1 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -33,15 +33,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&::std::ops::Range { start: 0, end: 1 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:26:16
|
--> $DIR/issue-54505-no-literals.rs:26:16
|
||||||
|
|
|
|
||||||
LL | take_range(std::ops::RangeFrom { start: 1 });
|
LL | take_range(std::ops::RangeFrom { start: 1 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFrom<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFrom<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&std::ops::RangeFrom { start: 1 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -51,15 +53,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&std::ops::RangeFrom { start: 1 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:31:16
|
--> $DIR/issue-54505-no-literals.rs:31:16
|
||||||
|
|
|
|
||||||
LL | take_range(::std::ops::RangeFrom { start: 1 });
|
LL | take_range(::std::ops::RangeFrom { start: 1 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFrom<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFrom<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&::std::ops::RangeFrom { start: 1 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -69,15 +73,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&::std::ops::RangeFrom { start: 1 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:36:16
|
--> $DIR/issue-54505-no-literals.rs:36:16
|
||||||
|
|
|
|
||||||
LL | take_range(std::ops::RangeFull {});
|
LL | take_range(std::ops::RangeFull {});
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFull`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFull`
|
|
||||||
| | help: consider borrowing here: `&std::ops::RangeFull {}`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -87,15 +93,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&std::ops::RangeFull {});
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:41:16
|
--> $DIR/issue-54505-no-literals.rs:41:16
|
||||||
|
|
|
|
||||||
LL | take_range(::std::ops::RangeFull {});
|
LL | take_range(::std::ops::RangeFull {});
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFull`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFull`
|
|
||||||
| | help: consider borrowing here: `&::std::ops::RangeFull {}`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -105,15 +113,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&::std::ops::RangeFull {});
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:46:16
|
--> $DIR/issue-54505-no-literals.rs:46:16
|
||||||
|
|
|
|
||||||
LL | take_range(std::ops::RangeInclusive::new(0, 1));
|
LL | take_range(std::ops::RangeInclusive::new(0, 1));
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&std::ops::RangeInclusive::new(0, 1)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -123,15 +133,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&std::ops::RangeInclusive::new(0, 1));
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:51:16
|
--> $DIR/issue-54505-no-literals.rs:51:16
|
||||||
|
|
|
|
||||||
LL | take_range(::std::ops::RangeInclusive::new(0, 1));
|
LL | take_range(::std::ops::RangeInclusive::new(0, 1));
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&::std::ops::RangeInclusive::new(0, 1)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -141,15 +153,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&::std::ops::RangeInclusive::new(0, 1));
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:56:16
|
--> $DIR/issue-54505-no-literals.rs:56:16
|
||||||
|
|
|
|
||||||
LL | take_range(std::ops::RangeTo { end: 5 });
|
LL | take_range(std::ops::RangeTo { end: 5 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeTo<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeTo<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&std::ops::RangeTo { end: 5 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -159,15 +173,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&std::ops::RangeTo { end: 5 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:61:16
|
--> $DIR/issue-54505-no-literals.rs:61:16
|
||||||
|
|
|
|
||||||
LL | take_range(::std::ops::RangeTo { end: 5 });
|
LL | take_range(::std::ops::RangeTo { end: 5 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeTo<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeTo<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&::std::ops::RangeTo { end: 5 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -177,15 +193,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&::std::ops::RangeTo { end: 5 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:66:16
|
--> $DIR/issue-54505-no-literals.rs:66:16
|
||||||
|
|
|
|
||||||
LL | take_range(std::ops::RangeToInclusive { end: 5 });
|
LL | take_range(std::ops::RangeToInclusive { end: 5 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeToInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeToInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&std::ops::RangeToInclusive { end: 5 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -195,15 +213,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&std::ops::RangeToInclusive { end: 5 });
|
||||||
|
| +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-literals.rs:71:16
|
--> $DIR/issue-54505-no-literals.rs:71:16
|
||||||
|
|
|
|
||||||
LL | take_range(::std::ops::RangeToInclusive { end: 5 });
|
LL | take_range(::std::ops::RangeToInclusive { end: 5 });
|
||||||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeToInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeToInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&::std::ops::RangeToInclusive { end: 5 }`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -213,6 +233,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&::std::ops::RangeToInclusive { end: 5 });
|
||||||
|
| +
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
|
|
|
@ -29,30 +29,30 @@ fn main() {
|
||||||
take_range(0..1);
|
take_range(0..1);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(0..1)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(1..);
|
take_range(1..);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(1..)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(..);
|
take_range(..);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(0..=1);
|
take_range(0..=1);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(0..=1)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(..5);
|
take_range(..5);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..5)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(..=42);
|
take_range(..=42);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..=42)
|
//~| SUGGESTION &(
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-std.rs:29:16
|
--> $DIR/issue-54505-no-std.rs:29:16
|
||||||
|
|
|
|
||||||
LL | take_range(0..1);
|
LL | take_range(0..1);
|
||||||
| ---------- ^^^^
|
| ---------- ^^^^ expected `&_`, found `Range<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `Range<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(0..1)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -27,15 +25,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(0..1));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-std.rs:34:16
|
--> $DIR/issue-54505-no-std.rs:34:16
|
||||||
|
|
|
|
||||||
LL | take_range(1..);
|
LL | take_range(1..);
|
||||||
| ---------- ^^^
|
| ---------- ^^^ expected `&_`, found `RangeFrom<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFrom<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(1..)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -45,15 +45,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(1..));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-std.rs:39:16
|
--> $DIR/issue-54505-no-std.rs:39:16
|
||||||
|
|
|
|
||||||
LL | take_range(..);
|
LL | take_range(..);
|
||||||
| ---------- ^^
|
| ---------- ^^ expected `&_`, found `RangeFull`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFull`
|
|
||||||
| | help: consider borrowing here: `&(..)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -63,15 +65,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(..));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-std.rs:44:16
|
--> $DIR/issue-54505-no-std.rs:44:16
|
||||||
|
|
|
|
||||||
LL | take_range(0..=1);
|
LL | take_range(0..=1);
|
||||||
| ---------- ^^^^^
|
| ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(0..=1)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -81,15 +85,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(0..=1));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-std.rs:49:16
|
--> $DIR/issue-54505-no-std.rs:49:16
|
||||||
|
|
|
|
||||||
LL | take_range(..5);
|
LL | take_range(..5);
|
||||||
| ---------- ^^^
|
| ---------- ^^^ expected `&_`, found `RangeTo<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeTo<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(..5)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -99,15 +105,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(..5));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505-no-std.rs:54:16
|
--> $DIR/issue-54505-no-std.rs:54:16
|
||||||
|
|
|
|
||||||
LL | take_range(..=42);
|
LL | take_range(..=42);
|
||||||
| ---------- ^^^^^
|
| ---------- ^^^^^ expected `&_`, found `RangeToInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeToInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(..=42)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -117,6 +125,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(..=42));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
|
@ -14,30 +14,30 @@ fn main() {
|
||||||
take_range(&(0..1));
|
take_range(&(0..1));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(0..1)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(&(1..));
|
take_range(&(1..));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(1..)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(&(..));
|
take_range(&(..));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(&(0..=1));
|
take_range(&(0..=1));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(0..=1)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(&(..5));
|
take_range(&(..5));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..5)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(&(..=42));
|
take_range(&(..=42));
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..=42)
|
//~| SUGGESTION &(
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,30 +14,30 @@ fn main() {
|
||||||
take_range(0..1);
|
take_range(0..1);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(0..1)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(1..);
|
take_range(1..);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(1..)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(..);
|
take_range(..);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(0..=1);
|
take_range(0..=1);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(0..=1)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(..5);
|
take_range(..5);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..5)
|
//~| SUGGESTION &(
|
||||||
|
|
||||||
take_range(..=42);
|
take_range(..=42);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
//~| HELP consider borrowing here
|
//~| HELP consider borrowing here
|
||||||
//~| SUGGESTION &(..=42)
|
//~| SUGGESTION &(
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505.rs:14:16
|
--> $DIR/issue-54505.rs:14:16
|
||||||
|
|
|
|
||||||
LL | take_range(0..1);
|
LL | take_range(0..1);
|
||||||
| ---------- ^^^^
|
| ---------- ^^^^ expected `&_`, found `Range<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `Range<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(0..1)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -15,15 +13,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(0..1));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505.rs:19:16
|
--> $DIR/issue-54505.rs:19:16
|
||||||
|
|
|
|
||||||
LL | take_range(1..);
|
LL | take_range(1..);
|
||||||
| ---------- ^^^
|
| ---------- ^^^ expected `&_`, found `RangeFrom<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFrom<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(1..)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -33,15 +33,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(1..));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505.rs:24:16
|
--> $DIR/issue-54505.rs:24:16
|
||||||
|
|
|
|
||||||
LL | take_range(..);
|
LL | take_range(..);
|
||||||
| ---------- ^^
|
| ---------- ^^ expected `&_`, found `RangeFull`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeFull`
|
|
||||||
| | help: consider borrowing here: `&(..)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -51,15 +53,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(..));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505.rs:29:16
|
--> $DIR/issue-54505.rs:29:16
|
||||||
|
|
|
|
||||||
LL | take_range(0..=1);
|
LL | take_range(0..=1);
|
||||||
| ---------- ^^^^^
|
| ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(0..=1)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -69,15 +73,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(0..=1));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505.rs:34:16
|
--> $DIR/issue-54505.rs:34:16
|
||||||
|
|
|
|
||||||
LL | take_range(..5);
|
LL | take_range(..5);
|
||||||
| ---------- ^^^
|
| ---------- ^^^ expected `&_`, found `RangeTo<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeTo<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(..5)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -87,15 +93,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(..5));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-54505.rs:39:16
|
--> $DIR/issue-54505.rs:39:16
|
||||||
|
|
|
|
||||||
LL | take_range(..=42);
|
LL | take_range(..=42);
|
||||||
| ---------- ^^^^^
|
| ---------- ^^^^^ expected `&_`, found `RangeToInclusive<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&_`, found `RangeToInclusive<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(..=42)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&_`
|
= note: expected reference `&_`
|
||||||
|
@ -105,6 +113,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
LL | fn take_range(_r: &impl RangeBounds<i8>) {}
|
||||||
| ^^^^^^^^^^ -------------------------
|
| ^^^^^^^^^^ -------------------------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | take_range(&(..=42));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/issue-73553-misinterp-range-literal.rs:12:10
|
--> $DIR/issue-73553-misinterp-range-literal.rs:12:10
|
||||||
|
|
|
|
||||||
LL | demo(tell(1)..tell(10));
|
LL | demo(tell(1)..tell(10));
|
||||||
| ---- ^^^^^^^^^^^^^^^^^
|
| ---- ^^^^^^^^^^^^^^^^^ expected `&Range<usize>`, found `Range<usize>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&Range<usize>`, found `Range<usize>`
|
|
||||||
| | help: consider borrowing here: `&(tell(1)..tell(10))`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&std::ops::Range<usize>`
|
= note: expected reference `&std::ops::Range<usize>`
|
||||||
|
@ -15,15 +13,17 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn demo(r: &Range) {
|
LL | fn demo(r: &Range) {
|
||||||
| ^^^^ ---------
|
| ^^^^ ---------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | demo(&(tell(1)..tell(10)));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-73553-misinterp-range-literal.rs:14:10
|
--> $DIR/issue-73553-misinterp-range-literal.rs:14:10
|
||||||
|
|
|
|
||||||
LL | demo(1..10);
|
LL | demo(1..10);
|
||||||
| ---- ^^^^^
|
| ---- ^^^^^ expected `&Range<usize>`, found `Range<{integer}>`
|
||||||
| | |
|
| |
|
||||||
| | expected `&Range<usize>`, found `Range<{integer}>`
|
|
||||||
| | help: consider borrowing here: `&(1..10)`
|
|
||||||
| arguments to this function are incorrect
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&std::ops::Range<usize>`
|
= note: expected reference `&std::ops::Range<usize>`
|
||||||
|
@ -33,6 +33,10 @@ note: function defined here
|
||||||
|
|
|
|
||||||
LL | fn demo(r: &Range) {
|
LL | fn demo(r: &Range) {
|
||||||
| ^^^^ ---------
|
| ^^^^ ---------
|
||||||
|
help: consider borrowing here
|
||||||
|
|
|
||||||
|
LL | demo(&(1..10));
|
||||||
|
| ++ +
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ trait Specialize {}
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait Bar {}
|
trait Bar {
|
||||||
|
fn bar();
|
||||||
|
}
|
||||||
|
|
||||||
// bgr360: I was only able to exercise the code path that raises the
|
// bgr360: I was only able to exercise the code path that raises the
|
||||||
// "missing ~const qualifier" error by making this base impl non-const, even
|
// "missing ~const qualifier" error by making this base impl non-const, even
|
||||||
|
@ -21,26 +23,36 @@ trait Bar {}
|
||||||
impl<T> Bar for T
|
impl<T> Bar for T
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
{}
|
{
|
||||||
|
default fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Bar for T
|
impl<T> Bar for T
|
||||||
where
|
where
|
||||||
T: Foo, //~ ERROR missing `~const` qualifier
|
T: Foo, //~ ERROR missing `~const` qualifier
|
||||||
T: Specialize,
|
T: Specialize,
|
||||||
{}
|
{
|
||||||
|
fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait Baz {}
|
trait Baz {
|
||||||
|
fn baz();
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Baz for T
|
impl<T> const Baz for T
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
{}
|
{
|
||||||
|
default fn baz() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz`
|
impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz`
|
||||||
where
|
where
|
||||||
T: Foo,
|
T: Foo,
|
||||||
T: Specialize,
|
T: Specialize,
|
||||||
{}
|
{
|
||||||
|
fn baz() {}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error: missing `~const` qualifier for specialization
|
error: missing `~const` qualifier for specialization
|
||||||
--> $DIR/const-default-bound-non-const-specialized-bound.rs:28:8
|
--> $DIR/const-default-bound-non-const-specialized-bound.rs:32:8
|
||||||
|
|
|
|
||||||
LL | T: Foo,
|
LL | T: Foo,
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `Baz`
|
error[E0119]: conflicting implementations of trait `Baz`
|
||||||
--> $DIR/const-default-bound-non-const-specialized-bound.rs:40:1
|
--> $DIR/const-default-bound-non-const-specialized-bound.rs:50:1
|
||||||
|
|
|
|
||||||
LL | impl<T> const Baz for T
|
LL | impl<T> const Baz for T
|
||||||
| ----------------------- first implementation here
|
| ----------------------- first implementation here
|
||||||
|
|
|
@ -11,27 +11,39 @@
|
||||||
trait Specialize {}
|
trait Specialize {}
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait Foo {}
|
trait Foo {
|
||||||
|
fn foo();
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Foo for T {}
|
impl<T> const Foo for T {
|
||||||
|
default fn foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Foo for T
|
impl<T> const Foo for T
|
||||||
where
|
where
|
||||||
T: ~const Specialize,
|
T: ~const Specialize,
|
||||||
{}
|
{
|
||||||
|
fn foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait Bar {}
|
trait Bar {
|
||||||
|
fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Bar for T
|
impl<T> const Bar for T
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
{}
|
{
|
||||||
|
default fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Bar for T
|
impl<T> const Bar for T
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
T: ~const Specialize,
|
T: ~const Specialize,
|
||||||
{}
|
{
|
||||||
|
fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -15,31 +15,43 @@ trait Specialize {}
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait Bar {}
|
trait Bar {
|
||||||
|
fn bar();
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Bar for T
|
impl<T> Bar for T
|
||||||
where
|
where
|
||||||
T: Foo,
|
T: Foo,
|
||||||
{}
|
{
|
||||||
|
default fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Bar for T
|
impl<T> const Bar for T
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
T: Specialize,
|
T: Specialize,
|
||||||
{}
|
{
|
||||||
|
fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait Baz {}
|
trait Baz {
|
||||||
|
fn baz();
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Baz for T
|
impl<T> const Baz for T
|
||||||
where
|
where
|
||||||
T: Foo,
|
T: Foo,
|
||||||
{}
|
{
|
||||||
|
default fn baz() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> const Baz for T
|
impl<T> const Baz for T
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
T: Specialize,
|
T: Specialize,
|
||||||
{}
|
{
|
||||||
|
fn baz() {}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -18,7 +18,7 @@ LL | &mut x.y
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn deref_extend_mut_field1(x: &mut Own<Point>) -> &mut isize {
|
LL | fn deref_extend_mut_field1(x: &mut Own<Point>) -> &mut isize {
|
||||||
| ~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0499]: cannot borrow `*x` as mutable more than once at a time
|
error[E0499]: cannot borrow `*x` as mutable more than once at a time
|
||||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19
|
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19
|
||||||
|
@ -50,7 +50,7 @@ LL | x.y = 3;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn assign_field2<'a>(x: &'a mut Own<Point>) {
|
LL | fn assign_field2<'a>(x: &'a mut Own<Point>) {
|
||||||
| ~~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0499]: cannot borrow `*x` as mutable more than once at a time
|
error[E0499]: cannot borrow `*x` as mutable more than once at a time
|
||||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5
|
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5
|
||||||
|
@ -82,7 +82,7 @@ LL | x.y_mut()
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn deref_extend_mut_method1(x: &mut Own<Point>) -> &mut isize {
|
LL | fn deref_extend_mut_method1(x: &mut Own<Point>) -> &mut isize {
|
||||||
| ~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6
|
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6
|
||||||
|
@ -104,7 +104,7 @@ LL | *x.y_mut() = 3;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn assign_method2<'a>(x: &'a mut Own<Point>) {
|
LL | fn assign_method2<'a>(x: &'a mut Own<Point>) {
|
||||||
| ~~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ LL | &mut **x
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn deref_extend_mut1<'a>(x: &'a mut Own<isize>) -> &'a mut isize {
|
LL | fn deref_extend_mut1<'a>(x: &'a mut Own<isize>) -> &'a mut isize {
|
||||||
| ~~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||||
--> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6
|
--> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6
|
||||||
|
@ -40,7 +40,7 @@ LL | **x = 3;
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn assign2<'a>(x: &'a mut Own<isize>) {
|
LL | fn assign2<'a>(x: &'a mut Own<isize>) {
|
||||||
| ~~~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ LL | (*f)();
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn test2<F>(f: &mut F) where F: FnMut() {
|
LL | fn test2<F>(f: &mut F) where F: FnMut() {
|
||||||
| ~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
|
||||||
|
@ -29,8 +29,8 @@ LL | f.f.call_mut(())
|
||||||
|
|
|
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn test4(f: &mut Test<'_>) {
|
LL | fn test4(f: &mut Test) {
|
||||||
| ~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
|
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
|
||||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | x.h();
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn b(x: &mut Foo) {
|
LL | fn b(x: &mut Foo) {
|
||||||
| ~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | x.push(format!("this is broken"));
|
||||||
help: consider changing this to be a mutable reference
|
help: consider changing this to be a mutable reference
|
||||||
|
|
|
|
||||||
LL | fn broken(x: &mut Vec<String>) {
|
LL | fn broken(x: &mut Vec<String>) {
|
||||||
| ~~~~~~~~~~~~~~~~
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue