Auto merge of #72575 - Dylan-DPC:rollup-zo679hv, r=Dylan-DPC
Rollup of 4 pull requests Successful merges: - #72153 (exhaustively check `ty::Kind` during structural match checking) - #72308 (Emit a better diagnostic when function actually has a 'self' parameter) - #72560 (Enable `glacier` command via triagebot) - #72567 (Clean up E0608 explanation) Failed merges: r? @ghost
This commit is contained in:
commit
f93bb2a50b
12 changed files with 173 additions and 11 deletions
23
src/test/ui/hygiene/missing-self-diag.rs
Normal file
23
src/test/ui/hygiene/missing-self-diag.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Regression test for issue #66898
|
||||
// Tests that we don't emit a nonsensical error message
|
||||
// when a macro invocation tries to access `self` from a function
|
||||
// that has a 'self' parameter
|
||||
|
||||
pub struct Foo;
|
||||
|
||||
macro_rules! call_bar {
|
||||
() => {
|
||||
self.bar(); //~ ERROR expected value
|
||||
}
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
pub fn foo(&self) {
|
||||
call_bar!();
|
||||
}
|
||||
|
||||
pub fn bar(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
17
src/test/ui/hygiene/missing-self-diag.stderr
Normal file
17
src/test/ui/hygiene/missing-self-diag.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0424]: expected value, found module `self`
|
||||
--> $DIR/missing-self-diag.rs:10:9
|
||||
|
|
||||
LL | self.bar();
|
||||
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
||||
...
|
||||
LL | / pub fn foo(&self) {
|
||||
LL | | call_bar!();
|
||||
| | ------------ in this macro invocation
|
||||
LL | | }
|
||||
| |_____- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0424`.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#![feature(const_fn, type_alias_impl_trait)]
|
||||
|
||||
type Bar = impl Send;
|
||||
|
||||
// While i32 is structural-match, we do not want to leak this information.
|
||||
// (See https://github.com/rust-lang/rust/issues/72156)
|
||||
const fn leak_free() -> Bar {
|
||||
7i32
|
||||
}
|
||||
const LEAK_FREE: Bar = leak_free();
|
||||
|
||||
fn leak_free_test() {
|
||||
match todo!() {
|
||||
LEAK_FREE => (),
|
||||
//~^ opaque types cannot be used in patterns
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: opaque types cannot be used in patterns
|
||||
--> $DIR/structural-match-no-leak.rs:14:9
|
||||
|
|
||||
LL | LEAK_FREE => (),
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
21
src/test/ui/type-alias-impl-trait/structural-match.rs
Normal file
21
src/test/ui/type-alias-impl-trait/structural-match.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#![feature(const_fn, type_alias_impl_trait)]
|
||||
|
||||
type Foo = impl Send;
|
||||
|
||||
// This is not structural-match
|
||||
struct A;
|
||||
|
||||
const fn value() -> Foo {
|
||||
A
|
||||
}
|
||||
const VALUE: Foo = value();
|
||||
|
||||
fn test() {
|
||||
match todo!() {
|
||||
VALUE => (),
|
||||
//~^ opaque types cannot be used in patterns
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: opaque types cannot be used in patterns
|
||||
--> $DIR/structural-match.rs:15:9
|
||||
|
|
||||
LL | VALUE => (),
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue