Auto merge of #149515 - matthiaskrgr:rollup-djmciuc, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#149393 (expand valid edition range for use-path-segment-kw.rs)
 - rust-lang/rust#149427 (Make the capitalization explicit on keyword misspell error)
 - rust-lang/rust#149433 (Use a delayed bug for this layout ICE)
 - rust-lang/rust#149473 (Tidying up UI tests [7/N])
 - rust-lang/rust#149505 (Update the comment in the add_typo_suggestion function)
 - rust-lang/rust#149513 (`rust-analyzer` subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-12-01 20:29:33 +00:00
commit 1d60f9e070
41 changed files with 363 additions and 260 deletions

View file

@ -3544,6 +3544,8 @@ pub fn detect_confusion_type(sm: &SourceMap, suggested: &str, sp: Span) -> Confu
let mut has_digit_letter_confusable = false;
let mut has_other_diff = false;
// Letters whose lowercase version is very similar to the uppercase
// version.
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
let digit_letter_confusables = [('0', 'O'), ('1', 'l'), ('5', 'S'), ('8', 'B'), ('9', 'g')];

View file

@ -1366,7 +1366,7 @@ impl<'a> DiagCtxtHandle<'a> {
self.create_err(err).emit()
}
/// Ensures that an error is printed. See `Level::DelayedBug`.
/// Ensures that an error is printed. See [`Level::DelayedBug`].
//
// No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
// user-facing.

View file

@ -513,7 +513,7 @@ parse_keyword_lifetime =
lifetimes cannot use keyword names
parse_kw_bad_case = keyword `{$kw}` is written in the wrong case
.suggestion = write it in the correct case
.suggestion = write it in {$case}
parse_label_inner_attr_does_not_annotate_this = the inner attribute doesn't annotate this {$item}
parse_label_unexpected_token = unexpected token

View file

@ -1,14 +1,15 @@
// ignore-tidy-filelength
use std::borrow::Cow;
use std::path::PathBuf;
use rustc_ast::token::Token;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_ast::{Path, Visibility};
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, Subdiagnostic,
SuggestionStyle,
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg,
Level, Subdiagnostic, SuggestionStyle,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_session::errors::ExprParenthesesNeeded;
@ -3341,6 +3342,24 @@ pub(crate) struct KwBadCase<'a> {
#[suggestion(code = "{kw}", style = "verbose", applicability = "machine-applicable")]
pub span: Span,
pub kw: &'a str,
pub case: Case,
}
pub(crate) enum Case {
Upper,
Lower,
Mixed,
}
impl IntoDiagArg for Case {
fn into_diag_arg(self, path: &mut Option<PathBuf>) -> DiagArgValue {
match self {
Case::Upper => "uppercase",
Case::Lower => "lowercase",
Case::Mixed => "the correct case",
}
.into_diag_arg(path)
}
}
#[derive(Diagnostic)]

View file

@ -606,7 +606,20 @@ impl<'a> Parser<'a> {
// Do an ASCII case-insensitive match, because all keywords are ASCII.
&& ident.as_str().eq_ignore_ascii_case(exp.kw.as_str())
{
self.dcx().emit_err(errors::KwBadCase { span: ident.span, kw: exp.kw.as_str() });
let kw = exp.kw.as_str();
let is_upper = kw.chars().all(char::is_uppercase);
let is_lower = kw.chars().all(char::is_lowercase);
let case = match (is_upper, is_lower) {
(true, true) => {
unreachable!("keyword that is both fully upper- and fully lowercase")
}
(true, false) => errors::Case::Upper,
(false, true) => errors::Case::Lower,
(false, false) => errors::Case::Mixed,
};
self.dcx().emit_err(errors::KwBadCase { span: ident.span, kw, case });
self.bump();
true
} else {

View file

@ -1902,7 +1902,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if span.overlaps(def_span) {
// Don't suggest typo suggestion for itself like in the following:
// error[E0423]: expected function, tuple struct or tuple variant, found struct `X`
// --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14
// --> $DIR/unicode-string-literal-syntax-error-64792.rs:4:14
// |
// LL | struct X {}
// | ----------- `X` defined here

View file

@ -281,10 +281,16 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou
}
// Ensure that for niche encoded tags the discriminant coincides with the variant index.
assert_eq!(
layout.ty.discriminant_for_variant(tcx, idx).unwrap().val,
u128::from(idx.as_u32()),
);
let val = layout.ty.discriminant_for_variant(tcx, idx).unwrap().val;
if val != u128::from(idx.as_u32()) {
let adt_def = layout.ty.ty_adt_def().unwrap();
cx.tcx().dcx().span_delayed_bug(
cx.tcx().def_span(adt_def.did()),
format!(
"variant {idx:?} has discriminant {val:?} in niche-encoded type"
),
);
}
}
}
for variant in variants.iter() {

View file

@ -962,8 +962,6 @@ impl<T: SpanTransformer> Reader<'_, T> {
};
res[i] = Some(g);
}
proc_macro_srv::TokenStream::new(vec![proc_macro_srv::TokenTree::Group(
res[0].take().unwrap(),
)])
res[0].take().unwrap().stream.unwrap_or_default()
}
}

View file

@ -297,26 +297,38 @@ fn test_fn_like_macro_noop() {
fn test_fn_like_macro_clone_ident_subtree() {
assert_expand(
"fn_like_clone_tokens",
r#"ident, []"#,
r#"ident, [ident2, ident3]"#,
expect![[r#"
IDENT 1 ident
PUNCT 1 , [alone]
GROUP [] 1 1 1
IDENT 1 ident2
PUNCT 1 , [alone]
IDENT 1 ident3
IDENT 1 ident
PUNCT 1 , [alone]
GROUP [] 1 1 1
IDENT 1 ident2
PUNCT 1 , [alone]
IDENT 1 ident3
"#]],
expect![[r#"
IDENT 42:Root[0000, 0]@0..5#ROOT2024 ident
PUNCT 42:Root[0000, 0]@5..6#ROOT2024 , [alone]
GROUP [] 42:Root[0000, 0]@7..8#ROOT2024 42:Root[0000, 0]@8..9#ROOT2024 42:Root[0000, 0]@7..9#ROOT2024
GROUP [] 42:Root[0000, 0]@7..8#ROOT2024 42:Root[0000, 0]@22..23#ROOT2024 42:Root[0000, 0]@7..23#ROOT2024
IDENT 42:Root[0000, 0]@8..14#ROOT2024 ident2
PUNCT 42:Root[0000, 0]@14..15#ROOT2024 , [alone]
IDENT 42:Root[0000, 0]@16..22#ROOT2024 ident3
IDENT 42:Root[0000, 0]@0..5#ROOT2024 ident
PUNCT 42:Root[0000, 0]@5..6#ROOT2024 , [alone]
GROUP [] 42:Root[0000, 0]@7..9#ROOT2024 42:Root[0000, 0]@7..9#ROOT2024 42:Root[0000, 0]@7..9#ROOT2024
GROUP [] 42:Root[0000, 0]@7..23#ROOT2024 42:Root[0000, 0]@7..23#ROOT2024 42:Root[0000, 0]@7..23#ROOT2024
IDENT 42:Root[0000, 0]@8..14#ROOT2024 ident2
PUNCT 42:Root[0000, 0]@14..15#ROOT2024 , [alone]
IDENT 42:Root[0000, 0]@16..22#ROOT2024 ident3
"#]],
);
}

View file

@ -113,12 +113,6 @@ See [Tracking Issue for autodiff #124509](https://github.com/rust-lang/rust/issu
Tests for automatic referencing and dereferencing behavior, such as automatically adding reference operations (`&` or `&mut`) to make a value match a method's receiver type. Sometimes abbreviated as "auto-ref" or "auto-deref".
## `tests/ui/auxiliary/`: Auxiliary files for tests directly under `tests/ui`.
This top-level `auxiliary` subdirectory contains support files for tests immediately under `tests/ui/`.
**FIXME(#133895)**: tests immediately under `tests/ui/` should be rehomed to more suitable subdirectories, after which this subdirectory can be removed.
## `tests/ui/backtrace/`: Backtraces
Runtime panics and error handling generate backtraces to assist in debugging and diagnostics.
@ -542,12 +536,6 @@ These tests are about very different topics, only unified by the fact that they
Accompanies `tests/ui/error-codes/`, exercises the `--explain` cli flag.
## `tests/ui/explicit/`: Errors involving the concept of "explicit"
This category contains three tests: two which are about the specific error `explicit use of destructor method`, and one which is about explicit annotation of lifetimes: https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/explicit.html.
**FIXME**: Rehome the two tests about the destructor method with `drop`-related categories, and rehome the last test with a category related to lifetimes.
## `tests/ui/explicit-tail-calls/`
Exercises `#![feature(explicit_tail_calls)]` and the `become` keyword. See [Explicit Tail Calls #3407](https://github.com/rust-lang/rfcs/pull/3407).
@ -733,10 +721,6 @@ See [Instrument coverage | The rustc book](https://doc.rust-lang.org/rustc/instr
See [Tracking issue for `-Z instrument-xray` #102921](https://github.com/rust-lang/rust/issues/102921).
## `tests/ui/interior-mutability/`
**FIXME**: contains a single test, probably better rehomed.
## `tests/ui/internal/`
Tests for `internal_unstable` and the attribute header `#![feature(allow_internal_unstable)]`, which lets compiler developers mark features as internal to the compiler, and unstable for standard library use.
@ -759,16 +743,6 @@ Various tests related to rejecting invalid inputs.
Tests for checking that invalid usage of compiler flags are rejected.
## `tests/ui/invalid-module-declaration/`
**FIXME**: Consider merging into module/resolve directories.
## `tests/ui/invalid-self-argument/`: `self` as a function argument incorrectly
Tests with erroneous ways of using `self`, such as having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`).
**FIXME**: Maybe merge with `ui/self`.
## `tests/ui/io-checks/`
Contains a single test. The test tries to output a file into an invalid directory with `-o`, then checks that the result is an error, not an internal compiler error.

View file

@ -1,6 +1,6 @@
//@ run-rustfix
struct Foo {
x: isize
x: isize,
}
impl Drop for Foo {
@ -12,5 +12,5 @@ impl Drop for Foo {
fn main() {
let x = Foo { x: 3 };
println!("{}", x.x);
drop(x); //~ ERROR explicit use of destructor method
drop(x); //~ ERROR explicit use of destructor method
}

View file

@ -1,6 +1,6 @@
//@ run-rustfix
struct Foo {
x: isize
x: isize,
}
impl Drop for Foo {
@ -12,5 +12,5 @@ impl Drop for Foo {
fn main() {
let x = Foo { x: 3 };
println!("{}", x.x);
x.drop(); //~ ERROR explicit use of destructor method
x.drop(); //~ ERROR explicit use of destructor method
}

View file

@ -4,7 +4,7 @@
#![allow(dropping_references)]
struct Foo {
x: isize
x: isize,
}
#[allow(drop_bounds)]
@ -20,7 +20,7 @@ impl Drop for Foo {
impl Bar for Foo {
fn blah(&self) {
drop(self); //~ ERROR explicit use of destructor method
drop(self); //~ ERROR explicit use of destructor method
}
}

View file

@ -4,7 +4,7 @@
#![allow(dropping_references)]
struct Foo {
x: isize
x: isize,
}
#[allow(drop_bounds)]
@ -20,7 +20,7 @@ impl Drop for Foo {
impl Bar for Foo {
fn blah(&self) {
self.drop(); //~ ERROR explicit use of destructor method
self.drop(); //~ ERROR explicit use of destructor method
}
}

View file

@ -0,0 +1,35 @@
error[E0732]: `#[repr(inttype)]` must be specified for enums with explicit discriminants and non-unit variants
--> $DIR/invalid-niche-discriminant.rs:11:1
|
LL | enum E {
| ^^^^^^
...
LL | S0 {
| -- non-unit discriminant declared here
...
LL | Bar = {
| ___________-
LL | | let x = 1;
LL | | 3
LL | | },
| |_____- explicit discriminant specified here
error[E0599]: no variant named `S1` found for enum `E`
--> $DIR/invalid-niche-discriminant.rs:23:18
|
LL | enum E {
| ------ variant `S1` not found here
...
LL | static C: E = E::S1 { u: 23 };
| ^^
|
help: there is a variant with a similar name
|
LL - static C: E = E::S1 { u: 23 };
LL + static C: E = E::S0 { u: 23 };
|
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0599, E0732.
For more information about an error, try `rustc --explain E0599`.

View file

@ -0,0 +1,25 @@
//@ needs-rustc-debug-assertions
//@ revisions: normal with_delayed
//@ [with_delayed] compile-flags: -Z eagerly-emit-delayed-bugs
#![crate_type = "lib"]
// Repro for <https://github.com/rust-lang/rust/issues/144501>
// which ICEd because the calculated layout is invalid
// but which we needn't care about as the discriminant already was.
enum E {
//~^ ERROR must be specified
//[with_delayed]~| ERROR variant 1 has discriminant 3
S0 {
s: String,
},
Bar = {
let x = 1;
3
},
}
static C: E = E::S1 { u: 23 };
//~^ ERROR no variant named
//[with_delayed]~| ERROR but no error emitted

View file

@ -0,0 +1,47 @@
error[E0732]: `#[repr(inttype)]` must be specified for enums with explicit discriminants and non-unit variants
--> $DIR/invalid-niche-discriminant.rs:11:1
|
LL | enum E {
| ^^^^^^
...
LL | S0 {
| -- non-unit discriminant declared here
...
LL | Bar = {
| ___________-
LL | | let x = 1;
LL | | 3
LL | | },
| |_____- explicit discriminant specified here
error: variant 1 has discriminant 3 in niche-encoded type
--> $DIR/invalid-niche-discriminant.rs:11:1
|
LL | enum E {
| ^^^^^^
error[E0599]: no variant named `S1` found for enum `E`
--> $DIR/invalid-niche-discriminant.rs:23:18
|
LL | enum E {
| ------ variant `S1` not found here
...
LL | static C: E = E::S1 { u: 23 };
| ^^
|
help: there is a variant with a similar name
|
LL - static C: E = E::S1 { u: 23 };
LL + static C: E = E::S0 { u: 23 };
|
error: `Res::Err` but no error emitted
--> $DIR/invalid-niche-discriminant.rs:23:15
|
LL | static C: E = E::S1 { u: 23 };
| ^^^^^
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0599, E0732.
For more information about an error, try `rustc --explain E0599`.

View file

@ -1,22 +0,0 @@
//@ dont-require-annotations: NOTE
struct Foo<'a,'b> {
x: &'a isize,
y: &'b isize,
}
impl<'a,'b> Foo<'a,'b> {
fn bar(self:
Foo<'b,'a>
//~^ ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a, 'b>`
//~| NOTE found struct `Foo<'b, 'a>`
//~| NOTE lifetime mismatch
//~| ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a, 'b>`
//~| NOTE found struct `Foo<'b, 'a>`
//~| NOTE lifetime mismatch
) {}
}
fn main() {}

View file

@ -1,41 +0,0 @@
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:10:12
|
LL | Foo<'b,'a>
| ^^^^^^^^^^ lifetime mismatch
|
= note: expected struct `Foo<'a, 'b>`
found struct `Foo<'b, 'a>`
note: the lifetime `'b` as defined here...
--> $DIR/explicit-self-lifetime-mismatch.rs:8:9
|
LL | impl<'a,'b> Foo<'a,'b> {
| ^^
note: ...does not necessarily outlive the lifetime `'a` as defined here
--> $DIR/explicit-self-lifetime-mismatch.rs:8:6
|
LL | impl<'a,'b> Foo<'a,'b> {
| ^^
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:10:12
|
LL | Foo<'b,'a>
| ^^^^^^^^^^ lifetime mismatch
|
= note: expected struct `Foo<'a, 'b>`
found struct `Foo<'b, 'a>`
note: the lifetime `'a` as defined here...
--> $DIR/explicit-self-lifetime-mismatch.rs:8:6
|
LL | impl<'a,'b> Foo<'a,'b> {
| ^^
note: ...does not necessarily outlive the lifetime `'b` as defined here
--> $DIR/explicit-self-lifetime-mismatch.rs:8:9
|
LL | impl<'a,'b> Foo<'a,'b> {
| ^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -1 +0,0 @@
pub mod baz;

View file

@ -1 +0,0 @@
pub mod bar;

View file

@ -1,7 +0,0 @@
mod auxiliary {
mod foo;
}
fn main() {}
//~? ERROR file not found for module `baz`

View file

@ -1,12 +0,0 @@
error[E0583]: file not found for module `baz`
--> $DIR/auxiliary/foo/bar.rs:1:1
|
LL | pub mod baz;
| ^^^^^^^^^^^^
|
= help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs" or "$DIR/auxiliary/foo/bar/baz/mod.rs"
= note: if there is a `mod baz` elsewhere in the crate already, import it with `use crate::...` instead
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0583`.

View file

@ -1,6 +0,0 @@
fn a(&self) { }
//~^ ERROR `self` parameter is only allowed in associated functions
//~| NOTE not semantically valid as function parameter
//~| NOTE associated functions are those in `impl` or `trait` definitions
fn main() { }

View file

@ -1,10 +0,0 @@
error: `self` parameter is only allowed in associated functions
--> $DIR/bare-fn-start.rs:1:6
|
LL | fn a(&self) { }
| ^^^^^ not semantically valid as function parameter
|
= note: associated functions are those in `impl` or `trait` definitions
error: aborting due to 1 previous error

View file

@ -1,5 +0,0 @@
fn b(foo: u32, &mut self) { }
//~^ ERROR unexpected `self` parameter in function
//~| NOTE must be the first parameter of an associated function
fn main() { }

View file

@ -1,8 +0,0 @@
error: unexpected `self` parameter in function
--> $DIR/bare-fn.rs:1:16
|
LL | fn b(foo: u32, &mut self) { }
| ^^^^^^^^^ must be the first parameter of an associated function
error: aborting due to 1 previous error

View file

@ -1,11 +0,0 @@
struct Foo {}
impl Foo {
fn c(foo: u32, self) {}
//~^ ERROR unexpected `self` parameter in function
//~| NOTE must be the first parameter of an associated function
fn good(&mut self, foo: u32) {}
}
fn main() { }

View file

@ -1,8 +0,0 @@
error: unexpected `self` parameter in function
--> $DIR/trait-fn.rs:4:20
|
LL | fn c(foo: u32, self) {}
| ^^^^ must be the first parameter of an associated function
error: aborting due to 1 previous error

View file

@ -1,20 +0,0 @@
//@ dont-require-annotations: NOTE
struct Foo<'a> {
data: &'a[u8],
}
impl <'a> Foo<'a>{
fn bar(self: &mut Foo) {
//~^ ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a>`
//~| NOTE found struct `Foo<'_>`
//~| NOTE lifetime mismatch
//~| ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a>`
//~| NOTE found struct `Foo<'_>`
//~| NOTE lifetime mismatch
}
}
fn main() {}

View file

@ -1,41 +0,0 @@
error[E0308]: mismatched `self` parameter type
--> $DIR/issue-17740.rs:8:18
|
LL | fn bar(self: &mut Foo) {
| ^^^^^^^^ lifetime mismatch
|
= note: expected struct `Foo<'a>`
found struct `Foo<'_>`
note: the anonymous lifetime defined here...
--> $DIR/issue-17740.rs:8:23
|
LL | fn bar(self: &mut Foo) {
| ^^^
note: ...does not necessarily outlive the lifetime `'a` as defined here
--> $DIR/issue-17740.rs:7:7
|
LL | impl <'a> Foo<'a>{
| ^^
error[E0308]: mismatched `self` parameter type
--> $DIR/issue-17740.rs:8:18
|
LL | fn bar(self: &mut Foo) {
| ^^^^^^^^ lifetime mismatch
|
= note: expected struct `Foo<'a>`
found struct `Foo<'_>`
note: the lifetime `'a` as defined here...
--> $DIR/issue-17740.rs:7:7
|
LL | impl <'a> Foo<'a>{
| ^^
note: ...does not necessarily outlive the anonymous lifetime defined here
--> $DIR/issue-17740.rs:8:23
|
LL | fn bar(self: &mut Foo) {
| ^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,41 @@
//@ dont-require-annotations: NOTE
//! regression test for <https://github.com/rust-lang/rust/issues/17740>
struct Foo<'a, 'b> {
x: &'a isize,
y: &'b isize,
}
impl<'a, 'b> Foo<'a, 'b> {
fn bar(
self: Foo<'b, 'a>,
//~^ ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a, 'b>`
//~| NOTE found struct `Foo<'b, 'a>`
//~| NOTE lifetime mismatch
//~| ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a, 'b>`
//~| NOTE found struct `Foo<'b, 'a>`
//~| NOTE lifetime mismatch
) {
}
}
struct Bar<'a> {
data: &'a [u8],
}
impl<'a> Bar<'a> {
fn bar(self: &mut Bar) {
//~^ ERROR mismatched `self` parameter type
//~| NOTE expected struct `Bar<'a>`
//~| NOTE found struct `Bar<'_>`
//~| NOTE lifetime mismatch
//~| ERROR mismatched `self` parameter type
//~| NOTE expected struct `Bar<'a>`
//~| NOTE found struct `Bar<'_>`
//~| NOTE lifetime mismatch
}
}
fn main() {}

View file

@ -0,0 +1,79 @@
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:11:15
|
LL | self: Foo<'b, 'a>,
| ^^^^^^^^^^^ lifetime mismatch
|
= note: expected struct `Foo<'a, 'b>`
found struct `Foo<'b, 'a>`
note: the lifetime `'b` as defined here...
--> $DIR/explicit-self-lifetime-mismatch.rs:9:10
|
LL | impl<'a, 'b> Foo<'a, 'b> {
| ^^
note: ...does not necessarily outlive the lifetime `'a` as defined here
--> $DIR/explicit-self-lifetime-mismatch.rs:9:6
|
LL | impl<'a, 'b> Foo<'a, 'b> {
| ^^
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:11:15
|
LL | self: Foo<'b, 'a>,
| ^^^^^^^^^^^ lifetime mismatch
|
= note: expected struct `Foo<'a, 'b>`
found struct `Foo<'b, 'a>`
note: the lifetime `'a` as defined here...
--> $DIR/explicit-self-lifetime-mismatch.rs:9:6
|
LL | impl<'a, 'b> Foo<'a, 'b> {
| ^^
note: ...does not necessarily outlive the lifetime `'b` as defined here
--> $DIR/explicit-self-lifetime-mismatch.rs:9:10
|
LL | impl<'a, 'b> Foo<'a, 'b> {
| ^^
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:29:18
|
LL | fn bar(self: &mut Bar) {
| ^^^^^^^^ lifetime mismatch
|
= note: expected struct `Bar<'a>`
found struct `Bar<'_>`
note: the anonymous lifetime defined here...
--> $DIR/explicit-self-lifetime-mismatch.rs:29:23
|
LL | fn bar(self: &mut Bar) {
| ^^^
note: ...does not necessarily outlive the lifetime `'a` as defined here
--> $DIR/explicit-self-lifetime-mismatch.rs:28:6
|
LL | impl<'a> Bar<'a> {
| ^^
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:29:18
|
LL | fn bar(self: &mut Bar) {
| ^^^^^^^^ lifetime mismatch
|
= note: expected struct `Bar<'a>`
found struct `Bar<'_>`
note: the lifetime `'a` as defined here...
--> $DIR/explicit-self-lifetime-mismatch.rs:28:6
|
LL | impl<'a> Bar<'a> {
| ^^
note: ...does not necessarily outlive the anonymous lifetime defined here
--> $DIR/explicit-self-lifetime-mismatch.rs:29:23
|
LL | fn bar(self: &mut Bar) {
| ^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -4,7 +4,7 @@ error: keyword `use` is written in the wrong case
LL | Use std::ptr::read;
| ^^^
|
help: write it in the correct case (notice the capitalization)
help: write it in lowercase (notice the capitalization)
|
LL - Use std::ptr::read;
LL + use std::ptr::read;
@ -16,7 +16,7 @@ error: keyword `use` is written in the wrong case
LL | USE std::ptr::write;
| ^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - USE std::ptr::write;
LL + use std::ptr::write;
@ -28,7 +28,7 @@ error: keyword `fn` is written in the wrong case
LL | async Fn _a() {}
| ^^
|
help: write it in the correct case (notice the capitalization)
help: write it in lowercase (notice the capitalization)
|
LL - async Fn _a() {}
LL + async fn _a() {}
@ -40,7 +40,7 @@ error: keyword `fn` is written in the wrong case
LL | Fn _b() {}
| ^^
|
help: write it in the correct case (notice the capitalization)
help: write it in lowercase (notice the capitalization)
|
LL - Fn _b() {}
LL + fn _b() {}
@ -52,7 +52,7 @@ error: keyword `async` is written in the wrong case
LL | aSYNC fN _c() {}
| ^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - aSYNC fN _c() {}
LL + async fN _c() {}
@ -64,7 +64,7 @@ error: keyword `fn` is written in the wrong case
LL | aSYNC fN _c() {}
| ^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - aSYNC fN _c() {}
LL + aSYNC fn _c() {}
@ -76,7 +76,7 @@ error: keyword `async` is written in the wrong case
LL | Async fn _d() {}
| ^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - Async fn _d() {}
LL + async fn _d() {}
@ -88,7 +88,7 @@ error: keyword `const` is written in the wrong case
LL | CONST UNSAFE FN _e() {}
| ^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - CONST UNSAFE FN _e() {}
LL + const UNSAFE FN _e() {}
@ -100,7 +100,7 @@ error: keyword `unsafe` is written in the wrong case
LL | CONST UNSAFE FN _e() {}
| ^^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - CONST UNSAFE FN _e() {}
LL + CONST unsafe FN _e() {}
@ -112,7 +112,7 @@ error: keyword `fn` is written in the wrong case
LL | CONST UNSAFE FN _e() {}
| ^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - CONST UNSAFE FN _e() {}
LL + CONST UNSAFE fn _e() {}
@ -124,7 +124,7 @@ error: keyword `unsafe` is written in the wrong case
LL | unSAFE EXTern "C" fn _f() {}
| ^^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - unSAFE EXTern "C" fn _f() {}
LL + unsafe EXTern "C" fn _f() {}
@ -136,7 +136,7 @@ error: keyword `extern` is written in the wrong case
LL | unSAFE EXTern "C" fn _f() {}
| ^^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - unSAFE EXTern "C" fn _f() {}
LL + unSAFE extern "C" fn _f() {}
@ -148,7 +148,7 @@ error: keyword `extern` is written in the wrong case
LL | EXTERN "C" FN _g() {}
| ^^^^^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - EXTERN "C" FN _g() {}
LL + extern "C" FN _g() {}
@ -160,7 +160,7 @@ error: keyword `fn` is written in the wrong case
LL | EXTERN "C" FN _g() {}
| ^^
|
help: write it in the correct case
help: write it in lowercase
|
LL - EXTERN "C" FN _g() {}
LL + EXTERN "C" fn _g() {}

View file

@ -0,0 +1,22 @@
//! regression test for <https://github.com/rust-lang/rust/issues/55972>
fn a(&self) {}
//~^ ERROR `self` parameter is only allowed in associated functions
//~| NOTE not semantically valid as function parameter
//~| NOTE associated functions are those in `impl` or `trait` definitions
fn b(foo: u32, &mut self) {}
//~^ ERROR unexpected `self` parameter in function
//~| NOTE must be the first parameter of an associated function
struct Foo {}
impl Foo {
fn c(foo: u32, self) {}
//~^ ERROR unexpected `self` parameter in function
//~| NOTE must be the first parameter of an associated function
fn good(&mut self, foo: u32) {}
}
fn main() {}

View file

@ -0,0 +1,22 @@
error: unexpected `self` parameter in function
--> $DIR/invalid-self-argument.rs:8:16
|
LL | fn b(foo: u32, &mut self) {}
| ^^^^^^^^^ must be the first parameter of an associated function
error: unexpected `self` parameter in function
--> $DIR/invalid-self-argument.rs:15:20
|
LL | fn c(foo: u32, self) {}
| ^^^^ must be the first parameter of an associated function
error: `self` parameter is only allowed in associated functions
--> $DIR/invalid-self-argument.rs:3:6
|
LL | fn a(&self) {}
| ^^^^^ not semantically valid as function parameter
|
= note: associated functions are those in `impl` or `trait` definitions
error: aborting due to 3 previous errors

View file

@ -1,3 +1,4 @@
//! related issue: <https://github.com/rust-lang/rust/issues/40313>
//@ compile-flags: -Zwrite-long-types-to-disk=yes
use std::cell::Cell;
use std::panic::catch_unwind;

View file

@ -1,5 +1,5 @@
error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary
--> $DIR/interior-mutability.rs:6:18
--> $DIR/catch-unwind-cell-interior-mut.rs:7:18
|
LL | catch_unwind(|| { x.set(23); });
| ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary
@ -11,7 +11,7 @@ note: required because it appears within the type `Cell<i32>`
--> $SRC_DIR/core/src/cell.rs:LL:COL
= note: required for `&Cell<i32>` to implement `UnwindSafe`
note: required because it's used within this closure
--> $DIR/interior-mutability.rs:6:18
--> $DIR/catch-unwind-cell-interior-mut.rs:7:18
|
LL | catch_unwind(|| { x.set(23); });
| ^^

View file

@ -1,4 +1,4 @@
//@ edition: 2021
//@ edition: 2018..
macro_rules! macro_dollar_crate {
() => {