Skip to content

Commit

Permalink
Rollup merge of #69498 - mark-i-m:describe-it-2, r=matthewjasper
Browse files Browse the repository at this point in the history
Change "method" to "associated function"

r? @matthewjasper

cc @Centril @eddyb #67742

I'm opening this mostly as a test to see what the diagnostic changes would be. It seems that this makes them somewhat more verbose, and I'm not sure it's worth it...

The relevant changes are the last two commits (it is rebased on top of #67742)
  • Loading branch information
Dylan-DPC authored Mar 15, 2020
2 parents 0619e46 + b6518f0 commit f40272c
Show file tree
Hide file tree
Showing 77 changed files with 177 additions and 177 deletions.
4 changes: 2 additions & 2 deletions src/librustc_hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ impl DefKind {
DefKind::Union => "union",
DefKind::Trait => "trait",
DefKind::ForeignTy => "foreign type",
// FIXME: Update the description to "assoc fn"
DefKind::AssocFn => "method",
DefKind::AssocFn => "associated function",
DefKind::Const => "constant",
DefKind::AssocConst => "associated constant",
DefKind::TyParam => "type parameter",
Expand All @@ -123,6 +122,7 @@ impl DefKind {
DefKind::AssocTy
| DefKind::AssocConst
| DefKind::AssocOpaqueTy
| DefKind::AssocFn
| DefKind::Enum
| DefKind::OpaqueTy => "an",
DefKind::Macro(macro_kind) => macro_kind.article(),
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-item/associated-item-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | Enum::mispellable();
| ^^^^^^^^^^^
| |
| variant or associated item not found in `Enum`
| help: there is a method with a similar name: `misspellable`
| help: there is an associated function with a similar name: `misspellable`

error[E0599]: no variant or associated item named `mispellable_trait` found for enum `Enum` in the current scope
--> $DIR/associated-item-enum.rs:18:11
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/async-await/issues/issue-62097.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ help: to force the closure to take ownership of `self` (and any other referenced
LL | foo(move || self.bar()).await;
| ^^^^^^^

error[E0521]: borrowed data escapes outside of method
error[E0521]: borrowed data escapes outside of associated function
--> $DIR/issue-62097.rs:13:9
|
LL | pub async fn run_dummy_fn(&self) {
| ----- `self` is a reference that is only valid in the method body
| ----- `self` is a reference that is only valid in the associated function body
LL | foo(|| self.bar()).await;
| ^^^^^^^^^^^^^^^^^^ `self` escapes the method body here
| ^^^^^^^^^^^^^^^^^^ `self` escapes the associated function body here

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-63388-1.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | ) -> &dyn Foo
LL | / {
LL | | foo
LL | | }
| |_____^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
| |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/auto-ref-slice-plus-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `test_mut` found for struct `std::vec::Vec<{intege
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
|
LL | a.test_mut();
| ^^^^^^^^ help: there is a method with a similar name: `get_mut`
| ^^^^^^^^ help: there is an associated function with a similar name: `get_mut`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-3563.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `b` found for reference `&Self` in the current sco
--> $DIR/issue-3563.rs:3:17
|
LL | || self.b()
| ^ help: there is a method with a similar name: `a`
| ^ help: there is an associated function with a similar name: `a`

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0624.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ mod inner {

fn main() {
let foo = inner::Foo;
foo.method(); //~ ERROR method `method` is private [E0624]
foo.method(); //~ ERROR associated function `method` is private [E0624]
}
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0624.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0624]: method `method` is private
error[E0624]: associated function `method` is private
--> $DIR/E0624.rs:11:9
|
LL | foo.method();
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/explore-issue-38412.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ LL | r.unstable_undeclared();
= note: see issue #38412 <https://github.com/rust-lang/rust/issues/38412> for more information
= help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable

error[E0624]: method `pub_crate` is private
error[E0624]: associated function `pub_crate` is private
--> $DIR/explore-issue-38412.rs:50:7
|
LL | r.pub_crate();
| ^^^^^^^^^

error[E0624]: method `pub_mod` is private
error[E0624]: associated function `pub_mod` is private
--> $DIR/explore-issue-38412.rs:51:7
|
LL | r.pub_mod();
| ^^^^^^^

error[E0624]: method `private` is private
error[E0624]: associated function `private` is private
--> $DIR/explore-issue-38412.rs:52:7
|
LL | r.private();
Expand All @@ -115,19 +115,19 @@ LL | t.unstable_undeclared();
= note: see issue #38412 <https://github.com/rust-lang/rust/issues/38412> for more information
= help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable

error[E0624]: method `pub_crate` is private
error[E0624]: associated function `pub_crate` is private
--> $DIR/explore-issue-38412.rs:63:7
|
LL | t.pub_crate();
| ^^^^^^^^^

error[E0624]: method `pub_mod` is private
error[E0624]: associated function `pub_mod` is private
--> $DIR/explore-issue-38412.rs:64:7
|
LL | t.pub_mod();
| ^^^^^^^

error[E0624]: method `private` is private
error[E0624]: associated function `private` is private
--> $DIR/explore-issue-38412.rs:65:7
|
LL | t.private();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/fn-in-pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn hof<F>(_: F) where F: FnMut(()) {}

fn ice() {
hof(|c| match c {
A::new() => (), //~ ERROR expected tuple struct or tuple variant, found method
A::new() => (), //~ ERROR expected tuple struct or tuple variant, found associated function
_ => ()
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/fn-in-pat.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0164]: expected tuple struct or tuple variant, found method `A::new`
error[E0164]: expected tuple struct or tuple variant, found associated function `A::new`
--> $DIR/fn-in-pat.rs:11:9
|
LL | A::new() => (),
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/issues/issue-16683.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0521]: borrowed data escapes outside of method
error[E0521]: borrowed data escapes outside of associated function
--> $DIR/issue-16683.rs:4:9
|
LL | fn b(&self) {
| ----- `self` is a reference that is only valid in the method body
| ----- `self` is a reference that is only valid in the associated function body
LL | self.a();
| ^^^^^^^^ `self` escapes the method body here
| ^^^^^^^^ `self` escapes the associated function body here

error: aborting due to previous error

6 changes: 3 additions & 3 deletions src/test/ui/issues/issue-17758.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0521]: borrowed data escapes outside of method
error[E0521]: borrowed data escapes outside of associated function
--> $DIR/issue-17758.rs:7:9
|
LL | fn bar(&self) {
| ----- `self` is a reference that is only valid in the method body
| ----- `self` is a reference that is only valid in the associated function body
LL | self.foo();
| ^^^^^^^^^^ `self` escapes the method body here
| ^^^^^^^^^^ `self` escapes the associated function body here

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-21202.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod B {
use crate1::A::Foo;
fn bar(f: Foo) {
Foo::foo(&f);
//~^ ERROR: method `foo` is private
//~^ ERROR: associated function `foo` is private
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-21202.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0624]: method `foo` is private
error[E0624]: associated function `foo` is private
--> $DIR/issue-21202.rs:10:9
|
LL | Foo::foo(&f);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-28344.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
| ^^^^^
| |
| function or associated item not found in `dyn std::ops::BitXor<_>`
| help: there is a method with a similar name: `bitxor`
| help: there is an associated function with a similar name: `bitxor`

error[E0191]: the value of the associated type `Output` (from trait `std::ops::BitXor`) must be specified
--> $DIR/issue-28344.rs:8:13
Expand All @@ -26,7 +26,7 @@ LL | let g = BitXor::bitor;
| ^^^^^
| |
| function or associated item not found in `dyn std::ops::BitXor<_>`
| help: there is a method with a similar name: `bitxor`
| help: there is an associated function with a similar name: `bitxor`

error: aborting due to 4 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-3763.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ fn main() {
let _woohoo = (Box::new(my_struct)).priv_field;
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private

(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
(&my_struct).happyfun(); //~ ERROR associated function `happyfun` is private

(Box::new(my_struct)).happyfun(); //~ ERROR method `happyfun` is private
(Box::new(my_struct)).happyfun(); //~ ERROR associated function `happyfun` is private
let nope = my_struct.priv_field;
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
}
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-3763.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ error[E0616]: field `priv_field` of struct `my_mod::MyStruct` is private
LL | let _woohoo = (Box::new(my_struct)).priv_field;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0624]: method `happyfun` is private
error[E0624]: associated function `happyfun` is private
--> $DIR/issue-3763.rs:24:18
|
LL | (&my_struct).happyfun();
| ^^^^^^^^

error[E0624]: method `happyfun` is private
error[E0624]: associated function `happyfun` is private
--> $DIR/issue-3763.rs:26:27
|
LL | (Box::new(my_struct)).happyfun();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `as_deref` found for enum `std::option::Option<{in
--> $DIR/option-as_deref.rs:2:29
|
LL | let _result = &Some(42).as_deref();
| ^^^^^^^^ help: there is a method with a similar name: `as_ref`
| ^^^^^^^^ help: there is an associated function with a similar name: `as_ref`
|
= note: the method `as_deref` exists but the following trait bounds were not satisfied:
`{integer}: std::ops::Deref`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `as_deref` found for enum `std::result::Result<{in
--> $DIR/result-as_deref.rs:4:27
|
LL | let _result = &Ok(42).as_deref();
| ^^^^^^^^ help: there is a method with a similar name: `as_ref`
| ^^^^^^^^ help: there is an associated function with a similar name: `as_ref`
|
= note: the method `as_deref` exists but the following trait bounds were not satisfied:
`{integer}: std::ops::Deref`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `as_deref_err` found for enum `std::result::Result
--> $DIR/result-as_deref_err.rs:4:28
|
LL | let _result = &Err(41).as_deref_err();
| ^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_mut`
| ^^^^^^^^^^^^ help: there is an associated function with a similar name: `as_deref_mut`
|
= note: the method `as_deref_err` exists but the following trait bounds were not satisfied:
`{integer}: std::ops::Deref`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `as_deref_mut` found for enum `std::result::Result
--> $DIR/result-as_deref_mut.rs:4:31
|
LL | let _result = &mut Ok(42).as_deref_mut();
| ^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_err`
| ^^^^^^^^^^^^ help: there is an associated function with a similar name: `as_deref_err`
|
= note: the method `as_deref_mut` exists but the following trait bounds were not satisfied:
`{integer}: std::ops::DerefMut`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `as_deref_mut_err` found for enum `std::result::Re
--> $DIR/result-as_deref_mut_err.rs:4:32
|
LL | let _result = &mut Err(41).as_deref_mut_err();
| ^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_mut`
| ^^^^^^^^^^^^^^^^ help: there is an associated function with a similar name: `as_deref_mut`
|
= note: the method `as_deref_mut_err` exists but the following trait bounds were not satisfied:
`{integer}: std::ops::DerefMut`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-53498.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ pub mod test {
}

fn main() {
test::Foo::<test::B>::foo(); //~ ERROR method `foo` is private
test::Foo::<test::B>::foo(); //~ ERROR associated function `foo` is private
}
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-53498.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0624]: method `foo` is private
error[E0624]: associated function `foo` is private
--> $DIR/issue-53498.rs:16:5
|
LL | test::Foo::<test::B>::foo();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-55587.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0164]: expected tuple struct or tuple variant, found method `Path::new`
error[E0164]: expected tuple struct or tuple variant, found associated function `Path::new`
--> $DIR/issue-55587.rs:4:9
|
LL | let Path::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
| lifetime `'a` defined here
LL |
LL | if x > y { x } else { y }
| ^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
| ^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
| lifetime `'a` defined here
LL |
LL | x
| ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
| ^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
| lifetime `'a` defined here
LL |
LL | if true { x } else { self }
| ^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
| ^^^^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | fn foo<'a>(&self, x: &i32) -> &i32 {
| |
| let's call the lifetime of this reference `'2`
LL | x
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | fn foo<'a>(&self, x: &Foo) -> &Foo {
| |
| let's call the lifetime of this reference `'2`
LL | if true { x } else { self }
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/match/match-fn-call.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0164]: expected tuple struct or tuple variant, found method `Path::new`
error[E0164]: expected tuple struct or tuple variant, found associated function `Path::new`
--> $DIR/match-fn-call.rs:6:9
|
LL | Path::new("foo") => println!("foo"),
| ^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
|
= help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html

error[E0164]: expected tuple struct or tuple variant, found method `Path::new`
error[E0164]: expected tuple struct or tuple variant, found associated function `Path::new`
--> $DIR/match-fn-call.rs:8:9
|
LL | Path::new("bar") => println!("bar"),
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/methods/method-path-in-pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ impl MyTrait for Foo {}
fn main() {
match 0u32 {
Foo::bar => {}
//~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar`
//~^ ERROR expected unit struct, unit variant or constant, found associated function
}
match 0u32 {
<Foo>::bar => {}
//~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar`
//~^ ERROR expected unit struct, unit variant or constant, found associated function
}
match 0u32 {
<Foo>::trait_bar => {}
//~^ ERROR expected unit struct, unit variant or constant, found method `Foo::trait_bar`
//~^ ERROR expected unit struct, unit variant or constant, found associated function
}
if let Foo::bar = 0u32 {}
//~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar`
//~^ ERROR expected unit struct, unit variant or constant, found associated function
if let <Foo>::bar = 0u32 {}
//~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar`
//~^ ERROR expected unit struct, unit variant or constant, found associated function
if let Foo::trait_bar = 0u32 {}
//~^ ERROR expected unit struct, unit variant or constant, found method `Foo::trait_bar`
//~^ ERROR expected unit struct, unit variant or constant, found associated function
}
Loading

0 comments on commit f40272c

Please sign in to comment.