Skip to content

Commit 011d34e

Browse files
committed
Auto merge of rust-lang#120561 - matthiaskrgr:rollup-uz1ednf, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#119759 (Add FileCheck annotations to dataflow-const-prop tests) - rust-lang#120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - rust-lang#120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - rust-lang#120520 (Some cleanups around diagnostic levels.) - rust-lang#120540 (add test for try-block-in-match-arm) - rust-lang#120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - rust-lang#120552 (Correctly check `never_type` feature gating) - rust-lang#120555 (put pnkfelix (me) back on the review queue.) - rust-lang#120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 671eb38 + 4b3423b commit 011d34e

File tree

168 files changed

+1290
-671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+1290
-671
lines changed

Diff for: compiler/rustc_ast_passes/src/feature_gate.rs

+13
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,19 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
362362
}
363363
}
364364

365+
fn visit_generic_args(&mut self, args: &'a ast::GenericArgs) {
366+
// This check needs to happen here because the never type can be returned from a function,
367+
// but cannot be used in any other context. If this check was in `visit_fn_ret_ty`, it
368+
// include both functions and generics like `impl Fn() -> !`.
369+
if let ast::GenericArgs::Parenthesized(generic_args) = args
370+
&& let ast::FnRetTy::Ty(ref ty) = generic_args.output
371+
&& matches!(ty.kind, ast::TyKind::Never)
372+
{
373+
gate!(&self, never_type, ty.span, "the `!` type is experimental");
374+
}
375+
visit::walk_generic_args(self, args);
376+
}
377+
365378
fn visit_expr(&mut self, e: &'a ast::Expr) {
366379
match e.kind {
367380
ast::ExprKind::TryBlock(_) => {

Diff for: compiler/rustc_error_codes/src/error_codes/E0091.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
An unnecessary type or const parameter was given in a type alias.
1+
An unnecessary type parameter was given in a type alias.
22

33
Erroneous code example:
44

55
```compile_fail,E0091
6-
type Foo<T> = u32; // error: type parameter `T` is unused
6+
type Foo<T> = u32; // error: type parameter `T` is never used
77
// or:
8-
type Foo<A,B> = Box<A>; // error: type parameter `B` is unused
8+
type Foo<A, B> = Box<A>; // error: type parameter `B` is never used
99
```
1010

1111
Please check you didn't write too many parameters. Example:

Diff for: compiler/rustc_error_messages/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl From<Cow<'static, str>> for DiagnosticMessage {
378378
}
379379
}
380380

381-
/// A workaround for "good path" ICEs when formatting types in disabled lints.
381+
/// A workaround for good_path_delayed_bug ICEs when formatting types in disabled lints.
382382
///
383383
/// Delays formatting until `.into(): DiagnosticMessage` is used.
384384
pub struct DelayDm<F>(pub F);

Diff for: compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ fn source_string(file: Lrc<SourceFile>, line: &Line) -> String {
8585
/// Maps `Diagnostic::Level` to `snippet::AnnotationType`
8686
fn annotation_type_for_level(level: Level) -> AnnotationType {
8787
match level {
88-
Level::Bug | Level::DelayedBug(_) | Level::Fatal | Level::Error => AnnotationType::Error,
88+
Level::Bug
89+
| Level::Fatal
90+
| Level::Error
91+
| Level::DelayedBug
92+
| Level::GoodPathDelayedBug => AnnotationType::Error,
8993
Level::ForceWarning(_) | Level::Warning => AnnotationType::Warning,
9094
Level::Note | Level::OnceNote => AnnotationType::Note,
9195
Level::Help | Level::OnceHelp => AnnotationType::Help,

Diff for: compiler/rustc_errors/src/diagnostic.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::snippet::Style;
22
use crate::{
3-
CodeSuggestion, DelayedBugKind, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee,
4-
ErrCode, Level, MultiSpan, SubdiagnosticMessage, Substitution, SubstitutionPart,
5-
SuggestionStyle,
3+
CodeSuggestion, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, ErrCode, Level,
4+
MultiSpan, SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
65
};
76
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
87
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
@@ -233,19 +232,16 @@ impl Diagnostic {
233232

234233
pub fn is_error(&self) -> bool {
235234
match self.level {
236-
Level::Bug
237-
| Level::DelayedBug(DelayedBugKind::Normal)
238-
| Level::Fatal
239-
| Level::Error
240-
| Level::FailureNote => true,
235+
Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => true,
241236

242-
Level::ForceWarning(_)
237+
Level::GoodPathDelayedBug
238+
| Level::ForceWarning(_)
243239
| Level::Warning
244-
| Level::DelayedBug(DelayedBugKind::GoodPath)
245240
| Level::Note
246241
| Level::OnceNote
247242
| Level::Help
248243
| Level::OnceHelp
244+
| Level::FailureNote
249245
| Level::Allow
250246
| Level::Expect(_) => false,
251247
}
@@ -304,11 +300,11 @@ impl Diagnostic {
304300
#[track_caller]
305301
pub fn downgrade_to_delayed_bug(&mut self) {
306302
assert!(
307-
self.is_error(),
303+
matches!(self.level, Level::Error | Level::DelayedBug),
308304
"downgrade_to_delayed_bug: cannot downgrade {:?} to DelayedBug: not an error",
309305
self.level
310306
);
311-
self.level = Level::DelayedBug(DelayedBugKind::Normal);
307+
self.level = Level::DelayedBug;
312308
}
313309

314310
/// Appends a labeled span to the diagnostic.

Diff for: compiler/rustc_errors/src/emitter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,7 @@ impl HumanEmitter {
21182118
}
21192119
if !self.short_message {
21202120
for child in children {
2121+
assert!(child.level.can_be_top_or_sub().1);
21212122
let span = &child.span;
21222123
if let Err(err) = self.emit_messages_default_inner(
21232124
span,

0 commit comments

Comments
 (0)