Add note to E0401
This commit is contained in:
parent
48dde00f10
commit
14646ec374
21 changed files with 42 additions and 1 deletions
|
|
@ -175,6 +175,7 @@ resolve_generic_params_from_outer_item =
|
|||
} from outer item
|
||||
.refer_to_type_directly = refer to the type directly here instead
|
||||
.suggestion = try introducing a local generic parameter here
|
||||
.note = nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
|
||||
resolve_generic_params_from_outer_item_const = a `const` is a separate item from the item that contains it
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use crate::{Res, fluent_generated as fluent};
|
|||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_generic_params_from_outer_item, code = E0401)]
|
||||
#[note]
|
||||
pub(crate) struct GenericParamsFromOuterItem {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | fn bar() -> u32 {
|
|||
LL | X
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bar<X>() -> u32 {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ LL | reuse Trait::static_method {
|
|||
LL |
|
||||
LL | let _ = T::Default();
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
|
||||
error[E0434]: can't capture dynamic environment in a fn item
|
||||
--> $DIR/target-expr.rs:26:17
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) {
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bfnr<T, U, V: Baz<U>, W: Fn()>(y: T) {
|
||||
|
|
@ -25,6 +26,7 @@ LL | fn baz<U,
|
|||
LL | (y: T) {
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn baz<T, U,
|
||||
|
|
@ -41,6 +43,7 @@ LL | fn helper(sel: &Self) -> u8 {
|
|||
| |
|
||||
| `Self` used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: refer to the type directly here instead
|
||||
|
|
||||
LL - fn helper(sel: &Self) -> u8 {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | enum E { V(Z) }
|
|||
| |
|
||||
| generic parameter used in this inner enum
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | enum E<Z> { V(Z) }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | fn bar(w: [U]) -> U {
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bar<U>(w: [U]) -> U {
|
||||
|
|
@ -23,6 +24,7 @@ LL | fn bar(w: [U]) -> U {
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bar<U>(w: [U]) -> U {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ LL | struct _Obligation where T:;
|
|||
| |
|
||||
| generic parameter used in this inner struct
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | struct _Obligation<T> where T:;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | fn bar(b: T) { }
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bar<T>(b: T) { }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | const K: u32 = T::C;
|
|||
| |
|
||||
| generic parameter used in this inner constant item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `const` is a separate item from the item that contains it
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
|
|
@ -21,6 +22,7 @@ LL | const I: u32 = T::C;
|
|||
| |
|
||||
| generic parameter used in this inner constant item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `const` is a separate item from the item that contains it
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
|
|
@ -33,6 +35,7 @@ LL | const _: u32 = T::C;
|
|||
| |
|
||||
| generic parameter used in this inner constant item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `const` is a separate item from the item that contains it
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | const K: u32 = T::C;
|
|||
| |
|
||||
| generic parameter used in this inner constant item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `const` is a separate item from the item that contains it
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
|
|
@ -25,6 +26,7 @@ LL | const I: u32 = T::C;
|
|||
| |
|
||||
| generic parameter used in this inner constant item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `const` is a separate item from the item that contains it
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
|
|
@ -41,6 +43,7 @@ LL | const _: u32 = T::C;
|
|||
| |
|
||||
| generic parameter used in this inner constant item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `const` is a separate item from the item that contains it
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ LL | fn inner(_: &Self) {
|
|||
| | use of `Self` from outer item
|
||||
| | can't use `Self` here
|
||||
| `Self` used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ LL | trait U {
|
|||
LL | fn g(&self, x: T) -> T;
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | trait U<T> {
|
||||
|
|
@ -25,6 +26,7 @@ LL | trait U {
|
|||
LL | fn g(&self, x: T) -> T;
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | trait U<T> {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | struct Foo {
|
|||
LL | x: T,
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | struct Foo<T> {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ LL | |
|
|||
LL | | }
|
||||
| |_____- generic parameter used in this inner extern block
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ LL | |
|
|||
LL | | }
|
||||
| |_____- generic parameter used in this inner extern block
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
|
|
@ -22,6 +23,7 @@ LL | static a: *const T = Default::default();
|
|||
| |
|
||||
| generic parameter used in this inner static item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
|
|
@ -36,6 +38,7 @@ LL | |
|
|||
LL | | }
|
||||
| |_____- generic parameter used in this inner extern block
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
|
|
@ -48,6 +51,7 @@ LL | static a: [u8; N] = [0; N];
|
|||
| |
|
||||
| generic parameter used in this inner static item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
|
|
@ -60,6 +64,7 @@ LL | static a: [u8; N] = [0; N];
|
|||
| |
|
||||
| generic parameter used in this inner static item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ LL | enum Foo<B> {
|
|||
LL | Variance(A)
|
||||
| ^ use of generic parameter from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | enum Foo<A, B> {
|
||||
|
|
@ -25,6 +26,7 @@ LL | struct Foo<B>(A);
|
|||
| |
|
||||
| generic parameter used in this inner struct
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | struct Foo<A, B>(A);
|
||||
|
|
@ -41,6 +43,7 @@ LL | struct Foo<B> { a: A }
|
|||
| |
|
||||
| generic parameter used in this inner struct
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | struct Foo<A, B> { a: A }
|
||||
|
|
@ -57,6 +60,7 @@ LL | fn foo<B>(a: A) { }
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn foo<A, B>(a: A) { }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ impl A {
|
|||
//~| NOTE use of `Self` from outer item
|
||||
//~| NOTE `Self` used in this inner function
|
||||
//~| HELP refer to the type directly here instead
|
||||
//~| NOTE nested items are independent from their
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +28,7 @@ impl MyEnum {
|
|||
//~^ ERROR can't use `Self` from outer item
|
||||
//~| NOTE use of `Self` from outer item
|
||||
//~| HELP refer to the type directly here instead
|
||||
//~| NOTE nested items are independent from their
|
||||
MyEnum::do_something(move || {});
|
||||
}
|
||||
inner();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ LL | fn peach(this: &Self) {
|
|||
| |
|
||||
| `Self` used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: refer to the type directly here instead
|
||||
|
|
||||
LL - fn peach(this: &Self) {
|
||||
|
|
@ -16,7 +17,7 @@ LL + fn peach(this: &A) {
|
|||
|
|
||||
|
||||
error[E0401]: can't use `Self` from outer item
|
||||
--> $DIR/use-self-in-inner-fn.rs:26:13
|
||||
--> $DIR/use-self-in-inner-fn.rs:27:13
|
||||
|
|
||||
LL | impl MyEnum {
|
||||
| ---- `Self` type implicitly declared here, by this `impl`
|
||||
|
|
@ -27,6 +28,7 @@ LL |
|
|||
LL | Self::do_something(move || {});
|
||||
| ^^^^ use of `Self` from outer item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: refer to the type directly here instead
|
||||
|
|
||||
LL - Self::do_something(move || {});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | static a: Bar<T> = Bar::What;
|
|||
| |
|
||||
| generic parameter used in this inner static item
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error[E0392]: type parameter `T` is never used
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ LL | fn bar(f: Box<dyn FnMut(T) -> T>) { }
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bar<T>(f: Box<dyn FnMut(T) -> T>) { }
|
||||
|
|
@ -23,6 +24,7 @@ LL | fn bar(f: Box<dyn FnMut(T) -> T>) { }
|
|||
| |
|
||||
| generic parameter used in this inner function
|
||||
|
|
||||
= note: nested items are independent from their parent item for everything except for privacy and name resolution
|
||||
help: try introducing a local generic parameter here
|
||||
|
|
||||
LL | fn bar<T>(f: Box<dyn FnMut(T) -> T>) { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue