Auto merge of #53960 - estebank:issue-51303, r=nagisa
Fix incorrect outer function type parameter message Fix #51303.
This commit is contained in:
commit
dac76020a5
5 changed files with 66 additions and 12 deletions
|
|
@ -24,12 +24,13 @@ error[E0401]: can't use type parameters from outer function
|
|||
--> $DIR/E0401.rs:32:25
|
||||
|
|
||||
LL | impl<T> Iterator for A<T> {
|
||||
| ---- `Self` type implicitly declared here, on the `impl`
|
||||
| ---- `Self` type implicitly declared here, by this `impl`
|
||||
...
|
||||
LL | fn helper(sel: &Self) -> u8 { //~ ERROR E0401
|
||||
| ------ ^^^^ use of type variable from outer function
|
||||
| |
|
||||
| help: try using a local type parameter instead: `helper<Self>`
|
||||
| ^^^^
|
||||
| |
|
||||
| use of type variable from outer function
|
||||
| use a type here instead
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ error[E0401]: can't use type parameters from outer function
|
|||
--> $DIR/issue-12796.rs:13:22
|
||||
|
|
||||
LL | fn inner(_: &Self) {
|
||||
| ----- ^^^^ use of type variable from outer function
|
||||
| |
|
||||
| help: try using a local type parameter instead: `inner<Self>`
|
||||
| ^^^^
|
||||
| |
|
||||
| use of type variable from outer function
|
||||
| can't use `Self` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
24
src/test/ui/use-self-in-inner-fn.rs
Normal file
24
src/test/ui/use-self-in-inner-fn.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct A;
|
||||
|
||||
impl A {
|
||||
//~^ NOTE `Self` type implicitly declared here, by this `impl`
|
||||
fn banana(&mut self) {
|
||||
fn peach(this: &Self) {
|
||||
//~^ ERROR can't use type parameters from outer function
|
||||
//~| NOTE use of type variable from outer function
|
||||
//~| NOTE use a type here instead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
15
src/test/ui/use-self-in-inner-fn.stderr
Normal file
15
src/test/ui/use-self-in-inner-fn.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error[E0401]: can't use type parameters from outer function
|
||||
--> $DIR/use-self-in-inner-fn.rs:16:25
|
||||
|
|
||||
LL | impl A {
|
||||
| ---- `Self` type implicitly declared here, by this `impl`
|
||||
...
|
||||
LL | fn peach(this: &Self) {
|
||||
| ^^^^
|
||||
| |
|
||||
| use of type variable from outer function
|
||||
| use a type here instead
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0401`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue