mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Const generic parameters aren't bounds, even if we end up erroring because of the bound that binds the parameter's type
This commit is contained in:
parent
1cb75dc4a9
commit
e4c9a8cf9b
@ -2776,97 +2776,115 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
let mut this = "this bound";
|
let mut this = "this bound";
|
||||||
let mut note = None;
|
let mut note = None;
|
||||||
let mut help = None;
|
let mut help = None;
|
||||||
if let ty::PredicateKind::Clause(clause) = predicate.kind().skip_binder()
|
if let ty::PredicateKind::Clause(clause) = predicate.kind().skip_binder() {
|
||||||
&& let ty::ClauseKind::Trait(trait_pred) = clause
|
match clause {
|
||||||
{
|
ty::ClauseKind::Trait(trait_pred) => {
|
||||||
let def_id = trait_pred.def_id();
|
let def_id = trait_pred.def_id();
|
||||||
let visible_item = if let Some(local) = def_id.as_local() {
|
let visible_item = if let Some(local) = def_id.as_local() {
|
||||||
// Check for local traits being reachable.
|
// Check for local traits being reachable.
|
||||||
let vis = &tcx.resolutions(()).effective_visibilities;
|
let vis = &tcx.resolutions(()).effective_visibilities;
|
||||||
// Account for non-`pub` traits in the root of the local crate.
|
// Account for non-`pub` traits in the root of the local crate.
|
||||||
let is_locally_reachable = tcx.parent(def_id).is_crate_root();
|
let is_locally_reachable = tcx.parent(def_id).is_crate_root();
|
||||||
vis.is_reachable(local) || is_locally_reachable
|
vis.is_reachable(local) || is_locally_reachable
|
||||||
} else {
|
|
||||||
// Check for foreign traits being reachable.
|
|
||||||
tcx.visible_parent_map(()).get(&def_id).is_some()
|
|
||||||
};
|
|
||||||
if tcx.is_lang_item(def_id, LangItem::Sized) {
|
|
||||||
// Check if this is an implicit bound, even in foreign crates.
|
|
||||||
if tcx
|
|
||||||
.generics_of(item_def_id)
|
|
||||||
.own_params
|
|
||||||
.iter()
|
|
||||||
.any(|param| tcx.def_span(param.def_id) == span)
|
|
||||||
{
|
|
||||||
a = "an implicit `Sized`";
|
|
||||||
this = "the implicit `Sized` requirement on this type parameter";
|
|
||||||
}
|
|
||||||
if let Some(hir::Node::TraitItem(hir::TraitItem {
|
|
||||||
generics,
|
|
||||||
kind: hir::TraitItemKind::Type(bounds, None),
|
|
||||||
..
|
|
||||||
})) = tcx.hir().get_if_local(item_def_id)
|
|
||||||
// Do not suggest relaxing if there is an explicit `Sized` obligation.
|
|
||||||
&& !bounds.iter()
|
|
||||||
.filter_map(|bound| bound.trait_ref())
|
|
||||||
.any(|tr| tr.trait_def_id() == tcx.lang_items().sized_trait())
|
|
||||||
{
|
|
||||||
let (span, separator) = if let [.., last] = bounds {
|
|
||||||
(last.span().shrink_to_hi(), " +")
|
|
||||||
} else {
|
} else {
|
||||||
(generics.span.shrink_to_hi(), ":")
|
// Check for foreign traits being reachable.
|
||||||
|
tcx.visible_parent_map(()).get(&def_id).is_some()
|
||||||
};
|
};
|
||||||
err.span_suggestion_verbose(
|
if tcx.is_lang_item(def_id, LangItem::Sized) {
|
||||||
span,
|
// Check if this is an implicit bound, even in foreign crates.
|
||||||
"consider relaxing the implicit `Sized` restriction",
|
if tcx
|
||||||
format!("{separator} ?Sized"),
|
.generics_of(item_def_id)
|
||||||
Applicability::MachineApplicable,
|
.own_params
|
||||||
);
|
.iter()
|
||||||
|
.any(|param| tcx.def_span(param.def_id) == span)
|
||||||
|
{
|
||||||
|
a = "an implicit `Sized`";
|
||||||
|
this =
|
||||||
|
"the implicit `Sized` requirement on this type parameter";
|
||||||
|
}
|
||||||
|
if let Some(hir::Node::TraitItem(hir::TraitItem {
|
||||||
|
generics,
|
||||||
|
kind: hir::TraitItemKind::Type(bounds, None),
|
||||||
|
..
|
||||||
|
})) = tcx.hir().get_if_local(item_def_id)
|
||||||
|
// Do not suggest relaxing if there is an explicit `Sized` obligation.
|
||||||
|
&& !bounds.iter()
|
||||||
|
.filter_map(|bound| bound.trait_ref())
|
||||||
|
.any(|tr| tr.trait_def_id() == tcx.lang_items().sized_trait())
|
||||||
|
{
|
||||||
|
let (span, separator) = if let [.., last] = bounds {
|
||||||
|
(last.span().shrink_to_hi(), " +")
|
||||||
|
} else {
|
||||||
|
(generics.span.shrink_to_hi(), ":")
|
||||||
|
};
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
span,
|
||||||
|
"consider relaxing the implicit `Sized` restriction",
|
||||||
|
format!("{separator} ?Sized"),
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let DefKind::Trait = tcx.def_kind(item_def_id)
|
||||||
|
&& !visible_item
|
||||||
|
{
|
||||||
|
note = Some(format!(
|
||||||
|
"`{short_item_name}` is a \"sealed trait\", because to implement it \
|
||||||
|
you also need to implement `{}`, which is not accessible; this is \
|
||||||
|
usually done to force you to use one of the provided types that \
|
||||||
|
already implement it",
|
||||||
|
with_no_trimmed_paths!(tcx.def_path_str(def_id)),
|
||||||
|
));
|
||||||
|
let impls_of = tcx.trait_impls_of(def_id);
|
||||||
|
let impls = impls_of
|
||||||
|
.non_blanket_impls()
|
||||||
|
.values()
|
||||||
|
.flatten()
|
||||||
|
.chain(impls_of.blanket_impls().iter())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
if !impls.is_empty() {
|
||||||
|
let len = impls.len();
|
||||||
|
let mut types = impls
|
||||||
|
.iter()
|
||||||
|
.map(|t| {
|
||||||
|
with_no_trimmed_paths!(format!(
|
||||||
|
" {}",
|
||||||
|
tcx.type_of(*t).instantiate_identity(),
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let post = if types.len() > 9 {
|
||||||
|
types.truncate(8);
|
||||||
|
format!("\nand {} others", len - 8)
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
help = Some(format!(
|
||||||
|
"the following type{} implement{} the trait:\n{}{post}",
|
||||||
|
pluralize!(len),
|
||||||
|
if len == 1 { "s" } else { "" },
|
||||||
|
types.join("\n"),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ty::ClauseKind::ConstArgHasType(..) => {
|
||||||
if let DefKind::Trait = tcx.def_kind(item_def_id)
|
let descr =
|
||||||
&& !visible_item
|
format!("required by a const generic parameter in `{item_name}`");
|
||||||
{
|
if span.is_visible(sm) {
|
||||||
note = Some(format!(
|
let msg = format!(
|
||||||
"`{short_item_name}` is a \"sealed trait\", because to implement it \
|
"required by this const generic parameter in `{short_item_name}`"
|
||||||
you also need to implement `{}`, which is not accessible; this is \
|
);
|
||||||
usually done to force you to use one of the provided types that \
|
multispan.push_span_label(span, msg);
|
||||||
already implement it",
|
err.span_note(multispan, descr);
|
||||||
with_no_trimmed_paths!(tcx.def_path_str(def_id)),
|
|
||||||
));
|
|
||||||
let impls_of = tcx.trait_impls_of(def_id);
|
|
||||||
let impls = impls_of
|
|
||||||
.non_blanket_impls()
|
|
||||||
.values()
|
|
||||||
.flatten()
|
|
||||||
.chain(impls_of.blanket_impls().iter())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if !impls.is_empty() {
|
|
||||||
let len = impls.len();
|
|
||||||
let mut types = impls
|
|
||||||
.iter()
|
|
||||||
.map(|t| {
|
|
||||||
with_no_trimmed_paths!(format!(
|
|
||||||
" {}",
|
|
||||||
tcx.type_of(*t).instantiate_identity(),
|
|
||||||
))
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let post = if types.len() > 9 {
|
|
||||||
types.truncate(8);
|
|
||||||
format!("\nand {} others", len - 8)
|
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
err.span_note(tcx.def_span(item_def_id), descr);
|
||||||
};
|
}
|
||||||
help = Some(format!(
|
return;
|
||||||
"the following type{} implement{} the trait:\n{}{post}",
|
|
||||||
pluralize!(len),
|
|
||||||
if len == 1 { "s" } else { "" },
|
|
||||||
types.join("\n"),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let descr = format!("required by {a} bound in `{item_name}`");
|
let descr = format!("required by {a} bound in `{item_name}`");
|
||||||
if span.is_visible(sm) {
|
if span.is_visible(sm) {
|
||||||
let msg = format!("required by {this} in `{short_item_name}`");
|
let msg = format!("required by {this} in `{short_item_name}`");
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed for `Foo<_>`
|
|||||||
LL | let foo = Foo::foo();
|
LL | let foo = Foo::foo();
|
||||||
| ^^^ ---------- type must be known at this point
|
| ^^^ ---------- type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `Foo::<N>::foo`
|
note: required by a const generic parameter in `Foo::<N>::foo`
|
||||||
--> $DIR/doesnt_infer.rs:5:6
|
--> $DIR/doesnt_infer.rs:5:6
|
||||||
|
|
|
|
||||||
LL | impl<const N: u32> Foo<N> {
|
LL | impl<const N: u32> Foo<N> {
|
||||||
| ^^^^^^^^^^^^ required by this bound in `Foo::<N>::foo`
|
| ^^^^^^^^^^^^ required by this const generic parameter in `Foo::<N>::foo`
|
||||||
LL | fn foo() -> Self {
|
LL | fn foo() -> Self {
|
||||||
| --- required by a bound in this associated function
|
| --- required by a bound in this associated function
|
||||||
help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
|
help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
|
||||||
@ -22,11 +22,11 @@ error[E0284]: type annotations needed for `Foo<_>`
|
|||||||
LL | let foo = Foo::foo();
|
LL | let foo = Foo::foo();
|
||||||
| ^^^ --- type must be known at this point
|
| ^^^ --- type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `Foo`
|
note: required by a const generic parameter in `Foo`
|
||||||
--> $DIR/doesnt_infer.rs:3:12
|
--> $DIR/doesnt_infer.rs:3:12
|
||||||
|
|
|
|
||||||
LL | struct Foo<const N: u32 = 2>;
|
LL | struct Foo<const N: u32 = 2>;
|
||||||
| ^^^^^^^^^^^^^^^^ required by this bound in `Foo`
|
| ^^^^^^^^^^^^^^^^ required by this const generic parameter in `Foo`
|
||||||
help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
|
help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
|
||||||
|
|
|
|
||||||
LL | let foo: Foo<N> = Foo::foo();
|
LL | let foo: Foo<N> = Foo::foo();
|
||||||
|
@ -37,11 +37,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | uwu();
|
LL | uwu();
|
||||||
| ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu`
|
| ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu`
|
||||||
|
|
|
|
||||||
note: required by a bound in `uwu`
|
note: required by a const generic parameter in `uwu`
|
||||||
--> $DIR/rp_impl_trait_fail.rs:16:8
|
--> $DIR/rp_impl_trait_fail.rs:16:8
|
||||||
|
|
|
|
||||||
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
|
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
|
||||||
| ^^^^^^^^^^^ required by this bound in `uwu`
|
| ^^^^^^^^^^^ required by this const generic parameter in `uwu`
|
||||||
help: consider specifying the generic argument
|
help: consider specifying the generic argument
|
||||||
|
|
|
|
||||||
LL | uwu::<N>();
|
LL | uwu::<N>();
|
||||||
|
@ -4,7 +4,7 @@ error[E0284]: type annotations needed for `Mask<_, _>`
|
|||||||
LL | let y = Mask::<_, _>::splat(false);
|
LL | let y = Mask::<_, _>::splat(false);
|
||||||
| ^ -------------------------- type must be known at this point
|
| ^ -------------------------- type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `Mask::<T, N>::splat`
|
note: required by a const generic parameter in `Mask::<T, N>::splat`
|
||||||
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
||||||
help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
|
help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
|
||||||
|
|
|
|
||||||
@ -17,7 +17,7 @@ error[E0284]: type annotations needed for `Mask<_, _>`
|
|||||||
LL | let y = Mask::<_, _>::splat(false);
|
LL | let y = Mask::<_, _>::splat(false);
|
||||||
| ^ ------------ type must be known at this point
|
| ^ ------------ type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `Mask`
|
note: required by a const generic parameter in `Mask`
|
||||||
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
||||||
help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
|
help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
|
||||||
|
|
|
|
||||||
|
@ -24,11 +24,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
|
|||||||
LL | let mut array = ArrayHolder::new();
|
LL | let mut array = ArrayHolder::new();
|
||||||
| ^^^^^^^^^ ------------------ type must be known at this point
|
| ^^^^^^^^^ ------------------ type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `ArrayHolder::<X>::new`
|
note: required by a const generic parameter in `ArrayHolder::<X>::new`
|
||||||
--> $DIR/issue-62504.rs:16:6
|
--> $DIR/issue-62504.rs:16:6
|
||||||
|
|
|
|
||||||
LL | impl<const X: usize> ArrayHolder<X> {
|
LL | impl<const X: usize> ArrayHolder<X> {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder::<X>::new`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::<X>::new`
|
||||||
LL | pub const fn new() -> Self {
|
LL | pub const fn new() -> Self {
|
||||||
| --- required by a bound in this associated function
|
| --- required by a bound in this associated function
|
||||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||||
@ -42,11 +42,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
|
|||||||
LL | let mut array = ArrayHolder::new();
|
LL | let mut array = ArrayHolder::new();
|
||||||
| ^^^^^^^^^ ----------- type must be known at this point
|
| ^^^^^^^^^ ----------- type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `ArrayHolder`
|
note: required by a const generic parameter in `ArrayHolder`
|
||||||
--> $DIR/issue-62504.rs:14:20
|
--> $DIR/issue-62504.rs:14:20
|
||||||
|
|
|
|
||||||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
|
||||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||||
|
|
|
|
||||||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||||
|
@ -28,11 +28,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
|
|||||||
LL | let mut array = ArrayHolder::new();
|
LL | let mut array = ArrayHolder::new();
|
||||||
| ^^^^^^^^^ ------------------ type must be known at this point
|
| ^^^^^^^^^ ------------------ type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `ArrayHolder::<X>::new`
|
note: required by a const generic parameter in `ArrayHolder::<X>::new`
|
||||||
--> $DIR/issue-62504.rs:16:6
|
--> $DIR/issue-62504.rs:16:6
|
||||||
|
|
|
|
||||||
LL | impl<const X: usize> ArrayHolder<X> {
|
LL | impl<const X: usize> ArrayHolder<X> {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder::<X>::new`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::<X>::new`
|
||||||
LL | pub const fn new() -> Self {
|
LL | pub const fn new() -> Self {
|
||||||
| --- required by a bound in this associated function
|
| --- required by a bound in this associated function
|
||||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||||
@ -46,11 +46,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
|
|||||||
LL | let mut array = ArrayHolder::new();
|
LL | let mut array = ArrayHolder::new();
|
||||||
| ^^^^^^^^^ ----------- type must be known at this point
|
| ^^^^^^^^^ ----------- type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `ArrayHolder`
|
note: required by a const generic parameter in `ArrayHolder`
|
||||||
--> $DIR/issue-62504.rs:14:20
|
--> $DIR/issue-62504.rs:14:20
|
||||||
|
|
|
|
||||||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
|
||||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||||
|
|
|
|
||||||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | use_dyn(&());
|
LL | use_dyn(&());
|
||||||
| ^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `use_dyn`
|
| ^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `use_dyn`
|
||||||
|
|
|
|
||||||
note: required by a bound in `use_dyn`
|
note: required by a const generic parameter in `use_dyn`
|
||||||
--> $DIR/object-safety-ok-infer-err.rs:14:12
|
--> $DIR/object-safety-ok-infer-err.rs:14:12
|
||||||
|
|
|
|
||||||
LL | fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized {
|
LL | fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `use_dyn`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `use_dyn`
|
||||||
help: consider specifying the generic argument
|
help: consider specifying the generic argument
|
||||||
|
|
|
|
||||||
LL | use_dyn::<N>(&());
|
LL | use_dyn::<N>(&());
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | foo();
|
LL | foo();
|
||||||
| ^^^ cannot infer the value of the const parameter `X` declared on the function `foo`
|
| ^^^ cannot infer the value of the const parameter `X` declared on the function `foo`
|
||||||
|
|
|
|
||||||
note: required by a bound in `foo`
|
note: required by a const generic parameter in `foo`
|
||||||
--> $DIR/cannot-infer-const-args.rs:1:8
|
--> $DIR/cannot-infer-const-args.rs:1:8
|
||||||
|
|
|
|
||||||
LL | fn foo<const X: usize>() -> usize {
|
LL | fn foo<const X: usize>() -> usize {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `foo`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||||
help: consider specifying the generic argument
|
help: consider specifying the generic argument
|
||||||
|
|
|
|
||||||
LL | foo::<X>();
|
LL | foo::<X>();
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | println!("{:?}", take_array_from_mut(&mut arr, i));
|
LL | println!("{:?}", take_array_from_mut(&mut arr, i));
|
||||||
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut`
|
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut`
|
||||||
|
|
|
|
||||||
note: required by a bound in `take_array_from_mut`
|
note: required by a const generic parameter in `take_array_from_mut`
|
||||||
--> $DIR/issue-77092.rs:3:27
|
--> $DIR/issue-77092.rs:3:27
|
||||||
|
|
|
|
||||||
LL | fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] {
|
LL | fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `take_array_from_mut`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `take_array_from_mut`
|
||||||
help: consider specifying the generic arguments
|
help: consider specifying the generic arguments
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", take_array_from_mut::<i32, N>(&mut arr, i));
|
LL | println!("{:?}", take_array_from_mut::<i32, N>(&mut arr, i));
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | Foo.bar().bar().bar().bar().baz();
|
LL | Foo.bar().bar().bar().bar().baz();
|
||||||
| ^^^ cannot infer the value of the const parameter `N` declared on the method `baz`
|
| ^^^ cannot infer the value of the const parameter `N` declared on the method `baz`
|
||||||
|
|
|
|
||||||
note: required by a bound in `Foo::baz`
|
note: required by a const generic parameter in `Foo::baz`
|
||||||
--> $DIR/method-chain.rs:8:12
|
--> $DIR/method-chain.rs:8:12
|
||||||
|
|
|
|
||||||
LL | fn baz<const N: usize>(self) -> Foo {
|
LL | fn baz<const N: usize>(self) -> Foo {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `Foo::baz`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::baz`
|
||||||
help: consider specifying the generic argument
|
help: consider specifying the generic argument
|
||||||
|
|
|
|
||||||
LL | Foo.bar().bar().bar().bar().baz::<N>();
|
LL | Foo.bar().bar().bar().bar().baz::<N>();
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | let _: [u8; 17] = foo();
|
LL | let _: [u8; 17] = foo();
|
||||||
| ^^^ cannot infer the value of the const parameter `M` declared on the function `foo`
|
| ^^^ cannot infer the value of the const parameter `M` declared on the function `foo`
|
||||||
|
|
|
|
||||||
note: required by a bound in `foo`
|
note: required by a const generic parameter in `foo`
|
||||||
--> $DIR/one-param-uninferred.rs:2:24
|
--> $DIR/one-param-uninferred.rs:2:24
|
||||||
|
|
|
|
||||||
LL | fn foo<const N: usize, const M: usize>() -> [u8; N] {
|
LL | fn foo<const N: usize, const M: usize>() -> [u8; N] {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `foo`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||||
help: consider specifying the generic arguments
|
help: consider specifying the generic arguments
|
||||||
|
|
|
|
||||||
LL | let _: [u8; 17] = foo::<17, M>();
|
LL | let _: [u8; 17] = foo::<17, M>();
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | Foo.foo();
|
LL | Foo.foo();
|
||||||
| ^^^ cannot infer the value of the const parameter `A` declared on the method `foo`
|
| ^^^ cannot infer the value of the const parameter `A` declared on the method `foo`
|
||||||
|
|
|
|
||||||
note: required by a bound in `Foo::foo`
|
note: required by a const generic parameter in `Foo::foo`
|
||||||
--> $DIR/uninferred-consts.rs:6:12
|
--> $DIR/uninferred-consts.rs:6:12
|
||||||
|
|
|
|
||||||
LL | fn foo<const A: usize, const B: usize>(self) {}
|
LL | fn foo<const A: usize, const B: usize>(self) {}
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `Foo::foo`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::foo`
|
||||||
help: consider specifying the generic arguments
|
help: consider specifying the generic arguments
|
||||||
|
|
|
|
||||||
LL | Foo.foo::<A, B>();
|
LL | Foo.foo::<A, B>();
|
||||||
@ -20,11 +20,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | Foo.foo();
|
LL | Foo.foo();
|
||||||
| ^^^ cannot infer the value of the const parameter `B` declared on the method `foo`
|
| ^^^ cannot infer the value of the const parameter `B` declared on the method `foo`
|
||||||
|
|
|
|
||||||
note: required by a bound in `Foo::foo`
|
note: required by a const generic parameter in `Foo::foo`
|
||||||
--> $DIR/uninferred-consts.rs:6:28
|
--> $DIR/uninferred-consts.rs:6:28
|
||||||
|
|
|
|
||||||
LL | fn foo<const A: usize, const B: usize>(self) {}
|
LL | fn foo<const A: usize, const B: usize>(self) {}
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `Foo::foo`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::foo`
|
||||||
help: consider specifying the generic arguments
|
help: consider specifying the generic arguments
|
||||||
|
|
|
|
||||||
LL | Foo.foo::<A, B>();
|
LL | Foo.foo::<A, B>();
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | generics_of_parent_impl_trait::foo([()]);
|
LL | generics_of_parent_impl_trait::foo([()]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `foo`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `foo`
|
||||||
|
|
|
|
||||||
note: required by a bound in `foo`
|
note: required by a const generic parameter in `foo`
|
||||||
--> $DIR/auxiliary/generics_of_parent_impl_trait.rs:5:12
|
--> $DIR/auxiliary/generics_of_parent_impl_trait.rs:5:12
|
||||||
|
|
|
|
||||||
LL | pub fn foo<const N: usize>(foo: impl Into<[(); N + 1]>) {
|
LL | pub fn foo<const N: usize>(foo: impl Into<[(); N + 1]>) {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `foo`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
@ -4,11 +4,11 @@ error: the constant `N` is not of type `u8`
|
|||||||
LL | bar::<N>()
|
LL | bar::<N>()
|
||||||
| ^ expected `u8`, found `usize`
|
| ^ expected `u8`, found `usize`
|
||||||
|
|
|
|
||||||
note: required by a bound in `bar`
|
note: required by a const generic parameter in `bar`
|
||||||
--> $DIR/type_mismatch.rs:6:8
|
--> $DIR/type_mismatch.rs:6:8
|
||||||
|
|
|
|
||||||
LL | fn bar<const N: u8>() -> [u8; N] {}
|
LL | fn bar<const N: u8>() -> [u8; N] {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `bar`
|
| ^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/type_mismatch.rs:6:26
|
--> $DIR/type_mismatch.rs:6:26
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed
|
|||||||
LL | bar();
|
LL | bar();
|
||||||
| ^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
| ^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
||||||
|
|
|
|
||||||
note: required by a bound in `bar`
|
note: required by a const generic parameter in `bar`
|
||||||
--> $DIR/unify_with_nested_expr.rs:12:8
|
--> $DIR/unify_with_nested_expr.rs:12:8
|
||||||
|
|
|
|
||||||
LL | fn bar<const N: usize>()
|
LL | fn bar<const N: usize>()
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `bar`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||||
help: consider specifying the generic argument
|
help: consider specifying the generic argument
|
||||||
|
|
|
|
||||||
LL | bar::<N>();
|
LL | bar::<N>();
|
||||||
|
@ -4,11 +4,11 @@ error[E0284]: type annotations needed for `[usize; _]`
|
|||||||
LL | let _ = foo("foo");
|
LL | let _ = foo("foo");
|
||||||
| ^ ---------- type must be known at this point
|
| ^ ---------- type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `foo`
|
note: required by a const generic parameter in `foo`
|
||||||
--> $DIR/issue-83606.rs:3:8
|
--> $DIR/issue-83606.rs:3:8
|
||||||
|
|
|
|
||||||
LL | fn foo<const N: usize>(_: impl std::fmt::Display) -> [usize; N] {
|
LL | fn foo<const N: usize>(_: impl std::fmt::Display) -> [usize; N] {
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `foo`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||||
help: consider giving this pattern a type, where the value of const parameter `N` is specified
|
help: consider giving this pattern a type, where the value of const parameter `N` is specified
|
||||||
|
|
|
|
||||||
LL | let _: [usize; N] = foo("foo");
|
LL | let _: [usize; N] = foo("foo");
|
||||||
|
@ -6,11 +6,11 @@ LL | SmallCString::try_from(p).map(|cstr| cstr);
|
|||||||
| |
|
| |
|
||||||
| type must be known at this point
|
| type must be known at this point
|
||||||
|
|
|
|
||||||
note: required by a bound in `SmallCString`
|
note: required by a const generic parameter in `SmallCString`
|
||||||
--> $DIR/issue-98299.rs:10:25
|
--> $DIR/issue-98299.rs:10:25
|
||||||
|
|
|
|
||||||
LL | pub struct SmallCString<const N: usize> {}
|
LL | pub struct SmallCString<const N: usize> {}
|
||||||
| ^^^^^^^^^^^^^^ required by this bound in `SmallCString`
|
| ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString`
|
||||||
help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified
|
help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified
|
||||||
|
|
|
|
||||||
LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr);
|
LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr);
|
||||||
|
@ -14,11 +14,11 @@ LL | impl<const C: usize> Wrapper<C> {}
|
|||||||
|
|
|
|
||||||
= help: consider constraining the associated type `<i32 as Trait>::Type` to `usize`
|
= help: consider constraining the associated type `<i32 as Trait>::Type` to `usize`
|
||||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
note: required by a bound in `Wrapper`
|
note: required by a const generic parameter in `Wrapper`
|
||||||
--> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:12:16
|
--> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:12:16
|
||||||
|
|
|
|
||||||
LL | struct Wrapper<const C: <i32 as Trait>::Type> {}
|
LL | struct Wrapper<const C: <i32 as Trait>::Type> {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `Wrapper`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:30
|
--> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:30
|
||||||
|
@ -10,7 +10,7 @@ error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
|||||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||||
|
|
|
|
||||||
note: required by a bound in `BikeshedIntrinsicFrom`
|
note: required by a const generic parameter in `BikeshedIntrinsicFrom`
|
||||||
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
|
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
|
Loading…
Reference in New Issue
Block a user