Auto merge of #116112 - matthiaskrgr:rollup-s3cm2f7, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #116073 (Allow higher-ranked fn sigs in `ValuePairs`) - #116082 (Tweak expected message to explain what it's actually signifying) - #116086 (More accurate suggestion for `self.` and `Self::`) - #116104 (Reuse calculate_debuginfo_offset for fragments.) - #116106 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
0f2a9ce53e
25 changed files with 197 additions and 104 deletions
|
@ -158,8 +158,7 @@ fn calculate_debuginfo_offset<
|
||||||
L: DebugInfoOffsetLocation<'tcx, Bx>,
|
L: DebugInfoOffsetLocation<'tcx, Bx>,
|
||||||
>(
|
>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
local: mir::Local,
|
projection: &[mir::PlaceElem<'tcx>],
|
||||||
var: &PerLocalVarDebugInfo<'tcx, Bx::DIVariable>,
|
|
||||||
base: L,
|
base: L,
|
||||||
) -> DebugInfoOffset<L> {
|
) -> DebugInfoOffset<L> {
|
||||||
let mut direct_offset = Size::ZERO;
|
let mut direct_offset = Size::ZERO;
|
||||||
|
@ -167,7 +166,7 @@ fn calculate_debuginfo_offset<
|
||||||
let mut indirect_offsets = vec![];
|
let mut indirect_offsets = vec![];
|
||||||
let mut place = base;
|
let mut place = base;
|
||||||
|
|
||||||
for elem in &var.projection[..] {
|
for elem in projection {
|
||||||
match *elem {
|
match *elem {
|
||||||
mir::ProjectionElem::Deref => {
|
mir::ProjectionElem::Deref => {
|
||||||
indirect_offsets.push(Size::ZERO);
|
indirect_offsets.push(Size::ZERO);
|
||||||
|
@ -188,11 +187,7 @@ fn calculate_debuginfo_offset<
|
||||||
} => {
|
} => {
|
||||||
let offset = indirect_offsets.last_mut().unwrap_or(&mut direct_offset);
|
let offset = indirect_offsets.last_mut().unwrap_or(&mut direct_offset);
|
||||||
let FieldsShape::Array { stride, count: _ } = place.layout().fields else {
|
let FieldsShape::Array { stride, count: _ } = place.layout().fields else {
|
||||||
span_bug!(
|
bug!("ConstantIndex on non-array type {:?}", place.layout())
|
||||||
var.source_info.span,
|
|
||||||
"ConstantIndex on non-array type {:?}",
|
|
||||||
place.layout()
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
*offset += stride * index;
|
*offset += stride * index;
|
||||||
place = place.project_constant_index(bx, index);
|
place = place.project_constant_index(bx, index);
|
||||||
|
@ -200,11 +195,7 @@ fn calculate_debuginfo_offset<
|
||||||
_ => {
|
_ => {
|
||||||
// Sanity check for `can_use_in_debuginfo`.
|
// Sanity check for `can_use_in_debuginfo`.
|
||||||
debug_assert!(!elem.can_use_in_debuginfo());
|
debug_assert!(!elem.can_use_in_debuginfo());
|
||||||
span_bug!(
|
bug!("unsupported var debuginfo projection `{:?}`", projection)
|
||||||
var.source_info.span,
|
|
||||||
"unsupported var debuginfo place `{:?}`",
|
|
||||||
mir::Place { local, projection: var.projection },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,7 +398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return };
|
let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return };
|
||||||
|
|
||||||
let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } =
|
let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } =
|
||||||
calculate_debuginfo_offset(bx, local, &var, base.layout);
|
calculate_debuginfo_offset(bx, &var.projection, base.layout);
|
||||||
|
|
||||||
// When targeting MSVC, create extra allocas for arguments instead of pointing multiple
|
// When targeting MSVC, create extra allocas for arguments instead of pointing multiple
|
||||||
// dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records
|
// dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records
|
||||||
|
@ -425,7 +416,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
|
||||||
if should_create_individual_allocas {
|
if should_create_individual_allocas {
|
||||||
let DebugInfoOffset { direct_offset: _, indirect_offsets: _, result: place } =
|
let DebugInfoOffset { direct_offset: _, indirect_offsets: _, result: place } =
|
||||||
calculate_debuginfo_offset(bx, local, &var, base);
|
calculate_debuginfo_offset(bx, &var.projection, base);
|
||||||
|
|
||||||
// Create a variable which will be a pointer to the actual value
|
// Create a variable which will be a pointer to the actual value
|
||||||
let ptr_ty = Ty::new_ptr(
|
let ptr_ty = Ty::new_ptr(
|
||||||
|
@ -532,23 +523,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let fragment = if let Some(ref fragment) = var.composite {
|
let fragment = if let Some(ref fragment) = var.composite {
|
||||||
let var_layout = self.cx.layout_of(var_ty);
|
let var_layout = self.cx.layout_of(var_ty);
|
||||||
|
|
||||||
let mut fragment_start = Size::ZERO;
|
let DebugInfoOffset { direct_offset, indirect_offsets, result: fragment_layout } =
|
||||||
let mut fragment_layout = var_layout;
|
calculate_debuginfo_offset(bx, &fragment.projection, var_layout);
|
||||||
|
debug_assert!(indirect_offsets.is_empty());
|
||||||
for elem in &fragment.projection {
|
|
||||||
match *elem {
|
|
||||||
mir::ProjectionElem::Field(field, _) => {
|
|
||||||
let i = field.index();
|
|
||||||
fragment_start += fragment_layout.fields.offset(i);
|
|
||||||
fragment_layout = fragment_layout.field(self.cx, i);
|
|
||||||
}
|
|
||||||
_ => span_bug!(
|
|
||||||
var.source_info.span,
|
|
||||||
"unsupported fragment projection `{:?}`",
|
|
||||||
elem,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if fragment_layout.size == Size::ZERO {
|
if fragment_layout.size == Size::ZERO {
|
||||||
// Fragment is a ZST, so does not represent anything. Avoid generating anything
|
// Fragment is a ZST, so does not represent anything. Avoid generating anything
|
||||||
|
@ -559,7 +536,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
// DWARF is concerned, it's not really a fragment.
|
// DWARF is concerned, it's not really a fragment.
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(fragment_start..fragment_start + fragment_layout.size)
|
Some(direct_offset..direct_offset + fragment_layout.size)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -1134,7 +1134,10 @@ fn report_trait_method_mismatch<'tcx>(
|
||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
trait_err_span.map(|sp| (sp, Cow::from("type in trait"))),
|
trait_err_span.map(|sp| (sp, Cow::from("type in trait"))),
|
||||||
Some(infer::ValuePairs::Sigs(ExpectedFound { expected: trait_sig, found: impl_sig })),
|
Some(infer::ValuePairs::PolySigs(ExpectedFound {
|
||||||
|
expected: ty::Binder::dummy(trait_sig),
|
||||||
|
found: ty::Binder::dummy(impl_sig),
|
||||||
|
})),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -573,10 +573,7 @@ pub fn check_function_signature<'tcx>(
|
||||||
let norm_cause = ObligationCause::misc(cause.span, local_id);
|
let norm_cause = ObligationCause::misc(cause.span, local_id);
|
||||||
let actual_sig = ocx.normalize(&norm_cause, param_env, actual_sig);
|
let actual_sig = ocx.normalize(&norm_cause, param_env, actual_sig);
|
||||||
|
|
||||||
let expected_ty = Ty::new_fn_ptr(tcx, expected_sig);
|
match ocx.eq(&cause, param_env, expected_sig, actual_sig) {
|
||||||
let actual_ty = Ty::new_fn_ptr(tcx, actual_sig);
|
|
||||||
|
|
||||||
match ocx.eq(&cause, param_env, expected_ty, actual_ty) {
|
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let errors = ocx.select_all_or_error();
|
let errors = ocx.select_all_or_error();
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
|
@ -595,9 +592,9 @@ pub fn check_function_signature<'tcx>(
|
||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
None,
|
None,
|
||||||
Some(infer::ValuePairs::Sigs(ExpectedFound {
|
Some(infer::ValuePairs::PolySigs(ExpectedFound {
|
||||||
expected: tcx.liberate_late_bound_regions(fn_id, expected_sig),
|
expected: expected_sig,
|
||||||
found: tcx.liberate_late_bound_regions(fn_id, actual_sig),
|
found: actual_sig,
|
||||||
})),
|
})),
|
||||||
err,
|
err,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -478,7 +478,28 @@ impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> {
|
||||||
a: Self,
|
a: Self,
|
||||||
b: Self,
|
b: Self,
|
||||||
) -> TypeTrace<'tcx> {
|
) -> TypeTrace<'tcx> {
|
||||||
TypeTrace { cause: cause.clone(), values: Sigs(ExpectedFound::new(a_is_expected, a, b)) }
|
TypeTrace {
|
||||||
|
cause: cause.clone(),
|
||||||
|
values: PolySigs(ExpectedFound::new(
|
||||||
|
a_is_expected,
|
||||||
|
ty::Binder::dummy(a),
|
||||||
|
ty::Binder::dummy(b),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> ToTrace<'tcx> for ty::PolyFnSig<'tcx> {
|
||||||
|
fn to_trace(
|
||||||
|
cause: &ObligationCause<'tcx>,
|
||||||
|
a_is_expected: bool,
|
||||||
|
a: Self,
|
||||||
|
b: Self,
|
||||||
|
) -> TypeTrace<'tcx> {
|
||||||
|
TypeTrace {
|
||||||
|
cause: cause.clone(),
|
||||||
|
values: PolySigs(ExpectedFound::new(a_is_expected, a, b)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1660,7 +1660,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
_ => (false, Mismatch::Fixed("type")),
|
_ => (false, Mismatch::Fixed("type")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ValuePairs::Sigs(infer::ExpectedFound { expected, found }) => {
|
ValuePairs::PolySigs(infer::ExpectedFound { expected, found }) => {
|
||||||
OpaqueTypesVisitor::visit_expected_found(self.tcx, expected, found, span)
|
OpaqueTypesVisitor::visit_expected_found(self.tcx, expected, found, span)
|
||||||
.report(diag);
|
.report(diag);
|
||||||
(false, Mismatch::Fixed("signature"))
|
(false, Mismatch::Fixed("signature"))
|
||||||
|
@ -2232,15 +2232,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
ret => ret,
|
ret => ret,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infer::Sigs(exp_found) => {
|
infer::PolySigs(exp_found) => {
|
||||||
let exp_found = self.resolve_vars_if_possible(exp_found);
|
let exp_found = self.resolve_vars_if_possible(exp_found);
|
||||||
if exp_found.references_error() {
|
if exp_found.references_error() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let (exp, fnd) = self.cmp_fn_sig(
|
let (exp, fnd) = self.cmp_fn_sig(&exp_found.expected, &exp_found.found);
|
||||||
&ty::Binder::dummy(exp_found.expected),
|
|
||||||
&ty::Binder::dummy(exp_found.found),
|
|
||||||
);
|
|
||||||
Some((exp, fnd, None, None))
|
Some((exp, fnd, None, None))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
&& let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin)
|
&& let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin)
|
||||||
&& let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code()
|
&& let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code()
|
||||||
&& sub_trace.values == sup_trace.values
|
&& sub_trace.values == sup_trace.values
|
||||||
&& let ValuePairs::Sigs(ExpectedFound { expected, found }) = sub_trace.values
|
&& let ValuePairs::PolySigs(ExpectedFound { expected, found }) = sub_trace.values
|
||||||
{
|
{
|
||||||
// FIXME(compiler-errors): Don't like that this needs `Ty`s, but
|
// FIXME(compiler-errors): Don't like that this needs `Ty`s, but
|
||||||
// all of the region highlighting machinery only deals with those.
|
// all of the region highlighting machinery only deals with those.
|
||||||
let guar = self.emit_err(
|
let guar = self.emit_err(
|
||||||
var_origin.span(),
|
var_origin.span(),
|
||||||
Ty::new_fn_ptr(self.cx.tcx,ty::Binder::dummy(expected)),
|
Ty::new_fn_ptr(self.cx.tcx, expected),
|
||||||
Ty::new_fn_ptr(self.cx.tcx,ty::Binder::dummy(found)),
|
Ty::new_fn_ptr(self.cx.tcx, found),
|
||||||
*trait_item_def_id,
|
*trait_item_def_id,
|
||||||
);
|
);
|
||||||
return Some(guar);
|
return Some(guar);
|
||||||
|
|
|
@ -616,9 +616,13 @@ fn foo(&self) -> Self::T { String::new() }
|
||||||
for item in &items[..] {
|
for item in &items[..] {
|
||||||
if let hir::AssocItemKind::Type = item.kind {
|
if let hir::AssocItemKind::Type = item.kind {
|
||||||
let assoc_ty = tcx.type_of(item.id.owner_id).instantiate_identity();
|
let assoc_ty = tcx.type_of(item.id.owner_id).instantiate_identity();
|
||||||
|
if let hir::Defaultness::Default { has_value: true } = tcx.defaultness(item.id.owner_id)
|
||||||
if self.infcx.can_eq(param_env, assoc_ty, found) {
|
&& self.infcx.can_eq(param_env, assoc_ty, found)
|
||||||
diag.span_label(item.span, "expected this associated type");
|
{
|
||||||
|
diag.span_label(
|
||||||
|
item.span,
|
||||||
|
format!("associated type is `default` and may be overridden"),
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,7 @@ pub enum ValuePairs<'tcx> {
|
||||||
Aliases(ExpectedFound<ty::AliasTy<'tcx>>),
|
Aliases(ExpectedFound<ty::AliasTy<'tcx>>),
|
||||||
TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
|
TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
|
||||||
PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
|
PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
|
||||||
Sigs(ExpectedFound<ty::FnSig<'tcx>>),
|
PolySigs(ExpectedFound<ty::PolyFnSig<'tcx>>),
|
||||||
ExistentialTraitRef(ExpectedFound<ty::PolyExistentialTraitRef<'tcx>>),
|
ExistentialTraitRef(ExpectedFound<ty::PolyExistentialTraitRef<'tcx>>),
|
||||||
ExistentialProjection(ExpectedFound<ty::PolyExistentialProjection<'tcx>>),
|
ExistentialProjection(ExpectedFound<ty::PolyExistentialProjection<'tcx>>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -2333,7 +2333,10 @@ impl CheckAttrVisitor<'_> {
|
||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
None,
|
None,
|
||||||
Some(ValuePairs::Sigs(ExpectedFound { expected: expected_sig, found: sig })),
|
Some(ValuePairs::PolySigs(ExpectedFound {
|
||||||
|
expected: ty::Binder::dummy(expected_sig),
|
||||||
|
found: ty::Binder::dummy(sig),
|
||||||
|
})),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -214,6 +214,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
module: None,
|
module: None,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let mut span_label = None;
|
||||||
let item_span = path.last().unwrap().ident.span;
|
let item_span = path.last().unwrap().ident.span;
|
||||||
let (mod_prefix, mod_str, module, suggestion) = if path.len() == 1 {
|
let (mod_prefix, mod_str, module, suggestion) = if path.len() == 1 {
|
||||||
debug!(?self.diagnostic_metadata.current_impl_items);
|
debug!(?self.diagnostic_metadata.current_impl_items);
|
||||||
|
@ -224,32 +225,41 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
&& let FnKind::Fn(_, _, sig, ..) = fn_kind
|
&& let FnKind::Fn(_, _, sig, ..) = fn_kind
|
||||||
&& let Some(items) = self.diagnostic_metadata.current_impl_items
|
&& let Some(items) = self.diagnostic_metadata.current_impl_items
|
||||||
&& let Some(item) = items.iter().find(|i| {
|
&& let Some(item) = items.iter().find(|i| {
|
||||||
if let AssocItemKind::Fn(..) | AssocItemKind::Const(..) = &i.kind
|
i.ident.name == item_str.name
|
||||||
&& i.ident.name == item_str.name
|
// Don't suggest if the item is in Fn signature arguments (#112590).
|
||||||
// don't suggest if the item is in Fn signature arguments
|
|
||||||
// issue #112590
|
|
||||||
&& !sig.span.contains(item_span)
|
&& !sig.span.contains(item_span)
|
||||||
{
|
|
||||||
debug!(?item_str.name);
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
false
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
let self_sugg = match &item.kind {
|
let sp = item_span.shrink_to_lo();
|
||||||
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => "self.",
|
match &item.kind {
|
||||||
_ => "Self::",
|
AssocItemKind::Fn(fn_)
|
||||||
};
|
if !sig.decl.has_self() && fn_.sig.decl.has_self() => {
|
||||||
|
// Ensure that we only suggest `self.` if `self` is available,
|
||||||
Some((
|
// you can't call `fn foo(&self)` from `fn bar()` (#115992).
|
||||||
item_span.shrink_to_lo(),
|
// We also want to mention that the method exists.
|
||||||
match &item.kind {
|
span_label = Some((
|
||||||
AssocItemKind::Fn(..) => "consider using the associated function",
|
item.ident.span,
|
||||||
AssocItemKind::Const(..) => "consider using the associated constant",
|
"a method by that name is available on `Self` here",
|
||||||
_ => unreachable!("item kind was filtered above"),
|
));
|
||||||
},
|
None
|
||||||
self_sugg.to_string()
|
}
|
||||||
))
|
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some((
|
||||||
|
sp,
|
||||||
|
"consider using the method on `Self`",
|
||||||
|
"self.".to_string(),
|
||||||
|
)),
|
||||||
|
AssocItemKind::Fn(_) => Some((
|
||||||
|
sp,
|
||||||
|
"consider using the associated function on `Self`",
|
||||||
|
"Self::".to_string(),
|
||||||
|
)),
|
||||||
|
AssocItemKind::Const(..) => Some((
|
||||||
|
sp,
|
||||||
|
"consider using the associated constant on `Self`",
|
||||||
|
"Self::".to_string(),
|
||||||
|
)),
|
||||||
|
_ => None
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -314,7 +324,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||||
msg: format!("cannot find {expected} `{item_str}` in {mod_prefix}{mod_str}"),
|
msg: format!("cannot find {expected} `{item_str}` in {mod_prefix}{mod_str}"),
|
||||||
fallback_label,
|
fallback_label,
|
||||||
span: item_span,
|
span: item_span,
|
||||||
span_label: None,
|
span_label,
|
||||||
could_be_expr: false,
|
could_be_expr: false,
|
||||||
suggestion,
|
suggestion,
|
||||||
module,
|
module,
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
go-to: "file://" + |DOC_PATH| + "/settings/index.html"
|
go-to: "file://" + |DOC_PATH| + "/settings/index.html"
|
||||||
// Wait a bit to be sure the default theme is applied.
|
// Wait a bit to be sure the default theme is applied.
|
||||||
// If the theme isn't applied, the command will time out.
|
// If the theme isn't applied, the command will time out.
|
||||||
wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"})
|
wait-for-css: ("body", {"background-color": "#0f1419"})
|
||||||
|
|
|
@ -29,7 +29,7 @@ error[E0053]: method `make` has an incompatible type for trait
|
||||||
--> $DIR/defaults-specialization.rs:35:18
|
--> $DIR/defaults-specialization.rs:35:18
|
||||||
|
|
|
|
||||||
LL | default type Ty = bool;
|
LL | default type Ty = bool;
|
||||||
| ----------------------- expected this associated type
|
| ----------------------- associated type is `default` and may be overridden
|
||||||
LL |
|
LL |
|
||||||
LL | fn make() -> bool { true }
|
LL | fn make() -> bool { true }
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -76,7 +76,7 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/defaults-specialization.rs:44:29
|
--> $DIR/defaults-specialization.rs:44:29
|
||||||
|
|
|
|
||||||
LL | default type Ty = bool;
|
LL | default type Ty = bool;
|
||||||
| ----------------------- expected this associated type
|
| ----------------------- associated type is `default` and may be overridden
|
||||||
LL |
|
LL |
|
||||||
LL | fn make() -> Self::Ty { true }
|
LL | fn make() -> Self::Ty { true }
|
||||||
| -------- ^^^^ expected associated type, found `bool`
|
| -------- ^^^^ expected associated type, found `bool`
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: `#[panic_handler]` function has wrong type
|
||||||
LL | fn panic(info: PanicInfo) -> () {}
|
LL | fn panic(info: PanicInfo) -> () {}
|
||||||
| ^^^^^^^^^ expected `&PanicInfo<'_>`, found `PanicInfo<'_>`
|
| ^^^^^^^^^ expected `&PanicInfo<'_>`, found `PanicInfo<'_>`
|
||||||
|
|
|
|
||||||
= note: expected signature `fn(&PanicInfo<'_>) -> !`
|
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
|
||||||
found signature `fn(PanicInfo<'_>)`
|
found signature `for<'a> fn(PanicInfo<'a>)`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: `#[panic_handler]` function has wrong type
|
||||||
LL | fn panic(info: &'static PanicInfo) -> !
|
LL | fn panic(info: &'static PanicInfo) -> !
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
|
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
|
||||||
found fn pointer `for<'a> fn(&'static PanicInfo<'a>) -> _`
|
found signature `for<'a> fn(&'static PanicInfo<'a>) -> _`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0308]: `#[panic_handler]` function has wrong type
|
||||||
LL | fn panic() -> ! {
|
LL | fn panic() -> ! {
|
||||||
| ^^^^^^^^^^^^^^^ incorrect number of function parameters
|
| ^^^^^^^^^^^^^^^ incorrect number of function parameters
|
||||||
|
|
|
|
||||||
= note: expected signature `fn(&PanicInfo<'_>) -> _`
|
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
|
||||||
found signature `fn() -> _`
|
found signature `fn() -> _`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: `#[panic_handler]` function has wrong type
|
||||||
LL | fn panic(info: &PanicInfo<'static>) -> !
|
LL | fn panic(info: &PanicInfo<'static>) -> !
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
|
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
|
||||||
found fn pointer `for<'a> fn(&'a PanicInfo<'static>) -> _`
|
found signature `for<'a> fn(&'a PanicInfo<'static>) -> _`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
struct Foo {
|
||||||
|
field: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
fn field(&self) -> u32 {
|
||||||
|
self.field
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new() -> Foo {
|
||||||
|
field; //~ ERROR cannot find value `field` in this scope
|
||||||
|
Foo { field } //~ ERROR cannot find value `field` in this scope
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,21 @@
|
||||||
|
error[E0425]: cannot find value `field` in this scope
|
||||||
|
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9
|
||||||
|
|
|
||||||
|
LL | fn field(&self) -> u32 {
|
||||||
|
| ----- a method by that name is available on `Self` here
|
||||||
|
...
|
||||||
|
LL | field;
|
||||||
|
| ^^^^^ a field by this name exists in `Self`
|
||||||
|
|
||||||
|
error[E0425]: cannot find value `field` in this scope
|
||||||
|
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15
|
||||||
|
|
|
||||||
|
LL | fn field(&self) -> u32 {
|
||||||
|
| ----- a method by that name is available on `Self` here
|
||||||
|
...
|
||||||
|
LL | Foo { field }
|
||||||
|
| ^^^^^ a field by this name exists in `Self`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0425`.
|
|
@ -19,7 +19,7 @@ error[E0425]: cannot find function `first` in this scope
|
||||||
LL | first()
|
LL | first()
|
||||||
| ^^^^^ not found in this scope
|
| ^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated function
|
help: consider using the method on `Self`
|
||||||
|
|
|
|
||||||
LL | self.first()
|
LL | self.first()
|
||||||
| +++++
|
| +++++
|
||||||
|
|
|
@ -73,7 +73,7 @@ error[E0425]: cannot find function `static_method` in this scope
|
||||||
LL | static_method();
|
LL | static_method();
|
||||||
| ^^^^^^^^^^^^^ not found in this scope
|
| ^^^^^^^^^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated function
|
help: consider using the associated function on `Self`
|
||||||
|
|
|
|
||||||
LL | Self::static_method();
|
LL | Self::static_method();
|
||||||
| ++++++
|
| ++++++
|
||||||
|
@ -102,7 +102,7 @@ error[E0425]: cannot find function `grow_older` in this scope
|
||||||
LL | grow_older();
|
LL | grow_older();
|
||||||
| ^^^^^^^^^^ not found in this scope
|
| ^^^^^^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated function
|
help: consider using the associated function on `Self`
|
||||||
|
|
|
|
||||||
LL | Self::grow_older();
|
LL | Self::grow_older();
|
||||||
| ++++++
|
| ++++++
|
||||||
|
|
|
@ -10,7 +10,7 @@ error[E0425]: cannot find function `sleep` in this scope
|
||||||
LL | sleep();
|
LL | sleep();
|
||||||
| ^^^^^ not found in this scope
|
| ^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated function
|
help: consider using the method on `Self`
|
||||||
|
|
|
|
||||||
LL | self.sleep();
|
LL | self.sleep();
|
||||||
| +++++
|
| +++++
|
||||||
|
|
|
@ -12,7 +12,7 @@ error[E0308]: mismatched types
|
||||||
--> $DIR/specialization-default-types.rs:15:9
|
--> $DIR/specialization-default-types.rs:15:9
|
||||||
|
|
|
|
||||||
LL | default type Output = Box<T>;
|
LL | default type Output = Box<T>;
|
||||||
| ----------------------------- expected this associated type
|
| ----------------------------- associated type is `default` and may be overridden
|
||||||
LL | default fn generate(self) -> Self::Output {
|
LL | default fn generate(self) -> Self::Output {
|
||||||
| ------------ expected `<T as Example>::Output` because of return type
|
| ------------ expected `<T as Example>::Output` because of return type
|
||||||
LL | Box::new(self)
|
LL | Box::new(self)
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0425]: cannot find value `A_CONST` in this scope
|
||||||
LL | A_CONST
|
LL | A_CONST
|
||||||
| ^^^^^^^ not found in this scope
|
| ^^^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated constant
|
help: consider using the associated constant on `Self`
|
||||||
|
|
|
|
||||||
LL | Self::A_CONST
|
LL | Self::A_CONST
|
||||||
| ++++++
|
| ++++++
|
||||||
|
|
|
@ -17,4 +17,12 @@ impl S {
|
||||||
bar(); //~ ERROR cannot find function `bar` in this scope
|
bar(); //~ ERROR cannot find function `bar` in this scope
|
||||||
baz(2, 3); //~ ERROR cannot find function `baz` in this scope
|
baz(2, 3); //~ ERROR cannot find function `baz` in this scope
|
||||||
}
|
}
|
||||||
|
fn d(&self) {
|
||||||
|
fn c() {
|
||||||
|
foo(); //~ ERROR cannot find function `foo` in this scope
|
||||||
|
}
|
||||||
|
foo(); //~ ERROR cannot find function `foo` in this scope
|
||||||
|
bar(); //~ ERROR cannot find function `bar` in this scope
|
||||||
|
baz(2, 3); //~ ERROR cannot find function `baz` in this scope
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0425]: cannot find function `foo` in this scope
|
||||||
LL | foo();
|
LL | foo();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated function
|
help: consider using the associated function on `Self`
|
||||||
|
|
|
|
||||||
LL | Self::foo();
|
LL | Self::foo();
|
||||||
| ++++++
|
| ++++++
|
||||||
|
@ -12,13 +12,11 @@ LL | Self::foo();
|
||||||
error[E0425]: cannot find function `bar` in this scope
|
error[E0425]: cannot find function `bar` in this scope
|
||||||
--> $DIR/assoc_fn_without_self.rs:17:9
|
--> $DIR/assoc_fn_without_self.rs:17:9
|
||||||
|
|
|
|
||||||
|
LL | fn bar(&self) {}
|
||||||
|
| --- a method by that name is available on `Self` here
|
||||||
|
...
|
||||||
LL | bar();
|
LL | bar();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
||||||
help: consider using the associated function
|
|
||||||
|
|
|
||||||
LL | self.bar();
|
|
||||||
| +++++
|
|
||||||
|
|
||||||
error[E0425]: cannot find function `baz` in this scope
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
--> $DIR/assoc_fn_without_self.rs:18:9
|
--> $DIR/assoc_fn_without_self.rs:18:9
|
||||||
|
@ -26,7 +24,7 @@ error[E0425]: cannot find function `baz` in this scope
|
||||||
LL | baz(2, 3);
|
LL | baz(2, 3);
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider using the associated function
|
help: consider using the associated function on `Self`
|
||||||
|
|
|
|
||||||
LL | Self::baz(2, 3);
|
LL | Self::baz(2, 3);
|
||||||
| ++++++
|
| ++++++
|
||||||
|
@ -37,6 +35,45 @@ error[E0425]: cannot find function `foo` in this scope
|
||||||
LL | foo();
|
LL | foo();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error[E0425]: cannot find function `foo` in this scope
|
||||||
|
--> $DIR/assoc_fn_without_self.rs:24:9
|
||||||
|
|
|
||||||
|
LL | foo();
|
||||||
|
| ^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: consider using the associated function on `Self`
|
||||||
|
|
|
||||||
|
LL | Self::foo();
|
||||||
|
| ++++++
|
||||||
|
|
||||||
|
error[E0425]: cannot find function `bar` in this scope
|
||||||
|
--> $DIR/assoc_fn_without_self.rs:25:9
|
||||||
|
|
|
||||||
|
LL | bar();
|
||||||
|
| ^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: consider using the method on `Self`
|
||||||
|
|
|
||||||
|
LL | self.bar();
|
||||||
|
| +++++
|
||||||
|
|
||||||
|
error[E0425]: cannot find function `baz` in this scope
|
||||||
|
--> $DIR/assoc_fn_without_self.rs:26:9
|
||||||
|
|
|
||||||
|
LL | baz(2, 3);
|
||||||
|
| ^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: consider using the associated function on `Self`
|
||||||
|
|
|
||||||
|
LL | Self::baz(2, 3);
|
||||||
|
| ++++++
|
||||||
|
|
||||||
|
error[E0425]: cannot find function `foo` in this scope
|
||||||
|
--> $DIR/assoc_fn_without_self.rs:22:13
|
||||||
|
|
|
||||||
|
LL | foo();
|
||||||
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0425`.
|
For more information about this error, try `rustc --explain E0425`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue