Skip to content

Commit 4d7c095

Browse files
committed
Auto merge of #129331 - matthiaskrgr:rollup-rxv463w, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #128662 (Lint on tail expr drop order change in Edition 2024) - #128932 (skip updating when external binding is existed) - #129270 (Don't consider locals to shadow inner items' generics) - #129277 (Update annotate-snippets to 0.11) - #129294 (Stabilize `iter::repeat_n`) - #129308 (fix: simple typo in compiler directory) - #129309 (ctfe: make CompileTimeInterpCx type alias public) - #129314 (fix a broken link in `mir/mod.rs`) - #129318 (Remove unneeded conversion to `DefId` for `ExtraInfo`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5aea140 + f631287 commit 4d7c095

Some content is hidden

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

41 files changed

+742
-142
lines changed

Cargo.lock

+2-12
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ dependencies = [
9494
"yansi-term",
9595
]
9696

97-
[[package]]
98-
name = "annotate-snippets"
99-
version = "0.10.2"
100-
source = "registry+https://github.com/rust-lang/crates.io-index"
101-
checksum = "6d9b665789884a7e8fb06c84b295e923b03ca51edbb7d08f91a6a50322ecbfe6"
102-
dependencies = [
103-
"anstyle",
104-
"unicode-width",
105-
]
106-
10797
[[package]]
10898
name = "annotate-snippets"
10999
version = "0.11.4"
@@ -3642,7 +3632,7 @@ dependencies = [
36423632
name = "rustc_errors"
36433633
version = "0.0.0"
36443634
dependencies = [
3645-
"annotate-snippets 0.10.2",
3635+
"annotate-snippets 0.11.4",
36463636
"derive_setters",
36473637
"rustc_ast",
36483638
"rustc_ast_pretty",
@@ -3702,7 +3692,7 @@ dependencies = [
37023692
name = "rustc_fluent_macro"
37033693
version = "0.0.0"
37043694
dependencies = [
3705-
"annotate-snippets 0.10.2",
3695+
"annotate-snippets 0.11.4",
37063696
"fluent-bundle",
37073697
"fluent-syntax",
37083698
"proc-macro2",

compiler/rustc_const_eval/src/const_eval/machine.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ const TINY_LINT_TERMINATOR_LIMIT: usize = 20;
4040
/// power of two of interpreted terminators.
4141
const PROGRESS_INDICATOR_START: usize = 4_000_000;
4242

43-
/// Extra machine state for CTFE, and the Machine instance
43+
/// Extra machine state for CTFE, and the Machine instance.
44+
//
45+
// Should be public because out-of-tree rustc consumers need this
46+
// if they want to interact with constant values.
4447
pub struct CompileTimeMachine<'tcx> {
4548
/// The number of terminators that have been evaluated.
4649
///
@@ -160,7 +163,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
160163
}
161164
}
162165

163-
pub(crate) type CompileTimeInterpCx<'tcx> = InterpCx<'tcx, CompileTimeMachine<'tcx>>;
166+
pub type CompileTimeInterpCx<'tcx> = InterpCx<'tcx, CompileTimeMachine<'tcx>>;
164167

165168
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
166169
pub enum MemoryKind {

compiler/rustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
annotate-snippets = "0.10"
8+
annotate-snippets = "0.11"
99
derive_setters = "0.1.6"
1010
rustc_ast = { path = "../rustc_ast" }
1111
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+29-40
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
77
8-
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
8+
use annotate_snippets::{Renderer, Snippet};
99
use rustc_data_structures::sync::Lrc;
1010
use rustc_error_messages::FluentArgs;
1111
use rustc_span::source_map::SourceMap;
@@ -83,15 +83,17 @@ fn source_string(file: Lrc<SourceFile>, line: &Line) -> String {
8383
file.get_line(line.line_index - 1).map(|a| a.to_string()).unwrap_or_default()
8484
}
8585

86-
/// Maps `diagnostic::Level` to `snippet::AnnotationType`
87-
fn annotation_type_for_level(level: Level) -> AnnotationType {
86+
/// Maps [`crate::Level`] to [`annotate_snippets::Level`]
87+
fn annotation_level_for_level(level: Level) -> annotate_snippets::Level {
8888
match level {
89-
Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => AnnotationType::Error,
90-
Level::ForceWarning(_) | Level::Warning => AnnotationType::Warning,
91-
Level::Note | Level::OnceNote => AnnotationType::Note,
92-
Level::Help | Level::OnceHelp => AnnotationType::Help,
89+
Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => {
90+
annotate_snippets::Level::Error
91+
}
92+
Level::ForceWarning(_) | Level::Warning => annotate_snippets::Level::Warning,
93+
Level::Note | Level::OnceNote => annotate_snippets::Level::Note,
94+
Level::Help | Level::OnceHelp => annotate_snippets::Level::Help,
9395
// FIXME(#59346): Not sure how to map this level
94-
Level::FailureNote => AnnotationType::Error,
96+
Level::FailureNote => annotate_snippets::Level::Error,
9597
Level::Allow => panic!("Should not call with Allow"),
9698
Level::Expect(_) => panic!("Should not call with Expect"),
9799
}
@@ -180,42 +182,29 @@ impl AnnotateSnippetEmitter {
180182
})
181183
.collect();
182184
let code = code.map(|code| code.to_string());
183-
let snippet = Snippet {
184-
title: Some(Annotation {
185-
label: Some(&message),
186-
id: code.as_deref(),
187-
annotation_type: annotation_type_for_level(*level),
188-
}),
189-
footer: vec![],
190-
slices: annotated_files
191-
.iter()
192-
.map(|(file_name, source, line_index, annotations)| {
193-
Slice {
194-
source,
195-
line_start: *line_index,
196-
origin: Some(file_name),
197-
// FIXME(#59346): Not really sure when `fold` should be true or false
198-
fold: false,
199-
annotations: annotations
200-
.iter()
201-
.map(|annotation| SourceAnnotation {
202-
range: (
203-
annotation.start_col.display,
204-
annotation.end_col.display,
205-
),
206-
label: annotation.label.as_deref().unwrap_or_default(),
207-
annotation_type: annotation_type_for_level(*level),
208-
})
209-
.collect(),
210-
}
211-
})
212-
.collect(),
213-
};
185+
186+
let snippets =
187+
annotated_files.iter().map(|(file_name, source, line_index, annotations)| {
188+
Snippet::source(source)
189+
.line_start(*line_index)
190+
.origin(file_name)
191+
// FIXME(#59346): Not really sure when `fold` should be true or false
192+
.fold(false)
193+
.annotations(annotations.iter().map(|annotation| {
194+
annotation_level_for_level(*level)
195+
.span(annotation.start_col.display..annotation.end_col.display)
196+
.label(annotation.label.as_deref().unwrap_or_default())
197+
}))
198+
});
199+
let mut message = annotation_level_for_level(*level).title(&message).snippets(snippets);
200+
if let Some(code) = code.as_deref() {
201+
message = message.id(code)
202+
}
214203
// FIXME(#59346): Figure out if we can _always_ print to stderr or not.
215204
// `emitter.rs` has the `Destination` enum that lists various possible output
216205
// destinations.
217206
let renderer = Renderer::plain().anonymized_line_numbers(self.ui_testing);
218-
eprintln!("{}", renderer.render(snippet))
207+
eprintln!("{}", renderer.render(message))
219208
}
220209
// FIXME(#59346): Is it ok to return None if there's no source_map?
221210
}

compiler/rustc_fluent_macro/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ proc-macro = true
88

99
[dependencies]
1010
# tidy-alphabetical-start
11-
annotate-snippets = "0.10"
11+
annotate-snippets = "0.11"
1212
fluent-bundle = "0.15.2"
1313
fluent-syntax = "0.11"
1414
proc-macro2 = "1"

compiler/rustc_fluent_macro/src/fluent.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
22
use std::fs::read_to_string;
33
use std::path::{Path, PathBuf};
44

5-
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
5+
use annotate_snippets::{Renderer, Snippet};
66
use fluent_bundle::{FluentBundle, FluentError, FluentResource};
77
use fluent_syntax::ast::{
88
Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement,
@@ -154,27 +154,15 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
154154
.unwrap()
155155
.0;
156156

157-
let snippet = Snippet {
158-
title: Some(Annotation {
159-
label: Some(&err),
160-
id: None,
161-
annotation_type: AnnotationType::Error,
162-
}),
163-
footer: vec![],
164-
slices: vec![Slice {
165-
source: this.source(),
166-
line_start,
167-
origin: Some(&relative_ftl_path),
168-
fold: true,
169-
annotations: vec![SourceAnnotation {
170-
label: "",
171-
annotation_type: AnnotationType::Error,
172-
range: (pos.start, pos.end - 1),
173-
}],
174-
}],
175-
};
157+
let message = annotate_snippets::Level::Error.title(&err).snippet(
158+
Snippet::source(this.source())
159+
.line_start(line_start)
160+
.origin(&relative_ftl_path)
161+
.fold(true)
162+
.annotation(annotate_snippets::Level::Error.span(pos.start..pos.end - 1)),
163+
);
176164
let renderer = Renderer::plain();
177-
eprintln!("{}\n", renderer.render(snippet));
165+
eprintln!("{}\n", renderer.render(message));
178166
}
179167

180168
return failed(&crate_name);

compiler/rustc_lint/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ lint_suspicious_double_ref_clone =
758758
lint_suspicious_double_ref_deref =
759759
using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type
760760
761+
lint_tail_expr_drop_order = these values and local bindings have significant drop implementation that will have a different drop order from that of Edition 2021
762+
.label = these values have significant drop implementation and will observe changes in drop order under Edition 2024
763+
761764
lint_trailing_semi_macro = trailing semicolon in macro used in expression position
762765
.note1 = macro invocations at the end of a block are treated as expressions
763766
.note2 = to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`

compiler/rustc_lint/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ mod ptr_nulls;
7878
mod redundant_semicolon;
7979
mod reference_casting;
8080
mod shadowed_into_iter;
81+
mod tail_expr_drop_order;
8182
mod traits;
8283
mod types;
8384
mod unit_bindings;
@@ -115,6 +116,7 @@ use rustc_middle::query::Providers;
115116
use rustc_middle::ty::TyCtxt;
116117
use shadowed_into_iter::ShadowedIntoIter;
117118
pub use shadowed_into_iter::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
119+
use tail_expr_drop_order::TailExprDropOrder;
118120
use traits::*;
119121
use types::*;
120122
use unit_bindings::*;
@@ -238,6 +240,7 @@ late_lint_methods!(
238240
AsyncFnInTrait: AsyncFnInTrait,
239241
NonLocalDefinitions: NonLocalDefinitions::default(),
240242
ImplTraitOvercaptures: ImplTraitOvercaptures,
243+
TailExprDropOrder: TailExprDropOrder,
241244
]
242245
]
243246
);

0 commit comments

Comments
 (0)