diff --git a/.github/ISSUE_TEMPLATE/ice.md b/.github/ISSUE_TEMPLATE/ice.md index 1ab1ddf46016..2afcd210a6eb 100644 --- a/.github/ISSUE_TEMPLATE/ice.md +++ b/.github/ISSUE_TEMPLATE/ice.md @@ -2,7 +2,6 @@ name: Internal Compiler Error about: Create a report for an internal compiler error in rustc. labels: C-bug, I-ICE, T-compiler -title: "[ICE]: " --- file.rs:16:58 + // | + // 16 | ... fn foo(self) -> Self::Bar { + // | ^^^^^^^^^ + // ``` + + let mut m = Margin { + whitespace_left: whitespace_left.saturating_sub(6), + span_left: span_left.saturating_sub(6), + span_right: span_right + 6, + computed_left: 0, + computed_right: 0, + column_width, + label_right: label_right + 6, + }; + m.compute(max_line_len); + m + } + + fn was_cut_left(&self) -> bool { + self.computed_left > 0 + } + + fn compute(&mut self, max_line_len: usize) { + // When there's a lot of whitespace (>20), we want to trim it as it is useless. + // FIXME: this doesn't account for '\t', but to do so correctly we need to perform that + // calculation later, right before printing in order to be accurate with both unicode + // handling and trimming of long lines. + self.computed_left = if self.whitespace_left > 20 { + self.whitespace_left - 16 // We want some padding. + } else { + 0 + }; + // We want to show as much as possible, max_line_len is the rightmost boundary for the + // relevant code. + self.computed_right = max(max_line_len, self.computed_left); + + if self.computed_right - self.computed_left > self.column_width { + // Trimming only whitespace isn't enough, let's get craftier. + if self.label_right - self.whitespace_left <= self.column_width { + // Attempt to fit the code window only trimming whitespace. + self.computed_left = self.whitespace_left; + self.computed_right = self.computed_left + self.column_width; + } else if self.label_right - self.span_left <= self.column_width { + // Attempt to fit the code window considering only the spans and labels. + let padding_left = (self.column_width - (self.label_right - self.span_left)) / 2; + self.computed_left = self.span_left.saturating_sub(padding_left); + self.computed_right = self.computed_left + self.column_width; + } else if self.span_right - self.span_left <= self.column_width { + // Attempt to fit the code window considering the spans and labels plus padding. + let padding_left = (self.column_width - (self.span_right - self.span_left)) / 5 * 2; + self.computed_left = self.span_left.saturating_sub(padding_left); + self.computed_right = self.computed_left + self.column_width; + } else { + // Mostly give up but still don't show the full line. + self.computed_left = self.span_left; + self.computed_right = self.span_right; + } + } + } + + fn left(&self, line_len: usize) -> usize { + min(self.computed_left, line_len) + } + + fn right(&self, line_len: usize) -> usize { + if line_len.saturating_sub(self.computed_left) <= self.column_width { + line_len + } else { + min(line_len, self.computed_right) + } + } +} + pub enum TimingEvent { Start, End, } +const ANONYMIZED_LINE_NUM: &str = "LL"; + pub type DynEmitter = dyn Emitter + DynSend; /// Emitter trait for emitting errors and other structured information. pub trait Emitter { /// Emit a structured diagnostic. - fn emit_diagnostic(&mut self, diag: DiagInner); + fn emit_diagnostic(&mut self, diag: DiagInner, registry: &Registry); /// Emit a notification that an artifact has been output. /// Currently only supported for the JSON format. @@ -65,7 +187,7 @@ pub trait Emitter { /// Emit a report about future breakage. /// Currently only supported for the JSON format. - fn emit_future_breakage_report(&mut self, _diags: Vec) {} + fn emit_future_breakage_report(&mut self, _diags: Vec, _registry: &Registry) {} /// Emit list of unused externs. /// Currently only supported for the JSON format. @@ -368,6 +490,48 @@ pub trait Emitter { } } +impl Emitter for HumanEmitter { + fn source_map(&self) -> Option<&SourceMap> { + self.sm.as_deref() + } + + fn emit_diagnostic(&mut self, mut diag: DiagInner, _registry: &Registry) { + let fluent_args = to_fluent_args(diag.args.iter()); + + if self.track_diagnostics && diag.span.has_primary_spans() && !diag.span.is_dummy() { + diag.children.insert(0, diag.emitted_at_sub_diag()); + } + + let mut suggestions = diag.suggestions.unwrap_tag(); + self.primary_span_formatted(&mut diag.span, &mut suggestions, &fluent_args); + + self.fix_multispans_in_extern_macros_and_render_macro_backtrace( + &mut diag.span, + &mut diag.children, + &diag.level, + self.macro_backtrace, + ); + + self.emit_messages_default( + &diag.level, + &diag.messages, + &fluent_args, + &diag.code, + &diag.span, + &diag.children, + &suggestions, + ); + } + + fn should_show_explain(&self) -> bool { + !self.short_message + } + + fn translator(&self) -> &Translator { + &self.translator + } +} + /// An emitter that adds a note to each diagnostic. pub struct EmitterWithNote { pub emitter: Box, @@ -379,9 +543,9 @@ impl Emitter for EmitterWithNote { None } - fn emit_diagnostic(&mut self, mut diag: DiagInner) { + fn emit_diagnostic(&mut self, mut diag: DiagInner, registry: &Registry) { diag.sub(Level::Note, self.note.clone(), MultiSpan::new()); - self.emitter.emit_diagnostic(diag); + self.emitter.emit_diagnostic(diag, registry); } fn translator(&self) -> &Translator { @@ -398,7 +562,7 @@ impl Emitter for SilentEmitter { None } - fn emit_diagnostic(&mut self, _diag: DiagInner) {} + fn emit_diagnostic(&mut self, _diag: DiagInner, _registry: &Registry) {} fn translator(&self) -> &Translator { &self.translator @@ -440,6 +604,2703 @@ pub enum OutputTheme { Unicode, } +/// Handles the writing of `HumanReadableErrorType` +#[derive(Setters)] +pub struct HumanEmitter { + #[setters(skip)] + dst: IntoDynSyncSend, + sm: Option>, + #[setters(skip)] + translator: Translator, + short_message: bool, + ui_testing: bool, + ignored_directories_in_source_blocks: Vec, + diagnostic_width: Option, + + macro_backtrace: bool, + track_diagnostics: bool, + terminal_url: TerminalUrl, + theme: OutputTheme, +} + +#[derive(Debug)] +pub(crate) struct FileWithAnnotatedLines { + pub(crate) file: Arc, + pub(crate) lines: Vec, + multiline_depth: usize, +} + +impl HumanEmitter { + pub fn new(dst: Destination, translator: Translator) -> HumanEmitter { + HumanEmitter { + dst: IntoDynSyncSend(dst), + sm: None, + translator, + short_message: false, + ui_testing: false, + ignored_directories_in_source_blocks: Vec::new(), + diagnostic_width: None, + macro_backtrace: false, + track_diagnostics: false, + terminal_url: TerminalUrl::No, + theme: OutputTheme::Ascii, + } + } + + fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> { + if self.ui_testing { + Cow::Borrowed(ANONYMIZED_LINE_NUM) + } else { + Cow::Owned(line_num.to_string()) + } + } + + fn draw_line( + &self, + buffer: &mut StyledBuffer, + source_string: &str, + line_index: usize, + line_offset: usize, + width_offset: usize, + code_offset: usize, + margin: Margin, + ) -> usize { + let line_len = source_string.len(); + // Create the source line we will highlight. + let left = margin.left(line_len); + let right = margin.right(line_len); + // FIXME: The following code looks fishy. See #132860. + // On long lines, we strip the source line, accounting for unicode. + let code: String = source_string + .chars() + .enumerate() + .skip_while(|(i, _)| *i < left) + .take_while(|(i, _)| *i < right) + .map(|(_, c)| c) + .collect(); + let code = normalize_whitespace(&code); + let was_cut_right = + source_string.chars().enumerate().skip_while(|(i, _)| *i < right).next().is_some(); + buffer.puts(line_offset, code_offset, &code, Style::Quotation); + let placeholder = self.margin(); + if margin.was_cut_left() { + // We have stripped some code/whitespace from the beginning, make it clear. + buffer.puts(line_offset, code_offset, placeholder, Style::LineNumber); + } + if was_cut_right { + let padding = str_width(placeholder); + // We have stripped some code after the rightmost span end, make it clear we did so. + buffer.puts( + line_offset, + code_offset + str_width(&code) - padding, + placeholder, + Style::LineNumber, + ); + } + self.draw_line_num(buffer, line_index, line_offset, width_offset - 3); + self.draw_col_separator_no_space(buffer, line_offset, width_offset - 2); + left + } + + #[instrument(level = "trace", skip(self), ret)] + fn render_source_line( + &self, + buffer: &mut StyledBuffer, + file: Arc, + line: &Line, + width_offset: usize, + code_offset: usize, + margin: Margin, + close_window: bool, + ) -> Vec<(usize, Style)> { + // Draw: + // + // LL | ... code ... + // | ^^-^ span label + // | | + // | secondary span label + // + // ^^ ^ ^^^ ^^^^ ^^^ we don't care about code too far to the right of a span, we trim it + // | | | | + // | | | actual code found in your source code and the spans we use to mark it + // | | when there's too much wasted space to the left, trim it + // | vertical divider between the column number and the code + // column number + + if line.line_index == 0 { + return Vec::new(); + } + + let Some(source_string) = file.get_line(line.line_index - 1) else { + return Vec::new(); + }; + trace!(?source_string); + + let line_offset = buffer.num_lines(); + + // Left trim. + // FIXME: This looks fishy. See #132860. + let left = self.draw_line( + buffer, + &source_string, + line.line_index, + line_offset, + width_offset, + code_offset, + margin, + ); + + // Special case when there's only one annotation involved, it is the start of a multiline + // span and there's no text at the beginning of the code line. Instead of doing the whole + // graph: + // + // 2 | fn foo() { + // | _^ + // 3 | | + // 4 | | } + // | |_^ test + // + // we simplify the output to: + // + // 2 | / fn foo() { + // 3 | | + // 4 | | } + // | |_^ test + let mut buffer_ops = vec![]; + let mut annotations = vec![]; + let mut short_start = true; + for ann in &line.annotations { + if let AnnotationType::MultilineStart(depth) = ann.annotation_type { + if source_string.chars().take(ann.start_col.file).all(|c| c.is_whitespace()) { + let uline = self.underline(ann.is_primary); + let chr = uline.multiline_whole_line; + annotations.push((depth, uline.style)); + buffer_ops.push((line_offset, width_offset + depth - 1, chr, uline.style)); + } else { + short_start = false; + break; + } + } else if let AnnotationType::MultilineLine(_) = ann.annotation_type { + } else { + short_start = false; + break; + } + } + if short_start { + for (y, x, c, s) in buffer_ops { + buffer.putc(y, x, c, s); + } + return annotations; + } + + // We want to display like this: + // + // vec.push(vec.pop().unwrap()); + // --- ^^^ - previous borrow ends here + // | | + // | error occurs here + // previous borrow of `vec` occurs here + // + // But there are some weird edge cases to be aware of: + // + // vec.push(vec.pop().unwrap()); + // -------- - previous borrow ends here + // || + // |this makes no sense + // previous borrow of `vec` occurs here + // + // For this reason, we group the lines into "highlight lines" + // and "annotations lines", where the highlight lines have the `^`. + + // Sort the annotations by (start, end col) + // The labels are reversed, sort and then reversed again. + // Consider a list of annotations (A1, A2, C1, C2, B1, B2) where + // the letter signifies the span. Here we are only sorting by the + // span and hence, the order of the elements with the same span will + // not change. On reversing the ordering (|a, b| but b.cmp(a)), you get + // (C1, C2, B1, B2, A1, A2). All the elements with the same span are + // still ordered first to last, but all the elements with different + // spans are ordered by their spans in last to first order. Last to + // first order is important, because the jiggly lines and | are on + // the left, so the rightmost span needs to be rendered first, + // otherwise the lines would end up needing to go over a message. + + let mut annotations = line.annotations.clone(); + annotations.sort_by_key(|a| Reverse(a.start_col)); + + // First, figure out where each label will be positioned. + // + // In the case where you have the following annotations: + // + // vec.push(vec.pop().unwrap()); + // -------- - previous borrow ends here [C] + // || + // |this makes no sense [B] + // previous borrow of `vec` occurs here [A] + // + // `annotations_position` will hold [(2, A), (1, B), (0, C)]. + // + // We try, when possible, to stick the rightmost annotation at the end + // of the highlight line: + // + // vec.push(vec.pop().unwrap()); + // --- --- - previous borrow ends here + // + // But sometimes that's not possible because one of the other + // annotations overlaps it. For example, from the test + // `span_overlap_label`, we have the following annotations + // (written on distinct lines for clarity): + // + // fn foo(x: u32) { + // -------------- + // - + // + // In this case, we can't stick the rightmost-most label on + // the highlight line, or we would get: + // + // fn foo(x: u32) { + // -------- x_span + // | + // fn_span + // + // which is totally weird. Instead we want: + // + // fn foo(x: u32) { + // -------------- + // | | + // | x_span + // fn_span + // + // which is...less weird, at least. In fact, in general, if + // the rightmost span overlaps with any other span, we should + // use the "hang below" version, so we can at least make it + // clear where the span *starts*. There's an exception for this + // logic, when the labels do not have a message: + // + // fn foo(x: u32) { + // -------------- + // | + // x_span + // + // instead of: + // + // fn foo(x: u32) { + // -------------- + // | | + // | x_span + // + // + let mut overlap = vec![false; annotations.len()]; + let mut annotations_position = vec![]; + let mut line_len: usize = 0; + let mut p = 0; + for (i, annotation) in annotations.iter().enumerate() { + for (j, next) in annotations.iter().enumerate() { + if overlaps(next, annotation, 0) && j > i { + overlap[i] = true; + overlap[j] = true; + } + if overlaps(next, annotation, 0) // This label overlaps with another one and both + && annotation.has_label() // take space (they have text and are not + && j > i // multiline lines). + && p == 0 + // We're currently on the first line, move the label one line down + { + // If we're overlapping with an un-labelled annotation with the same span + // we can just merge them in the output + if next.start_col == annotation.start_col + && next.end_col == annotation.end_col + && !next.has_label() + { + continue; + } + + // This annotation needs a new line in the output. + p += 1; + break; + } + } + annotations_position.push((p, annotation)); + for (j, next) in annotations.iter().enumerate() { + if j > i { + let l = next.label.as_ref().map_or(0, |label| label.len() + 2); + if (overlaps(next, annotation, l) // Do not allow two labels to be in the same + // line if they overlap including padding, to + // avoid situations like: + // + // fn foo(x: u32) { + // -------^------ + // | | + // fn_spanx_span + // + && annotation.has_label() // Both labels must have some text, otherwise + && next.has_label()) // they are not overlapping. + // Do not add a new line if this annotation + // or the next are vertical line placeholders. + || (annotation.takes_space() // If either this or the next annotation is + && next.has_label()) // multiline start/end, move it to a new line + || (annotation.has_label() // so as not to overlap the horizontal lines. + && next.takes_space()) + || (annotation.takes_space() && next.takes_space()) + || (overlaps(next, annotation, l) + && next.end_col <= annotation.end_col + && next.has_label() + && p == 0) + // Avoid #42595. + { + // This annotation needs a new line in the output. + p += 1; + break; + } + } + } + line_len = max(line_len, p); + } + + if line_len != 0 { + line_len += 1; + } + + // If there are no annotations or the only annotations on this line are + // MultilineLine, then there's only code being shown, stop processing. + if line.annotations.iter().all(|a| a.is_line()) { + return vec![]; + } + + if annotations_position + .iter() + .all(|(_, ann)| matches!(ann.annotation_type, AnnotationType::MultilineStart(_))) + && let Some(max_pos) = annotations_position.iter().map(|(pos, _)| *pos).max() + { + // Special case the following, so that we minimize overlapping multiline spans. + // + // 3 │ X0 Y0 Z0 + // │ â”â”â”â”â”â”â”› │ │ < We are writing these lines + // │ ┃┌───────┘ │ < by reverting the "depth" of + // │ ┃│┌─────────┘ < their multiline spans. + // 4 │ ┃││ X1 Y1 Z1 + // 5 │ ┃││ X2 Y2 Z2 + // │ ┃│└────╿──│──┘ `Z` label + // │ ┃└─────│──┤ + // │ â”—â”â”â”â”â”â”┥ `Y` is a good letter too + // â•°â•´ `X` is a good letter + for (pos, _) in &mut annotations_position { + *pos = max_pos - *pos; + } + // We know then that we don't need an additional line for the span label, saving us + // one line of vertical space. + line_len = line_len.saturating_sub(1); + } + + // Write the column separator. + // + // After this we will have: + // + // 2 | fn foo() { + // | + // | + // | + // 3 | + // 4 | } + // | + for pos in 0..=line_len { + self.draw_col_separator_no_space(buffer, line_offset + pos + 1, width_offset - 2); + } + if close_window { + self.draw_col_separator_end(buffer, line_offset + line_len + 1, width_offset - 2); + } + + // Write the horizontal lines for multiline annotations + // (only the first and last lines need this). + // + // After this we will have: + // + // 2 | fn foo() { + // | __________ + // | + // | + // 3 | + // 4 | } + // | _ + for &(pos, annotation) in &annotations_position { + let underline = self.underline(annotation.is_primary); + let pos = pos + 1; + match annotation.annotation_type { + AnnotationType::MultilineStart(depth) | AnnotationType::MultilineEnd(depth) => { + let pre: usize = source_string + .chars() + .take(annotation.start_col.file) + .skip(left) + .map(|c| char_width(c)) + .sum(); + self.draw_range( + buffer, + underline.multiline_horizontal, + line_offset + pos, + width_offset + depth, + code_offset + pre, + underline.style, + ); + } + _ => {} + } + } + + // Write the vertical lines for labels that are on a different line as the underline. + // + // After this we will have: + // + // 2 | fn foo() { + // | __________ + // | | | + // | | + // 3 | | + // 4 | | } + // | |_ + for &(pos, annotation) in &annotations_position { + let underline = self.underline(annotation.is_primary); + let pos = pos + 1; + + let code_offset = code_offset + + source_string + .chars() + .take(annotation.start_col.file) + .skip(left) + .map(|c| char_width(c)) + .sum::(); + if pos > 1 && (annotation.has_label() || annotation.takes_space()) { + for p in line_offset + 1..=line_offset + pos { + buffer.putc( + p, + code_offset, + match annotation.annotation_type { + AnnotationType::MultilineLine(_) => underline.multiline_vertical, + _ => underline.vertical_text_line, + }, + underline.style, + ); + } + if let AnnotationType::MultilineStart(_) = annotation.annotation_type { + buffer.putc( + line_offset + pos, + code_offset, + underline.bottom_right, + underline.style, + ); + } + if let AnnotationType::MultilineEnd(_) = annotation.annotation_type + && annotation.has_label() + { + buffer.putc( + line_offset + pos, + code_offset, + underline.multiline_bottom_right_with_text, + underline.style, + ); + } + } + match annotation.annotation_type { + AnnotationType::MultilineStart(depth) => { + buffer.putc( + line_offset + pos, + width_offset + depth - 1, + underline.top_left, + underline.style, + ); + for p in line_offset + pos + 1..line_offset + line_len + 2 { + buffer.putc( + p, + width_offset + depth - 1, + underline.multiline_vertical, + underline.style, + ); + } + } + AnnotationType::MultilineEnd(depth) => { + for p in line_offset..line_offset + pos { + buffer.putc( + p, + width_offset + depth - 1, + underline.multiline_vertical, + underline.style, + ); + } + buffer.putc( + line_offset + pos, + width_offset + depth - 1, + underline.bottom_left, + underline.style, + ); + } + _ => (), + } + } + + // Write the labels on the annotations that actually have a label. + // + // After this we will have: + // + // 2 | fn foo() { + // | __________ + // | | + // | something about `foo` + // 3 | + // 4 | } + // | _ test + for &(pos, annotation) in &annotations_position { + let style = + if annotation.is_primary { Style::LabelPrimary } else { Style::LabelSecondary }; + let (pos, col) = if pos == 0 { + let pre: usize = source_string + .chars() + .take(annotation.end_col.file) + .skip(left) + .map(|c| char_width(c)) + .sum(); + if annotation.end_col.file == 0 { + (pos + 1, (pre + 2)) + } else { + let pad = if annotation.end_col.file - annotation.start_col.file == 0 { + 2 + } else { + 1 + }; + (pos + 1, (pre + pad)) + } + } else { + let pre: usize = source_string + .chars() + .take(annotation.start_col.file) + .skip(left) + .map(|c| char_width(c)) + .sum(); + (pos + 2, pre) + }; + if let Some(ref label) = annotation.label { + buffer.puts(line_offset + pos, code_offset + col, label, style); + } + } + + // Sort from biggest span to smallest span so that smaller spans are + // represented in the output: + // + // x | fn foo() + // | ^^^---^^ + // | | | + // | | something about `foo` + // | something about `fn foo()` + annotations_position.sort_by_key(|(_, ann)| { + // Decreasing order. When annotations share the same length, prefer `Primary`. + (Reverse(ann.len()), ann.is_primary) + }); + + // Write the underlines. + // + // After this we will have: + // + // 2 | fn foo() { + // | ____-_____^ + // | | + // | something about `foo` + // 3 | + // 4 | } + // | _^ test + for &(pos, annotation) in &annotations_position { + let uline = self.underline(annotation.is_primary); + let width = annotation.end_col.file - annotation.start_col.file; + let previous: String = + source_string.chars().take(annotation.start_col.file).skip(left).collect(); + let underlined: String = + source_string.chars().skip(annotation.start_col.file).take(width).collect(); + debug!(?previous, ?underlined); + let code_offset = code_offset + + source_string + .chars() + .take(annotation.start_col.file) + .skip(left) + .map(|c| char_width(c)) + .sum::(); + let ann_width: usize = source_string + .chars() + .skip(annotation.start_col.file) + .take(width) + .map(|c| char_width(c)) + .sum(); + let ann_width = if ann_width == 0 + && matches!(annotation.annotation_type, AnnotationType::Singleline) + { + 1 + } else { + ann_width + }; + for p in 0..ann_width { + // The default span label underline. + buffer.putc(line_offset + 1, code_offset + p, uline.underline, uline.style); + } + + if pos == 0 + && matches!( + annotation.annotation_type, + AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_) + ) + { + // The beginning of a multiline span with its leftward moving line on the same line. + buffer.putc( + line_offset + 1, + code_offset, + match annotation.annotation_type { + AnnotationType::MultilineStart(_) => uline.top_right_flat, + AnnotationType::MultilineEnd(_) => uline.multiline_end_same_line, + _ => panic!("unexpected annotation type: {annotation:?}"), + }, + uline.style, + ); + } else if pos != 0 + && matches!( + annotation.annotation_type, + AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_) + ) + { + // The beginning of a multiline span with its leftward moving line on another line, + // so we start going down first. + buffer.putc( + line_offset + 1, + code_offset, + match annotation.annotation_type { + AnnotationType::MultilineStart(_) => uline.multiline_start_down, + AnnotationType::MultilineEnd(_) => uline.multiline_end_up, + _ => panic!("unexpected annotation type: {annotation:?}"), + }, + uline.style, + ); + } else if pos != 0 && annotation.has_label() { + // The beginning of a span label with an actual label, we'll point down. + buffer.putc(line_offset + 1, code_offset, uline.label_start, uline.style); + } + } + + // We look for individual *long* spans, and we trim the *middle*, so that we render + // LL | ...= [0, 0, 0, ..., 0, 0]; + // | ^^^^^^^^^^...^^^^^^^ expected `&[u8]`, found `[{integer}; 1680]` + for (i, (_pos, annotation)) in annotations_position.iter().enumerate() { + // Skip cases where multiple spans overlap each other. + if overlap[i] { + continue; + }; + let AnnotationType::Singleline = annotation.annotation_type else { continue }; + let width = annotation.end_col.display - annotation.start_col.display; + if width > margin.column_width * 2 && width > 10 { + // If the terminal is *too* small, we keep at least a tiny bit of the span for + // display. + let pad = max(margin.column_width / 3, 5); + // Code line + buffer.replace( + line_offset, + annotation.start_col.file + pad, + annotation.end_col.file - pad, + self.margin(), + ); + // Underline line + buffer.replace( + line_offset + 1, + annotation.start_col.file + pad, + annotation.end_col.file - pad, + self.margin(), + ); + } + } + annotations_position + .iter() + .filter_map(|&(_, annotation)| match annotation.annotation_type { + AnnotationType::MultilineStart(p) | AnnotationType::MultilineEnd(p) => { + let style = if annotation.is_primary { + Style::LabelPrimary + } else { + Style::LabelSecondary + }; + Some((p, style)) + } + _ => None, + }) + .collect::>() + } + + fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize { + let Some(ref sm) = self.sm else { + return 0; + }; + + let will_be_emitted = |span: Span| { + !span.is_dummy() && { + let file = sm.lookup_source_file(span.hi()); + should_show_source_code(&self.ignored_directories_in_source_blocks, sm, &file) + } + }; + + let mut max = 0; + for primary_span in msp.primary_spans() { + if will_be_emitted(*primary_span) { + let hi = sm.lookup_char_pos(primary_span.hi()); + max = (hi.line).max(max); + } + } + if !self.short_message { + for span_label in msp.span_labels() { + if will_be_emitted(span_label.span) { + let hi = sm.lookup_char_pos(span_label.span.hi()); + max = (hi.line).max(max); + } + } + } + + max + } + + fn get_max_line_num(&mut self, span: &MultiSpan, children: &[Subdiag]) -> usize { + let primary = self.get_multispan_max_line_num(span); + children + .iter() + .map(|sub| self.get_multispan_max_line_num(&sub.span)) + .max() + .unwrap_or(0) + .max(primary) + } + + /// Adds a left margin to every line but the first, given a padding length and the label being + /// displayed, keeping the provided highlighting. + fn msgs_to_buffer( + &self, + buffer: &mut StyledBuffer, + msgs: &[(DiagMessage, Style)], + args: &FluentArgs<'_>, + padding: usize, + label: &str, + override_style: Option
#[allow(dead_code)]
 #[rustfmt::skip]
-#[proc_macros::identity]
+#[proc_macros::identity]
 #[derive(Default)]
 /// This is a doc comment
 // This is a normal comment
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_crate_root.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_crate_root.html
index 0b32cedca5d8..a6e6b16bead5 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_crate_root.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_crate_root.html
@@ -41,25 +41,25 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
-
extern crate foo;
-use core::iter;
+
extern crate foo;
+use core::iter;
 
 pub const NINETY_TWO: u8 = 92;
 
-use foo as foooo;
+use foo as foooo;
 
-pub(crate) fn main() {
+pub(crate) fn main() {
     let baz = iter::repeat(92);
 }
 
 mod bar {
-    pub(in super) const FORTY_TWO: u8 = 42;
+    pub(in super) const FORTY_TWO: u8 = 42;
 
     mod baz {
-        use super::super::NINETY_TWO;
-        use crate::foooo::Point;
+        use super::super::NINETY_TWO;
+        use crate::foooo::Point;
 
-        pub(in super::super) const TWENTY_NINE: u8 = 29;
+        pub(in super::super) const TWENTY_NINE: u8 = 29;
     }
 }
 
\ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html index 29f78959a54f..2f4a2004f1de 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html @@ -41,7 +41,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; } .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
use core::iter;
+
use core::iter;
 
 fn main() {
     let foo = Some(92);
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html
index 5287affbfc5c..41d3dff8ed9e 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html
@@ -42,8 +42,8 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
 
#![deprecated]
-use crate as _;
-extern crate bar;
+use crate as _;
+extern crate bar;
 #[deprecated]
 macro_rules! macro_ {
     () => {};
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
index ce9ec7431a97..b5c3df6ee447 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
@@ -48,9 +48,9 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 //! Syntactic name ref highlighting testing
 //! ```rust
-//! extern crate self;
-//! extern crate other as otter;
-//! extern crate core;
+//! extern crate self;
+//! extern crate other as otter;
+//! extern crate core;
 //! trait T { type Assoc; }
 //! fn f<Arg>() -> use<Arg> where (): T<Assoc = ()> {}
 //! ```
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html
index 8f7cbddd7ffb..3a4518236883 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html
@@ -41,12 +41,12 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
-
extern crate self as this;
-extern crate std;
-extern crate alloc as abc;
-extern crate unresolved as definitely_unresolved;
+
extern crate self as this;
+extern crate std;
+extern crate alloc as abc;
+extern crate unresolved as definitely_unresolved;
 extern crate unresolved as _;
-extern crate test as opt_in_crate;
-extern crate test as _;
-extern crate proc_macro;
+extern crate test as opt_in_crate;
+extern crate test as _;
+extern crate proc_macro;
 
\ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html index c6dbc435c0e8..fd652f444ffd 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html @@ -72,7 +72,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } } -use self::FooCopy::{self as BarCopy}; +use self::FooCopy::{self as BarCopy}; #[derive(Copy)] struct FooCopy { @@ -110,7 +110,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd FOO } -use core::ops::Fn; +use core::ops::Fn; fn baz<F: Fn() -> ()>(f: F) { f() } @@ -184,15 +184,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } fn use_foo_items() { - let bob = foo::Person { + let bob = foo::Person { name: "Bob", - age: foo::consts::NUMBER, + age: foo::consts::NUMBER, }; - let control_flow = foo::identity(foo::ControlFlow::Continue); + let control_flow = foo::identity(foo::ControlFlow::Continue); if control_flow.should_die() { - foo::die!(); + foo::die!(); } } diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_injection_2.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_injection_2.html index 391a46f706c8..5a5d9bd1f909 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_injection_2.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_injection_2.html @@ -47,7 +47,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fixture(r#" @@- /main.rs crate:main deps:other_crate fn test() { - let x = other_crate::foo::S::thing(); + let x = other_crate::foo::S::thing(); x; } //^ i128 diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_issue_18089.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_issue_18089.html index fccf34083d7f..b28818e679ff 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_issue_18089.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_issue_18089.html @@ -45,5 +45,5 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd template!(template); } -#[proc_macros::issue_18089] +#[proc_macros::issue_18089] fn template() {}
\ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2015.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2015.html index 6366cba1bd03..d2a53b2ff9e1 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2015.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2015.html @@ -41,12 +41,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; } .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
extern crate self;
+
extern crate self;
 
-use crate;
-use self;
+use crate;
+use self;
 mod __ {
-    use super::*;
+    use super::*;
 }
 
 macro_rules! void {
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2018.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2018.html
index a89e8190832e..d309b4723238 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2018.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2018.html
@@ -41,12 +41,12 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
-
extern crate self;
+
extern crate self;
 
-use crate;
-use self;
+use crate;
+use self;
 mod __ {
-    use super::*;
+    use super::*;
 }
 
 macro_rules! void {
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2021.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2021.html
index a89e8190832e..d309b4723238 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2021.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2021.html
@@ -41,12 +41,12 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
-
extern crate self;
+
extern crate self;
 
-use crate;
-use self;
+use crate;
+use self;
 mod __ {
-    use super::*;
+    use super::*;
 }
 
 macro_rules! void {
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2024.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2024.html
index aa1500b8f85b..575c9a6b0aca 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2024.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_2024.html
@@ -41,12 +41,12 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
-
extern crate self;
+
extern crate self;
 
-use crate;
-use self;
+use crate;
+use self;
 mod __ {
-    use super::*;
+    use super::*;
 }
 
 macro_rules! void {
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_macros.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_macros.html
index 484afd81ead2..caf66ace7a68 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_macros.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_keywords_macros.html
@@ -41,6 +41,6 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
-
lib2015::void_2015!(try async await gen);
-lib2024::void_2024!(try async await gen);
+
lib2015::void_2015!(try async await gen);
+lib2024::void_2024!(try async await gen);
 
\ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html index 740a6272a79a..b63d5cedc825 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html @@ -41,8 +41,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; } .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
use proc_macros::{mirror, identity, DeriveIdentity};
-use pm::proc_macro;
+
use proc_macros::{mirror, identity, DeriveIdentity};
 
 mirror! {
     {
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_rainbow.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_rainbow.html
index 7c64707ac1f9..d5401e7aec91 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_rainbow.html
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_rainbow.html
@@ -42,14 +42,14 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .unresolved_reference    { color: #FC5555; text-decoration: wavy underline; }
 
 
fn main() {
-    let hello = "hello";
-    let x = hello.to_string();
-    let y = hello.to_string();
+    let hello = "hello";
+    let x = hello.to_string();
+    let y = hello.to_string();
 
-    let x = "other color please!";
-    let y = x.to_string();
+    let x = "other color please!";
+    let y = x.to_string();
 }
 
 fn bar() {
-    let mut hello = "hello";
+    let mut hello = "hello";
 }
\ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html index 4e3822c3d31f..e178782c79c4 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html @@ -165,7 +165,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd toho!("{}fmt", 0); let i: u64 = 3; let o: u64; - core::arch::asm!( + core::arch::asm!( "mov {0}, {1}", "add {0}, 5", out(reg) o, diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings_disabled.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings_disabled.html deleted file mode 100644 index 344d0c2ff03b..000000000000 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_strings_disabled.html +++ /dev/null @@ -1,47 +0,0 @@ - - -
fn main() {
-    format_args!("foo\nbar");
-    format_args!("foo\invalid");
-}
\ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html index 008987d409ad..93513f5b575d 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html @@ -91,7 +91,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd // unsafe fn and method calls unsafe_fn(); - self::unsafe_fn(); + self::unsafe_fn(); (unsafe_fn as unsafe fn())(); Struct { field: 0 }.unsafe_method(); @@ -120,7 +120,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd &EXTERN_STATIC; &raw const EXTERN_STATIC; - core::arch::asm!( + core::arch::asm!( "push {base}", base = const 0 ); diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs index c6aebd0b0cd1..89a5e434f90c 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs @@ -55,9 +55,8 @@ fn macros() { r#" //- proc_macros: mirror, identity, derive_identity //- minicore: fmt, include, concat -//- /lib.rs crate:lib deps:pm +//- /lib.rs crate:lib use proc_macros::{mirror, identity, DeriveIdentity}; -use pm::proc_macro; mirror! { { @@ -127,11 +126,6 @@ fn main() { //- /foo/foo.rs crate:foo mod foo {} use self::foo as bar; -//- /pm.rs crate:pm -#![crate_type = "proc-macro"] - -#[proc_macro_attribute] -pub fn proc_macro() {} "#, expect_file!["./test_data/highlight_macros.html"], false, @@ -1504,23 +1498,6 @@ fn main() { ); } -#[test] -fn test_strings_highlighting_disabled() { - // Test that comments are not highlighted when disabled - check_highlighting_with_config( - r#" -//- minicore: fmt -fn main() { - format_args!("foo\nbar"); - format_args!("foo\invalid"); -} -"#, - HighlightConfig { strings: false, ..HL_CONFIG }, - expect_file!["./test_data/highlight_strings_disabled.html"], - false, - ); -} - #[test] fn regression_20952() { check_highlighting( diff --git a/src/tools/rust-analyzer/crates/ide/src/typing.rs b/src/tools/rust-analyzer/crates/ide/src/typing.rs index f8b0dbfe6282..0381865fed45 100644 --- a/src/tools/rust-analyzer/crates/ide/src/typing.rs +++ b/src/tools/rust-analyzer/crates/ide/src/typing.rs @@ -17,10 +17,7 @@ mod on_enter; use either::Either; use hir::EditionedFileId; -use ide_db::{ - FilePosition, RootDatabase, - base_db::{RootQueryDb, SourceDatabase}, -}; +use ide_db::{FilePosition, RootDatabase, base_db::RootQueryDb}; use span::Edition; use std::iter; @@ -73,12 +70,11 @@ pub(crate) fn on_char_typed( if !TRIGGER_CHARS.contains(&char_typed) { return None; } - let edition = db - .source_root_crates(db.file_source_root(position.file_id).source_root_id(db)) - .first() - .map_or(Edition::CURRENT, |crates| crates.data(db).edition); + // FIXME: We need to figure out the edition of the file here, but that means hitting the + // database for more than just parsing the file which is bad. // FIXME: We are hitting the database here, if we are unlucky this call might block momentarily - // causing the editor to feel sluggish! We need to make this bail if it would block too long? + // causing the editor to feel sluggish! + let edition = Edition::CURRENT_FIXME; let editioned_file_id_wrapper = EditionedFileId::from_span_guess_origin( db, span::EditionedFileId::new(position.file_id, edition), @@ -461,8 +457,8 @@ mod tests { let (offset, mut before) = extract_offset(before); let edit = TextEdit::insert(offset, char_typed.to_string()); edit.apply(&mut before); - let parse = SourceFile::parse(&before, span::Edition::CURRENT); - on_char_typed_(&parse, offset, char_typed, span::Edition::CURRENT).map(|it| { + let parse = SourceFile::parse(&before, span::Edition::CURRENT_FIXME); + on_char_typed_(&parse, offset, char_typed, span::Edition::CURRENT_FIXME).map(|it| { it.apply(&mut before); before.to_string() }) diff --git a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs index cc09a1aae7a6..6181413a46db 100644 --- a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs +++ b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs @@ -109,8 +109,6 @@ define_symbols! { vectorcall_dash_unwind = "vectorcall-unwind", win64_dash_unwind = "win64-unwind", x86_dash_interrupt = "x86-interrupt", - rust_dash_preserve_dash_none = "preserve-none", - _0_u8 = "0_u8", @PLAIN: __ra_fixup, @@ -286,7 +284,6 @@ define_symbols! { Into, into_future, into_iter, - into_try_type, IntoFuture, IntoIter, IntoIterator, @@ -528,17 +525,10 @@ define_symbols! { arbitrary_self_types, arbitrary_self_types_pointers, supertrait_item_shadowing, - new_range, - range, - RangeCopy, - RangeFromCopy, - RangeInclusiveCopy, - RangeToInclusiveCopy, hash, partial_cmp, cmp, CoerceUnsized, DispatchFromDyn, define_opaque, - marker, } diff --git a/src/tools/rust-analyzer/crates/load-cargo/src/lib.rs b/src/tools/rust-analyzer/crates/load-cargo/src/lib.rs index 70a00cf82516..e8d98b1ce661 100644 --- a/src/tools/rust-analyzer/crates/load-cargo/src/lib.rs +++ b/src/tools/rust-analyzer/crates/load-cargo/src/lib.rs @@ -26,7 +26,10 @@ use ide_db::{ use itertools::Itertools; use proc_macro_api::{ MacroDylib, ProcMacroClient, - bidirectional_protocol::msg::{SubRequest, SubResponse}, + bidirectional_protocol::{ + msg::{SubRequest, SubResponse}, + reject_subrequests, + }, }; use project_model::{CargoConfig, PackageRoot, ProjectManifest, ProjectWorkspace}; use span::{Span, SpanAnchor, SyntaxContext}; @@ -42,7 +45,6 @@ pub struct LoadCargoConfig { pub load_out_dirs_from_check: bool, pub with_proc_macro_server: ProcMacroServerChoice, pub prefill_caches: bool, - pub proc_macro_processes: usize, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -111,25 +113,15 @@ pub fn load_workspace_into_db( let proc_macro_server = match &load_config.with_proc_macro_server { ProcMacroServerChoice::Sysroot => ws.find_sysroot_proc_macro_srv().map(|it| { it.and_then(|it| { - ProcMacroClient::spawn( - &it, - extra_env, - ws.toolchain.as_ref(), - load_config.proc_macro_processes, - ) - .map_err(Into::into) + ProcMacroClient::spawn(&it, extra_env, ws.toolchain.as_ref()).map_err(Into::into) }) .map_err(|e| ProcMacroLoadingError::ProcMacroSrvError(e.to_string().into_boxed_str())) }), - ProcMacroServerChoice::Explicit(path) => Some( - ProcMacroClient::spawn( - path, - extra_env, - ws.toolchain.as_ref(), - load_config.proc_macro_processes, - ) - .map_err(|e| ProcMacroLoadingError::ProcMacroSrvError(e.to_string().into_boxed_str())), - ), + ProcMacroServerChoice::Explicit(path) => { + Some(ProcMacroClient::spawn(path, extra_env, ws.toolchain.as_ref()).map_err(|e| { + ProcMacroLoadingError::ProcMacroSrvError(e.to_string().into_boxed_str()) + })) + } ProcMacroServerChoice::None => Some(Err(ProcMacroLoadingError::Disabled)), }; match &proc_macro_server { @@ -443,7 +435,7 @@ pub fn load_proc_macro( ) -> ProcMacroLoadResult { let res: Result, _> = (|| { let dylib = MacroDylib::new(path.to_path_buf()); - let vec = server.load_dylib(dylib).map_err(|e| { + let vec = server.load_dylib(dylib, Some(&mut reject_subrequests)).map_err(|e| { ProcMacroLoadingError::ProcMacroSrvError(format!("{e}").into_boxed_str()) })?; if vec.is_empty() { @@ -549,7 +541,7 @@ impl ProcMacroExpander for Expander { mixed_site: Span, current_dir: String, ) -> Result { - let cb = |req| match req { + let mut cb = |req| match req { SubRequest::LocalFilePath { file_id } => { let file_id = FileId::from_raw(file_id); let source_root_id = db.file_source_root(file_id).source_root_id(db); @@ -561,14 +553,15 @@ impl ProcMacroExpander for Expander { Ok(SubResponse::LocalFilePathResult { name }) } - // Not incremental: requires full file text. SubRequest::SourceText { file_id, ast_id, start, end } => { - let range = resolve_sub_span( - db, - file_id, - ast_id, - TextRange::new(TextSize::from(start), TextSize::from(end)), - ); + let ast_id = span::ErasedFileAstId::from_raw(ast_id); + let editioned_file_id = span::EditionedFileId::from_raw(file_id); + let span = Span { + range: TextRange::new(TextSize::from(start), TextSize::from(end)), + anchor: SpanAnchor { file_id: editioned_file_id, ast_id }, + ctx: SyntaxContext::root(editioned_file_id.edition()), + }; + let range = db.resolve_span(span); let source = db.file_text(range.file_id.file_id(db)).text(db); let text = source .get(usize::from(range.range.start())..usize::from(range.range.end())) @@ -576,19 +569,6 @@ impl ProcMacroExpander for Expander { Ok(SubResponse::SourceTextResult { text }) } - // Not incremental: requires building line index. - SubRequest::LineColumn { file_id, ast_id, offset } => { - let range = - resolve_sub_span(db, file_id, ast_id, TextRange::empty(TextSize::from(offset))); - let source = db.file_text(range.file_id.file_id(db)).text(db); - let line_index = ide_db::line_index::LineIndex::new(source); - let (line, column) = line_index - .try_line_col(range.range.start()) - .map(|lc| (lc.line + 1, lc.col + 1)) - .unwrap_or((1, 1)); - // proc_macro::Span line/column are 1-based - Ok(SubResponse::LineColumnResult { line, column }) - } SubRequest::FilePath { file_id } => { let file_id = FileId::from_raw(file_id); let source_root_id = db.file_source_root(file_id).source_root_id(db); @@ -601,17 +581,6 @@ impl ProcMacroExpander for Expander { Ok(SubResponse::FilePathResult { name }) } - // Not incremental: requires global span resolution. - SubRequest::ByteRange { file_id, ast_id, start, end } => { - let range = resolve_sub_span( - db, - file_id, - ast_id, - TextRange::new(TextSize::from(start), TextSize::from(end)), - ); - - Ok(SubResponse::ByteRangeResult { range: range.range.into() }) - } }; match self.0.expand( subtree.view(), @@ -621,7 +590,7 @@ impl ProcMacroExpander for Expander { call_site, mixed_site, current_dir, - Some(&cb), + Some(&mut cb), ) { Ok(Ok(subtree)) => Ok(subtree), Ok(Err(err)) => Err(ProcMacroExpansionError::Panic(err)), @@ -634,22 +603,6 @@ impl ProcMacroExpander for Expander { } } -fn resolve_sub_span( - db: &dyn ExpandDatabase, - file_id: u32, - ast_id: u32, - range: TextRange, -) -> hir_expand::FileRange { - let ast_id = span::ErasedFileAstId::from_raw(ast_id); - let editioned_file_id = span::EditionedFileId::from_raw(file_id); - let span = Span { - range, - anchor: SpanAnchor { file_id: editioned_file_id, ast_id }, - ctx: SyntaxContext::root(editioned_file_id.edition()), - }; - db.resolve_span(span) -} - #[cfg(test)] mod tests { use ide_db::base_db::RootQueryDb; @@ -665,7 +618,6 @@ mod tests { load_out_dirs_from_check: false, with_proc_macro_server: ProcMacroServerChoice::None, prefill_caches: false, - proc_macro_processes: 1, }; let (db, _vfs, _proc_macro) = load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {}).unwrap(); diff --git a/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs b/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs index fe01fb1f1063..8f6627a60fe6 100644 --- a/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs +++ b/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs @@ -414,9 +414,8 @@ fn match_loop_inner<'t>( } // Check if we need a separator. - if let Some(sep) = &item.sep - && !item.sep_matched - { + if item.sep.is_some() && !item.sep_matched { + let sep = item.sep.as_ref().unwrap(); let mut fork = src.clone(); if expect_separator(&mut fork, sep) { // HACK: here we use `meta_result` to pass `TtIter` back to caller because diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar.rs b/src/tools/rust-analyzer/crates/parser/src/grammar.rs index e481bbe9bc4a..bf8430294110 100644 --- a/src/tools/rust-analyzer/crates/parser/src/grammar.rs +++ b/src/tools/rust-analyzer/crates/parser/src/grammar.rs @@ -6,7 +6,7 @@ //! each submodule starts with `use super::*` import and exports //! "public" productions via `pub(super)`. //! -//! See docs for [`Parser`] to learn about API, +//! See docs for [`Parser`](super::parser::Parser) to learn about API, //! available to the grammar, and see docs for [`Event`](super::event::Event) //! to learn how this actually manages to produce parse trees. //! diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/attributes.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/attributes.rs index c0cf43a87bf7..ccb556b2ccac 100644 --- a/src/tools/rust-analyzer/crates/parser/src/grammar/attributes.rs +++ b/src/tools/rust-analyzer/crates/parser/src/grammar/attributes.rs @@ -24,11 +24,15 @@ fn attr(p: &mut Parser<'_>, inner: bool) { p.bump(T![!]); } - if p.expect(T!['[']) { + if p.eat(T!['[']) { meta(p); - p.expect(T![']']); - } + if !p.eat(T![']']) { + p.error("expected `]`"); + } + } else { + p.error("expected `[`"); + } attr.complete(p, ATTR); } @@ -70,7 +74,7 @@ pub(super) fn meta(p: &mut Parser<'_>) { paths::attr_path(p); match p.current() { - T![=] if !p.at(T![=>]) && !p.at(T![==]) => { + T![=] => { p.bump(T![=]); if expressions::expr(p).is_none() { p.error("expected expression"); diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs index b75474ee2b86..d83e2eb2b4ae 100644 --- a/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs +++ b/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs @@ -976,17 +976,11 @@ fn break_expr(p: &mut Parser<'_>, r: Restrictions) -> CompletedMarker { // test try_block_expr // fn foo() { // let _ = try {}; -// let _ = try bikeshed T {}; // } fn try_block_expr(p: &mut Parser<'_>, m: Option) -> CompletedMarker { assert!(p.at(T![try])); let m = m.unwrap_or_else(|| p.start()); - let try_modifier = p.start(); p.bump(T![try]); - if p.eat_contextual_kw(T![bikeshed]) { - type_(p); - } - try_modifier.complete(p, TRY_BLOCK_MODIFIER); if p.at(T!['{']) { stmt_list(p); } else { diff --git a/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs b/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs index a2295e449550..5d22d966b2b7 100644 --- a/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs +++ b/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs @@ -114,7 +114,6 @@ pub enum SyntaxKind { ATT_SYNTAX_KW, AUTO_KW, AWAIT_KW, - BIKESHED_KW, BUILTIN_KW, CLOBBER_ABI_KW, DEFAULT_KW, @@ -286,7 +285,6 @@ pub enum SyntaxKind { STRUCT, TOKEN_TREE, TRAIT, - TRY_BLOCK_MODIFIER, TRY_EXPR, TUPLE_EXPR, TUPLE_FIELD, @@ -460,7 +458,6 @@ impl SyntaxKind { | STRUCT | TOKEN_TREE | TRAIT - | TRY_BLOCK_MODIFIER | TRY_EXPR | TUPLE_EXPR | TUPLE_FIELD @@ -599,7 +596,6 @@ impl SyntaxKind { ASM_KW => "asm", ATT_SYNTAX_KW => "att_syntax", AUTO_KW => "auto", - BIKESHED_KW => "bikeshed", BUILTIN_KW => "builtin", CLOBBER_ABI_KW => "clobber_abi", DEFAULT_KW => "default", @@ -702,7 +698,6 @@ impl SyntaxKind { ASM_KW => true, ATT_SYNTAX_KW => true, AUTO_KW => true, - BIKESHED_KW => true, BUILTIN_KW => true, CLOBBER_ABI_KW => true, DEFAULT_KW => true, @@ -793,7 +788,6 @@ impl SyntaxKind { ASM_KW => true, ATT_SYNTAX_KW => true, AUTO_KW => true, - BIKESHED_KW => true, BUILTIN_KW => true, CLOBBER_ABI_KW => true, DEFAULT_KW => true, @@ -947,7 +941,6 @@ impl SyntaxKind { "asm" => ASM_KW, "att_syntax" => ATT_SYNTAX_KW, "auto" => AUTO_KW, - "bikeshed" => BIKESHED_KW, "builtin" => BUILTIN_KW, "clobber_abi" => CLOBBER_ABI_KW, "default" => DEFAULT_KW, @@ -1119,7 +1112,6 @@ macro_rules ! T_ { [asm] => { $ crate :: SyntaxKind :: ASM_KW }; [att_syntax] => { $ crate :: SyntaxKind :: ATT_SYNTAX_KW }; [auto] => { $ crate :: SyntaxKind :: AUTO_KW }; - [bikeshed] => { $ crate :: SyntaxKind :: BIKESHED_KW }; [builtin] => { $ crate :: SyntaxKind :: BUILTIN_KW }; [clobber_abi] => { $ crate :: SyntaxKind :: CLOBBER_ABI_KW }; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW }; diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0002_duplicate_shebang.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0002_duplicate_shebang.rast index 60cc690f7c98..7ee1ecfbb159 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0002_duplicate_shebang.rast +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0002_duplicate_shebang.rast @@ -28,7 +28,7 @@ SOURCE_FILE NAME_REF IDENT "rusti" WHITESPACE "\n" -error 23: expected L_BRACK +error 23: expected `[` error 23: expected an item error 27: expected one of `*`, `::`, `{`, `self`, `super` or an identifier error 28: expected SEMICOLON diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0005_attribute_recover.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0005_attribute_recover.rast index 77b4d06321d5..6ff072e207cd 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0005_attribute_recover.rast +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0005_attribute_recover.rast @@ -58,5 +58,5 @@ SOURCE_FILE R_CURLY "}" WHITESPACE "\n" error 53: expected R_PAREN -error 53: expected R_BRACK +error 53: expected `]` error 53: expected an item diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0032_match_arms_inner_attrs.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0032_match_arms_inner_attrs.rast index b657e9834156..327bf94a49e6 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0032_match_arms_inner_attrs.rast +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0032_match_arms_inner_attrs.rast @@ -192,14 +192,14 @@ SOURCE_FILE WHITESPACE "\n" R_CURLY "}" WHITESPACE "\n" -error 52: expected L_BRACK +error 52: expected `[` error 52: expected pattern error 53: expected FAT_ARROW error 78: expected `,` -error 161: expected L_BRACK +error 161: expected `[` error 161: expected pattern error 162: expected FAT_ARROW -error 232: expected L_BRACK +error 232: expected `[` error 232: expected pattern error 233: expected FAT_ARROW error 250: expected `,` diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0042_weird_blocks.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0042_weird_blocks.rast index 9e4e9dbf9d25..d6d2e75cca67 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0042_weird_blocks.rast +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0042_weird_blocks.rast @@ -45,8 +45,7 @@ SOURCE_FILE WHITESPACE " " EXPR_STMT BLOCK_EXPR - TRY_BLOCK_MODIFIER - TRY_KW "try" + TRY_KW "try" WHITESPACE " " LITERAL INT_NUMBER "92" diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rast index 472ce711c5fe..aec8fbf4775c 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rast +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rast @@ -21,42 +21,7 @@ SOURCE_FILE EQ "=" WHITESPACE " " BLOCK_EXPR - TRY_BLOCK_MODIFIER - TRY_KW "try" - WHITESPACE " " - STMT_LIST - L_CURLY "{" - R_CURLY "}" - SEMICOLON ";" - WHITESPACE "\n " - LET_STMT - LET_KW "let" - WHITESPACE " " - WILDCARD_PAT - UNDERSCORE "_" - WHITESPACE " " - EQ "=" - WHITESPACE " " - BLOCK_EXPR - TRY_BLOCK_MODIFIER - TRY_KW "try" - WHITESPACE " " - BIKESHED_KW "bikeshed" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - IDENT "T" - GENERIC_ARG_LIST - L_ANGLE "<" - TYPE_ARG - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - IDENT "U" - R_ANGLE ">" + TRY_KW "try" WHITESPACE " " STMT_LIST L_CURLY "{" diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rs b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rs index 719980473c3b..0f1b41eb64b4 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rs +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/try_block_expr.rs @@ -1,4 +1,3 @@ fn foo() { let _ = try {}; - let _ = try bikeshed T {}; } diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml b/src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml index a135a469e87e..4de1a3e5dd7d 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml +++ b/src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml @@ -31,7 +31,6 @@ span = { path = "../span", version = "0.0.0", default-features = false} intern.workspace = true postcard.workspace = true semver.workspace = true -rayon.workspace = true [features] sysroot-abi = ["proc-macro-srv", "proc-macro-srv/sysroot-abi"] diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol.rs index ba59cb219b9a..e44723a6a389 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol.rs @@ -2,7 +2,6 @@ use std::{ io::{self, BufRead, Write}, - panic::{AssertUnwindSafe, catch_unwind}, sync::Arc, }; @@ -10,7 +9,7 @@ use paths::AbsPath; use span::Span; use crate::{ - ProcMacro, ProcMacroKind, ServerError, + Codec, ProcMacro, ProcMacroKind, ServerError, bidirectional_protocol::msg::{ BidirectionalMessage, ExpandMacro, ExpandMacroData, ExpnGlobals, Request, Response, SubRequest, SubResponse, @@ -23,25 +22,26 @@ use crate::{ }, }, process::ProcMacroServerProcess, - transport::postcard, + transport::codec::postcard::PostcardProtocol, + version, }; pub mod msg; -pub type SubCallback<'a> = &'a dyn Fn(SubRequest) -> Result; +pub type SubCallback<'a> = &'a mut dyn FnMut(SubRequest) -> Result; -pub fn run_conversation( +pub fn run_conversation( writer: &mut dyn Write, reader: &mut dyn BufRead, - buf: &mut Vec, + buf: &mut C::Buf, msg: BidirectionalMessage, callback: SubCallback<'_>, ) -> Result { - let encoded = postcard::encode(&msg).map_err(wrap_encode)?; - postcard::write(writer, &encoded).map_err(wrap_io("failed to write initial request"))?; + let encoded = C::encode(&msg).map_err(wrap_encode)?; + C::write(writer, &encoded).map_err(wrap_io("failed to write initial request"))?; loop { - let maybe_buf = postcard::read(reader, buf).map_err(wrap_io("failed to read message"))?; + let maybe_buf = C::read(reader, buf).map_err(wrap_io("failed to read message"))?; let Some(b) = maybe_buf else { return Err(ServerError { message: "proc-macro server closed the stream".into(), @@ -49,28 +49,17 @@ pub fn run_conversation( }); }; - let msg: BidirectionalMessage = postcard::decode(b).map_err(wrap_decode)?; + let msg: BidirectionalMessage = C::decode(b).map_err(wrap_decode)?; match msg { BidirectionalMessage::Response(response) => { return Ok(BidirectionalMessage::Response(response)); } BidirectionalMessage::SubRequest(sr) => { - // TODO: Avoid `AssertUnwindSafe` by making the callback `UnwindSafe` once `ExpandDatabase` - // becomes unwind-safe (currently blocked by `parking_lot::RwLock` in the VFS). - let resp = match catch_unwind(AssertUnwindSafe(|| callback(sr))) { - Ok(Ok(resp)) => BidirectionalMessage::SubResponse(resp), - Ok(Err(err)) => BidirectionalMessage::SubResponse(SubResponse::Cancel { - reason: err.to_string(), - }), - Err(_) => BidirectionalMessage::SubResponse(SubResponse::Cancel { - reason: "callback panicked or was cancelled".into(), - }), - }; - - let encoded = postcard::encode(&resp).map_err(wrap_encode)?; - postcard::write(writer, &encoded) - .map_err(wrap_io("failed to write sub-response"))?; + let resp = callback(sr)?; + let reply = BidirectionalMessage::SubResponse(resp); + let encoded = C::encode(&reply).map_err(wrap_encode)?; + C::write(writer, &encoded).map_err(wrap_io("failed to write sub-response"))?; } _ => { return Err(ServerError { @@ -149,7 +138,6 @@ pub(crate) fn find_proc_macros( pub(crate) fn expand( proc_macro: &ProcMacro, - process: &ProcMacroServerProcess, subtree: tt::SubtreeView<'_>, attr: Option>, env: Vec<(String, String)>, @@ -159,7 +147,7 @@ pub(crate) fn expand( current_dir: String, callback: SubCallback<'_>, ) -> Result, crate::ServerError> { - let version = process.version(); + let version = proc_macro.process.version(); let mut span_data_table = SpanDataIndexMap::default(); let def_site = span_data_table.insert_full(def_site).0; let call_site = span_data_table.insert_full(call_site).0; @@ -170,8 +158,13 @@ pub(crate) fn expand( macro_name: proc_macro.name.to_string(), attributes: attr .map(|subtree| FlatTree::from_subtree(subtree, version, &mut span_data_table)), - has_global_spans: ExpnGlobals { def_site, call_site, mixed_site }, - span_data_table: if process.rust_analyzer_spans() { + has_global_spans: ExpnGlobals { + serialize: version >= version::HAS_GLOBAL_SPANS, + def_site, + call_site, + mixed_site, + }, + span_data_table: if proc_macro.process.rust_analyzer_spans() { serialize_span_data_index_map(&span_data_table) } else { Vec::new() @@ -182,7 +175,7 @@ pub(crate) fn expand( current_dir: Some(current_dir), }))); - let response_payload = run_request(process, task, callback)?; + let response_payload = run_request(&proc_macro.process, task, callback)?; match response_payload { BidirectionalMessage::Response(Response::ExpandMacro(it)) => Ok(it @@ -219,7 +212,14 @@ fn run_request( if let Some(err) = srv.exited() { return Err(err.clone()); } - srv.run_bidirectional(msg, callback) + + match srv.use_postcard() { + true => srv.run_bidirectional::(msg, callback), + false => Err(ServerError { + message: "bidirectional messaging does not support JSON".to_owned(), + io: None, + }), + } } pub fn reject_subrequests(req: SubRequest) -> Result { diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol/msg.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol/msg.rs index 3f0422dc5bc8..e41f8a5d7da7 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol/msg.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/bidirectional_protocol/msg.rs @@ -1,17 +1,11 @@ //! Bidirectional protocol messages -use std::{ - io::{self, BufRead, Write}, - ops::Range, -}; - use paths::Utf8PathBuf; use serde::{Deserialize, Serialize}; use crate::{ ProcMacroKind, legacy_protocol::msg::{FlatTree, Message, PanicMessage, ServerConfig}, - transport::postcard, }; #[derive(Debug, Serialize, Deserialize)] @@ -19,32 +13,13 @@ pub enum SubRequest { FilePath { file_id: u32 }, SourceText { file_id: u32, ast_id: u32, start: u32, end: u32 }, LocalFilePath { file_id: u32 }, - LineColumn { file_id: u32, ast_id: u32, offset: u32 }, - ByteRange { file_id: u32, ast_id: u32, start: u32, end: u32 }, } #[derive(Debug, Serialize, Deserialize)] pub enum SubResponse { - FilePathResult { - name: String, - }, - SourceTextResult { - text: Option, - }, - LocalFilePathResult { - name: Option, - }, - /// Line and column are 1-based. - LineColumnResult { - line: u32, - column: u32, - }, - ByteRangeResult { - range: Range, - }, - Cancel { - reason: String, - }, + FilePathResult { name: String }, + SourceTextResult { text: Option }, + LocalFilePathResult { name: Option }, } #[derive(Debug, Serialize, Deserialize)] @@ -77,6 +52,7 @@ pub struct ExpandMacro { pub lib: Utf8PathBuf, pub env: Vec<(String, String)>, pub current_dir: Option, + #[serde(flatten)] pub data: ExpandMacroData, } @@ -91,30 +67,29 @@ pub struct ExpandMacroData { pub macro_body: FlatTree, pub macro_name: String, pub attributes: Option, + #[serde(skip_serializing_if = "ExpnGlobals::skip_serializing_if")] #[serde(default)] pub has_global_spans: ExpnGlobals, + + #[serde(skip_serializing_if = "Vec::is_empty")] #[serde(default)] pub span_data_table: Vec, } #[derive(Clone, Copy, Default, Debug, Serialize, Deserialize)] pub struct ExpnGlobals { + #[serde(skip_serializing)] + #[serde(default)] + pub serialize: bool, pub def_site: usize, pub call_site: usize, pub mixed_site: usize, } -impl Message for BidirectionalMessage { - type Buf = Vec; - - fn read(inp: &mut dyn BufRead, buf: &mut Self::Buf) -> io::Result> { - Ok(match postcard::read(inp, buf)? { - None => None, - Some(buf) => Some(postcard::decode(buf)?), - }) - } - fn write(self, out: &mut dyn Write) -> io::Result<()> { - let value = postcard::encode(&self)?; - postcard::write(out, &value) +impl ExpnGlobals { + fn skip_serializing_if(&self) -> bool { + !self.serialize } } + +impl Message for BidirectionalMessage {} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol.rs index ee1795d39c2e..22a7d9868e21 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol.rs @@ -18,6 +18,8 @@ use crate::{ flat::serialize_span_data_index_map, }, process::ProcMacroServerProcess, + transport::codec::Codec, + transport::codec::{json::JsonProtocol, postcard::PostcardProtocol}, version, }; @@ -75,7 +77,6 @@ pub(crate) fn find_proc_macros( pub(crate) fn expand( proc_macro: &ProcMacro, - process: &ProcMacroServerProcess, subtree: tt::SubtreeView<'_>, attr: Option>, env: Vec<(String, String)>, @@ -84,7 +85,7 @@ pub(crate) fn expand( mixed_site: Span, current_dir: String, ) -> Result, crate::ServerError> { - let version = process.version(); + let version = proc_macro.process.version(); let mut span_data_table = SpanDataIndexMap::default(); let def_site = span_data_table.insert_full(def_site).0; let call_site = span_data_table.insert_full(call_site).0; @@ -101,7 +102,7 @@ pub(crate) fn expand( call_site, mixed_site, }, - span_data_table: if process.rust_analyzer_spans() { + span_data_table: if proc_macro.process.rust_analyzer_spans() { serialize_span_data_index_map(&span_data_table) } else { Vec::new() @@ -112,7 +113,7 @@ pub(crate) fn expand( current_dir: Some(current_dir), }; - let response = send_task(process, Request::ExpandMacro(Box::new(task)))?; + let response = send_task(&proc_macro.process, Request::ExpandMacro(Box::new(task)))?; match response { Response::ExpandMacro(it) => Ok(it @@ -147,21 +148,25 @@ fn send_task(srv: &ProcMacroServerProcess, req: Request) -> Result(send_request, req) + if srv.use_postcard() { + srv.send_task::<_, _, PostcardProtocol>(send_request::, req) + } else { + srv.send_task::<_, _, JsonProtocol>(send_request::, req) + } } /// Sends a request to the server and reads the response. -fn send_request( +fn send_request( mut writer: &mut dyn Write, mut reader: &mut dyn BufRead, req: Request, - buf: &mut String, + buf: &mut P::Buf, ) -> Result, ServerError> { - req.write(&mut writer).map_err(|err| ServerError { + req.write::<_, P>(&mut writer).map_err(|err| ServerError { message: "failed to write request".into(), io: Some(Arc::new(err)), })?; - let res = Response::read(&mut reader, buf).map_err(|err| ServerError { + let res = Response::read::<_, P>(&mut reader, buf).map_err(|err| ServerError { message: "failed to read response".into(), io: Some(Arc::new(err)), })?; diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg.rs index bb0dde472860..4146b619ec0c 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg.rs @@ -8,7 +8,7 @@ use paths::Utf8PathBuf; use serde::de::DeserializeOwned; use serde_derive::{Deserialize, Serialize}; -use crate::{ProcMacroKind, transport::json}; +use crate::{Codec, ProcMacroKind}; /// Represents requests sent from the client to the proc-macro-srv. #[derive(Debug, Serialize, Deserialize)] @@ -155,40 +155,20 @@ impl ExpnGlobals { } pub trait Message: serde::Serialize + DeserializeOwned { - type Buf; - fn read(inp: &mut dyn BufRead, buf: &mut Self::Buf) -> io::Result>; - fn write(self, out: &mut dyn Write) -> io::Result<()>; -} - -impl Message for Request { - type Buf = String; - - fn read(inp: &mut dyn BufRead, buf: &mut Self::Buf) -> io::Result> { - Ok(match json::read(inp, buf)? { + fn read(inp: &mut R, buf: &mut C::Buf) -> io::Result> { + Ok(match C::read(inp, buf)? { None => None, - Some(buf) => Some(json::decode(buf)?), + Some(buf) => Some(C::decode(buf)?), }) } - fn write(self, out: &mut dyn Write) -> io::Result<()> { - let value = json::encode(&self)?; - json::write(out, &value) + fn write(self, out: &mut W) -> io::Result<()> { + let value = C::encode(&self)?; + C::write(out, &value) } } -impl Message for Response { - type Buf = String; - - fn read(inp: &mut dyn BufRead, buf: &mut Self::Buf) -> io::Result> { - Ok(match json::read(inp, buf)? { - None => None, - Some(buf) => Some(json::decode(buf)?), - }) - } - fn write(self, out: &mut dyn Write) -> io::Result<()> { - let value = json::encode(&self)?; - json::write(out, &value) - } -} +impl Message for Request {} +impl Message for Response {} #[cfg(test)] mod tests { diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs index 68b3afc3e841..f5fcc99f14a3 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs @@ -18,8 +18,7 @@ extern crate rustc_driver as _; pub mod bidirectional_protocol; pub mod legacy_protocol; -pub mod pool; -pub mod process; +mod process; pub mod transport; use paths::{AbsPath, AbsPathBuf}; @@ -27,9 +26,8 @@ use semver::Version; use span::{ErasedFileAstId, FIXUP_ERASED_FILE_AST_ID_MARKER, Span}; use std::{fmt, io, sync::Arc, time::SystemTime}; -use crate::{ - bidirectional_protocol::SubCallback, pool::ProcMacroServerPool, process::ProcMacroServerProcess, -}; +pub use crate::transport::codec::Codec; +use crate::{bidirectional_protocol::SubCallback, process::ProcMacroServerProcess}; /// The versions of the server protocol pub mod version { @@ -46,26 +44,6 @@ pub mod version { pub const CURRENT_API_VERSION: u32 = HASHED_AST_ID; } -/// Protocol format for communication between client and server. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum ProtocolFormat { - /// JSON-based legacy protocol (newline-delimited JSON). - JsonLegacy, - /// Bidirectional postcard protocol with sub-request support. - BidirectionalPostcardPrototype, -} - -impl fmt::Display for ProtocolFormat { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - ProtocolFormat::JsonLegacy => write!(f, "json-legacy"), - ProtocolFormat::BidirectionalPostcardPrototype => { - write!(f, "bidirectional-postcard-prototype") - } - } - } -} - /// Represents different kinds of procedural macros that can be expanded by the external server. #[derive(Copy, Clone, Eq, PartialEq, Debug, serde_derive::Serialize, serde_derive::Deserialize)] pub enum ProcMacroKind { @@ -87,7 +65,7 @@ pub struct ProcMacroClient { /// /// That means that concurrent salsa requests may block each other when expanding proc macros, /// which is unfortunate, but simple and good enough for the time being. - pool: Arc, + process: Arc, path: AbsPathBuf, } @@ -109,7 +87,7 @@ impl MacroDylib { /// we share a single expander process for all macros within a workspace. #[derive(Debug, Clone)] pub struct ProcMacro { - pool: ProcMacroServerPool, + process: Arc, dylib_path: Arc, name: Box, kind: ProcMacroKind, @@ -123,6 +101,7 @@ impl PartialEq for ProcMacro { && self.kind == other.kind && self.dylib_path == other.dylib_path && self.dylib_last_modified == other.dylib_last_modified + && Arc::ptr_eq(&self.process, &other.process) } } @@ -152,44 +131,9 @@ impl ProcMacroClient { Item = (impl AsRef, &'a Option>), > + Clone, version: Option<&Version>, - num_process: usize, ) -> io::Result { - let pool_size = num_process; - let mut workers = Vec::with_capacity(pool_size); - for _ in 0..pool_size { - let worker = ProcMacroServerProcess::spawn(process_path, env.clone(), version)?; - workers.push(worker); - } - - let pool = ProcMacroServerPool::new(workers); - Ok(ProcMacroClient { pool: Arc::new(pool), path: process_path.to_owned() }) - } - - /// Invokes `spawn` and returns a client connected to the resulting read and write handles. - /// - /// The `process_path` is used for `Self::server_path`. This function is mainly used for testing. - pub fn with_io_channels( - process_path: &AbsPath, - spawn: impl Fn( - Option, - ) -> io::Result<( - Box, - Box, - Box, - )> + Clone, - version: Option<&Version>, - num_process: usize, - ) -> io::Result { - let pool_size = num_process; - let mut workers = Vec::with_capacity(pool_size); - for _ in 0..pool_size { - let worker = - ProcMacroServerProcess::run(spawn.clone(), version, || "".to_owned())?; - workers.push(worker); - } - - let pool = ProcMacroServerPool::new(workers); - Ok(ProcMacroClient { pool: Arc::new(pool), path: process_path.to_owned() }) + let process = ProcMacroServerProcess::run(process_path, env, version)?; + Ok(ProcMacroClient { process: Arc::new(process), path: process_path.to_owned() }) } /// Returns the absolute path to the proc-macro server. @@ -198,13 +142,36 @@ impl ProcMacroClient { } /// Loads a proc-macro dylib into the server process returning a list of `ProcMacro`s loaded. - pub fn load_dylib(&self, dylib: MacroDylib) -> Result, ServerError> { - self.pool.load_dylib(&dylib) + pub fn load_dylib( + &self, + dylib: MacroDylib, + callback: Option>, + ) -> Result, ServerError> { + let _p = tracing::info_span!("ProcMacroServer::load_dylib").entered(); + let macros = self.process.find_proc_macros(&dylib.path, callback)?; + + let dylib_path = Arc::new(dylib.path); + let dylib_last_modified = std::fs::metadata(dylib_path.as_path()) + .ok() + .and_then(|metadata| metadata.modified().ok()); + match macros { + Ok(macros) => Ok(macros + .into_iter() + .map(|(name, kind)| ProcMacro { + process: self.process.clone(), + name: name.into(), + kind, + dylib_path: dylib_path.clone(), + dylib_last_modified, + }) + .collect()), + Err(message) => Err(ServerError { message, io: None }), + } } /// Checks if the proc-macro server has exited. pub fn exited(&self) -> Option<&ServerError> { - self.pool.exited() + self.process.exited() } } @@ -220,7 +187,7 @@ impl ProcMacro { } fn needs_fixup_change(&self) -> bool { - let version = self.pool.version(); + let version = self.process.version(); (version::RUST_ANALYZER_SPAN_SUPPORT..version::HASHED_AST_ID).contains(&version) } @@ -264,7 +231,7 @@ impl ProcMacro { } } - self.pool.pick_process()?.expand( + self.process.expand( self, subtree, attr, diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/pool.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/pool.rs deleted file mode 100644 index e6541823da58..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/pool.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! A pool of proc-macro server processes -use std::sync::Arc; - -use rayon::iter::{IntoParallelIterator, ParallelIterator}; - -use crate::{MacroDylib, ProcMacro, ServerError, process::ProcMacroServerProcess}; - -#[derive(Debug, Clone)] -pub(crate) struct ProcMacroServerPool { - workers: Arc<[ProcMacroServerProcess]>, - version: u32, -} - -impl ProcMacroServerPool { - pub(crate) fn new(workers: Vec) -> Self { - let version = workers[0].version(); - Self { workers: workers.into(), version } - } -} - -impl ProcMacroServerPool { - pub(crate) fn exited(&self) -> Option<&ServerError> { - for worker in &*self.workers { - worker.exited()?; - } - self.workers[0].exited() - } - - pub(crate) fn pick_process(&self) -> Result<&ProcMacroServerProcess, ServerError> { - let mut best: Option<&ProcMacroServerProcess> = None; - let mut best_load = u32::MAX; - - for w in self.workers.iter().filter(|w| w.exited().is_none()) { - let load = w.number_of_active_req(); - - if load == 0 { - return Ok(w); - } - - if load < best_load { - best = Some(w); - best_load = load; - } - } - - best.ok_or_else(|| ServerError { - message: "all proc-macro server workers have exited".into(), - io: None, - }) - } - - pub(crate) fn load_dylib(&self, dylib: &MacroDylib) -> Result, ServerError> { - let _span = tracing::info_span!("ProcMacroServer::load_dylib").entered(); - - let dylib_path = Arc::new(dylib.path.clone()); - let dylib_last_modified = - std::fs::metadata(dylib_path.as_path()).ok().and_then(|m| m.modified().ok()); - - let (first, rest) = self.workers.split_first().expect("worker pool must not be empty"); - - let macros = first - .find_proc_macros(&dylib.path)? - .map_err(|e| ServerError { message: e, io: None })?; - - rest.into_par_iter() - .map(|worker| { - worker - .find_proc_macros(&dylib.path)? - .map(|_| ()) - .map_err(|e| ServerError { message: e, io: None }) - }) - .collect::>()?; - - Ok(macros - .into_iter() - .map(|(name, kind)| ProcMacro { - pool: self.clone(), - name: name.into(), - kind, - dylib_path: dylib_path.clone(), - dylib_last_modified, - }) - .collect()) - } - - pub(crate) fn version(&self) -> u32 { - self.version - } -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/process.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/process.rs index 80e4ed05c36d..f6a656e3ce3a 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/process.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/process.rs @@ -1,14 +1,10 @@ //! Handle process life-time and message passing for proc-macro client use std::{ - fmt::Debug, io::{self, BufRead, BufReader, Read, Write}, panic::AssertUnwindSafe, process::{Child, ChildStdin, ChildStdout, Command, Stdio}, - sync::{ - Arc, Mutex, OnceLock, - atomic::{AtomicU32, Ordering}, - }, + sync::{Arc, Mutex, OnceLock}, }; use paths::AbsPath; @@ -17,17 +13,14 @@ use span::Span; use stdx::JodChild; use crate::{ - ProcMacro, ProcMacroKind, ProtocolFormat, ServerError, - bidirectional_protocol::{ - self, SubCallback, - msg::{BidirectionalMessage, SubResponse}, - reject_subrequests, - }, + Codec, ProcMacro, ProcMacroKind, ServerError, + bidirectional_protocol::{self, SubCallback, msg::BidirectionalMessage, reject_subrequests}, legacy_protocol::{self, SpanMode}, version, }; /// Represents a process handling proc-macro communication. +#[derive(Debug)] pub(crate) struct ProcMacroServerProcess { /// The state of the proc-macro server process, the protocol is currently strictly sequential /// hence the lock on the state. @@ -36,102 +29,31 @@ pub(crate) struct ProcMacroServerProcess { protocol: Protocol, /// Populated when the server exits. exited: OnceLock>, - active: AtomicU32, -} - -impl std::fmt::Debug for ProcMacroServerProcess { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("ProcMacroServerProcess") - .field("version", &self.version) - .field("protocol", &self.protocol) - .field("exited", &self.exited) - .finish() - } } #[derive(Debug, Clone)] pub(crate) enum Protocol { LegacyJson { mode: SpanMode }, + LegacyPostcard { mode: SpanMode }, BidirectionalPostcardPrototype { mode: SpanMode }, } -pub trait ProcessExit: Send + Sync { - fn exit_err(&mut self) -> Option; -} - -impl ProcessExit for Process { - fn exit_err(&mut self) -> Option { - match self.child.try_wait() { - Ok(None) | Err(_) => None, - Ok(Some(status)) => { - let mut msg = String::new(); - if !status.success() - && let Some(stderr) = self.child.stderr.as_mut() - { - _ = stderr.read_to_string(&mut msg); - } - Some(ServerError { - message: format!( - "proc-macro server exited with {status}{}{msg}", - if msg.is_empty() { "" } else { ": " } - ), - io: None, - }) - } - } - } -} - /// Maintains the state of the proc-macro server process. -pub(crate) struct ProcessSrvState { - process: Box, - stdin: Box, - stdout: Box, +#[derive(Debug)] +struct ProcessSrvState { + process: Process, + stdin: ChildStdin, + stdout: BufReader, } impl ProcMacroServerProcess { /// Starts the proc-macro server and performs a version check - pub(crate) fn spawn<'a>( + pub(crate) fn run<'a>( process_path: &AbsPath, env: impl IntoIterator< Item = (impl AsRef, &'a Option>), > + Clone, version: Option<&Version>, - ) -> io::Result { - Self::run( - |format| { - let mut process = Process::run( - process_path, - env.clone(), - format.map(|format| format.to_string()).as_deref(), - )?; - let (stdin, stdout) = process.stdio().expect("couldn't access child stdio"); - - Ok((Box::new(process), Box::new(stdin), Box::new(stdout))) - }, - version, - || { - #[expect(clippy::disallowed_methods)] - Command::new(process_path) - .arg("--version") - .output() - .map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned()) - .unwrap_or_else(|_| "unknown version".to_owned()) - }, - ) - } - - /// Invokes `spawn` and performs a version check. - pub(crate) fn run( - spawn: impl Fn( - Option, - ) -> io::Result<( - Box, - Box, - Box, - )>, - version: Option<&Version>, - binary_server_version: impl Fn() -> String, ) -> io::Result { const VERSION: Version = Version::new(1, 93, 0); // we do `>` for nightly as this started working in the middle of the 1.93 nightly release, so we dont want to break on half of the nightlies @@ -143,38 +65,40 @@ impl ProcMacroServerProcess { && has_working_format_flag { &[ - Some(ProtocolFormat::BidirectionalPostcardPrototype), - Some(ProtocolFormat::JsonLegacy), + ( + Some("bidirectional-postcard-prototype"), + Protocol::BidirectionalPostcardPrototype { mode: SpanMode::Id }, + ), + (Some("postcard-legacy"), Protocol::LegacyPostcard { mode: SpanMode::Id }), + (Some("json-legacy"), Protocol::LegacyJson { mode: SpanMode::Id }), ] } else { - &[None] + &[(None, Protocol::LegacyJson { mode: SpanMode::Id })] }; let mut err = None; - for &format in formats { + for &(format, ref protocol) in formats { let create_srv = || { - let (process, stdin, stdout) = spawn(format)?; + let mut process = Process::run(process_path, env.clone(), format)?; + let (stdin, stdout) = process.stdio().expect("couldn't access child stdio"); io::Result::Ok(ProcMacroServerProcess { state: Mutex::new(ProcessSrvState { process, stdin, stdout }), version: 0, - protocol: match format { - Some(ProtocolFormat::BidirectionalPostcardPrototype) => { - Protocol::BidirectionalPostcardPrototype { mode: SpanMode::Id } - } - Some(ProtocolFormat::JsonLegacy) | None => { - Protocol::LegacyJson { mode: SpanMode::Id } - } - }, + protocol: protocol.clone(), exited: OnceLock::new(), - active: AtomicU32::new(0), }) }; let mut srv = create_srv()?; tracing::info!("sending proc-macro server version check"); - match srv.version_check(Some(&reject_subrequests)) { + match srv.version_check(Some(&mut reject_subrequests)) { Ok(v) if v > version::CURRENT_API_VERSION => { - let process_version = binary_server_version(); + #[allow(clippy::disallowed_methods)] + let process_version = Command::new(process_path) + .arg("--version") + .output() + .map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned()) + .unwrap_or_else(|_| "unknown version".to_owned()); err = Some(io::Error::other(format!( "Your installed proc-macro server is too new for your rust-analyzer. API version: {}, server version: {process_version}. \ This will prevent proc-macro expansion from working. Please consider updating your rust-analyzer to ensure compatibility with your current toolchain.", @@ -186,10 +110,11 @@ impl ProcMacroServerProcess { srv.version = v; if srv.version >= version::RUST_ANALYZER_SPAN_SUPPORT && let Ok(new_mode) = - srv.enable_rust_analyzer_spans(Some(&reject_subrequests)) + srv.enable_rust_analyzer_spans(Some(&mut reject_subrequests)) { match &mut srv.protocol { Protocol::LegacyJson { mode } + | Protocol::LegacyPostcard { mode } | Protocol::BidirectionalPostcardPrototype { mode } => *mode = new_mode, } } @@ -207,31 +132,15 @@ impl ProcMacroServerProcess { Err(err.unwrap()) } - /// Finds proc-macros in a given dynamic library. - pub(crate) fn find_proc_macros( - &self, - dylib_path: &AbsPath, - ) -> Result, String>, ServerError> { - match self.protocol { - Protocol::LegacyJson { .. } => legacy_protocol::find_proc_macros(self, dylib_path), - - Protocol::BidirectionalPostcardPrototype { .. } => { - bidirectional_protocol::find_proc_macros(self, dylib_path, &|_| { - Ok(SubResponse::Cancel { - reason: String::from( - "Server should not do a sub request when loading proc-macros", - ), - }) - }) - } - } - } - /// Returns the server error if the process has exited. pub(crate) fn exited(&self) -> Option<&ServerError> { self.exited.get().map(|it| &it.0) } + pub(crate) fn use_postcard(&self) -> bool { + matches!(self.protocol, Protocol::LegacyPostcard { .. }) + } + /// Retrieves the API version of the proc-macro server. pub(crate) fn version(&self) -> u32 { self.version @@ -241,6 +150,7 @@ impl ProcMacroServerProcess { pub(crate) fn rust_analyzer_spans(&self) -> bool { match self.protocol { Protocol::LegacyJson { mode } => mode == SpanMode::RustAnalyzer, + Protocol::LegacyPostcard { mode } => mode == SpanMode::RustAnalyzer, Protocol::BidirectionalPostcardPrototype { mode } => mode == SpanMode::RustAnalyzer, } } @@ -248,7 +158,9 @@ impl ProcMacroServerProcess { /// Checks the API version of the running proc-macro server. fn version_check(&self, callback: Option>) -> Result { match self.protocol { - Protocol::LegacyJson { .. } => legacy_protocol::version_check(self), + Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { + legacy_protocol::version_check(self) + } Protocol::BidirectionalPostcardPrototype { .. } => { let cb = callback.expect("callback required for bidirectional protocol"); bidirectional_protocol::version_check(self, cb) @@ -262,7 +174,9 @@ impl ProcMacroServerProcess { callback: Option>, ) -> Result { match self.protocol { - Protocol::LegacyJson { .. } => legacy_protocol::enable_rust_analyzer_spans(self), + Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { + legacy_protocol::enable_rust_analyzer_spans(self) + } Protocol::BidirectionalPostcardPrototype { .. } => { let cb = callback.expect("callback required for bidirectional protocol"); bidirectional_protocol::enable_rust_analyzer_spans(self, cb) @@ -270,6 +184,23 @@ impl ProcMacroServerProcess { } } + /// Finds proc-macros in a given dynamic library. + pub(crate) fn find_proc_macros( + &self, + dylib_path: &AbsPath, + callback: Option>, + ) -> Result, String>, ServerError> { + match self.protocol { + Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { + legacy_protocol::find_proc_macros(self, dylib_path) + } + Protocol::BidirectionalPostcardPrototype { .. } => { + let cb = callback.expect("callback required for bidirectional protocol"); + bidirectional_protocol::find_proc_macros(self, dylib_path, cb) + } + } + } + pub(crate) fn expand( &self, proc_macro: &ProcMacro, @@ -282,22 +213,21 @@ impl ProcMacroServerProcess { current_dir: String, callback: Option>, ) -> Result, ServerError> { - self.active.fetch_add(1, Ordering::AcqRel); - let result = match self.protocol { - Protocol::LegacyJson { .. } => legacy_protocol::expand( - proc_macro, - self, - subtree, - attr, - env, - def_site, - call_site, - mixed_site, - current_dir, - ), + match self.protocol { + Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { + legacy_protocol::expand( + proc_macro, + subtree, + attr, + env, + def_site, + call_site, + mixed_site, + current_dir, + ) + } Protocol::BidirectionalPostcardPrototype { .. } => bidirectional_protocol::expand( proc_macro, - self, subtree, attr, env, @@ -307,23 +237,20 @@ impl ProcMacroServerProcess { current_dir, callback.expect("callback required for bidirectional protocol"), ), - }; - - self.active.fetch_sub(1, Ordering::AcqRel); - result + } } - pub(crate) fn send_task_legacy( + pub(crate) fn send_task( &self, send: impl FnOnce( &mut dyn Write, &mut dyn BufRead, Request, - &mut String, + &mut C::Buf, ) -> Result, ServerError>, req: Request, ) -> Result { - self.with_locked_io(String::new(), |writer, reader, buf| { + self.with_locked_io::(|writer, reader, buf| { send(writer, reader, req, buf).and_then(|res| { res.ok_or_else(|| { let message = "proc-macro server did not respond with data".to_owned(); @@ -339,17 +266,31 @@ impl ProcMacroServerProcess { }) } - fn with_locked_io( + pub(crate) fn with_locked_io( &self, - mut buf: B, - f: impl FnOnce(&mut dyn Write, &mut dyn BufRead, &mut B) -> Result, + f: impl FnOnce(&mut dyn Write, &mut dyn BufRead, &mut C::Buf) -> Result, ) -> Result { let state = &mut *self.state.lock().unwrap(); + let mut buf = C::Buf::default(); + f(&mut state.stdin, &mut state.stdout, &mut buf).map_err(|e| { if e.io.as_ref().map(|it| it.kind()) == Some(io::ErrorKind::BrokenPipe) { - match state.process.exit_err() { - None => e, - Some(server_error) => { + match state.process.child.try_wait() { + Ok(None) | Err(_) => e, + Ok(Some(status)) => { + let mut msg = String::new(); + if !status.success() + && let Some(stderr) = state.process.child.stderr.as_mut() + { + _ = stderr.read_to_string(&mut msg); + } + let server_error = ServerError { + message: format!( + "proc-macro server exited with {status}{}{msg}", + if msg.is_empty() { "" } else { ": " } + ), + io: None, + }; self.exited.get_or_init(|| AssertUnwindSafe(server_error)).0.clone() } } @@ -359,19 +300,15 @@ impl ProcMacroServerProcess { }) } - pub(crate) fn run_bidirectional( + pub(crate) fn run_bidirectional( &self, initial: BidirectionalMessage, callback: SubCallback<'_>, ) -> Result { - self.with_locked_io(Vec::new(), |writer, reader, buf| { - bidirectional_protocol::run_conversation(writer, reader, buf, initial, callback) + self.with_locked_io::(|writer, reader, buf| { + bidirectional_protocol::run_conversation::(writer, reader, buf, initial, callback) }) } - - pub(crate) fn number_of_active_req(&self) -> u32 { - self.active.load(Ordering::Acquire) - } } /// Manages the execution of the proc-macro server process. diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport.rs index f383edb0cbbb..b7a1d8f7322c 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport.rs @@ -1,3 +1,3 @@ //! Contains construct for transport of messages. -pub(crate) mod json; -pub(crate) mod postcard; +pub mod codec; +pub mod framing; diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec.rs new file mode 100644 index 000000000000..c9afad260a56 --- /dev/null +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec.rs @@ -0,0 +1,15 @@ +//! Protocol codec + +use std::io; + +use serde::de::DeserializeOwned; + +use crate::transport::framing::Framing; + +pub mod json; +pub mod postcard; + +pub trait Codec: Framing { + fn encode(msg: &T) -> io::Result; + fn decode(buf: &mut Self::Buf) -> io::Result; +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec/json.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec/json.rs new file mode 100644 index 000000000000..96db802e0bfd --- /dev/null +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec/json.rs @@ -0,0 +1,58 @@ +//! Protocol functions for json. +use std::io::{self, BufRead, Write}; + +use serde::{Serialize, de::DeserializeOwned}; + +use crate::{Codec, transport::framing::Framing}; + +pub struct JsonProtocol; + +impl Framing for JsonProtocol { + type Buf = String; + + fn read<'a, R: BufRead + ?Sized>( + inp: &mut R, + buf: &'a mut String, + ) -> io::Result> { + loop { + buf.clear(); + + inp.read_line(buf)?; + buf.pop(); // Remove trailing '\n' + + if buf.is_empty() { + return Ok(None); + } + + // Some ill behaved macro try to use stdout for debugging + // We ignore it here + if !buf.starts_with('{') { + tracing::error!("proc-macro tried to print : {}", buf); + continue; + } + + return Ok(Some(buf)); + } + } + + fn write(out: &mut W, buf: &String) -> io::Result<()> { + tracing::debug!("> {}", buf); + out.write_all(buf.as_bytes())?; + out.write_all(b"\n")?; + out.flush() + } +} + +impl Codec for JsonProtocol { + fn encode(msg: &T) -> io::Result { + Ok(serde_json::to_string(msg)?) + } + + fn decode(buf: &mut String) -> io::Result { + let mut deserializer = serde_json::Deserializer::from_str(buf); + // Note that some proc-macro generate very deep syntax tree + // We have to disable the current limit of serde here + deserializer.disable_recursion_limit(); + Ok(T::deserialize(&mut deserializer)?) + } +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec/postcard.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec/postcard.rs new file mode 100644 index 000000000000..6f5319e75b37 --- /dev/null +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/codec/postcard.rs @@ -0,0 +1,40 @@ +//! Postcard encode and decode implementations. + +use std::io::{self, BufRead, Write}; + +use serde::{Serialize, de::DeserializeOwned}; + +use crate::{Codec, transport::framing::Framing}; + +pub struct PostcardProtocol; + +impl Framing for PostcardProtocol { + type Buf = Vec; + + fn read<'a, R: BufRead + ?Sized>( + inp: &mut R, + buf: &'a mut Vec, + ) -> io::Result>> { + buf.clear(); + let n = inp.read_until(0, buf)?; + if n == 0 { + return Ok(None); + } + Ok(Some(buf)) + } + + fn write(out: &mut W, buf: &Vec) -> io::Result<()> { + out.write_all(buf)?; + out.flush() + } +} + +impl Codec for PostcardProtocol { + fn encode(msg: &T) -> io::Result> { + postcard::to_allocvec_cobs(msg).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) + } + + fn decode(buf: &mut Self::Buf) -> io::Result { + postcard::from_bytes_cobs(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) + } +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/framing.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/framing.rs new file mode 100644 index 000000000000..56c3b68e8cd2 --- /dev/null +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/framing.rs @@ -0,0 +1,14 @@ +//! Protocol framing + +use std::io::{self, BufRead, Write}; + +pub trait Framing { + type Buf: Default + Send + Sync; + + fn read<'a, R: BufRead + ?Sized>( + inp: &mut R, + buf: &'a mut Self::Buf, + ) -> io::Result>; + + fn write(out: &mut W, buf: &Self::Buf) -> io::Result<()>; +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/json.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/json.rs deleted file mode 100644 index f433bb7de033..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/json.rs +++ /dev/null @@ -1,48 +0,0 @@ -//! Protocol functions for json. -use std::io::{self, BufRead, Write}; - -use serde::{Serialize, de::DeserializeOwned}; - -pub(crate) fn read<'a, R: BufRead + ?Sized>( - inp: &mut R, - buf: &'a mut String, -) -> io::Result> { - loop { - buf.clear(); - - inp.read_line(buf)?; - buf.pop(); // Remove trailing '\n' - - if buf.is_empty() { - return Ok(None); - } - - // Some ill behaved macro try to use stdout for debugging - // We ignore it here - if !buf.starts_with('{') { - tracing::error!("proc-macro tried to print : {}", buf); - continue; - } - - return Ok(Some(buf)); - } -} - -pub(crate) fn write(out: &mut W, buf: &String) -> io::Result<()> { - tracing::debug!("> {}", buf); - out.write_all(buf.as_bytes())?; - out.write_all(b"\n")?; - out.flush() -} - -pub(crate) fn encode(msg: &T) -> io::Result { - Ok(serde_json::to_string(msg)?) -} - -pub(crate) fn decode(buf: &mut str) -> io::Result { - let mut deserializer = serde_json::Deserializer::from_str(buf); - // Note that some proc-macro generate very deep syntax tree - // We have to disable the current limit of serde here - deserializer.disable_recursion_limit(); - Ok(T::deserialize(&mut deserializer)?) -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/postcard.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/postcard.rs deleted file mode 100644 index 75aa90e4c480..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/transport/postcard.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! Postcard encode and decode implementations. - -use std::io::{self, BufRead, Write}; - -use serde::{Serialize, de::DeserializeOwned}; - -pub(crate) fn read<'a, R: BufRead + ?Sized>( - inp: &mut R, - buf: &'a mut Vec, -) -> io::Result>> { - buf.clear(); - let n = inp.read_until(0, buf)?; - if n == 0 { - return Ok(None); - } - Ok(Some(buf)) -} - -pub(crate) fn write(out: &mut W, buf: &[u8]) -> io::Result<()> { - out.write_all(buf)?; - out.flush() -} - -pub(crate) fn encode(msg: &T) -> io::Result> { - postcard::to_allocvec_cobs(msg).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) -} - -pub(crate) fn decode(buf: &mut [u8]) -> io::Result { - postcard::from_bytes_cobs(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/Cargo.toml b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/Cargo.toml index f586fe7644d7..6b2db0b269d5 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/Cargo.toml +++ b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/Cargo.toml @@ -10,25 +10,12 @@ license.workspace = true rust-version.workspace = true publish = false -[lib] -doctest = false - [dependencies] proc-macro-srv.workspace = true proc-macro-api.workspace = true +postcard.workspace = true clap = {version = "4.5.42", default-features = false, features = ["std"]} -[dev-dependencies] -expect-test.workspace = true -paths.workspace = true -# span = {workspace = true, default-features = false} does not work -span = { path = "../span", default-features = false} -tt.workspace = true -intern.workspace = true - -# used as proc macro test target -proc-macro-test.path = "../proc-macro-srv/proc-macro-test" - [features] default = [] # default = ["sysroot-abi"] diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/lib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/lib.rs deleted file mode 100644 index 8475c05ae8a1..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Library interface for `proc-macro-srv-cli`. -//! -//! This module exposes the server main loop and protocol format for integration testing. - -#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] - -#[cfg(feature = "in-rust-tree")] -extern crate rustc_driver as _; - -#[cfg(feature = "sysroot-abi")] -pub mod main_loop; diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs index 928753659f1c..bdfdb50002e1 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs @@ -9,11 +9,11 @@ extern crate rustc_driver as _; mod version; -use clap::{Command, ValueEnum}; -use proc_macro_api::ProtocolFormat; - #[cfg(feature = "sysroot-abi")] -use proc_macro_srv_cli::main_loop::run; +mod main_loop; +use clap::{Command, ValueEnum}; +#[cfg(feature = "sysroot-abi")] +use main_loop::run; fn main() -> std::io::Result<()> { let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE"); @@ -32,7 +32,7 @@ fn main() -> std::io::Result<()> { .long("format") .action(clap::ArgAction::Set) .default_value("json-legacy") - .value_parser(clap::builder::EnumValueParser::::new()), + .value_parser(clap::builder::EnumValueParser::::new()), clap::Arg::new("version") .long("version") .action(clap::ArgAction::SetTrue) @@ -43,48 +43,44 @@ fn main() -> std::io::Result<()> { println!("rust-analyzer-proc-macro-srv {}", version::version()); return Ok(()); } - let &format = matches - .get_one::("format") - .expect("format value should always be present"); - - let mut stdin = std::io::BufReader::new(std::io::stdin()); - let mut stdout = std::io::stdout(); - - run(&mut stdin, &mut stdout, format.into()) + let &format = + matches.get_one::("format").expect("format value should always be present"); + run(format) } -/// Wrapper for CLI argument parsing that implements `ValueEnum`. #[derive(Copy, Clone)] -struct ProtocolFormatArg(ProtocolFormat); - -impl From for ProtocolFormat { - fn from(arg: ProtocolFormatArg) -> Self { - arg.0 - } +enum ProtocolFormat { + JsonLegacy, + PostcardLegacy, + BidirectionalPostcardPrototype, } -impl ValueEnum for ProtocolFormatArg { +impl ValueEnum for ProtocolFormat { fn value_variants<'a>() -> &'a [Self] { &[ - ProtocolFormatArg(ProtocolFormat::JsonLegacy), - ProtocolFormatArg(ProtocolFormat::BidirectionalPostcardPrototype), + ProtocolFormat::JsonLegacy, + ProtocolFormat::PostcardLegacy, + ProtocolFormat::BidirectionalPostcardPrototype, ] } fn to_possible_value(&self) -> Option { - match self.0 { + match self { ProtocolFormat::JsonLegacy => Some(clap::builder::PossibleValue::new("json-legacy")), + ProtocolFormat::PostcardLegacy => { + Some(clap::builder::PossibleValue::new("postcard-legacy")) + } ProtocolFormat::BidirectionalPostcardPrototype => { Some(clap::builder::PossibleValue::new("bidirectional-postcard-prototype")) } } } - fn from_str(input: &str, _ignore_case: bool) -> Result { match input { - "json-legacy" => Ok(ProtocolFormatArg(ProtocolFormat::JsonLegacy)), + "json-legacy" => Ok(ProtocolFormat::JsonLegacy), + "postcard-legacy" => Ok(ProtocolFormat::PostcardLegacy), "bidirectional-postcard-prototype" => { - Ok(ProtocolFormatArg(ProtocolFormat::BidirectionalPostcardPrototype)) + Ok(ProtocolFormat::BidirectionalPostcardPrototype) } _ => Err(format!("unknown protocol format: {input}")), } @@ -92,11 +88,7 @@ impl ValueEnum for ProtocolFormatArg { } #[cfg(not(feature = "sysroot-abi"))] -fn run( - _: &mut std::io::BufReader, - _: &mut std::io::Stdout, - _: ProtocolFormat, -) -> std::io::Result<()> { +fn run(_: ProtocolFormat) -> std::io::Result<()> { Err(std::io::Error::new( std::io::ErrorKind::Unsupported, "proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function" diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main_loop.rs b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main_loop.rs index 9be3199a3836..b2f4b96bd255 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main_loop.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main_loop.rs @@ -1,18 +1,18 @@ //! The main loop of the proc-macro server. use proc_macro_api::{ - ProtocolFormat, bidirectional_protocol::msg as bidirectional, legacy_protocol::msg as legacy, + Codec, + bidirectional_protocol::msg as bidirectional, + legacy_protocol::msg as legacy, + transport::codec::{json::JsonProtocol, postcard::PostcardProtocol}, version::CURRENT_API_VERSION, }; -use std::panic::{panic_any, resume_unwind}; -use std::{ - io::{self, BufRead, Write}, - ops::Range, -}; +use std::io; use legacy::Message; -use proc_macro_srv::{EnvSnapshot, ProcMacroClientError, ProcMacroPanicMarker, SpanId}; +use proc_macro_srv::{EnvSnapshot, SpanId}; +use crate::ProtocolFormat; struct SpanTrans; impl legacy::SpanTransformer for SpanTrans { @@ -32,21 +32,15 @@ impl legacy::SpanTransformer for SpanTrans { } } -pub fn run( - stdin: &mut (dyn BufRead + Send + Sync), - stdout: &mut (dyn Write + Send + Sync), - format: ProtocolFormat, -) -> io::Result<()> { +pub(crate) fn run(format: ProtocolFormat) -> io::Result<()> { match format { - ProtocolFormat::JsonLegacy => run_old(stdin, stdout), - ProtocolFormat::BidirectionalPostcardPrototype => run_new(stdin, stdout), + ProtocolFormat::JsonLegacy => run_::(), + ProtocolFormat::PostcardLegacy => run_::(), + ProtocolFormat::BidirectionalPostcardPrototype => run_new::(), } } -fn run_new( - stdin: &mut (dyn BufRead + Send + Sync), - stdout: &mut (dyn Write + Send + Sync), -) -> io::Result<()> { +fn run_new() -> io::Result<()> { fn macro_kind_to_api(kind: proc_macro_srv::ProcMacroKind) -> proc_macro_api::ProcMacroKind { match kind { proc_macro_srv::ProcMacroKind::CustomDerive => { @@ -57,7 +51,9 @@ fn run_new( } } - let mut buf = Vec::default(); + let mut buf = C::Buf::default(); + let mut stdin = io::stdin(); + let mut stdout = io::stdout(); let env_snapshot = EnvSnapshot::default(); let srv = proc_macro_srv::ProcMacroSrv::new(&env_snapshot); @@ -65,7 +61,8 @@ fn run_new( let mut span_mode = legacy::SpanMode::Id; 'outer: loop { - let req_opt = bidirectional::BidirectionalMessage::read(stdin, &mut buf)?; + let req_opt = + bidirectional::BidirectionalMessage::read::<_, C>(&mut stdin.lock(), &mut buf)?; let Some(req) = req_opt else { break 'outer; }; @@ -80,22 +77,22 @@ fn run_new( .collect() }); - send_response(stdout, bidirectional::Response::ListMacros(res))?; + send_response::(&stdout, bidirectional::Response::ListMacros(res))?; } bidirectional::Request::ApiVersionCheck {} => { - send_response( - stdout, + send_response::( + &stdout, bidirectional::Response::ApiVersionCheck(CURRENT_API_VERSION), )?; } bidirectional::Request::SetConfig(config) => { span_mode = config.span_mode; - send_response(stdout, bidirectional::Response::SetConfig(config))?; + send_response::(&stdout, bidirectional::Response::SetConfig(config))?; } bidirectional::Request::ExpandMacro(task) => { - handle_expand(&srv, stdin, stdout, &mut buf, span_mode, *task)?; + handle_expand::(&srv, &mut stdin, &mut stdout, &mut buf, span_mode, *task)?; } }, _ => continue, @@ -105,23 +102,23 @@ fn run_new( Ok(()) } -fn handle_expand( +fn handle_expand( srv: &proc_macro_srv::ProcMacroSrv<'_>, - stdin: &mut (dyn BufRead + Send + Sync), - stdout: &mut (dyn Write + Send + Sync), - buf: &mut Vec, + stdin: &io::Stdin, + stdout: &io::Stdout, + buf: &mut C::Buf, span_mode: legacy::SpanMode, task: bidirectional::ExpandMacro, ) -> io::Result<()> { match span_mode { - legacy::SpanMode::Id => handle_expand_id(srv, stdout, task), - legacy::SpanMode::RustAnalyzer => handle_expand_ra(srv, stdin, stdout, buf, task), + legacy::SpanMode::Id => handle_expand_id::(srv, stdout, task), + legacy::SpanMode::RustAnalyzer => handle_expand_ra::(srv, stdin, stdout, buf, task), } } -fn handle_expand_id( +fn handle_expand_id( srv: &proc_macro_srv::ProcMacroSrv<'_>, - stdout: &mut dyn Write, + stdout: &io::Stdout, task: bidirectional::ExpandMacro, ) -> io::Result<()> { let bidirectional::ExpandMacro { lib, env, current_dir, data } = task; @@ -160,65 +157,40 @@ fn handle_expand_id( }) .map_err(|e| legacy::PanicMessage(e.into_string().unwrap_or_default())); - send_response(stdout, bidirectional::Response::ExpandMacro(res)) + send_response::(&stdout, bidirectional::Response::ExpandMacro(res)) } -struct ProcMacroClientHandle<'a> { - stdin: &'a mut (dyn BufRead + Send + Sync), - stdout: &'a mut (dyn Write + Send + Sync), - buf: &'a mut Vec, +struct ProcMacroClientHandle<'a, C: Codec> { + stdin: &'a io::Stdin, + stdout: &'a io::Stdout, + buf: &'a mut C::Buf, } -impl<'a> ProcMacroClientHandle<'a> { +impl<'a, C: Codec> ProcMacroClientHandle<'a, C> { fn roundtrip( &mut self, req: bidirectional::SubRequest, - ) -> Result { + ) -> Option { let msg = bidirectional::BidirectionalMessage::SubRequest(req); - msg.write(&mut *self.stdout).map_err(ProcMacroClientError::Io)?; + if msg.write::<_, C>(&mut self.stdout.lock()).is_err() { + return None; + } - let msg = bidirectional::BidirectionalMessage::read(&mut *self.stdin, self.buf) - .map_err(ProcMacroClientError::Io)? - .ok_or(ProcMacroClientError::Eof)?; - - match msg { - bidirectional::BidirectionalMessage::SubResponse(resp) => match resp { - bidirectional::SubResponse::Cancel { reason } => { - Err(ProcMacroClientError::Cancelled { reason }) - } - other => Ok(other), - }, - other => { - Err(ProcMacroClientError::Protocol(format!("expected SubResponse, got {other:?}"))) - } + match bidirectional::BidirectionalMessage::read::<_, C>(&mut self.stdin.lock(), self.buf) { + Ok(Some(msg)) => Some(msg), + _ => None, } } } -fn handle_failure(failure: Result) -> ! { - match failure { - Err(ProcMacroClientError::Cancelled { reason }) => { - resume_unwind(Box::new(ProcMacroPanicMarker::Cancelled { reason })); - } - Err(err) => { - panic_any(ProcMacroPanicMarker::Internal { - reason: format!("proc-macro IPC error: {err:?}"), - }); - } - Ok(other) => { - panic_any(ProcMacroPanicMarker::Internal { - reason: format!("unexpected SubResponse {other:?}"), - }); - } - } -} - -impl proc_macro_srv::ProcMacroClientInterface for ProcMacroClientHandle<'_> { +impl proc_macro_srv::ProcMacroClientInterface for ProcMacroClientHandle<'_, C> { fn file(&mut self, file_id: proc_macro_srv::span::FileId) -> String { match self.roundtrip(bidirectional::SubRequest::FilePath { file_id: file_id.index() }) { - Ok(bidirectional::SubResponse::FilePathResult { name }) => name, - other => handle_failure(other), + Some(bidirectional::BidirectionalMessage::SubResponse( + bidirectional::SubResponse::FilePathResult { name }, + )) => name, + _ => String::new(), } } @@ -232,54 +204,29 @@ impl proc_macro_srv::ProcMacroClientInterface for ProcMacroClientHandle<'_> { start: range.start().into(), end: range.end().into(), }) { - Ok(bidirectional::SubResponse::SourceTextResult { text }) => text, - other => handle_failure(other), + Some(bidirectional::BidirectionalMessage::SubResponse( + bidirectional::SubResponse::SourceTextResult { text }, + )) => text, + _ => None, } } fn local_file(&mut self, file_id: proc_macro_srv::span::FileId) -> Option { match self.roundtrip(bidirectional::SubRequest::LocalFilePath { file_id: file_id.index() }) { - Ok(bidirectional::SubResponse::LocalFilePathResult { name }) => name, - other => handle_failure(other), - } - } - - fn line_column(&mut self, span: proc_macro_srv::span::Span) -> Option<(u32, u32)> { - let proc_macro_srv::span::Span { range, anchor, ctx: _ } = span; - match self.roundtrip(bidirectional::SubRequest::LineColumn { - file_id: anchor.file_id.as_u32(), - ast_id: anchor.ast_id.into_raw(), - offset: range.start().into(), - }) { - Ok(bidirectional::SubResponse::LineColumnResult { line, column }) => { - Some((line, column)) - } - other => handle_failure(other), - } - } - - fn byte_range( - &mut self, - proc_macro_srv::span::Span { range, anchor, ctx: _ }: proc_macro_srv::span::Span, - ) -> Range { - match self.roundtrip(bidirectional::SubRequest::ByteRange { - file_id: anchor.file_id.as_u32(), - ast_id: anchor.ast_id.into_raw(), - start: range.start().into(), - end: range.end().into(), - }) { - Ok(bidirectional::SubResponse::ByteRangeResult { range }) => range, - other => handle_failure(other), + Some(bidirectional::BidirectionalMessage::SubResponse( + bidirectional::SubResponse::LocalFilePathResult { name }, + )) => name, + _ => None, } } } -fn handle_expand_ra( +fn handle_expand_ra( srv: &proc_macro_srv::ProcMacroSrv<'_>, - stdin: &mut (dyn BufRead + Send + Sync), - stdout: &mut (dyn Write + Send + Sync), - buf: &mut Vec, + stdin: &io::Stdin, + stdout: &io::Stdout, + buf: &mut C::Buf, task: bidirectional::ExpandMacro, ) -> io::Result<()> { let bidirectional::ExpandMacro { @@ -324,7 +271,7 @@ fn handle_expand_ra( def_site, call_site, mixed_site, - Some(&mut ProcMacroClientHandle { stdin, stdout, buf }), + Some(&mut ProcMacroClientHandle:: { stdin, stdout, buf }), ) .map(|it| { ( @@ -340,13 +287,10 @@ fn handle_expand_ra( .map(|(tree, span_data_table)| bidirectional::ExpandMacroExtended { tree, span_data_table }) .map_err(|e| legacy::PanicMessage(e.into_string().unwrap_or_default())); - send_response(stdout, bidirectional::Response::ExpandMacroExtended(res)) + send_response::(&stdout, bidirectional::Response::ExpandMacroExtended(res)) } -fn run_old( - stdin: &mut (dyn BufRead + Send + Sync), - stdout: &mut (dyn Write + Send + Sync), -) -> io::Result<()> { +fn run_() -> io::Result<()> { fn macro_kind_to_api(kind: proc_macro_srv::ProcMacroKind) -> proc_macro_api::ProcMacroKind { match kind { proc_macro_srv::ProcMacroKind::CustomDerive => { @@ -357,9 +301,9 @@ fn run_old( } } - let mut buf = String::default(); - let mut read_request = || legacy::Request::read(stdin, &mut buf); - let mut write_response = |msg: legacy::Response| msg.write(stdout); + let mut buf = C::Buf::default(); + let mut read_request = || legacy::Request::read::<_, C>(&mut io::stdin().lock(), &mut buf); + let write_response = |msg: legacy::Response| msg.write::<_, C>(&mut io::stdout().lock()); let env = EnvSnapshot::default(); let srv = proc_macro_srv::ProcMacroSrv::new(&env); @@ -488,7 +432,7 @@ fn run_old( Ok(()) } -fn send_response(stdout: &mut dyn Write, resp: bidirectional::Response) -> io::Result<()> { +fn send_response(stdout: &io::Stdout, resp: bidirectional::Response) -> io::Result<()> { let resp = bidirectional::BidirectionalMessage::Response(resp); - resp.write(stdout) + resp.write::<_, C>(&mut stdout.lock()) } diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs deleted file mode 100644 index ba9657a9bb45..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs +++ /dev/null @@ -1,229 +0,0 @@ -#![cfg(feature = "sysroot-abi")] -#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] - -#[cfg(feature = "in-rust-tree")] -extern crate rustc_driver as _; - -mod common { - pub(crate) mod utils; -} - -use common::utils::{ - create_empty_token_tree, proc_macro_test_dylib_path, request_bidirectional, with_server, -}; -use expect_test::expect; -use proc_macro_api::{ - ProtocolFormat::BidirectionalPostcardPrototype, - bidirectional_protocol::{ - msg::{ExpandMacro, ExpandMacroData, ExpnGlobals, Request, Response}, - reject_subrequests, - }, - legacy_protocol::msg::{PanicMessage, ServerConfig, SpanDataIndexMap, SpanMode}, - version::CURRENT_API_VERSION, -}; - -#[test] -fn test_bidi_version_check_bidirectional() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let response = - request_bidirectional(writer, reader, Request::ApiVersionCheck {}, reject_subrequests); - - match response { - Response::ApiVersionCheck(version) => { - assert_eq!(version, CURRENT_API_VERSION); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_bidi_list_macros() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - let response = request_bidirectional( - writer, - reader, - Request::ListMacros { dylib_path }, - &reject_subrequests, - ); - - let Response::ListMacros(Ok(macros)) = response else { - panic!("expected successful ListMacros response"); - }; - - let mut macro_list: Vec<_> = - macros.iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect(); - macro_list.sort(); - let macro_list_str = macro_list.join("\n"); - - expect![[r#" - DeriveEmpty [CustomDerive] - DeriveError [CustomDerive] - DerivePanic [CustomDerive] - DeriveReemit [CustomDerive] - attr_error [Attr] - attr_noop [Attr] - attr_panic [Attr] - fn_like_clone_tokens [Bang] - fn_like_error [Bang] - fn_like_mk_idents [Bang] - fn_like_mk_literals [Bang] - fn_like_noop [Bang] - fn_like_panic [Bang] - fn_like_span_join [Bang] - fn_like_span_line_column [Bang] - fn_like_span_ops [Bang]"#]] - .assert_eq(¯o_list_str); - }); -} - -#[test] -fn test_bidi_list_macros_invalid_path() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let response = request_bidirectional( - writer, - reader, - Request::ListMacros { dylib_path: "/nonexistent/path/to/dylib.so".into() }, - reject_subrequests, - ); - - match response { - Response::ListMacros(Err(e)) => assert!( - e.starts_with("Cannot create expander for /nonexistent/path/to/dylib.so"), - "{e}" - ), - other => panic!("expected error response, got: {other:?}"), - } - }); -} - -#[test] -fn test_bidi_set_config() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let config = ServerConfig { span_mode: SpanMode::Id }; - let response = - request_bidirectional(writer, reader, Request::SetConfig(config), reject_subrequests); - - match response { - Response::SetConfig(returned_config) => { - assert_eq!(returned_config.span_mode, SpanMode::Id); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_bidi_set_config_rust_analyzer_mode() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let config = ServerConfig { span_mode: SpanMode::RustAnalyzer }; - let response = - request_bidirectional(writer, reader, Request::SetConfig(config), reject_subrequests); - - match response { - Response::SetConfig(returned_config) => { - assert_eq!(returned_config.span_mode, SpanMode::RustAnalyzer); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_bidi_expand_macro_panic() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - - let mut span_data_table = SpanDataIndexMap::default(); - let macro_body = - common::utils::create_empty_token_tree(CURRENT_API_VERSION, &mut span_data_table); - - let request1 = Request::ExpandMacro(Box::new(ExpandMacro { - lib: dylib_path, - env: vec![], - current_dir: None, - data: ExpandMacroData { - macro_body, - macro_name: "fn_like_panic".to_owned(), - attributes: None, - has_global_spans: ExpnGlobals { def_site: 0, call_site: 0, mixed_site: 0 }, - span_data_table: vec![], - }, - })); - - let response = request_bidirectional(writer, reader, request1, reject_subrequests); - - match response { - Response::ExpandMacro(Err(PanicMessage(msg))) => { - assert!(msg.contains("fn_like_panic"), "panic message should mention macro name"); - } - other => panic!("expected panic response, got: {other:?}"), - } - }); -} - -#[test] -fn test_bidi_basic_call_flow() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - - let response1 = - request_bidirectional(writer, reader, Request::ApiVersionCheck {}, reject_subrequests); - assert!(matches!(response1, Response::ApiVersionCheck(_))); - - let response2 = request_bidirectional( - writer, - reader, - Request::SetConfig(ServerConfig { span_mode: SpanMode::Id }), - reject_subrequests, - ); - assert!(matches!(response2, Response::SetConfig(_))); - - let response3 = request_bidirectional( - writer, - reader, - Request::ListMacros { dylib_path: dylib_path.clone() }, - reject_subrequests, - ); - assert!(matches!(response3, Response::ListMacros(Ok(_)))); - }); -} - -#[test] -fn test_bidi_expand_nonexistent_macro() { - with_server(BidirectionalPostcardPrototype, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - - let version_response = - request_bidirectional(writer, reader, Request::ApiVersionCheck {}, reject_subrequests); - let Response::ApiVersionCheck(version) = version_response else { - panic!("expected version check response"); - }; - - let mut span_data_table = SpanDataIndexMap::default(); - let macro_body = create_empty_token_tree(version, &mut span_data_table); - - let expand_request = Request::ExpandMacro(Box::new(ExpandMacro { - lib: dylib_path, - env: vec![], - current_dir: None, - data: ExpandMacroData { - macro_body, - macro_name: "NonexistentMacro".to_owned(), - attributes: None, - has_global_spans: ExpnGlobals { def_site: 0, call_site: 0, mixed_site: 0 }, - span_data_table: vec![], - }, - })); - - let response = request_bidirectional(writer, reader, expand_request, reject_subrequests); - - match response { - Response::ExpandMacro(Err(PanicMessage(msg))) => { - expect!["proc-macro `NonexistentMacro` is missing"].assert_eq(&msg) - } - other => panic!("expected error for nonexistent macro, got: {other:?}"), - } - }); -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/common/utils.rs b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/common/utils.rs deleted file mode 100644 index 3049e9800405..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/common/utils.rs +++ /dev/null @@ -1,288 +0,0 @@ -use std::{ - collections::VecDeque, - io::{self, BufRead, Read, Write}, - sync::{Arc, Condvar, Mutex}, - thread, -}; - -use paths::Utf8PathBuf; -use proc_macro_api::{ - ServerError, - bidirectional_protocol::msg::{ - BidirectionalMessage, Request as BiRequest, Response as BiResponse, SubRequest, SubResponse, - }, - legacy_protocol::msg::{FlatTree, Message, Request, Response, SpanDataIndexMap}, -}; -use span::{Edition, EditionedFileId, FileId, Span, SpanAnchor, SyntaxContext, TextRange}; -use tt::{Delimiter, DelimiterKind, TopSubtreeBuilder}; - -/// Shared state for an in-memory byte channel. -#[derive(Default)] -struct ChannelState { - buffer: VecDeque, - closed: bool, -} - -type InMemoryChannel = Arc<(Mutex, Condvar)>; - -/// Writer end of an in-memory channel. -pub(crate) struct ChannelWriter { - state: InMemoryChannel, -} - -impl Write for ChannelWriter { - fn write(&mut self, buf: &[u8]) -> io::Result { - let (lock, cvar) = &*self.state; - let mut state = lock.lock().unwrap(); - if state.closed { - return Err(io::Error::new(io::ErrorKind::BrokenPipe, "channel closed")); - } - state.buffer.extend(buf); - cvar.notify_all(); - Ok(buf.len()) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl Drop for ChannelWriter { - fn drop(&mut self) { - let (lock, cvar) = &*self.state; - let mut state = lock.lock().unwrap(); - state.closed = true; - cvar.notify_all(); - } -} - -/// Reader end of an in-memory channel. -pub(crate) struct ChannelReader { - state: InMemoryChannel, - internal_buf: Vec, -} - -impl Read for ChannelReader { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - let (lock, cvar) = &*self.state; - let mut state = lock.lock().unwrap(); - - while state.buffer.is_empty() && !state.closed { - state = cvar.wait(state).unwrap(); - } - - if state.buffer.is_empty() && state.closed { - return Ok(0); - } - - let to_read = buf.len().min(state.buffer.len()); - for (dst, src) in buf.iter_mut().zip(state.buffer.drain(..to_read)) { - *dst = src; - } - Ok(to_read) - } -} - -impl BufRead for ChannelReader { - fn fill_buf(&mut self) -> io::Result<&[u8]> { - let (lock, cvar) = &*self.state; - let mut state = lock.lock().unwrap(); - - while state.buffer.is_empty() && !state.closed { - state = cvar.wait(state).unwrap(); - } - - self.internal_buf.clear(); - self.internal_buf.extend(&state.buffer); - Ok(&self.internal_buf) - } - - fn consume(&mut self, amt: usize) { - let (lock, _) = &*self.state; - let mut state = lock.lock().unwrap(); - let to_drain = amt.min(state.buffer.len()); - drop(state.buffer.drain(..to_drain)); - } -} - -/// Creates a connected pair of channels for bidirectional communication. -fn create_channel_pair() -> (ChannelWriter, ChannelReader, ChannelWriter, ChannelReader) { - // Channel for client -> server communication - let client_to_server = Arc::new(( - Mutex::new(ChannelState { buffer: VecDeque::new(), closed: false }), - Condvar::new(), - )); - let client_writer = ChannelWriter { state: client_to_server.clone() }; - let server_reader = ChannelReader { state: client_to_server, internal_buf: Vec::new() }; - - // Channel for server -> client communication - let server_to_client = Arc::new(( - Mutex::new(ChannelState { buffer: VecDeque::new(), closed: false }), - Condvar::new(), - )); - - let server_writer = ChannelWriter { state: server_to_client.clone() }; - let client_reader = ChannelReader { state: server_to_client, internal_buf: Vec::new() }; - - (client_writer, client_reader, server_writer, server_reader) -} - -pub(crate) fn proc_macro_test_dylib_path() -> Utf8PathBuf { - let path = proc_macro_test::PROC_MACRO_TEST_LOCATION; - if path.is_empty() { - panic!("proc-macro-test dylib not available (requires nightly toolchain)"); - } - path.into() -} - -/// Creates a simple empty token tree suitable for testing. -pub(crate) fn create_empty_token_tree( - version: u32, - span_data_table: &mut SpanDataIndexMap, -) -> FlatTree { - let anchor = SpanAnchor { - file_id: EditionedFileId::new(FileId::from_raw(0), Edition::CURRENT), - ast_id: span::ROOT_ERASED_FILE_AST_ID, - }; - let span = Span { - range: TextRange::empty(0.into()), - anchor, - ctx: SyntaxContext::root(Edition::CURRENT), - }; - - let builder = TopSubtreeBuilder::new(Delimiter { - open: span, - close: span, - kind: DelimiterKind::Invisible, - }); - let tt = builder.build(); - - FlatTree::from_subtree(tt.view(), version, span_data_table) -} - -pub(crate) fn with_server(format: proc_macro_api::ProtocolFormat, test_fn: F) -> R -where - F: FnOnce(&mut dyn Write, &mut dyn BufRead) -> R, -{ - let (mut client_writer, mut client_reader, mut server_writer, mut server_reader) = - create_channel_pair(); - - let server_handle = thread::spawn(move || { - proc_macro_srv_cli::main_loop::run(&mut server_reader, &mut server_writer, format) - }); - - let result = test_fn(&mut client_writer, &mut client_reader); - - drop(client_writer); - - match server_handle.join() { - Ok(Ok(())) => {} - Ok(Err(e)) => { - if !matches!( - e.kind(), - io::ErrorKind::BrokenPipe - | io::ErrorKind::UnexpectedEof - | io::ErrorKind::InvalidData - ) { - panic!("Server error: {e}"); - } - } - Err(e) => std::panic::resume_unwind(e), - } - - result -} - -trait TestProtocol { - type Request; - type Response; - - fn request(&self, writer: &mut dyn Write, req: Self::Request); - fn receive(&self, reader: &mut dyn BufRead, writer: &mut dyn Write) -> Self::Response; -} - -#[allow(dead_code)] -struct JsonLegacy; - -impl TestProtocol for JsonLegacy { - type Request = Request; - type Response = Response; - - fn request(&self, writer: &mut dyn Write, req: Request) { - req.write(writer).expect("failed to write request"); - } - - fn receive(&self, reader: &mut dyn BufRead, _writer: &mut dyn Write) -> Response { - let mut buf = String::new(); - Response::read(reader, &mut buf) - .expect("failed to read response") - .expect("no response received") - } -} - -#[allow(dead_code)] -struct PostcardBidirectional -where - F: Fn(SubRequest) -> Result, -{ - callback: F, -} - -impl TestProtocol for PostcardBidirectional -where - F: Fn(SubRequest) -> Result, -{ - type Request = BiRequest; - type Response = BiResponse; - - fn request(&self, writer: &mut dyn Write, req: BiRequest) { - let msg = BidirectionalMessage::Request(req); - msg.write(writer).expect("failed to write request"); - } - - fn receive(&self, reader: &mut dyn BufRead, writer: &mut dyn Write) -> BiResponse { - let mut buf = Vec::new(); - - loop { - let msg = BidirectionalMessage::read(reader, &mut buf) - .expect("failed to read message") - .expect("no message received"); - - match msg { - BidirectionalMessage::Response(resp) => return resp, - BidirectionalMessage::SubRequest(sr) => { - let reply = (self.callback)(sr).expect("subrequest callback failed"); - let msg = BidirectionalMessage::SubResponse(reply); - msg.write(writer).expect("failed to write subresponse"); - } - other => panic!("unexpected message: {other:?}"), - } - } - } -} - -#[allow(dead_code)] -pub(crate) fn request_legacy( - writer: &mut dyn Write, - reader: &mut dyn BufRead, - request: Request, -) -> Response { - let protocol = JsonLegacy; - protocol.request(writer, request); - protocol.receive(reader, writer) -} - -#[allow(dead_code)] -pub(crate) fn request_bidirectional( - writer: &mut dyn Write, - reader: &mut dyn BufRead, - request: BiRequest, - callback: F, -) -> BiResponse -where - F: Fn(SubRequest) -> Result, -{ - let protocol = PostcardBidirectional { callback }; - protocol.request(writer, request); - protocol.receive(reader, writer) -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/legacy_json.rs b/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/legacy_json.rs deleted file mode 100644 index 562cf0c2516f..000000000000 --- a/src/tools/rust-analyzer/crates/proc-macro-srv-cli/tests/legacy_json.rs +++ /dev/null @@ -1,234 +0,0 @@ -//! Integration tests for the proc-macro-srv-cli main loop. -//! -//! These tests exercise the full client-server RPC procedure using in-memory -//! channels without needing to spawn the actual server and client processes. - -#![cfg(feature = "sysroot-abi")] -#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] - -#[cfg(feature = "in-rust-tree")] -extern crate rustc_driver as _; - -mod common { - pub(crate) mod utils; -} - -use common::utils::{ - create_empty_token_tree, proc_macro_test_dylib_path, request_legacy, with_server, -}; -use expect_test::expect; -use proc_macro_api::{ - ProtocolFormat::JsonLegacy, - legacy_protocol::msg::{ - ExpandMacro, ExpandMacroData, ExpnGlobals, PanicMessage, Request, Response, ServerConfig, - SpanDataIndexMap, SpanMode, - }, - version::CURRENT_API_VERSION, -}; - -#[test] -fn test_version_check() { - with_server(JsonLegacy, |writer, reader| { - let response = request_legacy(writer, reader, Request::ApiVersionCheck {}); - - match response { - Response::ApiVersionCheck(version) => { - assert_eq!(version, CURRENT_API_VERSION); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_list_macros() { - with_server(JsonLegacy, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - let response = request_legacy(writer, reader, Request::ListMacros { dylib_path }); - - let Response::ListMacros(Ok(macros)) = response else { - panic!("expected successful ListMacros response"); - }; - - let mut macro_list: Vec<_> = - macros.iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect(); - macro_list.sort(); - let macro_list_str = macro_list.join("\n"); - - expect![[r#" - DeriveEmpty [CustomDerive] - DeriveError [CustomDerive] - DerivePanic [CustomDerive] - DeriveReemit [CustomDerive] - attr_error [Attr] - attr_noop [Attr] - attr_panic [Attr] - fn_like_clone_tokens [Bang] - fn_like_error [Bang] - fn_like_mk_idents [Bang] - fn_like_mk_literals [Bang] - fn_like_noop [Bang] - fn_like_panic [Bang] - fn_like_span_join [Bang] - fn_like_span_line_column [Bang] - fn_like_span_ops [Bang]"#]] - .assert_eq(¯o_list_str); - }); -} - -#[test] -fn test_list_macros_invalid_path() { - with_server(JsonLegacy, |writer, reader| { - let response = request_legacy( - writer, - reader, - Request::ListMacros { dylib_path: "/nonexistent/path/to/dylib.so".into() }, - ); - - match response { - Response::ListMacros(Err(e)) => assert!( - e.starts_with("Cannot create expander for /nonexistent/path/to/dylib.so"), - "{e}" - ), - other => panic!("expected error response, got: {other:?}"), - } - }); -} - -#[test] -fn test_set_config() { - with_server(JsonLegacy, |writer, reader| { - let config = ServerConfig { span_mode: SpanMode::Id }; - let response = request_legacy(writer, reader, Request::SetConfig(config)); - - match response { - Response::SetConfig(returned_config) => { - assert_eq!(returned_config.span_mode, SpanMode::Id); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_set_config_rust_analyzer_mode() { - with_server(JsonLegacy, |writer, reader| { - let config = ServerConfig { span_mode: SpanMode::RustAnalyzer }; - let response = request_legacy(writer, reader, Request::SetConfig(config)); - - match response { - Response::SetConfig(returned_config) => { - assert_eq!(returned_config.span_mode, SpanMode::RustAnalyzer); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_expand_macro_panic() { - with_server(JsonLegacy, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - - let version_response = request_legacy(writer, reader, Request::ApiVersionCheck {}); - let Response::ApiVersionCheck(version) = version_response else { - panic!("expected version check response"); - }; - - let mut span_data_table = SpanDataIndexMap::default(); - let macro_body = create_empty_token_tree(version, &mut span_data_table); - - let expand_request = Request::ExpandMacro(Box::new(ExpandMacro { - lib: dylib_path, - env: vec![], - current_dir: None, - data: ExpandMacroData { - macro_body, - macro_name: "fn_like_panic".to_owned(), - attributes: None, - has_global_spans: ExpnGlobals { - serialize: version >= 3, - def_site: 0, - call_site: 0, - mixed_site: 0, - }, - span_data_table: vec![], - }, - })); - - let response = request_legacy(writer, reader, expand_request); - - match response { - Response::ExpandMacro(Err(PanicMessage(msg))) => { - assert!(msg.contains("fn_like_panic"), "panic message should mention the macro"); - } - Response::ExpandMacro(Ok(_)) => { - panic!("expected panic, but macro succeeded"); - } - other => panic!("unexpected response: {other:?}"), - } - }); -} - -#[test] -fn test_basic_call_flow() { - with_server(JsonLegacy, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - - let response1 = request_legacy(writer, reader, Request::ApiVersionCheck {}); - assert!(matches!(response1, Response::ApiVersionCheck(_))); - - let response2 = request_legacy( - writer, - reader, - Request::SetConfig(ServerConfig { span_mode: SpanMode::Id }), - ); - assert!(matches!(response2, Response::SetConfig(_))); - - let response3 = - request_legacy(writer, reader, Request::ListMacros { dylib_path: dylib_path.clone() }); - assert!(matches!(response3, Response::ListMacros(Ok(_)))); - }); -} - -#[test] -fn test_expand_nonexistent_macro() { - with_server(JsonLegacy, |writer, reader| { - let dylib_path = proc_macro_test_dylib_path(); - - let version_response = request_legacy(writer, reader, Request::ApiVersionCheck {}); - let Response::ApiVersionCheck(version) = version_response else { - panic!("expected version check response"); - }; - - let mut span_data_table = SpanDataIndexMap::default(); - let macro_body = create_empty_token_tree(version, &mut span_data_table); - - let expand_request = Request::ExpandMacro(Box::new(ExpandMacro { - lib: dylib_path, - env: vec![], - current_dir: None, - data: ExpandMacroData { - macro_body, - macro_name: "NonexistentMacro".to_owned(), - attributes: None, - has_global_spans: ExpnGlobals { - serialize: version >= 3, - def_site: 0, - call_site: 0, - mixed_site: 0, - }, - span_data_table: vec![], - }, - })); - - let response = request_legacy(writer, reader, expand_request); - - match response { - Response::ExpandMacro(Err(PanicMessage(msg))) => { - expect!["proc-macro `NonexistentMacro` is missing"].assert_eq(&msg) - } - other => panic!("expected error for nonexistent macro, got: {other:?}"), - } - }); -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml b/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml index 8e5617f8a20e..361017178409 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml @@ -31,7 +31,6 @@ libc.workspace = true [dev-dependencies] expect-test.workspace = true -line-index.workspace = true # used as proc macro test targets proc-macro-test.path = "./proc-macro-test" diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs index 06c76b6d0381..b4fac26d6e72 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs @@ -79,16 +79,6 @@ pub fn fn_like_span_ops(args: TokenStream) -> TokenStream { TokenStream::from_iter(vec![first, second, third]) } -/// Returns the line and column of the first token's span as two integer literals. -#[proc_macro] -pub fn fn_like_span_line_column(args: TokenStream) -> TokenStream { - let first = args.into_iter().next().unwrap(); - let span = first.span(); - let line = Literal::usize_unsuffixed(span.line()); - let column = Literal::usize_unsuffixed(span.column()); - TokenStream::from_iter(vec![TokenTree::Literal(line), TokenTree::Literal(column)]) -} - #[proc_macro_attribute] pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream { item diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/bridge.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/bridge.rs index fc62f9413a34..fc063a07b5f8 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/bridge.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/bridge.rs @@ -1,6 +1,6 @@ //! `proc_macro::bridge` newtypes. -use rustc_proc_macro::bridge as pm_bridge; +use proc_macro::bridge as pm_bridge; pub use pm_bridge::{DelimSpan, Diagnostic, ExpnGlobals, LitKind}; diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs index 9a65538675fe..02bdcc50d387 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs @@ -3,7 +3,7 @@ mod proc_macros; mod version; -use rustc_proc_macro::bridge; +use proc_macro::bridge; use std::{fmt, fs, io, time::SystemTime}; use temp_dir::TempDir; @@ -48,7 +48,7 @@ impl Expander { callback: Option>, ) -> Result, PanicMessage> where - as bridge::server::Server>::TokenStream: Default, + as bridge::server::Types>::TokenStream: Default, { self.inner .proc_macros diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib/proc_macros.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib/proc_macros.rs index 4065dbd0b49b..c763301135ee 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib/proc_macros.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib/proc_macros.rs @@ -1,6 +1,6 @@ //! Proc macro ABI use crate::{ProcMacroClientHandle, ProcMacroKind, ProcMacroSrvSpan, token_stream::TokenStream}; -use rustc_proc_macro::bridge; +use proc_macro::bridge; #[repr(transparent)] pub(crate) struct ProcMacros([bridge::client::ProcMacro]); @@ -30,7 +30,7 @@ impl ProcMacros { if *trait_name == macro_name => { let res = client.run( - &bridge::server::SAME_THREAD, + &bridge::server::SameThread, S::make_server(call_site, def_site, mixed_site, callback), macro_body, cfg!(debug_assertions), @@ -39,7 +39,7 @@ impl ProcMacros { } bridge::client::ProcMacro::Bang { name, client } if *name == macro_name => { let res = client.run( - &bridge::server::SAME_THREAD, + &bridge::server::SameThread, S::make_server(call_site, def_site, mixed_site, callback), macro_body, cfg!(debug_assertions), @@ -48,7 +48,7 @@ impl ProcMacros { } bridge::client::ProcMacro::Attr { name, client } if *name == macro_name => { let res = client.run( - &bridge::server::SAME_THREAD, + &bridge::server::SameThread, S::make_server(call_site, def_site, mixed_site, callback), parsed_attributes, macro_body, diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs index c548dc620ad1..f2d1dfbba4cc 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs @@ -22,12 +22,9 @@ )] #![deny(deprecated_safe, clippy::undocumented_unsafe_blocks)] -#[cfg(not(feature = "in-rust-tree"))] -extern crate proc_macro as rustc_proc_macro; +extern crate proc_macro; #[cfg(feature = "in-rust-tree")] extern crate rustc_driver as _; -#[cfg(feature = "in-rust-tree")] -extern crate rustc_proc_macro; #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_lexer as rustc_lexer; @@ -44,7 +41,6 @@ use std::{ env, ffi::OsString, fs, - ops::Range, path::{Path, PathBuf}, sync::{Arc, Mutex, PoisonError}, thread, @@ -56,7 +52,7 @@ use temp_dir::TempDir; pub use crate::server_impl::token_id::SpanId; -pub use rustc_proc_macro::Delimiter; +pub use proc_macro::Delimiter; pub use span; pub use crate::bridge::*; @@ -96,50 +92,16 @@ impl<'env> ProcMacroSrv<'env> { } } -#[derive(Debug)] -pub enum ProcMacroClientError { - Cancelled { reason: String }, - Io(std::io::Error), - Protocol(String), - Eof, -} - -#[derive(Debug)] -pub enum ProcMacroPanicMarker { - Cancelled { reason: String }, - Internal { reason: String }, -} - pub type ProcMacroClientHandle<'a> = &'a mut (dyn ProcMacroClientInterface + Sync + Send); pub trait ProcMacroClientInterface { fn file(&mut self, file_id: span::FileId) -> String; fn source_text(&mut self, span: Span) -> Option; fn local_file(&mut self, file_id: span::FileId) -> Option; - /// Line and column are 1-based. - fn line_column(&mut self, span: Span) -> Option<(u32, u32)>; - - fn byte_range(&mut self, span: Span) -> Range; } const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024; -pub enum ExpandError { - Panic(PanicMessage), - Cancelled { reason: Option }, - Internal { reason: Option }, -} - -impl ExpandError { - pub fn into_string(self) -> Option { - match self { - ExpandError::Panic(panic_message) => panic_message.into_string(), - ExpandError::Cancelled { reason } => reason, - ExpandError::Internal { reason } => reason, - } - } -} - impl ProcMacroSrv<'_> { pub fn expand( &self, @@ -153,10 +115,10 @@ impl ProcMacroSrv<'_> { call_site: S, mixed_site: S, callback: Option>, - ) -> Result, ExpandError> { + ) -> Result, PanicMessage> { let snapped_env = self.env; - let expander = self.expander(lib.as_ref()).map_err(|err| ExpandError::Internal { - reason: Some(format!("failed to load macro: {err}")), + let expander = self.expander(lib.as_ref()).map_err(|err| PanicMessage { + message: Some(format!("failed to load macro: {err}")), })?; let prev_env = EnvChange::apply(snapped_env, env, current_dir.as_ref().map(<_>::as_ref)); @@ -174,22 +136,8 @@ impl ProcMacroSrv<'_> { ) }); match thread.unwrap().join() { - Ok(res) => res.map_err(ExpandError::Panic), - - Err(payload) => { - if let Some(marker) = payload.downcast_ref::() { - return match marker { - ProcMacroPanicMarker::Cancelled { reason } => { - Err(ExpandError::Cancelled { reason: Some(reason.clone()) }) - } - ProcMacroPanicMarker::Internal { reason } => { - Err(ExpandError::Internal { reason: Some(reason.clone()) }) - } - }; - } - - std::panic::resume_unwind(payload) - } + Ok(res) => res, + Err(e) => std::panic::resume_unwind(e), } }); prev_env.rollback(); @@ -233,9 +181,7 @@ impl ProcMacroSrv<'_> { } pub trait ProcMacroSrvSpan: Copy + Send + Sync { - type Server<'a>: rustc_proc_macro::bridge::server::Server< - TokenStream = crate::token_stream::TokenStream, - >; + type Server<'a>: proc_macro::bridge::server::Server>; fn make_server<'a>( call_site: Self, def_site: Self, diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs index c114d52ec33c..32725afc5527 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs @@ -10,7 +10,7 @@ use std::{ }; use intern::Symbol; -use rustc_proc_macro::bridge::server; +use proc_macro::bridge::server; use span::{FIXUP_ERASED_FILE_AST_ID_MARKER, Span, TextRange, TextSize}; use crate::{ @@ -19,6 +19,8 @@ use crate::{ server_impl::literal_from_str, }; +pub struct FreeFunctions; + pub struct RaSpanServer<'a> { // FIXME: Report this back to the caller to track as dependencies pub tracked_env_vars: HashMap, Option>>, @@ -30,27 +32,14 @@ pub struct RaSpanServer<'a> { pub callback: Option>, } -impl server::Server for RaSpanServer<'_> { +impl server::Types for RaSpanServer<'_> { + type FreeFunctions = FreeFunctions; type TokenStream = crate::token_stream::TokenStream; type Span = Span; type Symbol = Symbol; +} - fn globals(&mut self) -> ExpnGlobals { - ExpnGlobals { - def_site: self.def_site, - call_site: self.call_site, - mixed_site: self.mixed_site, - } - } - - fn intern_symbol(ident: &str) -> Self::Symbol { - Symbol::intern(ident) - } - - fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) { - f(symbol.as_str()) - } - +impl server::FreeFunctions for RaSpanServer<'_> { fn injected_env_var(&mut self, _: &str) -> Option { None } @@ -69,19 +58,13 @@ impl server::Server for RaSpanServer<'_> { fn emit_diagnostic(&mut self, _: Diagnostic) { // FIXME handle diagnostic } +} - fn ts_drop(&mut self, stream: Self::TokenStream) { - drop(stream); - } - - fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream { - stream.clone() - } - - fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool { +impl server::TokenStream for RaSpanServer<'_> { + fn is_empty(&mut self, stream: &Self::TokenStream) -> bool { stream.is_empty() } - fn ts_from_str(&mut self, src: &str) -> Self::TokenStream { + fn from_str(&mut self, src: &str) -> Self::TokenStream { Self::TokenStream::from_str(src, self.call_site).unwrap_or_else(|e| { Self::TokenStream::from_str( &format!("compile_error!(\"failed to parse str to token stream: {e}\")"), @@ -90,15 +73,15 @@ impl server::Server for RaSpanServer<'_> { .unwrap() }) } - fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String { + fn to_string(&mut self, stream: &Self::TokenStream) -> String { stream.to_string() } - fn ts_from_token_tree(&mut self, tree: TokenTree) -> Self::TokenStream { + fn from_token_tree(&mut self, tree: TokenTree) -> Self::TokenStream { Self::TokenStream::new(vec![tree]) } - fn ts_expand_expr(&mut self, self_: &Self::TokenStream) -> Result { + fn expand_expr(&mut self, self_: &Self::TokenStream) -> Result { // FIXME: requires db, more importantly this requires name resolution so we would need to // eagerly expand this proc-macro, but we can't know that this proc-macro is eager until we // expand it ... @@ -107,7 +90,7 @@ impl server::Server for RaSpanServer<'_> { Ok(self_.clone()) } - fn ts_concat_trees( + fn concat_trees( &mut self, base: Option, trees: Vec>, @@ -123,7 +106,7 @@ impl server::Server for RaSpanServer<'_> { } } - fn ts_concat_streams( + fn concat_streams( &mut self, base: Option, streams: Vec, @@ -135,26 +118,28 @@ impl server::Server for RaSpanServer<'_> { stream } - fn ts_into_trees(&mut self, stream: Self::TokenStream) -> Vec> { + fn into_trees(&mut self, stream: Self::TokenStream) -> Vec> { (*stream.0).clone() } +} - fn span_debug(&mut self, span: Self::Span) -> String { +impl server::Span for RaSpanServer<'_> { + fn debug(&mut self, span: Self::Span) -> String { format!("{:?}", span) } - fn span_file(&mut self, span: Self::Span) -> String { + fn file(&mut self, span: Self::Span) -> String { self.callback.as_mut().map(|cb| cb.file(span.anchor.file_id.file_id())).unwrap_or_default() } - fn span_local_file(&mut self, span: Self::Span) -> Option { + fn local_file(&mut self, span: Self::Span) -> Option { self.callback.as_mut().and_then(|cb| cb.local_file(span.anchor.file_id.file_id())) } - fn span_save_span(&mut self, _span: Self::Span) -> usize { + fn save_span(&mut self, _span: Self::Span) -> usize { // FIXME, quote is incompatible with third-party tools // This is called by the quote proc-macro which is expanded when the proc-macro is compiled // As such, r-a will never observe this 0 } - fn span_recover_proc_macro_span(&mut self, _id: usize) -> Self::Span { + fn recover_proc_macro_span(&mut self, _id: usize) -> Self::Span { // FIXME, quote is incompatible with third-party tools // This is called by the expansion of quote!, r-a will observe this, but we don't have // access to the spans that were encoded @@ -164,25 +149,23 @@ impl server::Server for RaSpanServer<'_> { /// /// See PR: /// https://github.com/rust-lang/rust/pull/55780 - fn span_source_text(&mut self, span: Self::Span) -> Option { + fn source_text(&mut self, span: Self::Span) -> Option { self.callback.as_mut()?.source_text(span) } - fn span_parent(&mut self, _span: Self::Span) -> Option { + fn parent(&mut self, _span: Self::Span) -> Option { // FIXME requires db, looks up the parent call site None } - fn span_source(&mut self, span: Self::Span) -> Self::Span { + fn source(&mut self, span: Self::Span) -> Self::Span { // FIXME requires db, returns the top level call site span } - fn span_byte_range(&mut self, span: Self::Span) -> Range { - if let Some(cb) = self.callback.as_mut() { - return cb.byte_range(span); - } + fn byte_range(&mut self, span: Self::Span) -> Range { + // FIXME requires db to resolve the ast id, THIS IS NOT INCREMENTAL Range { start: span.range.start().into(), end: span.range.end().into() } } - fn span_join(&mut self, first: Self::Span, second: Self::Span) -> Option { + fn join(&mut self, first: Self::Span, second: Self::Span) -> Option { // We can't modify the span range for fixup spans, those are meaningful to fixup, so just // prefer the non-fixup span. if first.anchor.ast_id == FIXUP_ERASED_FILE_AST_ID_MARKER { @@ -210,7 +193,7 @@ impl server::Server for RaSpanServer<'_> { ctx: second.ctx, }) } - fn span_subspan( + fn subspan( &mut self, span: Self::Span, start: Bound, @@ -254,11 +237,11 @@ impl server::Server for RaSpanServer<'_> { }) } - fn span_resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span { + fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span { Span { ctx: at.ctx, ..span } } - fn span_end(&mut self, span: Self::Span) -> Self::Span { + fn end(&mut self, span: Self::Span) -> Self::Span { // We can't modify the span range for fixup spans, those are meaningful to fixup. if span.anchor.ast_id == FIXUP_ERASED_FILE_AST_ID_MARKER { return span; @@ -266,7 +249,7 @@ impl server::Server for RaSpanServer<'_> { Span { range: TextRange::empty(span.range.end()), ..span } } - fn span_start(&mut self, span: Self::Span) -> Self::Span { + fn start(&mut self, span: Self::Span) -> Self::Span { // We can't modify the span range for fixup spans, those are meaningful to fixup. if span.anchor.ast_id == FIXUP_ERASED_FILE_AST_ID_MARKER { return span; @@ -274,16 +257,38 @@ impl server::Server for RaSpanServer<'_> { Span { range: TextRange::empty(span.range.start()), ..span } } - fn span_line(&mut self, span: Self::Span) -> usize { - self.callback.as_mut().and_then(|cb| cb.line_column(span)).map_or(1, |(l, _)| l as usize) + fn line(&mut self, _span: Self::Span) -> usize { + // FIXME requires db to resolve line index, THIS IS NOT INCREMENTAL + 1 } - fn span_column(&mut self, span: Self::Span) -> usize { - self.callback.as_mut().and_then(|cb| cb.line_column(span)).map_or(1, |(_, c)| c as usize) + fn column(&mut self, _span: Self::Span) -> usize { + // FIXME requires db to resolve line index, THIS IS NOT INCREMENTAL + 1 } +} - fn symbol_normalize_and_validate_ident(&mut self, string: &str) -> Result { +impl server::Symbol for RaSpanServer<'_> { + fn normalize_and_validate_ident(&mut self, string: &str) -> Result { // FIXME: nfc-normalize and validate idents Ok(::intern_symbol(string)) } } + +impl server::Server for RaSpanServer<'_> { + fn globals(&mut self) -> ExpnGlobals { + ExpnGlobals { + def_site: self.def_site, + call_site: self.call_site, + mixed_site: self.mixed_site, + } + } + + fn intern_symbol(ident: &str) -> Self::Symbol { + Symbol::intern(ident) + } + + fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) { + f(symbol.as_str()) + } +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs index 70484c4dc28f..a968ea4cd225 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs @@ -6,7 +6,7 @@ use std::{ }; use intern::Symbol; -use rustc_proc_macro::bridge::server; +use proc_macro::bridge::server; use crate::{ ProcMacroClientHandle, @@ -25,6 +25,8 @@ impl std::fmt::Debug for SpanId { type Span = SpanId; +pub struct FreeFunctions; + pub struct SpanIdServer<'a> { // FIXME: Report this back to the caller to track as dependencies pub tracked_env_vars: HashMap, Option>>, @@ -36,27 +38,14 @@ pub struct SpanIdServer<'a> { pub callback: Option>, } -impl server::Server for SpanIdServer<'_> { +impl server::Types for SpanIdServer<'_> { + type FreeFunctions = FreeFunctions; type TokenStream = crate::token_stream::TokenStream; type Span = Span; type Symbol = Symbol; +} - fn globals(&mut self) -> ExpnGlobals { - ExpnGlobals { - def_site: self.def_site, - call_site: self.call_site, - mixed_site: self.mixed_site, - } - } - - fn intern_symbol(ident: &str) -> Self::Symbol { - Symbol::intern(ident) - } - - fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) { - f(symbol.as_str()) - } - +impl server::FreeFunctions for SpanIdServer<'_> { fn injected_env_var(&mut self, _: &str) -> Option { None } @@ -72,19 +61,13 @@ impl server::Server for SpanIdServer<'_> { } fn emit_diagnostic(&mut self, _: Diagnostic) {} +} - fn ts_drop(&mut self, stream: Self::TokenStream) { - drop(stream); - } - - fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream { - stream.clone() - } - - fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool { +impl server::TokenStream for SpanIdServer<'_> { + fn is_empty(&mut self, stream: &Self::TokenStream) -> bool { stream.is_empty() } - fn ts_from_str(&mut self, src: &str) -> Self::TokenStream { + fn from_str(&mut self, src: &str) -> Self::TokenStream { Self::TokenStream::from_str(src, self.call_site).unwrap_or_else(|e| { Self::TokenStream::from_str( &format!("compile_error!(\"failed to parse str to token stream: {e}\")"), @@ -93,18 +76,18 @@ impl server::Server for SpanIdServer<'_> { .unwrap() }) } - fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String { + fn to_string(&mut self, stream: &Self::TokenStream) -> String { stream.to_string() } - fn ts_from_token_tree(&mut self, tree: TokenTree) -> Self::TokenStream { + fn from_token_tree(&mut self, tree: TokenTree) -> Self::TokenStream { Self::TokenStream::new(vec![tree]) } - fn ts_expand_expr(&mut self, self_: &Self::TokenStream) -> Result { + fn expand_expr(&mut self, self_: &Self::TokenStream) -> Result { Ok(self_.clone()) } - fn ts_concat_trees( + fn concat_trees( &mut self, base: Option, trees: Vec>, @@ -120,7 +103,7 @@ impl server::Server for SpanIdServer<'_> { } } - fn ts_concat_streams( + fn concat_streams( &mut self, base: Option, streams: Vec, @@ -132,47 +115,49 @@ impl server::Server for SpanIdServer<'_> { stream } - fn ts_into_trees(&mut self, stream: Self::TokenStream) -> Vec> { + fn into_trees(&mut self, stream: Self::TokenStream) -> Vec> { (*stream.0).clone() } +} - fn span_debug(&mut self, span: Self::Span) -> String { +impl server::Span for SpanIdServer<'_> { + fn debug(&mut self, span: Self::Span) -> String { format!("{:?}", span.0) } - fn span_file(&mut self, _span: Self::Span) -> String { + fn file(&mut self, _span: Self::Span) -> String { String::new() } - fn span_local_file(&mut self, _span: Self::Span) -> Option { + fn local_file(&mut self, _span: Self::Span) -> Option { None } - fn span_save_span(&mut self, _span: Self::Span) -> usize { + fn save_span(&mut self, _span: Self::Span) -> usize { 0 } - fn span_recover_proc_macro_span(&mut self, _id: usize) -> Self::Span { + fn recover_proc_macro_span(&mut self, _id: usize) -> Self::Span { self.call_site } /// Recent feature, not yet in the proc_macro /// /// See PR: /// https://github.com/rust-lang/rust/pull/55780 - fn span_source_text(&mut self, _span: Self::Span) -> Option { + fn source_text(&mut self, _span: Self::Span) -> Option { None } - fn span_parent(&mut self, _span: Self::Span) -> Option { + fn parent(&mut self, _span: Self::Span) -> Option { None } - fn span_source(&mut self, span: Self::Span) -> Self::Span { + fn source(&mut self, span: Self::Span) -> Self::Span { span } - fn span_byte_range(&mut self, _span: Self::Span) -> Range { + fn byte_range(&mut self, _span: Self::Span) -> Range { Range { start: 0, end: 0 } } - fn span_join(&mut self, first: Self::Span, _second: Self::Span) -> Option { + fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option { // Just return the first span again, because some macros will unwrap the result. Some(first) } - fn span_subspan( + fn subspan( &mut self, span: Self::Span, _start: Bound, @@ -181,28 +166,48 @@ impl server::Server for SpanIdServer<'_> { // Just return the span again, because some macros will unwrap the result. Some(span) } - fn span_resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { + fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { self.call_site } - fn span_end(&mut self, _self_: Self::Span) -> Self::Span { + fn end(&mut self, _self_: Self::Span) -> Self::Span { self.call_site } - fn span_start(&mut self, _self_: Self::Span) -> Self::Span { + fn start(&mut self, _self_: Self::Span) -> Self::Span { self.call_site } - fn span_line(&mut self, _span: Self::Span) -> usize { + fn line(&mut self, _span: Self::Span) -> usize { 1 } - fn span_column(&mut self, _span: Self::Span) -> usize { + fn column(&mut self, _span: Self::Span) -> usize { 1 } +} - fn symbol_normalize_and_validate_ident(&mut self, string: &str) -> Result { +impl server::Symbol for SpanIdServer<'_> { + fn normalize_and_validate_ident(&mut self, string: &str) -> Result { // FIXME: nfc-normalize and validate idents Ok(::intern_symbol(string)) } } + +impl server::Server for SpanIdServer<'_> { + fn globals(&mut self) -> ExpnGlobals { + ExpnGlobals { + def_site: self.def_site, + call_site: self.call_site, + mixed_site: self.mixed_site, + } + } + + fn intern_symbol(ident: &str) -> Self::Symbol { + Symbol::intern(ident) + } + + fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) { + f(symbol.as_str()) + } +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs index ebef9a9a519a..20507a6def54 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs @@ -703,7 +703,6 @@ fn list_test_macros() { fn_like_mk_idents [Bang] fn_like_span_join [Bang] fn_like_span_ops [Bang] - fn_like_span_line_column [Bang] attr_noop [Attr] attr_panic [Attr] attr_error [Attr] @@ -713,17 +712,3 @@ fn list_test_macros() { DeriveError [CustomDerive]"#]] .assert_eq(&res); } - -#[test] -fn test_fn_like_span_line_column() { - assert_expand_with_callback( - "fn_like_span_line_column", - // Input text with known position: "hello" starts at offset 1 (line 2, column 1 in 1-based) - " -hello", - expect![[r#" - LITER 42:Root[0000, 0]@0..100#ROOT2024 Integer 2 - LITER 42:Root[0000, 0]@0..100#ROOT2024 Integer 1 - "#]], - ); -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs index b7c5c4fdd21f..61fcd810b1d9 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs @@ -4,11 +4,9 @@ use expect_test::Expect; use span::{ EditionedFileId, FileId, ROOT_ERASED_FILE_AST_ID, Span, SpanAnchor, SyntaxContext, TextRange, }; -use std::ops::Range; use crate::{ - EnvSnapshot, ProcMacroClientInterface, ProcMacroSrv, SpanId, dylib, proc_macro_test_dylib_path, - token_stream::TokenStream, + EnvSnapshot, ProcMacroSrv, SpanId, dylib, proc_macro_test_dylib_path, token_stream::TokenStream, }; fn parse_string(call_site: SpanId, src: &str) -> TokenStream { @@ -111,70 +109,3 @@ pub(crate) fn list() -> Vec { let res = srv.list_macros(&dylib_path).unwrap(); res.into_iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect() } - -/// A mock callback for testing that computes line/column from the input text. -struct MockCallback<'a> { - text: &'a str, -} - -impl ProcMacroClientInterface for MockCallback<'_> { - fn source_text(&mut self, span: Span) -> Option { - self.text - .get(usize::from(span.range.start())..usize::from(span.range.end())) - .map(ToOwned::to_owned) - } - - fn file(&mut self, _file_id: FileId) -> String { - String::new() - } - - fn local_file(&mut self, _file_id: FileId) -> Option { - None - } - - fn line_column(&mut self, span: Span) -> Option<(u32, u32)> { - let line_index = line_index::LineIndex::new(self.text); - let line_col = line_index.try_line_col(span.range.start())?; - // proc_macro uses 1-based line/column - Some((line_col.line as u32 + 1, line_col.col as u32 + 1)) - } - - fn byte_range(&mut self, span: Span) -> Range { - Range { start: span.range.start().into(), end: span.range.end().into() } - } -} - -pub fn assert_expand_with_callback( - macro_name: &str, - #[rust_analyzer::rust_fixture] ra_fixture: &str, - expect_spanned: Expect, -) { - let path = proc_macro_test_dylib_path(); - let expander = dylib::Expander::new(&temp_dir::TempDir::new().unwrap(), &path).unwrap(); - - let def_site = Span { - range: TextRange::new(0.into(), 150.into()), - anchor: SpanAnchor { - file_id: EditionedFileId::current_edition(FileId::from_raw(41)), - ast_id: ROOT_ERASED_FILE_AST_ID, - }, - ctx: SyntaxContext::root(span::Edition::CURRENT), - }; - let call_site = Span { - range: TextRange::new(0.into(), 100.into()), - anchor: SpanAnchor { - file_id: EditionedFileId::current_edition(FileId::from_raw(42)), - ast_id: ROOT_ERASED_FILE_AST_ID, - }, - ctx: SyntaxContext::root(span::Edition::CURRENT), - }; - let mixed_site = call_site; - - let fixture = parse_string_spanned(call_site.anchor, call_site.ctx, ra_fixture); - - let mut callback = MockCallback { text: ra_fixture }; - let res = expander - .expand(macro_name, fixture, None, def_site, call_site, mixed_site, Some(&mut callback)) - .unwrap(); - expect_spanned.assert_eq(&format!("{res:?}")); -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/token_stream.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/token_stream.rs index 2358f6963c79..36827d2561f9 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/token_stream.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/token_stream.rs @@ -4,8 +4,8 @@ use core::fmt; use std::{mem, sync::Arc}; use intern::Symbol; +use proc_macro::Delimiter; use rustc_lexer::{DocStyle, LiteralKind}; -use rustc_proc_macro::Delimiter; use crate::bridge::{DelimSpan, Group, Ident, LitKind, Literal, Punct, TokenTree}; @@ -52,7 +52,7 @@ impl TokenStream { S: SpanLike + Copy, { let mut groups = Vec::new(); - groups.push((rustc_proc_macro::Delimiter::None, 0..0, vec![])); + groups.push((proc_macro::Delimiter::None, 0..0, vec![])); let mut offset = 0; let mut tokens = rustc_lexer::tokenize(s, rustc_lexer::FrontmatterAllowed::No).peekable(); while let Some(token) = tokens.next() { @@ -102,7 +102,7 @@ impl TokenStream { }; match token.kind { rustc_lexer::TokenKind::OpenParen => { - groups.push((rustc_proc_macro::Delimiter::Parenthesis, range, vec![])) + groups.push((proc_macro::Delimiter::Parenthesis, range, vec![])) } rustc_lexer::TokenKind::CloseParen if *open_delim != Delimiter::Parenthesis => { return if *open_delim == Delimiter::None { @@ -130,7 +130,7 @@ impl TokenStream { ); } rustc_lexer::TokenKind::OpenBrace => { - groups.push((rustc_proc_macro::Delimiter::Brace, range, vec![])) + groups.push((proc_macro::Delimiter::Brace, range, vec![])) } rustc_lexer::TokenKind::CloseBrace if *open_delim != Delimiter::Brace => { return if *open_delim == Delimiter::None { @@ -158,7 +158,7 @@ impl TokenStream { ); } rustc_lexer::TokenKind::OpenBracket => { - groups.push((rustc_proc_macro::Delimiter::Bracket, range, vec![])) + groups.push((proc_macro::Delimiter::Bracket, range, vec![])) } rustc_lexer::TokenKind::CloseBracket if *open_delim != Delimiter::Bracket => { return if *open_delim == Delimiter::None { @@ -460,10 +460,10 @@ fn display_token_tree( f, "{}", match delimiter { - rustc_proc_macro::Delimiter::Parenthesis => "(", - rustc_proc_macro::Delimiter::Brace => "{", - rustc_proc_macro::Delimiter::Bracket => "[", - rustc_proc_macro::Delimiter::None => "", + proc_macro::Delimiter::Parenthesis => "(", + proc_macro::Delimiter::Brace => "{", + proc_macro::Delimiter::Bracket => "[", + proc_macro::Delimiter::None => "", } )?; if let Some(stream) = stream { @@ -473,10 +473,10 @@ fn display_token_tree( f, "{}", match delimiter { - rustc_proc_macro::Delimiter::Parenthesis => ")", - rustc_proc_macro::Delimiter::Brace => "}", - rustc_proc_macro::Delimiter::Bracket => "]", - rustc_proc_macro::Delimiter::None => "", + proc_macro::Delimiter::Parenthesis => ")", + proc_macro::Delimiter::Brace => "}", + proc_macro::Delimiter::Bracket => "]", + proc_macro::Delimiter::None => "", } )?; } @@ -587,16 +587,16 @@ fn debug_token_tree( f, "GROUP {}{} {:#?} {:#?} {:#?}", match delimiter { - rustc_proc_macro::Delimiter::Parenthesis => "(", - rustc_proc_macro::Delimiter::Brace => "{", - rustc_proc_macro::Delimiter::Bracket => "[", - rustc_proc_macro::Delimiter::None => "$", + proc_macro::Delimiter::Parenthesis => "(", + proc_macro::Delimiter::Brace => "{", + proc_macro::Delimiter::Bracket => "[", + proc_macro::Delimiter::None => "$", }, match delimiter { - rustc_proc_macro::Delimiter::Parenthesis => ")", - rustc_proc_macro::Delimiter::Brace => "}", - rustc_proc_macro::Delimiter::Bracket => "]", - rustc_proc_macro::Delimiter::None => "$", + proc_macro::Delimiter::Parenthesis => ")", + proc_macro::Delimiter::Brace => "}", + proc_macro::Delimiter::Bracket => "]", + proc_macro::Delimiter::None => "$", }, span.open, span.close, diff --git a/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs index 483ab2845045..6e1a3f37ff1c 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs @@ -640,7 +640,7 @@ impl FetchMetadata { /// Builds a command to fetch metadata for the given `cargo_toml` manifest. /// /// Performs a lightweight pre-fetch using the `--no-deps` option, - /// available via `FetchMetadata::no_deps_metadata`, to gather basic + /// available via [`FetchMetadata::no_deps_metadata`], to gather basic /// information such as the `target-dir`. /// /// The provided sysroot is used to set the `RUSTUP_TOOLCHAIN` diff --git a/src/tools/rust-analyzer/crates/project-model/src/project_json.rs b/src/tools/rust-analyzer/crates/project-model/src/project_json.rs index 6938010cbd70..b3478d2cfe03 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/project_json.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/project_json.rs @@ -78,13 +78,6 @@ pub struct ProjectJson { runnables: Vec, } -impl std::ops::Index for ProjectJson { - type Output = Crate; - fn index(&self, index: CrateArrayIdx) -> &Self::Output { - &self.crates[index.0] - } -} - impl ProjectJson { /// Create a new ProjectJson instance. /// @@ -202,11 +195,12 @@ impl ProjectJson { &self.project_root } - pub fn crate_by_root(&self, root: &AbsPath) -> Option<&Crate> { + pub fn crate_by_root(&self, root: &AbsPath) -> Option { self.crates .iter() .filter(|krate| krate.is_workspace_member) .find(|krate| krate.root_module == root) + .cloned() } /// Returns the path to the project's manifest, if it exists. @@ -220,17 +214,8 @@ impl ProjectJson { self.crates .iter() .filter(|krate| krate.is_workspace_member) - .filter_map(|krate| krate.build.as_ref()) + .filter_map(|krate| krate.build.clone()) .find(|build| build.build_file.as_std_path() == path) - .cloned() - } - - pub fn crate_by_label(&self, label: &str) -> Option<&Crate> { - // this is fast enough for now, but it's unfortunate that this is O(crates). - self.crates - .iter() - .filter(|krate| krate.is_workspace_member) - .find(|krate| krate.build.as_ref().is_some_and(|build| build.label == label)) } /// Returns the path to the project's manifest or root folder, if no manifest exists. @@ -246,10 +231,6 @@ impl ProjectJson { pub fn runnables(&self) -> &[Runnable] { &self.runnables } - - pub fn runnable_template(&self, kind: RunnableKind) -> Option<&Runnable> { - self.runnables().iter().find(|r| r.kind == kind) - } } /// A crate points to the root module of a crate and lists the dependencies of the crate. This is @@ -277,12 +258,6 @@ pub struct Crate { pub build: Option, } -impl Crate { - pub fn iter_deps(&self) -> impl ExactSizeIterator { - self.deps.iter().map(|dep| dep.krate) - } -} - /// Additional, build-specific data about a crate. #[derive(Clone, Debug, Eq, PartialEq)] pub struct Build { @@ -353,21 +328,13 @@ pub struct Runnable { /// The kind of runnable. #[derive(Debug, Clone, PartialEq, Eq)] pub enum RunnableKind { - /// `cargo check`, basically, with human-readable output. Check, /// Can run a binary. - /// May include {label} which will get the label from the `build` section of a crate. Run, /// Run a single test. - /// May include {label} which will get the label from the `build` section of a crate. - /// May include {test_id} which will get the test clicked on by the user. TestOne, - - /// Template for checking a target, emitting rustc JSON diagnostics. - /// May include {label} which will get the label from the `build` section of a crate. - Flycheck, } #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] @@ -474,7 +441,6 @@ pub struct RunnableData { #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub enum RunnableKindData { - Flycheck, Check, Run, TestOne, @@ -545,7 +511,6 @@ impl From for RunnableKind { RunnableKindData::Check => RunnableKind::Check, RunnableKindData::Run => RunnableKind::Run, RunnableKindData::TestOne => RunnableKind::TestOne, - RunnableKindData::Flycheck => RunnableKind::Flycheck, } } } diff --git a/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs b/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs index 546a1e05a063..f244c9736c7c 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs @@ -275,10 +275,7 @@ impl Sysroot { } tracing::debug!("Stitching sysroot library: {src_root}"); - let mut stitched = stitched::Stitched { - crates: Default::default(), - edition: span::Edition::Edition2024, - }; + let mut stitched = stitched::Stitched { crates: Default::default() }; for path in stitched::SYSROOT_CRATES.trim().lines() { let name = path.split('/').next_back().unwrap(); @@ -514,7 +511,6 @@ pub(crate) mod stitched { #[derive(Debug, Clone, Eq, PartialEq)] pub struct Stitched { pub(super) crates: Arena, - pub(crate) edition: span::Edition, } impl ops::Index for Stitched { diff --git a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs index 581b5fa51446..fa3a79e041e0 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs @@ -1161,8 +1161,6 @@ fn project_json_to_crate_graph( name: Some(name.canonical_name().to_owned()), } } - } else if is_sysroot { - CrateOrigin::Lang(LangCrateOrigin::Dependency) } else { CrateOrigin::Local { repo: None, name: None } }, @@ -1296,8 +1294,6 @@ fn cargo_to_crate_graph( name: Some(Symbol::intern(&pkg_data.name)), } } - } else if cargo.is_sysroot() { - CrateOrigin::Lang(LangCrateOrigin::Dependency) } else { CrateOrigin::Library { repo: pkg_data.repository.clone(), @@ -1721,7 +1717,7 @@ fn extend_crate_graph_with_sysroot( !matches!(lang_crate, LangCrateOrigin::Test | LangCrateOrigin::Alloc), )), LangCrateOrigin::ProcMacro => libproc_macro = Some(cid), - LangCrateOrigin::Other | LangCrateOrigin::Dependency => (), + LangCrateOrigin::Other => (), } } } @@ -1831,7 +1827,7 @@ fn sysroot_to_crate_graph( let display_name = CrateDisplayName::from_canonical_name(&stitched[krate].name); let crate_id = crate_graph.add_crate_root( file_id, - stitched.edition, + Edition::CURRENT_FIXME, Some(display_name), None, cfg_options.clone(), diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs index 1995d3889891..a02d1a78564f 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -91,7 +91,6 @@ impl flags::AnalysisStats { } }, prefill_caches: false, - proc_macro_processes: 1, }; let build_scripts_time = if self.disable_build_scripts { diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/diagnostics.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/diagnostics.rs index 575c77f8428c..776069f155f0 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/diagnostics.rs @@ -41,7 +41,6 @@ impl flags::Diagnostics { load_out_dirs_from_check: !self.disable_build_scripts, with_proc_macro_server, prefill_caches: false, - proc_macro_processes: 1, }; let (db, _vfs, _proc_macro) = load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/lsif.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/lsif.rs index e5e238db6361..f3b0699d5515 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/lsif.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/lsif.rs @@ -293,7 +293,6 @@ impl flags::Lsif { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: false, - proc_macro_processes: 1, }; let path = AbsPathBuf::assert_utf8(env::current_dir()?.join(self.path)); let root = ProjectManifest::discover_single(&path)?; diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/prime_caches.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/prime_caches.rs index d5da6791797b..467d8a53884a 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/prime_caches.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/prime_caches.rs @@ -38,7 +38,6 @@ impl flags::PrimeCaches { // we want to ensure that this command, not `load_workspace_at`, // is responsible for that work. prefill_caches: false, - proc_macro_processes: config.proc_macro_num_processes(), }; let root = AbsPathBuf::assert_utf8(std::env::current_dir()?.join(root)); diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/run_tests.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/run_tests.rs index d4a56d773e7d..82ace8c8b315 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/run_tests.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/run_tests.rs @@ -23,7 +23,6 @@ impl flags::RunTests { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: false, - proc_macro_processes: 1, }; let (ref db, _vfs, _proc_macro) = load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/rustc_tests.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/rustc_tests.rs index e8c6c5f4d4f7..249566d2ac16 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/rustc_tests.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/rustc_tests.rs @@ -103,7 +103,6 @@ impl Tester { load_out_dirs_from_check: false, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: false, - proc_macro_processes: 1, }; let (db, _vfs, _proc_macro) = load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?; diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs index ed0476697c9c..271d2507bcfe 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs @@ -52,7 +52,6 @@ impl flags::Scip { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: true, - proc_macro_processes: config.proc_macro_num_processes(), }; let cargo_config = config.cargo(None); let (db, vfs, _) = load_workspace_at( diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/ssr.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/ssr.rs index 5c69bda723fb..39186831459c 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/ssr.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/ssr.rs @@ -20,7 +20,6 @@ impl flags::Ssr { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: false, - proc_macro_processes: 1, }; let (ref db, vfs, _proc_macro) = load_workspace_at( &std::env::current_dir()?, @@ -57,7 +56,6 @@ impl flags::Search { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: false, - proc_macro_processes: 1, }; let (ref db, _vfs, _proc_macro) = load_workspace_at( &std::env::current_dir()?, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/unresolved_references.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/unresolved_references.rs index 49c6fcb91ebf..294add682d01 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/unresolved_references.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/unresolved_references.rs @@ -44,7 +44,6 @@ impl flags::UnresolvedReferences { load_out_dirs_from_check: !self.disable_build_scripts, with_proc_macro_server, prefill_caches: false, - proc_macro_processes: config.proc_macro_num_processes(), }; let (db, vfs, _proc_macro) = load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/command.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/command.rs index 49ce6db4ea9a..2f052618cdfa 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/command.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/command.rs @@ -10,7 +10,6 @@ use std::{ process::{ChildStderr, ChildStdout, Command, Stdio}, }; -use anyhow::Context; use crossbeam_channel::Sender; use paths::Utf8PathBuf; use process_wrap::std::{StdChildWrapper, StdCommandWrap}; @@ -157,7 +156,7 @@ impl CommandHandle { parser: impl JsonLinesParser, sender: Sender, out_file: Option, - ) -> anyhow::Result { + ) -> std::io::Result { command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null()); let program = command.get_program().into(); @@ -169,10 +168,7 @@ impl CommandHandle { child.wrap(process_wrap::std::ProcessSession); #[cfg(windows)] child.wrap(process_wrap::std::JobObject); - let mut child = child - .spawn() - .map(JodGroupChild) - .with_context(|| "Failed to spawn command: {child:?}")?; + let mut child = child.spawn().map(JodGroupChild)?; let stdout = child.0.stdout().take().unwrap(); let stderr = child.0.stderr().take().unwrap(); diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 0dda7f3cc276..e39569e108de 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -387,12 +387,6 @@ config_data! { /// Enable support for procedural macros, implies `#rust-analyzer.cargo.buildScripts.enable#`. procMacro_enable: bool = true, - /// Number of proc-macro server processes to spawn. - /// - /// Controls how many independent `proc-macro-srv` processes rust-analyzer - /// runs in parallel to handle macro expansion. - procMacro_processes: NumProcesses = NumProcesses::Concrete(1), - /// Internal config, path to proc-macro server executable. procMacro_server: Option = None, @@ -484,83 +478,33 @@ config_data! { typing_triggerChars: Option = Some("=.".to_owned()), - /// Configure a command that rust-analyzer can invoke to - /// obtain configuration. + /// Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`]. /// - /// This is an alternative to manually generating - /// `rust-project.json`: it enables rust-analyzer to generate - /// rust-project.json on the fly, and regenerate it when - /// switching or modifying projects. - /// - /// This is an object with three fields: - /// - /// * `command`: the shell command to invoke - /// - /// * `filesToWatch`: which build system-specific files should - /// be watched to trigger regenerating the configuration - /// - /// * `progressLabel`: the name of the command, used in - /// progress indicators in the IDE - /// - /// Here's an example of a valid configuration: + /// [`DiscoverWorkspaceConfig`] also requires setting `progress_label` and `files_to_watch`. + /// `progress_label` is used for the title in progress indicators, whereas `files_to_watch` + /// is used to determine which build system-specific files should be watched in order to + /// reload rust-analyzer. /// + /// Below is an example of a valid configuration: /// ```json /// "rust-analyzer.workspace.discoverConfig": { /// "command": [ /// "rust-project", - /// "develop-json", - /// "{arg}" + /// "develop-json" /// ], - /// "progressLabel": "buck2/rust-project", + /// "progressLabel": "rust-analyzer", /// "filesToWatch": [ /// "BUCK" /// ] /// } /// ``` /// - /// ## Argument Substitutions - /// - /// If `command` includes the argument `{arg}`, that argument will be substituted - /// with the JSON-serialized form of the following enum: - /// - /// ```norun - /// #[derive(PartialEq, Clone, Debug, Serialize)] - /// #[serde(rename_all = "camelCase")] - /// pub enum DiscoverArgument { - /// Path(AbsPathBuf), - /// Buildfile(AbsPathBuf), - /// } - /// ``` - /// - /// rust-analyzer will use the path invocation to find and - /// generate a `rust-project.json` and therefore a - /// workspace. Example: - /// - /// - /// ```norun - /// rust-project develop-json '{ "path": "myproject/src/main.rs" }' - /// ``` - /// - /// rust-analyzer will use build file invocations to update an - /// existing workspace. Example: - /// - /// Or with a build file and the configuration above: - /// - /// ```norun - /// rust-project develop-json '{ "buildfile": "myproject/BUCK" }' - /// ``` - /// - /// As a reference for implementors, buck2's `rust-project` - /// will likely be useful: - /// . - /// - /// ## Discover Command Output + /// ## On `DiscoverWorkspaceConfig::command` /// /// **Warning**: This format is provisional and subject to change. /// - /// The discover command should output JSON objects, one per - /// line (JSONL format). These objects should correspond to - /// this Rust data type: + /// [`DiscoverWorkspaceConfig::command`] *must* return a JSON object corresponding to + /// `DiscoverProjectData::Finished`: /// /// ```norun /// #[derive(Debug, Clone, Deserialize, Serialize)] @@ -573,14 +517,7 @@ config_data! { /// } /// ``` /// - /// For example, a progress event: - /// - /// ```json - /// {"kind":"progress","message":"generating rust-project.json"} - /// ``` - /// - /// A finished event can look like this (expanded and - /// commented for readability): + /// As JSON, `DiscoverProjectData::Finished` is: /// /// ```json /// { @@ -588,7 +525,7 @@ config_data! { /// "kind": "finished", /// // the file used by a non-Cargo build system to define /// // a package or target. - /// "buildfile": "rust-analyzer/BUCK", + /// "buildfile": "rust-analyzer/BUILD", /// // the contents of a rust-project.json, elided for brevity /// "project": { /// "sysroot": "foo", @@ -597,9 +534,41 @@ config_data! { /// } /// ``` /// - /// Only the finished event is required, but the other - /// variants are encouraged to give users more feedback about - /// progress or errors. + /// It is encouraged, but not required, to use the other variants on `DiscoverProjectData` + /// to provide a more polished end-user experience. + /// + /// `DiscoverWorkspaceConfig::command` may *optionally* include an `{arg}`, which will be + /// substituted with the JSON-serialized form of the following enum: + /// + /// ```norun + /// #[derive(PartialEq, Clone, Debug, Serialize)] + /// #[serde(rename_all = "camelCase")] + /// pub enum DiscoverArgument { + /// Path(AbsPathBuf), + /// Buildfile(AbsPathBuf), + /// } + /// ``` + /// + /// The JSON representation of `DiscoverArgument::Path` is: + /// + /// ```json + /// { + /// "path": "src/main.rs" + /// } + /// ``` + /// + /// Similarly, the JSON representation of `DiscoverArgument::Buildfile` is: + /// + /// ```json + /// { + /// "buildfile": "BUILD" + /// } + /// ``` + /// + /// `DiscoverArgument::Path` is used to find and generate a `rust-project.json`, and + /// therefore, a workspace, whereas `DiscoverArgument::buildfile` is used to to update an + /// existing workspace. As a reference for implementors, buck2's `rust-project` will likely + /// be useful: . workspace_discoverConfig: Option = None, } } @@ -901,18 +870,10 @@ config_data! { /// (i.e., the folder containing the `Cargo.toml`). This can be overwritten /// by changing `#rust-analyzer.check.invocationStrategy#`. /// - /// It supports two interpolation syntaxes, both mainly intended to be used with - /// [non-Cargo build systems](./non_cargo_based_projects.md): - /// - /// - If `{saved_file}` is part of the command, rust-analyzer will pass - /// the absolute path of the saved file to the provided command. - /// (A previous version, `$saved_file`, also works.) - /// - If `{label}` is part of the command, rust-analyzer will pass the - /// Cargo package ID, which can be used with `cargo check -p`, or a build label from - /// `rust-project.json`. If `{label}` is included, rust-analyzer behaves much like - /// [`"rust-analyzer.check.workspace": false`](#check.workspace). - /// - /// + /// If `$saved_file` is part of the command, rust-analyzer will pass + /// the absolute path of the saved file to the provided command. This is + /// intended to be used with non-Cargo build systems. + /// Note that `$saved_file` is experimental and may be removed in the future. /// /// An example command would be: /// @@ -1073,7 +1034,6 @@ pub struct Config { /// The workspace roots as registered by the LSP client workspace_roots: Vec, caps: ClientCapabilities, - /// The LSP root path, deprecated in favor of `workspace_roots` root_path: AbsPathBuf, snippets: Vec, client_info: Option, @@ -1397,10 +1357,6 @@ impl Config { self.discovered_projects_from_command.push(ProjectJsonFromCommand { data, buildfile }); } - - pub fn workspace_roots(&self) -> &[AbsPathBuf] { - &self.workspace_roots - } } #[derive(Default, Debug)] @@ -1777,7 +1733,6 @@ impl Config { } pub fn root_path(&self) -> &AbsPathBuf { - // We should probably use `workspace_roots` here if set &self.root_path } @@ -2476,8 +2431,6 @@ impl Config { pub(crate) fn cargo_test_options(&self, source_root: Option) -> CargoOptions { CargoOptions { - // Might be nice to allow users to specify test_command = "nextest" - subcommand: "test".into(), target_tuples: self.cargo_target(source_root).clone().into_iter().collect(), all_targets: false, no_default_features: *self.cargo_noDefaultFeatures(source_root), @@ -2511,9 +2464,9 @@ impl Config { }, } } - Some(_) | None => FlycheckConfig::Automatic { - cargo_options: CargoOptions { - subcommand: self.check_command(source_root).clone(), + Some(_) | None => FlycheckConfig::CargoCommand { + command: self.check_command(source_root).clone(), + options: CargoOptions { target_tuples: self .check_targets(source_root) .clone() @@ -2677,13 +2630,6 @@ impl Config { } } - pub fn proc_macro_num_processes(&self) -> usize { - match self.procMacro_processes() { - NumProcesses::Concrete(0) | NumProcesses::Physical => num_cpus::get_physical(), - &NumProcesses::Concrete(n) => n, - } - } - pub fn main_loop_num_threads(&self) -> usize { match self.numThreads() { Some(NumThreads::Concrete(0)) | None | Some(NumThreads::Physical) => { @@ -3120,14 +3066,6 @@ pub enum NumThreads { Concrete(usize), } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(rename_all = "snake_case")] -pub enum NumProcesses { - Physical, - #[serde(untagged)] - Concrete(usize), -} - macro_rules! _default_val { ($default:expr, $ty:ty) => {{ let default_: $ty = $default; @@ -3954,22 +3892,6 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json }, ], }, - "NumProcesses" => set! { - "anyOf": [ - { - "type": "number", - "minimum": 0, - "maximum": 255 - }, - { - "type": "string", - "enum": ["physical"], - "enumDescriptions": [ - "Use the number of physical cores", - ], - }, - ], - }, "Option" => set! { "anyOf": [ { @@ -4249,8 +4171,8 @@ mod tests { assert_eq!(config.cargo_targetDir(None), &None); assert!(matches!( config.flycheck(None), - FlycheckConfig::Automatic { - cargo_options: CargoOptions { target_dir_config: TargetDirectoryConfig::None, .. }, + FlycheckConfig::CargoCommand { + options: CargoOptions { target_dir_config: TargetDirectoryConfig::None, .. }, .. } )); @@ -4273,8 +4195,8 @@ mod tests { Utf8PathBuf::from(std::env::var("CARGO_TARGET_DIR").unwrap_or("target".to_owned())); assert!(matches!( config.flycheck(None), - FlycheckConfig::Automatic { - cargo_options: CargoOptions { target_dir_config, .. }, + FlycheckConfig::CargoCommand { + options: CargoOptions { target_dir_config, .. }, .. } if target_dir_config.target_dir(Some(&ws_target_dir)).map(Cow::into_owned) == Some(ws_target_dir.join("rust-analyzer")) @@ -4299,8 +4221,8 @@ mod tests { ); assert!(matches!( config.flycheck(None), - FlycheckConfig::Automatic { - cargo_options: CargoOptions { target_dir_config, .. }, + FlycheckConfig::CargoCommand { + options: CargoOptions { target_dir_config, .. }, .. } if target_dir_config.target_dir(None).map(Cow::into_owned) == Some(Utf8PathBuf::from("other_folder")) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config/patch_old_style.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config/patch_old_style.rs index 5dc463eccce4..389bb7848c01 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config/patch_old_style.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config/patch_old_style.rs @@ -3,7 +3,7 @@ use serde_json::{Value, json}; /// This function patches the json config to the new expected keys. /// That is we try to load old known config keys here and convert them to the new ones. -/// See +/// See https://github.com/rust-lang/rust-analyzer/pull/12010 /// /// We already have an alias system for simple cases, but if we make structural changes /// the alias infra fails down. diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs index 8d0f52433e02..4a247800af9d 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs @@ -3,6 +3,7 @@ pub(crate) mod flycheck_to_proto; use std::mem; +use cargo_metadata::PackageId; use ide::FileId; use ide_db::{FxHashMap, base_db::DbPanicContext}; use itertools::Itertools; @@ -11,13 +12,10 @@ use smallvec::SmallVec; use stdx::iter_eq_by; use triomphe::Arc; -use crate::{ - flycheck::PackageSpecifier, global_state::GlobalStateSnapshot, lsp, lsp_ext, - main_loop::DiagnosticsTaskKind, -}; +use crate::{global_state::GlobalStateSnapshot, lsp, lsp_ext, main_loop::DiagnosticsTaskKind}; pub(crate) type CheckFixes = - Arc, FxHashMap>>>>; + Arc>, FxHashMap>>>>; #[derive(Debug, Default, Clone)] pub struct DiagnosticsMapConfig { @@ -31,7 +29,7 @@ pub(crate) type DiagnosticsGeneration = usize; #[derive(Debug, Clone, Default)] pub(crate) struct WorkspaceFlycheckDiagnostic { - pub(crate) per_package: FxHashMap, PackageFlycheckDiagnostic>, + pub(crate) per_package: FxHashMap>, PackageFlycheckDiagnostic>, } #[derive(Debug, Clone)] @@ -87,7 +85,7 @@ impl DiagnosticCollection { pub(crate) fn clear_check_for_package( &mut self, flycheck_id: usize, - package_id: PackageSpecifier, + package_id: Arc, ) { let Some(check) = self.check.get_mut(flycheck_id) else { return; @@ -126,7 +124,7 @@ impl DiagnosticCollection { pub(crate) fn clear_check_older_than_for_package( &mut self, flycheck_id: usize, - package_id: PackageSpecifier, + package_id: Arc, generation: DiagnosticsGeneration, ) { let Some(check) = self.check.get_mut(flycheck_id) else { @@ -156,7 +154,7 @@ impl DiagnosticCollection { &mut self, flycheck_id: usize, generation: DiagnosticsGeneration, - package_id: &Option, + package_id: &Option>, file_id: FileId, diagnostic: lsp_types::Diagnostic, fix: Option>, @@ -289,40 +287,34 @@ pub(crate) fn fetch_native_diagnostics( let mut diagnostics = subscriptions[slice] .iter() .copied() - .map(|file_id| { - let diagnostics = (|| { - let line_index = snapshot.file_line_index(file_id).ok()?; - let source_root = snapshot.analysis.source_root_id(file_id).ok()?; + .filter_map(|file_id| { + let line_index = snapshot.file_line_index(file_id).ok()?; + let source_root = snapshot.analysis.source_root_id(file_id).ok()?; - let config = &snapshot.config.diagnostics(Some(source_root)); - let diagnostics = match kind { - NativeDiagnosticsFetchKind::Syntax => { - snapshot.analysis.syntax_diagnostics(config, file_id).ok()? + let config = &snapshot.config.diagnostics(Some(source_root)); + let diagnostics = match kind { + NativeDiagnosticsFetchKind::Syntax => { + snapshot.analysis.syntax_diagnostics(config, file_id).ok()? + } + + NativeDiagnosticsFetchKind::Semantic if config.enabled => snapshot + .analysis + .semantic_diagnostics(config, ide::AssistResolveStrategy::None, file_id) + .ok()?, + NativeDiagnosticsFetchKind::Semantic => return None, + }; + let diagnostics = diagnostics + .into_iter() + .filter_map(|d| { + if d.range.file_id == file_id { + Some(convert_diagnostic(&line_index, d)) + } else { + odd_ones.push(d); + None } - - NativeDiagnosticsFetchKind::Semantic if config.enabled => snapshot - .analysis - .semantic_diagnostics(config, ide::AssistResolveStrategy::None, file_id) - .ok()?, - NativeDiagnosticsFetchKind::Semantic => return None, - }; - Some( - diagnostics - .into_iter() - .filter_map(|d| { - if d.range.file_id == file_id { - Some(convert_diagnostic(&line_index, d)) - } else { - odd_ones.push(d); - None - } - }) - .collect::>(), - ) - })() - .unwrap_or_default(); - - (file_id, diagnostics) + }) + .collect::>(); + Some((file_id, diagnostics)) }) .collect::>(); diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/discover.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/discover.rs index 098b6a4d986d..4aef5b0b7f3d 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/discover.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/discover.rs @@ -1,6 +1,6 @@ //! Infrastructure for lazy project discovery. Currently only support rust-project.json discovery //! via a custom discover command. -use std::path::Path; +use std::{io, path::Path}; use crossbeam_channel::Sender; use ide_db::FxHashMap; @@ -42,12 +42,12 @@ impl DiscoverCommand { Self { sender, command } } - /// Spawn the command inside `DiscoverCommand` and report progress, if any. + /// Spawn the command inside [Discover] and report progress, if any. pub(crate) fn spawn( &self, discover_arg: DiscoverArgument, current_dir: &Path, - ) -> anyhow::Result { + ) -> io::Result { let command = &self.command[0]; let args = &self.command[1..]; @@ -73,7 +73,7 @@ impl DiscoverCommand { } } -/// A handle to a spawned `DiscoverCommand`. +/// A handle to a spawned [Discover]. #[derive(Debug)] pub(crate) struct DiscoverHandle { pub(crate) handle: CommandHandle, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs index 47f7a57f72ec..b06264169188 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs @@ -14,7 +14,6 @@ use ide_db::FxHashSet; use itertools::Itertools; use paths::{AbsPath, AbsPathBuf, Utf8Path, Utf8PathBuf}; use project_model::TargetDirectoryConfig; -use project_model::project_json; use rustc_hash::FxHashMap; use serde::Deserialize as _; use serde_derive::Deserialize; @@ -37,11 +36,8 @@ pub(crate) enum InvocationStrategy { PerWorkspace, } -/// Data needed to construct a `cargo` command invocation, e.g. for flycheck or running a test. #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) struct CargoOptions { - /// The cargo subcommand to run, e.g. "check" or "clippy" - pub(crate) subcommand: String, pub(crate) target_tuples: Vec, pub(crate) all_targets: bool, pub(crate) set_test: bool, @@ -93,36 +89,13 @@ impl CargoOptions { } } -/// The flycheck config from a rust-project.json file or discoverConfig JSON output. -#[derive(Debug, Default)] -pub(crate) struct FlycheckConfigJson { - /// The template with [project_json::RunnableKind::Flycheck] - pub single_template: Option, -} - -impl FlycheckConfigJson { - pub(crate) fn any_configured(&self) -> bool { - // self.workspace_template.is_some() || - self.single_template.is_some() - } -} - -/// The flycheck config from rust-analyzer's own configuration. -/// -/// We rely on this when rust-project.json does not specify a flycheck runnable -/// #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) enum FlycheckConfig { - /// Automatically use rust-project.json's flycheck runnable or just use cargo (the common case) - /// - /// We can't have a variant for ProjectJson because that is configured on the fly during - /// discoverConfig. We only know what we can read at config time. - Automatic { - /// If we do use cargo, how to build the check command - cargo_options: CargoOptions, + CargoCommand { + command: String, + options: CargoOptions, ansi_color_output: bool, }, - /// check_overrideCommand. This overrides both cargo and rust-project.json's flycheck runnable. CustomCommand { command: String, args: Vec, @@ -134,7 +107,7 @@ pub(crate) enum FlycheckConfig { impl FlycheckConfig { pub(crate) fn invocation_strategy(&self) -> InvocationStrategy { match self { - FlycheckConfig::Automatic { .. } => InvocationStrategy::PerWorkspace, + FlycheckConfig::CargoCommand { .. } => InvocationStrategy::PerWorkspace, FlycheckConfig::CustomCommand { invocation_strategy, .. } => { invocation_strategy.clone() } @@ -143,33 +116,19 @@ impl FlycheckConfig { } impl fmt::Display for FlycheckConfig { - /// Show a shortened version of the check command. fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - FlycheckConfig::Automatic { cargo_options, .. } => { - write!(f, "cargo {}", cargo_options.subcommand) - } + FlycheckConfig::CargoCommand { command, .. } => write!(f, "cargo {command}"), FlycheckConfig::CustomCommand { command, args, .. } => { // Don't show `my_custom_check --foo $saved_file` literally to the user, as it // looks like we've forgotten to substitute $saved_file. // - // `my_custom_check --foo /home/user/project/src/dir/foo.rs` is too verbose. - // // Instead, show `my_custom_check --foo ...`. The // actual path is often too long to be worth showing // in the IDE (e.g. in the VS Code status bar). let display_args = args .iter() - .map(|arg| { - if (arg == SAVED_FILE_PLACEHOLDER_DOLLAR) - || (arg == SAVED_FILE_INLINE) - || arg.ends_with(".rs") - { - "..." - } else { - arg - } - }) + .map(|arg| if arg == SAVED_FILE_PLACEHOLDER { "..." } else { arg }) .collect::>(); write!(f, "{command} {}", display_args.join(" ")) @@ -197,7 +156,6 @@ impl FlycheckHandle { generation: Arc, sender: Sender, config: FlycheckConfig, - config_json: FlycheckConfigJson, sysroot_root: Option, workspace_root: AbsPathBuf, manifest_path: Option, @@ -208,7 +166,6 @@ impl FlycheckHandle { generation.load(Ordering::Relaxed), sender, config, - config_json, sysroot_root, workspace_root, manifest_path, @@ -238,17 +195,16 @@ impl FlycheckHandle { /// Schedule a re-start of the cargo check worker to do a package wide check. pub(crate) fn restart_for_package( &self, - package: PackageSpecifier, + package: Arc, target: Option, - workspace_deps: Option>, - saved_file: Option, + workspace_deps: Option>>, ) { let generation = self.generation.fetch_add(1, Ordering::Relaxed) + 1; self.sender .send(StateChange::Restart { generation, scope: FlycheckScope::Package { package, workspace_deps }, - saved_file, + saved_file: None, target, }) .unwrap(); @@ -277,7 +233,7 @@ pub(crate) enum ClearDiagnosticsKind { #[derive(Debug)] pub(crate) enum ClearScope { Workspace, - Package(PackageSpecifier), + Package(Arc), } pub(crate) enum FlycheckMessage { @@ -287,7 +243,7 @@ pub(crate) enum FlycheckMessage { generation: DiagnosticsGeneration, workspace_root: Arc, diagnostic: Diagnostic, - package_id: Option, + package_id: Option>, }, /// Request clearing all outdated diagnostics. @@ -330,56 +286,16 @@ impl fmt::Debug for FlycheckMessage { #[derive(Debug)] pub(crate) enum Progress { - DidStart { - /// The user sees this in VSCode, etc. May be a shortened version of the command we actually - /// executed, otherwise it is way too long. - user_facing_command: String, - }, + DidStart, DidCheckCrate(String), DidFinish(io::Result<()>), DidCancel, DidFailToRestart(String), } -#[derive(Debug, Clone)] enum FlycheckScope { Workspace, - Package { - // Either a cargo package or a $label in rust-project.check.overrideCommand - package: PackageSpecifier, - workspace_deps: Option>, - }, -} - -#[derive(Debug, Hash, PartialEq, Eq, Clone)] -pub(crate) enum PackageSpecifier { - Cargo { - /// The one in Cargo.toml, assumed to work with `cargo check -p {}` etc - package_id: Arc, - }, - BuildInfo { - /// If a `build` field is present in rust-project.json, its label field - label: String, - }, -} - -impl PackageSpecifier { - pub(crate) fn as_str(&self) -> &str { - match self { - Self::Cargo { package_id } => &package_id.repr, - Self::BuildInfo { label } => label, - } - } -} - -#[derive(Debug)] -enum FlycheckCommandOrigin { - /// Regular cargo invocation - Cargo, - /// Configured via check_overrideCommand - CheckOverrideCommand, - /// From a runnable with [project_json::RunnableKind::Flycheck] - ProjectJsonRunnable, + Package { package: Arc, workspace_deps: Option>> }, } enum StateChange { @@ -400,8 +316,6 @@ struct FlycheckActor { generation: DiagnosticsGeneration, sender: Sender, config: FlycheckConfig, - config_json: FlycheckConfigJson, - manifest_path: Option, ws_target_dir: Option, /// Either the workspace root of the workspace we are flychecking, @@ -414,92 +328,27 @@ struct FlycheckActor { /// doesn't provide a way to read sub-process output without blocking, so we /// have to wrap sub-processes output handling in a thread and pass messages /// back over a channel. - command_handle: Option>, + command_handle: Option>, /// The receiver side of the channel mentioned above. - command_receiver: Option>, - diagnostics_cleared_for: FxHashSet, + command_receiver: Option>, + diagnostics_cleared_for: FxHashSet>, diagnostics_received: DiagnosticsReceived, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq)] enum DiagnosticsReceived { - /// We started a flycheck, but we haven't seen any diagnostics yet. - NotYet, - /// We received a non-zero number of diagnostics from rustc or clippy (via - /// cargo or custom check command). This means there were errors or - /// warnings. - AtLeastOne, - /// We received a non-zero number of diagnostics, and the scope is - /// workspace, so we've discarded the previous workspace diagnostics. - AtLeastOneAndClearedWorkspace, + Yes, + No, + YesAndClearedForAll, } #[allow(clippy::large_enum_variant)] enum Event { RequestStateChange(StateChange), - CheckEvent(Option), + CheckEvent(Option), } -/// This is stable behaviour. Don't change. -const SAVED_FILE_PLACEHOLDER_DOLLAR: &str = "$saved_file"; -const LABEL_INLINE: &str = "{label}"; -const SAVED_FILE_INLINE: &str = "{saved_file}"; - -struct Substitutions<'a> { - label: Option<&'a str>, - saved_file: Option<&'a str>, -} - -impl<'a> Substitutions<'a> { - /// If you have a runnable, and it has {label} in it somewhere, treat it as a template that - /// may be unsatisfied if you do not provide a label to substitute into it. Returns None in - /// that situation. Otherwise performs the requested substitutions. - /// - /// Same for {saved_file}. - /// - #[allow(clippy::disallowed_types)] /* generic parameter allows for FxHashMap */ - fn substitute( - self, - template: &project_json::Runnable, - extra_env: &std::collections::HashMap, H>, - ) -> Option { - let mut cmd = toolchain::command(&template.program, &template.cwd, extra_env); - for arg in &template.args { - if let Some(ix) = arg.find(LABEL_INLINE) { - if let Some(label) = self.label { - let mut arg = arg.to_string(); - arg.replace_range(ix..ix + LABEL_INLINE.len(), label); - cmd.arg(arg); - continue; - } else { - return None; - } - } - if let Some(ix) = arg.find(SAVED_FILE_INLINE) { - if let Some(saved_file) = self.saved_file { - let mut arg = arg.to_string(); - arg.replace_range(ix..ix + SAVED_FILE_INLINE.len(), saved_file); - cmd.arg(arg); - continue; - } else { - return None; - } - } - // Legacy syntax: full argument match - if arg == SAVED_FILE_PLACEHOLDER_DOLLAR { - if let Some(saved_file) = self.saved_file { - cmd.arg(saved_file); - continue; - } else { - return None; - } - } - cmd.arg(arg); - } - cmd.current_dir(&template.cwd); - Some(cmd) - } -} +pub(crate) const SAVED_FILE_PLACEHOLDER: &str = "$saved_file"; impl FlycheckActor { fn new( @@ -507,7 +356,6 @@ impl FlycheckActor { generation: DiagnosticsGeneration, sender: Sender, config: FlycheckConfig, - config_json: FlycheckConfigJson, sysroot_root: Option, workspace_root: AbsPathBuf, manifest_path: Option, @@ -519,7 +367,6 @@ impl FlycheckActor { generation, sender, config, - config_json, sysroot_root, root: Arc::new(workspace_root), scope: FlycheckScope::Workspace, @@ -528,7 +375,7 @@ impl FlycheckActor { command_handle: None, command_receiver: None, diagnostics_cleared_for: Default::default(), - diagnostics_received: DiagnosticsReceived::NotYet, + diagnostics_received: DiagnosticsReceived::No, } } @@ -571,29 +418,27 @@ impl FlycheckActor { } let command = self.check_command(&scope, saved_file.as_deref(), target); - self.scope = scope.clone(); + self.scope = scope; self.generation = generation; - let Some((command, origin)) = command else { - tracing::debug!(?scope, "failed to build flycheck command"); + let Some(command) = command else { continue; }; - let debug_command = format!("{command:?}"); - let user_facing_command = self.config.to_string(); + let formatted_command = format!("{command:?}"); - tracing::debug!(?origin, ?command, "will restart flycheck"); + tracing::debug!(?command, "will restart flycheck"); let (sender, receiver) = unbounded(); match CommandHandle::spawn( command, - CheckParser, + CargoCheckParser, sender, match &self.config { - FlycheckConfig::Automatic { cargo_options, .. } => { + FlycheckConfig::CargoCommand { options, .. } => { let ws_target_dir = self.ws_target_dir.as_ref().map(Utf8PathBuf::as_path); let target_dir = - cargo_options.target_dir_config.target_dir(ws_target_dir); + options.target_dir_config.target_dir(ws_target_dir); // If `"rust-analyzer.cargo.targetDir": null`, we should use // workspace's target dir instead of hard-coded fallback. @@ -619,14 +464,14 @@ impl FlycheckActor { }, ) { Ok(command_handle) => { - tracing::debug!(?origin, command = %debug_command, "did restart flycheck"); + tracing::debug!(command = formatted_command, "did restart flycheck"); self.command_handle = Some(command_handle); self.command_receiver = Some(receiver); - self.report_progress(Progress::DidStart { user_facing_command }); + self.report_progress(Progress::DidStart); } Err(error) => { self.report_progress(Progress::DidFailToRestart(format!( - "Failed to run the following command: {debug_command} origin={origin:?} error={error}" + "Failed to run the following command: {formatted_command} error={error}" ))); } } @@ -647,7 +492,7 @@ impl FlycheckActor { error ); } - if self.diagnostics_received == DiagnosticsReceived::NotYet { + if self.diagnostics_received == DiagnosticsReceived::No { tracing::trace!(flycheck_id = self.id, "clearing diagnostics"); // We finished without receiving any diagnostics. // Clear everything for good measure @@ -706,7 +551,7 @@ impl FlycheckActor { self.report_progress(Progress::DidFinish(res)); } Event::CheckEvent(Some(message)) => match message { - CheckMessage::CompilerArtifact(msg) => { + CargoCheckMessage::CompilerArtifact(msg) => { tracing::trace!( flycheck_id = self.id, artifact = msg.target.name, @@ -719,10 +564,7 @@ impl FlycheckActor { msg.target.kind.iter().format_with(", ", |kind, f| f(&kind)), ))); let package_id = Arc::new(msg.package_id); - if self - .diagnostics_cleared_for - .insert(PackageSpecifier::Cargo { package_id: package_id.clone() }) - { + if self.diagnostics_cleared_for.insert(package_id.clone()) { tracing::trace!( flycheck_id = self.id, package_id = package_id.repr, @@ -730,27 +572,25 @@ impl FlycheckActor { ); self.send(FlycheckMessage::ClearDiagnostics { id: self.id, - kind: ClearDiagnosticsKind::All(ClearScope::Package( - PackageSpecifier::Cargo { package_id }, - )), + kind: ClearDiagnosticsKind::All(ClearScope::Package(package_id)), }); } } - CheckMessage::Diagnostic { diagnostic, package_id } => { + CargoCheckMessage::Diagnostic { diagnostic, package_id } => { tracing::trace!( flycheck_id = self.id, message = diagnostic.message, - package_id = package_id.as_ref().map(|it| it.as_str()), + package_id = package_id.as_ref().map(|it| &it.repr), "diagnostic received" ); - if self.diagnostics_received == DiagnosticsReceived::NotYet { - self.diagnostics_received = DiagnosticsReceived::AtLeastOne; + if self.diagnostics_received == DiagnosticsReceived::No { + self.diagnostics_received = DiagnosticsReceived::Yes; } if let Some(package_id) = &package_id { if self.diagnostics_cleared_for.insert(package_id.clone()) { tracing::trace!( flycheck_id = self.id, - package_id = package_id.as_str(), + package_id = package_id.repr, "clearing diagnostics" ); self.send(FlycheckMessage::ClearDiagnostics { @@ -761,10 +601,9 @@ impl FlycheckActor { }); } } else if self.diagnostics_received - != DiagnosticsReceived::AtLeastOneAndClearedWorkspace + != DiagnosticsReceived::YesAndClearedForAll { - self.diagnostics_received = - DiagnosticsReceived::AtLeastOneAndClearedWorkspace; + self.diagnostics_received = DiagnosticsReceived::YesAndClearedForAll; self.send(FlycheckMessage::ClearDiagnostics { id: self.id, kind: ClearDiagnosticsKind::All(ClearScope::Workspace), @@ -800,30 +639,7 @@ impl FlycheckActor { fn clear_diagnostics_state(&mut self) { self.diagnostics_cleared_for.clear(); - self.diagnostics_received = DiagnosticsReceived::NotYet; - } - - fn explicit_check_command( - &self, - scope: &FlycheckScope, - saved_file: Option<&AbsPath>, - ) -> Option { - let label = match scope { - // We could add a runnable like "RunnableKind::FlycheckWorkspace". But generally - // if you're not running cargo, it's because your workspace is too big to check - // all at once. You can always use `check_overrideCommand` with no {label}. - FlycheckScope::Workspace => return None, - FlycheckScope::Package { package: PackageSpecifier::BuildInfo { label }, .. } => { - label.as_str() - } - FlycheckScope::Package { - package: PackageSpecifier::Cargo { package_id: label }, - .. - } => &label.repr, - }; - let template = self.config_json.single_template.as_ref()?; - let subs = Substitutions { label: Some(label), saved_file: saved_file.map(|x| x.as_str()) }; - subs.substitute(template, &FxHashMap::default()) + self.diagnostics_received = DiagnosticsReceived::No; } /// Construct a `Command` object for checking the user's code. If the user @@ -834,49 +650,23 @@ impl FlycheckActor { scope: &FlycheckScope, saved_file: Option<&AbsPath>, target: Option, - ) -> Option<(Command, FlycheckCommandOrigin)> { + ) -> Option { match &self.config { - FlycheckConfig::Automatic { cargo_options, ansi_color_output } => { - // Only use the rust-project.json's flycheck config when no check_overrideCommand - // is configured. In the FlycheckConcig::CustomCommand branch we will still do - // label substitution, but on the overrideCommand instead. - // - // There needs to be SOME way to override what your discoverConfig tool says, - // because to change the flycheck runnable there you may have to literally - // recompile the tool. - if self.config_json.any_configured() { - // Completely handle according to rust-project.json. - // We don't consider this to be "using cargo" so we will not apply any of the - // CargoOptions to the command. - let cmd = self.explicit_check_command(scope, saved_file)?; - return Some((cmd, FlycheckCommandOrigin::ProjectJsonRunnable)); - } - + FlycheckConfig::CargoCommand { command, options, ansi_color_output } => { let mut cmd = - toolchain::command(Tool::Cargo.path(), &*self.root, &cargo_options.extra_env); + toolchain::command(Tool::Cargo.path(), &*self.root, &options.extra_env); if let Some(sysroot_root) = &self.sysroot_root - && !cargo_options.extra_env.contains_key("RUSTUP_TOOLCHAIN") + && !options.extra_env.contains_key("RUSTUP_TOOLCHAIN") && std::env::var_os("RUSTUP_TOOLCHAIN").is_none() { cmd.env("RUSTUP_TOOLCHAIN", AsRef::::as_ref(sysroot_root)); } cmd.env("CARGO_LOG", "cargo::core::compiler::fingerprint=info"); - cmd.arg(&cargo_options.subcommand); + cmd.arg(command); match scope { FlycheckScope::Workspace => cmd.arg("--workspace"), - FlycheckScope::Package { - package: PackageSpecifier::Cargo { package_id }, - .. - } => cmd.arg("-p").arg(&package_id.repr), - FlycheckScope::Package { - package: PackageSpecifier::BuildInfo { .. }, .. - } => { - // No way to flycheck this single package. All we have is a build label. - // There's no way to really say whether this build label happens to be - // a cargo canonical name, so we won't try. - return None; - } + FlycheckScope::Package { package, .. } => cmd.arg("-p").arg(&package.repr), }; if let Some(tgt) = target { @@ -905,12 +695,12 @@ impl FlycheckActor { cmd.arg("--keep-going"); - cargo_options.apply_on_command( + options.apply_on_command( &mut cmd, self.ws_target_dir.as_ref().map(Utf8PathBuf::as_path), ); - cmd.args(&cargo_options.extra_args); - Some((cmd, FlycheckCommandOrigin::Cargo)) + cmd.args(&options.extra_args); + Some(cmd) } FlycheckConfig::CustomCommand { command, args, extra_env, invocation_strategy } => { let root = match invocation_strategy { @@ -920,25 +710,31 @@ impl FlycheckActor { &*self.root } }; - let runnable = project_json::Runnable { - program: command.clone(), - cwd: Utf8Path::to_owned(root.as_ref()), - args: args.clone(), - kind: project_json::RunnableKind::Flycheck, - }; + let mut cmd = toolchain::command(command, root, extra_env); - let label = match scope { - FlycheckScope::Workspace => None, - // We support substituting both build labels (e.g. buck, bazel) and cargo package ids. - // With cargo package ids, you get `cargo check -p path+file:///path/to/rust-analyzer/crates/hir#0.0.0`. - // That does work! - FlycheckScope::Package { package, .. } => Some(package.as_str()), - }; + // If the custom command has a $saved_file placeholder, and + // we're saving a file, replace the placeholder in the arguments. + if let Some(saved_file) = saved_file { + for arg in args { + if arg == SAVED_FILE_PLACEHOLDER { + cmd.arg(saved_file); + } else { + cmd.arg(arg); + } + } + } else { + for arg in args { + if arg == SAVED_FILE_PLACEHOLDER { + // The custom command has a $saved_file placeholder, + // but we had an IDE event that wasn't a file save. Do nothing. + return None; + } - let subs = Substitutions { label, saved_file: saved_file.map(|x| x.as_str()) }; - let cmd = subs.substitute(&runnable, extra_env)?; + cmd.arg(arg); + } + } - Some((cmd, FlycheckCommandOrigin::CheckOverrideCommand)) + Some(cmd) } } } @@ -950,18 +746,15 @@ impl FlycheckActor { } #[allow(clippy::large_enum_variant)] -enum CheckMessage { - /// A message from `cargo check`, including details like the path - /// to the relevant `Cargo.toml`. +enum CargoCheckMessage { CompilerArtifact(cargo_metadata::Artifact), - /// A diagnostic message from rustc itself. - Diagnostic { diagnostic: Diagnostic, package_id: Option }, + Diagnostic { diagnostic: Diagnostic, package_id: Option> }, } -struct CheckParser; +struct CargoCheckParser; -impl JsonLinesParser for CheckParser { - fn from_line(&self, line: &str, error: &mut String) -> Option { +impl JsonLinesParser for CargoCheckParser { + fn from_line(&self, line: &str, error: &mut String) -> Option { let mut deserializer = serde_json::Deserializer::from_str(line); deserializer.disable_recursion_limit(); if let Ok(message) = JsonMessage::deserialize(&mut deserializer) { @@ -969,20 +762,18 @@ impl JsonLinesParser for CheckParser { // Skip certain kinds of messages to only spend time on what's useful JsonMessage::Cargo(message) => match message { cargo_metadata::Message::CompilerArtifact(artifact) if !artifact.fresh => { - Some(CheckMessage::CompilerArtifact(artifact)) + Some(CargoCheckMessage::CompilerArtifact(artifact)) } cargo_metadata::Message::CompilerMessage(msg) => { - Some(CheckMessage::Diagnostic { + Some(CargoCheckMessage::Diagnostic { diagnostic: msg.message, - package_id: Some(PackageSpecifier::Cargo { - package_id: Arc::new(msg.package_id), - }), + package_id: Some(Arc::new(msg.package_id)), }) } _ => None, }, JsonMessage::Rustc(message) => { - Some(CheckMessage::Diagnostic { diagnostic: message, package_id: None }) + Some(CargoCheckMessage::Diagnostic { diagnostic: message, package_id: None }) } }; } @@ -992,7 +783,7 @@ impl JsonLinesParser for CheckParser { None } - fn from_eof(&self) -> Option { + fn from_eof(&self) -> Option { None } } @@ -1003,144 +794,3 @@ enum JsonMessage { Cargo(cargo_metadata::Message), Rustc(Diagnostic), } - -#[cfg(test)] -mod tests { - use super::*; - use ide_db::FxHashMap; - use itertools::Itertools; - use paths::Utf8Path; - use project_model::project_json; - - #[test] - fn test_substitutions() { - let label = ":label"; - let saved_file = "file.rs"; - - // Runnable says it needs both; you need both. - assert_eq!(test_substitute(None, None, "{label} {saved_file}").as_deref(), None); - assert_eq!(test_substitute(Some(label), None, "{label} {saved_file}").as_deref(), None); - assert_eq!( - test_substitute(None, Some(saved_file), "{label} {saved_file}").as_deref(), - None - ); - assert_eq!( - test_substitute(Some(label), Some(saved_file), "{label} {saved_file}").as_deref(), - Some("build :label file.rs") - ); - - // Only need label? only need label. - assert_eq!(test_substitute(None, None, "{label}").as_deref(), None); - assert_eq!(test_substitute(Some(label), None, "{label}").as_deref(), Some("build :label"),); - assert_eq!(test_substitute(None, Some(saved_file), "{label}").as_deref(), None,); - assert_eq!( - test_substitute(Some(label), Some(saved_file), "{label}").as_deref(), - Some("build :label"), - ); - - // Only need saved_file - assert_eq!(test_substitute(None, None, "{saved_file}").as_deref(), None); - assert_eq!(test_substitute(Some(label), None, "{saved_file}").as_deref(), None); - assert_eq!( - test_substitute(None, Some(saved_file), "{saved_file}").as_deref(), - Some("build file.rs") - ); - assert_eq!( - test_substitute(Some(label), Some(saved_file), "{saved_file}").as_deref(), - Some("build file.rs") - ); - - // Need neither - assert_eq!(test_substitute(None, None, "xxx").as_deref(), Some("build xxx")); - assert_eq!(test_substitute(Some(label), None, "xxx").as_deref(), Some("build xxx")); - assert_eq!(test_substitute(None, Some(saved_file), "xxx").as_deref(), Some("build xxx")); - assert_eq!( - test_substitute(Some(label), Some(saved_file), "xxx").as_deref(), - Some("build xxx") - ); - - // {label} mid-argument substitution - assert_eq!( - test_substitute(Some(label), None, "--label={label}").as_deref(), - Some("build --label=:label") - ); - - // {saved_file} mid-argument substitution - assert_eq!( - test_substitute(None, Some(saved_file), "--saved={saved_file}").as_deref(), - Some("build --saved=file.rs") - ); - - // $saved_file legacy support (no mid-argument substitution, we never supported that) - assert_eq!( - test_substitute(None, Some(saved_file), "$saved_file").as_deref(), - Some("build file.rs") - ); - - fn test_substitute( - label: Option<&str>, - saved_file: Option<&str>, - args: &str, - ) -> Option { - Substitutions { label, saved_file } - .substitute( - &project_json::Runnable { - program: "build".to_owned(), - args: Vec::from_iter(args.split_whitespace().map(ToOwned::to_owned)), - cwd: Utf8Path::new("/path").to_owned(), - kind: project_json::RunnableKind::Flycheck, - }, - &FxHashMap::default(), - ) - .map(|command| { - command.get_args().map(|x| x.to_string_lossy()).collect_vec().join(" ") - }) - .map(|args| format!("build {}", args)) - } - } - - #[test] - fn test_flycheck_config_display() { - let clippy = FlycheckConfig::Automatic { - cargo_options: CargoOptions { - subcommand: "clippy".to_owned(), - target_tuples: vec![], - all_targets: false, - set_test: false, - no_default_features: false, - all_features: false, - features: vec![], - extra_args: vec![], - extra_test_bin_args: vec![], - extra_env: FxHashMap::default(), - target_dir_config: TargetDirectoryConfig::default(), - }, - ansi_color_output: true, - }; - assert_eq!(clippy.to_string(), "cargo clippy"); - - let custom_dollar = FlycheckConfig::CustomCommand { - command: "check".to_owned(), - args: vec!["--input".to_owned(), "$saved_file".to_owned()], - extra_env: FxHashMap::default(), - invocation_strategy: InvocationStrategy::Once, - }; - assert_eq!(custom_dollar.to_string(), "check --input ..."); - - let custom_inline = FlycheckConfig::CustomCommand { - command: "check".to_owned(), - args: vec!["--input".to_owned(), "{saved_file}".to_owned()], - extra_env: FxHashMap::default(), - invocation_strategy: InvocationStrategy::Once, - }; - assert_eq!(custom_inline.to_string(), "check --input ..."); - - let custom_rs = FlycheckConfig::CustomCommand { - command: "check".to_owned(), - args: vec!["--input".to_owned(), "/path/to/file.rs".to_owned()], - extra_env: FxHashMap::default(), - invocation_strategy: InvocationStrategy::Once, - }; - assert_eq!(custom_rs.to_string(), "check --input ..."); - } -} diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs index afd4162de622..9beab3c0e45c 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs @@ -9,6 +9,7 @@ use std::{ time::{Duration, Instant}, }; +use cargo_metadata::PackageId; use crossbeam_channel::{Receiver, Sender, unbounded}; use hir::ChangeWithProcMacros; use ide::{Analysis, AnalysisHost, Cancellable, FileId, SourceRootId}; @@ -35,7 +36,7 @@ use crate::{ config::{Config, ConfigChange, ConfigErrors, RatomlFileKind}, diagnostics::{CheckFixes, DiagnosticCollection}, discover, - flycheck::{FlycheckHandle, FlycheckMessage, PackageSpecifier}, + flycheck::{FlycheckHandle, FlycheckMessage}, line_index::{LineEndings, LineIndex}, lsp::{from_proto, to_proto::url_from_abs_path}, lsp_ext, @@ -112,7 +113,6 @@ pub(crate) struct GlobalState { pub(crate) flycheck_sender: Sender, pub(crate) flycheck_receiver: Receiver, pub(crate) last_flycheck_error: Option, - pub(crate) flycheck_formatted_commands: Vec, // Test explorer pub(crate) test_run_session: Option>, @@ -188,7 +188,7 @@ pub(crate) struct GlobalState { /// been called. pub(crate) deferred_task_queue: DeferredTaskQueue, - /// HACK: Workaround for + /// HACK: Workaround for https://github.com/rust-lang/rust-analyzer/issues/19709 /// This is marked true if we failed to load a crate root file at crate graph creation, /// which will usually end up causing a bunch of incorrect diagnostics on startup. pub(crate) incomplete_crate_graph: bool, @@ -289,7 +289,6 @@ impl GlobalState { flycheck_sender, flycheck_receiver, last_flycheck_error: None, - flycheck_formatted_commands: vec![], test_run_session: None, test_run_sender, @@ -826,7 +825,7 @@ impl GlobalStateSnapshot { let Some(krate) = project.crate_by_root(path) else { continue; }; - let Some(build) = krate.build.clone() else { + let Some(build) = krate.build else { continue; }; @@ -834,7 +833,6 @@ impl GlobalStateSnapshot { label: build.label, target_kind: build.target_kind, shell_runnables: project.runnables().to_owned(), - project_root: project.project_root().to_owned(), })); } ProjectWorkspaceKind::DetachedFile { .. } => {} @@ -846,43 +844,23 @@ impl GlobalStateSnapshot { pub(crate) fn all_workspace_dependencies_for_package( &self, - package: &PackageSpecifier, - ) -> Option> { - match package { - PackageSpecifier::Cargo { package_id } => { - self.workspaces.iter().find_map(|workspace| match &workspace.kind { - ProjectWorkspaceKind::Cargo { cargo, .. } - | ProjectWorkspaceKind::DetachedFile { cargo: Some((cargo, _, _)), .. } => { - let package = cargo.packages().find(|p| cargo[*p].id == *package_id)?; + package: &Arc, + ) -> Option>> { + for workspace in self.workspaces.iter() { + match &workspace.kind { + ProjectWorkspaceKind::Cargo { cargo, .. } + | ProjectWorkspaceKind::DetachedFile { cargo: Some((cargo, _, _)), .. } => { + let package = cargo.packages().find(|p| cargo[*p].id == *package)?; - cargo[package].all_member_deps.as_ref().map(|deps| { - deps.iter() - .map(|dep| cargo[*dep].id.clone()) - .map(|p| PackageSpecifier::Cargo { package_id: p }) - .collect() - }) - } - _ => None, - }) - } - PackageSpecifier::BuildInfo { label } => { - self.workspaces.iter().find_map(|workspace| match &workspace.kind { - ProjectWorkspaceKind::Json(p) => { - let krate = p.crate_by_label(label)?; - Some( - krate - .iter_deps() - .filter_map(|dep| p[dep].build.as_ref()) - .map(|build| PackageSpecifier::BuildInfo { - label: build.label.clone(), - }) - .collect(), - ) - } - _ => None, - }) + return cargo[package] + .all_member_deps + .as_ref() + .map(|deps| deps.iter().map(|dep| cargo[*dep].id.clone()).collect()); + } + _ => {} } } + None } pub(crate) fn file_exists(&self, file_id: FileId) -> bool { diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/dispatch.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/dispatch.rs index 90deae2d902e..10bbb0bb31d9 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/dispatch.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/dispatch.rs @@ -101,7 +101,7 @@ impl RequestDispatcher<'_> { } /// Dispatches a non-latency-sensitive request onto the thread pool. When the VFS is marked not - /// ready this will return a default constructed `R::Result`. + /// ready this will return a default constructed [`R::Result`]. pub(crate) fn on( &mut self, f: fn(GlobalStateSnapshot, R::Params) -> anyhow::Result, @@ -128,7 +128,7 @@ impl RequestDispatcher<'_> { } /// Dispatches a non-latency-sensitive request onto the thread pool. When the VFS is marked not - /// ready this will return a `default` constructed `R::Result`. + /// ready this will return a `default` constructed [`R::Result`]. pub(crate) fn on_with_vfs_default( &mut self, f: fn(GlobalStateSnapshot, R::Params) -> anyhow::Result, @@ -176,7 +176,7 @@ impl RequestDispatcher<'_> { } /// Dispatches a latency-sensitive request onto the thread pool. When the VFS is marked not - /// ready this will return a default constructed `R::Result`. + /// ready this will return a default constructed [`R::Result`]. pub(crate) fn on_latency_sensitive( &mut self, f: fn(GlobalStateSnapshot, R::Params) -> anyhow::Result, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs index 138310b78f62..4a6544508ff4 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs @@ -18,7 +18,7 @@ use vfs::{AbsPathBuf, ChangeKind, VfsPath}; use crate::{ config::{Config, ConfigChange}, - flycheck::{InvocationStrategy, PackageSpecifier, Target}, + flycheck::{InvocationStrategy, Target}, global_state::{FetchWorkspaceRequest, GlobalState}, lsp::{from_proto, utils::apply_document_changes}, lsp_ext::{self, RunFlycheckParams}, @@ -289,24 +289,11 @@ pub(crate) fn handle_did_change_watched_files( state: &mut GlobalState, params: DidChangeWatchedFilesParams, ) -> anyhow::Result<()> { - // we want to trigger flycheck if a file outside of our workspaces has changed, - // as to reduce stale diagnostics when outside changes happen - let mut trigger_flycheck = false; for change in params.changes.iter().unique_by(|&it| &it.uri) { if let Ok(path) = from_proto::abs_path(&change.uri) { - if !trigger_flycheck { - trigger_flycheck = - state.config.workspace_roots().iter().any(|root| !path.starts_with(root)); - } state.loader.handle.invalidate(path); } } - - if trigger_flycheck && state.config.check_on_save(None) { - for flycheck in state.flycheck.iter() { - flycheck.restart_workspace(None); - } - } Ok(()) } @@ -341,33 +328,22 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { } InvocationStrategy::PerWorkspace => { Box::new(move || { - let saved_file = vfs_path.as_path().map(ToOwned::to_owned); - let target = TargetSpec::for_file(&world, file_id)?.map(|it| { + let target = TargetSpec::for_file(&world, file_id)?.and_then(|it| { let tgt_kind = it.target_kind(); let (tgt_name, root, package) = match it { - TargetSpec::Cargo(c) => ( - Some(c.target), - c.workspace_root, - PackageSpecifier::Cargo { package_id: c.package_id }, - ), - TargetSpec::ProjectJson(p) => ( - None, - p.project_root, - PackageSpecifier::BuildInfo { label: p.label.clone() }, - ), + TargetSpec::Cargo(c) => (c.target, c.workspace_root, c.package_id), + _ => return None, }; - let tgt = tgt_name.and_then(|tgt_name| { - Some(match tgt_kind { - project_model::TargetKind::Bin => Target::Bin(tgt_name), - project_model::TargetKind::Example => Target::Example(tgt_name), - project_model::TargetKind::Test => Target::Test(tgt_name), - project_model::TargetKind::Bench => Target::Benchmark(tgt_name), - _ => return None, - }) - }); + let tgt = match tgt_kind { + project_model::TargetKind::Bin => Target::Bin(tgt_name), + project_model::TargetKind::Example => Target::Example(tgt_name), + project_model::TargetKind::Test => Target::Test(tgt_name), + project_model::TargetKind::Bench => Target::Benchmark(tgt_name), + _ => return Some((None, root, package)), + }; - (tgt, root, package) + Some((Some(tgt), root, package)) }); tracing::debug!(?target, "flycheck target"); // we have a specific non-library target, attempt to only check that target, nothing @@ -376,10 +352,8 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { if let Some((target, root, package)) = target { // trigger a package check if we have a non-library target as that can't affect // anything else in the workspace OR if we're not allowed to check the workspace as - // the user opted into package checks then OR if this is not cargo. - let package_check_allowed = target.is_some() - || !may_flycheck_workspace - || matches!(package, PackageSpecifier::BuildInfo { .. }); + // the user opted into package checks then + let package_check_allowed = target.is_some() || !may_flycheck_workspace; if package_check_allowed { package_workspace_idx = world.workspaces.iter().position(|ws| match &ws.kind { @@ -391,30 +365,16 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { cargo: Some((cargo, _, _)), .. } => *cargo.workspace_root() == root, - project_model::ProjectWorkspaceKind::Json(p) => { - *p.project_root() == root - } - project_model::ProjectWorkspaceKind::DetachedFile { - cargo: None, - .. - } => false, + _ => false, }); if let Some(idx) = package_workspace_idx { - // flycheck handles are indexed by their ID (which is the workspace index), - // but not all workspaces have flycheck enabled (e.g., JSON projects without - // a flycheck template). Find the flycheck handle by its ID. - if let Some(flycheck) = - world.flycheck.iter().find(|fc| fc.id() == idx) - { - let workspace_deps = - world.all_workspace_dependencies_for_package(&package); - flycheck.restart_for_package( - package, - target, - workspace_deps, - saved_file.clone(), - ); - } + let workspace_deps = + world.all_workspace_dependencies_for_package(&package); + world.flycheck[idx].restart_for_package( + package, + target, + workspace_deps, + ); } } } @@ -484,6 +444,7 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { ws_contains_file && !is_pkg_ws }); + let saved_file = vfs_path.as_path().map(ToOwned::to_owned); let mut workspace_check_triggered = false; // Find and trigger corresponding flychecks 'flychecks: for flycheck in world.flycheck.iter() { diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/integrated_benchmarks.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/integrated_benchmarks.rs index d16ca2fb48ac..c61825b99fec 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/integrated_benchmarks.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/integrated_benchmarks.rs @@ -53,7 +53,6 @@ fn integrated_highlighting_benchmark() { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: false, - proc_macro_processes: 1, }; let (db, vfs, _proc_macro) = { @@ -122,7 +121,6 @@ fn integrated_completion_benchmark() { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: true, - proc_macro_processes: 1, }; let (db, vfs, _proc_macro) = { @@ -324,7 +322,6 @@ fn integrated_diagnostics_benchmark() { load_out_dirs_from_check: true, with_proc_macro_server: ProcMacroServerChoice::Sysroot, prefill_caches: true, - proc_macro_processes: 1, }; let (db, vfs, _proc_macro) = { diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs index e5b983dcbf85..6f0f57725fc7 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs @@ -70,7 +70,6 @@ pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind { | SymbolKind::Attribute | SymbolKind::Derive | SymbolKind::DeriveHelper => lsp_types::SymbolKind::FUNCTION, - SymbolKind::CrateRoot => lsp_types::SymbolKind::PACKAGE, SymbolKind::Module | SymbolKind::ToolModule => lsp_types::SymbolKind::MODULE, SymbolKind::TypeAlias | SymbolKind::TypeParam | SymbolKind::SelfType => { lsp_types::SymbolKind::TYPE_PARAMETER @@ -142,7 +141,6 @@ pub(crate) fn completion_item_kind( SymbolKind::Method => lsp_types::CompletionItemKind::METHOD, SymbolKind::Const => lsp_types::CompletionItemKind::CONSTANT, SymbolKind::ConstParam => lsp_types::CompletionItemKind::TYPE_PARAMETER, - SymbolKind::CrateRoot => lsp_types::CompletionItemKind::MODULE, SymbolKind::Derive => lsp_types::CompletionItemKind::FUNCTION, SymbolKind::DeriveHelper => lsp_types::CompletionItemKind::FUNCTION, SymbolKind::Enum => lsp_types::CompletionItemKind::ENUM, @@ -805,16 +803,11 @@ fn semantic_token_type_and_modifiers( ) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) { use semantic_tokens::{modifiers as mods, types}; - let mut mods = semantic_tokens::ModifierSet::default(); let ty = match highlight.tag { HlTag::Symbol(symbol) => match symbol { SymbolKind::Attribute => types::DECORATOR, SymbolKind::Derive => types::DERIVE, SymbolKind::DeriveHelper => types::DERIVE_HELPER, - SymbolKind::CrateRoot => { - mods |= mods::CRATE_ROOT; - types::NAMESPACE - } SymbolKind::Module => types::NAMESPACE, SymbolKind::Impl => types::TYPE_ALIAS, SymbolKind::Field => types::PROPERTY, @@ -877,6 +870,7 @@ fn semantic_token_type_and_modifiers( }, }; + let mut mods = semantic_tokens::ModifierSet::default(); for modifier in highlight.mods.iter() { let modifier = match modifier { HlMod::Associated => mods::ASSOCIATED, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs index 64decc9e0db6..dd0813c14454 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs @@ -309,10 +309,10 @@ impl GlobalState { let event_dbg_msg = format!("{event:?}"); tracing::debug!(?loop_start, ?event, "handle_event"); - if tracing::enabled!(tracing::Level::TRACE) { + if tracing::enabled!(tracing::Level::INFO) { let task_queue_len = self.task_pool.handle.len(); if task_queue_len > 0 { - tracing::trace!("task queue len: {}", task_queue_len); + tracing::info!("task queue len: {}", task_queue_len); } } @@ -666,33 +666,31 @@ impl GlobalState { move |sender| { // We aren't observing the semantics token cache here let snapshot = AssertUnwindSafe(&snapshot); - let diags = std::panic::catch_unwind(|| { + let Ok(diags) = std::panic::catch_unwind(|| { fetch_native_diagnostics( &snapshot, subscriptions.clone(), slice.clone(), NativeDiagnosticsFetchKind::Syntax, ) - }) - .unwrap_or_else(|_| { - subscriptions.iter().map(|&id| (id, Vec::new())).collect::>() - }); + }) else { + return; + }; sender .send(Task::Diagnostics(DiagnosticsTaskKind::Syntax(generation, diags))) .unwrap(); if fetch_semantic { - let diags = std::panic::catch_unwind(|| { + let Ok(diags) = std::panic::catch_unwind(|| { fetch_native_diagnostics( &snapshot, subscriptions.clone(), slice.clone(), NativeDiagnosticsFetchKind::Semantic, ) - }) - .unwrap_or_else(|_| { - subscriptions.iter().map(|&id| (id, Vec::new())).collect::>() - }); + }) else { + return; + }; sender .send(Task::Diagnostics(DiagnosticsTaskKind::Semantic( generation, diags, @@ -827,29 +825,33 @@ impl GlobalState { } Task::DiscoverLinkedProjects(arg) => { if let Some(cfg) = self.config.discover_workspace_config() { + // the clone is unfortunately necessary to avoid a borrowck error when + // `self.report_progress` is called later + let title = &cfg.progress_label.clone(); let command = cfg.command.clone(); let discover = DiscoverCommand::new(self.discover_sender.clone(), command); + if self.discover_jobs_active == 0 { + self.report_progress(title, Progress::Begin, None, None, None); + } + self.discover_jobs_active += 1; + let arg = match arg { DiscoverProjectParam::Buildfile(it) => DiscoverArgument::Buildfile(it), DiscoverProjectParam::Path(it) => DiscoverArgument::Path(it), }; - match discover.spawn(arg, self.config.root_path().as_ref()) { - Ok(handle) => { - if self.discover_jobs_active == 0 { - let title = &cfg.progress_label.clone(); - self.report_progress(title, Progress::Begin, None, None, None); - } - self.discover_jobs_active += 1; - self.discover_handles.push(handle) - } - Err(e) => self.show_message( - lsp_types::MessageType::ERROR, - format!("Failed to spawn project discovery command: {e:#}"), - false, - ), - } + let handle = discover + .spawn( + arg, + &std::env::current_dir() + .expect("Failed to get cwd during project discovery"), + ) + .unwrap_or_else(|e| { + panic!("Failed to spawn project discovery command: {e}") + }); + + self.discover_handles.push(handle); } } Task::FetchBuildData(progress) => { @@ -1177,24 +1179,8 @@ impl GlobalState { kind: ClearDiagnosticsKind::OlderThan(generation, ClearScope::Package(package_id)), } => self.diagnostics.clear_check_older_than_for_package(id, package_id, generation), FlycheckMessage::Progress { id, progress } => { - let format_with_id = |user_facing_command: String| { - if self.flycheck.len() == 1 { - user_facing_command - } else { - format!("{user_facing_command} (#{})", id + 1) - } - }; - - self.flycheck_formatted_commands - .resize_with(self.flycheck.len().max(id + 1), || { - format_with_id(self.config.flycheck(None).to_string()) - }); - let (state, message) = match progress { - flycheck::Progress::DidStart { user_facing_command } => { - self.flycheck_formatted_commands[id] = format_with_id(user_facing_command); - (Progress::Begin, None) - } + flycheck::Progress::DidStart => (Progress::Begin, None), flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)), flycheck::Progress::DidCancel => { self.last_flycheck_error = None; @@ -1214,8 +1200,13 @@ impl GlobalState { } }; - // Clone because we &mut self for report_progress - let title = self.flycheck_formatted_commands[id].clone(); + // When we're running multiple flychecks, we have to include a disambiguator in + // the title, or the editor complains. Note that this is a user-facing string. + let title = if self.flycheck.len() == 1 { + format!("{}", self.config.flycheck(None)) + } else { + format!("{} (#{})", self.config.flycheck(None), id + 1) + }; self.report_progress( &title, state, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs index 83f4a19b39fa..e3a5ee221973 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs @@ -25,9 +25,7 @@ use load_cargo::{ProjectFolders, load_proc_macro}; use lsp_types::FileSystemWatcher; use paths::Utf8Path; use proc_macro_api::ProcMacroClient; -use project_model::{ - ManifestPath, ProjectWorkspace, ProjectWorkspaceKind, WorkspaceBuildScripts, project_json, -}; +use project_model::{ManifestPath, ProjectWorkspace, ProjectWorkspaceKind, WorkspaceBuildScripts}; use stdx::{format_to, thread::ThreadIntent}; use triomphe::Arc; use vfs::{AbsPath, AbsPathBuf, ChangeKind}; @@ -701,19 +699,15 @@ impl GlobalState { _ => Default::default(), }; info!("Using proc-macro server at {path}"); - let num_process = self.config.proc_macro_num_processes(); - Some( - ProcMacroClient::spawn(&path, &env, ws.toolchain.as_ref(), num_process) - .map_err(|err| { - tracing::error!( - "Failed to run proc-macro server from path {path}, error: {err:?}", - ); - anyhow::format_err!( - "Failed to run proc-macro server from path {path}, error: {err:?}", - ) - }), - ) + Some(ProcMacroClient::spawn(&path, &env, ws.toolchain.as_ref()).map_err(|err| { + tracing::error!( + "Failed to run proc-macro server from path {path}, error: {err:?}", + ); + anyhow::format_err!( + "Failed to run proc-macro server from path {path}, error: {err:?}", + ) + })) })) } @@ -881,7 +875,6 @@ impl GlobalState { generation.clone(), sender.clone(), config, - crate::flycheck::FlycheckConfigJson::default(), None, self.config.root_path().clone(), None, @@ -901,25 +894,16 @@ impl GlobalState { cargo: Some((cargo, _, _)), .. } => ( - crate::flycheck::FlycheckConfigJson::default(), cargo.workspace_root(), Some(cargo.manifest_path()), Some(cargo.target_directory()), ), ProjectWorkspaceKind::Json(project) => { - let config_json = crate::flycheck::FlycheckConfigJson { - single_template: project - .runnable_template(project_json::RunnableKind::Flycheck) - .cloned(), - }; // Enable flychecks for json projects if a custom flycheck command was supplied // in the workspace configuration. match config { - _ if config_json.any_configured() => { - (config_json, project.path(), None, None) - } FlycheckConfig::CustomCommand { .. } => { - (config_json, project.path(), None, None) + (project.path(), None, None) } _ => return None, } @@ -929,13 +913,12 @@ impl GlobalState { ws.sysroot.root().map(ToOwned::to_owned), )) }) - .map(|(id, (config_json, root, manifest_path, target_dir), sysroot_root)| { + .map(|(id, (root, manifest_path, target_dir), sysroot_root)| { FlycheckHandle::spawn( id, generation.clone(), sender.clone(), config.clone(), - config_json, sysroot_root, root.to_path_buf(), manifest_path.map(|it| it.to_path_buf()), @@ -946,7 +929,6 @@ impl GlobalState { } } .into(); - self.flycheck_formatted_commands = vec![]; } } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/target_spec.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/target_spec.rs index b8d9acc02a32..e0f95a7830ea 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/target_spec.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/target_spec.rs @@ -68,7 +68,6 @@ pub(crate) struct ProjectJsonTargetSpec { pub(crate) label: String, pub(crate) target_kind: TargetKind, pub(crate) shell_runnables: Vec, - pub(crate) project_root: AbsPathBuf, } impl ProjectJsonTargetSpec { @@ -77,16 +76,7 @@ impl ProjectJsonTargetSpec { RunnableKind::Bin => { for runnable in &self.shell_runnables { if matches!(runnable.kind, project_model::project_json::RunnableKind::Run) { - let mut runnable = runnable.clone(); - - let replaced_args: Vec<_> = runnable - .args - .iter() - .map(|arg| arg.replace("{label}", &self.label)) - .collect(); - runnable.args = replaced_args; - - return Some(runnable); + return Some(runnable.clone()); } } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/task_pool.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/task_pool.rs index 104cd3d2eae9..8b8876b801cf 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/task_pool.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/task_pool.rs @@ -52,7 +52,7 @@ impl TaskPool { /// `DeferredTaskQueue` holds deferred tasks. /// /// These are tasks that must be run after -/// `GlobalState::process_changes` has been called. +/// [`GlobalState::process_changes`] has been called. pub(crate) struct DeferredTaskQueue { pub(crate) sender: crossbeam_channel::Sender, pub(crate) receiver: crossbeam_channel::Receiver, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/test_runner.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/test_runner.rs index 0d9c8310d858..7111a15d0246 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/test_runner.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/test_runner.rs @@ -101,11 +101,11 @@ impl CargoTestHandle { ws_target_dir: Option<&Utf8Path>, test_target: TestTarget, sender: Sender, - ) -> anyhow::Result { + ) -> std::io::Result { let mut cmd = toolchain::command(Tool::Cargo.path(), root, &options.extra_env); cmd.env("RUSTC_BOOTSTRAP", "1"); cmd.arg("--color=always"); - cmd.arg(&options.subcommand); // test, usually + cmd.arg("test"); cmd.arg("--package"); cmd.arg(&test_target.package); diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs index b4a7b44d165a..eb1b8c5dd0e6 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs @@ -1447,27 +1447,7 @@ foo = { path = "../foo" } .server() .wait_until_workspace_is_loaded(); - server.request::( - Default::default(), - json!([ - { - "name": "bar", - "kind": 4, - "location": { - "uri": "file:///[..]bar/src/lib.rs", - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - } - } - }]), - ); + server.request::(Default::default(), json!([])); let server = Project::with_fixture( r#" @@ -1506,27 +1486,7 @@ version = "0.0.0" .server() .wait_until_workspace_is_loaded(); - server.request::( - Default::default(), - json!([ - { - "name": "baz", - "kind": 4, - "location": { - "uri": "file:///[..]baz/src/lib.rs", - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - } - } - }]), - ); + server.request::(Default::default(), json!([])); } #[test] diff --git a/src/tools/rust-analyzer/crates/span/src/ast_id.rs b/src/tools/rust-analyzer/crates/span/src/ast_id.rs index f52604e13917..599b3c717522 100644 --- a/src/tools/rust-analyzer/crates/span/src/ast_id.rs +++ b/src/tools/rust-analyzer/crates/span/src/ast_id.rs @@ -88,6 +88,7 @@ impl fmt::Debug for ErasedFileAstId { Module, Static, Trait, + TraitAlias, Variant, Const, Fn, @@ -128,6 +129,7 @@ enum ErasedFileAstIdKind { Module, Static, Trait, + TraitAlias, // Until here associated with `ErasedHasNameFileAstId`. // The following are associated with `ErasedAssocItemFileAstId`. Variant, diff --git a/src/tools/rust-analyzer/crates/span/src/hygiene.rs b/src/tools/rust-analyzer/crates/span/src/hygiene.rs index fe05ef946518..fdfa94dfee4e 100644 --- a/src/tools/rust-analyzer/crates/span/src/hygiene.rs +++ b/src/tools/rust-analyzer/crates/span/src/hygiene.rs @@ -8,9 +8,9 @@ //! //! # The Expansion Order Hierarchy //! -//! `ExpnData` in rustc, rust-analyzer's version is `MacroCallLoc`. Traversing the hierarchy -//! upwards can be achieved by walking up `MacroCallLoc::kind`'s contained file id, as -//! `MacroFile`s are interned `MacroCallLoc`s. +//! `ExpnData` in rustc, rust-analyzer's version is [`MacroCallLoc`]. Traversing the hierarchy +//! upwards can be achieved by walking up [`MacroCallLoc::kind`]'s contained file id, as +//! [`MacroFile`]s are interned [`MacroCallLoc`]s. //! //! # The Macro Definition Hierarchy //! @@ -18,7 +18,7 @@ //! //! # The Call-site Hierarchy //! -//! `ExpnData::call_site` in rustc, `MacroCallLoc::call_site` in rust-analyzer. +//! `ExpnData::call_site` in rustc, [`MacroCallLoc::call_site`] in rust-analyzer. use crate::Edition; use std::fmt; @@ -241,7 +241,9 @@ const _: () = { edition: zalsa_::interned::Lookup::into_owned(data.2), parent: zalsa_::interned::Lookup::into_owned(data.3), opaque: opaque(zalsa_::FromId::from_id(id)), - opaque_and_semiopaque: opaque_and_semiopaque(zalsa_::FromId::from_id(id)), + opaque_and_semiopaque: opaque_and_semiopaque( + zalsa_::FromId::from_id(id), + ), }, ) } diff --git a/src/tools/rust-analyzer/crates/stdx/src/process.rs b/src/tools/rust-analyzer/crates/stdx/src/process.rs index 7c4ae978b04a..2efeed45e44e 100644 --- a/src/tools/rust-analyzer/crates/stdx/src/process.rs +++ b/src/tools/rust-analyzer/crates/stdx/src/process.rs @@ -76,7 +76,7 @@ pub fn spawn_with_streaming_output( Ok(Output { status, stdout, stderr }) } -#[cfg(all(unix, not(target_arch = "wasm32")))] +#[cfg(unix)] mod imp { use std::{ io::{self, prelude::*}, diff --git a/src/tools/rust-analyzer/crates/syntax/rust.ungram b/src/tools/rust-analyzer/crates/syntax/rust.ungram index 544053408f73..991fe7d83a0e 100644 --- a/src/tools/rust-analyzer/crates/syntax/rust.ungram +++ b/src/tools/rust-analyzer/crates/syntax/rust.ungram @@ -472,11 +472,8 @@ RefExpr = TryExpr = Attr* Expr '?' -TryBlockModifier = - 'try' ('bikeshed' Type)? - BlockExpr = - Attr* Label? (TryBlockModifier | 'unsafe' | ('async' 'move'?) | ('gen' 'move'?) | 'const') StmtList + Attr* Label? ('try' | 'unsafe' | ('async' 'move'?) | ('gen' 'move'?) | 'const') StmtList PrefixExpr = Attr* op:('-' | '!' | '*') Expr diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/edit_in_place.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/edit_in_place.rs index 2b7dc5cd76ab..1cd8146f6863 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/edit_in_place.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/edit_in_place.rs @@ -9,9 +9,8 @@ use crate::{ SyntaxKind::{ATTR, COMMENT, WHITESPACE}, SyntaxNode, SyntaxToken, algo::{self, neighbor}, - ast::{self, HasGenericParams, edit::IndentLevel, make, syntax_factory::SyntaxFactory}, - syntax_editor::{Position, SyntaxEditor}, - ted, + ast::{self, HasGenericParams, edit::IndentLevel, make}, + ted::{self, Position}, }; use super::{GenericParam, HasName}; @@ -27,13 +26,13 @@ impl GenericParamsOwnerEdit for ast::Fn { Some(it) => it, None => { let position = if let Some(name) = self.name() { - ted::Position::after(name.syntax) + Position::after(name.syntax) } else if let Some(fn_token) = self.fn_token() { - ted::Position::after(fn_token) + Position::after(fn_token) } else if let Some(param_list) = self.param_list() { - ted::Position::before(param_list.syntax) + Position::before(param_list.syntax) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_generic_param_list(position) } @@ -43,11 +42,11 @@ impl GenericParamsOwnerEdit for ast::Fn { fn get_or_create_where_clause(&self) -> ast::WhereClause { if self.where_clause().is_none() { let position = if let Some(ty) = self.ret_type() { - ted::Position::after(ty.syntax()) + Position::after(ty.syntax()) } else if let Some(param_list) = self.param_list() { - ted::Position::after(param_list.syntax()) + Position::after(param_list.syntax()) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_where_clause(position); } @@ -61,8 +60,8 @@ impl GenericParamsOwnerEdit for ast::Impl { Some(it) => it, None => { let position = match self.impl_token() { - Some(imp_token) => ted::Position::after(imp_token), - None => ted::Position::last_child_of(self.syntax()), + Some(imp_token) => Position::after(imp_token), + None => Position::last_child_of(self.syntax()), }; create_generic_param_list(position) } @@ -72,8 +71,8 @@ impl GenericParamsOwnerEdit for ast::Impl { fn get_or_create_where_clause(&self) -> ast::WhereClause { if self.where_clause().is_none() { let position = match self.assoc_item_list() { - Some(items) => ted::Position::before(items.syntax()), - None => ted::Position::last_child_of(self.syntax()), + Some(items) => Position::before(items.syntax()), + None => Position::last_child_of(self.syntax()), }; create_where_clause(position); } @@ -87,11 +86,11 @@ impl GenericParamsOwnerEdit for ast::Trait { Some(it) => it, None => { let position = if let Some(name) = self.name() { - ted::Position::after(name.syntax) + Position::after(name.syntax) } else if let Some(trait_token) = self.trait_token() { - ted::Position::after(trait_token) + Position::after(trait_token) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_generic_param_list(position) } @@ -101,9 +100,9 @@ impl GenericParamsOwnerEdit for ast::Trait { fn get_or_create_where_clause(&self) -> ast::WhereClause { if self.where_clause().is_none() { let position = match (self.assoc_item_list(), self.semicolon_token()) { - (Some(items), _) => ted::Position::before(items.syntax()), - (_, Some(tok)) => ted::Position::before(tok), - (None, None) => ted::Position::last_child_of(self.syntax()), + (Some(items), _) => Position::before(items.syntax()), + (_, Some(tok)) => Position::before(tok), + (None, None) => Position::last_child_of(self.syntax()), }; create_where_clause(position); } @@ -117,11 +116,11 @@ impl GenericParamsOwnerEdit for ast::TypeAlias { Some(it) => it, None => { let position = if let Some(name) = self.name() { - ted::Position::after(name.syntax) + Position::after(name.syntax) } else if let Some(trait_token) = self.type_token() { - ted::Position::after(trait_token) + Position::after(trait_token) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_generic_param_list(position) } @@ -131,10 +130,10 @@ impl GenericParamsOwnerEdit for ast::TypeAlias { fn get_or_create_where_clause(&self) -> ast::WhereClause { if self.where_clause().is_none() { let position = match self.eq_token() { - Some(tok) => ted::Position::before(tok), + Some(tok) => Position::before(tok), None => match self.semicolon_token() { - Some(tok) => ted::Position::before(tok), - None => ted::Position::last_child_of(self.syntax()), + Some(tok) => Position::before(tok), + None => Position::last_child_of(self.syntax()), }, }; create_where_clause(position); @@ -149,11 +148,11 @@ impl GenericParamsOwnerEdit for ast::Struct { Some(it) => it, None => { let position = if let Some(name) = self.name() { - ted::Position::after(name.syntax) + Position::after(name.syntax) } else if let Some(struct_token) = self.struct_token() { - ted::Position::after(struct_token) + Position::after(struct_token) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_generic_param_list(position) } @@ -167,13 +166,13 @@ impl GenericParamsOwnerEdit for ast::Struct { ast::FieldList::TupleFieldList(it) => Some(it), }); let position = if let Some(tfl) = tfl { - ted::Position::after(tfl.syntax()) + Position::after(tfl.syntax()) } else if let Some(gpl) = self.generic_param_list() { - ted::Position::after(gpl.syntax()) + Position::after(gpl.syntax()) } else if let Some(name) = self.name() { - ted::Position::after(name.syntax()) + Position::after(name.syntax()) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_where_clause(position); } @@ -187,11 +186,11 @@ impl GenericParamsOwnerEdit for ast::Enum { Some(it) => it, None => { let position = if let Some(name) = self.name() { - ted::Position::after(name.syntax) + Position::after(name.syntax) } else if let Some(enum_token) = self.enum_token() { - ted::Position::after(enum_token) + Position::after(enum_token) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_generic_param_list(position) } @@ -201,11 +200,11 @@ impl GenericParamsOwnerEdit for ast::Enum { fn get_or_create_where_clause(&self) -> ast::WhereClause { if self.where_clause().is_none() { let position = if let Some(gpl) = self.generic_param_list() { - ted::Position::after(gpl.syntax()) + Position::after(gpl.syntax()) } else if let Some(name) = self.name() { - ted::Position::after(name.syntax()) + Position::after(name.syntax()) } else { - ted::Position::last_child_of(self.syntax()) + Position::last_child_of(self.syntax()) }; create_where_clause(position); } @@ -213,12 +212,12 @@ impl GenericParamsOwnerEdit for ast::Enum { } } -fn create_where_clause(position: ted::Position) { +fn create_where_clause(position: Position) { let where_clause = make::where_clause(empty()).clone_for_update(); ted::insert(position, where_clause.syntax()); } -fn create_generic_param_list(position: ted::Position) -> ast::GenericParamList { +fn create_generic_param_list(position: Position) -> ast::GenericParamList { let gpl = make::generic_param_list(empty()).clone_for_update(); ted::insert_raw(position, gpl.syntax()); gpl @@ -254,7 +253,7 @@ impl ast::GenericParamList { pub fn add_generic_param(&self, generic_param: ast::GenericParam) { match self.generic_params().last() { Some(last_param) => { - let position = ted::Position::after(last_param.syntax()); + let position = Position::after(last_param.syntax()); let elements = vec![ make::token(T![,]).into(), make::tokens::single_space().into(), @@ -263,7 +262,7 @@ impl ast::GenericParamList { ted::insert_all(position, elements); } None => { - let after_l_angle = ted::Position::after(self.l_angle_token().unwrap()); + let after_l_angle = Position::after(self.l_angle_token().unwrap()); ted::insert(after_l_angle, generic_param.syntax()); } } @@ -413,7 +412,7 @@ impl ast::UseTree { match self.use_tree_list() { Some(it) => it, None => { - let position = ted::Position::last_child_of(self.syntax()); + let position = Position::last_child_of(self.syntax()); let use_tree_list = make::use_tree_list(empty()).clone_for_update(); let mut elements = Vec::with_capacity(2); if self.coloncolon_token().is_none() { @@ -459,7 +458,7 @@ impl ast::UseTree { // Next, transform 'suffix' use tree into 'prefix::{suffix}' let subtree = self.clone_subtree().clone_for_update(); ted::remove_all_iter(self.syntax().children_with_tokens()); - ted::insert(ted::Position::first_child_of(self.syntax()), prefix.syntax()); + ted::insert(Position::first_child_of(self.syntax()), prefix.syntax()); self.get_or_create_use_tree_list().add_use_tree(subtree); fn split_path_prefix(prefix: &ast::Path) -> Option<()> { @@ -508,7 +507,7 @@ impl ast::UseTreeList { pub fn add_use_tree(&self, use_tree: ast::UseTree) { let (position, elements) = match self.use_trees().last() { Some(last_tree) => ( - ted::Position::after(last_tree.syntax()), + Position::after(last_tree.syntax()), vec![ make::token(T![,]).into(), make::tokens::single_space().into(), @@ -517,8 +516,8 @@ impl ast::UseTreeList { ), None => { let position = match self.l_curly_token() { - Some(l_curly) => ted::Position::after(l_curly), - None => ted::Position::last_child_of(self.syntax()), + Some(l_curly) => Position::after(l_curly), + None => Position::last_child_of(self.syntax()), }; (position, vec![use_tree.syntax.into()]) } @@ -583,15 +582,15 @@ impl ast::AssocItemList { let (indent, position, whitespace) = match self.assoc_items().last() { Some(last_item) => ( IndentLevel::from_node(last_item.syntax()), - ted::Position::after(last_item.syntax()), + Position::after(last_item.syntax()), "\n\n", ), None => match self.l_curly_token() { Some(l_curly) => { normalize_ws_between_braces(self.syntax()); - (IndentLevel::from_token(&l_curly) + 1, ted::Position::after(&l_curly), "\n") + (IndentLevel::from_token(&l_curly) + 1, Position::after(&l_curly), "\n") } - None => (IndentLevel::single(), ted::Position::last_child_of(self.syntax()), "\n"), + None => (IndentLevel::single(), Position::last_child_of(self.syntax()), "\n"), }, }; let elements: Vec = vec![ @@ -619,17 +618,17 @@ impl ast::RecordExprFieldList { let position = match self.fields().last() { Some(last_field) => { let comma = get_or_insert_comma_after(last_field.syntax()); - ted::Position::after(comma) + Position::after(comma) } None => match self.l_curly_token() { - Some(it) => ted::Position::after(it), - None => ted::Position::last_child_of(self.syntax()), + Some(it) => Position::after(it), + None => Position::last_child_of(self.syntax()), }, }; ted::insert_all(position, vec![whitespace.into(), field.syntax().clone().into()]); if is_multiline { - ted::insert(ted::Position::after(field.syntax()), ast::make::token(T![,])); + ted::insert(Position::after(field.syntax()), ast::make::token(T![,])); } } } @@ -657,7 +656,7 @@ impl ast::RecordExprField { ast::make::tokens::single_space().into(), expr.syntax().clone().into(), ]; - ted::insert_all_raw(ted::Position::last_child_of(self.syntax()), children); + ted::insert_all_raw(Position::last_child_of(self.syntax()), children); } } } @@ -680,17 +679,17 @@ impl ast::RecordPatFieldList { Some(last_field) => { let syntax = last_field.syntax(); let comma = get_or_insert_comma_after(syntax); - ted::Position::after(comma) + Position::after(comma) } None => match self.l_curly_token() { - Some(it) => ted::Position::after(it), - None => ted::Position::last_child_of(self.syntax()), + Some(it) => Position::after(it), + None => Position::last_child_of(self.syntax()), }, }; ted::insert_all(position, vec![whitespace.into(), field.syntax().clone().into()]); if is_multiline { - ted::insert(ted::Position::after(field.syntax()), ast::make::token(T![,])); + ted::insert(Position::after(field.syntax()), ast::make::token(T![,])); } } } @@ -704,7 +703,7 @@ fn get_or_insert_comma_after(syntax: &SyntaxNode) -> SyntaxToken { Some(it) => it, None => { let comma = ast::make::token(T![,]); - ted::insert(ted::Position::after(syntax), &comma); + ted::insert(Position::after(syntax), &comma); comma } } @@ -729,7 +728,7 @@ fn normalize_ws_between_braces(node: &SyntaxNode) -> Option<()> { } } Some(ws) if ws.kind() == T!['}'] => { - ted::insert(ted::Position::after(l), make::tokens::whitespace(&format!("\n{indent}"))); + ted::insert(Position::after(l), make::tokens::whitespace(&format!("\n{indent}"))); } _ => (), } @@ -781,56 +780,6 @@ impl ast::IdentPat { } } } - - pub fn set_pat_with_editor( - &self, - pat: Option, - syntax_editor: &mut SyntaxEditor, - syntax_factory: &SyntaxFactory, - ) { - match pat { - None => { - if let Some(at_token) = self.at_token() { - // Remove `@ Pat` - let start = at_token.clone().into(); - let end = self - .pat() - .map(|it| it.syntax().clone().into()) - .unwrap_or_else(|| at_token.into()); - syntax_editor.delete_all(start..=end); - - // Remove any trailing ws - if let Some(last) = - self.syntax().last_token().filter(|it| it.kind() == WHITESPACE) - { - last.detach(); - } - } - } - Some(pat) => { - if let Some(old_pat) = self.pat() { - // Replace existing pattern - syntax_editor.replace(old_pat.syntax(), pat.syntax()) - } else if let Some(at_token) = self.at_token() { - // Have an `@` token but not a pattern yet - syntax_editor.insert(Position::after(at_token), pat.syntax()); - } else { - // Don't have an `@`, should have a name - let name = self.name().unwrap(); - - syntax_editor.insert_all( - Position::after(name.syntax()), - vec![ - syntax_factory.whitespace(" ").into(), - syntax_factory.token(T![@]).into(), - syntax_factory.whitespace(" ").into(), - pat.syntax().clone().into(), - ], - ) - } - } - } - } } pub trait HasVisibilityEdit: ast::HasVisibility { diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/expr_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/expr_ext.rs index b44150f86842..db6699538138 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/expr_ext.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/expr_ext.rs @@ -375,11 +375,7 @@ impl ast::Literal { pub enum BlockModifier { Async(SyntaxToken), Unsafe(SyntaxToken), - Try { - try_token: SyntaxToken, - bikeshed_token: Option, - result_type: Option, - }, + Try(SyntaxToken), Const(SyntaxToken), AsyncGen(SyntaxToken), Gen(SyntaxToken), @@ -398,13 +394,7 @@ impl ast::BlockExpr { }) .or_else(|| self.async_token().map(BlockModifier::Async)) .or_else(|| self.unsafe_token().map(BlockModifier::Unsafe)) - .or_else(|| { - let modifier = self.try_block_modifier()?; - let try_token = modifier.try_token()?; - let bikeshed_token = modifier.bikeshed_token(); - let result_type = modifier.ty(); - Some(BlockModifier::Try { try_token, bikeshed_token, result_type }) - }) + .or_else(|| self.try_token().map(BlockModifier::Try)) .or_else(|| self.const_token().map(BlockModifier::Const)) .or_else(|| self.label().map(BlockModifier::Label)) } diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs index c4e72eafa793..7b9f5b9166bb 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs @@ -323,8 +323,6 @@ impl BlockExpr { #[inline] pub fn stmt_list(&self) -> Option { support::child(&self.syntax) } #[inline] - pub fn try_block_modifier(&self) -> Option { support::child(&self.syntax) } - #[inline] pub fn async_token(&self) -> Option { support::token(&self.syntax, T![async]) } #[inline] pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } @@ -333,6 +331,8 @@ impl BlockExpr { #[inline] pub fn move_token(&self) -> Option { support::token(&self.syntax, T![move]) } #[inline] + pub fn try_token(&self) -> Option { support::token(&self.syntax, T![try]) } + #[inline] pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } } pub struct BoxPat { @@ -1630,19 +1630,6 @@ impl Trait { #[inline] pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } } -pub struct TryBlockModifier { - pub(crate) syntax: SyntaxNode, -} -impl TryBlockModifier { - #[inline] - pub fn ty(&self) -> Option { support::child(&self.syntax) } - #[inline] - pub fn bikeshed_token(&self) -> Option { - support::token(&self.syntax, T![bikeshed]) - } - #[inline] - pub fn try_token(&self) -> Option { support::token(&self.syntax, T![try]) } -} pub struct TryExpr { pub(crate) syntax: SyntaxNode, } @@ -6333,38 +6320,6 @@ impl fmt::Debug for Trait { f.debug_struct("Trait").field("syntax", &self.syntax).finish() } } -impl AstNode for TryBlockModifier { - #[inline] - fn kind() -> SyntaxKind - where - Self: Sized, - { - TRY_BLOCK_MODIFIER - } - #[inline] - fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_MODIFIER } - #[inline] - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } - } - #[inline] - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -impl hash::Hash for TryBlockModifier { - fn hash(&self, state: &mut H) { self.syntax.hash(state); } -} -impl Eq for TryBlockModifier {} -impl PartialEq for TryBlockModifier { - fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax } -} -impl Clone for TryBlockModifier { - fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } } -} -impl fmt::Debug for TryBlockModifier { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("TryBlockModifier").field("syntax", &self.syntax).finish() - } -} impl AstNode for TryExpr { #[inline] fn kind() -> SyntaxKind @@ -10024,11 +9979,6 @@ impl std::fmt::Display for Trait { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TryBlockModifier { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for TryExpr { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/prec.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/prec.rs index d99cf492616e..8c88224a761a 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/prec.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/prec.rs @@ -154,11 +154,6 @@ fn check_ancestry(ancestor: &SyntaxNode, descendent: &SyntaxNode) -> bool { bail() } -fn next_token_of(node: &SyntaxNode) -> Option { - let last = node.last_token()?; - skip_trivia_token(last.next_token()?, Direction::Next) -} - impl Expr { pub fn precedence(&self) -> ExprPrecedence { precedence(self) @@ -202,8 +197,6 @@ impl Expr { if is_parent_call_expr && is_field_expr { return true; } - let place_of_parent = - || place_of.ancestors().find(|it| it.parent().is_none_or(|p| &p == parent.syntax())); // Special-case block weirdness if parent.child_is_followed_by_a_block() { @@ -233,24 +226,15 @@ impl Expr { // For `&&`, we avoid introducing ` && ` into a binary chain. if self.precedence() == ExprPrecedence::Jump - && let Some(node) = place_of_parent() - && let Some(next) = next_token_of(&node) + && let Some(node) = + place_of.ancestors().find(|it| it.parent().is_none_or(|p| &p == parent.syntax())) + && let Some(next) = + node.last_token().and_then(|t| skip_trivia_token(t.next_token()?, Direction::Next)) && matches!(next.kind(), T![||] | T![&&]) { return true; } - // Special-case `2 as x < 3` - if let ast::Expr::CastExpr(it) = self - && let Some(ty) = it.ty() - && ty.syntax().last_token().and_then(|it| ast::NameLike::cast(it.parent()?)).is_some() - && let Some(node) = place_of_parent() - && let Some(next) = next_token_of(&node) - && matches!(next.kind(), T![<] | T![<<]) - { - return true; - } - if self.is_paren_like() || parent.is_paren_like() || self.is_prefix() diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs index 6e17d262a79d..7cf9e2bf14f9 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs @@ -75,24 +75,6 @@ impl SyntaxFactory { make::path_from_text(text).clone_for_update() } - pub fn path_concat(&self, first: ast::Path, second: ast::Path) -> ast::Path { - make::path_concat(first, second).clone_for_update() - } - - pub fn visibility_pub(&self) -> ast::Visibility { - make::visibility_pub() - } - - pub fn struct_( - &self, - visibility: Option, - strukt_name: ast::Name, - generic_param_list: Option, - field_list: ast::FieldList, - ) -> ast::Struct { - make::struct_(visibility, strukt_name, generic_param_list, field_list).clone_for_update() - } - pub fn expr_field(&self, receiver: ast::Expr, field: &str) -> ast::FieldExpr { let ast::Expr::FieldExpr(ast) = make::expr_field(receiver.clone(), field).clone_for_update() @@ -1596,103 +1578,6 @@ impl SyntaxFactory { pub fn ident(&self, text: &str) -> SyntaxToken { make::tokens::ident(text) } - - pub fn mut_self_param(&self) -> ast::SelfParam { - let ast = make::mut_self_param().clone_for_update(); - - if let Some(mut mapping) = self.mappings() { - let builder = SyntaxMappingBuilder::new(ast.syntax().clone()); - builder.finish(&mut mapping); - } - - ast - } - - pub fn self_param(&self) -> ast::SelfParam { - let ast = make::self_param().clone_for_update(); - - if let Some(mut mapping) = self.mappings() { - let builder = SyntaxMappingBuilder::new(ast.syntax().clone()); - builder.finish(&mut mapping); - } - - ast - } - - pub fn impl_( - &self, - attrs: impl IntoIterator, - generic_params: Option, - generic_args: Option, - path_type: ast::Type, - where_clause: Option, - body: Option, - ) -> ast::Impl { - let (attrs, attrs_input) = iterator_input(attrs); - let ast = make::impl_( - attrs, - generic_params.clone(), - generic_args.clone(), - path_type.clone(), - where_clause.clone(), - body.clone(), - ) - .clone_for_update(); - - if let Some(mut mapping) = self.mappings() { - let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone()); - builder.map_children(attrs_input, ast.attrs().map(|attr| attr.syntax().clone())); - if let Some(generic_params) = generic_params { - builder.map_node( - generic_params.syntax().clone(), - ast.generic_param_list().unwrap().syntax().clone(), - ); - } - builder.map_node(path_type.syntax().clone(), ast.self_ty().unwrap().syntax().clone()); - if let Some(where_clause) = where_clause { - builder.map_node( - where_clause.syntax().clone(), - ast.where_clause().unwrap().syntax().clone(), - ); - } - if let Some(body) = body { - builder.map_node( - body.syntax().clone(), - ast.assoc_item_list().unwrap().syntax().clone(), - ); - } - builder.finish(&mut mapping); - } - - ast - } - - pub fn ret_type(&self, ty: ast::Type) -> ast::RetType { - let ast = make::ret_type(ty.clone()).clone_for_update(); - - if let Some(mut mapping) = self.mappings() { - let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone()); - builder.map_node(ty.syntax().clone(), ast.ty().unwrap().syntax().clone()); - builder.finish(&mut mapping); - } - ast - } - - pub fn ty_ref(&self, ty: ast::Type, is_mut: bool) -> ast::Type { - let ast = make::ty_ref(ty.clone(), is_mut).clone_for_update(); - - if let Some(mut mapping) = self.mappings() { - let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone()); - match &ast { - ast::Type::RefType(ref_ty) => { - builder.map_node(ty.syntax().clone(), ref_ty.ty().unwrap().syntax().clone()); - } - _ => unreachable!(), - } - builder.finish(&mut mapping); - } - ast - } } // `ext` constructors diff --git a/src/tools/rust-analyzer/crates/syntax/src/ptr.rs b/src/tools/rust-analyzer/crates/syntax/src/ptr.rs index c4979b8e3ae8..34c07598d200 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ptr.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ptr.rs @@ -68,7 +68,7 @@ impl AstPtr { self.raw } - pub fn text_range(self) -> TextRange { + pub fn text_range(&self) -> TextRange { self.raw.text_range() } diff --git a/src/tools/rust-analyzer/crates/syntax/src/syntax_editor/mapping.rs b/src/tools/rust-analyzer/crates/syntax/src/syntax_editor/mapping.rs index 6257bf4e572e..1eaef03197c5 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/syntax_editor/mapping.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/syntax_editor/mapping.rs @@ -1,6 +1,6 @@ //! Maps syntax elements through disjoint syntax nodes. //! -//! [`SyntaxMappingBuilder`] should be used to create mappings to add to a `SyntaxEditor` +//! [`SyntaxMappingBuilder`] should be used to create mappings to add to a [`SyntaxEditor`] use itertools::Itertools; use rustc_hash::FxHashMap; diff --git a/src/tools/rust-analyzer/crates/syntax/src/syntax_error.rs b/src/tools/rust-analyzer/crates/syntax/src/syntax_error.rs index 6f00ef4ed584..1c902893abc6 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/syntax_error.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/syntax_error.rs @@ -9,6 +9,16 @@ use crate::{TextRange, TextSize}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SyntaxError(String, TextRange); +// FIXME: there was an unused SyntaxErrorKind previously (before this enum was removed) +// It was introduced in this PR: https://github.com/rust-lang/rust-analyzer/pull/846/files#diff-827da9b03b8f9faa1bade5cdd44d5dafR95 +// but it was not removed by a mistake. +// +// So, we need to find a place where to stick validation for attributes in match clauses. +// Code before refactor: +// InvalidMatchInnerAttr => { +// write!(f, "Inner attributes are only allowed directly after the opening brace of the match expression") +// } + impl SyntaxError { pub fn new(message: impl Into, range: TextRange) -> Self { Self(message.into(), range) diff --git a/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs b/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs index ca68edd88c05..d81f27d7c3b1 100644 --- a/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs +++ b/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs @@ -37,110 +37,7 @@ use triomphe::Arc; pub const WORKSPACE: base_db::SourceRootId = base_db::SourceRootId(0); -/// A trait for setting up test databases from fixture strings. -/// -/// Fixtures are strings containing Rust source code with optional metadata that describe -/// a project setup. This is the primary way to write tests for rust-analyzer without -/// having to depend on the entire sysroot. -/// -/// # Fixture Syntax -/// -/// ## Basic Structure -/// -/// A fixture without metadata is parsed into a single source file (`/main.rs`). -/// Metadata is added after a `//-` comment prefix. -/// -/// ```text -/// //- /main.rs -/// fn main() { -/// println!("Hello"); -/// } -/// ``` -/// -/// Note that the fixture syntax is optional and can be omitted if the test only requires -/// a simple single file. -/// -/// ## File Metadata -/// -/// Each file can have the following metadata after `//-`: -/// -/// - **Path** (required): Must start with `/`, e.g., `/main.rs`, `/lib.rs`, `/foo/bar.rs` -/// - **`crate:`**: Defines a new crate with this file as its root -/// - Optional version: `crate:foo@0.1.0,https://example.com/repo.git` -/// - **`deps:,`**: Dependencies (requires `crate:`) -/// - **`extern-prelude:,`**: Limits extern prelude to specified crates -/// - **`edition:`**: Rust edition (2015, 2018, 2021, 2024). Defaults to current. -/// - **`cfg:=,`**: Configuration options, e.g., `cfg:test,feature="foo"` -/// - **`env:=`**: Environment variables -/// - **`crate-attr:`**: Crate-level attributes, e.g., `crate-attr:no_std` -/// - **`new_source_root:local|library`**: Starts a new source root -/// - **`library`**: Marks crate as external library (not workspace member) -/// -/// ## Global Meta (must appear at the top, in order) -/// -/// - **`//- toolchain: nightly|stable`**: Sets the Rust toolchain (default: stable) -/// - **`//- target_data_layout: `**: LLVM data layout string -/// - **`//- target_arch: `**: Target architecture (default: x86_64) -/// - **`//- proc_macros: ,`**: Enables predefined test proc macros -/// - **`//- minicore: , `**: Includes subset of libcore -/// -/// ## Cursor Markers -/// -/// Use `$0` to mark cursor position(s) in the fixture: -/// - Single `$0`: marks a position (use with [`with_position`](Self::with_position)) -/// - Two `$0` markers: marks a range (use with [`with_range`](Self::with_range)) -/// - Escape as `\$0` if you need a literal `$0` -/// -/// # Examples -/// -/// ## Single file with cursor position -/// ```text -/// r#" -/// fn main() { -/// let x$0 = 42; -/// } -/// "# -/// ``` -/// -/// ## Multiple crates with dependencies -/// ```text -/// r#" -/// //- /main.rs crate:main deps:helper -/// use helper::greet; -/// fn main() { greet(); } -/// -/// //- /lib.rs crate:helper -/// pub fn greet() {} -/// "# -/// ``` -/// -/// ## Using minicore for lang items -/// ```text -/// r#" -/// //- minicore: option, result, iterator -/// //- /main.rs -/// fn foo() -> Option { Some(42) } -/// "# -/// ``` -/// -/// The available minicore flags are listed at the top of crates\test-utils\src\minicore.rs. -/// -/// ## Using test proc macros -/// ```text -/// r#" -/// //- proc_macros: identity, mirror -/// //- /main.rs crate:main deps:proc_macros -/// use proc_macros::identity; -/// -/// #[identity] -/// fn foo() {} -/// "# -/// ``` -/// -/// Available proc macros: `identity` (attr), `DeriveIdentity` (derive), `input_replace` (attr), -/// `mirror` (bang), `shorten` (bang) pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_single_file( #[rust_analyzer::rust_fixture] ra_fixture: &str, @@ -153,7 +50,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { (db, file) } - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_many_files( #[rust_analyzer::rust_fixture] ra_fixture: &str, @@ -170,7 +66,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { (db, files) } - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_files(#[rust_analyzer::rust_fixture] ra_fixture: &str) -> Self { let mut db = Self::default(); @@ -180,7 +75,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { db } - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_files_extra_proc_macros( #[rust_analyzer::rust_fixture] ra_fixture: &str, @@ -194,7 +88,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { db } - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_position(#[rust_analyzer::rust_fixture] ra_fixture: &str) -> (Self, FilePosition) { let (db, file_id, range_or_offset) = Self::with_range_or_offset(ra_fixture); @@ -202,7 +95,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { (db, FilePosition { file_id, offset }) } - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_range(#[rust_analyzer::rust_fixture] ra_fixture: &str) -> (Self, FileRange) { let (db, file_id, range_or_offset) = Self::with_range_or_offset(ra_fixture); @@ -210,7 +102,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabase + 'static { (db, FileRange { file_id, range }) } - /// See the trait documentation for more information on fixtures. #[track_caller] fn with_range_or_offset( #[rust_analyzer::rust_fixture] ra_fixture: &str, diff --git a/src/tools/rust-analyzer/crates/test-utils/src/minicore.rs b/src/tools/rust-analyzer/crates/test-utils/src/minicore.rs index c34475bbdf01..c3429356d9e5 100644 --- a/src/tools/rust-analyzer/crates/test-utils/src/minicore.rs +++ b/src/tools/rust-analyzer/crates/test-utils/src/minicore.rs @@ -43,7 +43,6 @@ //! dispatch_from_dyn: unsize, pin //! hash: sized //! include: -//! include_bytes: //! index: sized //! infallible: //! int_impl: size_of, transmute @@ -59,7 +58,6 @@ //! pin: //! pointee: copy, send, sync, ord, hash, unpin, phantom_data //! range: -//! new_range: //! receiver: deref //! result: //! send: sized @@ -177,9 +175,7 @@ pub mod marker { // region:clone impl Clone for PhantomData { - fn clone(&self) -> Self { - Self - } + fn clone(&self) -> Self { Self } } // endregion:clone @@ -954,9 +950,6 @@ pub mod ops { #[lang = "from_residual"] fn from_residual(residual: R) -> Self; } - pub const trait Residual: Sized { - type TryType: [const] Try; - } #[lang = "Try"] pub trait Try: FromResidual { type Output; @@ -966,12 +959,6 @@ pub mod ops { #[lang = "branch"] fn branch(self) -> ControlFlow; } - #[lang = "into_try_type"] - pub const fn residual_into_try_type, O>( - r: R, - ) -> >::TryType { - FromResidual::from_residual(r) - } impl Try for ControlFlow { type Output = C; @@ -995,10 +982,6 @@ pub mod ops { } } } - - impl Residual for ControlFlow { - type TryType = ControlFlow; - } // region:option impl Try for Option { type Output = T; @@ -1022,10 +1005,6 @@ pub mod ops { } } } - - impl const Residual for Option { - type TryType = Option; - } // endregion:option // region:result // region:from @@ -1055,14 +1034,10 @@ pub mod ops { } } } - - impl const Residual for Result { - type TryType = Result; - } // endregion:from // endregion:result } - pub use self::try_::{ControlFlow, FromResidual, Residual, Try}; + pub use self::try_::{ControlFlow, FromResidual, Try}; // endregion:try // region:add @@ -1153,32 +1128,6 @@ pub mod ops { // endregion:dispatch_from_dyn } -// region:new_range -pub mod range { - #[lang = "RangeCopy"] - pub struct Range { - pub start: Idx, - pub end: Idx, - } - - #[lang = "RangeFromCopy"] - pub struct RangeFrom { - pub start: Idx, - } - - #[lang = "RangeInclusiveCopy"] - pub struct RangeInclusive { - pub start: Idx, - pub end: Idx, - } - - #[lang = "RangeToInclusiveCopy"] - pub struct RangeToInclusive { - pub end: Idx, - } -} -// endregion:new_range - // region:eq pub mod cmp { use crate::marker::PointeeSized; @@ -1195,9 +1144,7 @@ pub mod cmp { // region:builtin_impls impl PartialEq for () { - fn eq(&self, other: &()) -> bool { - true - } + fn eq(&self, other: &()) -> bool { true } } // endregion:builtin_impls @@ -1620,7 +1567,10 @@ pub mod pin { } // endregion:dispatch_from_dyn // region:coerce_unsized - impl crate::ops::CoerceUnsized> for Pin where Ptr: crate::ops::CoerceUnsized {} + impl crate::ops::CoerceUnsized> for Pin where + Ptr: crate::ops::CoerceUnsized + { + } // endregion:coerce_unsized } // endregion:pin @@ -1689,21 +1639,6 @@ pub mod iter { } } - pub struct Filter { - iter: I, - predicate: P, - } - impl Iterator for Filter - where - P: FnMut(&I::Item) -> bool, - { - type Item = I::Item; - - fn next(&mut self) -> Option { - loop {} - } - } - pub struct FilterMap { iter: I, f: F, @@ -1720,7 +1655,7 @@ pub mod iter { } } } - pub use self::adapters::{Filter, FilterMap, Take}; + pub use self::adapters::{FilterMap, Take}; mod sources { mod repeat { @@ -1771,13 +1706,6 @@ pub mod iter { { loop {} } - fn filter

(self, predicate: P) -> crate::iter::Filter - where - Self: Sized, - P: FnMut(&Self::Item) -> bool, - { - loop {} - } fn filter_map(self, _f: F) -> crate::iter::FilterMap where Self: Sized, @@ -1864,9 +1792,9 @@ pub mod iter { fn from_iter>(iter: T) -> Self; } } - pub use self::collect::{FromIterator, IntoIterator}; + pub use self::collect::{IntoIterator, FromIterator}; } - pub use self::traits::{FromIterator, IntoIterator, Iterator}; + pub use self::traits::{IntoIterator, FromIterator, Iterator}; } // endregion:iterator @@ -1952,10 +1880,6 @@ mod arch { pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) { /* compiler built-in */ } - #[rustc_builtin_macro] - pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) { - /* compiler built-in */ - } } // endregion:asm @@ -2084,14 +2008,6 @@ mod macros { } // endregion:include - // region:include_bytes - #[rustc_builtin_macro] - #[macro_export] - macro_rules! include_bytes { - ($file:expr $(,)?) => {{ /* compiler built-in */ }}; - } - // endregion:include_bytes - // region:concat #[rustc_builtin_macro] #[macro_export] @@ -2171,30 +2087,30 @@ macro_rules! column { pub mod prelude { pub mod v1 { pub use crate::{ - clone::Clone, // :clone - cmp::{Eq, PartialEq}, // :eq - cmp::{Ord, PartialOrd}, // :ord - convert::AsMut, // :as_mut - convert::AsRef, // :as_ref - convert::{From, Into, TryFrom, TryInto}, // :from - default::Default, // :default - fmt::derive::Debug, // :fmt, derive - hash::derive::Hash, // :hash, derive - iter::{FromIterator, IntoIterator, Iterator}, // :iterator - macros::builtin::{derive, derive_const}, // :derive - marker::Copy, // :copy - marker::Send, // :send - marker::Sized, // :sized - marker::Sync, // :sync - mem::drop, // :drop - mem::size_of, // :size_of - ops::Drop, // :drop - ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}, // :async_fn - ops::{Fn, FnMut, FnOnce}, // :fn - option::Option::{self, None, Some}, // :option - panic, // :panic - result::Result::{self, Err, Ok}, // :result - str::FromStr, // :str + clone::Clone, // :clone + cmp::{Eq, PartialEq}, // :eq + cmp::{Ord, PartialOrd}, // :ord + convert::AsMut, // :as_mut + convert::AsRef, // :as_ref + convert::{From, Into, TryFrom, TryInto}, // :from + default::Default, // :default + iter::{IntoIterator, Iterator, FromIterator}, // :iterator + macros::builtin::{derive, derive_const}, // :derive + marker::Copy, // :copy + marker::Send, // :send + marker::Sized, // :sized + marker::Sync, // :sync + mem::drop, // :drop + mem::size_of, // :size_of + ops::Drop, // :drop + ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}, // :async_fn + ops::{Fn, FnMut, FnOnce}, // :fn + option::Option::{self, None, Some}, // :option + panic, // :panic + result::Result::{self, Err, Ok}, // :result + str::FromStr, // :str + fmt::derive::Debug, // :fmt, derive + hash::derive::Hash, // :hash, derive }; } diff --git a/src/tools/rust-analyzer/crates/tt/src/storage.rs b/src/tools/rust-analyzer/crates/tt/src/storage.rs index 50a1106175ab..4dd02d875a29 100644 --- a/src/tools/rust-analyzer/crates/tt/src/storage.rs +++ b/src/tools/rust-analyzer/crates/tt/src/storage.rs @@ -488,7 +488,7 @@ impl TopSubtree { unreachable!() }; *open_span = S::new(span.open.range, 0); - *close_span = S::new(span.close.range, 1); + *close_span = S::new(span.close.range, 0); } dispatch! { match &mut self.repr => tt => do_it(tt, span) diff --git a/src/tools/rust-analyzer/crates/vfs-notify/Cargo.toml b/src/tools/rust-analyzer/crates/vfs-notify/Cargo.toml index ce7ea53b5373..bd6c8331e66c 100644 --- a/src/tools/rust-analyzer/crates/vfs-notify/Cargo.toml +++ b/src/tools/rust-analyzer/crates/vfs-notify/Cargo.toml @@ -16,7 +16,7 @@ doctest = false tracing.workspace = true walkdir = "2.5.0" crossbeam-channel.workspace = true -notify = "8.2.0" +notify = "8.0.0" rayon = "1.10.0" stdx.workspace = true diff --git a/src/tools/rust-analyzer/docs/book/README.md b/src/tools/rust-analyzer/docs/book/README.md index cd4d8783a4d2..0a3161f3af38 100644 --- a/src/tools/rust-analyzer/docs/book/README.md +++ b/src/tools/rust-analyzer/docs/book/README.md @@ -6,7 +6,7 @@ The rust analyzer manual uses [mdbook](https://rust-lang.github.io/mdBook/). To run the documentation site locally: -```bash +```shell cargo install mdbook cargo xtask codegen cd docs/book diff --git a/src/tools/rust-analyzer/docs/book/src/configuration_generated.md b/src/tools/rust-analyzer/docs/book/src/configuration_generated.md index 8460c2c7d0cf..58b636334527 100644 --- a/src/tools/rust-analyzer/docs/book/src/configuration_generated.md +++ b/src/tools/rust-analyzer/docs/book/src/configuration_generated.md @@ -323,18 +323,10 @@ each of them, with the working directory being the workspace root (i.e., the folder containing the `Cargo.toml`). This can be overwritten by changing `#rust-analyzer.check.invocationStrategy#`. -It supports two interpolation syntaxes, both mainly intended to be used with -[non-Cargo build systems](./non_cargo_based_projects.md): - -- If `{saved_file}` is part of the command, rust-analyzer will pass - the absolute path of the saved file to the provided command. - (A previous version, `$saved_file`, also works.) -- If `{label}` is part of the command, rust-analyzer will pass the - Cargo package ID, which can be used with `cargo check -p`, or a build label from - `rust-project.json`. If `{label}` is included, rust-analyzer behaves much like - [`"rust-analyzer.check.workspace": false`](#check.workspace). - - +If `$saved_file` is part of the command, rust-analyzer will pass +the absolute path of the saved file to the provided command. This is +intended to be used with non-Cargo build systems. +Note that `$saved_file` is experimental and may be removed in the future. An example command would be: @@ -1318,16 +1310,6 @@ These proc-macros will be ignored when trying to expand them. This config takes a map of crate names with the exported proc-macro names to ignore as values. -## rust-analyzer.procMacro.processes {#procMacro.processes} - -Default: `1` - -Number of proc-macro server processes to spawn. - -Controls how many independent `proc-macro-srv` processes rust-analyzer -runs in parallel to handle macro expansion. - - ## rust-analyzer.procMacro.server {#procMacro.server} Default: `null` @@ -1629,83 +1611,33 @@ though Cargo might be the eventual consumer. Default: `null` -Configure a command that rust-analyzer can invoke to -obtain configuration. +Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`]. -This is an alternative to manually generating -`rust-project.json`: it enables rust-analyzer to generate -rust-project.json on the fly, and regenerate it when -switching or modifying projects. - -This is an object with three fields: - -* `command`: the shell command to invoke - -* `filesToWatch`: which build system-specific files should -be watched to trigger regenerating the configuration - -* `progressLabel`: the name of the command, used in -progress indicators in the IDE - -Here's an example of a valid configuration: +[`DiscoverWorkspaceConfig`] also requires setting `progress_label` and `files_to_watch`. +`progress_label` is used for the title in progress indicators, whereas `files_to_watch` +is used to determine which build system-specific files should be watched in order to +reload rust-analyzer. +Below is an example of a valid configuration: ```json "rust-analyzer.workspace.discoverConfig": { "command": [ "rust-project", - "develop-json", - "{arg}" + "develop-json" ], - "progressLabel": "buck2/rust-project", + "progressLabel": "rust-analyzer", "filesToWatch": [ "BUCK" ] } ``` -## Argument Substitutions - -If `command` includes the argument `{arg}`, that argument will be substituted -with the JSON-serialized form of the following enum: - -```norun -#[derive(PartialEq, Clone, Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub enum DiscoverArgument { - Path(AbsPathBuf), - Buildfile(AbsPathBuf), -} -``` - -rust-analyzer will use the path invocation to find and -generate a `rust-project.json` and therefore a -workspace. Example: - - -```norun -rust-project develop-json '{ "path": "myproject/src/main.rs" }' -``` - -rust-analyzer will use build file invocations to update an -existing workspace. Example: - -Or with a build file and the configuration above: - -```norun -rust-project develop-json '{ "buildfile": "myproject/BUCK" }' -``` - -As a reference for implementors, buck2's `rust-project` -will likely be useful: -. - -## Discover Command Output +## On `DiscoverWorkspaceConfig::command` **Warning**: This format is provisional and subject to change. -The discover command should output JSON objects, one per -line (JSONL format). These objects should correspond to -this Rust data type: +[`DiscoverWorkspaceConfig::command`] *must* return a JSON object corresponding to +`DiscoverProjectData::Finished`: ```norun #[derive(Debug, Clone, Deserialize, Serialize)] @@ -1718,14 +1650,7 @@ enum DiscoverProjectData { } ``` -For example, a progress event: - -```json -{"kind":"progress","message":"generating rust-project.json"} -``` - -A finished event can look like this (expanded and -commented for readability): +As JSON, `DiscoverProjectData::Finished` is: ```json { @@ -1733,7 +1658,7 @@ commented for readability): "kind": "finished", // the file used by a non-Cargo build system to define // a package or target. - "buildfile": "rust-analyzer/BUCK", + "buildfile": "rust-analyzer/BUILD", // the contents of a rust-project.json, elided for brevity "project": { "sysroot": "foo", @@ -1742,9 +1667,41 @@ commented for readability): } ``` -Only the finished event is required, but the other -variants are encouraged to give users more feedback about -progress or errors. +It is encouraged, but not required, to use the other variants on `DiscoverProjectData` +to provide a more polished end-user experience. + +`DiscoverWorkspaceConfig::command` may *optionally* include an `{arg}`, which will be +substituted with the JSON-serialized form of the following enum: + +```norun +#[derive(PartialEq, Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub enum DiscoverArgument { + Path(AbsPathBuf), + Buildfile(AbsPathBuf), +} +``` + +The JSON representation of `DiscoverArgument::Path` is: + +```json +{ + "path": "src/main.rs" +} +``` + +Similarly, the JSON representation of `DiscoverArgument::Buildfile` is: + +```json +{ + "buildfile": "BUILD" +} +``` + +`DiscoverArgument::Path` is used to find and generate a `rust-project.json`, and +therefore, a workspace, whereas `DiscoverArgument::buildfile` is used to to update an +existing workspace. As a reference for implementors, buck2's `rust-project` will likely +be useful: . ## rust-analyzer.workspace.symbol.search.excludeImports {#workspace.symbol.search.excludeImports} diff --git a/src/tools/rust-analyzer/docs/book/src/contributing/README.md b/src/tools/rust-analyzer/docs/book/src/contributing/README.md index bb2b6081ad95..c95a1dba6249 100644 --- a/src/tools/rust-analyzer/docs/book/src/contributing/README.md +++ b/src/tools/rust-analyzer/docs/book/src/contributing/README.md @@ -4,7 +4,7 @@ rust-analyzer is an ordinary Rust project, which is organized as a Cargo workspa So, just ```bash -cargo test +$ cargo test ``` should be enough to get you started! @@ -203,14 +203,14 @@ It is enabled by `RA_COUNT=1`. To measure time for from-scratch analysis, use something like this: ```bash -cargo run --release -p rust-analyzer -- analysis-stats ../chalk/ +$ cargo run --release -p rust-analyzer -- analysis-stats ../chalk/ ``` For measuring time of incremental analysis, use either of these: ```bash -cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --highlight ../chalk/chalk-engine/src/logic.rs -cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0 +$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --highlight ../chalk/chalk-engine/src/logic.rs +$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0 ``` Look for `fn benchmark_xxx` tests for a quick way to reproduce performance problems. @@ -283,8 +283,7 @@ repository. We use the [rustc-josh-sync](https://github.com/rust-lang/josh-sync) repositories. You can find documentation of the tool [here](https://github.com/rust-lang/josh-sync). You can install the synchronization tool using the following commands: - -```bash +``` cargo install --locked --git https://github.com/rust-lang/josh-sync ``` diff --git a/src/tools/rust-analyzer/docs/book/src/contributing/debugging.md b/src/tools/rust-analyzer/docs/book/src/contributing/debugging.md index ace9be025ab4..fcda664f5ed3 100644 --- a/src/tools/rust-analyzer/docs/book/src/contributing/debugging.md +++ b/src/tools/rust-analyzer/docs/book/src/contributing/debugging.md @@ -68,7 +68,7 @@ while d == 4 { // set a breakpoint here and change the value However for this to work, you will need to enable debug_assertions in your build -```bash +```rust RUSTFLAGS='--cfg debug_assertions' cargo build --release ``` diff --git a/src/tools/rust-analyzer/docs/book/src/faq.md b/src/tools/rust-analyzer/docs/book/src/faq.md index 9eeb2ae55539..8c143ab94935 100644 --- a/src/tools/rust-analyzer/docs/book/src/faq.md +++ b/src/tools/rust-analyzer/docs/book/src/faq.md @@ -4,7 +4,7 @@ rust-analyzer fails to resolve `None`, and thinks you are binding to a variable named `None`. That's usually a sign of a corrupted sysroot. Try removing and re-installing -it: `rustup component remove rust-src` then `rustup component add rust-src`. +it: `rustup component remove rust-src` then `rustup component install rust-src`. ### Rust Analyzer and Cargo compete over the build lock diff --git a/src/tools/rust-analyzer/docs/book/src/installation.md b/src/tools/rust-analyzer/docs/book/src/installation.md index cc636c31e6ec..3a4c0cf22774 100644 --- a/src/tools/rust-analyzer/docs/book/src/installation.md +++ b/src/tools/rust-analyzer/docs/book/src/installation.md @@ -13,9 +13,7 @@ editor](./other_editors.html). rust-analyzer will attempt to install the standard library source code automatically. You can also install it manually with `rustup`. -```bash -rustup component add rust-src -``` + $ rustup component add rust-src Only the latest stable standard library source is officially supported for use with rust-analyzer. If you are using an older toolchain or have diff --git a/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md b/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md index f1f10ae33653..e7df4a5d7668 100644 --- a/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md +++ b/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md @@ -204,40 +204,23 @@ interface Runnable { args: string[]; /// The current working directory of the runnable. cwd: string; - /// Maps a runnable to a piece of rust-analyzer functionality. + /// Used to decide what code lens to offer. /// - /// - `testOne`: This runnable will be used when the user clicks the 'Run Test' - /// CodeLens above a test. - /// - `run`: This runnable will be used when the user clicks the 'Run' CodeLens - /// above a main function or triggers a run command. - /// - `flycheck`: This is run to provide check-on-save diagnostics when the user - /// saves a file. It must emit rustc JSON diagnostics that rust-analyzer can - /// parse. If this runnable is not specified, we may try to use `cargo check -p`. - /// This is only run for a single crate that the user saved a file in. The - /// {label} syntax is replaced with `BuildInfo::label`. - /// Alternatively, you may use `{saved_file}` and figure out which crate - /// to produce diagnostics for based on that. + /// `testOne`: This runnable will be used when the user clicks the 'Run Test' + /// CodeLens above a test. /// /// The args for testOne can contain two template strings: /// `{label}` and `{test_id}`. `{label}` will be replaced - /// with the `BuildInfo::label` and `{test_id}` will be replaced + /// with the `Build::label` and `{test_id}` will be replaced /// with the test name. - kind: 'testOne' | 'run' | 'flycheck' | string; + kind: 'testOne' | string; } ``` This format is provisional and subject to change. Specifically, the `roots` setup will be different eventually. -### Providing a JSON project to rust-analyzer - -There are four ways to feed `rust-project.json` to rust-analyzer: - -- Use - [`"rust-analyzer.workspace.discoverConfig": … }`](./configuration.md#workspace.discoverConfig) - to specify a workspace discovery command to generate project descriptions - on-the-fly. Please note that the command output is message-oriented and must - output JSONL [as described in the configuration docs](./configuration.md#workspace.discoverConfig). +There are three ways to feed `rust-project.json` to rust-analyzer: - Place `rust-project.json` file at the root of the project, and rust-analyzer will discover it. @@ -257,86 +240,19 @@ location or (for inline JSON) relative to `rootUri`. You can set the `RA_LOG` environment variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading. -### Flycheck support +Note that calls to `cargo check` are disabled when using +`rust-project.json` by default, so compilation errors and warnings will +no longer be sent to your LSP client. To enable these compilation errors +you will need to specify explicitly what command rust-analyzer should +run to perform the checks using the +`rust-analyzer.check.overrideCommand` configuration. As an example, the +following configuration explicitly sets `cargo check` as the `check` +command. -Rust-analyzer has functionality to run an actual build of a crate when the user saves a file, to -fill in diagnostics it does not implement natively. This is known as "flycheck". + { "rust-analyzer.check.overrideCommand": ["cargo", "check", "--message-format=json"] } -**Flycheck is disabled when using `rust-project.json` unless explicitly configured**, so compilation -errors and warnings will no longer be sent to your LSP client by default. To enable these -compilation errors you will need to specify explicitly what command rust-analyzer should run to -perform the checks. There are two ways to do this: - -- `rust-project.json` may contain a `runnables` field. The `flycheck` runnable may be used to - configure a check command. See above for documentation. - -- Using the [`rust-analyzer.check.overrideCommand`](./configuration.md#check.overrideCommand) - configuration. This will also override anything in `rust-project.json`. As an example, the - following configuration explicitly sets `cargo check` as the `check` command. - - ```json - { "rust-analyzer.check.overrideCommand": ["cargo", "check", "--message-format=json"] } - ``` - - Note also that this works with cargo projects. - -Either option requires the command specified to output JSON error messages for rust-analyzer to -consume. The `--message-format=json` flag does this for `cargo check` so whichever command you use -must also output errors in this format. - -Either option also supports two syntaxes within each argument: - -- `{label}` will be replaced with the `BuildInfo::label` of the crate - containing a saved file, if `BuildInfo` is provided. In the case of `check.overrideCommand` being - used in a Cargo project, this will be the cargo package ID, which can be used with `cargo check -p`. -- `{saved_file}` will be replaced with an absolute path to the saved file. This can be queried against a - build system to find targets that include the file. - -For example: - -```json -{ "rust-analyzer.check.overrideCommand": ["custom_crate_checker", "{label}"] } -``` - -If you do use `{label}` or `{saved_file}`, the command will not be run unless the relevant value can -be substituted. - - -#### Flycheck considerations - -##### Diagnostic output on error - -A flycheck command using a complex build orchestrator like `"bazel", "build", "{label}"`, even with -a tweak to return JSON messages, is often insufficient. Such a command will typically succeed if -there are warnings, but if there are errors, it might "fail to compile" the diagnostics and not -produce any output. You must build a package in such a way that the build succeeds even if `rustc` -exits with an error, and prints the JSON build messages in every case. - -##### Diagnostics for upstream crates - -`cargo check -p` re-prints any errors and warnings in crates higher up in the dependency graph -than the one requested. We do clear all diagnostics when flychecking, so if you manage to -replicate this behaviour, diagnostics for crates other than the one being checked will show up in -the editor. If you do not, then users may be confused that diagnostics are "stuck" or disappear -entirely when there is a build error in an upstream crate. - -##### Compiler options - -`cargo check` invokes rustc differently from `cargo build`. It turns off codegen (with `rustc ---emit=metadata`), which results in lower latency to get to diagnostics. If your build system can -configure this, it is recommended. - -If your build tool can configure rustc for incremental compiles, this is also recommended. - -##### Locking and pre-emption - -In any good build system, including Cargo, build commands sometimes block each other. Running a -flycheck will (by default) frequently block you from running other build commands. Generally this is -undesirable. Users will have to (unintuitively) press save again in the editor to cancel a -flycheck, so that some other command may proceed. - -If your build system has the ability to isolate any rust-analyzer-driven flychecks and prevent lock -contention, for example a separate build output directory and/or daemon instance, this is -recommended. Alternatively, consider using a feature if available that can set the priority of -various build invocations and automatically cancel lower-priority ones when needed. Flychecks should -be set to a lower priority than general direct build invocations. +`check.overrideCommand` requires the command specified to output json +error messages for rust-analyzer to consume. The `--message-format=json` +flag does this for `cargo check` so whichever command you use must also +output errors in this format. See the [Configuration](#_configuration) +section for more information. diff --git a/src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md b/src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md index 2b62011a8e33..c7ac3087ced7 100644 --- a/src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md +++ b/src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md @@ -11,11 +11,9 @@ your `$PATH`. On Linux to install the `rust-analyzer` binary into `~/.local/bin`, these commands should work: -```bash -mkdir -p ~/.local/bin -curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer -chmod +x ~/.local/bin/rust-analyzer -``` + $ mkdir -p ~/.local/bin + $ curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer + $ chmod +x ~/.local/bin/rust-analyzer Make sure that `~/.local/bin` is listed in the `$PATH` variable and use the appropriate URL if you’re not on a `x86-64` system. @@ -26,10 +24,8 @@ or `/usr/local/bin` will work just as well. Alternatively, you can install it from source using the command below. You’ll need the latest stable version of the Rust toolchain. -```bash -git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer -cargo xtask install --server -``` + $ git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer + $ cargo xtask install --server If your editor can’t find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn’t see the same `$PATH` @@ -42,9 +38,7 @@ the environment should help. `rust-analyzer` is available in `rustup`: -```bash -rustup component add rust-analyzer -``` + $ rustup component add rust-analyzer ### Arch Linux @@ -59,9 +53,7 @@ User Repository): Install it with pacman, for example: -```bash -pacman -S rust-analyzer -``` + $ pacman -S rust-analyzer ### Gentoo Linux @@ -72,9 +64,7 @@ pacman -S rust-analyzer The `rust-analyzer` binary can be installed via [Homebrew](https://brew.sh/). -```bash -brew install rust-analyzer -``` + $ brew install rust-analyzer ### Windows diff --git a/src/tools/rust-analyzer/docs/book/src/troubleshooting.md b/src/tools/rust-analyzer/docs/book/src/troubleshooting.md index c315bfad7f94..a357cbef415c 100644 --- a/src/tools/rust-analyzer/docs/book/src/troubleshooting.md +++ b/src/tools/rust-analyzer/docs/book/src/troubleshooting.md @@ -37,13 +37,13 @@ bypassing LSP machinery. When filing issues, it is useful (but not necessary) to try to minimize examples. An ideal bug reproduction looks like this: -```bash -git clone https://github.com/username/repo.git && cd repo && git switch --detach commit-hash -rust-analyzer --version +```shell +$ git clone https://github.com/username/repo.git && cd repo && git switch --detach commit-hash +$ rust-analyzer --version rust-analyzer dd12184e4 2021-05-08 dev -rust-analyzer analysis-stats . -``` +$ rust-analyzer analysis-stats . 💀 💀 💀 +``` It is especially useful when the `repo` doesn’t use external crates or the standard library. diff --git a/src/tools/rust-analyzer/docs/book/src/vs_code.md b/src/tools/rust-analyzer/docs/book/src/vs_code.md index 75f940e69a88..233b862d2c6b 100644 --- a/src/tools/rust-analyzer/docs/book/src/vs_code.md +++ b/src/tools/rust-analyzer/docs/book/src/vs_code.md @@ -49,9 +49,7 @@ Alternatively, download a VSIX corresponding to your platform from the Install the extension with the `Extensions: Install from VSIX` command within VS Code, or from the command line via: -```bash -code --install-extension /path/to/rust-analyzer.vsix -``` + $ code --install-extension /path/to/rust-analyzer.vsix If you are running an unsupported platform, you can install `rust-analyzer-no-server.vsix` and compile or obtain a server binary. @@ -66,10 +64,8 @@ example: Both the server and the Code plugin can be installed from source: -```bash -git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer -cargo xtask install -``` + $ git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer + $ cargo xtask install You’ll need Cargo, nodejs (matching a supported version of VS Code) and npm for this. @@ -80,9 +76,7 @@ Remote, instead you’ll need to install the `.vsix` manually. If you’re not using Code, you can compile and install only the LSP server: -```bash -cargo xtask install --server -``` + $ cargo xtask install --server Make sure that `.cargo/bin` is in `$PATH` and precedes paths where `rust-analyzer` may also be installed. Specifically, `rustup` includes a @@ -124,3 +118,4 @@ steps might help: A C compiler should already be available via `org.freedesktop.Sdk`. Any other tools or libraries you will need to acquire from Flatpak. + diff --git a/src/tools/rust-analyzer/editors/code/package-lock.json b/src/tools/rust-analyzer/editors/code/package-lock.json index 84be0a666f9c..57f6bf69beb0 100644 --- a/src/tools/rust-analyzer/editors/code/package-lock.json +++ b/src/tools/rust-analyzer/editors/code/package-lock.json @@ -1486,6 +1486,7 @@ "integrity": "sha512-4gbs64bnbSzu4FpgMiQ1A+D+urxkoJk/kqlDJ2W//5SygaEiAP2B4GoS7TEdxgwol2el03gckFV9lJ4QOMiiHg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.25.0", "@typescript-eslint/types": "8.25.0", @@ -1869,6 +1870,7 @@ "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2838,6 +2840,7 @@ "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", "license": "ISC", + "peer": true, "engines": { "node": ">=12" } @@ -3319,6 +3322,7 @@ "integrity": "sha512-KjeihdFqTPhOMXTt7StsDxriV4n66ueuF/jfPNC3j/lduHwr/ijDwJMsF+wyMJethgiKi5wniIE243vi07d3pg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -4406,6 +4410,7 @@ "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", "license": "MIT", + "peer": true, "bin": { "jiti": "lib/jiti-cli.mjs" } @@ -5579,9 +5584,9 @@ } }, "node_modules/qs": { - "version": "6.14.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", - "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -6673,6 +6678,7 @@ "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index fc20597e8876..2157cbd48653 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -1213,7 +1213,7 @@ "title": "Check", "properties": { "rust-analyzer.check.overrideCommand": { - "markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.check.invocationStrategy#`.\n\nIt supports two interpolation syntaxes, both mainly intended to be used with\n[non-Cargo build systems](./non_cargo_based_projects.md):\n\n- If `{saved_file}` is part of the command, rust-analyzer will pass\n the absolute path of the saved file to the provided command.\n (A previous version, `$saved_file`, also works.)\n- If `{label}` is part of the command, rust-analyzer will pass the\n Cargo package ID, which can be used with `cargo check -p`, or a build label from\n `rust-project.json`. If `{label}` is included, rust-analyzer behaves much like\n [`\"rust-analyzer.check.workspace\": false`](#check.workspace).\n\n\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n\nNote: The option must be specified as an array of command line arguments, with\nthe first argument being the name of the command to run.", + "markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.check.invocationStrategy#`.\n\nIf `$saved_file` is part of the command, rust-analyzer will pass\nthe absolute path of the saved file to the provided command. This is\nintended to be used with non-Cargo build systems.\nNote that `$saved_file` is experimental and may be removed in the future.\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n\nNote: The option must be specified as an array of command line arguments, with\nthe first argument being the name of the command to run.", "default": null, "type": [ "null", @@ -2770,31 +2770,6 @@ } } }, - { - "title": "Proc Macro", - "properties": { - "rust-analyzer.procMacro.processes": { - "markdownDescription": "Number of proc-macro server processes to spawn.\n\nControls how many independent `proc-macro-srv` processes rust-analyzer\nruns in parallel to handle macro expansion.", - "default": 1, - "anyOf": [ - { - "type": "number", - "minimum": 0, - "maximum": 255 - }, - { - "type": "string", - "enum": [ - "physical" - ], - "enumDescriptions": [ - "Use the number of physical cores" - ] - } - ] - } - } - }, { "title": "Proc Macro", "properties": { @@ -3160,7 +3135,7 @@ "title": "Workspace", "properties": { "rust-analyzer.workspace.discoverConfig": { - "markdownDescription": "Configure a command that rust-analyzer can invoke to\nobtain configuration.\n\nThis is an alternative to manually generating\n`rust-project.json`: it enables rust-analyzer to generate\nrust-project.json on the fly, and regenerate it when\nswitching or modifying projects.\n\nThis is an object with three fields:\n\n* `command`: the shell command to invoke\n\n* `filesToWatch`: which build system-specific files should\nbe watched to trigger regenerating the configuration\n\n* `progressLabel`: the name of the command, used in\nprogress indicators in the IDE\n\nHere's an example of a valid configuration:\n\n```json\n\"rust-analyzer.workspace.discoverConfig\": {\n \"command\": [\n \"rust-project\",\n \"develop-json\",\n \"{arg}\"\n ],\n \"progressLabel\": \"buck2/rust-project\",\n \"filesToWatch\": [\n \"BUCK\"\n ]\n}\n```\n\n## Argument Substitutions\n\nIf `command` includes the argument `{arg}`, that argument will be substituted\nwith the JSON-serialized form of the following enum:\n\n```norun\n#[derive(PartialEq, Clone, Debug, Serialize)]\n#[serde(rename_all = \"camelCase\")]\npub enum DiscoverArgument {\n Path(AbsPathBuf),\n Buildfile(AbsPathBuf),\n}\n```\n\nrust-analyzer will use the path invocation to find and\ngenerate a `rust-project.json` and therefore a\nworkspace. Example:\n\n\n```norun\nrust-project develop-json '{ \"path\": \"myproject/src/main.rs\" }'\n```\n\nrust-analyzer will use build file invocations to update an\nexisting workspace. Example:\n\nOr with a build file and the configuration above:\n\n```norun\nrust-project develop-json '{ \"buildfile\": \"myproject/BUCK\" }'\n```\n\nAs a reference for implementors, buck2's `rust-project`\nwill likely be useful:\n.\n\n## Discover Command Output\n\n**Warning**: This format is provisional and subject to change.\n\nThe discover command should output JSON objects, one per\nline (JSONL format). These objects should correspond to\nthis Rust data type:\n\n```norun\n#[derive(Debug, Clone, Deserialize, Serialize)]\n#[serde(tag = \"kind\")]\n#[serde(rename_all = \"snake_case\")]\nenum DiscoverProjectData {\n Finished { buildfile: Utf8PathBuf, project: ProjectJsonData },\n Error { error: String, source: Option },\n Progress { message: String },\n}\n```\n\nFor example, a progress event:\n\n```json\n{\"kind\":\"progress\",\"message\":\"generating rust-project.json\"}\n```\n\nA finished event can look like this (expanded and\ncommented for readability):\n\n```json\n{\n // the internally-tagged representation of the enum.\n \"kind\": \"finished\",\n // the file used by a non-Cargo build system to define\n // a package or target.\n \"buildfile\": \"rust-analyzer/BUCK\",\n // the contents of a rust-project.json, elided for brevity\n \"project\": {\n \"sysroot\": \"foo\",\n \"crates\": []\n }\n}\n```\n\nOnly the finished event is required, but the other\nvariants are encouraged to give users more feedback about\nprogress or errors.", + "markdownDescription": "Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`].\n\n[`DiscoverWorkspaceConfig`] also requires setting `progress_label` and `files_to_watch`.\n`progress_label` is used for the title in progress indicators, whereas `files_to_watch`\nis used to determine which build system-specific files should be watched in order to\nreload rust-analyzer.\n\nBelow is an example of a valid configuration:\n```json\n\"rust-analyzer.workspace.discoverConfig\": {\n \"command\": [\n \"rust-project\",\n \"develop-json\"\n ],\n \"progressLabel\": \"rust-analyzer\",\n \"filesToWatch\": [\n \"BUCK\"\n ]\n}\n```\n\n## On `DiscoverWorkspaceConfig::command`\n\n**Warning**: This format is provisional and subject to change.\n\n[`DiscoverWorkspaceConfig::command`] *must* return a JSON object corresponding to\n`DiscoverProjectData::Finished`:\n\n```norun\n#[derive(Debug, Clone, Deserialize, Serialize)]\n#[serde(tag = \"kind\")]\n#[serde(rename_all = \"snake_case\")]\nenum DiscoverProjectData {\n Finished { buildfile: Utf8PathBuf, project: ProjectJsonData },\n Error { error: String, source: Option },\n Progress { message: String },\n}\n```\n\nAs JSON, `DiscoverProjectData::Finished` is:\n\n```json\n{\n // the internally-tagged representation of the enum.\n \"kind\": \"finished\",\n // the file used by a non-Cargo build system to define\n // a package or target.\n \"buildfile\": \"rust-analyzer/BUILD\",\n // the contents of a rust-project.json, elided for brevity\n \"project\": {\n \"sysroot\": \"foo\",\n \"crates\": []\n }\n}\n```\n\nIt is encouraged, but not required, to use the other variants on `DiscoverProjectData`\nto provide a more polished end-user experience.\n\n`DiscoverWorkspaceConfig::command` may *optionally* include an `{arg}`, which will be\nsubstituted with the JSON-serialized form of the following enum:\n\n```norun\n#[derive(PartialEq, Clone, Debug, Serialize)]\n#[serde(rename_all = \"camelCase\")]\npub enum DiscoverArgument {\n Path(AbsPathBuf),\n Buildfile(AbsPathBuf),\n}\n```\n\nThe JSON representation of `DiscoverArgument::Path` is:\n\n```json\n{\n \"path\": \"src/main.rs\"\n}\n```\n\nSimilarly, the JSON representation of `DiscoverArgument::Buildfile` is:\n\n```json\n{\n \"buildfile\": \"BUILD\"\n}\n```\n\n`DiscoverArgument::Path` is used to find and generate a `rust-project.json`, and\ntherefore, a workspace, whereas `DiscoverArgument::buildfile` is used to to update an\nexisting workspace. As a reference for implementors, buck2's `rust-project` will likely\nbe useful: .", "default": null, "anyOf": [ { diff --git a/src/tools/rust-analyzer/lib/line-index/src/lib.rs b/src/tools/rust-analyzer/lib/line-index/src/lib.rs index d5f0584d988f..905da330e64b 100644 --- a/src/tools/rust-analyzer/lib/line-index/src/lib.rs +++ b/src/tools/rust-analyzer/lib/line-index/src/lib.rs @@ -207,7 +207,7 @@ impl LineIndex { } } -/// This is adapted from the rustc_span crate, +/// This is adapted from the rustc_span crate, https://github.com/rust-lang/rust/blob/de59844c98f7925242a798a72c59dc3610dd0e2c/compiler/rustc_span/src/analyze_source_file.rs fn analyze_source_file(src: &str) -> (Vec, IntMap>) { assert!(src.len() < !0u32 as usize); let mut lines = vec![]; diff --git a/src/tools/rust-analyzer/lib/smol_str/CHANGELOG.md b/src/tools/rust-analyzer/lib/smol_str/CHANGELOG.md index 4aa25fa13446..b7da6d18a440 100644 --- a/src/tools/rust-analyzer/lib/smol_str/CHANGELOG.md +++ b/src/tools/rust-analyzer/lib/smol_str/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 0.3.5 - 2026-01-08 +## Unreleased - Optimise `SmolStr::clone` 4-5x speedup inline, 0.5x heap (slow down). ## 0.3.4 - 2025-10-23 diff --git a/src/tools/rust-analyzer/lib/smol_str/Cargo.toml b/src/tools/rust-analyzer/lib/smol_str/Cargo.toml index 4e7844b49e19..118b25993ffe 100644 --- a/src/tools/rust-analyzer/lib/smol_str/Cargo.toml +++ b/src/tools/rust-analyzer/lib/smol_str/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smol_str" -version = "0.3.5" +version = "0.3.4" description = "small-string optimized string type with O(1) clone" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust-analyzer/tree/master/lib/smol_str" diff --git a/src/tools/rust-analyzer/lib/smol_str/src/borsh.rs b/src/tools/rust-analyzer/lib/smol_str/src/borsh.rs index b684a4910c96..527ce85a1746 100644 --- a/src/tools/rust-analyzer/lib/smol_str/src/borsh.rs +++ b/src/tools/rust-analyzer/lib/smol_str/src/borsh.rs @@ -29,9 +29,8 @@ impl BorshDeserialize for SmolStr { })) } else { // u8::vec_from_reader always returns Some on success in current implementation - let vec = u8::vec_from_reader(len, reader)?.ok_or_else(|| { - Error::new(ErrorKind::Other, "u8::vec_from_reader unexpectedly returned None") - })?; + let vec = u8::vec_from_reader(len, reader)? + .ok_or_else(|| Error::other("u8::vec_from_reader unexpectedly returned None"))?; Ok(SmolStr::from(String::from_utf8(vec).map_err(|err| { let msg = err.to_string(); Error::new(ErrorKind::InvalidData, msg) diff --git a/src/tools/rust-analyzer/lib/smol_str/tests/test.rs b/src/tools/rust-analyzer/lib/smol_str/tests/test.rs index 00fab2ee1c7f..640e7df681c9 100644 --- a/src/tools/rust-analyzer/lib/smol_str/tests/test.rs +++ b/src/tools/rust-analyzer/lib/smol_str/tests/test.rs @@ -393,7 +393,7 @@ mod test_str_ext { } } -#[cfg(all(feature = "borsh", feature = "std"))] +#[cfg(feature = "borsh")] mod borsh_tests { use borsh::BorshDeserialize; use smol_str::{SmolStr, ToSmolStr}; diff --git a/src/tools/rust-analyzer/rust-version b/src/tools/rust-analyzer/rust-version index b22c6c3869c6..5ffe95a0b54f 100644 --- a/src/tools/rust-analyzer/rust-version +++ b/src/tools/rust-analyzer/rust-version @@ -1 +1 @@ -139651428df86cf88443295542c12ea617cbb587 +e7d44143a12a526488e4f0c0d7ea8e62a4fe9354 diff --git a/src/tools/rust-analyzer/xtask/src/codegen/grammar/ast_src.rs b/src/tools/rust-analyzer/xtask/src/codegen/grammar/ast_src.rs index 205072a6ce0c..b9f570fe0e32 100644 --- a/src/tools/rust-analyzer/xtask/src/codegen/grammar/ast_src.rs +++ b/src/tools/rust-analyzer/xtask/src/codegen/grammar/ast_src.rs @@ -112,7 +112,7 @@ const RESERVED: &[&str] = &[ // keywords that are keywords only in specific parse contexts #[doc(alias = "WEAK_KEYWORDS")] const CONTEXTUAL_KEYWORDS: &[&str] = - &["macro_rules", "union", "default", "raw", "dyn", "auto", "yeet", "safe", "bikeshed"]; + &["macro_rules", "union", "default", "raw", "dyn", "auto", "yeet", "safe"]; // keywords we use for special macro expansions const CONTEXTUAL_BUILTIN_KEYWORDS: &[&str] = &[ "asm", diff --git a/src/tools/rustbook/README.md b/src/tools/rustbook/README.md index a9fd1b75b572..d9570c23ead1 100644 --- a/src/tools/rustbook/README.md +++ b/src/tools/rustbook/README.md @@ -10,7 +10,7 @@ This is invoked automatically when building mdbook-style documentation, for exam ## Cargo workspace -This package defines a separate cargo workspace from the main Rust workspace for a few reasons (ref [#127786](https://github.com/rust-lang/rust/pull/127786)): +This package defines a separate cargo workspace from the main Rust workspace for a few reasons (ref [#127786](https://github.com/rust-lang/rust/pull/127786): - Avoids requiring checking out submodules for developers who are not working on the documentation. Otherwise, some submodules such as those that have custom preprocessors would be required for cargo to find the dependencies. - Avoids problems with updating dependencies. Unfortunately this workspace has a rather large set of dependencies, which can make coordinating updates difficult (see [#127890](https://github.com/rust-lang/rust/issues/127890)). diff --git a/src/tools/rustdoc/main.rs b/src/tools/rustdoc/main.rs index a35bcf9f547c..d4099cafe5df 100644 --- a/src/tools/rustdoc/main.rs +++ b/src/tools/rustdoc/main.rs @@ -1,8 +1,6 @@ // We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`. #![feature(rustc_private)] -use std::process::ExitCode; - -fn main() -> ExitCode { +fn main() { rustdoc::main() } diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 70bce1920047..de96f004dc87 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -385,33 +385,8 @@ pub(crate) fn format_expr( )) } } - ast::ExprKind::TryBlock(ref block, Some(ref ty)) => { - let keyword = "try bikeshed "; - // 2 = " {".len() - let ty_shape = shape - .shrink_left(keyword.len()) - .and_then(|shape| shape.sub_width(2)) - .max_width_error(shape.width, expr.span)?; - let ty_str = ty.rewrite_result(context, ty_shape)?; - let prefix = format!("{keyword}{ty_str} "); - if let rw @ Ok(_) = - rewrite_single_line_block(context, &prefix, block, Some(&expr.attrs), None, shape) - { - rw - } else { - let budget = shape.width.saturating_sub(prefix.len()); - Ok(format!( - "{prefix}{}", - rewrite_block( - block, - Some(&expr.attrs), - None, - context, - Shape::legacy(budget, shape.indent) - )? - )) - } - } + // FIXME: heterogeneous try blocks, which include a type so are harder to format + ast::ExprKind::TryBlock(_, Some(_)) => Err(RewriteError::Unknown), ast::ExprKind::Gen(capture_by, ref block, ref kind, _) => { let mover = if matches!(capture_by, ast::CaptureBy::Value { .. }) { "move " diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index 90466b0b1110..c9e32492c50b 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -319,13 +319,12 @@ impl<'a> FnSig<'a> { method_sig: &'a ast::FnSig, generics: &'a ast::Generics, visibility: &'a ast::Visibility, - defaultness: ast::Defaultness, ) -> FnSig<'a> { FnSig { safety: method_sig.header.safety, coroutine_kind: Cow::Borrowed(&method_sig.header.coroutine_kind), constness: method_sig.header.constness, - defaultness, + defaultness: ast::Defaultness::Final, ext: method_sig.header.ext, decl: &*method_sig.decl, generics, @@ -340,7 +339,9 @@ impl<'a> FnSig<'a> { ) -> FnSig<'a> { match *fn_kind { visit::FnKind::Fn(visit::FnCtxt::Assoc(..), vis, ast::Fn { sig, generics, .. }) => { - FnSig::from_method_sig(sig, generics, vis, defaultness) + let mut fn_sig = FnSig::from_method_sig(sig, generics, vis); + fn_sig.defaultness = defaultness; + fn_sig } visit::FnKind::Fn(_, vis, ast::Fn { sig, generics, .. }) => FnSig { decl, @@ -458,7 +459,6 @@ impl<'a> FmtVisitor<'a> { sig: &ast::FnSig, vis: &ast::Visibility, generics: &ast::Generics, - defaultness: ast::Defaultness, span: Span, ) -> RewriteResult { // Drop semicolon or it will be interpreted as comment. @@ -469,7 +469,7 @@ impl<'a> FmtVisitor<'a> { &context, indent, ident, - &FnSig::from_method_sig(sig, generics, vis, defaultness), + &FnSig::from_method_sig(sig, generics, vis), span, FnBraceStyle::None, )?; @@ -2028,16 +2028,12 @@ impl<'a> StaticParts<'a> { ), ast::ItemKind::Const(c) => ( Some(c.defaultness), - if c.rhs_kind.is_type_const() { - "type const" - } else { - "const" - }, + "const", ast::Safety::Default, c.ident, &c.ty, ast::Mutability::Not, - c.rhs_kind.expr(), + c.rhs.as_ref().map(|rhs| rhs.expr()), Some(&c.generics), ), _ => unreachable!(), @@ -2057,25 +2053,17 @@ impl<'a> StaticParts<'a> { } pub(crate) fn from_trait_item(ti: &'a ast::AssocItem, ident: Ident) -> Self { - let (defaultness, ty, expr_opt, generics, prefix) = match &ti.kind { - ast::AssocItemKind::Const(c) => { - let prefix = if c.rhs_kind.is_type_const() { - "type const" - } else { - "const" - }; - ( - c.defaultness, - &c.ty, - c.rhs_kind.expr(), - Some(&c.generics), - prefix, - ) - } + let (defaultness, ty, expr_opt, generics) = match &ti.kind { + ast::AssocItemKind::Const(c) => ( + c.defaultness, + &c.ty, + c.rhs.as_ref().map(|rhs| rhs.expr()), + Some(&c.generics), + ), _ => unreachable!(), }; StaticParts { - prefix, + prefix: "const", safety: ast::Safety::Default, vis: &ti.vis, ident, @@ -2089,25 +2077,17 @@ impl<'a> StaticParts<'a> { } pub(crate) fn from_impl_item(ii: &'a ast::AssocItem, ident: Ident) -> Self { - let (defaultness, ty, expr_opt, generics, prefix) = match &ii.kind { - ast::AssocItemKind::Const(c) => { - let prefix = if c.rhs_kind.is_type_const() { - "type const" - } else { - "const" - }; - ( - c.defaultness, - &c.ty, - c.rhs_kind.expr(), - Some(&c.generics), - prefix, - ) - } + let (defaultness, ty, expr_opt, generics) = match &ii.kind { + ast::AssocItemKind::Const(c) => ( + c.defaultness, + &c.ty, + c.rhs.as_ref().map(|rhs| rhs.expr()), + Some(&c.generics), + ), _ => unreachable!(), }; StaticParts { - prefix, + prefix: "const", safety: ast::Safety::Default, vis: &ii.vis, ident, @@ -3495,7 +3475,7 @@ impl Rewrite for ast::ForeignItem { context, shape.indent, ident, - &FnSig::from_method_sig(sig, generics, &self.vis, defaultness), + &FnSig::from_method_sig(sig, generics, &self.vis), span, FnBraceStyle::None, ) diff --git a/src/tools/rustfmt/src/parse/macros/cfg_if.rs b/src/tools/rustfmt/src/parse/macros/cfg_if.rs index 495f12c8f5d5..26bf6c5326f5 100644 --- a/src/tools/rustfmt/src/parse/macros/cfg_if.rs +++ b/src/tools/rustfmt/src/parse/macros/cfg_if.rs @@ -3,7 +3,7 @@ use std::panic::{AssertUnwindSafe, catch_unwind}; use rustc_ast::ast; use rustc_ast::token::TokenKind; use rustc_parse::exp; -use rustc_parse::parser::{AllowConstBlockItems, ForceCollect}; +use rustc_parse::parser::ForceCollect; use rustc_span::symbol::kw; use crate::parse::macros::build_stream_parser; @@ -61,7 +61,7 @@ fn parse_cfg_if_inner<'a>( } while parser.token != TokenKind::CloseBrace && parser.token.kind != TokenKind::Eof { - let item = match parser.parse_item(ForceCollect::No, AllowConstBlockItems::Yes) { + let item = match parser.parse_item(ForceCollect::No) { Ok(Some(item_ptr)) => *item_ptr, Ok(None) => continue, Err(err) => { diff --git a/src/tools/rustfmt/src/parse/macros/mod.rs b/src/tools/rustfmt/src/parse/macros/mod.rs index 552300b1b828..c063990dfa0b 100644 --- a/src/tools/rustfmt/src/parse/macros/mod.rs +++ b/src/tools/rustfmt/src/parse/macros/mod.rs @@ -2,7 +2,7 @@ use rustc_ast::ast; use rustc_ast::token::{Delimiter, NonterminalKind, NtExprKind::*, NtPatKind::*, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_parse::MACRO_ARGUMENTS; -use rustc_parse::parser::{AllowConstBlockItems, ForceCollect, Parser, Recovery}; +use rustc_parse::parser::{ForceCollect, Parser, Recovery}; use rustc_session::parse::ParseSess; use rustc_span::symbol; @@ -67,7 +67,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option { parse_macro_arg!( Item, NonterminalKind::Item, - |parser: &mut Parser<'b>| parser.parse_item(ForceCollect::No, AllowConstBlockItems::Yes), + |parser: &mut Parser<'b>| parser.parse_item(ForceCollect::No), |x: Option>| x ); diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 2a5c8f776427..2fd8bfdaf3e1 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use rustc_data_structures::sync::IntoDynSyncSend; -use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; -use rustc_errors::emitter::{DynEmitter, Emitter, SilentEmitter, stderr_destination}; +use rustc_errors::emitter::{DynEmitter, Emitter, HumanEmitter, SilentEmitter, stderr_destination}; +use rustc_errors::registry::Registry; use rustc_errors::translation::Translator; use rustc_errors::{ColorConfig, Diag, DiagCtxt, DiagInner, Level as DiagnosticLevel}; use rustc_session::parse::ParseSess as RawParseSess; @@ -40,10 +40,10 @@ struct SilentOnIgnoredFilesEmitter { } impl SilentOnIgnoredFilesEmitter { - fn handle_non_ignoreable_error(&mut self, diag: DiagInner) { + fn handle_non_ignoreable_error(&mut self, diag: DiagInner, registry: &Registry) { self.has_non_ignorable_parser_errors = true; self.can_reset.store(false, Ordering::Release); - self.emitter.emit_diagnostic(diag); + self.emitter.emit_diagnostic(diag, registry); } } @@ -52,9 +52,9 @@ impl Emitter for SilentOnIgnoredFilesEmitter { None } - fn emit_diagnostic(&mut self, diag: DiagInner) { + fn emit_diagnostic(&mut self, diag: DiagInner, registry: &Registry) { if diag.level() == DiagnosticLevel::Fatal { - return self.handle_non_ignoreable_error(diag); + return self.handle_non_ignoreable_error(diag, registry); } if let Some(primary_span) = &diag.span.primary_span() { let file_name = self.source_map.span_to_filename(*primary_span); @@ -72,7 +72,7 @@ impl Emitter for SilentOnIgnoredFilesEmitter { } } } - self.handle_non_ignoreable_error(diag); + self.handle_non_ignoreable_error(diag, registry); } fn translator(&self) -> &Translator { @@ -108,7 +108,7 @@ fn default_dcx( let emitter: Box = if show_parse_errors { Box::new( - AnnotateSnippetEmitter::new(stderr_destination(emit_color), translator) + HumanEmitter::new(stderr_destination(emit_color), translator) .sm(Some(source_map.clone())), ) } else { @@ -339,7 +339,7 @@ mod tests { None } - fn emit_diagnostic(&mut self, _diag: DiagInner) { + fn emit_diagnostic(&mut self, _diag: DiagInner, _registry: &Registry) { self.num_emitted_errors.fetch_add(1, Ordering::Release); } @@ -349,6 +349,7 @@ mod tests { } fn build_diagnostic(level: DiagnosticLevel, span: Option) -> DiagInner { + #[allow(rustc::untranslatable_diagnostic)] // no translation needed for empty string let mut diag = DiagInner::new(level, ""); diag.messages.clear(); if let Some(span) = span { @@ -400,6 +401,7 @@ mod tests { let source = String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#); source_map.new_source_file(filename(&source_map, "foo.rs"), source); + let registry = Registry::new(&[]); let mut emitter = build_emitter( Arc::clone(&num_emitted_errors), Arc::clone(&can_reset_errors), @@ -408,7 +410,7 @@ mod tests { ); let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); let fatal_diagnostic = build_diagnostic(DiagnosticLevel::Fatal, Some(span)); - emitter.emit_diagnostic(fatal_diagnostic); + emitter.emit_diagnostic(fatal_diagnostic, ®istry); assert_eq!(num_emitted_errors.load(Ordering::Acquire), 1); assert_eq!(can_reset_errors.load(Ordering::Acquire), false); } @@ -422,6 +424,7 @@ mod tests { let source_map = Arc::new(SourceMap::new(FilePathMapping::empty())); let source = String::from(r#"pub fn bar() { 1x; }"#); source_map.new_source_file(filename(&source_map, "foo.rs"), source); + let registry = Registry::new(&[]); let mut emitter = build_emitter( Arc::clone(&num_emitted_errors), Arc::clone(&can_reset_errors), @@ -430,7 +433,7 @@ mod tests { ); let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span)); - emitter.emit_diagnostic(non_fatal_diagnostic); + emitter.emit_diagnostic(non_fatal_diagnostic, ®istry); assert_eq!(num_emitted_errors.load(Ordering::Acquire), 0); assert_eq!(can_reset_errors.load(Ordering::Acquire), true); } @@ -443,6 +446,7 @@ mod tests { let source_map = Arc::new(SourceMap::new(FilePathMapping::empty())); let source = String::from(r#"pub fn bar() { 1x; }"#); source_map.new_source_file(filename(&source_map, "foo.rs"), source); + let registry = Registry::new(&[]); let mut emitter = build_emitter( Arc::clone(&num_emitted_errors), Arc::clone(&can_reset_errors), @@ -451,7 +455,7 @@ mod tests { ); let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span)); - emitter.emit_diagnostic(non_fatal_diagnostic); + emitter.emit_diagnostic(non_fatal_diagnostic, ®istry); assert_eq!(num_emitted_errors.load(Ordering::Acquire), 1); assert_eq!(can_reset_errors.load(Ordering::Acquire), false); } @@ -470,6 +474,7 @@ mod tests { source_map.new_source_file(filename(&source_map, "bar.rs"), bar_source); source_map.new_source_file(filename(&source_map, "foo.rs"), foo_source); source_map.new_source_file(filename(&source_map, "fatal.rs"), fatal_source); + let registry = Registry::new(&[]); let mut emitter = build_emitter( Arc::clone(&num_emitted_errors), Arc::clone(&can_reset_errors), @@ -481,9 +486,9 @@ mod tests { let bar_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(bar_span)); let foo_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(foo_span)); let fatal_diagnostic = build_diagnostic(DiagnosticLevel::Fatal, None); - emitter.emit_diagnostic(bar_diagnostic); - emitter.emit_diagnostic(foo_diagnostic); - emitter.emit_diagnostic(fatal_diagnostic); + emitter.emit_diagnostic(bar_diagnostic, ®istry); + emitter.emit_diagnostic(foo_diagnostic, ®istry); + emitter.emit_diagnostic(fatal_diagnostic, ®istry); assert_eq!(num_emitted_errors.load(Ordering::Acquire), 2); assert_eq!(can_reset_errors.load(Ordering::Acquire), false); } diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index b676803379f7..3a2975024a33 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -102,9 +102,8 @@ pub(crate) fn format_constness_right(constness: ast::Const) -> &'static str { #[inline] pub(crate) fn format_defaultness(defaultness: ast::Defaultness) -> &'static str { match defaultness { - ast::Defaultness::Implicit => "", ast::Defaultness::Default(..) => "default ", - ast::Defaultness::Final(..) => "final ", + ast::Defaultness::Final => "", } } diff --git a/src/tools/rustfmt/src/visitor.rs b/src/tools/rustfmt/src/visitor.rs index 742caefc7cc5..c521b497a2d9 100644 --- a/src/tools/rustfmt/src/visitor.rs +++ b/src/tools/rustfmt/src/visitor.rs @@ -7,9 +7,7 @@ use rustc_span::{BytePos, Ident, Pos, Span, symbol}; use tracing::debug; use crate::attr::*; -use crate::comment::{ - CodeCharKind, CommentCodeSlices, contains_comment, recover_comment_removed, rewrite_comment, -}; +use crate::comment::{CodeCharKind, CommentCodeSlices, contains_comment, rewrite_comment}; use crate::config::{BraceStyle, Config, MacroSelector, StyleEdition}; use crate::coverage::transform_missing_snippet; use crate::items::{ @@ -535,28 +533,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => { self.visit_static(&StaticParts::from_item(item)); } - ast::ItemKind::ConstBlock(ast::ConstBlockItem { - id: _, - span, - ref block, - }) => { - let context = &self.get_context(); - let offset = self.block_indent; - self.push_rewrite( - item.span, - block - .rewrite( - context, - Shape::legacy( - context.budget(offset.block_indent), - offset.block_only(), - ), - ) - .map(|rhs| { - recover_comment_removed(format!("const {rhs}"), span, context) - }), - ); - } ast::ItemKind::Fn(ref fn_kind) => { let ast::Fn { defaultness, @@ -583,15 +559,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { } else { let indent = self.block_indent; let rewrite = self - .rewrite_required_fn( - indent, - ident, - sig, - &item.vis, - generics, - defaultness, - item.span, - ) + .rewrite_required_fn(indent, ident, sig, &item.vis, generics, item.span) .ok(); self.push_rewrite(item.span, rewrite); } @@ -694,15 +662,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { } else { let indent = self.block_indent; let rewrite = self - .rewrite_required_fn( - indent, - fn_kind.ident, - sig, - &ai.vis, - generics, - defaultness, - ai.span, - ) + .rewrite_required_fn(indent, fn_kind.ident, sig, &ai.vis, generics, ai.span) .ok(); self.push_rewrite(ai.span, rewrite); } diff --git a/src/tools/rustfmt/tests/source/const-block-items.rs b/src/tools/rustfmt/tests/source/const-block-items.rs deleted file mode 100644 index f30f0fe256a5..000000000000 --- a/src/tools/rustfmt/tests/source/const-block-items.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![feature(const_block_items)] - - const { - - - assert!(true) - } - - #[cfg(false)] const { assert!(false) } - - - #[cfg(false)] -// foo - const - - { - // bar - assert!(false) - // baz - } // 123 - - - #[expect(unused)] -pub const { let a = 1; assert!(true); } diff --git a/src/tools/rustfmt/tests/source/try_block.rs b/src/tools/rustfmt/tests/source/try_block.rs index e324a1331758..2e8d61f7e66a 100644 --- a/src/tools/rustfmt/tests/source/try_block.rs +++ b/src/tools/rustfmt/tests/source/try_block.rs @@ -1,5 +1,4 @@ // rustfmt-edition: 2018 -#![feature(try_blocks)] fn main() -> Result<(), !> { let _x: Option<_> = try { diff --git a/src/tools/rustfmt/tests/source/try_blocks_heterogeneous.rs b/src/tools/rustfmt/tests/source/try_blocks_heterogeneous.rs deleted file mode 100644 index 7a1135cfbc76..000000000000 --- a/src/tools/rustfmt/tests/source/try_blocks_heterogeneous.rs +++ /dev/null @@ -1,39 +0,0 @@ -// rustfmt-edition: 2018 -#![feature(try_blocks_heterogeneous)] - -fn main() -> Result<(), !> { - let _x = try bikeshed Option<_> { - 4 - }; - - try bikeshed Result<_, _> {} -} - -fn baz() -> Option { - if (1 == 1) { - return try bikeshed Option { - 5 - }; - } - - // test - let x = try bikeshed Option<()> { - // try blocks are great - }; - - let y = try bikeshed Option { - 6 - }; // comment - - let x = try /* Invisible comment */ bikeshed Option<()> {}; - let x = try bikeshed /* Invisible comment */ Option<()> {}; - let x = try bikeshed Option<()> /* Invisible comment */ {}; - - let x = try bikeshed Option { baz()?; baz()?; baz()?; 7 }; - - let x = try bikeshed Foo { 1 + 1 + 1 }; - - let x = try bikeshed Foo {}; - - return None; -} diff --git a/src/tools/rustfmt/tests/target/const-block-items.rs b/src/tools/rustfmt/tests/target/const-block-items.rs deleted file mode 100644 index bbf6dbf481c7..000000000000 --- a/src/tools/rustfmt/tests/target/const-block-items.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(const_block_items)] - -const { assert!(true) } - -#[cfg(false)] -const { assert!(false) } - -#[cfg(false)] -// foo -const { - // bar - assert!(false) - // baz -} // 123 - -#[expect(unused)] -const { - let a = 1; - assert!(true); -} diff --git a/src/tools/rustfmt/tests/target/final-kw.rs b/src/tools/rustfmt/tests/target/final-kw.rs deleted file mode 100644 index d68b6908d76a..000000000000 --- a/src/tools/rustfmt/tests/target/final-kw.rs +++ /dev/null @@ -1,5 +0,0 @@ -trait Foo { - final fn final_() {} - - fn not_final() {} -} diff --git a/src/tools/rustfmt/tests/target/try_block.rs b/src/tools/rustfmt/tests/target/try_block.rs index 61da123b735d..19a3f3e14876 100644 --- a/src/tools/rustfmt/tests/target/try_block.rs +++ b/src/tools/rustfmt/tests/target/try_block.rs @@ -1,5 +1,4 @@ // rustfmt-edition: 2018 -#![feature(try_blocks)] fn main() -> Result<(), !> { let _x: Option<_> = try { 4 }; diff --git a/src/tools/rustfmt/tests/target/try_blocks_heterogeneous.rs b/src/tools/rustfmt/tests/target/try_blocks_heterogeneous.rs deleted file mode 100644 index 018d53ed35e4..000000000000 --- a/src/tools/rustfmt/tests/target/try_blocks_heterogeneous.rs +++ /dev/null @@ -1,41 +0,0 @@ -// rustfmt-edition: 2018 -#![feature(try_blocks_heterogeneous)] - -fn main() -> Result<(), !> { - let _x = try bikeshed Option<_> { 4 }; - - try bikeshed Result<_, _> {} -} - -fn baz() -> Option { - if (1 == 1) { - return try bikeshed Option { 5 }; - } - - // test - let x = try bikeshed Option<()> { - // try blocks are great - }; - - let y = try bikeshed Option { 6 }; // comment - - let x = try /* Invisible comment */ bikeshed Option<()> {}; - let x = try bikeshed /* Invisible comment */ Option<()> {}; - let x = try bikeshed Option<()> /* Invisible comment */ {}; - - let x = try bikeshed Option { - baz()?; - baz()?; - baz()?; - 7 - }; - - let x = try bikeshed Foo { - 1 + 1 + 1 - }; - - let x = - try bikeshed Foo {}; - - return None; -} diff --git a/src/tools/test-float-parse/src/traits.rs b/src/tools/test-float-parse/src/traits.rs index 0cb44d297bfb..65a8721bfa5c 100644 --- a/src/tools/test-float-parse/src/traits.rs +++ b/src/tools/test-float-parse/src/traits.rs @@ -155,7 +155,7 @@ macro_rules! impl_float { const BITS: u32 = <$ity>::BITS; const MAN_BITS: u32 = Self::MANTISSA_DIGITS - 1; const MAN_MASK: Self::Int = (Self::Int::ONE << Self::MAN_BITS) - Self::Int::ONE; - const SIGN_MASK: Self::Int = Self::Int::ONE << (::BITS-1); + const SIGN_MASK: Self::Int = Self::Int::ONE << (Self::BITS-1); fn from_bits(i: Self::Int) -> Self { Self::from_bits(i) } fn to_bits(self) -> Self::Int { self.to_bits() } fn constants() -> &'static Constants { diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index 4b38f9479fbc..cbf27ea87a07 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -16,10 +16,10 @@ semver = "1.0" serde = { version = "1.0.125", features = ["derive"], optional = true } termcolor = "1.1.3" rustc-hash = "2.0.0" +fluent-syntax = "0.12" similar = "2.5.0" toml = "0.7.8" tempfile = "3.15.0" -clap = "4.5.54" [features] build-metrics = ["dep:serde"] diff --git a/src/tools/tidy/src/alphabetical/tests.rs b/src/tools/tidy/src/alphabetical/tests.rs index 5fa0dd751b64..4a1d263f1a4f 100644 --- a/src/tools/tidy/src/alphabetical/tests.rs +++ b/src/tools/tidy/src/alphabetical/tests.rs @@ -37,7 +37,7 @@ fn bless_test(before: &str, after: &str) { let temp_path = tempfile::Builder::new().tempfile().unwrap().into_temp_path(); std::fs::write(&temp_path, before).unwrap(); - let tidy_ctx = TidyCtx::new(Path::new("/"), false, TidyFlags::new(true)); + let tidy_ctx = TidyCtx::new(Path::new("/"), false, TidyFlags::new(&["--bless".to_owned()])); let mut check = tidy_ctx.start_check("alphabetical-test"); check_lines(&temp_path, before, &tidy_ctx, &mut check); diff --git a/src/tools/tidy/src/arg_parser.rs b/src/tools/tidy/src/arg_parser.rs deleted file mode 100644 index 8041f739308d..000000000000 --- a/src/tools/tidy/src/arg_parser.rs +++ /dev/null @@ -1,102 +0,0 @@ -use std::num::NonZeroUsize; -use std::path::PathBuf; - -use clap::{Arg, ArgAction, ArgMatches, Command, value_parser}; - -#[cfg(test)] -mod tests; - -#[derive(Debug, Clone)] -pub struct TidyArgParser { - pub root_path: PathBuf, - pub cargo: PathBuf, - pub output_directory: PathBuf, - pub concurrency: NonZeroUsize, - pub npm: PathBuf, - pub verbose: bool, - pub bless: bool, - pub extra_checks: Option>, - pub pos_args: Vec, -} - -impl TidyArgParser { - fn command() -> Command { - Command::new("rust-tidy") - .arg( - Arg::new("root_path") - .help("path of the root directory") - .long("root-path") - .required(true) - .value_parser(value_parser!(PathBuf)), - ) - .arg( - Arg::new("cargo") - .help("path of cargo") - .long("cargo-path") - .required(true) - .value_parser(value_parser!(PathBuf)), - ) - .arg( - Arg::new("output_directory") - .help("path of output directory") - .long("output-dir") - .required(true) - .value_parser(value_parser!(PathBuf)), - ) - .arg( - Arg::new("concurrency") - .help("number of threads working concurrently") - .long("concurrency") - .required(true) - .value_parser(value_parser!(NonZeroUsize)), - ) - .arg( - Arg::new("npm") - .help("path of npm") - .long("npm-path") - .required(true) - .value_parser(value_parser!(PathBuf)), - ) - .arg(Arg::new("verbose").help("verbose").long("verbose").action(ArgAction::SetTrue)) - .arg(Arg::new("bless").help("target files are modified").long("bless").action(ArgAction::SetTrue)) - .arg( - Arg::new("extra_checks") - .help("extra checks") - .long("extra-checks") - .value_delimiter(',') - .action(ArgAction::Append), - ) - .arg(Arg::new("pos_args").help("for extra checks. you can specify configs and target files for external check tools").action(ArgAction::Append).last(true)) - } - - fn build(matches: ArgMatches) -> Self { - let mut tidy_flags = Self { - root_path: matches.get_one::("root_path").unwrap().clone(), - cargo: matches.get_one::("cargo").unwrap().clone(), - output_directory: matches.get_one::("output_directory").unwrap().clone(), - concurrency: *matches.get_one::("concurrency").unwrap(), - npm: matches.get_one::("npm").unwrap().clone(), - verbose: *matches.get_one::("verbose").unwrap(), - bless: *matches.get_one::("bless").unwrap(), - extra_checks: None, - pos_args: vec![], - }; - - if let Some(extra_checks) = matches.get_many::("extra_checks") { - tidy_flags.extra_checks = Some(extra_checks.map(|s| s.to_string()).collect::>()); - } - - tidy_flags.pos_args = matches - .get_many::("pos_args") - .unwrap_or_default() - .map(|v| v.to_string()) - .collect::>(); - - tidy_flags - } - - pub fn parse() -> Self { - let matches = Self::command().get_matches(); - Self::build(matches) - } -} diff --git a/src/tools/tidy/src/arg_parser/tests.rs b/src/tools/tidy/src/arg_parser/tests.rs deleted file mode 100644 index c5e7aed21c1a..000000000000 --- a/src/tools/tidy/src/arg_parser/tests.rs +++ /dev/null @@ -1,168 +0,0 @@ -use std::path::PathBuf; - -use crate::arg_parser::TidyArgParser; - -// Test all arguments -#[test] -fn test_tidy_parser_full() { - let args = vec![ - "rust-tidy", - "--root-path", - "/home/user/rust", - "--cargo-path", - "/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", - "--output-dir", - "/home/user/rust/build", - "--concurrency", - "16", - "--npm-path", - "yarn", - "--verbose", - "--bless", - "--extra-checks", - "if-installed:auto:js,auto:if-installed:py,if-installed:auto:cpp,if-installed:auto:spellcheck", - "--", // pos_args - "some-file", - "some-file2", - ]; - let cmd = TidyArgParser::command(); - let parsed_args = TidyArgParser::build(cmd.get_matches_from(args)); - - assert_eq!(parsed_args.root_path, PathBuf::from("/home/user/rust")); - assert_eq!( - parsed_args.cargo, - PathBuf::from("/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo") - ); - assert_eq!(parsed_args.output_directory, PathBuf::from("/home/user/rust/build")); - assert_eq!(parsed_args.concurrency.get(), 16); - assert_eq!(parsed_args.npm, PathBuf::from("yarn")); - assert!(parsed_args.verbose); - assert!(parsed_args.bless); - assert_eq!( - parsed_args.extra_checks, - Some(vec![ - "if-installed:auto:js".to_string(), - "auto:if-installed:py".to_string(), - "if-installed:auto:cpp".to_string(), - "if-installed:auto:spellcheck".to_string(), - ]) - ); - assert_eq!(parsed_args.pos_args, vec!["some-file".to_string(), "some-file2".to_string()]); -} - -// The parser can take required args any order -#[test] -fn test_tidy_parser_any_order() { - let args = vec![ - "rust-tidy", - "--npm-path", - "yarn", - "--concurrency", - "16", - "--output-dir", - "/home/user/rust/build", - "--cargo-path", - "/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", - "--root-path", - "/home/user/rust", - ]; - let cmd = TidyArgParser::command(); - let parsed_args = TidyArgParser::build(cmd.get_matches_from(args)); - - assert_eq!(parsed_args.root_path, PathBuf::from("/home/user/rust")); - assert_eq!( - parsed_args.cargo, - PathBuf::from("/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo") - ); - assert_eq!(parsed_args.output_directory, PathBuf::from("/home/user/rust/build")); - assert_eq!(parsed_args.concurrency.get(), 16); - assert_eq!(parsed_args.npm, PathBuf::from("yarn")); -} - -// --root-path is required -#[test] -fn test_tidy_parser_missing_root_path() { - let args = vec![ - "rust-tidy", - "--npm-path", - "yarn", - "--concurrency", - "16", - "--output-dir", - "/home/user/rust/build", - "--cargo-path", - "/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", - ]; - let cmd = TidyArgParser::command(); - assert!(cmd.try_get_matches_from(args).is_err()); -} - -// --cargo-path is required -#[test] -fn test_tidy_parser_missing_cargo_path() { - let args = vec![ - "rust-tidy", - "--npm-path", - "yarn", - "--concurrency", - "16", - "--output-dir", - "/home/user/rust/build", - "--root-path", - "/home/user/rust", - ]; - let cmd = TidyArgParser::command(); - assert!(cmd.try_get_matches_from(args).is_err()); -} - -// --output-dir is required -#[test] -fn test_tidy_parser_missing_output_dir() { - let args = vec![ - "rust-tidy", - "--npm-path", - "yarn", - "--concurrency", - "16", - "--cargo-path", - "/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", - "--root-path", - "/home/user/rust", - ]; - let cmd = TidyArgParser::command(); - assert!(cmd.try_get_matches_from(args).is_err()); -} - -// --concurrency is required -#[test] -fn test_tidy_parser_missing_concurrency() { - let args = vec![ - "rust-tidy", - "--npm-path", - "yarn", - "--output-dir", - "/home/user/rust/build", - "--cargo-path", - "/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", - "--root-path", - "/home/user/rust", - ]; - let cmd = TidyArgParser::command(); - assert!(cmd.try_get_matches_from(args).is_err()); -} - -// --npm-path is required -#[test] -fn test_tidy_parser_missing_npm_path() { - let args = vec![ - "rust-tidy", - "--concurrency", - "16", - "--output-dir", - "/home/user/rust/build", - "--cargo-path", - "/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", - ]; - let cmd = TidyArgParser::command(); - assert!(cmd.try_get_matches_from(args).is_err()); -} diff --git a/src/tools/tidy/src/diagnostics.rs b/src/tools/tidy/src/diagnostics.rs index 4e6c316f5e18..88816b5abeff 100644 --- a/src/tools/tidy/src/diagnostics.rs +++ b/src/tools/tidy/src/diagnostics.rs @@ -14,8 +14,16 @@ pub struct TidyFlags { } impl TidyFlags { - pub fn new(bless: bool) -> Self { - Self { bless } + pub fn new(cfg_args: &[String]) -> Self { + let mut flags = Self::default(); + + for arg in cfg_args { + match arg.as_str() { + "--bless" => flags.bless = true, + _ => continue, + } + } + flags } } @@ -205,7 +213,7 @@ impl RunningCheck { } } - /// Has an error already occurred for this check? + /// Has an error already occured for this check? pub fn is_bad(&self) -> bool { self.bad } diff --git a/src/tools/tidy/src/extra_checks/mod.rs b/src/tools/tidy/src/extra_checks/mod.rs index 28e78b396d55..1c81a485608a 100644 --- a/src/tools/tidy/src/extra_checks/mod.rs +++ b/src/tools/tidy/src/extra_checks/mod.rs @@ -58,8 +58,8 @@ pub fn check( tools_path: &Path, npm: &Path, cargo: &Path, - extra_checks: Option>, - pos_args: Vec, + extra_checks: Option<&str>, + pos_args: &[String], tidy_ctx: TidyCtx, ) { let mut check = tidy_ctx.start_check("extra_checks"); @@ -88,8 +88,8 @@ fn check_impl( tools_path: &Path, npm: &Path, cargo: &Path, - extra_checks: Option>, - pos_args: Vec, + extra_checks: Option<&str>, + pos_args: &[String], tidy_ctx: &TidyCtx, ) -> Result<(), Error> { let show_diff = @@ -99,7 +99,9 @@ fn check_impl( // Split comma-separated args up let mut lint_args = match extra_checks { Some(s) => s - .iter() + .strip_prefix("--extra-checks=") + .unwrap() + .split(',') .map(|s| { if s == "spellcheck:fix" { eprintln!("warning: `spellcheck:fix` is no longer valid, use `--extra-checks=spellcheck --bless`"); @@ -334,9 +336,9 @@ fn check_impl( if js_lint { if bless { - eprintln!("linting javascript files and applying suggestions"); - } else { eprintln!("linting javascript files"); + } else { + eprintln!("linting javascript files and applying suggestions"); } let res = rustdoc_js::lint(outdir, librustdoc_path, tools_path, bless); if res.is_err() { diff --git a/src/tools/tidy/src/fluent_alphabetical.rs b/src/tools/tidy/src/fluent_alphabetical.rs new file mode 100644 index 000000000000..7583241ea638 --- /dev/null +++ b/src/tools/tidy/src/fluent_alphabetical.rs @@ -0,0 +1,125 @@ +//! Checks that all Flunt files have messages in alphabetical order + +use std::collections::HashMap; +use std::fs::OpenOptions; +use std::io::Write; +use std::path::Path; + +use fluent_syntax::ast::Entry; +use fluent_syntax::parser; +use regex::Regex; + +use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; +use crate::walk::{filter_dirs, walk}; + +fn message() -> &'static Regex { + static_regex!(r#"(?m)^([a-zA-Z0-9_]+)\s*=\s*"#) +} + +fn is_fluent(path: &Path) -> bool { + path.extension().is_some_and(|ext| ext == "ftl") +} + +fn check_alphabetic( + filename: &str, + fluent: &str, + check: &mut RunningCheck, + all_defined_msgs: &mut HashMap, +) { + let Ok(resource) = parser::parse(fluent) else { + panic!("Errors encountered while parsing fluent file `{filename}`"); + }; + + let mut prev: Option<&str> = None; + + for entry in &resource.body { + if let Entry::Message(msg) = entry { + let name: &str = msg.id.name; + if let Some(defined_filename) = all_defined_msgs.get(name) { + check.error(format!( + "{filename}: message `{name}` is already defined in {defined_filename}", + )); + } else { + all_defined_msgs.insert(name.to_string(), filename.to_owned()); + } + if let Some(prev) = prev + && prev > name + { + check.error(format!( + "{filename}: message `{prev}` appears before `{name}`, but is alphabetically \ +later than it. Run `./x.py test tidy --bless` to sort the file correctly", + )); + } + prev = Some(name); + } + } +} + +fn sort_messages( + filename: &str, + fluent: &str, + check: &mut RunningCheck, + all_defined_msgs: &mut HashMap, +) -> String { + let mut chunks = vec![]; + let mut cur = String::new(); + for line in fluent.lines() { + if let Some(name) = message().find(line) { + if let Some(defined_filename) = all_defined_msgs.get(name.as_str()) { + check.error(format!( + "{filename}: message `{}` is already defined in {defined_filename}", + name.as_str(), + )); + } + + all_defined_msgs.insert(name.as_str().to_owned(), filename.to_owned()); + chunks.push(std::mem::take(&mut cur)); + } + + cur += line; + cur.push('\n'); + } + chunks.push(cur); + chunks.sort(); + let mut out = chunks.join(""); + out = out.trim().to_string(); + out.push('\n'); + out +} + +pub fn check(path: &Path, tidy_ctx: TidyCtx) { + let mut check = tidy_ctx.start_check(CheckId::new("fluent_alphabetical").path(path)); + let bless = tidy_ctx.is_bless_enabled(); + + let mut all_defined_msgs = HashMap::new(); + walk( + path, + |path, is_dir| filter_dirs(path) || (!is_dir && !is_fluent(path)), + &mut |ent, contents| { + if bless { + let sorted = sort_messages( + ent.path().to_str().unwrap(), + contents, + &mut check, + &mut all_defined_msgs, + ); + if sorted != contents { + let mut f = + OpenOptions::new().write(true).truncate(true).open(ent.path()).unwrap(); + f.write_all(sorted.as_bytes()).unwrap(); + } + } else { + check_alphabetic( + ent.path().to_str().unwrap(), + contents, + &mut check, + &mut all_defined_msgs, + ); + } + }, + ); + + assert!(!all_defined_msgs.is_empty()); + + crate::fluent_used::check(path, all_defined_msgs, tidy_ctx); +} diff --git a/src/tools/tidy/src/fluent_lowercase.rs b/src/tools/tidy/src/fluent_lowercase.rs new file mode 100644 index 000000000000..690b733a5b64 --- /dev/null +++ b/src/tools/tidy/src/fluent_lowercase.rs @@ -0,0 +1,65 @@ +//! Checks that the error messages start with a lowercased letter (except when allowed to). + +use std::path::Path; + +use fluent_syntax::ast::{Entry, Message, PatternElement}; + +use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; +use crate::walk::{filter_dirs, walk}; + +#[rustfmt::skip] +const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[ + // tidy-alphabetical-start + "ABI", + "ABIs", + "ADT", + "C", + "CGU", + "Ferris", + "MIR", + "OK", + "Rust", + "VS", // VS Code + // tidy-alphabetical-end +]; + +fn filter_fluent(path: &Path) -> bool { + if let Some(ext) = path.extension() { ext.to_str() != Some("ftl") } else { true } +} + +fn is_allowed_capitalized_word(msg: &str) -> bool { + ALLOWED_CAPITALIZED_WORDS.iter().any(|word| { + msg.strip_prefix(word) + .map(|tail| tail.chars().next().map(|c| c == '-' || c.is_whitespace()).unwrap_or(true)) + .unwrap_or_default() + }) +} + +fn check_lowercase(filename: &str, contents: &str, check: &mut RunningCheck) { + let (Ok(parse) | Err((parse, _))) = fluent_syntax::parser::parse(contents); + + for entry in &parse.body { + if let Entry::Message(msg) = entry + && let Message { value: Some(pattern), .. } = msg + && let [first_pattern, ..] = &pattern.elements[..] + && let PatternElement::TextElement { value } = first_pattern + && value.chars().next().is_some_and(char::is_uppercase) + && !is_allowed_capitalized_word(value) + { + check.error(format!( + "{filename}: message `{value}` starts with an uppercase letter. Fix it or add it to `ALLOWED_CAPITALIZED_WORDS`" + )); + } + } +} + +pub fn check(path: &Path, tidy_ctx: TidyCtx) { + let mut check = tidy_ctx.start_check(CheckId::new("fluent_lowercase").path(path)); + walk( + path, + |path, is_dir| filter_dirs(path) || (!is_dir && filter_fluent(path)), + &mut |ent, contents| { + check_lowercase(ent.path().to_str().unwrap(), contents, &mut check); + }, + ); +} diff --git a/src/tools/tidy/src/fluent_period.rs b/src/tools/tidy/src/fluent_period.rs new file mode 100644 index 000000000000..e7d59e2ce2a9 --- /dev/null +++ b/src/tools/tidy/src/fluent_period.rs @@ -0,0 +1,88 @@ +//! Checks that no Fluent messages or attributes end in periods (except ellipses) + +use std::path::Path; + +use fluent_syntax::ast::{Entry, PatternElement}; + +use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; +use crate::walk::{filter_dirs, walk}; + +fn filter_fluent(path: &Path) -> bool { + if let Some(ext) = path.extension() { ext.to_str() != Some("ftl") } else { true } +} + +/// Messages allowed to have `.` at their end. +/// +/// These should probably be reworked eventually. +const ALLOWLIST: &[&str] = &[ + "const_eval_long_running", + "const_eval_validation_failure_note", + "driver_impl_ice", + "incremental_corrupt_file", +]; + +fn check_period(filename: &str, contents: &str, check: &mut RunningCheck) { + if filename.contains("codegen") { + // FIXME: Too many codegen messages have periods right now... + return; + } + + let (Ok(parse) | Err((parse, _))) = fluent_syntax::parser::parse(contents); + for entry in &parse.body { + if let Entry::Message(m) = entry { + if ALLOWLIST.contains(&m.id.name) { + continue; + } + + if let Some(pat) = &m.value + && let Some(PatternElement::TextElement { value }) = pat.elements.last() + { + // We don't care about ellipses. + if value.ends_with(".") && !value.ends_with("...") { + let ll = find_line(contents, value); + let name = m.id.name; + check.error(format!("{filename}:{ll}: message `{name}` ends in a period")); + } + } + + for attr in &m.attributes { + // Teach notes usually have long messages. + if attr.id.name == "teach_note" { + continue; + } + + if let Some(PatternElement::TextElement { value }) = attr.value.elements.last() + && value.ends_with(".") + && !value.ends_with("...") + { + let ll = find_line(contents, value); + let name = attr.id.name; + check.error(format!("{filename}:{ll}: attr `{name}` ends in a period")); + } + } + } + } +} + +/// Evil cursed bad hack. Requires that `value` be a substr (in memory) of `contents`. +fn find_line(haystack: &str, needle: &str) -> usize { + for (ll, line) in haystack.lines().enumerate() { + if line.as_ptr() > needle.as_ptr() { + return ll; + } + } + + 1 +} + +pub fn check(path: &Path, tidy_ctx: TidyCtx) { + let mut check = tidy_ctx.start_check(CheckId::new("fluent_period").path(path)); + + walk( + path, + |path, is_dir| filter_dirs(path) || (!is_dir && filter_fluent(path)), + &mut |ent, contents| { + check_period(ent.path().to_str().unwrap(), contents, &mut check); + }, + ); +} diff --git a/src/tools/tidy/src/fluent_used.rs b/src/tools/tidy/src/fluent_used.rs new file mode 100644 index 000000000000..75da1d7ea49d --- /dev/null +++ b/src/tools/tidy/src/fluent_used.rs @@ -0,0 +1,42 @@ +//! Checks that all Fluent messages appear at least twice + +use std::collections::HashMap; +use std::path::Path; + +use crate::diagnostics::{CheckId, TidyCtx}; +use crate::walk::{filter_dirs, walk}; + +fn filter_used_messages( + contents: &str, + msgs_not_appeared_yet: &mut HashMap, + msgs_appeared_only_once: &mut HashMap, +) { + // we don't just check messages never appear in Rust files, + // because messages can be used as parts of other fluent messages in Fluent files, + // so we check messages appear only once in all Rust and Fluent files. + let matches = static_regex!(r"\w+").find_iter(contents); + for name in matches { + if let Some((name, filename)) = msgs_not_appeared_yet.remove_entry(name.as_str()) { + // if one msg appears for the first time, + // remove it from `msgs_not_appeared_yet` and insert it into `msgs_appeared_only_once`. + msgs_appeared_only_once.insert(name, filename); + } else { + // if one msg appears for the second time, + // remove it from `msgs_appeared_only_once`. + msgs_appeared_only_once.remove(name.as_str()); + } + } +} + +pub fn check(path: &Path, mut all_defined_msgs: HashMap, tidy_ctx: TidyCtx) { + let mut check = tidy_ctx.start_check(CheckId::new("fluent_used").path(path)); + + let mut msgs_appear_only_once = HashMap::new(); + walk(path, |path, _| filter_dirs(path), &mut |_, contents| { + filter_used_messages(contents, &mut all_defined_msgs, &mut msgs_appear_only_once); + }); + + for (name, filename) in msgs_appear_only_once { + check.error(format!("{filename}: message `{name}` is not used")); + } +} diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index 9c176e9fffa1..c747636691f6 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -2450,6 +2450,7 @@ ui/single-use-lifetime/issue-107998.rs ui/single-use-lifetime/issue-117965.rs ui/span/issue-107353.rs ui/span/issue-11925.rs +ui/span/issue-15480.rs ui/span/issue-23338-locals-die-before-temps-of-body.rs ui/span/issue-23729.rs ui/span/issue-23827.rs @@ -2977,6 +2978,7 @@ ui/unboxed-closures/issue-18652.rs ui/unboxed-closures/issue-18661.rs ui/unboxed-closures/issue-30906.rs ui/unboxed-closures/issue-53448.rs +ui/underscore-imports/issue-110164.rs ui/uniform-paths/auxiliary/issue-53691.rs ui/uniform-paths/issue-53691.rs ui/uninhabited/issue-107505.rs diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index ed41130f5d29..425f43e42b7f 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -157,7 +157,6 @@ pub fn files_modified(ci_info: &CiInfo, pred: impl Fn(&str) -> bool) -> bool { } pub mod alphabetical; -pub mod arg_parser; pub mod bins; pub mod debug_artifacts; pub mod deps; @@ -168,6 +167,10 @@ pub mod extdeps; pub mod extra_checks; pub mod features; pub mod filenames; +pub mod fluent_alphabetical; +pub mod fluent_lowercase; +pub mod fluent_period; +mod fluent_used; pub mod gcc_submodule; pub(crate) mod iter_header; pub mod known_bug; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 09c08e1baf50..94c24f11ed12 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -5,10 +5,12 @@ //! builders. The tidy checks can be executed with `./x.py test tidy`. use std::collections::VecDeque; +use std::num::NonZeroUsize; +use std::path::PathBuf; +use std::str::FromStr; use std::thread::{self, ScopedJoinHandle, scope}; use std::{env, process}; -use tidy::arg_parser::TidyArgParser; use tidy::diagnostics::{COLOR_ERROR, COLOR_SUCCESS, TidyCtx, TidyFlags, output_message}; use tidy::*; @@ -20,16 +22,16 @@ fn main() { env::set_var("RUSTC_BOOTSTRAP", "1"); } - let parsed_args = TidyArgParser::parse(); - - let root_path = parsed_args.root_path; - let cargo = parsed_args.cargo; - let output_directory = parsed_args.output_directory; - let concurrency = parsed_args.concurrency.get(); - let npm = parsed_args.npm; + let root_path: PathBuf = env::args_os().nth(1).expect("need path to root of repo").into(); + let cargo: PathBuf = env::args_os().nth(2).expect("need path to cargo").into(); + let output_directory: PathBuf = + env::args_os().nth(3).expect("need path to output directory").into(); + let concurrency: NonZeroUsize = + FromStr::from_str(&env::args().nth(4).expect("need concurrency")) + .expect("concurrency must be a number"); + let npm: PathBuf = env::args_os().nth(5).expect("need name/path of npm command").into(); let root_manifest = root_path.join("Cargo.toml"); - let typos_toml = root_path.join("typos.toml"); let src_path = root_path.join("src"); let tests_path = root_path.join("tests"); let library_path = root_path.join("library"); @@ -38,12 +40,17 @@ fn main() { let tools_path = src_path.join("tools"); let crashes_path = tests_path.join("crashes"); - let verbose = parsed_args.verbose; - let bless = parsed_args.bless; - let extra_checks = parsed_args.extra_checks; - let pos_args = parsed_args.pos_args; + let args: Vec = env::args().skip(1).collect(); + let (cfg_args, pos_args) = match args.iter().position(|arg| arg == "--") { + Some(pos) => (&args[..pos], &args[pos + 1..]), + None => (&args[..], [].as_slice()), + }; + let verbose = cfg_args.iter().any(|s| *s == "--verbose"); + let extra_checks = + cfg_args.iter().find(|s| s.starts_with("--extra-checks=")).map(String::as_str); - let tidy_ctx = TidyCtx::new(&root_path, verbose, TidyFlags::new(bless)); + let tidy_flags = TidyFlags::new(cfg_args); + let tidy_ctx = TidyCtx::new(&root_path, verbose, tidy_flags); let ci_info = CiInfo::new(tidy_ctx.clone()); let drain_handles = |handles: &mut VecDeque>| { @@ -54,13 +61,14 @@ fn main() { } } - while handles.len() >= concurrency { + while handles.len() >= concurrency.get() { handles.pop_front().unwrap().join().unwrap(); } }; scope(|s| { - let mut handles: VecDeque> = VecDeque::with_capacity(concurrency); + let mut handles: VecDeque> = + VecDeque::with_capacity(concurrency.get()); macro_rules! check { ($p:ident) => { @@ -107,6 +115,9 @@ fn main() { // Checks that only make sense for the compiler. check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], &ci_info); + check!(fluent_alphabetical, &compiler_path); + check!(fluent_period, &compiler_path); + check!(fluent_lowercase, &compiler_path); check!(target_policy, &root_path); check!(gcc_submodule, &root_path, &compiler_path); @@ -132,7 +143,6 @@ fn main() { check!(edition, &library_path); check!(alphabetical, &root_manifest); - check!(alphabetical, &typos_toml); check!(alphabetical, &src_path); check!(alphabetical, &tests_path); check!(alphabetical, &compiler_path); diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index f1ac90ba0bc5..e6423aeeba99 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -38,7 +38,7 @@ use crate::walk::{filter_dirs, walk}; const EXCEPTION_PATHS: &[&str] = &[ "library/compiler-builtins", "library/std_detect", - "library/windows_link", + "library/windows_targets", "library/panic_abort", "library/panic_unwind", "library/unwind", diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index ea365527a8cd..11138de5de76 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -98,7 +98,7 @@ fn arch_to_llvm_component(arch: &str) -> String { // enough for the purpose of this tidy check. match arch { "amdgcn" => "amdgpu".into(), - "aarch64v8r" | "aarch64_be" | "arm64_32" | "arm64e" | "arm64ec" => "aarch64".into(), + "aarch64_be" | "arm64_32" | "arm64e" | "arm64ec" => "aarch64".into(), "i386" | "i586" | "i686" | "x86" | "x86_64" | "x86_64h" => "x86".into(), "loongarch32" | "loongarch64" => "loongarch".into(), "nvptx64" => "nvptx".into(), diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index c16cfbe899b7..bf51810810a6 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -73,57 +73,6 @@ pub fn check(root_path: &Path, tidy_ctx: TidyCtx) { )); } } - - // The list of subdirectories in ui tests. - // Compare previous subdirectory with current subdirectory - // to sync with `tests/ui/README.md`. - // See - let mut prev_line = String::new(); - let mut is_sorted = true; - let documented_subdirs: BTreeSet<_> = include_str!("../../../../tests/ui/README.md") - .lines() - .filter_map(|line| { - static_regex!(r"^##.*?`(?

[^`]+)`").captures(line).map(|cap| { - let dir = &cap["dir"]; - // FIXME(reddevilmidzy) normalize subdirs title in tests/ui/README.md - if dir.ends_with('/') { - dir.strip_suffix('/').unwrap().to_string() - } else { - dir.to_string() - } - }) - }) - .inspect(|line| { - if prev_line.as_str() > line.as_str() { - is_sorted = false; - } - - prev_line = line.clone(); - }) - .collect(); - let filesystem_subdirs = collect_ui_tests_subdirs(&path); - let is_modified = !filesystem_subdirs.eq(&documented_subdirs); - - if !is_sorted { - check.error("`tests/ui/README.md` is not in order"); - } - if is_modified { - for directory in documented_subdirs.symmetric_difference(&filesystem_subdirs) { - if documented_subdirs.contains(directory) { - check.error(format!( - "ui subdirectory `{directory}` is listed in `tests/ui/README.md` but does not exist in the filesystem" - )); - } else { - check.error(format!( - "ui subdirectory `{directory}` exists in the filesystem but is not documented in `tests/ui/README.md`" - )); - } - } - check.error( - "`tests/ui/README.md` subdirectory listing is out of sync with the filesystem. \ - Please add or remove subdirectory entries (## headers with backtick-wrapped names) to match the actual directories in `tests/ui/`" - ); - } } fn deny_new_top_level_ui_tests(check: &mut RunningCheck, tests_path: &Path) { @@ -188,24 +137,6 @@ fn recursively_check_ui_tests<'issues>( remaining_issue_names } -fn collect_ui_tests_subdirs(path: &Path) -> BTreeSet { - let ui = path.join("ui"); - let entries = std::fs::read_dir(ui.as_path()).unwrap(); - - entries - .filter_map(|entry| entry.ok()) - .map(|entry| entry.path()) - .filter(|path| path.is_dir()) - .map(|dir_path| { - let dir_path = dir_path.strip_prefix(path).unwrap(); - format!( - "tests/{}", - dir_path.to_string_lossy().replace(std::path::MAIN_SEPARATOR_STR, "/") - ) - }) - .collect() -} - fn check_unexpected_extension(check: &mut RunningCheck, file_path: &Path, ext: &str) { const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files @@ -219,7 +150,6 @@ fn check_unexpected_extension(check: &mut RunningCheck, file_path: &Path, ext: & const EXTENSION_EXCEPTION_PATHS: &[&str] = &[ "tests/ui/asm/named-asm-labels.s", // loading an external asm file to test named labels lint - "tests/ui/asm/normalize-offsets-for-crlf.s", // loading an external asm file to test CRLF normalization "tests/ui/codegen/mismatched-data-layout.json", // testing mismatched data layout w/ custom targets "tests/ui/check-cfg/my-awesome-platform.json", // testing custom targets with cfgs "tests/ui/argfile/commandline-argfile-badutf8.args", // passing args via a file @@ -303,7 +233,7 @@ fn deny_new_nondescriptive_test_names( && !stripped_path.starts_with("ui/issues/") { check.error(format!( - "issue-number-only test names are not descriptive, consider renaming file `tests/{stripped_path}` to `{{reason}}-issue-{issue_n}.rs`", + "file `tests/{stripped_path}` must begin with a descriptive name, consider `{{reason}}-issue-{issue_n}.rs`", issue_n = &test_name[1], )); } diff --git a/src/tools/update-lockfile.sh b/src/tools/update-lockfile.sh deleted file mode 100755 index 123481b6b681..000000000000 --- a/src/tools/update-lockfile.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Updates the workspaces in `.`, `library` and `src/tools/rustbook` -# Logs are written to `cargo_update.log` -# Used as part of regular dependency bumps - -set -euo pipefail - -printf "\ncompiler & tools dependencies:" > cargo_update.log -# Remove first line that always just says "Updating crates.io index" -cargo update 2>&1 | sed '/crates.io index/d' | \ - tee -a cargo_update.log -printf "\nlibrary dependencies:" >> cargo_update.log -cargo update --manifest-path library/Cargo.toml 2>&1 | sed '/crates.io index/d' | \ - tee -a cargo_update.log -printf "\nrustbook dependencies:" >> cargo_update.log -cargo update --manifest-path src/tools/rustbook/Cargo.toml 2>&1 | sed '/crates.io index/d' | \ - tee -a cargo_update.log diff --git a/src/version b/src/version index 55f6ae93382d..8db4a57b3d02 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.95.0 +1.94.0 diff --git a/tests/assembly-llvm/align_offset.rs b/tests/assembly-llvm/align_offset.rs index 5663dca30b25..d9902ce336b0 100644 --- a/tests/assembly-llvm/align_offset.rs +++ b/tests/assembly-llvm/align_offset.rs @@ -4,7 +4,7 @@ #![crate_type = "rlib"] // CHECK-LABEL: align_offset_byte_ptr -// CHECK: leaq {{31|28}} +// CHECK: leaq 31 // CHECK: andq $-32 // CHECK: subq #[no_mangle] @@ -13,7 +13,7 @@ pub fn align_offset_byte_ptr(ptr: *const u8) -> usize { } // CHECK-LABEL: align_offset_byte_slice -// CHECK: leaq {{31|28}} +// CHECK: leaq 31 // CHECK: andq $-32 // CHECK: subq #[no_mangle] @@ -22,7 +22,7 @@ pub fn align_offset_byte_slice(slice: &[u8]) -> usize { } // CHECK-LABEL: align_offset_word_ptr -// CHECK: leaq {{31|28}} +// CHECK: leaq 31 // CHECK: andq $-32 // CHECK: subq // CHECK: shrq @@ -35,7 +35,7 @@ pub fn align_offset_word_ptr(ptr: *const u32) -> usize { } // CHECK-LABEL: align_offset_word_slice -// CHECK: leaq {{31|28}} +// CHECK: leaq 31 // CHECK: andq $-32 // CHECK: subq // CHECK: shrq diff --git a/tests/assembly-llvm/asm/loongarch-type.rs b/tests/assembly-llvm/asm/loongarch-type.rs index 5efad583a39d..e0a7940f89a3 100644 --- a/tests/assembly-llvm/asm/loongarch-type.rs +++ b/tests/assembly-llvm/asm/loongarch-type.rs @@ -1,14 +1,10 @@ //@ add-minicore -//@ revisions: loongarch32s loongarch32r loongarch64 +//@ revisions: loongarch32 loongarch64 //@ assembly-output: emit-asm -//@[loongarch32s] compile-flags: --target loongarch32-unknown-none -Ctarget-feature=+32s -//@[loongarch32s] needs-llvm-components: loongarch - -//@[loongarch32r] compile-flags: --target loongarch32-unknown-none -//@[loongarch32r] needs-llvm-components: loongarch -//@[loongarch32r] min-llvm-version: 22 +//@[loongarch32] compile-flags: --target loongarch32-unknown-none +//@[loongarch32] needs-llvm-components: loongarch //@[loongarch64] compile-flags: --target loongarch64-unknown-none //@[loongarch64] needs-llvm-components: loongarch @@ -32,12 +28,8 @@ extern "C" { // CHECK-LABEL: sym_fn: // CHECK: #APP -// loongarch64: pcalau12i $t0, %got_pc_hi20(extern_func) -// loongarch64: ld.d $t0, $t0, %got_pc_lo12(extern_func) -// loongarch32s: pcalau12i $t0, %got_pc_hi20(extern_func) -// loongarch32s: ld.w $t0, $t0, %got_pc_lo12(extern_func) -// loongarch32r: pcaddu12i $t0, %got_pcadd_hi20(extern_func) -// loongarch32r: ld.w $t0, $t0, %got_pcadd_lo12(.Lpcadd_hi0) +// CHECK: pcalau12i $t0, %got_pc_hi20(extern_func) +// CHECK: ld.{{[wd]}} $t0, $t0, %got_pc_lo12(extern_func) // CHECK: #NO_APP #[no_mangle] pub unsafe fn sym_fn() { @@ -46,13 +38,8 @@ pub unsafe fn sym_fn() { // CHECK-LABEL: sym_static: // CHECK: #APP -// loongarch64: pcalau12i $t0, %got_pc_hi20(extern_static) -// loongarch64: ld.d $t0, $t0, %got_pc_lo12(extern_static) -// loongarch32s: pcalau12i $t0, %got_pc_hi20(extern_static) -// loongarch32s: ld.w $t0, $t0, %got_pc_lo12(extern_static) -// loongarch32r: pcaddu12i $t0, %got_pcadd_hi20(extern_static) -// loongarch32r: ld.w $t0, $t0, %got_pcadd_lo12(.Lpcadd_hi1) - +// CHECK: pcalau12i $t0, %got_pc_hi20(extern_static) +// CHECK: ld.{{[wd]}} $t0, $t0, %got_pc_lo12(extern_static) // CHECK: #NO_APP #[no_mangle] pub unsafe fn sym_static() { diff --git a/tests/assembly-llvm/cstring-merging.rs b/tests/assembly-llvm/cstring-merging.rs index 9c1af4ebb4c0..03688e0068b7 100644 --- a/tests/assembly-llvm/cstring-merging.rs +++ b/tests/assembly-llvm/cstring-merging.rs @@ -1,6 +1,5 @@ // MIPS assembler uses the label prefix `$anon.` for local anonymous variables // other architectures (including ARM and x86-64) use the prefix `.Lanon.` -// Hexagon uses `.string` instead of `.asciz` for null-terminated strings //@ only-linux //@ assembly-output: emit-asm //@ compile-flags: --crate-type=lib -Copt-level=3 -Cllvm-args=-enable-global-merge=0 @@ -10,13 +9,13 @@ use std::ffi::CStr; // CHECK: .section .rodata.str1.{{[12]}},"aMS" // CHECK: {{(\.L|\$)}}anon.{{.+}}: -// CHECK-NEXT: .{{asciz|string}} "foo" +// CHECK-NEXT: .asciz "foo" #[unsafe(no_mangle)] static CSTR: &[u8; 4] = b"foo\0"; // CHECK-NOT: .section // CHECK: {{(\.L|\$)}}anon.{{.+}}: -// CHECK-NEXT: .{{asciz|string}} "bar" +// CHECK-NEXT: .asciz "bar" #[unsafe(no_mangle)] pub fn cstr() -> &'static CStr { c"bar" @@ -24,7 +23,7 @@ pub fn cstr() -> &'static CStr { // CHECK-NOT: .section // CHECK: {{(\.L|\$)}}anon.{{.+}}: -// CHECK-NEXT: .{{asciz|string}} "baz" +// CHECK-NEXT: .asciz "baz" #[unsafe(no_mangle)] pub fn manual_cstr() -> &'static str { "baz\0" diff --git a/tests/assembly-llvm/large_data_threshold.rs b/tests/assembly-llvm/large_data_threshold.rs deleted file mode 100644 index f3b37eb7f83d..000000000000 --- a/tests/assembly-llvm/large_data_threshold.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Test for -Z large_data_threshold=... -// This test verifies that with the medium code model, data above the threshold -// is placed in large data sections (.ldata, .lbss, .lrodata). -//@ assembly-output: emit-asm -//@ compile-flags: -Ccode-model=medium -Zlarge-data-threshold=4 -//@ compile-flags: --target=x86_64-unknown-linux-gnu -//@ needs-llvm-components: x86 - -#![feature(no_core, lang_items)] -#![no_std] -#![no_core] -#![crate_type = "lib"] - -#[lang = "pointee_sized"] -pub trait PointeeSized {} - -#[lang = "meta_sized"] -pub trait MetaSized: PointeeSized {} - -#[lang = "sized"] -pub trait Sized: MetaSized {} - -#[lang = "drop_in_place"] -fn drop_in_place(_: *mut T) {} - -#[used] -#[no_mangle] -// U is below the threshold, should be in .data -static mut U: u16 = 123; - -#[used] -#[no_mangle] -// V is below the threshold, should be in .bss -static mut V: u16 = 0; - -#[used] -#[no_mangle] -// W is at the threshold, should be in .data -static mut W: u32 = 123; - -#[used] -#[no_mangle] -// X is at the threshold, should be in .bss -static mut X: u32 = 0; - -#[used] -#[no_mangle] -// Y is over the threshold, should be in .ldata -static mut Y: u64 = 123; - -#[used] -#[no_mangle] -// Z is over the threshold, should be in .lbss -static mut Z: u64 = 0; - -// CHECK: .section .data.U, -// CHECK-NOT: .section -// CHECK: U: -// CHECK: .section .bss.V, -// CHECK-NOT: .section -// CHECK: V: -// CHECK: .section .data.W, -// CHECK-NOT: .section -// CHECK: W: -// CHECK: .section .bss.X, -// CHECK-NOT: .section -// CHECK: X: -// CHECK: .section .ldata.Y, -// CHECK-NOT: .section -// CHECK: Y: -// CHECK: .section .lbss.Z, -// CHECK-NOT: .section -// CHECK: Z: diff --git a/tests/assembly-llvm/s390x-softfloat-abi.rs b/tests/assembly-llvm/s390x-softfloat-abi.rs deleted file mode 100644 index e2d9d013d201..000000000000 --- a/tests/assembly-llvm/s390x-softfloat-abi.rs +++ /dev/null @@ -1,64 +0,0 @@ -//@ add-minicore -//@ revisions: enable-softfloat disable-softfloat -//@ assembly-output: emit-asm -//@ compile-flags: -Copt-level=3 --crate-type=lib -//@[enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat -//@[enable-softfloat] needs-llvm-components: systemz -//@[disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu -//@[disable-softfloat] needs-llvm-components: systemz -//@ ignore-backends: gcc - -#![feature(no_core, lang_items)] -#![no_std] -#![no_core] - -extern crate minicore; -use minicore::*; - -extern "C" { - fn extern_func(value: f64) -> f64; -} - -// CHECK-LABEL: test_softfloat -#[no_mangle] -extern "C" fn test_softfloat() -> f64 { - let value = 3.141_f64; - - // without softfloat we load the value direct to the first float register - // we do NOT construct a softfloat in r2 (first non-float arg register) - // disable-softfloat: ld %f{{.*}}, 0(%r{{.*}}) - // disable-softfloat-NOT: llihf %r{{.*}}, 1074340036 - // disable-softfloat-NOT: oilf %r{{.*}}, 2611340116 - - // with softfloat we construct the softfloat arg in r2 - // we do NOT pass anything by f0 (first float arg register) - // float registers can not be accessed - // enable-softfloat: llihf %r{{.*}}, 1074340036 - // enable-softfloat-NEXT: oilf %r{{.*}}, 2611340116 - // enable-softfloat-NOT: ld %f{{.*}}, 0(%r{{.*}}) - - unsafe { extern_func(value) }; - // disable-softfloat-NEXT: brasl %r{{.*}}, extern_func@PLT - // enable-softfloat-NEXT: brasl %r{{.*}}, extern_func@PLT - - // for return we check that without softfloat we write to float register - // disable-softfloat: ld %f{{.*}}, 0(%r{{.*}}) - // disable-softfloat-NOT: llihf %r{{.*}}, 1072841097 - // disable-softfloat-NOT: oilf %r{{.*}}, 927712936 - - #[cfg(not(target_feature = "soft-float"))] - { - 1.141_f64 - } - - // for return we check that WITH softfloat we write to genral purpose register - // enable-softfloat: llihf %r{{.*}}, 1072841097 - // enable-softfloat-NEXT: oilf %r{{.*}}, 927712936 - // enable-softfloat-NOT: ld %f{{.*}}, 0(%r{{.*}}) - #[cfg(target_feature = "soft-float")] - { - 2.718_f64 - } - // enable-softfloat: br %r{{.*}} - // disable-softfloat: br %r{{.*}} -} diff --git a/tests/assembly-llvm/slice-is-ascii.rs b/tests/assembly-llvm/slice-is-ascii.rs deleted file mode 100644 index b9a520505498..000000000000 --- a/tests/assembly-llvm/slice-is-ascii.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ revisions: X86_64 LA64 -//@ assembly-output: emit-asm -//@ compile-flags: -C opt-level=3 -// -//@ [X86_64] only-x86_64 -//@ [X86_64] compile-flags: -C target-cpu=znver4 -//@ [X86_64] compile-flags: -C llvm-args=-x86-asm-syntax=intel -// -//@ [LA64] only-loongarch64 - -#![crate_type = "lib"] - -/// Verify `is_ascii` generates efficient code on different architectures: -/// -/// - x86_64: Must NOT use `kshiftrd`/`kshiftrq` (broken AVX-512 auto-vectorization). -/// Good version uses explicit SSE2 intrinsics (`pmovmskb`/`vpmovmskb`). -/// -/// - loongarch64: Should use `vmskltz.b` instruction for the fast-path. - -// X86_64-LABEL: test_is_ascii -// X86_64-NOT: kshiftrd -// X86_64-NOT: kshiftrq -// X86_64: {{vpor|por}} -// X86_64: {{vpmovmskb|pmovmskb}} - -// LA64-LABEL: test_is_ascii -// LA64: vmskltz.b - -#[no_mangle] -pub fn test_is_ascii(s: &[u8]) -> bool { - s.is_ascii() -} diff --git a/tests/assembly-llvm/sparc-struct-abi.rs b/tests/assembly-llvm/sparc-struct-abi.rs index 41ac2be09b65..c6e83b6f8dab 100644 --- a/tests/assembly-llvm/sparc-struct-abi.rs +++ b/tests/assembly-llvm/sparc-struct-abi.rs @@ -9,7 +9,6 @@ #![crate_type = "lib"] #![feature(no_core, lang_items)] #![no_core] -#![feature(f128)] extern crate minicore; use minicore::*; @@ -22,33 +21,8 @@ pub struct Franta { d: f32, } -#[repr(C, packed)] -struct Misaligned(i32, f64); - -#[repr(C)] -struct AlignToMakeAssemblyShorter(T, f64); - -#[repr(C)] -pub struct Floats(i32, f32, f64, f128); - -#[repr(C)] -pub struct LessFloats(f32, i32, f64); - -#[repr(C)] -pub struct NotMisaligned(i32, Misaligned); - -#[repr(C, align(16))] -pub struct Align16(f64, i32, i32); - -impl Copy for Misaligned {} -impl Copy for AlignToMakeAssemblyShorter {} -impl Copy for Floats {} -impl Copy for LessFloats {} -impl Copy for NotMisaligned {} -impl Copy for Align16 {} - // NB: due to delay slots the `ld` following the call is actually executed before the call. -#[unsafe(no_mangle)] +#[no_mangle] pub unsafe extern "C" fn callee(arg: Franta) { // CHECK-LABEL: callee: // CHECK: st %f3, [[PLACE_D:.*]] @@ -80,7 +54,7 @@ extern "C" { fn tail_call_avoidance_fn(); } -#[unsafe(no_mangle)] +#[no_mangle] pub unsafe extern "C" fn caller() { // CHECK-LABEL: caller: // CHECK: ld [{{.*}}], %f0 @@ -88,168 +62,7 @@ pub unsafe extern "C" fn caller() { // CHECK: ld [{{.*}}], %f2 // CHECK: ld [{{.*}}], %f3 // CHECK: call opaque_callee - // CHECK: mov 3, %o2 + // CHECK: mov 3, %o2 opaque_callee(Franta { a: 1.0, b: 2.0, c: 3.0, d: 4.0 }, 3); tail_call_avoidance_fn(); } - -// Check that misaligned floats aren't promoted to floating point registers. -// CHECK-LABEL: misaligned_arg: -#[unsafe(no_mangle)] -extern "C" fn misaligned_arg(x: &mut AlignToMakeAssemblyShorter, value: Misaligned) { - // CHECK: srlx %o2, 32, %o2 - // CHECK-NEXT: stx %o1, [%o0] - // CHECK-NEXT: retl - // CHECK-NEXT: st %o2, [%o0+8] - x.0 = value; -} - -// CHECK-LABEL: misaligned_ret: -#[unsafe(no_mangle)] -extern "C" fn misaligned_ret(x: &AlignToMakeAssemblyShorter) -> Misaligned { - // CHECK: ld [%o0+8], %o1 - // CHECK-NEXT: ldx [%o0], %o0 - // CHECK-NEXT: retl - // CHECK-NEXT: sllx %o1, 32, %o1 - x.0 -} - -// Check structs where 32 >= size > 16 are promoted to register only as an argument. -// Also check that the various floating-point types are promoted to the correct registers. -// CHECK-LABEL: floats_arg: -#[unsafe(no_mangle)] -extern "C" fn floats_arg(x: &mut Floats, value: Floats) { - // CHECK: ldx [%o1+24], %o2 - // CHECK-NEXT: ldx [%o1+16], %o3 - // CHECK-NEXT: ldx [%o1+8], %o4 - // CHECK-NEXT: ldx [%o1], %o1 - // CHECK-NEXT: stx %o2, [%o0+24] - // CHECK-NEXT: stx %o3, [%o0+16] - // CHECK-NEXT: stx %o4, [%o0+8] - // CHECK-NEXT: retl - // CHECK-NEXT: stx %o1, [%o0] - *x = value; -} - -// CHECK-LABEL: floats_ret: -#[unsafe(no_mangle)] -extern "C" fn floats_ret(x: &Floats) -> Floats { - // CHECK: ld [%o0+4], %f1 - // CHECK-NEXT: ldd [%o0+8], %f2 - // CHECK-NEXT: ldd [%o0+16], %f4 - // CHECK-NEXT: ld [%o0], %o1 - // CHECK-NEXT: ldd [%o0+24], %f6 - // CHECK-NEXT: retl - // CHECK-NEXT: sllx %o1, 32, %o0 - *x -} - -// Check float promotion when passing as an argument with a struct where size <= 16. -// CHECK-LABEL: less_floats_arg: -#[unsafe(no_mangle)] -extern "C" fn less_floats_arg(x: &mut LessFloats, value: LessFloats) { - // CHECK: st %f2, [%o0] - // CHECK-NEXT: st %o1, [%o0+4] - // CHECK-NEXT: retl - // CHECK-NEXT: std %f4, [%o0+8] - *x = value; -} - -// CHECK-LABEL: less_floats_ret: -#[unsafe(no_mangle)] -extern "C" fn less_floats_ret(x: &LessFloats) -> LessFloats { - // CHECK: ld [%o0], %f0 - // CHECK-NEXT: ldd [%o0+8], %f2 - // CHECK-NEXT: retl - // CHECK-NEXT: ld [%o0+4], %o0 - *x -} - -// Check fields are promoted if they are aligned in the overall structure. -// This matches Clang's behaviour but not GCC's. -// CHECK-LABEL: not_misaligned_arg: -#[unsafe(no_mangle)] -extern "C" fn not_misaligned_arg( - x: &mut AlignToMakeAssemblyShorter, - value: NotMisaligned, -) { - // CHECK: stx %o1, [%o0] - // CHECK-NEXT: retl - // CHECK-NEXT: std %f4, [%o0+8] - x.0 = value; -} - -// CHECK-LABEL: not_misaligned_ret: -#[unsafe(no_mangle)] -extern "C" fn not_misaligned_ret(x: &AlignToMakeAssemblyShorter) -> NotMisaligned { - // CHECK: ldx [%o0], %o1 - // CHECK-NEXT: ldd [%o0+8], %f2 - // CHECK-NEXT: retl - // CHECK-NEXT: mov %o1, %o0 - x.0 -} - -// Check that 16-aligned structs are allocated the correct registers. -// CHECK-LABEL: align_16_arg: -#[unsafe(no_mangle)] -extern "C" fn align_16_arg(x: &mut Align16, value: Align16) { - // CHECK: std %f4, [%o0] - // CHECK-NEXT: retl - // CHECK-NEXT: stx %o3, [%o0+8] - *x = value; -} - -// CHECK-LABEL: align_16_ret: -#[unsafe(no_mangle)] -extern "C" fn align_16_ret(x: &Align16) -> Align16 { - // CHECK: ldd [%o0], %f0 - // CHECK-NEXT: retl - // CHECK-NEXT: ldx [%o0+8], %o1 - *x -} - -// Check ZST args don't prevent further arguments from being processed. -// CHECK-LABEL: zst_arg: -#[unsafe(no_mangle)] -extern "C" fn zst_arg(_: (), value: LessFloats, x: &mut LessFloats) { - // CHECK: st %f0, [%o2] - // CHECK-NEXT: st %o0, [%o2+4] - // CHECK-NEXT: retl - // CHECK-NEXT: std %f2, [%o2+8] - *x = value; -} - -#[repr(C)] -struct I32F32Input { - a: i32, - b: f32, -} - -#[repr(C)] -struct I32F32Output { - b: f32, - a: i32, -} - -// The clang/LLVM implementation mentions that this case requires special handling. -// CHECK-LABEL: i32_f32: -#[unsafe(no_mangle)] -extern "C" fn i32_f32(input: I32F32Input) -> I32F32Output { - // CHECK: srlx %o0, 32, %o0 - // CHECK-NEXT: fmovs %f1, %f0 - // CHECK-NEXT: retl - // CHECK-NEXT: nop - I32F32Output { a: input.a, b: input.b } -} - -#[repr(C)] -pub struct C { - a: f64, - b: f32, -} - -// regression test for https://github.com/rust-lang/rust/issues/147883. -#[unsafe(no_mangle)] -pub extern "C" fn foo(c: C) -> C { - c -} diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index b7deb6686cfe..c8b81cc858d6 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -67,12 +67,6 @@ //@ revisions: aarch64_unknown_none_softfloat //@ [aarch64_unknown_none_softfloat] compile-flags: --target aarch64-unknown-none-softfloat //@ [aarch64_unknown_none_softfloat] needs-llvm-components: aarch64 -//@ revisions: aarch64v8r_unknown_none -//@ [aarch64v8r_unknown_none] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r_unknown_none] needs-llvm-components: aarch64 -//@ revisions: aarch64v8r_unknown_none_softfloat -//@ [aarch64v8r_unknown_none_softfloat] compile-flags: --target aarch64v8r-unknown-none-softfloat -//@ [aarch64v8r_unknown_none_softfloat] needs-llvm-components: aarch64 //@ revisions: aarch64_unknown_nto_qnx700 //@ [aarch64_unknown_nto_qnx700] compile-flags: --target aarch64-unknown-nto-qnx700 //@ [aarch64_unknown_nto_qnx700] needs-llvm-components: aarch64 @@ -145,12 +139,6 @@ //@ revisions: armv5te_unknown_linux_uclibceabi //@ [armv5te_unknown_linux_uclibceabi] compile-flags: --target armv5te-unknown-linux-uclibceabi //@ [armv5te_unknown_linux_uclibceabi] needs-llvm-components: arm -//@ revisions: armv6_none_eabi -//@ [armv6_none_eabi] compile-flags: --target armv6-none-eabi -//@ [armv6_none_eabi] needs-llvm-components: arm -//@ revisions: armv6_none_eabihf -//@ [armv6_none_eabihf] compile-flags: --target armv6-none-eabihf -//@ [armv6_none_eabihf] needs-llvm-components: arm //@ revisions: armv6_unknown_freebsd //@ [armv6_unknown_freebsd] compile-flags: --target armv6-unknown-freebsd //@ [armv6_unknown_freebsd] needs-llvm-components: arm @@ -544,9 +532,6 @@ //@ revisions: s390x_unknown_linux_musl //@ [s390x_unknown_linux_musl] compile-flags: --target s390x-unknown-linux-musl //@ [s390x_unknown_linux_musl] needs-llvm-components: systemz -//@ revisions: s390x_unknown_none_softfloat -//@ [s390x_unknown_none_softfloat] compile-flags: --target s390x-unknown-none-softfloat -//@ [s390x_unknown_none_softfloat] needs-llvm-components: systemz //@ revisions: sparc64_unknown_helenos //@ [sparc64_unknown_helenos] compile-flags: --target sparc64-unknown-helenos //@ [sparc64_unknown_helenos] needs-llvm-components: sparc @@ -574,24 +559,6 @@ //@ revisions: thumbv5te_none_eabi //@ [thumbv5te_none_eabi] compile-flags: --target thumbv5te-none-eabi //@ [thumbv5te_none_eabi] needs-llvm-components: arm -//@ revisions: thumbv6_none_eabi -//@ [thumbv6_none_eabi] compile-flags: --target thumbv6-none-eabi -//@ [thumbv6_none_eabi] needs-llvm-components: arm -//@ revisions: thumbv7a_none_eabi -//@ [thumbv7a_none_eabi] compile-flags: --target thumbv7a-none-eabi -//@ [thumbv7a_none_eabi] needs-llvm-components: arm -//@ revisions: thumbv7a_none_eabihf -//@ [thumbv7a_none_eabihf] compile-flags: --target thumbv7a-none-eabihf -//@ [thumbv7a_none_eabihf] needs-llvm-components: arm -//@ revisions: thumbv7r_none_eabi -//@ [thumbv7r_none_eabi] compile-flags: --target thumbv7r-none-eabi -//@ [thumbv7r_none_eabi] needs-llvm-components: arm -//@ revisions: thumbv7r_none_eabihf -//@ [thumbv7r_none_eabihf] compile-flags: --target thumbv7r-none-eabihf -//@ [thumbv7r_none_eabihf] needs-llvm-components: arm -//@ revisions: thumbv8r_none_eabihf -//@ [thumbv8r_none_eabihf] compile-flags: --target thumbv8r-none-eabihf -//@ [thumbv8r_none_eabihf] needs-llvm-components: arm //@ revisions: thumbv6m_none_eabi //@ [thumbv6m_none_eabi] compile-flags: --target thumbv6m-none-eabi //@ [thumbv6m_none_eabi] needs-llvm-components: arm @@ -706,9 +673,6 @@ //@ revisions: x86_64_unknown_linux_gnux32 //@ [x86_64_unknown_linux_gnux32] compile-flags: --target x86_64-unknown-linux-gnux32 //@ [x86_64_unknown_linux_gnux32] needs-llvm-components: x86 -//@ revisions: x86_64_unknown_linux_gnuasan -//@ [x86_64_unknown_linux_gnuasan] compile-flags: --target x86_64-unknown-linux-gnuasan -//@ [x86_64_unknown_linux_gnuasan] needs-llvm-components: x86 //@ revisions: x86_64_unknown_linux_musl //@ [x86_64_unknown_linux_musl] compile-flags: --target x86_64-unknown-linux-musl //@ [x86_64_unknown_linux_musl] needs-llvm-components: x86 diff --git a/tests/assembly-llvm/x86_64-bigint-helpers.rs b/tests/assembly-llvm/x86_64-bigint-helpers.rs index d5d1eba99f39..9d998a31cf30 100644 --- a/tests/assembly-llvm/x86_64-bigint-helpers.rs +++ b/tests/assembly-llvm/x86_64-bigint-helpers.rs @@ -4,6 +4,7 @@ //@ compile-flags: -C llvm-args=-x86-asm-syntax=intel #![no_std] +#![feature(bigint_helper_methods)] // This checks that the `carrying_add` and `borrowing_sub` implementation successfully chain, // to catch issues like diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index c4546f4dea93..95b217c13031 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -76,9 +76,6 @@ pub trait BikeshedGuaranteedNoDrop {} #[lang = "freeze"] pub unsafe auto trait Freeze {} -#[lang = "unsafe_unpin"] -pub unsafe auto trait UnsafeUnpin {} - #[lang = "unpin"] #[diagnostic::on_unimplemented( note = "consider using the `pin!` macro\nconsider using `Box::pin` if you need to access the pinned value outside of the current scope", diff --git a/tests/build-std/configurations/rmake.rs b/tests/build-std/configurations/rmake.rs deleted file mode 100644 index 99cb9f9b0f4d..000000000000 --- a/tests/build-std/configurations/rmake.rs +++ /dev/null @@ -1,131 +0,0 @@ -// This test ensures we are able to compile -Zbuild-std=core under a variety of profiles. -// Currently, it tests that we can compile to all Tier 1 targets, and it does this by checking what -// the tier metadata in target-spec JSON. This means that all in-tree targets must have a tier set. - -#![deny(warnings)] - -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; -use std::thread; - -use run_make_support::serde_json::{self, Value}; -use run_make_support::tempfile::TempDir; -use run_make_support::{cargo, rfs, rustc}; - -#[derive(Clone)] -struct Task { - target: String, - opt_level: u8, - debug: u8, - panic: &'static str, -} - -fn manifest(task: &Task) -> String { - let Task { opt_level, debug, panic, target: _ } = task; - format!( - r#"[package] -name = "scratch" -version = "0.1.0" -edition = "2024" - -[lib] -path = "lib.rs" - -[profile.release] -opt-level = {opt_level} -debug = {debug} -panic = "{panic}" -"# - ) -} - -fn main() { - let mut targets = Vec::new(); - let all_targets = - rustc().args(&["--print=all-target-specs-json", "-Zunstable-options"]).run().stdout_utf8(); - let all_targets: HashMap = serde_json::from_str(&all_targets).unwrap(); - for (target, spec) in all_targets { - let metadata = spec.as_object().unwrap()["metadata"].as_object().unwrap(); - let tier = metadata["tier"] - .as_u64() - .expect(&format!("Target {} is missing tier metadata", target)); - if tier == 1 { - targets.push(target); - } - } - - let mut tasks = Vec::new(); - - // Testing every combination of compiler flags is infeasible. So we are making some attempt to - // choose combinations that will tend to run into problems. - // - // The particular combination of settings below is tuned to look for problems generating the - // code for compiler-builtins. - // We only exercise opt-level 0 and 3 to exercise mir-opt-level 1 and 2. - // We only exercise debug 0 and 2 because level 2 turns off some MIR optimizations. - // We only test abort and immediate-abort because abort vs unwind doesn't change MIR much at - // all. but immediate-abort does. - // - // Currently this only tests that we can compile the tier 1 targets. But since we are using - // -Zbuild-std=core, we could have any list of targets. - - for opt_level in [0, 3] { - for debug in [0, 2] { - for panic in ["abort", "immediate-abort"] { - for target in &targets { - tasks.push(Task { target: target.clone(), opt_level, debug, panic }); - } - } - } - } - - let tasks = Arc::new(Mutex::new(tasks)); - let mut threads = Vec::new(); - - // Try to obey the -j argument passed to bootstrap, otherwise fall back to using all the system - // resouces. This test can be rather memory-hungry (~1 GB/thread); if it causes trouble in - // practice do not hesitate to limit its parallelism. - for _ in 0..run_make_support::env::jobs() { - let tasks = Arc::clone(&tasks); - let handle = thread::spawn(move || { - loop { - let maybe_task = tasks.lock().unwrap().pop(); - if let Some(task) = maybe_task { - test(task); - } else { - break; - } - } - }); - threads.push(handle); - } - - for t in threads { - t.join().unwrap(); - } -} - -fn test(task: Task) { - let dir = TempDir::new().unwrap(); - - let manifest = manifest(&task); - rfs::write(dir.path().join("Cargo.toml"), &manifest); - rfs::write(dir.path().join("lib.rs"), "#![no_std]"); - - let mut args = vec!["build", "--release", "-Zbuild-std=core", "--target", &task.target, "-j1"]; - if task.panic == "immediate-abort" { - args.push("-Zpanic-immediate-abort"); - } - cargo() - .current_dir(dir.path()) - .args(&args) - .env("RUSTC_BOOTSTRAP", "1") - // Visual Studio 2022 requires that the LIB env var be set so it can - // find the Windows SDK. - .env("LIB", std::env::var("LIB").unwrap_or_default()) - .context(&format!( - "build-std for target `{}` failed with the following Cargo.toml:\n\n{manifest}", - task.target - )) - .run(); -} diff --git a/tests/codegen-llvm/aarch64v8r-softfloat.rs b/tests/codegen-llvm/aarch64v8r-softfloat.rs deleted file mode 100644 index 5ccda4f3a0ae..000000000000 --- a/tests/codegen-llvm/aarch64v8r-softfloat.rs +++ /dev/null @@ -1,45 +0,0 @@ -//@ add-minicore -//@ compile-flags: --target aarch64v8r-unknown-none-softfloat -Zmerge-functions=disabled -//@ needs-llvm-components: aarch64 -#![crate_type = "lib"] -#![feature(no_core, lang_items)] -#![no_core] - -extern crate minicore; -use minicore::*; - -// CHECK: i64 @pass_f64_C(i64 {{[^,]*}}) -#[no_mangle] -extern "C" fn pass_f64_C(x: f64) -> f64 { - x -} - -// CHECK: i64 @pass_f32_pair_C(i64 {{[^,]*}}) -#[no_mangle] -extern "C" fn pass_f32_pair_C(x: (f32, f32)) -> (f32, f32) { - x -} - -// CHECK: [2 x i64] @pass_f64_pair_C([2 x i64] {{[^,]*}}) -#[no_mangle] -extern "C" fn pass_f64_pair_C(x: (f64, f64)) -> (f64, f64) { - x -} - -// CHECK: i64 @pass_f64_Rust(i64 {{[^,]*}}) -#[no_mangle] -fn pass_f64_Rust(x: f64) -> f64 { - x -} - -// CHECK: i64 @pass_f32_pair_Rust(i64 {{[^,]*}}) -#[no_mangle] -fn pass_f32_pair_Rust(x: (f32, f32)) -> (f32, f32) { - x -} - -// CHECK: void @pass_f64_pair_Rust(ptr {{.*}}%{{[^ ]+}}, ptr {{.*}}%{{[^ ]+}}) -#[no_mangle] -fn pass_f64_pair_Rust(x: (f64, f64)) -> (f64, f64) { - x -} diff --git a/tests/codegen-llvm/addr-of-mutate.rs b/tests/codegen-llvm/addr-of-mutate.rs index d1939391b25d..d59d85af62a9 100644 --- a/tests/codegen-llvm/addr-of-mutate.rs +++ b/tests/codegen-llvm/addr-of-mutate.rs @@ -5,7 +5,7 @@ // Test for the absence of `readonly` on the argument when it is mutated via `&raw const`. // See . -// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}}{{( dead_on_return)?}} dereferenceable(128) %x) +// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}} dereferenceable(128) %x) #[no_mangle] pub fn foo(x: [u8; 128]) -> u8 { let ptr = core::ptr::addr_of!(x).cast_mut(); @@ -15,7 +15,7 @@ pub fn foo(x: [u8; 128]) -> u8 { x[0] } -// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}}{{( dead_on_return)?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut(); @@ -24,7 +24,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { } // If going through a deref (and there are no other mutating accesses), then `readonly` is fine. -// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(none\))?}}{{( dead_on_return)?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut(); diff --git a/tests/codegen-llvm/align-offset.rs b/tests/codegen-llvm/align-offset.rs index 383e9dd45dab..21062cc0a914 100644 --- a/tests/codegen-llvm/align-offset.rs +++ b/tests/codegen-llvm/align-offset.rs @@ -24,7 +24,7 @@ pub fn align_to4(x: &[u8]) -> bool { #[no_mangle] pub fn align_offset_byte_ptr(ptr: *const u8) -> usize { // CHECK: %[[ADDR:.+]] = ptrtoint ptr %ptr to [[USIZE:i[0-9]+]] - // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], {{31|28}} + // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 // CHECK: %[[OFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] @@ -41,7 +41,7 @@ pub fn align_offset_byte_ptr(ptr: *const u8) -> usize { #[no_mangle] pub fn align_offset_word_slice(slice: &[Align4]) -> usize { // CHECK: %[[ADDR:.+]] = ptrtoint ptr %slice.0 to [[USIZE]] - // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], {{31|28}} + // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 // CHECK: %[[BOFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] // CHECK: %[[OFFSET:.+]] = lshr exact [[USIZE]] %[[BOFFSET]], 2 @@ -57,7 +57,7 @@ pub fn align_offset_word_slice(slice: &[Align4]) -> usize { #[no_mangle] pub fn align_offset_word_ptr(ptr: *const Align4) -> usize { // CHECK: %[[ADDR:.+]] = ptrtoint ptr %ptr to [[USIZE]] - // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], {{31|28}} + // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 // CHECK: %[[BOFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] diff --git a/tests/codegen-llvm/amdgpu-addrspacecast.rs b/tests/codegen-llvm/amdgpu-addrspacecast.rs index 144565f7e28c..16a0c276ac0e 100644 --- a/tests/codegen-llvm/amdgpu-addrspacecast.rs +++ b/tests/codegen-llvm/amdgpu-addrspacecast.rs @@ -1,25 +1,16 @@ // Check that pointers are casted to addrspace(0) before they are used -//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 -O +//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 //@ needs-llvm-components: amdgpu //@ add-minicore -//@ revisions: LLVM21 LLVM22 -//@ [LLVM21] max-llvm-major-version: 21 -//@ [LLVM22] min-llvm-version: 22 #![feature(no_core)] #![no_core] extern crate minicore; -// Make sure that on LLVM 22, the alloca is passed directly to the lifetime intrinsics, -// not the addrspacecast. - // CHECK-LABEL: @ref_of_local // CHECK: [[alloca:%[0-9]]] = alloca // CHECK: %i = addrspacecast ptr addrspace(5) [[alloca]] to ptr -// LLVM22: call void @llvm.lifetime.start.p5(ptr addrspace(5) [[alloca]]) -// CHECK: call void %f(ptr{{.*}}%i) -// LLVM22: call void @llvm.lifetime.end.p5(ptr addrspace(5) [[alloca]]) #[no_mangle] pub fn ref_of_local(f: fn(&i32)) { let i = 0; diff --git a/tests/codegen-llvm/autodiff/abi_handling.rs b/tests/codegen-llvm/autodiff/abi_handling.rs index a8bc482fc293..5c8126898a8d 100644 --- a/tests/codegen-llvm/autodiff/abi_handling.rs +++ b/tests/codegen-llvm/autodiff/abi_handling.rs @@ -38,14 +38,14 @@ fn square(x: f32) -> f32 { // CHECK-LABEL: ; abi_handling::df1 // CHECK-NEXT: Function Attrs // debug-NEXT: define internal { float, float } -// debug-SAME: (ptr {{.*}}%x, ptr {{.*}}%bx_0) +// debug-SAME: (ptr align 4 %x, ptr align 4 %bx_0) // release-NEXT: define internal fastcc float // release-SAME: (float %x.0.val, float %x.4.val) // CHECK-LABEL: ; abi_handling::f1 // CHECK-NEXT: Function Attrs // debug-NEXT: define internal float -// debug-SAME: (ptr {{.*}}%x) +// debug-SAME: (ptr align 4 %x) // release-NEXT: define internal fastcc noundef float // release-SAME: (float %x.0.val, float %x.4.val) #[autodiff_forward(df1, Dual, Dual)] @@ -58,7 +58,7 @@ fn f1(x: &[f32; 2]) -> f32 { // CHECK-NEXT: Function Attrs // debug-NEXT: define internal { float, float } // debug-SAME: (ptr %f, float %x, float %dret) -// release-NEXT: define internal fastcc noundef float +// release-NEXT: define internal fastcc float // release-SAME: (float noundef %x) // CHECK-LABEL: ; abi_handling::f2 @@ -77,13 +77,13 @@ fn f2(f: fn(f32) -> f32, x: f32) -> f32 { // CHECK-NEXT: Function Attrs // debug-NEXT: define internal { float, float } // debug-SAME: (ptr align 4 %x, ptr align 4 %bx_0, ptr align 4 %y, ptr align 4 %by_0) -// release-NEXT: define internal fastcc float +// release-NEXT: define internal fastcc { float, float } // release-SAME: (float %x.0.val) // CHECK-LABEL: ; abi_handling::f3 // CHECK-NEXT: Function Attrs // debug-NEXT: define internal float -// debug-SAME: (ptr {{.*}}%x, ptr {{.*}}%y) +// debug-SAME: (ptr align 4 %x, ptr align 4 %y) // release-NEXT: define internal fastcc noundef float // release-SAME: (float %x.0.val) #[autodiff_forward(df3, Dual, Dual, Dual)] @@ -160,7 +160,7 @@ fn f6(i: NestedInput) -> f32 { // CHECK-LABEL: ; abi_handling::f7 // CHECK-NEXT: Function Attrs // debug-NEXT: define internal float -// debug-SAME: (ptr {{.*}}%x.0, ptr {{.*}}%x.1) +// debug-SAME: (ptr align 4 %x.0, ptr align 4 %x.1) // release-NEXT: define internal fastcc noundef float // release-SAME: (float %x.0.0.val, float %x.1.0.val) #[autodiff_forward(df7, Dual, Dual)] diff --git a/tests/codegen-llvm/autodiff/batched.rs b/tests/codegen-llvm/autodiff/batched.rs index 5a723ff04183..0ff6134bc07d 100644 --- a/tests/codegen-llvm/autodiff/batched.rs +++ b/tests/codegen-llvm/autodiff/batched.rs @@ -1,11 +1,13 @@ //@ compile-flags: -Zautodiff=Enable,NoTT,NoPostopt -C opt-level=3 -Clto=fat //@ no-prefer-dynamic //@ needs-enzyme - -// This test combines two features of Enzyme, automatic differentiation and batching. As such, it is -// especially prone to breakages. I reduced it therefore to a minimal check matches argument/return -// types. Based on the original batching author, implementing the batching feature over MLIR instead -// of LLVM should give significantly more reliable performance. +// +// In Enzyme, we test against a large range of LLVM versions (5+) and don't have overly many +// breakages. One benefit is that we match the IR generated by Enzyme only after running it +// through LLVM's O3 pipeline, which will remove most of the noise. +// However, our integration test could also be affected by changes in how rustc lowers MIR into +// LLVM-IR, which could cause additional noise and thus breakages. If that's the case, we should +// reduce this test to only match the first lines and the ret instructions. #![feature(autodiff)] @@ -20,20 +22,69 @@ fn square(x: &f32) -> f32 { x * x } -// The base ("scalar") case d_square3, without batching. -// CHECK: define internal fastcc float @fwddiffesquare(float %x.0.val, float %"x'.0.val") -// CHECK: %0 = fadd fast float %"x'.0.val", %"x'.0.val" -// CHECK-NEXT: %1 = fmul fast float %0, %x.0.val -// CHECK-NEXT: ret float %1 -// CHECK-NEXT: } - // d_square2 -// CHECK: define internal fastcc [4 x float] @fwddiffe4square(float %x.0.val, [4 x ptr] %"x'") -// CHECK: ret [4 x float] +// CHECK: define internal [4 x float] @fwddiffe4square(ptr noalias noundef readonly align 4 captures(none) dereferenceable(4) %x, [4 x ptr] %"x'") +// CHECK-NEXT: start: +// CHECK-NEXT: %0 = extractvalue [4 x ptr] %"x'", 0 +// CHECK-NEXT: %"_2'ipl" = load float, ptr %0, align 4 +// CHECK-NEXT: %1 = extractvalue [4 x ptr] %"x'", 1 +// CHECK-NEXT: %"_2'ipl1" = load float, ptr %1, align 4 +// CHECK-NEXT: %2 = extractvalue [4 x ptr] %"x'", 2 +// CHECK-NEXT: %"_2'ipl2" = load float, ptr %2, align 4 +// CHECK-NEXT: %3 = extractvalue [4 x ptr] %"x'", 3 +// CHECK-NEXT: %"_2'ipl3" = load float, ptr %3, align 4 +// CHECK-NEXT: %_2 = load float, ptr %x, align 4 +// CHECK-NEXT: %4 = fmul fast float %"_2'ipl", %_2 +// CHECK-NEXT: %5 = fmul fast float %"_2'ipl1", %_2 +// CHECK-NEXT: %6 = fmul fast float %"_2'ipl2", %_2 +// CHECK-NEXT: %7 = fmul fast float %"_2'ipl3", %_2 +// CHECK-NEXT: %8 = fmul fast float %"_2'ipl", %_2 +// CHECK-NEXT: %9 = fmul fast float %"_2'ipl1", %_2 +// CHECK-NEXT: %10 = fmul fast float %"_2'ipl2", %_2 +// CHECK-NEXT: %11 = fmul fast float %"_2'ipl3", %_2 +// CHECK-NEXT: %12 = fadd fast float %4, %8 +// CHECK-NEXT: %13 = insertvalue [4 x float] undef, float %12, 0 +// CHECK-NEXT: %14 = fadd fast float %5, %9 +// CHECK-NEXT: %15 = insertvalue [4 x float] %13, float %14, 1 +// CHECK-NEXT: %16 = fadd fast float %6, %10 +// CHECK-NEXT: %17 = insertvalue [4 x float] %15, float %16, 2 +// CHECK-NEXT: %18 = fadd fast float %7, %11 +// CHECK-NEXT: %19 = insertvalue [4 x float] %17, float %18, 3 +// CHECK-NEXT: ret [4 x float] %19 // CHECK-NEXT: } -// CHECK: define internal fastcc { float, [4 x float] } @fwddiffe4square.{{.*}}(float %x.0.val, [4 x ptr] %"x'") -// CHECK: ret { float, [4 x float] } +// d_square3, the extra float is the original return value (x * x) +// CHECK: define internal { float, [4 x float] } @fwddiffe4square.1(ptr noalias noundef readonly align 4 captures(none) dereferenceable(4) %x, [4 x ptr] %"x'") +// CHECK-NEXT: start: +// CHECK-NEXT: %0 = extractvalue [4 x ptr] %"x'", 0 +// CHECK-NEXT: %"_2'ipl" = load float, ptr %0, align 4 +// CHECK-NEXT: %1 = extractvalue [4 x ptr] %"x'", 1 +// CHECK-NEXT: %"_2'ipl1" = load float, ptr %1, align 4 +// CHECK-NEXT: %2 = extractvalue [4 x ptr] %"x'", 2 +// CHECK-NEXT: %"_2'ipl2" = load float, ptr %2, align 4 +// CHECK-NEXT: %3 = extractvalue [4 x ptr] %"x'", 3 +// CHECK-NEXT: %"_2'ipl3" = load float, ptr %3, align 4 +// CHECK-NEXT: %_2 = load float, ptr %x, align 4 +// CHECK-NEXT: %_0 = fmul float %_2, %_2 +// CHECK-NEXT: %4 = fmul fast float %"_2'ipl", %_2 +// CHECK-NEXT: %5 = fmul fast float %"_2'ipl1", %_2 +// CHECK-NEXT: %6 = fmul fast float %"_2'ipl2", %_2 +// CHECK-NEXT: %7 = fmul fast float %"_2'ipl3", %_2 +// CHECK-NEXT: %8 = fmul fast float %"_2'ipl", %_2 +// CHECK-NEXT: %9 = fmul fast float %"_2'ipl1", %_2 +// CHECK-NEXT: %10 = fmul fast float %"_2'ipl2", %_2 +// CHECK-NEXT: %11 = fmul fast float %"_2'ipl3", %_2 +// CHECK-NEXT: %12 = fadd fast float %4, %8 +// CHECK-NEXT: %13 = insertvalue [4 x float] undef, float %12, 0 +// CHECK-NEXT: %14 = fadd fast float %5, %9 +// CHECK-NEXT: %15 = insertvalue [4 x float] %13, float %14, 1 +// CHECK-NEXT: %16 = fadd fast float %6, %10 +// CHECK-NEXT: %17 = insertvalue [4 x float] %15, float %16, 2 +// CHECK-NEXT: %18 = fadd fast float %7, %11 +// CHECK-NEXT: %19 = insertvalue [4 x float] %17, float %18, 3 +// CHECK-NEXT: %20 = insertvalue { float, [4 x float] } undef, float %_0, 0 +// CHECK-NEXT: %21 = insertvalue { float, [4 x float] } %20, [4 x float] %19, 1 +// CHECK-NEXT: ret { float, [4 x float] } %21 // CHECK-NEXT: } fn main() { diff --git a/tests/codegen-llvm/autodiff/generic.rs b/tests/codegen-llvm/autodiff/generic.rs index b31468c91c9c..6f56460a2b6d 100644 --- a/tests/codegen-llvm/autodiff/generic.rs +++ b/tests/codegen-llvm/autodiff/generic.rs @@ -1,14 +1,6 @@ //@ compile-flags: -Zautodiff=Enable -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat //@ no-prefer-dynamic //@ needs-enzyme -//@ revisions: F32 F64 Main - -// Here we verify that the function `square` can be differentiated over f64. -// This is interesting to test, since the user never calls `square` with f64, so on it's own rustc -// would have no reason to monomorphize it that way. However, Enzyme needs the f64 version of -// `square` in order to be able to differentiate it, so we have logic to enforce the -// monomorphization. Here, we test this logic. - #![feature(autodiff)] use std::autodiff::autodiff_reverse; @@ -20,37 +12,32 @@ fn square + Copy>(x: &T) -> T { } // Ensure that `d_square::` code is generated - -// F32-LABEL: ; generic::square:: -// F32-NEXT: ; Function Attrs: {{.*}} -// F32-NEXT: define internal {{.*}} float -// F32-NEXT: start: -// F32-NOT: ret -// F32: fmul float +// +// CHECK: ; generic::square +// CHECK-NEXT: ; Function Attrs: {{.*}} +// CHECK-NEXT: define internal {{.*}} float +// CHECK-NEXT: start: +// CHECK-NOT: ret +// CHECK: fmul float // Ensure that `d_square::` code is generated even if `square::` was never called - -// F64-LABEL: ; generic::d_square:: -// F64-NEXT: ; Function Attrs: {{.*}} -// F64-NEXT: define internal {{.*}} void -// F64-NEXT: start: -// F64-NEXT: {{(tail )?}}call {{(fastcc )?}}void @diffe_{{.*}}(double {{.*}}, ptr {{.*}}) -// F64-NEXT: ret void - -// Main-LABEL: ; generic::main -// Main: ; call generic::square:: -// Main: ; call generic::d_square:: +// +// CHECK: ; generic::square +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define internal {{.*}} double +// CHECK-NEXT: start: +// CHECK-NOT: ret +// CHECK: fmul double fn main() { let xf32: f32 = std::hint::black_box(3.0); let xf64: f64 = std::hint::black_box(3.0); - let seed: f64 = std::hint::black_box(1.0); let outputf32 = square::(&xf32); assert_eq!(9.0, outputf32); let mut df_dxf64: f64 = std::hint::black_box(0.0); - let output_f64 = d_square::(&xf64, &mut df_dxf64, seed); + let output_f64 = d_square::(&xf64, &mut df_dxf64, 1.0); assert_eq!(6.0, df_dxf64); } diff --git a/tests/codegen-llvm/autodiff/identical_fnc.rs b/tests/codegen-llvm/autodiff/identical_fnc.rs index a8b186c302ea..1c18e7acc4b6 100644 --- a/tests/codegen-llvm/autodiff/identical_fnc.rs +++ b/tests/codegen-llvm/autodiff/identical_fnc.rs @@ -8,7 +8,7 @@ // merged placeholder function anymore, and compilation would fail. We prevent this by disabling // LLVM's merge_function pass before AD. Here we implicetely test that our solution keeps working. // We also explicetly test that we keep running merge_function after AD, by checking for two -// identical function calls in the LLVM-IR, despite having two different calls in the Rust code. +// identical function calls in the LLVM-IR, while having two different calls in the Rust code. #![feature(autodiff)] use std::autodiff::autodiff_reverse; @@ -27,14 +27,14 @@ fn square2(x: &f64) -> f64 { // CHECK:; identical_fnc::main // CHECK-NEXT:; Function Attrs: -// CHECK-NEXT:define internal void +// CHECK-NEXT:define internal void @_ZN13identical_fnc4main17h6009e4f751bf9407E() // CHECK-NEXT:start: // CHECK-NOT:br // CHECK-NOT:ret // CHECK:; call identical_fnc::d_square -// CHECK-NEXT:call fastcc void @[[HASH:.+]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1) +// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square[[HASH:.+]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1) // CHECK:; call identical_fnc::d_square -// CHECK-NEXT:call fastcc void @[[HASH]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2) +// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square[[HASH]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2) fn main() { let x = std::hint::black_box(3.0); diff --git a/tests/codegen-llvm/backchain.rs b/tests/codegen-llvm/backchain.rs deleted file mode 100644 index fae494dcad1b..000000000000 --- a/tests/codegen-llvm/backchain.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ add-minicore -//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu -Ctarget-feature=+backchain -//@ needs-llvm-components: systemz -#![crate_type = "lib"] -#![feature(no_core, lang_items)] -#![no_core] - -extern crate minicore; -use minicore::*; - -#[no_mangle] -pub fn test_backchain() { - // CHECK: @test_backchain() unnamed_addr #0 -} -// CHECK: attributes #0 = { {{.*}}"target-features"="{{[^"]*}}+backchain{{.*}} } diff --git a/tests/codegen-llvm/bigint-helpers.rs b/tests/codegen-llvm/bigint-helpers.rs index 404dc901de8c..ec70a3eabedb 100644 --- a/tests/codegen-llvm/bigint-helpers.rs +++ b/tests/codegen-llvm/bigint-helpers.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C opt-level=3 #![crate_type = "lib"] +#![feature(bigint_helper_methods)] // Note that there's also an assembly test for this, which is what checks for // the `ADC` (Add with Carry) instruction on x86 now that the IR we emit uses diff --git a/tests/codegen-llvm/box-uninit-bytes.rs b/tests/codegen-llvm/box-uninit-bytes.rs index 7ac929646cd4..0cc011485951 100644 --- a/tests/codegen-llvm/box-uninit-bytes.rs +++ b/tests/codegen-llvm/box-uninit-bytes.rs @@ -41,6 +41,6 @@ pub fn box_lotsa_padding() -> Box { // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably. -// CHECK: declare {{(dso_local )?}}noalias noundef ptr @{{.*}}__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef range(i{{[0-9]+}} 1, {{-2147483647|-9223372036854775807}})) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] +// CHECK: declare {{(dso_local )?}}noalias noundef ptr @{{.*}}__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) {{(uwtable )?}}"alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen-llvm/cast-target-abi.rs b/tests/codegen-llvm/cast-target-abi.rs index 6f1ab4572ee0..101e73e33c91 100644 --- a/tests/codegen-llvm/cast-target-abi.rs +++ b/tests/codegen-llvm/cast-target-abi.rs @@ -119,7 +119,7 @@ pub extern "C" fn returns_twou16s() -> TwoU16s { // aarch64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) // loongarch64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) // powerpc64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) -// sparc64-SAME: ([[ABI_TYPE:{ i64, i64 }]] {{.*}}[[ABI_VALUE:%.+]]) +// sparc64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) // x86_64-SAME: ([[ABI_TYPE:{ i64, i16 }]] {{.*}}[[ABI_VALUE:%.+]]) #[no_mangle] #[inline(never)] @@ -148,7 +148,7 @@ pub extern "C" fn returns_fiveu16s() -> FiveU16s { // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i64 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i16 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // aarch64: ret [[ABI_TYPE]] [[ABI_VALUE]] @@ -217,7 +217,7 @@ pub extern "C" fn returns_doubledouble() -> DoubleDouble { // aarch64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) // loongarch64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) // powerpc64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) -// sparc64-SAME: ([[ABI_TYPE:{ i64, i64 }]] {{.*}}[[ABI_VALUE:%.+]]) +// sparc64-SAME: ([[ABI_TYPE:\[2 x i64\]]] {{.*}}[[ABI_VALUE:%.+]]) // x86_64-SAME: ([[ABI_TYPE:{ i64, i32 }]] {{.*}}[[ABI_VALUE:%.+]]) #[no_mangle] #[inline(never)] @@ -246,7 +246,7 @@ pub extern "C" fn returns_three32s() -> Three32s { // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i64 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i32 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // aarch64: ret [[ABI_TYPE]] [[ABI_VALUE]] @@ -399,7 +399,7 @@ pub fn call_fiveu16s() { // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // powerpc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i64 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i16 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // CHECK: call void @receives_fiveu16s([[ABI_TYPE]] [[ABI_VALUE]]) @@ -424,7 +424,7 @@ pub fn return_fiveu16s() -> FiveU16s { // aarch64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:\[2 x i64\]]] @returns_fiveu16s() // loongarch64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:\[2 x i64\]]] @returns_fiveu16s() - // sparc64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:{ i64, i64 }]] @returns_fiveu16s() + // sparc64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:\[2 x i64\]]] @returns_fiveu16s() // x86_64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:{ i64, i16 }]] @returns_fiveu16s() // aarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] @@ -595,7 +595,7 @@ pub fn call_three32s() { // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // powerpc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i64 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ i64, i32 }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // CHECK: call void @receives_three32s([[ABI_TYPE]] [[ABI_VALUE]]) @@ -619,7 +619,7 @@ pub fn return_three32s() -> Three32s { // aarch64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:\[2 x i64\]]] @returns_three32s() // loongarch64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:\[2 x i64\]]] @returns_three32s() - // sparc64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:{ i64, i64 }]] @returns_three32s() + // sparc64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:\[2 x i64\]]] @returns_three32s() // x86_64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:{ i64, i32 }]] @returns_three32s() // aarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] diff --git a/tests/codegen-llvm/cffi/c-variadic-copy.rs b/tests/codegen-llvm/cffi/c-variadic-copy.rs new file mode 100644 index 000000000000..0cbdcb4bbb85 --- /dev/null +++ b/tests/codegen-llvm/cffi/c-variadic-copy.rs @@ -0,0 +1,16 @@ +// Tests that `VaList::clone` gets inlined into a call to `llvm.va_copy` + +#![crate_type = "lib"] +#![feature(c_variadic)] +#![no_std] +use core::ffi::VaList; + +extern "C" { + fn foreign_c_variadic_1(_: VaList, ...); +} + +pub unsafe extern "C" fn clone_variadic(ap: VaList) { + let mut ap2 = ap.clone(); + // CHECK: call void @llvm.va_copy + foreign_c_variadic_1(ap2, 42i32); +} diff --git a/tests/codegen-llvm/cffi/c-variadic-opt.rs b/tests/codegen-llvm/cffi/c-variadic-opt.rs index c779b25450fd..3cc0c3e9f9bd 100644 --- a/tests/codegen-llvm/cffi/c-variadic-opt.rs +++ b/tests/codegen-llvm/cffi/c-variadic-opt.rs @@ -17,3 +17,14 @@ pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 { vprintf(fmt, ap) // CHECK: call void @llvm.va_end } + +// Check that `VaList::clone` gets inlined into a direct call to `llvm.va_copy` +#[no_mangle] +pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 { + // CHECK: call void @llvm.va_start + let mut ap2 = ap.clone(); + // CHECK: call void @llvm.va_copy + let res = vprintf(fmt, ap2); + res + // CHECK: call void @llvm.va_end +} diff --git a/tests/codegen-llvm/direct-access-external-data.rs b/tests/codegen-llvm/direct-access-external-data.rs index a151bb6012e1..73dc08dc2b57 100644 --- a/tests/codegen-llvm/direct-access-external-data.rs +++ b/tests/codegen-llvm/direct-access-external-data.rs @@ -1,4 +1,3 @@ -//@ ignore-loongarch64 (handles dso_local differently) //@ ignore-powerpc64 (handles dso_local differently) //@ ignore-apple (handles dso_local differently) diff --git a/tests/codegen-llvm/enum/enum-transparent-extract.rs b/tests/codegen-llvm/enum/enum-transparent-extract.rs index 1a05b236abfb..1435e6ec8022 100644 --- a/tests/codegen-llvm/enum/enum-transparent-extract.rs +++ b/tests/codegen-llvm/enum/enum-transparent-extract.rs @@ -11,8 +11,6 @@ pub enum Never {} pub fn make_unmake_result_never(x: i32) -> i32 { // CHECK-LABEL: define i32 @make_unmake_result_never(i32{{( signext)?}} %x) // CHECK: start: - // CHECK-NEXT: br label %[[next:bb.*]] - // CHECK: [[next]]: // CHECK-NEXT: ret i32 %x let y: Result = Ok(x); @@ -24,8 +22,6 @@ pub fn make_unmake_result_never(x: i32) -> i32 { pub fn extract_control_flow_never(x: ControlFlow<&str, Never>) -> &str { // CHECK-LABEL: define { ptr, i64 } @extract_control_flow_never(ptr align 1 %x.0, i64 %x.1) // CHECK: start: - // CHECK-NEXT: br label %[[next:bb.*]] - // CHECK: [[next]]: // CHECK-NEXT: %[[P0:.+]] = insertvalue { ptr, i64 } poison, ptr %x.0, 0 // CHECK-NEXT: %[[P1:.+]] = insertvalue { ptr, i64 } %[[P0]], i64 %x.1, 1 // CHECK-NEXT: ret { ptr, i64 } %[[P1]] diff --git a/tests/codegen-llvm/function-arguments.rs b/tests/codegen-llvm/function-arguments.rs index 46e153a0cfc6..4d557470504e 100644 --- a/tests/codegen-llvm/function-arguments.rs +++ b/tests/codegen-llvm/function-arguments.rs @@ -1,9 +1,9 @@ //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(rustc_attrs)] -#![feature(allocator_api, unsafe_unpin)] +#![feature(allocator_api)] -use std::marker::{PhantomPinned, UnsafeUnpin}; +use std::marker::PhantomPinned; use std::mem::MaybeUninit; use std::num::NonZero; use std::ptr::NonNull; @@ -134,7 +134,7 @@ pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {} #[no_mangle] pub fn notunpin_borrow(_: &NotUnpin) {} -// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias noundef readonly align 4{{( captures\(none\))?}}{{( dead_on_return)?}} dereferenceable(32) %_1) +// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias noundef readonly align 4{{( captures\(none\))?}} dereferenceable(32) %_1) #[no_mangle] pub fn indirect_struct(_: S) {} @@ -259,21 +259,11 @@ pub fn trait_raw(_: *const dyn Drop) {} // CHECK: @trait_box(ptr noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) #[no_mangle] -pub fn trait_box(_: Box) {} - -// Ensure that removing *either* `Unpin` or `UnsafeUnpin` is enough to lose the attribute. -// CHECK: @trait_box_pin1(ptr noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) -#[no_mangle] -pub fn trait_box_pin1(_: Box) {} -// CHECK: @trait_box_pin2(ptr noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) -#[no_mangle] -pub fn trait_box_pin2(_: Box) {} +pub fn trait_box(_: Box) {} // CHECK: { ptr, ptr } @trait_option(ptr noalias noundef align 1 %x.0, ptr %x.1) #[no_mangle] -pub fn trait_option( - x: Option>, -) -> Option> { +pub fn trait_option(x: Option>) -> Option> { x } diff --git a/tests/codegen-llvm/gpu_offload/control_flow.rs b/tests/codegen-llvm/gpu_offload/control_flow.rs index fb483db667b2..28ee9c85b0ed 100644 --- a/tests/codegen-llvm/gpu_offload/control_flow.rs +++ b/tests/codegen-llvm/gpu_offload/control_flow.rs @@ -12,16 +12,17 @@ // CHECK: define{{( dso_local)?}} void @main() // CHECK-NOT: define -// CHECK: %.offload_baseptrs = alloca [1 x ptr], align 8 +// CHECK: %EmptyDesc = alloca %struct.__tgt_bin_desc, align 8 +// CHECK-NEXT: %.offload_baseptrs = alloca [1 x ptr], align 8 // CHECK-NEXT: %.offload_ptrs = alloca [1 x ptr], align 8 // CHECK-NEXT: %.offload_sizes = alloca [1 x i64], align 8 // CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 // CHECK: br label %bb3 // CHECK-NOT define // CHECK: bb3 -// CHECK: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.foo.begin, ptr null, ptr null) +// CHECK: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.foo, ptr null, ptr null) // CHECK: %10 = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) -// CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.foo.end, ptr null, ptr null) +// CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.foo, ptr null, ptr null) #[unsafe(no_mangle)] unsafe fn main() { let A = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; diff --git a/tests/codegen-llvm/gpu_offload/gpu_host.rs b/tests/codegen-llvm/gpu_offload/gpu_host.rs index f25ba679abbd..dcbd65b14427 100644 --- a/tests/codegen-llvm/gpu_offload/gpu_host.rs +++ b/tests/codegen-llvm/gpu_offload/gpu_host.rs @@ -2,10 +2,9 @@ //@ no-prefer-dynamic //@ needs-offload -// This test is verifying that we generate __tgt_target_data_*_mapper before and after a call to -// __tgt_target_kernel, and initialize all needed variables. It also verifies some related globals. -// Better documentation to what each global or variable means is available in the gpu offload code, -// or the LLVM offload documentation. +// This test is verifying that we generate __tgt_target_data_*_mapper before and after a call to the +// kernel_1. Better documentation to what each global or variable means is available in the gpu +// offload code, or the LLVM offload documentation. #![feature(rustc_attrs)] #![feature(core_intrinsics)] @@ -14,103 +13,94 @@ #[unsafe(no_mangle)] fn main() { let mut x = [3.0; 256]; - let y = [1.0; 256]; - kernel_1(&mut x, &y); + kernel_1(&mut x); core::hint::black_box(&x); - core::hint::black_box(&y); -} - -pub fn kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { - core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], (x, y)) } +#[unsafe(no_mangle)] #[inline(never)] -pub fn _kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { +pub fn kernel_1(x: &mut [f32; 256]) { + core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], (x,)) +} + +#[unsafe(no_mangle)] +#[inline(never)] +pub fn _kernel_1(x: &mut [f32; 256]) { for i in 0..256 { - x[i] = 21.0 + y[i]; + x[i] = 21.0; } } // CHECK: %struct.ident_t = type { i32, i32, i32, i32, ptr } // CHECK: %struct.__tgt_offload_entry = type { i64, i16, i16, i32, ptr, ptr, i64, i64, ptr } +// CHECK: %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } // CHECK: %struct.__tgt_kernel_arguments = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, [3 x i32], [3 x i32], i32 } -// CHECK: @anon.[[ID:.*]].0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 -// CHECK: @anon.{{.*}}.1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @anon.[[ID]].0 }, align 8 +// CHECK: @anon.{{.*}}.0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 +// CHECK: @anon.{{.*}}.1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @anon.{{.*}}.0 }, align 8 -// CHECK-DAG: @.omp_offloading.descriptor = internal constant { i32, ptr, ptr, ptr } zeroinitializer -// CHECK-DAG: @llvm.global_ctors = appending constant [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 101, ptr @.omp_offloading.descriptor_reg, ptr null }] -// CHECK-DAG: @.offload_sizes.[[K:[^ ]*kernel_1]] = private unnamed_addr constant [2 x i64] [i64 1024, i64 1024] -// CHECK-DAG: @.offload_maptypes.[[K]].begin = private unnamed_addr constant [2 x i64] [i64 1, i64 1] -// CHECK-DAG: @.offload_maptypes.[[K]].kernel = private unnamed_addr constant [2 x i64] [i64 32, i64 32] -// CHECK-DAG: @.offload_maptypes.[[K]].end = private unnamed_addr constant [2 x i64] [i64 2, i64 0] -// CHECK-DAG: @.[[K]].region_id = internal constant i8 0 -// CHECK-DAG: @.offloading.entry_name.[[K]] = internal unnamed_addr constant [{{[0-9]+}} x i8] c"[[K]]{{\\00}}", section ".llvm.rodata.offloading", align 1 -// CHECK-DAG: @.offloading.entry.[[K]] = internal constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @.[[K]].region_id, ptr @.offloading.entry_name.[[K]], i64 0, i64 0, ptr null }, section "llvm_offload_entries", align 8 +// CHECK: @.offload_sizes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 1024] +// CHECK: @.offload_maptypes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 35] +// CHECK: @._kernel_1.region_id = internal constant i8 0 +// CHECK: @.offloading.entry_name._kernel_1 = internal unnamed_addr constant [10 x i8] c"_kernel_1\00", section ".llvm.rodata.offloading", align 1 +// CHECK: @.offloading.entry._kernel_1 = internal constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @._kernel_1.region_id, ptr @.offloading.entry_name._kernel_1, i64 0, i64 0, ptr null }, section "llvm_offload_entries", align 8 // CHECK: declare i32 @__tgt_target_kernel(ptr, i64, i32, i32, ptr, ptr) - -// CHECK-LABEL: define{{( dso_local)?}} void @main() -// CHECK-NEXT: start: -// CHECK-NEXT: %0 = alloca [8 x i8], align 8 -// CHECK-NEXT: %1 = alloca [8 x i8], align 8 -// CHECK-NEXT: %y = alloca [1024 x i8], align 16 -// CHECK-NEXT: %x = alloca [1024 x i8], align 16 -// CHECK-NEXT: %.offload_baseptrs = alloca [2 x ptr], align 8 -// CHECK-NEXT: %.offload_ptrs = alloca [2 x ptr], align 8 -// CHECK-NEXT: %.offload_sizes = alloca [2 x i64], align 8 -// CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 -// CHECK: store ptr %x, ptr %.offload_baseptrs, align 8 -// CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8 -// CHECK-NEXT: store i64 1024, ptr %.offload_sizes, align 8 -// CHECK-NEXT: [[BPTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 -// CHECK-NEXT: store ptr %y, ptr [[BPTRS_1]], align 8 -// CHECK-NEXT: [[PTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 -// CHECK-NEXT: store ptr %y, ptr [[PTRS_1]], align 8 -// CHECK-NEXT: [[SIZES_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_sizes, i64 8 -// CHECK-NEXT: store i64 1024, ptr [[SIZES_1]], align 8 -// CHECK-NEXT: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.[[K]].begin, ptr null, ptr null) -// CHECK-NEXT: store i32 3, ptr %kernel_args, align 8 -// CHECK-NEXT: [[P4:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 4 -// CHECK-NEXT: store i32 2, ptr [[P4]], align 4 -// CHECK-NEXT: [[P8:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 8 -// CHECK-NEXT: store ptr %.offload_baseptrs, ptr [[P8]], align 8 -// CHECK-NEXT: [[P16:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 16 -// CHECK-NEXT: store ptr %.offload_ptrs, ptr [[P16]], align 8 -// CHECK-NEXT: [[P24:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 24 -// CHECK-NEXT: store ptr %.offload_sizes, ptr [[P24]], align 8 -// CHECK-NEXT: [[P32:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 32 -// CHECK-NEXT: store ptr @.offload_maptypes.[[K]].kernel, ptr [[P32]], align 8 -// CHECK-NEXT: [[P40:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 40 -// CHECK-NEXT: [[P72:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 72 -// CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) [[P40]], i8 0, i64 32, i1 false) -// CHECK-NEXT: store <4 x i32> , ptr [[P72]], align 8 -// CHECK-NEXT: [[P88:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 88 -// CHECK-NEXT: store i32 1, ptr [[P88]], align 8 -// CHECK-NEXT: [[P92:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 92 -// CHECK-NEXT: store i32 1, ptr [[P92]], align 4 -// CHECK-NEXT: [[P96:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %kernel_args, i64 96 -// CHECK-NEXT: store i32 0, ptr [[P96]], align 8 -// CHECK-NEXT: [[TGT_RET:%.*]] = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @.[[K]].region_id, ptr nonnull %kernel_args) -// CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.[[K]].end, ptr null, ptr null) -// CHECK: ret void -// CHECK-NEXT: } - // CHECK: declare void @__tgt_register_lib(ptr) local_unnamed_addr // CHECK: declare void @__tgt_unregister_lib(ptr) local_unnamed_addr -// CHECK-LABEL: define internal void @.omp_offloading.descriptor_reg() section ".text.startup" { -// CHECK-NEXT: entry: -// CHECK-NEXT: call void @__tgt_register_lib(ptr nonnull @.omp_offloading.descriptor) +// CHECK: define{{( dso_local)?}} void @main() +// CHECK-NEXT: start: +// CHECK-NEXT: %0 = alloca [8 x i8], align 8 +// CHECK-NEXT: %x = alloca [1024 x i8], align 16 +// CHECK: call void @kernel_1(ptr noalias noundef nonnull align 4 dereferenceable(1024) %x) +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) +// CHECK-NEXT: store ptr %x, ptr %0, align 8 +// CHECK-NEXT: call void asm sideeffect "", "r,~{memory}"(ptr nonnull %0) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %x) +// CHECK-NEXT: ret void +// CHECK-NEXT: } + +// CHECK: define{{( dso_local)?}} void @kernel_1(ptr noalias noundef align 4 dereferenceable(1024) %x) +// CHECK-NEXT: start: +// CHECK-NEXT: %EmptyDesc = alloca %struct.__tgt_bin_desc, align 8 +// CHECK-NEXT: %.offload_baseptrs = alloca [1 x ptr], align 8 +// CHECK-NEXT: %.offload_ptrs = alloca [1 x ptr], align 8 +// CHECK-NEXT: %.offload_sizes = alloca [1 x i64], align 8 +// CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 +// CHECK-NEXT: %dummy = load volatile ptr, ptr @.offload_sizes._kernel_1, align 8 +// CHECK-NEXT: %dummy1 = load volatile ptr, ptr @.offloading.entry._kernel_1, align 8 +// CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %EmptyDesc, i8 0, i64 32, i1 false) +// CHECK-NEXT: call void @__tgt_register_lib(ptr nonnull %EmptyDesc) // CHECK-NEXT: call void @__tgt_init_all_rtls() -// CHECK-NEXT: %0 = {{tail }}call i32 @atexit(ptr nonnull @.omp_offloading.descriptor_unreg) +// CHECK-NEXT: store ptr %x, ptr %.offload_baseptrs, align 8 +// CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8 +// CHECK-NEXT: store i64 1024, ptr %.offload_sizes, align 8 +// CHECK-NEXT: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes._kernel_1, ptr null, ptr null) +// CHECK-NEXT: store i32 3, ptr %kernel_args, align 8 +// CHECK-NEXT: %0 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 4 +// CHECK-NEXT: store i32 1, ptr %0, align 4 +// CHECK-NEXT: %1 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 8 +// CHECK-NEXT: store ptr %.offload_baseptrs, ptr %1, align 8 +// CHECK-NEXT: %2 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 16 +// CHECK-NEXT: store ptr %.offload_ptrs, ptr %2, align 8 +// CHECK-NEXT: %3 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 24 +// CHECK-NEXT: store ptr %.offload_sizes, ptr %3, align 8 +// CHECK-NEXT: %4 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 32 +// CHECK-NEXT: store ptr @.offload_maptypes._kernel_1, ptr %4, align 8 +// CHECK-NEXT: %5 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 40 +// CHECK-NEXT: %6 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 72 +// CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %5, i8 0, i64 32, i1 false) +// CHECK-NEXT: store <4 x i32> , ptr %6, align 8 +// CHECK-NEXT: %.fca.1.gep5 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 88 +// CHECK-NEXT: store i32 1, ptr %.fca.1.gep5, align 8 +// CHECK-NEXT: %.fca.2.gep7 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 92 +// CHECK-NEXT: store i32 1, ptr %.fca.2.gep7, align 4 +// CHECK-NEXT: %7 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 96 +// CHECK-NEXT: store i32 0, ptr %7, align 8 +// CHECK-NEXT: %8 = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @._kernel_1.region_id, ptr nonnull %kernel_args) +// CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes._kernel_1, ptr null, ptr null) +// CHECK-NEXT: call void @__tgt_unregister_lib(ptr nonnull %EmptyDesc) // CHECK-NEXT: ret void // CHECK-NEXT: } - -// CHECK-LABEL: define internal void @.omp_offloading.descriptor_unreg() section ".text.startup" { -// CHECK-NEXT: entry: -// CHECK-NEXT: call void @__tgt_unregister_lib(ptr nonnull @.omp_offloading.descriptor) -// CHECK-NEXT: ret void -// CHECK-NEXT: } - -// CHECK: !{i32 7, !"openmp", i32 51} diff --git a/tests/codegen-llvm/gpu_offload/scalar_device.rs b/tests/codegen-llvm/gpu_offload/scalar_device.rs deleted file mode 100644 index 61772d404063..000000000000 --- a/tests/codegen-llvm/gpu_offload/scalar_device.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ add-minicore -//@ revisions: amdgpu nvptx -//@[nvptx] compile-flags: -Copt-level=0 -Zunstable-options -Zoffload=Device --target nvptx64-nvidia-cuda --crate-type=rlib -//@[nvptx] needs-llvm-components: nvptx -//@[amdgpu] compile-flags: -Copt-level=0 -Zunstable-options -Zoffload=Device --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 --crate-type=rlib -//@[amdgpu] needs-llvm-components: amdgpu -//@ no-prefer-dynamic -//@ needs-offload - -// This test verifies that the offload intrinsic is properly handling scalar args on the device, -// replacing the args by i64 and then trunc and cast them to the original type - -#![feature(abi_gpu_kernel, rustc_attrs, no_core)] -#![no_core] - -extern crate minicore; - -// CHECK: ; Function Attrs -// nvptx-NEXT: define ptx_kernel void @foo(ptr %dyn_ptr, ptr %0, i64 %1) -// amdgpu-NEXT: define amdgpu_kernel void @foo(ptr %dyn_ptr, ptr %0, i64 %1) -// CHECK-NEXT: entry: -// CHECK-NEXT: %2 = trunc i64 %1 to i32 -// CHECK-NEXT: %3 = bitcast i32 %2 to float -// CHECK-NEXT: br label %start -// CHECK: start: -// CHECK-NEXT: store float %3, ptr %0, align 4 -// CHECK-NEXT: ret void -// CHECK-NEXT: } - -#[unsafe(no_mangle)] -#[rustc_offload_kernel] -pub unsafe extern "gpu-kernel" fn foo(x: *mut f32, k: f32) { - unsafe { - *x = k; - }; -} diff --git a/tests/codegen-llvm/gpu_offload/scalar_host.rs b/tests/codegen-llvm/gpu_offload/scalar_host.rs deleted file mode 100644 index 8c7dcd4dd581..000000000000 --- a/tests/codegen-llvm/gpu_offload/scalar_host.rs +++ /dev/null @@ -1,37 +0,0 @@ -//@ compile-flags: -Zoffload=Test -Zunstable-options -C opt-level=1 -Clto=fat -//@ no-prefer-dynamic -//@ needs-offload - -// This test verifies that the offload intrinsic is properly handling scalar args, passing them to -// the kernel as i64 - -#![feature(abi_gpu_kernel)] -#![feature(rustc_attrs)] -#![feature(core_intrinsics)] -#![no_main] - -// CHECK: define{{( dso_local)?}} void @main() -// CHECK-NOT: define -// CHECK: %addr = alloca i64, align 8 -// CHECK: store double 4.200000e+01, ptr %0, align 8 -// CHECK: %_0.i = load double, ptr %0, align 8 -// CHECK: store double %_0.i, ptr %addr, align 8 -// CHECK: %1 = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 -// CHECK-NEXT: store double %_0.i, ptr %1, align 8 -// CHECK-NEXT: %2 = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 -// CHECK-NEXT: store ptr %addr, ptr %2, align 8 -// CHECK-NEXT: %3 = getelementptr inbounds nuw i8, ptr %.offload_sizes, i64 8 -// CHECK-NEXT: store i64 4, ptr %3, align 8 -// CHECK-NEXT: call void @__tgt_target_data_begin_mapper - -#[unsafe(no_mangle)] -fn main() { - let mut x = 0.0; - let k = core::hint::black_box(42.0); - - core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], (&mut x, k)); -} - -unsafe extern "C" { - pub fn foo(x: *mut f32, k: f32); -} diff --git a/tests/codegen-llvm/hint/cold_path.rs b/tests/codegen-llvm/hint/cold_path.rs index e6e7379322dd..149abe474f67 100644 --- a/tests/codegen-llvm/hint/cold_path.rs +++ b/tests/codegen-llvm/hint/cold_path.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![feature(cold_path)] use std::hint::cold_path; diff --git a/tests/codegen-llvm/intrinsics/carrying_mul_add.rs b/tests/codegen-llvm/intrinsics/carrying_mul_add.rs index 844f4f6cff64..21fb49a3786a 100644 --- a/tests/codegen-llvm/intrinsics/carrying_mul_add.rs +++ b/tests/codegen-llvm/intrinsics/carrying_mul_add.rs @@ -11,9 +11,10 @@ use std::intrinsics::{carrying_mul_add, fallback}; -// The fallbacks should not be emitted. +// The fallbacks are emitted even when they're never used, but optimize out. -// NOT: wide_mul_u128 +// RAW: wide_mul_u128 +// OPT-NOT: wide_mul_u128 // CHECK-LABEL: @cma_u8 #[no_mangle] diff --git a/tests/codegen-llvm/intrinsics/likely_assert.rs b/tests/codegen-llvm/intrinsics/likely_assert.rs index e7e2cfdff052..59a40c750eab 100644 --- a/tests/codegen-llvm/intrinsics/likely_assert.rs +++ b/tests/codegen-llvm/intrinsics/likely_assert.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Copt-level=3 -#![feature(panic_internals, const_eval_select, rustc_attrs, core_intrinsics)] +#![feature(panic_internals, const_eval_select, rustc_allow_const_fn_unstable, core_intrinsics)] #![crate_type = "lib"] // check that assert! and const_assert! emit branch weights diff --git a/tests/codegen-llvm/issues/issue-138497-nonzero-remove-trailing-zeroes.rs b/tests/codegen-llvm/issues/issue-138497-nonzero-remove-trailing-zeroes.rs deleted file mode 100644 index 77cdbaf2bfe5..000000000000 --- a/tests/codegen-llvm/issues/issue-138497-nonzero-remove-trailing-zeroes.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This test checks that removing trailing zeroes from a `NonZero`, -//! then creating a new `NonZero` from the result does not panic. - -//@ min-llvm-version: 21 -//@ compile-flags: -O -Zmerge-functions=disabled -#![crate_type = "lib"] - -use std::num::NonZero; - -// CHECK-LABEL: @remove_trailing_zeros -#[no_mangle] -pub fn remove_trailing_zeros(x: NonZero) -> NonZero { - // CHECK: %[[TRAILING:[a-z0-9_-]+]] = {{.*}} call {{.*}} i8 @llvm.cttz.i8(i8 %x, i1 true) - // CHECK-NEXT: %[[RET:[a-z0-9_-]+]] = lshr exact i8 %x, %[[TRAILING]] - // CHECK-NEXT: ret i8 %[[RET]] - NonZero::new(x.get() >> x.trailing_zeros()).unwrap() -} diff --git a/tests/codegen-llvm/issues/matches-logical-or-141497.rs b/tests/codegen-llvm/issues/matches-logical-or-141497.rs index 59869fd70012..348f62096a5f 100644 --- a/tests/codegen-llvm/issues/matches-logical-or-141497.rs +++ b/tests/codegen-llvm/issues/matches-logical-or-141497.rs @@ -2,7 +2,7 @@ // `f == FrameType::Inter || f == FrameType::Switch`. //@ compile-flags: -Copt-level=3 -//@ min-llvm-version: 23 +//@ min-llvm-version: 21 #![crate_type = "lib"] @@ -18,7 +18,8 @@ pub enum FrameType { #[no_mangle] pub fn is_inter_or_switch(f: FrameType) -> bool { // CHECK-NEXT: start: - // CHECK-NEXT: trunc i8 %{{.*}} to i1 + // CHECK-NEXT: and i8 + // CHECK-NEXT: icmp // CHECK-NEXT: ret matches!(f, FrameType::Inter | FrameType::Switch) } diff --git a/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs b/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs index a4e5c885a139..1da7de535f75 100644 --- a/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs @@ -47,7 +47,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN) -> Option Vec { - // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @{{.*}}__rust_alloc(i64 noundef {{(range\(i64 0, -9223372036854775808\) )?}}1234, i64 noundef {{(range\(i64 1, -9223372036854775807\) )?}}1) + // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @{{.*}}__rust_alloc(i64 noundef {{(range\(i64 1, 0\) )?}}1234, i64 noundef {{(range\(i64 1, -9223372036854775807\) )?}}1) // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR]], i8 42, i64 1234, let n = 1234_usize; diff --git a/tests/codegen-llvm/lib-optimizations/append-elements.rs b/tests/codegen-llvm/lib-optimizations/append-elements.rs deleted file mode 100644 index 5d7d746dbb6c..000000000000 --- a/tests/codegen-llvm/lib-optimizations/append-elements.rs +++ /dev/null @@ -1,34 +0,0 @@ -//@ compile-flags: -O -Zmerge-functions=disabled -//@ needs-deterministic-layouts -//@ min-llvm-version: 21 -//@ ignore-std-debug-assertions (causes different value naming) -#![crate_type = "lib"] - -//! Check that a temporary intermediate allocations can eliminated and replaced -//! with memcpy forwarding. -//! This requires Vec code to be structured in a way that avoids phi nodes from the -//! zero-capacity length flowing into the memcpy arguments. - -// CHECK-LABEL: @vec_append_with_temp_alloc -// CHECK-SAME: ptr{{.*}}[[DST:%[a-z]+]]{{.*}}ptr{{.*}}[[SRC:%[a-z]+]] -#[no_mangle] -pub fn vec_append_with_temp_alloc(dst: &mut Vec, src: &[u8]) { - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.*}}[[DST]].i{{.*}}[[SRC]] - // CHECK-NOT: call void @llvm.memcpy - let temp = src.to_vec(); - dst.extend(&temp); - // CHECK: ret -} - -// CHECK-LABEL: @string_append_with_temp_alloc -// CHECK-SAME: ptr{{.*}}[[DST:%[a-z]+]]{{.*}}ptr{{.*}}[[SRC:%[a-z]+]] -#[no_mangle] -pub fn string_append_with_temp_alloc(dst: &mut String, src: &str) { - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.*}}[[DST]].i{{.*}}[[SRC]] - // CHECK-NOT: call void @llvm.memcpy - let temp = src.to_string(); - dst.push_str(&temp); - // CHECK: ret -} diff --git a/tests/codegen-llvm/lib-optimizations/eq_ignore_ascii_case.rs b/tests/codegen-llvm/lib-optimizations/eq_ignore_ascii_case.rs deleted file mode 100644 index d4ac5d64585d..000000000000 --- a/tests/codegen-llvm/lib-optimizations/eq_ignore_ascii_case.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ compile-flags: -Copt-level=3 -//@ only-x86_64 -#![crate_type = "lib"] - -// Ensure that the optimized variant of the function gets auto-vectorized and -// that the inner helper function is inlined. -// CHECK-LABEL: @eq_ignore_ascii_case_autovectorized -#[no_mangle] -pub fn eq_ignore_ascii_case_autovectorized(s: &str, other: &str) -> bool { - // CHECK: load <16 x i8> - // CHECK: load <16 x i8> - // CHECK: bitcast <16 x i1> - // CHECK-NOT: call {{.*}}eq_ignore_ascii_inner - // CHECK-NOT: panic - s.eq_ignore_ascii_case(other) -} diff --git a/tests/codegen-llvm/loongarch-abi/call-llvm-intrinsics.rs b/tests/codegen-llvm/loongarch-abi/call-llvm-intrinsics.rs index 36eb2dde7afb..9a50f7b8e3a5 100644 --- a/tests/codegen-llvm/loongarch-abi/call-llvm-intrinsics.rs +++ b/tests/codegen-llvm/loongarch-abi/call-llvm-intrinsics.rs @@ -23,7 +23,9 @@ pub fn do_call() { unsafe { // Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them - // CHECK: call float @llvm.sqrt.f32(float 4.000000e+00) + // CHECK: store float 4.000000e+00, ptr %{{.}}, align 4 + // CHECK: load float, ptr %{{.}}, align 4 + // CHECK: call float @llvm.sqrt.f32(float %{{.}} sqrt(4.0); } } diff --git a/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs index 4c61224ac6d8..546007ab0f2c 100644 --- a/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs @@ -256,7 +256,7 @@ pub struct IntDoubleInt { c: i32, } -// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias noundef align 8{{( captures\(address\))?}}{{( dead_on_return)?}} dereferenceable(24) %a) +// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias noundef align 8{{( captures\(address\))?}} dereferenceable(24) %a) #[no_mangle] pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {} diff --git a/tests/codegen-llvm/loongarch/direct-access-external-data.rs b/tests/codegen-llvm/loongarch/direct-access-external-data.rs deleted file mode 100644 index de495d7fe9a7..000000000000 --- a/tests/codegen-llvm/loongarch/direct-access-external-data.rs +++ /dev/null @@ -1,47 +0,0 @@ -//@ only-loongarch64 - -//@ revisions: DEFAULT PIE DIRECT INDIRECT -//@ [DEFAULT] compile-flags: -C relocation-model=static -//@ [PIE] compile-flags: -C relocation-model=pie -//@ [DIRECT] compile-flags: -C relocation-model=pie -Z direct-access-external-data=yes -//@ [INDIRECT] compile-flags: -C relocation-model=static -Z direct-access-external-data=no - -#![crate_type = "rlib"] -#![feature(linkage)] - -unsafe extern "C" { - // CHECK: @VAR = external - // DEFAULT-NOT: dso_local - // PIE-NOT: dso_local - // DIRECT-SAME: dso_local - // INDIRECT-NOT: dso_local - // CHECK-SAME: global i32 - safe static VAR: i32; - - // When "linkage" is used, we generate an indirection global. - // Check dso_local is still applied to the actual global. - // CHECK: @EXTERNAL = external - // DEFAULT-NOT: dso_local - // PIE-NOT: dso_local - // DIRECT-SAME: dso_local - // INDIRECT-NOT: dso_local - // CHECK-SAME: global i8 - #[linkage = "external"] - safe static EXTERNAL: *const u32; - - // CHECK: @WEAK = extern_weak - // DEFAULT-NOT: dso_local - // PIE-NOT: dso_local - // DIRECT-SAME: dso_local - // INDIRECT-NOT: dso_local - // CHECK-SAME: global i8 - #[linkage = "extern_weak"] - safe static WEAK: *const u32; -} - -#[no_mangle] -pub fn refer() { - core::hint::black_box(VAR); - core::hint::black_box(EXTERNAL); - core::hint::black_box(WEAK); -} diff --git a/tests/codegen-llvm/preserve-none.rs b/tests/codegen-llvm/preserve-none.rs deleted file mode 100644 index b45e49a466bf..000000000000 --- a/tests/codegen-llvm/preserve-none.rs +++ /dev/null @@ -1,33 +0,0 @@ -//@ add-minicore -//@ revisions: X86 AARCH64 UNSUPPORTED -//@ [X86] compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -//@ [X86] needs-llvm-components: x86 -//@ [AARCH64] compile-flags: -C no-prepopulate-passes --target=aarch64-unknown-linux-gnu -//@ [AARCH64] needs-llvm-components: aarch64 -//@ [UNSUPPORTED] compile-flags: -C no-prepopulate-passes --target=i686-unknown-linux-gnu -//@ [UNSUPPORTED] needs-llvm-components: x86 - -#![crate_type = "lib"] -#![feature(rust_preserve_none_cc)] -#![feature(no_core, lang_items)] -#![no_core] - -extern crate minicore; - -// X86: define{{( dso_local)?}} preserve_nonecc void @peach(i16 -// AARCH64: define{{( dso_local)?}} preserve_nonecc void @peach(i16 -// UNSUPPORTED: define{{( dso_local)?}} void @peach(i16 -#[no_mangle] -#[inline(never)] -pub extern "rust-preserve-none" fn peach(x: u16) { - loop {} -} - -// X86: call preserve_nonecc void @peach(i16 -// AARCH64: call preserve_nonecc void @peach(i16 -// UNSUPPORTED: call void @peach(i16 -pub fn quince(x: u16) { - if let 12345u16 = x { - peach(54321); - } -} diff --git a/tests/codegen-llvm/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen-llvm/sanitizer/kasan-emits-instrumentation.rs index f0135cdd0011..da0c976d8a53 100644 --- a/tests/codegen-llvm/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen-llvm/sanitizer/kasan-emits-instrumentation.rs @@ -2,11 +2,9 @@ //@ add-minicore //@ compile-flags: -Zsanitizer=kernel-address -Copt-level=0 -//@ revisions: aarch64 aarch64v8r riscv64imac riscv64gc x86_64 +//@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none //@[aarch64] needs-llvm-components: aarch64 -//@[aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@[aarch64v8r] needs-llvm-components: aarch64 //@[riscv64imac] compile-flags: --target riscv64imac-unknown-none-elf //@[riscv64imac] needs-llvm-components: riscv //@[riscv64gc] compile-flags: --target riscv64gc-unknown-none-elf diff --git a/tests/codegen-llvm/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs b/tests/codegen-llvm/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs index 53b8c605eb73..24c5d1be1d60 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs @@ -1,11 +1,9 @@ // Verifies that "cfi-normalize-integers" module flag is added. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers diff --git a/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-flag.rs b/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-flag.rs index 9058d5b5cfcb..53b1a3f2d74a 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-flag.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-flag.rs @@ -1,11 +1,9 @@ // Verifies that "kcfi" module flag is added. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi diff --git a/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-offset-flag.rs b/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-offset-flag.rs index 6574302033c8..82747351e028 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-offset-flag.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/add-kcfi-offset-flag.rs @@ -1,11 +1,9 @@ // Verifies that "kcfi-offset" module flag is added. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi -Z patchable-function-entry=4,3 diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-sanitize-off.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-sanitize-off.rs index eb9ab6b8f90c..ee4928053cf9 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-sanitize-off.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-sanitize-off.rs @@ -1,11 +1,9 @@ // Verifies that KCFI operand bundles are omitted. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs index f934a3bfcee7..9b861c08ac95 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs @@ -1,11 +1,9 @@ // Verifies that generalized KCFI type metadata for functions are emitted. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs index b72b6d7ce308..c2410aa9f4d8 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs @@ -1,11 +1,9 @@ // Verifies that normalized and generalized KCFI type metadata for functions are emitted. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs index 064ab53a1856..fbad335286cb 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs @@ -1,11 +1,9 @@ // Verifies that normalized KCFI type metadata for functions are emitted. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs index 8410286e49db..6c7a8194ec4e 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -1,11 +1,9 @@ // Verifies that KCFI type metadata for functions are emitted. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle.rs index 3494854bcffd..e22a210f3dfb 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle.rs @@ -1,11 +1,9 @@ // Verifies that KCFI operand bundles are emitted. // //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 diff --git a/tests/codegen-llvm/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen-llvm/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index 4510e70cbc35..3312f12f6885 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -1,11 +1,9 @@ // Verifies that type metadata identifiers for trait objects are emitted correctly. // //@ add-minicore -//@ revisions: aarch64v8r aarch64 x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 diff --git a/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs b/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs index 8cfb6a57a4a9..676b2af8c8f1 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs @@ -1,9 +1,7 @@ //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi -Cno-prepopulate-passes -Copt-level=0 diff --git a/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs b/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs index 6b9d11b192b3..830689780dce 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs @@ -1,9 +1,7 @@ //@ add-minicore -//@ revisions: aarch64 aarch64v8r x86_64 +//@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 -//@ [aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@ [aarch64v8r] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi -Cno-prepopulate-passes -Copt-level=0 diff --git a/tests/codegen-llvm/sanitizer/sanitize-off-asan-kasan.rs b/tests/codegen-llvm/sanitizer/sanitize-off-asan-kasan.rs index cef4a650e477..c5df311efae0 100644 --- a/tests/codegen-llvm/sanitizer/sanitize-off-asan-kasan.rs +++ b/tests/codegen-llvm/sanitizer/sanitize-off-asan-kasan.rs @@ -3,11 +3,9 @@ // //@ add-minicore //@ compile-flags: -Zsanitizer=kernel-address -Ctarget-feature=-crt-static -Copt-level=0 -//@ revisions: aarch64 aarch64v8r riscv64imac riscv64gc x86_64 +//@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none //@[aarch64] needs-llvm-components: aarch64 -//@[aarch64v8r] compile-flags: --target aarch64v8r-unknown-none -//@[aarch64v8r] needs-llvm-components: aarch64 //@[riscv64imac] compile-flags: --target riscv64imac-unknown-none-elf //@[riscv64imac] needs-llvm-components: riscv //@[riscv64gc] compile-flags: --target riscv64gc-unknown-none-elf diff --git a/tests/codegen-llvm/simd/array-repeat.rs b/tests/codegen-llvm/simd/array-repeat.rs deleted file mode 100644 index 691167f86662..000000000000 --- a/tests/codegen-llvm/simd/array-repeat.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@ add-minicore -//@ revisions: X86 AARCH64 RISCV S390X -//@ [X86] compile-flags: -Copt-level=3 --target=x86_64-unknown-linux-gnu -//@ [X86] needs-llvm-components: x86 -//@ [AARCH64] compile-flags: -Copt-level=3 --target=aarch64-unknown-linux-gnu -//@ [AARCH64] needs-llvm-components: aarch64 -//@ [RISCV] compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu -Ctarget-feature=+v -//@ [RISCV] needs-llvm-components: riscv -//@ [S390X] compile-flags: -Copt-level=3 --target s390x-unknown-linux-gnu -Ctarget-feature=+vector -//@ [S390X] needs-llvm-components: systemz -#![crate_type = "lib"] -#![feature(repr_simd)] -#![feature(no_core)] -#![no_std] -#![no_core] -extern crate minicore; -use minicore::*; - -#[repr(simd)] -pub struct Simd(pub [T; N]); - -pub type u8x16 = Simd; - -// Regression test for https://github.com/rust-lang/rust/issues/97804. - -#[unsafe(no_mangle)] -fn foo(v: u16, p: &mut [u8; 16]) { - // An array repeat transmuted into a SIMD type should emit a canonical LLVM splat sequence: - // - // CHECK-LABEL: foo - // CHECK: start - // CHECK-NEXT: %0 = insertelement <8 x i16> poison, i16 %v, i64 0 - // CHECK-NEXT: %1 = shufflevector <8 x i16> %0, <8 x i16> poison, <8 x i32> zeroinitializer - // CHECK-NEXT: store <8 x i16> %1, ptr %p, align 1 - // CHECK-NEXT: ret void - unsafe { - let v: u8x16 = mem::transmute([v; 8]); - *p = mem::transmute(v); - } -} diff --git a/tests/codegen-llvm/simd/splat.rs b/tests/codegen-llvm/simd/splat.rs deleted file mode 100644 index 7a24162321bd..000000000000 --- a/tests/codegen-llvm/simd/splat.rs +++ /dev/null @@ -1,33 +0,0 @@ -//@ compile-flags: -Copt-level=3 -#![crate_type = "lib"] -#![no_std] -#![feature(repr_simd, core_intrinsics)] -use core::intrinsics::simd::simd_splat; - -#[path = "../../auxiliary/minisimd.rs"] -mod minisimd; -use minisimd::*; - -// Test that `simd_splat` produces the canonical LLVM splat sequence. - -#[no_mangle] -unsafe fn int(x: u16) -> u16x2 { - // CHECK-LABEL: int - // CHECK: start: - // CHECK-NEXT: %0 = insertelement <2 x i16> poison, i16 %x, i64 0 - // CHECK-NEXT: %1 = shufflevector <2 x i16> %0, <2 x i16> poison, <2 x i32> zeroinitializer - // CHECK-NEXT: store - // CHECK-NEXT: ret - simd_splat(x) -} - -#[no_mangle] -unsafe fn float(x: f32) -> f32x4 { - // CHECK-LABEL: float - // CHECK: start: - // CHECK-NEXT: %0 = insertelement <4 x float> poison, float %x, i64 0 - // CHECK-NEXT: %1 = shufflevector <4 x float> %0, <4 x float> poison, <4 x i32> zeroinitializer - // CHECK-NEXT: store - // CHECK-NEXT: ret - simd_splat(x) -} diff --git a/tests/codegen-llvm/slice-is-ascii.rs b/tests/codegen-llvm/slice-is-ascii.rs new file mode 100644 index 000000000000..67537c871a0a --- /dev/null +++ b/tests/codegen-llvm/slice-is-ascii.rs @@ -0,0 +1,16 @@ +//@ only-x86_64 +//@ compile-flags: -C opt-level=3 -C target-cpu=x86-64 +#![crate_type = "lib"] + +/// Check that the fast-path of `is_ascii` uses a `pmovmskb` instruction. +/// Platforms lacking an equivalent instruction use other techniques for +/// optimizing `is_ascii`. +// CHECK-LABEL: @is_ascii_autovectorized +#[no_mangle] +pub fn is_ascii_autovectorized(s: &[u8]) -> bool { + // CHECK: load <32 x i8> + // CHECK-NEXT: icmp slt <32 x i8> + // CHECK-NEXT: bitcast <32 x i1> + // CHECK-NEXT: icmp eq i32 + s.is_ascii() +} diff --git a/tests/codegen-llvm/slice-range-indexing.rs b/tests/codegen-llvm/slice-range-indexing.rs deleted file mode 100644 index c4b3492dc4dc..000000000000 --- a/tests/codegen-llvm/slice-range-indexing.rs +++ /dev/null @@ -1,90 +0,0 @@ -//@ compile-flags: -Copt-level=3 -//@ min-llvm-version: 21 - -#![crate_type = "lib"] - -use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive}; - -macro_rules! tests { - ($range_ty:ty, $get_func_name:ident, $index_func_name:ident) => { - #[no_mangle] - pub fn $get_func_name(slice: &[u32], range: $range_ty) -> Option<&[u32]> { - slice.get(range) - } - - #[no_mangle] - pub fn $index_func_name(slice: &[u32], range: $range_ty) -> &[u32] { - &slice[range] - } - }; -} - -// 2 comparisons required: -// end <= len && start <= end - -// CHECK-LABEL: @get_range -// CHECK-COUNT-2: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range -// CHECK-COUNT-2: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(Range, get_range, index_range); - -// 2 comparisons required: -// end < len && start <= end + 1 - -// CHECK-LABEL: @get_range_inclusive -// CHECK-COUNT-2: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_inclusive -// CHECK-COUNT-2: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeInclusive, get_range_inclusive, index_range_inclusive); - -// 1 comparison required: -// end <= len - -// CHECK-LABEL: @get_range_to -// CHECK-COUNT-1: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_to -// CHECK-COUNT-1: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeTo, get_range_to, index_range_to); - -// 1 comparison required: -// end < len - -// CHECK-LABEL: @get_range_to_inclusive -// CHECK-COUNT-1: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_to_inclusive -// CHECK-COUNT-1: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeToInclusive, get_range_to_inclusive, index_range_to_inclusive); - -// 1 comparison required: -// start <= len - -// CHECK-LABEL: @get_range_from -// CHECK-COUNT-1: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_from -// CHECK-COUNT-1: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeFrom, get_range_from, index_range_from); diff --git a/tests/codegen-llvm/slice_cse_optimization.rs b/tests/codegen-llvm/slice_cse_optimization.rs deleted file mode 100644 index 2b1851d8ae44..000000000000 --- a/tests/codegen-llvm/slice_cse_optimization.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! Various iterating method over slice correctly optimized using common subexpression elimination. -//! Checks function has memory(argmem: read) attribute. -//! Regression test for . -//@ compile-flags: -O - -#![crate_type = "lib"] -// CHECK-LABEL: @has_zero_iter -// CHECK-SAME: #[[ATTR:[0-9]+]] -#[inline(never)] -#[unsafe(no_mangle)] -pub fn has_zero_iter(xs: &[u8]) -> bool { - xs.iter().any(|&x| x == 0) -} - -// CHECK-LABEL: @has_zero_ptr -// CHECK-SAME: #[[ATTR]] -#[inline(never)] -#[unsafe(no_mangle)] -fn has_zero_ptr(xs: &[u8]) -> bool { - let range = xs.as_ptr_range(); - let mut start = range.start; - let end = range.end; - while start < end { - unsafe { - if *start == 0 { - return true; - } - start = start.add(1); - } - } - false -} -// CHECK-LABEL: @has_zero_for -// CHECK-SAME: #[[ATTR]] -#[inline(never)] -#[unsafe(no_mangle)] -fn has_zero_for(xs: &[u8]) -> bool { - for x in xs { - if *x == 0 { - return true; - } - } - false -} - -// CHECK: attributes #[[ATTR]] = { {{.*}}memory(argmem: read){{.*}} } diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs deleted file mode 100644 index 38c0949b8271..000000000000 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! Regression test for #142519 -//@ only-x86_64 -//@ compile-flags: -O -//@ min-llvm-version: 22 - -#![crate_type = "lib"] - -// CHECK-LABEL: @mul3 -// CHECK: phi <4 x i8> -// CHECK: load <4 x i8> -// CHECK: add <4 x i8> -// CHECK: store <4 x i8> - -#[no_mangle] -pub fn mul3(previous: &[[u8; 4]], current: &mut [[u8; 4]]) { - let mut c_bpp = [0u8; 4]; - - for i in 0..previous.len() { - current[i][0] = current[i][0].wrapping_add(c_bpp[0]); - current[i][1] = current[i][1].wrapping_add(c_bpp[1]); - current[i][2] = current[i][2].wrapping_add(c_bpp[2]); - current[i][3] = current[i][3].wrapping_add(c_bpp[3]); - - c_bpp = previous[i]; - } -} diff --git a/tests/codegen-llvm/str-range-indexing.rs b/tests/codegen-llvm/str-range-indexing.rs deleted file mode 100644 index dee1a3a41c46..000000000000 --- a/tests/codegen-llvm/str-range-indexing.rs +++ /dev/null @@ -1,94 +0,0 @@ -//@ compile-flags: -Copt-level=3 -//@ min-llvm-version: 21 - -#![crate_type = "lib"] - -use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive}; - -macro_rules! tests { - ($range_ty:ty, $get_func_name:ident, $index_func_name:ident) => { - #[no_mangle] - pub fn $get_func_name(slice: &str, range: $range_ty) -> Option<&str> { - slice.get(range) - } - - #[no_mangle] - pub fn $index_func_name(slice: &str, range: $range_ty) -> &str { - &slice[range] - } - }; -} - -// 9 comparisons required: -// start <= end -// && (start == 0 || (start >= len && start == len) || bytes[start] >= -0x40) -// && (end == 0 || (end >= len && end == len) || bytes[end] >= -0x40) - -// CHECK-LABEL: @get_range -// CHECK-COUNT-9: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range -// CHECK-COUNT-9: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(Range, get_range, index_range); - -// 7 comparisons required: -// end < len && start <= end + 1 -// && (start == 0 || start >= len || bytes[start] >= -0x40) -// && ( end + 1 >= len || bytes[end + 1] >= -0x40) - -// CHECK-LABEL: @get_range_inclusive -// CHECK-COUNT-7: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_inclusive -// CHECK-COUNT-7: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeInclusive, get_range_inclusive, index_range_inclusive); - -// 4 comparisons required: -// end == 0 || (end >= len && end == len) || bytes[end] >= -0x40 - -// CHECK-LABEL: @get_range_to -// CHECK-COUNT-4: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_to -// CHECK-COUNT-4: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeTo, get_range_to, index_range_to); - -// 3 comparisons required: -// end < len && (end + 1 >= len || bytes[end + 1] >= -0x40) - -// CHECK-LABEL: @get_range_to_inclusive -// CHECK-COUNT-3: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_to_inclusive -// CHECK-COUNT-3: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeToInclusive, get_range_to_inclusive, index_range_to_inclusive); - -// 4 comparisons required: -// start == 0 || (start >= len && start == len) || bytes[start] >= -0x40) - -// CHECK-LABEL: @get_range_from -// CHECK-COUNT-4: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret - -// CHECK-LABEL: @index_range_from -// CHECK-COUNT-4: %{{.+}} = icmp -// CHECK-NOT: %{{.+}} = icmp -// CHECK: ret -tests!(RangeFrom, get_range_from, index_range_from); diff --git a/tests/codegen-llvm/vec-calloc.rs b/tests/codegen-llvm/vec-calloc.rs index b02b858f966b..15971bbfa003 100644 --- a/tests/codegen-llvm/vec-calloc.rs +++ b/tests/codegen-llvm/vec-calloc.rs @@ -197,6 +197,6 @@ pub fn vec_array(n: usize) -> Vec<[u32; 1_000_000]> { } // Ensure that __rust_alloc_zeroed gets the right attributes for LLVM to optimize it away. -// CHECK: declare noalias noundef ptr @{{.*}}__rust_alloc_zeroed(i64 noundef, i64 allocalign noundef range(i64 1, -9223372036854775807)) unnamed_addr [[RUST_ALLOC_ZEROED_ATTRS:#[0-9]+]] +// CHECK: declare noalias noundef ptr @{{.*}}__rust_alloc_zeroed(i64 noundef, i64 allocalign noundef) unnamed_addr [[RUST_ALLOC_ZEROED_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ZEROED_ATTRS]] = { {{.*}} allockind("alloc,zeroed,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index a3f649a80e32..54ab656c53db 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -42,6 +42,7 @@ pub fn foo2() -> Box { } //~ MONO_ITEM fn ::test_func2 +//~ MONO_ITEM fn alloc::alloc::exchange_malloc //~ MONO_ITEM fn foo2 //~ MONO_ITEM fn std::alloc::Global::alloc_impl_runtime //~ MONO_ITEM fn std::boxed::Box::::new diff --git a/tests/coverage/macros/context-mismatch-issue-147339.cov-map b/tests/coverage/macros/context-mismatch-issue-147339.cov-map deleted file mode 100644 index 7aa829cab72b..000000000000 --- a/tests/coverage/macros/context-mismatch-issue-147339.cov-map +++ /dev/null @@ -1,40 +0,0 @@ -Function name: context_mismatch_issue_147339::a (unused) -Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c] -Number of files: 1 -- file 0 => $DIR/context-mismatch-issue-147339.rs -Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Zero) at (prev + 12, 39) to (start + 0, 53) -- Code(Zero) at (prev + 0, 59) to (start + 0, 60) -Highest counter ID seen: (none) - -Function name: context_mismatch_issue_147339::b (unused) -Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c] -Number of files: 1 -- file 0 => $DIR/context-mismatch-issue-147339.rs -Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Zero) at (prev + 12, 39) to (start + 0, 53) -- Code(Zero) at (prev + 0, 59) to (start + 0, 60) -Highest counter ID seen: (none) - -Function name: context_mismatch_issue_147339::c (unused) -Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c] -Number of files: 1 -- file 0 => $DIR/context-mismatch-issue-147339.rs -Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Zero) at (prev + 12, 39) to (start + 0, 53) -- Code(Zero) at (prev + 0, 59) to (start + 0, 60) -Highest counter ID seen: (none) - -Function name: context_mismatch_issue_147339::main -Raw bytes (14): 0x[01, 01, 00, 02, 01, 14, 01, 00, 0a, 01, 00, 0c, 00, 0d] -Number of files: 1 -- file 0 => $DIR/context-mismatch-issue-147339.rs -Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Counter(0)) at (prev + 20, 1) to (start + 0, 10) -- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13) -Highest counter ID seen: c0 - diff --git a/tests/coverage/macros/context-mismatch-issue-147339.coverage b/tests/coverage/macros/context-mismatch-issue-147339.coverage deleted file mode 100644 index 9b4fc67b8dff..000000000000 --- a/tests/coverage/macros/context-mismatch-issue-147339.coverage +++ /dev/null @@ -1,28 +0,0 @@ - LL| |//@ edition: 2024 - LL| | - LL| |// These nested macro expansions were found to cause span refinement to produce - LL| |// spans with a context that doesn't match the function body span, triggering - LL| |// a defensive check that discards the span. - LL| |// - LL| |// Reported in . - LL| | - LL| |macro_rules! foo { - LL| | ($($m:ident $($f:ident $v:tt)+),*) => { - LL| | $($(macro_rules! $f { () => { $v } })+)* - LL| 0| $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })* - ------------------ - | Unexecuted instantiation: context_mismatch_issue_147339::a - ------------------ - | Unexecuted instantiation: context_mismatch_issue_147339::b - ------------------ - | Unexecuted instantiation: context_mismatch_issue_147339::c - ------------------ - LL| | } - LL| |} - LL| | - LL| |foo!(m a 1 b 2, n c 3); - LL| |m!(); - LL| |n!(); - LL| | - LL| 1|fn main() {} - diff --git a/tests/coverage/macros/context-mismatch-issue-147339.rs b/tests/coverage/macros/context-mismatch-issue-147339.rs deleted file mode 100644 index 80e744afc7c6..000000000000 --- a/tests/coverage/macros/context-mismatch-issue-147339.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ edition: 2024 - -// These nested macro expansions were found to cause span refinement to produce -// spans with a context that doesn't match the function body span, triggering -// a defensive check that discards the span. -// -// Reported in . - -macro_rules! foo { - ($($m:ident $($f:ident $v:tt)+),*) => { - $($(macro_rules! $f { () => { $v } })+)* - $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })* - } -} - -foo!(m a 1 b 2, n c 3); -m!(); -n!(); - -fn main() {} diff --git a/tests/coverage/macros/pass-through.cov-map b/tests/coverage/macros/pass-through.cov-map deleted file mode 100644 index 83937e4fb8b7..000000000000 --- a/tests/coverage/macros/pass-through.cov-map +++ /dev/null @@ -1,57 +0,0 @@ -Function name: pass_through::uses_inner_macro -Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 24, 01, 00, 16, 01, 01, 08, 00, 1d, 05, 01, 09, 00, 0c, 05, 00, 0d, 00, 21, 05, 01, 09, 00, 15, 05, 01, 09, 00, 0c, 05, 00, 0d, 00, 20, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/pass-through.rs -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 36, 1) to (start + 0, 22) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 29) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 33) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 21) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 32) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) - = (c0 - c1) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c1 - -Function name: pass_through::uses_middle_macro -Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 2c, 01, 00, 17, 01, 01, 08, 00, 1d, 05, 01, 09, 00, 0c, 05, 00, 0d, 00, 22, 05, 01, 09, 00, 16, 05, 01, 09, 00, 0c, 05, 00, 0d, 00, 21, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/pass-through.rs -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 44, 1) to (start + 0, 23) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 29) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 34) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 22) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 33) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) - = (c0 - c1) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c1 - -Function name: pass_through::uses_outer_macro -Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 34, 01, 00, 16, 01, 01, 08, 00, 1d, 05, 01, 09, 00, 0c, 05, 00, 0d, 00, 21, 05, 01, 09, 00, 15, 05, 01, 09, 00, 0c, 05, 00, 0d, 00, 20, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/pass-through.rs -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 52, 1) to (start + 0, 22) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 29) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 33) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 21) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 32) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) - = (c0 - c1) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c1 - diff --git a/tests/coverage/macros/pass-through.coverage b/tests/coverage/macros/pass-through.coverage deleted file mode 100644 index f1adb235f74a..000000000000 --- a/tests/coverage/macros/pass-through.coverage +++ /dev/null @@ -1,71 +0,0 @@ - LL| |#![feature(coverage_attribute)] - LL| |//@ edition: 2024 - LL| | - LL| |// Test that when a macro expands to another macro, without any significant - LL| |// spans of its own, that this doesn't cause coverage instrumentation to give - LL| |// up and ignore the inner spans. - LL| | - LL| |macro_rules! inner_macro { - LL| | () => { - LL| | if core::hint::black_box(true) { - LL| | say("true"); - LL| | } else { - LL| | say("false"); - LL| | } - LL| | }; - LL| |} - LL| | - LL| |macro_rules! middle_macro { - LL| | () => { - LL| | inner_macro!() - LL| | }; - LL| |} - LL| | - LL| |macro_rules! outer_macro { - LL| | () => { - LL| | middle_macro!() - LL| | }; - LL| |} - LL| | - LL| |// In each of these three functions, the macro call should be instrumented, - LL| |// and should have an execution count of 1. - LL| |// - LL| |// Each function contains some extra code to ensure that control flow is - LL| |// non-trivial. - LL| | - LL| 1|fn uses_inner_macro() { - LL| 1| if core::hint::black_box(true) { - LL| 1| say("before inner_macro"); - LL| 1| inner_macro!(); - LL| 1| say("after inner_macro"); - LL| 0| } - LL| 1|} - LL| | - LL| 1|fn uses_middle_macro() { - LL| 1| if core::hint::black_box(true) { - LL| 1| say("before middle_macro"); - LL| 1| middle_macro!(); - LL| 1| say("after middle_macro") - LL| 0| } - LL| 1|} - LL| | - LL| 1|fn uses_outer_macro() { - LL| 1| if core::hint::black_box(true) { - LL| 1| say("before outer_macro"); - LL| 1| outer_macro!(); - LL| 1| say("after outer_macro"); - LL| 0| } - LL| 1|} - LL| | - LL| |#[coverage(off)] - LL| |fn main() { - LL| | uses_inner_macro(); - LL| | uses_middle_macro(); - LL| | uses_outer_macro(); - LL| |} - LL| | - LL| |#[coverage(off)] - LL| |fn say(message: &str) { - LL| | println!("{message}"); - LL| |} - diff --git a/tests/coverage/macros/pass-through.rs b/tests/coverage/macros/pass-through.rs deleted file mode 100644 index 6e5ad3d93b73..000000000000 --- a/tests/coverage/macros/pass-through.rs +++ /dev/null @@ -1,70 +0,0 @@ -#![feature(coverage_attribute)] -//@ edition: 2024 - -// Test that when a macro expands to another macro, without any significant -// spans of its own, that this doesn't cause coverage instrumentation to give -// up and ignore the inner spans. - -macro_rules! inner_macro { - () => { - if core::hint::black_box(true) { - say("true"); - } else { - say("false"); - } - }; -} - -macro_rules! middle_macro { - () => { - inner_macro!() - }; -} - -macro_rules! outer_macro { - () => { - middle_macro!() - }; -} - -// In each of these three functions, the macro call should be instrumented, -// and should have an execution count of 1. -// -// Each function contains some extra code to ensure that control flow is -// non-trivial. - -fn uses_inner_macro() { - if core::hint::black_box(true) { - say("before inner_macro"); - inner_macro!(); - say("after inner_macro"); - } -} - -fn uses_middle_macro() { - if core::hint::black_box(true) { - say("before middle_macro"); - middle_macro!(); - say("after middle_macro") - } -} - -fn uses_outer_macro() { - if core::hint::black_box(true) { - say("before outer_macro"); - outer_macro!(); - say("after outer_macro"); - } -} - -#[coverage(off)] -fn main() { - uses_inner_macro(); - uses_middle_macro(); - uses_outer_macro(); -} - -#[coverage(off)] -fn say(message: &str) { - println!("{message}"); -} diff --git a/tests/coverage/remap-path-prefix.rs b/tests/coverage/remap-path-prefix.rs index 031b87b8f771..29c5826989c4 100644 --- a/tests/coverage/remap-path-prefix.rs +++ b/tests/coverage/remap-path-prefix.rs @@ -10,8 +10,8 @@ //@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope //@ compile-flags: --remap-path-prefix={{src-base}}=remapped // -//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage -//@[with_object_scope] compile-flags: --remap-path-scope=object -//@[with_macro_scope] compile-flags: --remap-path-scope=macro +//@[with_coverage_scope] compile-flags: -Zremap-path-scope=coverage +//@[with_object_scope] compile-flags: -Zremap-path-scope=object +//@[with_macro_scope] compile-flags: -Zremap-path-scope=macro fn main() {} diff --git a/tests/coverage/remap-path-prefix.with_macro_scope.coverage b/tests/coverage/remap-path-prefix.with_macro_scope.coverage index 9e8317672f90..63979d8fe15a 100644 --- a/tests/coverage/remap-path-prefix.with_macro_scope.coverage +++ b/tests/coverage/remap-path-prefix.with_macro_scope.coverage @@ -10,9 +10,9 @@ LL| |//@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope LL| |//@ compile-flags: --remap-path-prefix={{src-base}}=remapped LL| |// - LL| |//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage - LL| |//@[with_object_scope] compile-flags: --remap-path-scope=object - LL| |//@[with_macro_scope] compile-flags: --remap-path-scope=macro + LL| |//@[with_coverage_scope] compile-flags: -Zremap-path-scope=coverage + LL| |//@[with_object_scope] compile-flags: -Zremap-path-scope=object + LL| |//@[with_macro_scope] compile-flags: -Zremap-path-scope=macro LL| | LL| 1|fn main() {} diff --git a/tests/crashes/131292.rs b/tests/crashes/131292.rs new file mode 100644 index 000000000000..05b93d06b055 --- /dev/null +++ b/tests/crashes/131292.rs @@ -0,0 +1,7 @@ +//@ known-bug: #131292 +//@ needs-asm-support +use std::arch::asm; + +unsafe fn f6() { + asm!(concat!(r#"lJð¿Ã†ï¿½.ð¿ï¿½"#, "{}/day{:02}.txt")); +} diff --git a/tests/crashes/133966.rs b/tests/crashes/133966.rs new file mode 100644 index 000000000000..25a881ae99b4 --- /dev/null +++ b/tests/crashes/133966.rs @@ -0,0 +1,3 @@ +//@ known-bug: #133966 +pub struct Data([[&'static str]; 5_i32]); +const _: &'static Data = unsafe { &*(&[] as *const Data) }; diff --git a/tests/crashes/135845.rs b/tests/crashes/135845.rs new file mode 100644 index 000000000000..ed038d8a1f18 --- /dev/null +++ b/tests/crashes/135845.rs @@ -0,0 +1,6 @@ +//@ known-bug: #135845 +struct S<'a, T: ?Sized>(&'a T); + +fn b<'a>() -> S<'static, _> { + S::<'a>(&0) +} diff --git a/tests/crashes/136063.rs b/tests/crashes/136063.rs new file mode 100644 index 000000000000..078cc59dfa28 --- /dev/null +++ b/tests/crashes/136063.rs @@ -0,0 +1,6 @@ +//@ known-bug: #136063 +#![feature(generic_const_exprs)] +trait A {} +impl A<1> for bool {} +fn bar(arg : &dyn A) { bar(true) } +pub fn main() {} diff --git a/tests/crashes/137084.rs b/tests/crashes/137084.rs new file mode 100644 index 000000000000..0f248c212062 --- /dev/null +++ b/tests/crashes/137084.rs @@ -0,0 +1,6 @@ +//@ known-bug: #137084 +#![feature(min_generic_const_args)] +fn a() {} +fn d(e: &String) { + a:: +} diff --git a/tests/crashes/137260.rs b/tests/crashes/137260.rs new file mode 100644 index 000000000000..f1fa8a660dcd --- /dev/null +++ b/tests/crashes/137260.rs @@ -0,0 +1,11 @@ +//@ known-bug: #137260 +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Iter {} + +fn needs_iter>() {} + +fn test() { + needs_iter::<1, dyn Iter<()>>(); +} diff --git a/tests/crashes/137514.rs b/tests/crashes/137514.rs new file mode 100644 index 000000000000..7ae5f29e36e6 --- /dev/null +++ b/tests/crashes/137514.rs @@ -0,0 +1,9 @@ +//@ known-bug: #137514 +//@ needs-rustc-debug-assertions +#![feature(generic_const_exprs)] + +trait Bar {} + +trait BB = Bar<{ 1i32 + 1 }>; + +fn foo(x: &dyn BB) {} diff --git a/tests/crashes/137582.rs b/tests/crashes/137582.rs new file mode 100644 index 000000000000..e21b6c9578b7 --- /dev/null +++ b/tests/crashes/137582.rs @@ -0,0 +1,16 @@ +//@ known-bug: #137582 +#![feature(adt_const_params)] + +mod lib { + pub type Matrix = [&'static u32]; + + const EMPTY_MATRIX: Matrix = [[0; 4]; 4]; + + pub struct Walk { + _p: (), + } + + impl Walk {} +} + +fn main() {} diff --git a/tests/crashes/137916.rs b/tests/crashes/137916.rs new file mode 100644 index 000000000000..b25e7b200d95 --- /dev/null +++ b/tests/crashes/137916.rs @@ -0,0 +1,13 @@ +//@ known-bug: #137916 +//@ edition: 2021 +use std::ptr::null; + +async fn a() -> Box { + Box::new(async { + let non_send = null::<()>(); + &non_send; + async {}.await + }) +} + +fn main() {} diff --git a/tests/crashes/138089.rs b/tests/crashes/138089.rs new file mode 100644 index 000000000000..054d1b216959 --- /dev/null +++ b/tests/crashes/138089.rs @@ -0,0 +1,14 @@ +//@ known-bug: #138089 +#![feature(generic_const_exprs)] +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +struct OnDiskDirEntry<'a> {} + +impl<'a> OnDiskDirEntry<'a> { + #[type_const] + const LFN_FRAGMENT_LEN: i64 = 2; + + fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { + loop {} + } +} diff --git a/tests/crashes/138274.rs b/tests/crashes/138274.rs new file mode 100644 index 000000000000..d657b27e46f3 --- /dev/null +++ b/tests/crashes/138274.rs @@ -0,0 +1,18 @@ +//@ known-bug: #138274 +//@ edition: 2021 +//@ compile-flags: --crate-type=lib +trait Trait {} + +fn foo() -> Box { + todo!() +} + +fn fetch() { + async { + let fut = async { + let _x = foo(); + async {}.await; + }; + let _: Box = Box::new(fut); + }; +} diff --git a/tests/crashes/149809.rs b/tests/crashes/149809.rs deleted file mode 100644 index f70498f11c87..000000000000 --- a/tests/crashes/149809.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ known-bug: #149809 -#![feature(min_generic_const_args)] -#![feature(inherent_associated_types)] -struct Qux<'a> { - x: &'a (), -} -impl<'a> Qux<'a> { - type const LEN: usize = 4; - fn foo(_: [u8; Qux::LEN]) {} -} - -fn main() {} diff --git a/tests/debuginfo/associated-const-bindings.rs b/tests/debuginfo/associated-const-bindings.rs deleted file mode 100644 index 88c17cee8025..000000000000 --- a/tests/debuginfo/associated-const-bindings.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ compile-flags: -g -//@ disable-gdb-pretty-printers -//@ ignore-backends: gcc - -//@ gdb-command:run -//@ gdb-command:whatis local -//@ gdb-check:type = &dyn associated_const_bindings::Trait - -//@ cdb-command: g -//@ cdb-command:dv /t /n local -//@ cdb-check:struct ref$ > > > local = [...] - -#![feature(min_generic_const_args)] -#![expect(unused_variables, incomplete_features)] - -trait Trait { - type const N: usize; -} -impl Trait for () { - type const N: usize = 101; -} - -fn main() { - let local = &() as &dyn Trait; - - zzz(); // #break -} - -#[inline(never)] -fn zzz() { - () -} diff --git a/tests/debuginfo/basic-stepping.rs b/tests/debuginfo/basic-stepping.rs index 744f8f5dd654..ffb5d87710dc 100644 --- a/tests/debuginfo/basic-stepping.rs +++ b/tests/debuginfo/basic-stepping.rs @@ -5,14 +5,8 @@ //@ ignore-aarch64: Doesn't work yet. //@ ignore-loongarch64: Doesn't work yet. //@ ignore-riscv64: Doesn't work yet. -//@ ignore-backends: gcc - -// Debugger tests need debuginfo //@ compile-flags: -g - -// FIXME(#128945): SingleUseConsts shouldn't need to be disabled. -//@ revisions: default-mir-passes no-SingleUseConsts-mir-pass -//@ [no-SingleUseConsts-mir-pass] compile-flags: -Zmir-enable-passes=-SingleUseConsts +//@ ignore-backends: gcc //@ gdb-command: run // FIXME(#97083): Should we be able to break on initialization of zero-sized types? @@ -21,12 +15,12 @@ //@ gdb-command: next //@ gdb-check: let d = c = 99; //@ gdb-command: next -//@ [no-SingleUseConsts-mir-pass] gdb-check: let e = "hi bob"; -//@ [no-SingleUseConsts-mir-pass] gdb-command: next -//@ [no-SingleUseConsts-mir-pass] gdb-check: let f = b"hi bob"; -//@ [no-SingleUseConsts-mir-pass] gdb-command: next -//@ [no-SingleUseConsts-mir-pass] gdb-check: let g = b'9'; -//@ [no-SingleUseConsts-mir-pass] gdb-command: next +// FIXME(#33013): gdb-check: let e = "hi bob"; +// FIXME(#33013): gdb-command: next +// FIXME(#33013): gdb-check: let f = b"hi bob"; +// FIXME(#33013): gdb-command: next +// FIXME(#33013): gdb-check: let g = b'9'; +// FIXME(#33013): gdb-command: next //@ gdb-check: let h = ["whatever"; 8]; //@ gdb-command: next //@ gdb-check: let i = [1,2,3,4]; diff --git a/tests/debuginfo/borrowed-enum.rs b/tests/debuginfo/borrowed-enum.rs index b87d1f2b96d2..9c6e466c43c2 100644 --- a/tests/debuginfo/borrowed-enum.rs +++ b/tests/debuginfo/borrowed-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/by-value-non-immediate-argument.rs b/tests/debuginfo/by-value-non-immediate-argument.rs index 4ecb76ee0846..523f6b7623d1 100644 --- a/tests/debuginfo/by-value-non-immediate-argument.rs +++ b/tests/debuginfo/by-value-non-immediate-argument.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ min-gdb-version: 13.0 //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/coroutine-objects.rs b/tests/debuginfo/coroutine-objects.rs index 783156e07b8e..598de2ee4538 100644 --- a/tests/debuginfo/coroutine-objects.rs +++ b/tests/debuginfo/coroutine-objects.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 // LLDB (18.1+) now supports DW_TAG_variant_part, but there is some bug in either compiler or LLDB // with memory layout of discriminant for this particular enum diff --git a/tests/debuginfo/enum-thinlto.rs b/tests/debuginfo/enum-thinlto.rs index ef41feec6e24..4da49022630a 100644 --- a/tests/debuginfo/enum-thinlto.rs +++ b/tests/debuginfo/enum-thinlto.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g -Z thinlto //@ disable-gdb-pretty-printers //@ ignore-backends: gcc diff --git a/tests/debuginfo/function-arg-initialization.rs b/tests/debuginfo/function-arg-initialization.rs index 9b20eb1b8a4f..78fecd8a4bfe 100644 --- a/tests/debuginfo/function-arg-initialization.rs +++ b/tests/debuginfo/function-arg-initialization.rs @@ -5,8 +5,7 @@ // arguments have been properly loaded when setting the breakpoint via the // function name. -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc diff --git a/tests/debuginfo/function-prologue-stepping-regular.rs b/tests/debuginfo/function-prologue-stepping-regular.rs index 2a4a64f87303..83d5aa3c0a10 100644 --- a/tests/debuginfo/function-prologue-stepping-regular.rs +++ b/tests/debuginfo/function-prologue-stepping-regular.rs @@ -1,8 +1,7 @@ // This test case checks if function arguments already have the correct value when breaking at the // beginning of a function. -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ ignore-gdb //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/issue-57822.rs b/tests/debuginfo/issue-57822.rs index a970db873a28..6b030686e4ea 100644 --- a/tests/debuginfo/issue-57822.rs +++ b/tests/debuginfo/issue-57822.rs @@ -1,8 +1,7 @@ // This test makes sure that the LLDB pretty printer does not throw an exception // for nested closures and coroutines. -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc diff --git a/tests/debuginfo/macro-stepping.rs b/tests/debuginfo/macro-stepping.rs index 3f57eb9ad79b..ba3a4452041a 100644 --- a/tests/debuginfo/macro-stepping.rs +++ b/tests/debuginfo/macro-stepping.rs @@ -4,8 +4,7 @@ //! and we can match on them for testing purposes. //@ ignore-android -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ min-gdb-version: 13.0 //@ aux-build:macro-stepping.rs diff --git a/tests/debuginfo/method-on-enum.rs b/tests/debuginfo/method-on-enum.rs index 6c724622a89e..c7955a7e875a 100644 --- a/tests/debuginfo/method-on-enum.rs +++ b/tests/debuginfo/method-on-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ min-gdb-version: 13.0 //@ compile-flags:-g diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs index 1f55adcb5c00..efe5b066b52c 100644 --- a/tests/debuginfo/msvc-pretty-enums.rs +++ b/tests/debuginfo/msvc-pretty-enums.rs @@ -1,6 +1,5 @@ //@ only-msvc -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ ignore-gdb //@ compile-flags:-g diff --git a/tests/debuginfo/opt/dead_refs.rs b/tests/debuginfo/opt/dead_refs.rs index 8653b5d3b251..61c39f4fb778 100644 --- a/tests/debuginfo/opt/dead_refs.rs +++ b/tests/debuginfo/opt/dead_refs.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ min-gdb-version: 13.0 //@ compile-flags: -g -Copt-level=3 //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/option-like-enum.rs b/tests/debuginfo/option-like-enum.rs index 027e9657d8ab..047a738574c2 100644 --- a/tests/debuginfo/option-like-enum.rs +++ b/tests/debuginfo/option-like-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ min-gdb-version: 13.0 //@ compile-flags:-g diff --git a/tests/debuginfo/pretty-std.rs b/tests/debuginfo/pretty-std.rs index bf3102993d89..d4cb2f6625f4 100644 --- a/tests/debuginfo/pretty-std.rs +++ b/tests/debuginfo/pretty-std.rs @@ -2,8 +2,7 @@ //@ ignore-windows-gnu: #128981 //@ ignore-android: FIXME(#10381) //@ compile-flags:-g -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ min-cdb-version: 10.0.18317.1001 //@ ignore-backends: gcc diff --git a/tests/debuginfo/strings-and-strs.rs b/tests/debuginfo/strings-and-strs.rs index 165cfcd968a6..afb8b873ca08 100644 --- a/tests/debuginfo/strings-and-strs.rs +++ b/tests/debuginfo/strings-and-strs.rs @@ -1,6 +1,5 @@ //@ min-gdb-version: 14.0 -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/struct-in-enum.rs b/tests/debuginfo/struct-in-enum.rs index 89620c31a04f..02b2e6eb4cb7 100644 --- a/tests/debuginfo/struct-in-enum.rs +++ b/tests/debuginfo/struct-in-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/struct-style-enum.rs b/tests/debuginfo/struct-style-enum.rs index 7e38a5dcd079..e3d6c64c36aa 100644 --- a/tests/debuginfo/struct-style-enum.rs +++ b/tests/debuginfo/struct-style-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc diff --git a/tests/debuginfo/tuple-style-enum.rs b/tests/debuginfo/tuple-style-enum.rs index 0a06370c979e..7541b8aa3c6b 100644 --- a/tests/debuginfo/tuple-style-enum.rs +++ b/tests/debuginfo/tuple-style-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/debuginfo/unique-enum.rs b/tests/debuginfo/unique-enum.rs index 3bc6ce259655..3cc9b7774193 100644 --- a/tests/debuginfo/unique-enum.rs +++ b/tests/debuginfo/unique-enum.rs @@ -1,5 +1,4 @@ -// LLDB 1800+ tests were not tested in CI, broke, and now are disabled -//@ ignore-lldb +//@ min-lldb-version: 1800 //@ compile-flags:-g //@ disable-gdb-pretty-printers diff --git a/tests/incremental/const-generics/issue-64087.rs b/tests/incremental/const-generics/issue-64087.rs index 97f212b3fbba..787f2af8aa39 100644 --- a/tests/incremental/const-generics/issue-64087.rs +++ b/tests/incremental/const-generics/issue-64087.rs @@ -6,4 +6,6 @@ fn combinator() -> [T; S] {} fn main() { combinator().into_iter(); //[cfail1]~^ ERROR type annotations needed + //[cfail1]~| ERROR type annotations needed + //[cfail1]~| ERROR type annotations needed } diff --git a/tests/incremental/clean.rs b/tests/incremental/dirty_clean.rs similarity index 100% rename from tests/incremental/clean.rs rename to tests/incremental/dirty_clean.rs diff --git a/tests/incremental/unchecked_clean.rs b/tests/incremental/unchecked_dirty_clean.rs similarity index 100% rename from tests/incremental/unchecked_clean.rs rename to tests/incremental/unchecked_dirty_clean.rs diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir index 4c9ca11f8283..9ff1a90ab820 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir @@ -1,6 +1,6 @@ // MIR for `foo::{closure#0}::{closure#0}` after built -fn foo::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_fake_read_for_by_move.rs:12:27: 15:6}, _2: std::future::ResumeTy) -> () +fn foo::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_fake_read_for_by_move.rs:12:27: 15:6}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir index e80fdea7051d..4b745caf48c5 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir @@ -1,6 +1,6 @@ // MIR for `foo::{closure#0}::{synthetic#0}` after built -fn foo::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_fake_read_for_by_move.rs:12:27: 15:6}, _2: std::future::ResumeTy) -> () +fn foo::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_fake_read_for_by_move.rs:12:27: 15:6}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir index 075065b4c090..4d484b16b507 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}::{closure#0}` after built -fn main::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: std::future::ResumeTy) -> () +fn main::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir index 0f4e5f3cb02f..ace780f773e8 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}::{synthetic#0}` after built -fn main::{closure#0}::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: std::future::ResumeTy) -> () +fn main::{closure#0}::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir index 18f4e741384f..f50ad689f447 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#1}::{closure#0}` after built -fn main::{closure#0}::{closure#1}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: std::future::ResumeTy) -> () +fn main::{closure#0}::{closure#1}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir index 257586c4a080..62d8adeedcb6 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#1}::{synthetic#0}` after built -fn main::{closure#0}::{closure#1}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: std::future::ResumeTy) -> () +fn main::{closure#0}::{closure#1}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.diff b/tests/mir-opt/box_expr.main.ElaborateDrops.diff new file mode 100644 index 000000000000..4fa77cf82d81 --- /dev/null +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.diff @@ -0,0 +1,89 @@ +- // MIR for `main` before ElaborateDrops ++ // MIR for `main` after ElaborateDrops + + fn main() -> () { + let mut _0: (); + let _1: std::boxed::Box; + let mut _2: *mut u8; + let mut _3: std::boxed::Box; + let _4: (); + let mut _5: std::boxed::Box; ++ let mut _6: &mut std::boxed::Box; ++ let mut _7: (); ++ let mut _8: *const S; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_3); + _3 = ShallowInitBox(move _2, S); + (*_3) = S::new() -> [return: bb2, unwind: bb8]; + } + + bb2: { + _1 = move _3; +- drop(_3) -> [return: bb3, unwind continue]; ++ goto -> bb3; + } + + bb3: { + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = move _1; + _4 = std::mem::drop::>(move _5) -> [return: bb4, unwind: bb6]; + } + + bb4: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); +- drop(_1) -> [return: bb5, unwind continue]; ++ goto -> bb5; + } + + bb5: { + StorageDead(_1); + return; + } + + bb6 (cleanup): { +- drop(_5) -> [return: bb7, unwind terminate(cleanup)]; ++ goto -> bb7; + } + + bb7 (cleanup): { +- drop(_1) -> [return: bb9, unwind terminate(cleanup)]; ++ goto -> bb9; + } + + bb8 (cleanup): { +- drop(_3) -> [return: bb9, unwind terminate(cleanup)]; ++ goto -> bb12; + } + + bb9 (cleanup): { + resume; ++ } ++ ++ bb10 (cleanup): { ++ _6 = &mut _3; ++ _7 = as Drop>::drop(move _6) -> [return: bb9, unwind terminate(cleanup)]; ++ } ++ ++ bb11 (cleanup): { ++ goto -> bb10; ++ } ++ ++ bb12 (cleanup): { ++ _8 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const S (Transmute); ++ goto -> bb11; + } + } + diff --git a/tests/mir-opt/box_expr.rs b/tests/mir-opt/box_expr.rs new file mode 100644 index 000000000000..6299c9871809 --- /dev/null +++ b/tests/mir-opt/box_expr.rs @@ -0,0 +1,39 @@ +//@ test-mir-pass: ElaborateDrops +//@ needs-unwind + +#![feature(rustc_attrs, liballoc_internals)] + +// EMIT_MIR box_expr.main.ElaborateDrops.diff +fn main() { + // CHECK-LABEL: fn main( + // CHECK: [[ptr:_.*]] = move {{_.*}} as *const S (Transmute); + // CHECK: [[nonnull:_.*]] = NonNull:: { pointer: move [[ptr]] }; + // CHECK: [[unique:_.*]] = Unique:: { pointer: move [[nonnull]], _marker: const PhantomData:: }; + // CHECK: [[box:_.*]] = Box::(move [[unique]], const std::alloc::Global); + // CHECK: [[ptr:_.*]] = copy (([[box]].0: std::ptr::Unique).0: std::ptr::NonNull) as *const S (Transmute); + // CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]]; + // CHECK: [[ret]]: { + // CHECK: [[box2:_.*]] = move [[box]]; + // CHECK: [[box3:_.*]] = move [[box2]]; + // CHECK: std::mem::drop::>(move [[box3]]) + // CHECK: [[unwind]] (cleanup): { + // CHECK: [[boxref:_.*]] = &mut [[box]]; + // CHECK: as Drop>::drop(move [[boxref]]) + + let x = std::boxed::box_new(S::new()); + drop(x); +} + +struct S; + +impl S { + fn new() -> Self { + S + } +} + +impl Drop for S { + fn drop(&mut self) { + println!("splat!"); + } +} diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index cef4325b9a4d..83281dea44db 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -32,7 +32,7 @@ fn main() -> () { bb1: { StorageLive(_3); StorageLive(_4); - _4 = std::rt::begin_panic::<&str>(const "explicit panic") -> bb8; + _4 = begin_panic::<&str>(const "explicit panic") -> bb8; } bb2: { diff --git a/tests/mir-opt/building/match/never_patterns.opt1.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/never_patterns.opt1.SimplifyCfg-initial.after.mir index 78356a90743a..bba4d9c0149a 100644 --- a/tests/mir-opt/building/match/never_patterns.opt1.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/never_patterns.opt1.SimplifyCfg-initial.after.mir @@ -13,17 +13,17 @@ fn opt1(_1: &Result) -> &u32 { bb0: { PlaceMention(_1); - _2 = discriminant((*_1)); - switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; + falseEdge -> [real: bb4, imaginary: bb1]; } bb1: { - FakeRead(ForMatchedPlace(None), _1); - unreachable; + _2 = discriminant((*_1)); + switchInt(move _2) -> [1: bb3, otherwise: bb2]; } bb2: { - falseEdge -> [real: bb4, imaginary: bb3]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb3: { diff --git a/tests/mir-opt/building/match/never_patterns.opt2.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/never_patterns.opt2.SimplifyCfg-initial.after.mir index 979fbb2860dc..fc0769d6f7dc 100644 --- a/tests/mir-opt/building/match/never_patterns.opt2.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/never_patterns.opt2.SimplifyCfg-initial.after.mir @@ -11,25 +11,10 @@ fn opt2(_1: &Result) -> &u32 { bb0: { PlaceMention(_1); - _2 = discriminant((*_1)); - switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; - } - - bb1: { - FakeRead(ForMatchedPlace(None), _1); - unreachable; - } - - bb2: { StorageLive(_3); _3 = &(((*_1) as Ok).0: u32); _0 = &(*_3); StorageDead(_3); return; } - - bb3: { - FakeRead(ForMatchedPlace(None), (((*_1) as Err).0: Void)); - unreachable; - } } diff --git a/tests/mir-opt/building/match/never_patterns.opt3.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/never_patterns.opt3.SimplifyCfg-initial.after.mir index 93ebe600b3ff..86347db4d92e 100644 --- a/tests/mir-opt/building/match/never_patterns.opt3.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/never_patterns.opt3.SimplifyCfg-initial.after.mir @@ -12,24 +12,19 @@ fn opt3(_1: &Result) -> &u32 { bb0: { PlaceMention(_1); _2 = discriminant((*_1)); - switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; + switchInt(move _2) -> [1: bb2, otherwise: bb1]; } bb1: { - FakeRead(ForMatchedPlace(None), _1); - unreachable; - } - - bb2: { - FakeRead(ForMatchedPlace(None), (((*_1) as Err).0: Void)); - unreachable; - } - - bb3: { StorageLive(_3); _3 = &(((*_1) as Ok).0: u32); _0 = &(*_3); StorageDead(_3); return; } + + bb2: { + FakeRead(ForMatchedPlace(None), (((*_1) as Err).0: Void)); + unreachable; + } } diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.CleanupPostBorrowck.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.CleanupPostBorrowck.after.mir deleted file mode 100644 index 17756938b889..000000000000 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.CleanupPostBorrowck.after.mir +++ /dev/null @@ -1,68 +0,0 @@ -// MIR for `move_out_by_subslice` after CleanupPostBorrowck - -fn move_out_by_subslice() -> () { - let mut _0: (); - let _1: [std::boxed::Box; 2]; - let mut _2: std::boxed::Box; - let mut _3: std::boxed::Box; - scope 1 { - debug a => _1; - let _4: [std::boxed::Box; 2]; - scope 2 { - debug _y => _4; - } - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = Box::::new(const 1_i32) -> [return: bb1, unwind: bb9]; - } - - bb1: { - StorageLive(_3); - _3 = Box::::new(const 2_i32) -> [return: bb2, unwind: bb8]; - } - - bb2: { - _1 = [move _2, move _3]; - drop(_3) -> [return: bb3, unwind: bb8]; - } - - bb3: { - StorageDead(_3); - drop(_2) -> [return: bb4, unwind: bb9]; - } - - bb4: { - StorageDead(_2); - nop; - PlaceMention(_1); - StorageLive(_4); - _4 = move _1[0..2]; - _0 = const (); - drop(_4) -> [return: bb5, unwind: bb7]; - } - - bb5: { - StorageDead(_4); - drop(_1) -> [return: bb6, unwind: bb9]; - } - - bb6: { - StorageDead(_1); - return; - } - - bb7 (cleanup): { - drop(_1) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb8 (cleanup): { - drop(_2) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb9 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir new file mode 100644 index 000000000000..839bdeca86a8 --- /dev/null +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -0,0 +1,99 @@ +// MIR for `move_out_by_subslice` after built + +fn move_out_by_subslice() -> () { + let mut _0: (); + let _1: [std::boxed::Box; 2]; + let mut _2: std::boxed::Box; + let mut _3: *mut u8; + let mut _4: std::boxed::Box; + let mut _5: std::boxed::Box; + let mut _6: *mut u8; + let mut _7: std::boxed::Box; + scope 1 { + debug a => _1; + let _8: [std::boxed::Box; 2]; + scope 2 { + debug _y => _8; + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _3 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind: bb13]; + } + + bb1: { + StorageLive(_4); + _4 = ShallowInitBox(move _3, i32); + (*_4) = const 1_i32; + _2 = move _4; + drop(_4) -> [return: bb2, unwind: bb12]; + } + + bb2: { + StorageDead(_4); + StorageLive(_5); + _6 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb3, unwind: bb12]; + } + + bb3: { + StorageLive(_7); + _7 = ShallowInitBox(move _6, i32); + (*_7) = const 2_i32; + _5 = move _7; + drop(_7) -> [return: bb4, unwind: bb11]; + } + + bb4: { + StorageDead(_7); + _1 = [move _2, move _5]; + drop(_5) -> [return: bb5, unwind: bb12]; + } + + bb5: { + StorageDead(_5); + drop(_2) -> [return: bb6, unwind: bb13]; + } + + bb6: { + StorageDead(_2); + FakeRead(ForLet(None), _1); + PlaceMention(_1); + StorageLive(_8); + _8 = move _1[0..2]; + _0 = const (); + drop(_8) -> [return: bb8, unwind: bb10]; + } + + bb7: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb8: { + StorageDead(_8); + drop(_1) -> [return: bb9, unwind: bb13]; + } + + bb9: { + StorageDead(_1); + return; + } + + bb10 (cleanup): { + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb11 (cleanup): { + drop(_5) -> [return: bb12, unwind terminate(cleanup)]; + } + + bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.CleanupPostBorrowck.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.CleanupPostBorrowck.after.mir deleted file mode 100644 index 79e0f0af0dbc..000000000000 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.CleanupPostBorrowck.after.mir +++ /dev/null @@ -1,68 +0,0 @@ -// MIR for `move_out_from_end` after CleanupPostBorrowck - -fn move_out_from_end() -> () { - let mut _0: (); - let _1: [std::boxed::Box; 2]; - let mut _2: std::boxed::Box; - let mut _3: std::boxed::Box; - scope 1 { - debug a => _1; - let _4: std::boxed::Box; - scope 2 { - debug _y => _4; - } - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = Box::::new(const 1_i32) -> [return: bb1, unwind: bb9]; - } - - bb1: { - StorageLive(_3); - _3 = Box::::new(const 2_i32) -> [return: bb2, unwind: bb8]; - } - - bb2: { - _1 = [move _2, move _3]; - drop(_3) -> [return: bb3, unwind: bb8]; - } - - bb3: { - StorageDead(_3); - drop(_2) -> [return: bb4, unwind: bb9]; - } - - bb4: { - StorageDead(_2); - nop; - PlaceMention(_1); - StorageLive(_4); - _4 = move _1[1 of 2]; - _0 = const (); - drop(_4) -> [return: bb5, unwind: bb7]; - } - - bb5: { - StorageDead(_4); - drop(_1) -> [return: bb6, unwind: bb9]; - } - - bb6: { - StorageDead(_1); - return; - } - - bb7 (cleanup): { - drop(_1) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb8 (cleanup): { - drop(_2) -> [return: bb9, unwind terminate(cleanup)]; - } - - bb9 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir new file mode 100644 index 000000000000..7fda69c7500a --- /dev/null +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -0,0 +1,99 @@ +// MIR for `move_out_from_end` after built + +fn move_out_from_end() -> () { + let mut _0: (); + let _1: [std::boxed::Box; 2]; + let mut _2: std::boxed::Box; + let mut _3: *mut u8; + let mut _4: std::boxed::Box; + let mut _5: std::boxed::Box; + let mut _6: *mut u8; + let mut _7: std::boxed::Box; + scope 1 { + debug a => _1; + let _8: std::boxed::Box; + scope 2 { + debug _y => _8; + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _3 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind: bb13]; + } + + bb1: { + StorageLive(_4); + _4 = ShallowInitBox(move _3, i32); + (*_4) = const 1_i32; + _2 = move _4; + drop(_4) -> [return: bb2, unwind: bb12]; + } + + bb2: { + StorageDead(_4); + StorageLive(_5); + _6 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb3, unwind: bb12]; + } + + bb3: { + StorageLive(_7); + _7 = ShallowInitBox(move _6, i32); + (*_7) = const 2_i32; + _5 = move _7; + drop(_7) -> [return: bb4, unwind: bb11]; + } + + bb4: { + StorageDead(_7); + _1 = [move _2, move _5]; + drop(_5) -> [return: bb5, unwind: bb12]; + } + + bb5: { + StorageDead(_5); + drop(_2) -> [return: bb6, unwind: bb13]; + } + + bb6: { + StorageDead(_2); + FakeRead(ForLet(None), _1); + PlaceMention(_1); + StorageLive(_8); + _8 = move _1[1 of 2]; + _0 = const (); + drop(_8) -> [return: bb8, unwind: bb10]; + } + + bb7: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb8: { + StorageDead(_8); + drop(_1) -> [return: bb9, unwind: bb13]; + } + + bb9: { + StorageDead(_1); + return; + } + + bb10 (cleanup): { + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb11 (cleanup): { + drop(_5) -> [return: bb12, unwind terminate(cleanup)]; + } + + bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/building/uniform_array_move_out.rs b/tests/mir-opt/building/uniform_array_move_out.rs index 573e64f26dcb..36245273fe1c 100644 --- a/tests/mir-opt/building/uniform_array_move_out.rs +++ b/tests/mir-opt/building/uniform_array_move_out.rs @@ -1,17 +1,16 @@ //@ compile-flags: -Zmir-opt-level=0 // skip-filecheck +#![feature(liballoc_internals, rustc_attrs)] -// Can't emit `built.after` here as that contains user type annotations which contain DefId that -// change all the time. -// EMIT_MIR uniform_array_move_out.move_out_from_end.CleanupPostBorrowck.after.mir +// EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir fn move_out_from_end() { - let a = [Box::new(1), Box::new(2)]; + let a = [std::boxed::box_new(1), std::boxed::box_new(2)]; let [.., _y] = a; } -// EMIT_MIR uniform_array_move_out.move_out_by_subslice.CleanupPostBorrowck.after.mir +// EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir fn move_out_by_subslice() { - let a = [Box::new(1), Box::new(2)]; + let a = [std::boxed::box_new(1), std::boxed::box_new(2)]; let [_y @ ..] = a; } diff --git a/tests/mir-opt/building/write_box_via_move.box_new.CleanupPostBorrowck.after.mir b/tests/mir-opt/building/write_box_via_move.box_new.CleanupPostBorrowck.after.mir deleted file mode 100644 index 0050151e89b1..000000000000 --- a/tests/mir-opt/building/write_box_via_move.box_new.CleanupPostBorrowck.after.mir +++ /dev/null @@ -1,58 +0,0 @@ -// MIR for `box_new` after CleanupPostBorrowck - -fn box_new(_1: T) -> Box<[T; 1024]> { - debug x => _1; - let mut _0: std::boxed::Box<[T; 1024]>; - let mut _2: std::boxed::Box>; - let mut _3: std::boxed::Box>; - let mut _4: std::boxed::Box>; - let mut _5: T; - scope 1 { - debug b => _2; - } - - bb0: { - StorageLive(_2); - _2 = Box::<[T; 1024]>::new_uninit() -> [return: bb1, unwind: bb7]; - } - - bb1: { - nop; - StorageLive(_3); - StorageLive(_4); - _4 = move _2; - StorageLive(_5); - _5 = copy _1; - ((((*_4).1: std::mem::ManuallyDrop<[T; 1024]>).0: std::mem::MaybeDangling<[T; 1024]>).0: [T; 1024]) = [move _5; 1024]; - StorageDead(_5); - _3 = move _4; - drop(_4) -> [return: bb2, unwind: bb5]; - } - - bb2: { - StorageDead(_4); - _0 = Box::>::assume_init(move _3) -> [return: bb3, unwind: bb5]; - } - - bb3: { - StorageDead(_3); - drop(_2) -> [return: bb4, unwind: bb7]; - } - - bb4: { - StorageDead(_2); - return; - } - - bb5 (cleanup): { - drop(_3) -> [return: bb6, unwind terminate(cleanup)]; - } - - bb6 (cleanup): { - drop(_2) -> [return: bb7, unwind terminate(cleanup)]; - } - - bb7 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/building/write_box_via_move.rs b/tests/mir-opt/building/write_box_via_move.rs deleted file mode 100644 index 011bcf21522c..000000000000 --- a/tests/mir-opt/building/write_box_via_move.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Ensure we don't generate unnecessary copys for `write_via_move`. -//@ compile-flags: -Zmir-opt-level=0 -#![feature(liballoc_internals)] - -extern crate alloc; - -// Can't emit `built.after` here as that contains user type annotations which contain DefId that -// change all the time. -// EMIT_MIR write_box_via_move.box_new.CleanupPostBorrowck.after.mir -// CHECK-LABEL: fn box_new -#[inline(never)] -fn box_new(x: T) -> Box<[T; 1024]> { - let mut b = Box::new_uninit(); - // Ensure the array gets constructed directly into the deref'd pointer. - // CHECK: (*[[TEMP1:_.+]]) = [{{(move|copy) _.+}}; 1024]; - unsafe { alloc::intrinsics::write_box_via_move(b, [x; 1024]).assume_init() } -} - -// EMIT_MIR write_box_via_move.vec_macro.CleanupPostBorrowck.after.mir -// CHECK-LABEL: fn vec_macro -fn vec_macro() -> Vec { - // CHECK: (*[[TEMP1:_.+]]) = [const 0_i32, const 1_i32, - vec![0, 1, 2, 3, 4, 5, 6, 7] -} - -fn main() { - box_new(0); - vec_macro(); -} diff --git a/tests/mir-opt/building/write_box_via_move.vec_macro.CleanupPostBorrowck.after.mir b/tests/mir-opt/building/write_box_via_move.vec_macro.CleanupPostBorrowck.after.mir deleted file mode 100644 index 2410e4d31b48..000000000000 --- a/tests/mir-opt/building/write_box_via_move.vec_macro.CleanupPostBorrowck.after.mir +++ /dev/null @@ -1,37 +0,0 @@ -// MIR for `vec_macro` after CleanupPostBorrowck - -fn vec_macro() -> Vec { - let mut _0: std::vec::Vec; - let mut _1: std::boxed::Box>; - let mut _2: std::boxed::Box>; - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = Box::<[i32; 8]>::new_uninit() -> [return: bb1, unwind: bb5]; - } - - bb1: { - ((((*_2).1: std::mem::ManuallyDrop<[i32; 8]>).0: std::mem::MaybeDangling<[i32; 8]>).0: [i32; 8]) = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32, const 6_i32, const 7_i32]; - _1 = move _2; - drop(_2) -> [return: bb2, unwind: bb4]; - } - - bb2: { - StorageDead(_2); - _0 = std::boxed::box_assume_init_into_vec_unsafe::(move _1) -> [return: bb3, unwind: bb4]; - } - - bb3: { - StorageDead(_1); - return; - } - - bb4 (cleanup): { - drop(_1) -> [return: bb5, unwind terminate(cleanup)]; - } - - bb5 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir b/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir deleted file mode 100644 index 6a6e984023b7..000000000000 --- a/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir +++ /dev/null @@ -1,76 +0,0 @@ -// MIR for `box_new` after CleanupPostBorrowck - -fn box_new(_1: T) -> Box<[T; 1024]> { - debug x => _1; - let mut _0: std::boxed::Box<[T; 1024]>; - let mut _2: std::boxed::Box>; - let mut _4: &mut std::mem::MaybeUninit<[T; 1024]>; - let mut _5: &mut std::mem::MaybeUninit<[T; 1024]>; - let _6: (); - let mut _7: *mut [T; 1024]; - let mut _8: T; - let mut _9: std::boxed::Box>; - scope 1 { - debug b => _2; - let _3: *mut [T; 1024]; - scope 2 { - debug ptr => _3; - } - } - - bb0: { - StorageLive(_2); - _2 = Box::<[T; 1024]>::new_uninit() -> [return: bb1, unwind: bb7]; - } - - bb1: { - nop; - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _5 = &mut (*_2); - _4 = &mut (*_5); - _3 = MaybeUninit::<[T; 1024]>::as_mut_ptr(move _4) -> [return: bb2, unwind: bb6]; - } - - bb2: { - StorageDead(_4); - nop; - StorageDead(_5); - StorageLive(_6); - StorageLive(_7); - _7 = copy _3; - StorageLive(_8); - _8 = copy _1; - (*_7) = [move _8; 1024]; - StorageDead(_8); - StorageDead(_7); - StorageDead(_6); - StorageLive(_9); - _9 = move _2; - _0 = Box::>::assume_init(move _9) -> [return: bb3, unwind: bb5]; - } - - bb3: { - StorageDead(_9); - StorageDead(_3); - drop(_2) -> [return: bb4, unwind: bb7]; - } - - bb4: { - StorageDead(_2); - return; - } - - bb5 (cleanup): { - drop(_9) -> [return: bb6, unwind terminate(cleanup)]; - } - - bb6 (cleanup): { - drop(_2) -> [return: bb7, unwind terminate(cleanup)]; - } - - bb7 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/building/write_via_move.rs b/tests/mir-opt/building/write_via_move.rs deleted file mode 100644 index 12be592a855c..000000000000 --- a/tests/mir-opt/building/write_via_move.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Ensure we don't generate unnecessary copys for `write_via_move`. -//@ compile-flags: -Zmir-opt-level=0 -#![feature(core_intrinsics)] - -use std::mem; - -// Can't emit `built.after` here as that contains user type annotations which contain DefId that -// change all the time. -// EMIT_MIR write_via_move.box_new.CleanupPostBorrowck.after.mir -// CHECK-LABEL: fn box_new -#[inline(never)] -fn box_new(x: T) -> Box<[T; 1024]> { - let mut b = Box::new_uninit(); - let ptr = mem::MaybeUninit::as_mut_ptr(&mut *b); - // Ensure the array gets constructed directly into the deref'd pointer. - // CHECK: (*[[TEMP1:_.+]]) = [{{(move|copy) _.+}}; 1024]; - unsafe { std::intrinsics::write_via_move(ptr, [x; 1024]) }; - unsafe { b.assume_init() } -} - -fn main() { - box_new(0); -} diff --git a/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff new file mode 100644 index 000000000000..95eaf18b4703 --- /dev/null +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff @@ -0,0 +1,59 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: i32; + let mut _3: std::boxed::Box; + let mut _4: *mut u8; + let mut _5: std::boxed::Box; + let mut _6: *const i32; + let mut _7: std::ptr::NonNull; + let mut _8: std::ptr::Unique; + let mut _9: *const i32; + let mut _10: *const i32; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageLive(_5); +- _6 = move _4 as *const i32 (Transmute); +- _7 = NonNull:: { pointer: move _6 }; +- _8 = Unique:: { pointer: move _7, _marker: const PhantomData:: }; ++ _6 = copy _4 as *const i32 (PtrToPtr); ++ _7 = NonNull:: { pointer: copy _6 }; ++ _8 = Unique:: { pointer: copy _7, _marker: const PhantomData:: }; + _5 = Box::(move _8, const std::alloc::Global); +- _9 = copy ((_5.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); +- (*_9) = const 42_i32; ++ _9 = copy _6; ++ (*_6) = const 42_i32; + _3 = move _5; + StorageDead(_5); + _10 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); + _2 = copy (*_10); +- _1 = Add(move _2, const 0_i32); +- StorageDead(_2); ++ _1 = copy _2; ++ nop; + drop(_3) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff new file mode 100644 index 000000000000..6d8d3a0dcfe2 --- /dev/null +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff @@ -0,0 +1,63 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: i32; + let mut _3: std::boxed::Box; + let mut _4: *mut u8; + let mut _5: std::boxed::Box; + let mut _6: *const i32; + let mut _7: std::ptr::NonNull; + let mut _8: std::ptr::Unique; + let mut _9: *const i32; + let mut _10: *const i32; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_5); +- _6 = move _4 as *const i32 (Transmute); +- _7 = NonNull:: { pointer: move _6 }; +- _8 = Unique:: { pointer: move _7, _marker: const PhantomData:: }; ++ _6 = copy _4 as *const i32 (PtrToPtr); ++ _7 = NonNull:: { pointer: copy _6 }; ++ _8 = Unique:: { pointer: copy _7, _marker: const PhantomData:: }; + _5 = Box::(move _8, const std::alloc::Global); +- _9 = copy ((_5.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); +- (*_9) = const 42_i32; ++ _9 = copy _6; ++ (*_6) = const 42_i32; + _3 = move _5; + StorageDead(_5); + _10 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); + _2 = copy (*_10); +- _1 = Add(move _2, const 0_i32); +- StorageDead(_2); ++ _1 = copy _2; ++ nop; + drop(_3) -> [return: bb2, unwind: bb3]; + } + + bb2: { + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + + bb3 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs new file mode 100644 index 000000000000..a192d6b4133a --- /dev/null +++ b/tests/mir-opt/const_prop/boxes.rs @@ -0,0 +1,17 @@ +//@ test-mir-pass: GVN +//@ compile-flags: -O +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + +#![feature(rustc_attrs, liballoc_internals)] + +// Note: this test verifies that we, in fact, do not const prop `#[rustc_box]` + +// EMIT_MIR boxes.main.GVN.diff +fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: (*{{_.*}}) = const 42_i32; + // CHECK: [[tmp:_.*]] = copy (*{{_.*}}); + // CHECK: [[x]] = copy [[tmp]]; + let x = *(std::boxed::box_new(42)) + 0; +} diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff index 2ecf41638125..5df2232053fe 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff @@ -10,7 +10,7 @@ } bb1: { - _1 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + _1 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb2: { diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff index 06287b670dd4..788a4424943e 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff @@ -10,7 +10,7 @@ } bb1: { - _1 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind continue; + _1 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } bb2: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff index bd24af602c88..b698d8f37357 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff @@ -13,7 +13,7 @@ StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); - _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); ++ _1 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); + _2 = const std::ptr::NonNull:: {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute); unreachable; } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff index bd24af602c88..b698d8f37357 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff @@ -13,7 +13,7 @@ StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); - _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); ++ _1 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); + _2 = const std::ptr::NonNull:: {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute); unreachable; } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 5a3342a45cd3..2c89670dcf7d 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +45,19 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; + _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); + _7 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 2d1b05e6e987..8fecfe224cc6 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +45,19 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; + _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); + _7 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 695a06e29d3d..976ea252c2f8 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +45,19 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; + _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); + _7 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 17714feb1432..6c59f5e3e2e8 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +45,19 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; + _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); + _7 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 308f19ea759d..1f9cf6d6aca8 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +45,26 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); ++ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); +- _7 = copy _6 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; ++ _7 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); -- _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 819ad6054df8..a8760285fac1 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +45,26 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); ++ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); +- _7 = copy _6 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; ++ _7 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); -- _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 7029e02a857a..c398ae70a1a3 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +45,26 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); ++ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); +- _7 = copy _6 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; ++ _7 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); -- _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 23a134f3666b..02934c02587d 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -13,14 +13,15 @@ let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { } - scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) { + scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { + let mut _6: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let _7: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +45,26 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); ++ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_7); +- _7 = copy _6 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; ++ _7 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_7); StorageDead(_6); -- _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff index 3bc5f8507590..fa6c2e29e072 100644 --- a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff @@ -12,7 +12,7 @@ bb0: { StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); ++ _1 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); unreachable; } diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff index 3bc5f8507590..fa6c2e29e072 100644 --- a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff @@ -12,7 +12,7 @@ bb0: { StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); ++ _1 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); unreachable; } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index 7d722f7f5fdf..bcf0ad7c165f 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -11,9 +11,9 @@ let mut _9: *const [()]; let mut _10: std::boxed::Box<()>; let mut _11: *const (); - let mut _14: usize; - let mut _15: usize; - let mut _24: usize; + let mut _16: usize; + let mut _17: usize; + let mut _26: usize; scope 1 { debug vp_ctx => _1; let _5: *const (); @@ -26,56 +26,57 @@ scope 4 { debug _x => _8; } - scope 20 (inlined foo) { - let mut _25: *const [()]; + scope 19 (inlined foo) { + let mut _27: *const [()]; } } - scope 18 (inlined slice_from_raw_parts::<()>) { - scope 19 (inlined std::ptr::from_raw_parts::<[()], ()>) { + scope 17 (inlined slice_from_raw_parts::<()>) { + scope 18 (inlined std::ptr::from_raw_parts::<[()], ()>) { } } } } scope 5 (inlined Box::<()>::new) { - let mut _12: *mut (); - let mut _13: *mut u8; - scope 6 { - } - scope 7 (inlined boxed::box_new_uninit) { - let _16: std::alloc::Layout; - let mut _17: std::result::Result, std::alloc::AllocError>; - let mut _18: isize; - let mut _20: !; - scope 8 { - let _19: std::ptr::NonNull<[u8]>; - scope 9 { - scope 13 (inlined NonNull::<[u8]>::as_mut_ptr) { - scope 14 (inlined NonNull::<[u8]>::as_non_null_ptr) { - scope 15 (inlined NonNull::<[u8]>::cast::) { - let mut _23: *mut [u8]; - scope 16 (inlined NonNull::<[u8]>::as_ptr) { + let mut _12: *mut u8; + let mut _13: *const (); + let mut _14: std::ptr::NonNull<()>; + let mut _15: std::ptr::Unique<()>; + scope 6 (inlined alloc::alloc::exchange_malloc) { + let _18: std::alloc::Layout; + let mut _19: std::result::Result, std::alloc::AllocError>; + let mut _20: isize; + let mut _22: !; + scope 7 { + let _21: std::ptr::NonNull<[u8]>; + scope 8 { + scope 12 (inlined NonNull::<[u8]>::as_mut_ptr) { + scope 13 (inlined NonNull::<[u8]>::as_non_null_ptr) { + scope 14 (inlined NonNull::<[u8]>::cast::) { + let mut _25: *mut [u8]; + scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } } - scope 17 (inlined NonNull::::as_ptr) { + scope 16 (inlined NonNull::::as_ptr) { } } } - scope 11 (inlined ::allocate) { - scope 12 (inlined std::alloc::Global::alloc_impl) { + scope 10 (inlined ::allocate) { + scope 11 (inlined std::alloc::Global::alloc_impl) { } } } - scope 10 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let _21: (); - let mut _22: std::ptr::Alignment; + scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { + let _23: (); + let mut _24: std::ptr::Alignment; } } } bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); - _4 = (); @@ -83,16 +84,18 @@ StorageLive(_12); StorageLive(_13); StorageLive(_14); -- _14 = const <() as std::mem::SizedTypeProperties>::SIZE; -+ _14 = const 0_usize; StorageLive(_15); -- _15 = const <() as std::mem::SizedTypeProperties>::ALIGN; -+ _15 = const 1_usize; StorageLive(_16); +- _16 = const <() as std::mem::SizedTypeProperties>::SIZE; ++ _16 = const 0_usize; + StorageLive(_17); +- _17 = const <() as std::mem::SizedTypeProperties>::ALIGN; ++ _17 = const 1_usize; StorageLive(_18); - StorageLive(_19); StorageLive(_20); StorageLive(_21); + StorageLive(_22); + StorageLive(_23); switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } @@ -107,61 +110,67 @@ } bb3: { -- _20 = handle_alloc_error(move _16) -> unwind unreachable; -+ _20 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> unwind unreachable; +- _22 = handle_alloc_error(move _18) -> unwind unreachable; ++ _22 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; } bb4: { - _19 = copy ((_17 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_23); + _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); +- StorageLive(_25); + nop; - _23 = copy _19 as *mut [u8] (Transmute); - _13 = copy _23 as *mut u8 (PtrToPtr); -- StorageDead(_23); + _25 = copy _21 as *mut [u8] (Transmute); + _12 = copy _25 as *mut u8 (PtrToPtr); +- StorageDead(_25); + nop; - StorageDead(_17); + StorageDead(_19); + StorageDead(_23); + StorageDead(_22); StorageDead(_21); StorageDead(_20); - StorageDead(_19); StorageDead(_18); + StorageDead(_17); StorageDead(_16); +- _13 = copy _12 as *const () (PtrToPtr); ++ _13 = copy _25 as *const () (PtrToPtr); + _14 = NonNull::<()> { pointer: copy _13 }; + _15 = Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; + _3 = Box::<()>(move _15, const std::alloc::Global); +- (*_13) = move _4; ++ (*_13) = const (); StorageDead(_15); StorageDead(_14); -- _12 = copy _13 as *mut () (PtrToPtr); -- (*_12) = move _4; -+ _12 = copy _23 as *mut () (PtrToPtr); -+ (*_12) = const (); - _3 = copy _13 as std::boxed::Box<()> (Transmute); StorageDead(_13); StorageDead(_12); StorageDead(_4); _2 = &_3; _1 = &(*_2); - StorageDead(_2); +- StorageDead(_2); - StorageLive(_5); +- _10 = copy (*_1); + nop; - _10 = copy (*_1); ++ nop; ++ _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_24); - _24 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _24); + StorageLive(_26); + _26 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _26); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_24); + StorageDead(_26); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_25); -- _25 = copy _9; + StorageLive(_27); +- _27 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _25 = copy _6; ++ _27 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_25); + StorageDead(_27); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -173,25 +182,25 @@ } bb5: { -- _21 = Layout::from_size_align_unchecked::precondition_check(copy _14, copy _15) -> [return: bb6, unwind unreachable]; -+ _21 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _23 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; ++ _23 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageLive(_22); -- _22 = copy _15 as std::ptr::Alignment (Transmute); -- _16 = Layout { size: copy _14, align: move _22 }; -+ _22 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; -+ _16 = const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}; - StorageDead(_22); - StorageLive(_17); -- _17 = std::alloc::Global::alloc_impl_runtime(copy _16, const false) -> [return: bb7, unwind unreachable]; -+ _17 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}, const false) -> [return: bb7, unwind unreachable]; + StorageLive(_24); +- _24 = copy _17 as std::ptr::Alignment (Transmute); +- _18 = Layout { size: copy _16, align: move _24 }; ++ _24 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); ++ _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; + StorageDead(_24); + StorageLive(_19); +- _19 = std::alloc::Global::alloc_impl_runtime(copy _18, const false) -> [return: bb7, unwind unreachable]; ++ _19 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { - _18 = discriminant(_17); - switchInt(move _18) -> [0: bb4, 1: bb3, otherwise: bb2]; + _20 = discriminant(_19); + switchInt(move _20) -> [0: bb4, 1: bb3, otherwise: bb2]; } + } + diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff index 9a354fc005ed..82a14a8b6ec9 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff @@ -37,7 +37,8 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); - _4 = (); @@ -50,10 +51,12 @@ StorageDead(_4); _2 = &_3; _1 = &(*_2); - StorageDead(_2); +- StorageDead(_2); - StorageLive(_5); +- _10 = copy (*_1); + nop; - _10 = copy (*_1); ++ nop; ++ _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index d5134f734782..1b75a2bcba8b 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -11,9 +11,9 @@ let mut _9: *const [()]; let mut _10: std::boxed::Box<()>; let mut _11: *const (); - let mut _14: usize; - let mut _15: usize; - let mut _24: usize; + let mut _16: usize; + let mut _17: usize; + let mut _26: usize; scope 1 { debug vp_ctx => _1; let _5: *const (); @@ -26,56 +26,57 @@ scope 4 { debug _x => _8; } - scope 20 (inlined foo) { - let mut _25: *const [()]; + scope 19 (inlined foo) { + let mut _27: *const [()]; } } - scope 18 (inlined slice_from_raw_parts::<()>) { - scope 19 (inlined std::ptr::from_raw_parts::<[()], ()>) { + scope 17 (inlined slice_from_raw_parts::<()>) { + scope 18 (inlined std::ptr::from_raw_parts::<[()], ()>) { } } } } scope 5 (inlined Box::<()>::new) { - let mut _12: *mut (); - let mut _13: *mut u8; - scope 6 { - } - scope 7 (inlined boxed::box_new_uninit) { - let _16: std::alloc::Layout; - let mut _17: std::result::Result, std::alloc::AllocError>; - let mut _18: isize; - let mut _20: !; - scope 8 { - let _19: std::ptr::NonNull<[u8]>; - scope 9 { - scope 13 (inlined NonNull::<[u8]>::as_mut_ptr) { - scope 14 (inlined NonNull::<[u8]>::as_non_null_ptr) { - scope 15 (inlined NonNull::<[u8]>::cast::) { - let mut _23: *mut [u8]; - scope 16 (inlined NonNull::<[u8]>::as_ptr) { + let mut _12: *mut u8; + let mut _13: *const (); + let mut _14: std::ptr::NonNull<()>; + let mut _15: std::ptr::Unique<()>; + scope 6 (inlined alloc::alloc::exchange_malloc) { + let _18: std::alloc::Layout; + let mut _19: std::result::Result, std::alloc::AllocError>; + let mut _20: isize; + let mut _22: !; + scope 7 { + let _21: std::ptr::NonNull<[u8]>; + scope 8 { + scope 12 (inlined NonNull::<[u8]>::as_mut_ptr) { + scope 13 (inlined NonNull::<[u8]>::as_non_null_ptr) { + scope 14 (inlined NonNull::<[u8]>::cast::) { + let mut _25: *mut [u8]; + scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } } - scope 17 (inlined NonNull::::as_ptr) { + scope 16 (inlined NonNull::::as_ptr) { } } } - scope 11 (inlined ::allocate) { - scope 12 (inlined std::alloc::Global::alloc_impl) { + scope 10 (inlined ::allocate) { + scope 11 (inlined std::alloc::Global::alloc_impl) { } } } - scope 10 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let _21: (); - let mut _22: std::ptr::Alignment; + scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { + let _23: (); + let mut _24: std::ptr::Alignment; } } } bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); - _4 = (); @@ -83,16 +84,18 @@ StorageLive(_12); StorageLive(_13); StorageLive(_14); -- _14 = const <() as std::mem::SizedTypeProperties>::SIZE; -+ _14 = const 0_usize; StorageLive(_15); -- _15 = const <() as std::mem::SizedTypeProperties>::ALIGN; -+ _15 = const 1_usize; StorageLive(_16); +- _16 = const <() as std::mem::SizedTypeProperties>::SIZE; ++ _16 = const 0_usize; + StorageLive(_17); +- _17 = const <() as std::mem::SizedTypeProperties>::ALIGN; ++ _17 = const 1_usize; StorageLive(_18); - StorageLive(_19); StorageLive(_20); StorageLive(_21); + StorageLive(_22); + StorageLive(_23); switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } @@ -107,61 +110,67 @@ } bb3: { -- _20 = handle_alloc_error(move _16) -> unwind unreachable; -+ _20 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> unwind unreachable; +- _22 = handle_alloc_error(move _18) -> unwind unreachable; ++ _22 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; } bb4: { - _19 = copy ((_17 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_23); + _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); +- StorageLive(_25); + nop; - _23 = copy _19 as *mut [u8] (Transmute); - _13 = copy _23 as *mut u8 (PtrToPtr); -- StorageDead(_23); + _25 = copy _21 as *mut [u8] (Transmute); + _12 = copy _25 as *mut u8 (PtrToPtr); +- StorageDead(_25); + nop; - StorageDead(_17); + StorageDead(_19); + StorageDead(_23); + StorageDead(_22); StorageDead(_21); StorageDead(_20); - StorageDead(_19); StorageDead(_18); + StorageDead(_17); StorageDead(_16); +- _13 = copy _12 as *const () (PtrToPtr); ++ _13 = copy _25 as *const () (PtrToPtr); + _14 = NonNull::<()> { pointer: copy _13 }; + _15 = Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; + _3 = Box::<()>(move _15, const std::alloc::Global); +- (*_13) = move _4; ++ (*_13) = const (); StorageDead(_15); StorageDead(_14); -- _12 = copy _13 as *mut () (PtrToPtr); -- (*_12) = move _4; -+ _12 = copy _23 as *mut () (PtrToPtr); -+ (*_12) = const (); - _3 = copy _13 as std::boxed::Box<()> (Transmute); StorageDead(_13); StorageDead(_12); StorageDead(_4); _2 = &_3; _1 = &(*_2); - StorageDead(_2); +- StorageDead(_2); - StorageLive(_5); +- _10 = copy (*_1); + nop; - _10 = copy (*_1); ++ nop; ++ _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_24); - _24 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _24); + StorageLive(_26); + _26 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _26); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_24); + StorageDead(_26); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_25); -- _25 = copy _9; + StorageLive(_27); +- _27 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _25 = copy _6; ++ _27 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_25); + StorageDead(_27); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -173,25 +182,25 @@ } bb5: { -- _21 = Layout::from_size_align_unchecked::precondition_check(copy _14, copy _15) -> [return: bb6, unwind unreachable]; -+ _21 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _23 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; ++ _23 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageLive(_22); -- _22 = copy _15 as std::ptr::Alignment (Transmute); -- _16 = Layout { size: copy _14, align: move _22 }; -+ _22 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; -+ _16 = const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}; - StorageDead(_22); - StorageLive(_17); -- _17 = std::alloc::Global::alloc_impl_runtime(copy _16, const false) -> [return: bb7, unwind unreachable]; -+ _17 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}, const false) -> [return: bb7, unwind unreachable]; + StorageLive(_24); +- _24 = copy _17 as std::ptr::Alignment (Transmute); +- _18 = Layout { size: copy _16, align: move _24 }; ++ _24 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); ++ _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; + StorageDead(_24); + StorageLive(_19); +- _19 = std::alloc::Global::alloc_impl_runtime(copy _18, const false) -> [return: bb7, unwind unreachable]; ++ _19 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { - _18 = discriminant(_17); - switchInt(move _18) -> [0: bb4, 1: bb3, otherwise: bb2]; + _20 = discriminant(_19); + switchInt(move _20) -> [0: bb4, 1: bb3, otherwise: bb2]; } + } + diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff index 9a354fc005ed..82a14a8b6ec9 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff @@ -37,7 +37,8 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); - _4 = (); @@ -50,10 +51,12 @@ StorageDead(_4); _2 = &_3; _1 = &(*_2); - StorageDead(_2); +- StorageDead(_2); - StorageLive(_5); +- _10 = copy (*_1); + nop; - _10 = copy (*_1); ++ nop; ++ _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff index 88c77832a4e1..2b77aa380a0f 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff @@ -56,8 +56,8 @@ } bb1: { -- _5 = core::num::flt2dec::Sign::MinusPlus; -+ _5 = const core::num::flt2dec::Sign::MinusPlus; +- _5 = MinusPlus; ++ _5 = const MinusPlus; goto -> bb3; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff index 8a6e7fd35ccd..ba6d2f3e155c 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff @@ -56,8 +56,8 @@ } bb1: { -- _5 = core::num::flt2dec::Sign::MinusPlus; -+ _5 = const core::num::flt2dec::Sign::MinusPlus; +- _5 = MinusPlus; ++ _5 = const MinusPlus; goto -> bb3; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff index ce10f4bb247a..bf6d9d864d57 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff @@ -56,8 +56,8 @@ } bb1: { -- _5 = core::num::flt2dec::Sign::MinusPlus; -+ _5 = const core::num::flt2dec::Sign::MinusPlus; +- _5 = MinusPlus; ++ _5 = const MinusPlus; goto -> bb3; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff index b19f2438d022..01c87fd5317a 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff @@ -56,8 +56,8 @@ } bb1: { -- _5 = core::num::flt2dec::Sign::MinusPlus; -+ _5 = const core::num::flt2dec::Sign::MinusPlus; +- _5 = MinusPlus; ++ _5 = const MinusPlus; goto -> bb3; } diff --git a/tests/mir-opt/gvn.dereference_reborrow.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereference_reborrow.GVN.panic-abort.diff deleted file mode 100644 index 1b2e6c681b92..000000000000 --- a/tests/mir-opt/gvn.dereference_reborrow.GVN.panic-abort.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `dereference_reborrow` before GVN -+ // MIR for `dereference_reborrow` after GVN - - fn dereference_reborrow(_1: &mut u8) -> () { - debug mut_a => _1; - let mut _0: (); - let _2: &u8; - scope 1 { - debug a => _2; - let _3: u8; - scope 2 { - debug b => _3; - let _4: u8; - scope 3 { - debug c => _4; - } - } - } - - bb0: { - StorageLive(_2); - _2 = &(*_1); -- StorageLive(_3); -+ nop; - _3 = copy (*_2); - StorageLive(_4); -- _4 = copy (*_2); -+ _4 = copy _3; - _0 = const (); - StorageDead(_4); -- StorageDead(_3); -+ nop; - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/gvn.dereference_reborrow.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereference_reborrow.GVN.panic-unwind.diff deleted file mode 100644 index 1b2e6c681b92..000000000000 --- a/tests/mir-opt/gvn.dereference_reborrow.GVN.panic-unwind.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `dereference_reborrow` before GVN -+ // MIR for `dereference_reborrow` after GVN - - fn dereference_reborrow(_1: &mut u8) -> () { - debug mut_a => _1; - let mut _0: (); - let _2: &u8; - scope 1 { - debug a => _2; - let _3: u8; - scope 2 { - debug b => _3; - let _4: u8; - scope 3 { - debug c => _4; - } - } - } - - bb0: { - StorageLive(_2); - _2 = &(*_1); -- StorageLive(_3); -+ nop; - _3 = copy (*_2); - StorageLive(_4); -- _4 = copy (*_2); -+ _4 = copy _3; - _0 = const (); - StorageDead(_4); -- StorageDead(_3); -+ nop; - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff index a763614dc644..ecd7bdc433cd 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff @@ -107,23 +107,18 @@ StorageLive(_18); _18 = &(*_1); StorageLive(_19); -- StorageLive(_20); -+ nop; + StorageLive(_20); _20 = copy (*_18); -- _19 = opaque::(move _20) -> [return: bb7, unwind unreachable]; -+ _19 = opaque::(copy _20) -> [return: bb7, unwind unreachable]; + _19 = opaque::(move _20) -> [return: bb7, unwind unreachable]; } bb7: { -- StorageDead(_20); -+ nop; + StorageDead(_20); StorageDead(_19); StorageLive(_21); StorageLive(_22); -- _22 = copy (*_18); -- _21 = opaque::(move _22) -> [return: bb8, unwind unreachable]; -+ _22 = copy _20; -+ _21 = opaque::(copy _20) -> [return: bb8, unwind unreachable]; + _22 = copy (*_18); + _21 = opaque::(move _22) -> [return: bb8, unwind unreachable]; } bb8: { @@ -157,23 +152,18 @@ StorageDead(_28); StorageDead(_27); StorageLive(_29); -- StorageLive(_30); -+ nop; + StorageLive(_30); _30 = copy ((*_3).0: u32); -- _29 = opaque::(move _30) -> [return: bb12, unwind unreachable]; -+ _29 = opaque::(copy _30) -> [return: bb12, unwind unreachable]; + _29 = opaque::(move _30) -> [return: bb12, unwind unreachable]; } bb12: { -- StorageDead(_30); -+ nop; + StorageDead(_30); StorageDead(_29); StorageLive(_31); StorageLive(_32); -- _32 = copy ((*_3).0: u32); -- _31 = opaque::(move _32) -> [return: bb13, unwind unreachable]; -+ _32 = copy _30; -+ _31 = opaque::(copy _30) -> [return: bb13, unwind unreachable]; + _32 = copy ((*_3).0: u32); + _31 = opaque::(move _32) -> [return: bb13, unwind unreachable]; } bb13: { diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff index ca6fda483642..bbca6bc3c754 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff @@ -107,23 +107,18 @@ StorageLive(_18); _18 = &(*_1); StorageLive(_19); -- StorageLive(_20); -+ nop; + StorageLive(_20); _20 = copy (*_18); -- _19 = opaque::(move _20) -> [return: bb7, unwind continue]; -+ _19 = opaque::(copy _20) -> [return: bb7, unwind continue]; + _19 = opaque::(move _20) -> [return: bb7, unwind continue]; } bb7: { -- StorageDead(_20); -+ nop; + StorageDead(_20); StorageDead(_19); StorageLive(_21); StorageLive(_22); -- _22 = copy (*_18); -- _21 = opaque::(move _22) -> [return: bb8, unwind continue]; -+ _22 = copy _20; -+ _21 = opaque::(copy _20) -> [return: bb8, unwind continue]; + _22 = copy (*_18); + _21 = opaque::(move _22) -> [return: bb8, unwind continue]; } bb8: { @@ -157,23 +152,18 @@ StorageDead(_28); StorageDead(_27); StorageLive(_29); -- StorageLive(_30); -+ nop; + StorageLive(_30); _30 = copy ((*_3).0: u32); -- _29 = opaque::(move _30) -> [return: bb12, unwind continue]; -+ _29 = opaque::(copy _30) -> [return: bb12, unwind continue]; + _29 = opaque::(move _30) -> [return: bb12, unwind continue]; } bb12: { -- StorageDead(_30); -+ nop; + StorageDead(_30); StorageDead(_29); StorageLive(_31); StorageLive(_32); -- _32 = copy ((*_3).0: u32); -- _31 = opaque::(move _32) -> [return: bb13, unwind continue]; -+ _32 = copy _30; -+ _31 = opaque::(copy _30) -> [return: bb13, unwind continue]; + _32 = copy ((*_3).0: u32); + _31 = opaque::(move _32) -> [return: bb13, unwind continue]; } bb13: { diff --git a/tests/mir-opt/gvn.field_borrow.GVN.panic-abort.diff b/tests/mir-opt/gvn.field_borrow.GVN.panic-abort.diff deleted file mode 100644 index 5839ff581129..000000000000 --- a/tests/mir-opt/gvn.field_borrow.GVN.panic-abort.diff +++ /dev/null @@ -1,30 +0,0 @@ -- // MIR for `field_borrow` before GVN -+ // MIR for `field_borrow` after GVN - - fn field_borrow(_1: &FieldBorrow<'_>) -> () { - debug a => _1; - let mut _0: (); - let _2: &u8; - scope 1 { - debug b => _2; - let _3: &u8; - scope 2 { - debug c => _3; - } - } - - bb0: { -- StorageLive(_2); -+ nop; - _2 = copy ((*_1).0: &u8); - StorageLive(_3); -- _3 = copy ((*_1).0: &u8); -+ _3 = copy _2; - _0 = const (); - StorageDead(_3); -- StorageDead(_2); -+ nop; - return; - } - } - diff --git a/tests/mir-opt/gvn.field_borrow.GVN.panic-unwind.diff b/tests/mir-opt/gvn.field_borrow.GVN.panic-unwind.diff deleted file mode 100644 index 5839ff581129..000000000000 --- a/tests/mir-opt/gvn.field_borrow.GVN.panic-unwind.diff +++ /dev/null @@ -1,30 +0,0 @@ -- // MIR for `field_borrow` before GVN -+ // MIR for `field_borrow` after GVN - - fn field_borrow(_1: &FieldBorrow<'_>) -> () { - debug a => _1; - let mut _0: (); - let _2: &u8; - scope 1 { - debug b => _2; - let _3: &u8; - scope 2 { - debug c => _3; - } - } - - bb0: { -- StorageLive(_2); -+ nop; - _2 = copy ((*_1).0: &u8); - StorageLive(_3); -- _3 = copy ((*_1).0: &u8); -+ _3 = copy _2; - _0 = const (); - StorageDead(_3); -- StorageDead(_2); -+ nop; - return; - } - } - diff --git a/tests/mir-opt/gvn.field_borrow_2.GVN.panic-abort.diff b/tests/mir-opt/gvn.field_borrow_2.GVN.panic-abort.diff deleted file mode 100644 index 819211c41f90..000000000000 --- a/tests/mir-opt/gvn.field_borrow_2.GVN.panic-abort.diff +++ /dev/null @@ -1,51 +0,0 @@ -- // MIR for `field_borrow_2` before GVN -+ // MIR for `field_borrow_2` after GVN - - fn field_borrow_2(_1: &&FieldBorrow<'_>) -> () { - debug a => _1; - let mut _0: (); - let _2: &FieldBorrow<'_>; - scope 1 { - debug b => _2; - let _3: &u8; - scope 2 { - debug c => _3; - let _4: &FieldBorrow<'_>; - scope 3 { - debug d => _4; - let _5: &u8; - scope 4 { - debug e => _5; - let _6: &u8; - scope 5 { - debug f => _6; - } - } - } - } - } - - bb0: { - StorageLive(_2); - _2 = copy (*_1); - StorageLive(_3); - _3 = copy ((*_2).0: &u8); - StorageLive(_4); - _4 = copy (*_1); -- StorageLive(_5); -+ nop; - _5 = copy ((*_4).0: &u8); - StorageLive(_6); -- _6 = copy ((*_4).0: &u8); -+ _6 = copy _5; - _0 = const (); - StorageDead(_6); -- StorageDead(_5); -+ nop; - StorageDead(_4); - StorageDead(_3); - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/gvn.field_borrow_2.GVN.panic-unwind.diff b/tests/mir-opt/gvn.field_borrow_2.GVN.panic-unwind.diff deleted file mode 100644 index 819211c41f90..000000000000 --- a/tests/mir-opt/gvn.field_borrow_2.GVN.panic-unwind.diff +++ /dev/null @@ -1,51 +0,0 @@ -- // MIR for `field_borrow_2` before GVN -+ // MIR for `field_borrow_2` after GVN - - fn field_borrow_2(_1: &&FieldBorrow<'_>) -> () { - debug a => _1; - let mut _0: (); - let _2: &FieldBorrow<'_>; - scope 1 { - debug b => _2; - let _3: &u8; - scope 2 { - debug c => _3; - let _4: &FieldBorrow<'_>; - scope 3 { - debug d => _4; - let _5: &u8; - scope 4 { - debug e => _5; - let _6: &u8; - scope 5 { - debug f => _6; - } - } - } - } - } - - bb0: { - StorageLive(_2); - _2 = copy (*_1); - StorageLive(_3); - _3 = copy ((*_2).0: &u8); - StorageLive(_4); - _4 = copy (*_1); -- StorageLive(_5); -+ nop; - _5 = copy ((*_4).0: &u8); - StorageLive(_6); -- _6 = copy ((*_4).0: &u8); -+ _6 = copy _5; - _0 = const (); - StorageDead(_6); -- StorageDead(_5); -+ nop; - StorageDead(_4); - StorageDead(_3); - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff index 96920af4dddc..90920dd0be8f 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff @@ -8,10 +8,10 @@ let mut _3: fn(u8) -> u8; let _5: (); let mut _6: fn(u8) -> u8; - let mut _9: {closure@$DIR/gvn.rs:629:19: 629:21}; + let mut _9: {closure@$DIR/gvn.rs:617:19: 617:21}; let _10: (); let mut _11: fn(); - let mut _13: {closure@$DIR/gvn.rs:629:19: 629:21}; + let mut _13: {closure@$DIR/gvn.rs:617:19: 617:21}; let _14: (); let mut _15: fn(); scope 1 { @@ -19,7 +19,7 @@ let _4: fn(u8) -> u8; scope 2 { debug g => _4; - let _7: {closure@$DIR/gvn.rs:629:19: 629:21}; + let _7: {closure@$DIR/gvn.rs:617:19: 617:21}; scope 3 { debug closure => _7; let _8: fn(); @@ -62,16 +62,16 @@ StorageDead(_6); StorageDead(_5); - StorageLive(_7); -- _7 = {closure@$DIR/gvn.rs:629:19: 629:21}; +- _7 = {closure@$DIR/gvn.rs:617:19: 617:21}; - StorageLive(_8); + nop; -+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21}; ++ _7 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; + nop; StorageLive(_9); - _9 = copy _7; - _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21}; -+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _9 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; ++ _8 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_9); StorageLive(_10); StorageLive(_11); @@ -88,8 +88,8 @@ StorageLive(_13); - _13 = copy _7; - _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21}; -+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _13 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; ++ _12 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_13); StorageLive(_14); StorageLive(_15); diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff index d32a82322203..0aca8e508f5c 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff @@ -8,10 +8,10 @@ let mut _3: fn(u8) -> u8; let _5: (); let mut _6: fn(u8) -> u8; - let mut _9: {closure@$DIR/gvn.rs:629:19: 629:21}; + let mut _9: {closure@$DIR/gvn.rs:617:19: 617:21}; let _10: (); let mut _11: fn(); - let mut _13: {closure@$DIR/gvn.rs:629:19: 629:21}; + let mut _13: {closure@$DIR/gvn.rs:617:19: 617:21}; let _14: (); let mut _15: fn(); scope 1 { @@ -19,7 +19,7 @@ let _4: fn(u8) -> u8; scope 2 { debug g => _4; - let _7: {closure@$DIR/gvn.rs:629:19: 629:21}; + let _7: {closure@$DIR/gvn.rs:617:19: 617:21}; scope 3 { debug closure => _7; let _8: fn(); @@ -62,16 +62,16 @@ StorageDead(_6); StorageDead(_5); - StorageLive(_7); -- _7 = {closure@$DIR/gvn.rs:629:19: 629:21}; +- _7 = {closure@$DIR/gvn.rs:617:19: 617:21}; - StorageLive(_8); + nop; -+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21}; ++ _7 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; + nop; StorageLive(_9); - _9 = copy _7; - _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21}; -+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _9 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; ++ _8 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_9); StorageLive(_10); StorageLive(_11); @@ -88,8 +88,8 @@ StorageLive(_13); - _13 = copy _7; - _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21}; -+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:629:19: 629:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _13 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; ++ _12 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_13); StorageLive(_14); StorageLive(_15); diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 07309c1569cd..3c3241fefe22 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -9,7 +9,6 @@ #![feature(freeze)] #![allow(ambiguous_wide_pointer_comparisons)] #![allow(unconditional_panic)] -#![allow(unnecessary_transmutes)] #![allow(unused)] use std::intrinsics::mir::*; @@ -100,14 +99,14 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) { opaque((x * y) - y); opaque((x * y) - y); - // We can substitute through an immutable reference. + // We cannot substitute through an immutable reference. // CHECK: [[ref:_.*]] = &_3; // CHECK: [[deref:_.*]] = copy (*[[ref]]); - // CHECK: [[addref:_.*]] = Add(copy [[deref]], copy _1); - // CHECK: opaque::(copy [[addref]]) - // CHECK: [[deref2:_.*]] = copy [[deref]]; - // CHECK: [[addref2:_.*]] = copy [[addref]]; - // CHECK: opaque::(copy [[addref]]) + // CHECK: [[addref:_.*]] = Add(move [[deref]], copy _1); + // CHECK: opaque::(move [[addref]]) + // CHECK: [[deref2:_.*]] = copy (*[[ref]]); + // CHECK: [[addref2:_.*]] = Add(move [[deref2]], copy _1); + // CHECK: opaque::(move [[addref2]]) let a = &z; opaque(*a + x); opaque(*a + x); @@ -140,14 +139,15 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) { opaque(*d + x); } + // We still cannot substitute again, and never with the earlier computations. // Important: `e` is not `a`! // CHECK: [[ref2:_.*]] = &_3; // CHECK: [[deref2:_.*]] = copy (*[[ref2]]); - // CHECK: [[addref2:_.*]] = Add(copy [[deref2]], copy _1); - // CHECK: opaque::(copy [[addref2]]) - // CHECK: [[deref3:_.*]] = copy [[deref2]]; - // CHECK: [[addref3:_.*]] = copy [[addref2]]; - // CHECK: opaque::(copy [[addref2]]) + // CHECK: [[addref2:_.*]] = Add(move [[deref2]], copy _1); + // CHECK: opaque::(move [[addref2]]) + // CHECK: [[deref3:_.*]] = copy (*[[ref2]]); + // CHECK: [[addref3:_.*]] = Add(move [[deref3]], copy _1); + // CHECK: opaque::(move [[addref3]]) let e = &z; opaque(*e + x); opaque(*e + x); @@ -451,21 +451,20 @@ fn references(mut x: impl Sized) { // CHECK: opaque::<*mut impl Sized>(move [[ref8]]) opaque(&raw mut x); - // FIXME: ReferencePropagation transform this pattern. let r = &mut x; let s = S(r).0; // Obfuscate `r`. Following lines should still reborrow `r`. // CHECK: [[ref9:_.*]] = &mut _1; - // COM: CHECK: [[ref10:_.*]] = &(*[[ref9]]); - // COM: CHECK: opaque::<&impl Sized>(move [[ref10]]) + // CHECK: [[ref10:_.*]] = &(*[[ref9]]); + // CHECK: opaque::<&impl Sized>(move [[ref10]]) opaque(&*s); - // COM: CHECK: [[ref11:_.*]] = &mut (*[[ref9]]); - // COM: CHECK: opaque::<&mut impl Sized>(move [[ref11]]) + // CHECK: [[ref11:_.*]] = &mut (*[[ref9]]); + // CHECK: opaque::<&mut impl Sized>(move [[ref11]]) opaque(&mut *s); - // COM: CHECK: [[ref12:_.*]] = &raw const (*[[ref9]]); - // COM: CHECK: opaque::<*const impl Sized>(move [[ref12]]) + // CHECK: [[ref12:_.*]] = &raw const (*[[ref9]]); + // CHECK: opaque::<*const impl Sized>(move [[ref12]]) opaque(&raw const *s); - // COM: CHECK: [[ref12:_.*]] = &raw mut (*[[ref9]]); - // COM: CHECK: opaque::<*mut impl Sized>(move [[ref12]]) + // CHECK: [[ref12:_.*]] = &raw mut (*[[ref9]]); + // CHECK: opaque::<*mut impl Sized>(move [[ref12]]) opaque(&raw mut *s); } @@ -473,21 +472,17 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S) { // CHECK-LABEL: fn dereferences( // Do not reuse dereferences of `&mut`. - // CHECK: bb0: // CHECK: [[st1:_.*]] = copy (*_1); // CHECK: opaque::(move [[st1]]) - // CHECK: bb1: // CHECK: [[st2:_.*]] = copy (*_1); // CHECK: opaque::(move [[st2]]) opaque(*t); opaque(*t); // Do not reuse dereferences of `*const`. - // CHECK: bb2: // CHECK: [[raw:_.*]] = &raw const (*_1); // CHECK: [[st3:_.*]] = copy (*[[raw]]); // CHECK: opaque::(move [[st3]]) - // CHECK: bb3: // CHECK: [[st4:_.*]] = copy (*[[raw]]); // CHECK: opaque::(move [[st4]]) let z = &raw const *t; @@ -495,49 +490,42 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S) { unsafe { opaque(*z) }; // Do not reuse dereferences of `*mut`. - // CHECK: bb4: // CHECK: [[ptr:_.*]] = &raw mut (*_1); // CHECK: [[st5:_.*]] = copy (*[[ptr]]); // CHECK: opaque::(move [[st5]]) - // CHECK: bb5: // CHECK: [[st6:_.*]] = copy (*[[ptr]]); // CHECK: opaque::(move [[st6]]) let z = &raw mut *t; unsafe { opaque(*z) }; unsafe { opaque(*z) }; - // CHECK: bb6: + // Do not reuse dereferences of `&Freeze`. // CHECK: [[ref:_.*]] = &(*_1); // CHECK: [[st7:_.*]] = copy (*[[ref]]); - // CHECK: opaque::(copy [[st7]]) - // CHECK: bb7: - // CHECK: [[st8:_.*]] = copy [[st7]]; - // CHECK: opaque::(copy [[st7]]) + // CHECK: opaque::(move [[st7]]) + // CHECK: [[st8:_.*]] = copy (*[[ref]]); + // CHECK: opaque::(move [[st8]]) let z = &*t; opaque(*z); opaque(*z); // Not in reborrows either. - // CHECK: bb8: // CHECK: [[reborrow:_.*]] = &(*[[ref]]); // CHECK: opaque::<&u32>(move [[reborrow]]) opaque(&*z); // `*u` is not Freeze, so we cannot reuse. - // CHECK: bb9: // CHECK: [[st8:_.*]] = copy (*_2); // CHECK: opaque::(move [[st8]]) - // CHECK: bb10: // CHECK: [[st9:_.*]] = copy (*_2); // CHECK: opaque::(move [[st9]]) opaque(*u); opaque(*u); - // CHECK: bb11: + // `*s` is not Copy, but `(*s).0` is, but we still cannot reuse. // CHECK: [[st10:_.*]] = copy ((*_3).0: u32); - // CHECK: opaque::(copy [[st10]]) - // CHECK: bb12: - // CHECK: [[st11:_.*]] = copy [[st10]]; - // CHECK: opaque::(copy [[st10]]) + // CHECK: opaque::(move [[st10]]) + // CHECK: [[st11:_.*]] = copy ((*_3).0: u32); + // CHECK: opaque::(move [[st11]]) opaque(s.0); opaque(s.0); } @@ -997,14 +985,7 @@ unsafe fn aggregate_struct_then_transmute(id: u16, thin: *const u8) { opaque(std::intrinsics::transmute::<_, *const u8>(j)); } -#[repr(u8)] -enum ZeroOneTwo { - Zero, - One, - Two, -} - -unsafe fn transmute_then_transmute_again(a: u32, c: char, b: bool, d: u8) { +unsafe fn transmute_then_transmute_again(a: u32, c: char) { // CHECK: [[TEMP1:_[0-9]+]] = copy _1 as char (Transmute); // CHECK: [[TEMP2:_[0-9]+]] = copy [[TEMP1]] as i32 (Transmute); // CHECK: opaque::(move [[TEMP2]]) @@ -1015,16 +996,6 @@ unsafe fn transmute_then_transmute_again(a: u32, c: char, b: bool, d: u8) { // CHECK: opaque::(move [[TEMP]]) let x = std::intrinsics::transmute::(c); opaque(std::intrinsics::transmute::(x)); - - // CHECK: [[TEMP:_[0-9]+]] = copy _3 as u8 (Transmute); - // CHECK: opaque::(move [[TEMP]]) - let x = std::intrinsics::transmute::(b); - opaque(std::intrinsics::transmute::(x)); - - // CHECK: [[TEMP:_[0-9]+]] = copy _4 as bool (Transmute); - // CHECK: opaque::(move [[TEMP]]) - let x = std::intrinsics::transmute::(d); - opaque(std::intrinsics::transmute::(x)); } // Transmuting can skip a pointer cast so long as it wasn't a fat-to-thin cast. @@ -1100,53 +1071,6 @@ fn dereference_indexing(array: [u8; 2], index: usize) { opaque(*a); } -// EMIT_MIR gvn.dereference_reborrow.GVN.diff -fn dereference_reborrow(mut_a: &mut u8) { - // CHECK-LABEL: fn dereference_reborrow( - // CHECK: debug a => [[a:_.*]]; - // CHECK: debug b => [[b:_.*]]; - // CHECK: debug c => [[c:_.*]]; - // CHECK: [[a]] = &(*_1); - // CHECK: [[b]] = copy (*[[a]]); - // CHECK: [[c]] = copy [[b]]; - let a = &*mut_a; - let b = *a; - let c = *a; -} - -struct FieldBorrow<'a>(&'a u8); - -// EMIT_MIR gvn.field_borrow.GVN.diff -fn field_borrow(a: &FieldBorrow<'_>) { - // CHECK-LABEL: fn field_borrow( - // CHECK: debug b => [[b:_.*]]; - // CHECK: debug c => [[c:_.*]]; - // CHECK: [[b]] = copy ((*_1).0: &u8); - // CHECK: [[c]] = copy [[b]]; - let b = a.0; - let c = a.0; -} - -// EMIT_MIR gvn.field_borrow_2.GVN.diff -fn field_borrow_2(a: &&FieldBorrow<'_>) { - // CHECK-LABEL: fn field_borrow_2( - // CHECK: debug b => [[b:_.*]]; - // CHECK: debug c => [[c:_.*]]; - // CHECK: debug d => [[d:_.*]]; - // CHECK: debug e => [[e:_.*]]; - // CHECK: debug f => [[f:_.*]]; - // CHECK: [[b]] = copy (*_1); - // CHECK: [[c]] = copy ((*[[b]]).0: &u8); - // CHECK: [[d]] = copy (*_1); - // CHECK: [[e]] = copy ((*[[d]]).0: &u8); - // CHECK: [[f]] = copy [[e]]; - let b = *a; - let c = b.0; - let d = *a; - let e = d.0; - let f = d.0; -} - // CHECK-LABEL: fn main( fn main() { subexpression_elimination(2, 4, 5); @@ -1176,9 +1100,6 @@ fn main() { meta_of_ref_to_slice(&42); slice_from_raw_parts_as_ptr(&123, 456); dereference_indexing([129, 14], 5); - dereference_reborrow(&mut 5); - field_borrow(&FieldBorrow(&0)); - field_borrow(&&FieldBorrow(&0)); } #[inline(never)] diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index 247ddc73ec36..b7872fc9952b 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -210,9 +210,9 @@ _26 = &(*_27); StorageLive(_28); - _28 = Option::>::None; -- _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; +- _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; + _28 = const Option::>::None; -+ _22 = core::panicking::assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, const Option::>::None) -> unwind unreachable; ++ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, const Option::>::None) -> unwind unreachable; } bb7: { @@ -313,9 +313,9 @@ _52 = &(*_53); StorageLive(_54); - _54 = Option::>::None; -- _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable; +- _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable; + _54 = const Option::>::None; -+ _48 = core::panicking::assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, const Option::>::None) -> unwind unreachable; ++ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, const Option::>::None) -> unwind unreachable; } } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index f15c16f1ce0f..37817b48c199 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -210,9 +210,9 @@ _26 = &(*_27); StorageLive(_28); - _28 = Option::>::None; -- _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue; +- _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue; + _28 = const Option::>::None; -+ _22 = core::panicking::assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, const Option::>::None) -> unwind continue; ++ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, const Option::>::None) -> unwind continue; } bb7: { @@ -313,9 +313,9 @@ _52 = &(*_53); StorageLive(_54); - _54 = Option::>::None; -- _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue; +- _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue; + _54 = const Option::>::None; -+ _48 = core::panicking::assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, const Option::>::None) -> unwind continue; ++ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, const Option::>::None) -> unwind continue; } } diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff index 7a479bc55da7..e872e011542b 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff @@ -758,39 +758,32 @@ StorageLive(_126); _126 = &_3; StorageLive(_127); -- StorageLive(_128); -- StorageLive(_129); -+ nop; -+ nop; + StorageLive(_128); + StorageLive(_129); _129 = copy (*_126); StorageLive(_130); _130 = copy _1; - _128 = Add(move _129, move _130); -+ _128 = Add(copy _129, copy _1); ++ _128 = Add(move _129, copy _1); StorageDead(_130); -- StorageDead(_129); -- _127 = opaque::(move _128) -> [return: bb35, unwind unreachable]; -+ nop; -+ _127 = opaque::(copy _128) -> [return: bb35, unwind unreachable]; + StorageDead(_129); + _127 = opaque::(move _128) -> [return: bb35, unwind unreachable]; } bb35: { -- StorageDead(_128); -+ nop; + StorageDead(_128); StorageDead(_127); StorageLive(_131); StorageLive(_132); StorageLive(_133); -- _133 = copy (*_126); -+ _133 = copy _129; + _133 = copy (*_126); StorageLive(_134); _134 = copy _1; - _132 = Add(move _133, move _134); -+ _132 = copy _128; ++ _132 = Add(move _133, copy _1); StorageDead(_134); StorageDead(_133); -- _131 = opaque::(move _132) -> [return: bb36, unwind unreachable]; -+ _131 = opaque::(copy _128) -> [return: bb36, unwind unreachable]; + _131 = opaque::(move _132) -> [return: bb36, unwind unreachable]; } bb36: { @@ -906,39 +899,32 @@ StorageLive(_163); _163 = &_3; StorageLive(_164); -- StorageLive(_165); -- StorageLive(_166); -+ nop; -+ nop; + StorageLive(_165); + StorageLive(_166); _166 = copy (*_163); StorageLive(_167); _167 = copy _1; - _165 = Add(move _166, move _167); -+ _165 = Add(copy _166, copy _1); ++ _165 = Add(move _166, copy _1); StorageDead(_167); -- StorageDead(_166); -- _164 = opaque::(move _165) -> [return: bb43, unwind unreachable]; -+ nop; -+ _164 = opaque::(copy _165) -> [return: bb43, unwind unreachable]; + StorageDead(_166); + _164 = opaque::(move _165) -> [return: bb43, unwind unreachable]; } bb43: { -- StorageDead(_165); -+ nop; + StorageDead(_165); StorageDead(_164); StorageLive(_168); StorageLive(_169); StorageLive(_170); -- _170 = copy (*_163); -+ _170 = copy _166; + _170 = copy (*_163); StorageLive(_171); _171 = copy _1; - _169 = Add(move _170, move _171); -+ _169 = copy _165; ++ _169 = Add(move _170, copy _1); StorageDead(_171); StorageDead(_170); -- _168 = opaque::(move _169) -> [return: bb44, unwind unreachable]; -+ _168 = opaque::(copy _165) -> [return: bb44, unwind unreachable]; + _168 = opaque::(move _169) -> [return: bb44, unwind unreachable]; } bb44: { diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff index 3ca5238663c2..3996dab27a34 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff @@ -758,39 +758,32 @@ StorageLive(_126); _126 = &_3; StorageLive(_127); -- StorageLive(_128); -- StorageLive(_129); -+ nop; -+ nop; + StorageLive(_128); + StorageLive(_129); _129 = copy (*_126); StorageLive(_130); _130 = copy _1; - _128 = Add(move _129, move _130); -+ _128 = Add(copy _129, copy _1); ++ _128 = Add(move _129, copy _1); StorageDead(_130); -- StorageDead(_129); -- _127 = opaque::(move _128) -> [return: bb35, unwind continue]; -+ nop; -+ _127 = opaque::(copy _128) -> [return: bb35, unwind continue]; + StorageDead(_129); + _127 = opaque::(move _128) -> [return: bb35, unwind continue]; } bb35: { -- StorageDead(_128); -+ nop; + StorageDead(_128); StorageDead(_127); StorageLive(_131); StorageLive(_132); StorageLive(_133); -- _133 = copy (*_126); -+ _133 = copy _129; + _133 = copy (*_126); StorageLive(_134); _134 = copy _1; - _132 = Add(move _133, move _134); -+ _132 = copy _128; ++ _132 = Add(move _133, copy _1); StorageDead(_134); StorageDead(_133); -- _131 = opaque::(move _132) -> [return: bb36, unwind continue]; -+ _131 = opaque::(copy _128) -> [return: bb36, unwind continue]; + _131 = opaque::(move _132) -> [return: bb36, unwind continue]; } bb36: { @@ -906,39 +899,32 @@ StorageLive(_163); _163 = &_3; StorageLive(_164); -- StorageLive(_165); -- StorageLive(_166); -+ nop; -+ nop; + StorageLive(_165); + StorageLive(_166); _166 = copy (*_163); StorageLive(_167); _167 = copy _1; - _165 = Add(move _166, move _167); -+ _165 = Add(copy _166, copy _1); ++ _165 = Add(move _166, copy _1); StorageDead(_167); -- StorageDead(_166); -- _164 = opaque::(move _165) -> [return: bb43, unwind continue]; -+ nop; -+ _164 = opaque::(copy _165) -> [return: bb43, unwind continue]; + StorageDead(_166); + _164 = opaque::(move _165) -> [return: bb43, unwind continue]; } bb43: { -- StorageDead(_165); -+ nop; + StorageDead(_165); StorageDead(_164); StorageLive(_168); StorageLive(_169); StorageLive(_170); -- _170 = copy (*_163); -+ _170 = copy _166; + _170 = copy (*_163); StorageLive(_171); _171 = copy _1; - _169 = Add(move _170, move _171); -+ _169 = copy _165; ++ _169 = Add(move _170, copy _1); StorageDead(_171); StorageDead(_170); -- _168 = opaque::(move _169) -> [return: bb44, unwind continue]; -+ _168 = opaque::(copy _165) -> [return: bb44, unwind continue]; + _168 = opaque::(move _169) -> [return: bb44, unwind continue]; } bb44: { diff --git a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff index caed065536e3..962fecd2586e 100644 --- a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff @@ -1,135 +1,71 @@ - // MIR for `transmute_then_transmute_again` before GVN + // MIR for `transmute_then_transmute_again` after GVN - fn transmute_then_transmute_again(_1: u32, _2: char, _3: bool, _4: u8) -> () { + fn transmute_then_transmute_again(_1: u32, _2: char) -> () { debug a => _1; debug c => _2; - debug b => _3; - debug d => _4; let mut _0: (); - let _5: char; - let mut _6: u32; - let _7: (); - let mut _8: i32; + let _3: char; + let mut _4: u32; + let _5: (); + let mut _6: i32; + let mut _7: char; let mut _9: char; - let mut _11: char; - let _12: (); - let mut _13: i32; - let mut _14: u32; - let mut _16: bool; - let _17: (); - let mut _18: u8; - let mut _19: ZeroOneTwo; - let mut _21: u8; - let _22: (); - let mut _23: bool; - let mut _24: ZeroOneTwo; + let _10: (); + let mut _11: i32; + let mut _12: u32; scope 1 { - debug x => _5; - let _10: u32; + debug x => _3; + let _8: u32; scope 2 { - debug x => _10; - let _15: ZeroOneTwo; - scope 3 { - debug x => _15; - let _20: ZeroOneTwo; - scope 4 { - debug x => _20; - } - } + debug x => _8; } } bb0: { -- StorageLive(_5); +- StorageLive(_3); + nop; + StorageLive(_4); + _4 = copy _1; +- _3 = move _4 as char (Transmute); ++ _3 = copy _1 as char (Transmute); + StorageDead(_4); + StorageLive(_5); StorageLive(_6); - _6 = copy _1; -- _5 = move _6 as char (Transmute); -+ _5 = copy _1 as char (Transmute); - StorageDead(_6); StorageLive(_7); - StorageLive(_8); - StorageLive(_9); - _9 = copy _5; -- _8 = move _9 as i32 (Transmute); -+ _8 = copy _5 as i32 (Transmute); - StorageDead(_9); - _7 = opaque::(move _8) -> [return: bb1, unwind unreachable]; + _7 = copy _3; +- _6 = move _7 as i32 (Transmute); ++ _6 = copy _3 as i32 (Transmute); + StorageDead(_7); + _5 = opaque::(move _6) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_8); - StorageDead(_7); -- StorageLive(_10); + StorageDead(_6); + StorageDead(_5); +- StorageLive(_8); + nop; + StorageLive(_9); + _9 = copy _2; +- _8 = move _9 as u32 (Transmute); ++ _8 = copy _2 as u32 (Transmute); + StorageDead(_9); + StorageLive(_10); StorageLive(_11); - _11 = copy _2; -- _10 = move _11 as u32 (Transmute); -+ _10 = copy _2 as u32 (Transmute); - StorageDead(_11); StorageLive(_12); - StorageLive(_13); - StorageLive(_14); - _14 = copy _10; -- _13 = move _14 as i32 (Transmute); -+ _13 = copy _2 as i32 (Transmute); - StorageDead(_14); - _12 = opaque::(move _13) -> [return: bb2, unwind unreachable]; + _12 = copy _8; +- _11 = move _12 as i32 (Transmute); ++ _11 = copy _2 as i32 (Transmute); + StorageDead(_12); + _10 = opaque::(move _11) -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_13); - StorageDead(_12); -- StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = copy _3; -- _15 = move _16 as ZeroOneTwo (Transmute); -+ _15 = copy _3 as ZeroOneTwo (Transmute); - StorageDead(_16); - StorageLive(_17); - StorageLive(_18); - StorageLive(_19); -- _19 = move _15; -- _18 = move _19 as u8 (Transmute); -+ _19 = copy _15; -+ _18 = copy _3 as u8 (Transmute); - StorageDead(_19); - _17 = opaque::(move _18) -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_18); - StorageDead(_17); -- StorageLive(_20); -+ nop; - StorageLive(_21); - _21 = copy _4; -- _20 = move _21 as ZeroOneTwo (Transmute); -+ _20 = copy _4 as ZeroOneTwo (Transmute); - StorageDead(_21); - StorageLive(_22); - StorageLive(_23); - StorageLive(_24); -- _24 = move _20; -- _23 = move _24 as bool (Transmute); -+ _24 = copy _20; -+ _23 = copy _4 as bool (Transmute); - StorageDead(_24); - _22 = opaque::(move _23) -> [return: bb4, unwind unreachable]; - } - - bb4: { - StorageDead(_23); - StorageDead(_22); + StorageDead(_11); + StorageDead(_10); _0 = const (); -- StorageDead(_20); -- StorageDead(_15); -- StorageDead(_10); -- StorageDead(_5); -+ nop; -+ nop; +- StorageDead(_8); +- StorageDead(_3); + nop; + nop; return; diff --git a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff index 3b25dd362cd5..e32397c1aed0 100644 --- a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff @@ -1,135 +1,71 @@ - // MIR for `transmute_then_transmute_again` before GVN + // MIR for `transmute_then_transmute_again` after GVN - fn transmute_then_transmute_again(_1: u32, _2: char, _3: bool, _4: u8) -> () { + fn transmute_then_transmute_again(_1: u32, _2: char) -> () { debug a => _1; debug c => _2; - debug b => _3; - debug d => _4; let mut _0: (); - let _5: char; - let mut _6: u32; - let _7: (); - let mut _8: i32; + let _3: char; + let mut _4: u32; + let _5: (); + let mut _6: i32; + let mut _7: char; let mut _9: char; - let mut _11: char; - let _12: (); - let mut _13: i32; - let mut _14: u32; - let mut _16: bool; - let _17: (); - let mut _18: u8; - let mut _19: ZeroOneTwo; - let mut _21: u8; - let _22: (); - let mut _23: bool; - let mut _24: ZeroOneTwo; + let _10: (); + let mut _11: i32; + let mut _12: u32; scope 1 { - debug x => _5; - let _10: u32; + debug x => _3; + let _8: u32; scope 2 { - debug x => _10; - let _15: ZeroOneTwo; - scope 3 { - debug x => _15; - let _20: ZeroOneTwo; - scope 4 { - debug x => _20; - } - } + debug x => _8; } } bb0: { -- StorageLive(_5); +- StorageLive(_3); + nop; + StorageLive(_4); + _4 = copy _1; +- _3 = move _4 as char (Transmute); ++ _3 = copy _1 as char (Transmute); + StorageDead(_4); + StorageLive(_5); StorageLive(_6); - _6 = copy _1; -- _5 = move _6 as char (Transmute); -+ _5 = copy _1 as char (Transmute); - StorageDead(_6); StorageLive(_7); - StorageLive(_8); - StorageLive(_9); - _9 = copy _5; -- _8 = move _9 as i32 (Transmute); -+ _8 = copy _5 as i32 (Transmute); - StorageDead(_9); - _7 = opaque::(move _8) -> [return: bb1, unwind continue]; + _7 = copy _3; +- _6 = move _7 as i32 (Transmute); ++ _6 = copy _3 as i32 (Transmute); + StorageDead(_7); + _5 = opaque::(move _6) -> [return: bb1, unwind continue]; } bb1: { - StorageDead(_8); - StorageDead(_7); -- StorageLive(_10); + StorageDead(_6); + StorageDead(_5); +- StorageLive(_8); + nop; + StorageLive(_9); + _9 = copy _2; +- _8 = move _9 as u32 (Transmute); ++ _8 = copy _2 as u32 (Transmute); + StorageDead(_9); + StorageLive(_10); StorageLive(_11); - _11 = copy _2; -- _10 = move _11 as u32 (Transmute); -+ _10 = copy _2 as u32 (Transmute); - StorageDead(_11); StorageLive(_12); - StorageLive(_13); - StorageLive(_14); - _14 = copy _10; -- _13 = move _14 as i32 (Transmute); -+ _13 = copy _2 as i32 (Transmute); - StorageDead(_14); - _12 = opaque::(move _13) -> [return: bb2, unwind continue]; + _12 = copy _8; +- _11 = move _12 as i32 (Transmute); ++ _11 = copy _2 as i32 (Transmute); + StorageDead(_12); + _10 = opaque::(move _11) -> [return: bb2, unwind continue]; } bb2: { - StorageDead(_13); - StorageDead(_12); -- StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = copy _3; -- _15 = move _16 as ZeroOneTwo (Transmute); -+ _15 = copy _3 as ZeroOneTwo (Transmute); - StorageDead(_16); - StorageLive(_17); - StorageLive(_18); - StorageLive(_19); -- _19 = move _15; -- _18 = move _19 as u8 (Transmute); -+ _19 = copy _15; -+ _18 = copy _3 as u8 (Transmute); - StorageDead(_19); - _17 = opaque::(move _18) -> [return: bb3, unwind continue]; - } - - bb3: { - StorageDead(_18); - StorageDead(_17); -- StorageLive(_20); -+ nop; - StorageLive(_21); - _21 = copy _4; -- _20 = move _21 as ZeroOneTwo (Transmute); -+ _20 = copy _4 as ZeroOneTwo (Transmute); - StorageDead(_21); - StorageLive(_22); - StorageLive(_23); - StorageLive(_24); -- _24 = move _20; -- _23 = move _24 as bool (Transmute); -+ _24 = copy _20; -+ _23 = copy _4 as bool (Transmute); - StorageDead(_24); - _22 = opaque::(move _23) -> [return: bb4, unwind continue]; - } - - bb4: { - StorageDead(_23); - StorageDead(_22); + StorageDead(_11); + StorageDead(_10); _0 = const (); -- StorageDead(_20); -- StorageDead(_15); -- StorageDead(_10); -- StorageDead(_5); -+ nop; -+ nop; +- StorageDead(_8); +- StorageDead(_3); + nop; + nop; return; diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff index c3eb5d9092be..3bbfd3a891eb 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff @@ -32,7 +32,7 @@ bb2: { StorageLive(_6); - _6 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + _6 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb3: { diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff index ea1878be8cf6..03464f43f81e 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff @@ -32,7 +32,7 @@ bb2: { StorageLive(_6); - _6 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind continue; + _6 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } bb3: { diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff index 2eeeff56cc77..eed8cb7d62e7 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff @@ -29,13 +29,17 @@ _8 = copy (*_1); _2 = copy ((*_8).0: i32); - StorageLive(_3); -+ nop; - _9 = copy (*_1); - _3 = copy ((*_9).1: u64); +- _9 = copy (*_1); +- _3 = copy ((*_9).1: u64); - StorageLive(_4); +- _10 = copy (*_1); +- _4 = copy ((*_10).2: [i8; 3]); + nop; - _10 = copy (*_1); - _4 = copy ((*_10).2: [i8; 3]); ++ _9 = copy _8; ++ _3 = copy ((*_8).1: u64); ++ nop; ++ _10 = copy _8; ++ _4 = copy ((*_8).2: [i8; 3]); StorageLive(_5); _5 = copy _2; StorageLive(_6); @@ -43,7 +47,7 @@ StorageLive(_7); _7 = copy _4; - _0 = AllCopy { a: move _5, b: move _6, c: move _7 }; -+ _0 = AllCopy { a: copy _2, b: copy _3, c: copy _4 }; ++ _0 = copy (*_8); StorageDead(_7); StorageDead(_6); StorageDead(_5); diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_mut.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_mut.GVN.diff deleted file mode 100644 index 92c9db1b3d79..000000000000 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_mut.GVN.diff +++ /dev/null @@ -1,61 +0,0 @@ -- // MIR for `all_copy_mut` before GVN -+ // MIR for `all_copy_mut` after GVN - - fn all_copy_mut(_1: &mut AllCopy) -> AllCopy { - debug mut_v => _1; - let mut _0: AllCopy; - let _2: &AllCopy; - let mut _6: i32; - let mut _7: u64; - let mut _8: [i8; 3]; - scope 1 { - debug v => _2; - let _3: i32; - scope 2 { - debug a => _3; - let _4: u64; - scope 3 { - debug b => _4; - let _5: [i8; 3]; - scope 4 { - debug c => _5; - } - } - } - } - - bb0: { - StorageLive(_2); - _2 = &(*_1); -- StorageLive(_3); -+ nop; - _3 = copy ((*_2).0: i32); -- StorageLive(_4); -+ nop; - _4 = copy ((*_2).1: u64); -- StorageLive(_5); -+ nop; - _5 = copy ((*_2).2: [i8; 3]); - ((*_1).0: i32) = const 0_i32; - StorageLive(_6); - _6 = copy _3; - StorageLive(_7); - _7 = copy _4; - StorageLive(_8); - _8 = copy _5; -- _0 = AllCopy { a: move _6, b: move _7, c: move _8 }; -+ _0 = AllCopy { a: copy _3, b: copy _4, c: copy _5 }; - StorageDead(_8); - StorageDead(_7); - StorageDead(_6); -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -+ nop; -+ nop; -+ nop; - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/gvn_copy_aggregate.deref_nonssa.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.deref_nonssa.GVN.diff deleted file mode 100644 index d9707e40c0bd..000000000000 --- a/tests/mir-opt/gvn_copy_aggregate.deref_nonssa.GVN.diff +++ /dev/null @@ -1,48 +0,0 @@ -- // MIR for `deref_nonssa` before GVN -+ // MIR for `deref_nonssa` after GVN - - fn deref_nonssa() -> Single { - let mut _0: Single; - let mut _1: Single; - let mut _4: Single; - let mut _5: u8; - scope 1 { - debug a => _1; - let _2: &Single; - scope 2 { - debug b => _2; - let _3: u8; - scope 3 { - debug c => _3; - } - } - } - - bb0: { - StorageLive(_1); -- _1 = Single(const 0_u8); -+ _1 = const Single(0_u8); - StorageLive(_2); - _2 = &_1; -- StorageLive(_3); -+ nop; - _3 = copy ((*_2).0: u8); - StorageLive(_4); -- _4 = Single(const 1_u8); -- _1 = move _4; -+ _4 = const Single(1_u8); -+ _1 = const Single(1_u8); - StorageDead(_4); - StorageLive(_5); - _5 = copy _3; -- _0 = Single(move _5); -+ _0 = Single(copy _3); - StorageDead(_5); -- StorageDead(_3); -+ nop; - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/gvn_copy_aggregate.deref_nonssa_2.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.deref_nonssa_2.GVN.diff deleted file mode 100644 index 0dea89020e85..000000000000 --- a/tests/mir-opt/gvn_copy_aggregate.deref_nonssa_2.GVN.diff +++ /dev/null @@ -1,68 +0,0 @@ -- // MIR for `deref_nonssa_2` before GVN -+ // MIR for `deref_nonssa_2` after GVN - - fn deref_nonssa_2() -> Single { - let mut _0: Single; - let mut _1: Single; - let mut _3: &Single; - let _4: &Single; - let mut _7: Single; - let mut _8: u8; - scope 1 { - debug a => _1; - let _2: SingleRef<'_>; - scope 2 { - debug r => _2; - let _5: &Single; - scope 3 { - debug b => _5; - let _6: u8; - scope 4 { - debug c => _6; - } - } - } - } - - bb0: { - StorageLive(_1); -- _1 = Single(const 0_u8); -+ _1 = const Single(0_u8); - StorageLive(_2); -- StorageLive(_3); -+ nop; - StorageLive(_4); - _4 = &_1; - _3 = &(*_4); -- _2 = SingleRef::<'_>(move _3); -- StorageDead(_3); -+ _2 = SingleRef::<'_>(copy _3); -+ nop; - StorageDead(_4); - StorageLive(_5); -- _5 = copy (_2.0: &Single); -- StorageLive(_6); -- _6 = copy ((*_5).0: u8); -+ _5 = copy _3; -+ nop; -+ _6 = copy ((*_3).0: u8); - StorageLive(_7); -- _7 = Single(const 1_u8); -- _1 = move _7; -+ _7 = const Single(1_u8); -+ _1 = const Single(1_u8); - StorageDead(_7); - StorageLive(_8); - _8 = copy _6; -- _0 = Single(move _8); -+ _0 = Single(copy _6); - StorageDead(_8); -- StorageDead(_6); -+ nop; - StorageDead(_5); - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/gvn_copy_aggregate.rs b/tests/mir-opt/gvn_copy_aggregate.rs index c96138824154..c9473025a15f 100644 --- a/tests/mir-opt/gvn_copy_aggregate.rs +++ b/tests/mir-opt/gvn_copy_aggregate.rs @@ -24,25 +24,13 @@ fn all_copy(v: &AllCopy) -> AllCopy { AllCopy { a, b, c } } -// EMIT_MIR gvn_copy_aggregate.all_copy_mut.GVN.diff -fn all_copy_mut(mut_v: &mut AllCopy) -> AllCopy { - // CHECK-LABEL: fn all_copy_mut( - // CHECK: = AllCopy { {{.*}} }; - // CHECK-NOT: _0 = copy ({{.*}}); - let v = &*mut_v; - let a = v.a; - let b = v.b; - let c = v.c; - mut_v.a = 0; - AllCopy { a, b, c } -} - -// Nested references may be modified. // EMIT_MIR gvn_copy_aggregate.all_copy_2.GVN.diff fn all_copy_2(v: &&AllCopy) -> AllCopy { // CHECK-LABEL: fn all_copy_2( // CHECK: bb0: { - // CHECK: _0 = AllCopy { {{.*}} }; + // CHECK-NOT: = AllCopy { {{.*}} }; + // CHECK: [[V1:_.*]] = copy (*_1); + // CHECK: _0 = copy (*[[V1]]); let a = v.a; let b = v.b; let c = v.c; @@ -271,31 +259,3 @@ fn remove_storage_dead_from_index(f: fn() -> usize, v: [SameType; 5]) -> SameTyp } } } - -pub struct Single(u8); - -// EMIT_MIR gvn_copy_aggregate.deref_nonssa.GVN.diff -fn deref_nonssa() -> Single { - // CHECK-LABEL: fn deref_nonssa( - // CHECK: _0 = Single(copy {{.*}}); - let mut a = Single(0); - let b = &a; - let c = (*b).0; - a = Single(1); - // GVN shouldn't replace `Single(c)` with `*b`. - Single(c) -} - -pub struct SingleRef<'a>(&'a Single); - -// EMIT_MIR gvn_copy_aggregate.deref_nonssa_2.GVN.diff -pub fn deref_nonssa_2() -> Single { - // CHECK-LABEL: fn deref_nonssa_2( - // CHECK: _0 = Single(copy {{.*}}); - let mut a = Single(0); - let r = SingleRef(&a); - let b = r.0; - let c = (*b).0; - a = Single(1); - Single(c) -} diff --git a/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff b/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff index 589cfd2a3cf1..e5d719cf3ca9 100644 --- a/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff +++ b/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff @@ -17,7 +17,7 @@ let mut _15: !; let mut _16: Value; scope 1 { - debug val_alias => _3; + debug val_alias => _2; let mut _5: bool; scope 2 { debug stop => _5; @@ -33,16 +33,23 @@ } bb0: { + StorageLive(_2); +- StorageLive(_3); ++ nop; StorageLive(_4); _4 = &(*_1); - _3 = get::(copy _4) -> [return: bb1, unwind unreachable]; + _3 = get::(move _4) -> [return: bb1, unwind unreachable]; } bb1: { + _2 = &(*_3); StorageDead(_4); +- StorageDead(_3); ++ nop; StorageLive(_5); _5 = const false; - _8 = discriminant((*_3)); +- _8 = discriminant((*_2)); ++ _8 = discriminant((*_3)); switchInt(move _8) -> [0: bb3, otherwise: bb2]; } @@ -52,8 +59,10 @@ bb3: { - StorageLive(_7); +- _7 = copy (((*_2) as V0).0: i32); + nop; - _7 = copy (((*_3) as V0).0: i32); ++ _7 = copy (((*_3) as V0).0: i32); + StorageLive(_9); goto -> bb4; } @@ -64,6 +73,7 @@ - _11 = Value::V0(move _12); + _11 = Value::V0(copy _7); StorageDead(_12); + StorageLive(_13); StorageLive(_14); _14 = copy _5; switchInt(move _14) -> [0: bb6, otherwise: bb5]; @@ -72,15 +82,20 @@ bb5: { _0 = move _11; StorageDead(_14); + StorageDead(_13); StorageDead(_11); + StorageDead(_9); - StorageDead(_7); + nop; StorageDead(_5); + StorageDead(_2); return; } bb6: { + _13 = const (); StorageDead(_14); + StorageDead(_13); _5 = const true; StorageLive(_16); - _16 = Value::V1; @@ -88,6 +103,7 @@ + _16 = const Value::V1; + (*_1) = const Value::V1; StorageDead(_16); + _10 = const (); StorageDead(_11); goto -> bb4; } diff --git a/tests/mir-opt/gvn_loop.rs b/tests/mir-opt/gvn_loop.rs index d51baf46302f..ce23f7930f1b 100644 --- a/tests/mir-opt/gvn_loop.rs +++ b/tests/mir-opt/gvn_loop.rs @@ -1,5 +1,5 @@ //@ test-mir-pass: GVN -//@ compile-flags: -Zdump-mir-exclude-alloc-bytes -Zmir-enable-passes=+ReferencePropagation +//@ compile-flags: -Zdump-mir-exclude-alloc-bytes #![crate_type = "lib"] #![feature(core_intrinsics, rustc_attrs)] diff --git a/tests/mir-opt/gvn_overlapping.copy_overlapping.GVN.diff b/tests/mir-opt/gvn_overlapping.copy_overlapping.GVN.diff deleted file mode 100644 index 7b7537bc9b40..000000000000 --- a/tests/mir-opt/gvn_overlapping.copy_overlapping.GVN.diff +++ /dev/null @@ -1,18 +0,0 @@ -- // MIR for `copy_overlapping` before GVN -+ // MIR for `copy_overlapping` after GVN - - fn copy_overlapping() -> () { - let mut _0: (); - let mut _1: Adt; - let mut _2: u32; - let mut _3: &Adt; - - bb0: { - ((_1 as variant#1).0: u32) = const 0_u32; - _3 = &_1; - _2 = copy (((*_3) as variant#1).0: u32); - _1 = Adt::Some(copy _2); - return; - } - } - diff --git a/tests/mir-opt/gvn_overlapping.overlapping.GVN.diff b/tests/mir-opt/gvn_overlapping.overlapping.GVN.diff index efebdf53c292..fcabcdbcfef2 100644 --- a/tests/mir-opt/gvn_overlapping.overlapping.GVN.diff +++ b/tests/mir-opt/gvn_overlapping.overlapping.GVN.diff @@ -3,12 +3,12 @@ fn overlapping(_1: Adt) -> () { let mut _0: (); - let mut _2: &mut Adt; + let mut _2: *mut Adt; let mut _3: u32; let mut _4: &Adt; bb0: { - _2 = &mut _1; + _2 = &raw mut _1; _4 = &(*_2); _3 = copy (((*_4) as variant#1).0: u32); (*_2) = Adt::Some(copy _3); diff --git a/tests/mir-opt/gvn_overlapping.rs b/tests/mir-opt/gvn_overlapping.rs index bd93787cb483..f148a8435612 100644 --- a/tests/mir-opt/gvn_overlapping.rs +++ b/tests/mir-opt/gvn_overlapping.rs @@ -7,19 +7,19 @@ use std::intrinsics::mir::*; // EMIT_MIR gvn_overlapping.overlapping.GVN.diff /// Check that we do not create overlapping assignments. #[custom_mir(dialect = "runtime")] -fn overlapping(_1: Adt) { +fn overlapping(_17: Adt) { // CHECK-LABEL: fn overlapping( - // CHECK: let mut [[PTR:.*]]: &mut Adt; + // CHECK: let mut [[PTR:.*]]: *mut Adt; // CHECK: (*[[PTR]]) = Adt::Some(copy {{.*}}); mir! { - let _2: &mut Adt; - let _3: u32; - let _4: &Adt; + let _33: *mut Adt; + let _48: u32; + let _73: &Adt; { - _2 = &mut _1; - _4 = &(*_2); - _3 = Field(Variant((*_4), 1), 0); - (*_2) = Adt::Some(_3); + _33 = core::ptr::addr_of_mut!(_17); + _73 = &(*_33); + _48 = Field(Variant((*_73), 1), 0); + (*_33) = Adt::Some(_48); Return() } } @@ -30,19 +30,18 @@ fn overlapping(_1: Adt) { #[custom_mir(dialect = "runtime")] fn stable_projection(_1: (Adt,)) { // CHECK-LABEL: fn stable_projection( - // CHECK: let mut _2: &Adt; + // CHECK: let mut _2: *mut Adt; // CHECK: let mut _4: &Adt; - // CHECK: (_5.0: Adt) = copy (_1.0: Adt); + // CHECK: (_1.0: Adt) = copy (*_4); mir! { - let _2: &Adt; + let _2: *mut Adt; let _3: u32; let _4: &Adt; - let _5: (Adt,); { - _2 = &_1.0; + _2 = core::ptr::addr_of_mut!(_1.0); _4 = &(*_2); _3 = Field(Variant((*_4), 1), 0); - _5.0 = Adt::Some(_3); + _1.0 = Adt::Some(_3); Return() } } @@ -65,23 +64,6 @@ fn fields(_1: (Adt, Adt)) { } } -// EMIT_MIR gvn_overlapping.copy_overlapping.GVN.diff -#[custom_mir(dialect = "runtime")] -fn copy_overlapping() { - mir! { - let _1; - let _2; - let _3; - { - place!(Field(Variant(_1, 1), 0)) = 0u32; - _3 = &_1; - _2 = Field(Variant(*_3, 1), 0); - _1 = Adt::Some(_2); - Return() - } - } -} - fn main() { overlapping(Adt::Some(0)); } diff --git a/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff b/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff index b5353b7abde7..088354565911 100644 --- a/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff +++ b/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff @@ -3,18 +3,16 @@ fn stable_projection(_1: (Adt,)) -> () { let mut _0: (); - let mut _2: &Adt; + let mut _2: *mut Adt; let mut _3: u32; let mut _4: &Adt; - let mut _5: (Adt,); bb0: { - _2 = &(_1.0: Adt); + _2 = &raw mut (_1.0: Adt); _4 = &(*_2); -- _3 = copy (((*_4) as variant#1).0: u32); -- (_5.0: Adt) = Adt::Some(copy _3); -+ _3 = copy (((_1.0: Adt) as variant#1).0: u32); -+ (_5.0: Adt) = copy (_1.0: Adt); + _3 = copy (((*_4) as variant#1).0: u32); +- (_1.0: Adt) = Adt::Some(copy _3); ++ (_1.0: Adt) = copy (*_4); return; } } diff --git a/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff b/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff index 23889b266e4a..f56af33ea603 100644 --- a/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff +++ b/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff @@ -7,7 +7,7 @@ let mut _2: *mut u8; scope 1 (inlined dangling_mut::) { scope 2 (inlined NonNull::::dangling) { - let _3: std::ptr::Alignment; + let mut _3: std::num::NonZero; scope 3 { scope 5 (inlined std::ptr::Alignment::as_nonzero) { } @@ -40,9 +40,9 @@ StorageLive(_1); StorageLive(_2); StorageLive(_3); -- _3 = const ::ALIGNMENT; +- _3 = const std::ptr::Alignment::of::::{constant#0} as std::num::NonZero (Transmute); - _2 = copy _3 as *mut u8 (Transmute); -+ _3 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; ++ _3 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + _2 = const {0x1 as *mut u8}; StorageDead(_3); StorageLive(_4); diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff index 66b1bc29877a..423de59e5754 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff @@ -36,7 +36,7 @@ StorageLive(_6); - _6 = panic() -> unwind unreachable; + StorageLive(_7); -+ _7 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind unreachable; ++ _7 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } + } + diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff index 68dd9530137d..3689744dcb04 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff @@ -36,7 +36,7 @@ StorageLive(_6); - _6 = panic() -> unwind continue; + StorageLive(_7); -+ _7 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind continue; ++ _7 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } + } + diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff index a74309e16e88..9509739413b7 100644 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff @@ -20,13 +20,13 @@ + scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { + scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { + let mut _11: std::ptr::NonNull; -+ scope 7 (inlined std::ptr::Unique::::cast::) { ++ scope 7 (inlined Unique::::cast::) { + scope 8 (inlined NonNull::::cast::) { + scope 9 (inlined NonNull::::as_ptr) { + } + } + } -+ scope 10 (inlined std::ptr::Unique::::as_non_null_ptr) { ++ scope 10 (inlined Unique::::as_non_null_ptr) { + } + } + scope 11 (inlined NonNull::::as_ptr) { diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff index 440675826dd5..4c1b25c786ef 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff @@ -197,12 +197,12 @@ + StorageLive(_40); + _40 = &raw mut _19; + _39 = copy _40 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); -+ _37 = copy ((*_39).0: &mut std::future::Ready<()>); + StorageDead(_40); ++ _37 = copy ((*_39).0: &mut std::future::Ready<()>); + StorageLive(_42); + _42 = Option::<()>::None; + _35 = copy ((*_37).0: std::option::Option<()>); -+ ((*_37).0: std::option::Option<()>) = move _42; ++ ((*_37).0: std::option::Option<()>) = copy _42; + StorageDead(_42); + StorageLive(_43); + _43 = discriminant(_35); diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff index f4efcc6c8c62..59417ce64651 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff @@ -208,12 +208,12 @@ + StorageLive(_40); + _40 = &raw mut _19; + _39 = copy _40 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); -+ _37 = copy ((*_39).0: &mut std::future::Ready<()>); + StorageDead(_40); ++ _37 = copy ((*_39).0: &mut std::future::Ready<()>); + StorageLive(_42); + _42 = Option::<()>::None; + _35 = copy ((*_37).0: std::option::Option<()>); -+ ((*_37).0: std::option::Option<()>) = move _42; ++ ((*_37).0: std::option::Option<()>) = copy _42; + StorageDead(_42); + StorageLive(_43); + _43 = discriminant(_35); diff --git a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify-after-simplifycfg.diff index 75038e899b3e..afa25ecdbfba 100644 --- a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify-after-simplifycfg.diff @@ -9,7 +9,6 @@ let mut _4: *const &u8; scope 1 (inlined generic_cast::<&u8, &u8>) { let mut _5: *const &u8; - let mut _6: *const &u8; } bb0: { @@ -18,12 +17,9 @@ StorageLive(_4); _4 = copy _1; StorageLive(_5); - StorageLive(_6); - _6 = copy _4; -- _5 = move _6 as *const &u8 (PtrToPtr); -+ _5 = move _6; - _3 = copy _5; - StorageDead(_6); + _5 = copy _4; +- _3 = move _5 as *const &u8 (PtrToPtr); ++ _3 = move _5; StorageDead(_5); StorageDead(_4); - _2 = move _3 as *const &u8 (PtrToPtr); diff --git a/tests/mir-opt/issue_62289.rs b/tests/mir-opt/issue_62289.rs index 6db2ec2a3719..d020c2cedca0 100644 --- a/tests/mir-opt/issue_62289.rs +++ b/tests/mir-opt/issue_62289.rs @@ -5,9 +5,9 @@ #![feature(rustc_attrs, liballoc_internals)] -// EMIT_MIR issue_62289.test.ElaborateDrops.after.mir -fn test() -> Option> { - Some(vec![None?]) +// EMIT_MIR issue_62289.test.ElaborateDrops.before.mir +fn test() -> Option> { + Some(std::boxed::box_new(None?)) } fn main() { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir deleted file mode 100644 index 968334753db4..000000000000 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir +++ /dev/null @@ -1,119 +0,0 @@ -// MIR for `test` after ElaborateDrops - -fn test() -> Option> { - let mut _0: std::option::Option>; - let mut _1: std::vec::Vec; - let mut _2: std::boxed::Box>; - let mut _3: std::boxed::Box>; - let mut _4: u32; - let mut _5: std::ops::ControlFlow, u32>; - let mut _6: std::option::Option; - let mut _7: isize; - let _8: std::option::Option; - let mut _9: !; - let mut _10: std::option::Option; - let _11: u32; - scope 1 { - debug residual => _8; - scope 2 { - } - } - scope 3 { - debug val => _11; - scope 4 { - } - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - _3 = Box::<[u32; 1]>::new_uninit() -> [return: bb1, unwind: bb14]; - } - - bb1: { - StorageLive(_4); - StorageLive(_5); - StorageLive(_6); - _6 = Option::::None; - _5 = as Try>::branch(move _6) -> [return: bb2, unwind: bb13]; - } - - bb2: { - StorageDead(_6); - PlaceMention(_5); - _7 = discriminant(_5); - switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb3]; - } - - bb3: { - unreachable; - } - - bb4: { - StorageLive(_11); - _11 = copy ((_5 as Continue).0: u32); - _4 = copy _11; - StorageDead(_11); - ((((*_3).1: std::mem::ManuallyDrop<[u32; 1]>).0: std::mem::MaybeDangling<[u32; 1]>).0: [u32; 1]) = [move _4]; - StorageDead(_4); - _2 = move _3; - goto -> bb7; - } - - bb5: { - StorageLive(_8); - _8 = copy ((_5 as Break).0: std::option::Option); - StorageLive(_10); - _10 = copy _8; - _0 = > as FromResidual>>::from_residual(move _10) -> [return: bb6, unwind: bb13]; - } - - bb6: { - StorageDead(_10); - StorageDead(_8); - StorageDead(_4); - drop(_3) -> [return: bb10, unwind: bb14]; - } - - bb7: { - StorageDead(_3); - _1 = std::boxed::box_assume_init_into_vec_unsafe::(move _2) -> [return: bb8, unwind: bb12]; - } - - bb8: { - StorageDead(_2); - _0 = Option::>::Some(move _1); - goto -> bb9; - } - - bb9: { - StorageDead(_1); - StorageDead(_5); - goto -> bb11; - } - - bb10: { - StorageDead(_3); - StorageDead(_2); - StorageDead(_1); - StorageDead(_5); - goto -> bb11; - } - - bb11: { - return; - } - - bb12 (cleanup): { - goto -> bb14; - } - - bb13 (cleanup): { - drop(_3) -> [return: bb14, unwind terminate(cleanup)]; - } - - bb14 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir deleted file mode 100644 index 1fc75018c862..000000000000 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir +++ /dev/null @@ -1,119 +0,0 @@ -// MIR for `test` after ElaborateDrops - -fn test() -> Option> { - let mut _0: std::option::Option>; - let mut _1: std::vec::Vec; - let mut _2: std::boxed::Box>; - let mut _3: std::boxed::Box>; - let mut _4: u32; - let mut _5: std::ops::ControlFlow, u32>; - let mut _6: std::option::Option; - let mut _7: isize; - let _8: std::option::Option; - let mut _9: !; - let mut _10: std::option::Option; - let _11: u32; - scope 1 { - debug residual => _8; - scope 2 { - } - } - scope 3 { - debug val => _11; - scope 4 { - } - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - _3 = Box::<[u32; 1]>::new_uninit() -> [return: bb1, unwind continue]; - } - - bb1: { - StorageLive(_4); - StorageLive(_5); - StorageLive(_6); - _6 = Option::::None; - _5 = as Try>::branch(move _6) -> [return: bb2, unwind: bb13]; - } - - bb2: { - StorageDead(_6); - PlaceMention(_5); - _7 = discriminant(_5); - switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb3]; - } - - bb3: { - unreachable; - } - - bb4: { - StorageLive(_11); - _11 = copy ((_5 as Continue).0: u32); - _4 = copy _11; - StorageDead(_11); - ((((*_3).1: std::mem::ManuallyDrop<[u32; 1]>).0: std::mem::MaybeDangling<[u32; 1]>).0: [u32; 1]) = [move _4]; - StorageDead(_4); - _2 = move _3; - goto -> bb7; - } - - bb5: { - StorageLive(_8); - _8 = copy ((_5 as Break).0: std::option::Option); - StorageLive(_10); - _10 = copy _8; - _0 = > as FromResidual>>::from_residual(move _10) -> [return: bb6, unwind: bb13]; - } - - bb6: { - StorageDead(_10); - StorageDead(_8); - StorageDead(_4); - drop(_3) -> [return: bb10, unwind: bb14]; - } - - bb7: { - StorageDead(_3); - _1 = std::boxed::box_assume_init_into_vec_unsafe::(move _2) -> [return: bb8, unwind: bb12]; - } - - bb8: { - StorageDead(_2); - _0 = Option::>::Some(move _1); - goto -> bb9; - } - - bb9: { - StorageDead(_1); - StorageDead(_5); - goto -> bb11; - } - - bb10: { - StorageDead(_3); - StorageDead(_2); - StorageDead(_1); - StorageDead(_5); - goto -> bb11; - } - - bb11: { - return; - } - - bb12 (cleanup): { - goto -> bb14; - } - - bb13 (cleanup): { - drop(_3) -> [return: bb14, unwind terminate(cleanup)]; - } - - bb14 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir new file mode 100644 index 000000000000..c46549c5742f --- /dev/null +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir @@ -0,0 +1,108 @@ +// MIR for `test` before ElaborateDrops + +fn test() -> Option> { + let mut _0: std::option::Option>; + let mut _1: std::boxed::Box; + let mut _2: *mut u8; + let mut _3: std::boxed::Box; + let mut _4: std::ops::ControlFlow, u32>; + let mut _5: std::option::Option; + let mut _6: isize; + let _7: std::option::Option; + let mut _8: !; + let mut _9: std::option::Option; + let _10: u32; + scope 1 { + debug residual => _7; + scope 2 { + } + } + scope 3 { + debug val => _10; + scope 4 { + } + } + + bb0: { + StorageLive(_1); + _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind: bb13]; + } + + bb1: { + StorageLive(_3); + _3 = ShallowInitBox(move _2, u32); + StorageLive(_4); + StorageLive(_5); + _5 = Option::::None; + _4 = as Try>::branch(move _5) -> [return: bb2, unwind: bb12]; + } + + bb2: { + StorageDead(_5); + PlaceMention(_4); + _6 = discriminant(_4); + switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb3]; + } + + bb3: { + unreachable; + } + + bb4: { + StorageLive(_10); + _10 = copy ((_4 as Continue).0: u32); + (*_3) = copy _10; + StorageDead(_10); + _1 = move _3; + drop(_3) -> [return: bb7, unwind: bb11]; + } + + bb5: { + StorageLive(_7); + _7 = copy ((_4 as Break).0: std::option::Option); + StorageLive(_9); + _9 = copy _7; + _0 = > as FromResidual>>::from_residual(move _9) -> [return: bb6, unwind: bb12]; + } + + bb6: { + StorageDead(_9); + StorageDead(_7); + drop(_3) -> [return: bb9, unwind: bb13]; + } + + bb7: { + StorageDead(_3); + _0 = Option::>::Some(move _1); + drop(_1) -> [return: bb8, unwind: bb13]; + } + + bb8: { + StorageDead(_1); + StorageDead(_4); + goto -> bb10; + } + + bb9: { + StorageDead(_3); + StorageDead(_1); + StorageDead(_4); + goto -> bb10; + } + + bb10: { + return; + } + + bb11 (cleanup): { + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb12 (cleanup): { + drop(_3) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir new file mode 100644 index 000000000000..9f26debdbb6d --- /dev/null +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir @@ -0,0 +1,108 @@ +// MIR for `test` before ElaborateDrops + +fn test() -> Option> { + let mut _0: std::option::Option>; + let mut _1: std::boxed::Box; + let mut _2: *mut u8; + let mut _3: std::boxed::Box; + let mut _4: std::ops::ControlFlow, u32>; + let mut _5: std::option::Option; + let mut _6: isize; + let _7: std::option::Option; + let mut _8: !; + let mut _9: std::option::Option; + let _10: u32; + scope 1 { + debug residual => _7; + scope 2 { + } + } + scope 3 { + debug val => _10; + scope 4 { + } + } + + bb0: { + StorageLive(_1); + _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_3); + _3 = ShallowInitBox(move _2, u32); + StorageLive(_4); + StorageLive(_5); + _5 = Option::::None; + _4 = as Try>::branch(move _5) -> [return: bb2, unwind: bb12]; + } + + bb2: { + StorageDead(_5); + PlaceMention(_4); + _6 = discriminant(_4); + switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb3]; + } + + bb3: { + unreachable; + } + + bb4: { + StorageLive(_10); + _10 = copy ((_4 as Continue).0: u32); + (*_3) = copy _10; + StorageDead(_10); + _1 = move _3; + drop(_3) -> [return: bb7, unwind: bb11]; + } + + bb5: { + StorageLive(_7); + _7 = copy ((_4 as Break).0: std::option::Option); + StorageLive(_9); + _9 = copy _7; + _0 = > as FromResidual>>::from_residual(move _9) -> [return: bb6, unwind: bb12]; + } + + bb6: { + StorageDead(_9); + StorageDead(_7); + drop(_3) -> [return: bb9, unwind continue]; + } + + bb7: { + StorageDead(_3); + _0 = Option::>::Some(move _1); + drop(_1) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_1); + StorageDead(_4); + goto -> bb10; + } + + bb9: { + StorageDead(_3); + StorageDead(_1); + StorageDead(_4); + goto -> bb10; + } + + bb10: { + return; + } + + bb11 (cleanup): { + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb12 (cleanup): { + drop(_3) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff index a0aeb0a30f41..3cf28f4b60af 100644 --- a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff @@ -57,13 +57,13 @@ scope 11 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 12 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _34: std::ptr::NonNull; - scope 13 (inlined std::ptr::Unique::::cast::) { + scope 13 (inlined Unique::::cast::) { scope 14 (inlined NonNull::::cast::) { scope 15 (inlined NonNull::::as_ptr) { } } } - scope 16 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined Unique::::as_non_null_ptr) { } } scope 17 (inlined NonNull::::as_ptr) { @@ -93,100 +93,64 @@ } scope 25 (inlined std::cmp::impls::::eq) { scope 26 (inlined core::slice::cmp::::eq) { - let _39: usize; - let mut _40: bool; - let mut _41: usize; - let mut _42: *const u8; - let mut _43: *const u8; - scope 27 { - scope 28 (inlined core::slice::::as_ptr) { - let mut _44: *const [u8]; - } - scope 29 (inlined core::slice::::as_ptr) { - let mut _45: *const [u8]; - } - scope 30 (inlined >::equal_same_length) { - let mut _46: i32; - scope 31 { - } - } - } } } } } } - scope 32 (inlined std::cmp::impls:: for &String>::eq) { - let mut _47: &std::string::String; - let mut _48: &str; - scope 33 (inlined >::eq) { - scope 34 (inlined #[track_caller] >::index) { - let _49: &str; - scope 35 (inlined String::as_str) { - let _50: &[u8]; - scope 36 (inlined Vec::::as_slice) { - let _51: *const [u8]; - let mut _52: *const u8; - let mut _53: usize; - scope 37 (inlined Vec::::as_ptr) { - scope 38 (inlined alloc::raw_vec::RawVec::::ptr) { - scope 39 (inlined alloc::raw_vec::RawVecInner::ptr::) { - scope 40 (inlined alloc::raw_vec::RawVecInner::non_null::) { - let mut _54: std::ptr::NonNull; - scope 41 (inlined std::ptr::Unique::::cast::) { - scope 42 (inlined NonNull::::cast::) { - scope 43 (inlined NonNull::::as_ptr) { + scope 27 (inlined std::cmp::impls:: for &String>::eq) { + let mut _39: &std::string::String; + let mut _40: &str; + scope 28 (inlined >::eq) { + scope 29 (inlined #[track_caller] >::index) { + let _41: &str; + scope 30 (inlined String::as_str) { + let _42: &[u8]; + scope 31 (inlined Vec::::as_slice) { + let _43: *const [u8]; + let mut _44: *const u8; + let mut _45: usize; + scope 32 (inlined Vec::::as_ptr) { + scope 33 (inlined alloc::raw_vec::RawVec::::ptr) { + scope 34 (inlined alloc::raw_vec::RawVecInner::ptr::) { + scope 35 (inlined alloc::raw_vec::RawVecInner::non_null::) { + let mut _46: std::ptr::NonNull; + scope 36 (inlined Unique::::cast::) { + scope 37 (inlined NonNull::::cast::) { + scope 38 (inlined NonNull::::as_ptr) { } } } - scope 44 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 39 (inlined Unique::::as_non_null_ptr) { } } - scope 45 (inlined NonNull::::as_ptr) { + scope 40 (inlined NonNull::::as_ptr) { } } } } } - scope 46 (inlined from_utf8_unchecked) { + scope 41 (inlined from_utf8_unchecked) { } } - scope 47 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 42 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 48 (inlined #[track_caller] core::str::traits:: for str>::index) { - scope 49 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 43 (inlined #[track_caller] core::str::traits:: for str>::index) { + scope 44 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 50 (inlined core::str::traits::::eq) { - let mut _55: &&[u8]; - let _56: &[u8]; - let mut _57: &&[u8]; - let _58: &[u8]; - scope 51 (inlined core::str::::as_bytes) { + scope 45 (inlined core::str::traits::::eq) { + let mut _47: &&[u8]; + let _48: &[u8]; + let mut _49: &&[u8]; + let _50: &[u8]; + scope 46 (inlined core::str::::as_bytes) { } - scope 52 (inlined core::str::::as_bytes) { + scope 47 (inlined core::str::::as_bytes) { } - scope 53 (inlined std::cmp::impls::::eq) { - scope 54 (inlined core::slice::cmp::::eq) { - let _59: usize; - let mut _60: bool; - let mut _61: usize; - let mut _62: *const u8; - let mut _63: *const u8; - scope 55 { - scope 56 (inlined core::slice::::as_ptr) { - let mut _64: *const [u8]; - } - scope 57 (inlined core::slice::::as_ptr) { - let mut _65: *const [u8]; - } - scope 58 (inlined >::equal_same_length) { - let mut _66: i32; - scope 59 { - } - } - } + scope 48 (inlined std::cmp::impls::::eq) { + scope 49 (inlined core::slice::cmp::::eq) { } } } @@ -215,7 +179,7 @@ bb3: { _1 = chained_conditions::BacktraceStyle::Off; - goto -> bb18; -+ goto -> bb29; ++ goto -> bb23; } bb4: { @@ -252,17 +216,9 @@ StorageDead(_30); StorageLive(_36); StorageLive(_38); - StorageLive(_39); - StorageLive(_42); - StorageLive(_43); _36 = copy _29 as &[u8] (Transmute); _38 = copy _28 as &[u8] (Transmute); - _39 = PtrMetadata(copy _36); - StorageLive(_40); - StorageLive(_41); - _41 = PtrMetadata(copy _38); - _40 = Eq(copy _39, move _41); - switchInt(move _40) -> [0: bb20, otherwise: bb19]; + _7 = <[u8] as core::slice::cmp::SlicePartialEq>::equal(move _36, move _38) -> [return: bb19, unwind unreachable]; } bb5: { @@ -293,47 +249,39 @@ StorageLive(_17); _20 = const chained_conditions::promoted[0]; _17 = &(*_20); - StorageLive(_47); + StorageLive(_39); + StorageLive(_40); + _39 = copy (*_15); + _40 = copy (*_17); + StorageLive(_41); + StorageLive(_42); + StorageLive(_43); + StorageLive(_44); + StorageLive(_46); + _46 = copy ((((((*_39).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _44 = copy _46 as *const u8 (Transmute); + StorageDead(_46); + StorageLive(_45); + _45 = copy (((*_39).0: std::vec::Vec).1: usize); + _43 = *const [u8] from (copy _44, move _45); + StorageDead(_45); + StorageDead(_44); + _42 = &(*_43); + StorageDead(_43); + _41 = copy _42 as &str (Transmute); + StorageDead(_42); StorageLive(_48); - _47 = copy (*_15); - _48 = copy (*_17); - StorageLive(_49); StorageLive(_50); - StorageLive(_51); - StorageLive(_52); - StorageLive(_54); - _54 = copy ((((((*_47).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); - _52 = copy _54 as *const u8 (Transmute); - StorageDead(_54); - StorageLive(_53); - _53 = copy (((*_47).0: std::vec::Vec).1: usize); - _51 = *const [u8] from (copy _52, move _53); - StorageDead(_53); - StorageDead(_52); - _50 = &(*_51); - StorageDead(_51); - _49 = copy _50 as &str (Transmute); - StorageDead(_50); - StorageLive(_56); - StorageLive(_58); - StorageLive(_59); - StorageLive(_62); - StorageLive(_63); - _56 = copy _49 as &[u8] (Transmute); - _58 = copy _48 as &[u8] (Transmute); - _59 = PtrMetadata(copy _56); - StorageLive(_60); - StorageLive(_61); - _61 = PtrMetadata(copy _58); - _60 = Eq(copy _59, move _61); - switchInt(move _60) -> [0: bb24, otherwise: bb23]; + _48 = copy _41 as &[u8] (Transmute); + _50 = copy _40 as &[u8] (Transmute); + _14 = <[u8] as core::slice::cmp::SlicePartialEq>::equal(move _48, move _50) -> [return: bb20, unwind unreachable]; } bb7: { StorageDead(_5); StorageDead(_6); - goto -> bb18; -+ goto -> bb27; ++ goto -> bb21; } bb8: { @@ -356,14 +304,14 @@ StorageDead(_13); _1 = chained_conditions::BacktraceStyle::Short; - goto -> bb18; -+ goto -> bb29; ++ goto -> bb23; } bb10: { StorageDead(_12); StorageDead(_13); - goto -> bb18; -+ goto -> bb27; ++ goto -> bb21; } bb11: { @@ -408,31 +356,6 @@ } bb19: { - StorageDead(_41); - StorageLive(_44); - _44 = &raw const (*_36); - _42 = copy _44 as *const u8 (PtrToPtr); - StorageDead(_44); - StorageLive(_45); - _45 = &raw const (*_38); - _43 = copy _45 as *const u8 (PtrToPtr); - StorageDead(_45); - StorageLive(_46); - _46 = compare_bytes(move _42, move _43, move _39) -> [return: bb22, unwind unreachable]; - } - - bb20: { - StorageDead(_41); - _7 = const false; -- goto -> bb21; -+ goto -> bb32; - } - - bb21: { - StorageDead(_40); - StorageDead(_43); - StorageDead(_42); - StorageDead(_39); StorageDead(_38); StorageDead(_36); StorageDead(_29); @@ -441,94 +364,31 @@ switchInt(move _7) -> [0: bb6, otherwise: bb5]; } - bb22: { - _7 = Eq(move _46, const 0_i32); - StorageDead(_46); - goto -> bb21; - } - - bb23: { - StorageDead(_61); - StorageLive(_64); - _64 = &raw const (*_56); - _62 = copy _64 as *const u8 (PtrToPtr); - StorageDead(_64); - StorageLive(_65); - _65 = &raw const (*_58); - _63 = copy _65 as *const u8 (PtrToPtr); - StorageDead(_65); - StorageLive(_66); - _66 = compare_bytes(move _62, move _63, move _59) -> [return: bb26, unwind unreachable]; - } - - bb24: { - StorageDead(_61); - _14 = const false; -- goto -> bb25; -+ goto -> bb31; - } - - bb25: { - StorageDead(_60); - StorageDead(_63); - StorageDead(_62); - StorageDead(_59); - StorageDead(_58); - StorageDead(_56); - StorageDead(_49); + bb20: { + StorageDead(_50); StorageDead(_48); - StorageDead(_47); + StorageDead(_41); + StorageDead(_40); + StorageDead(_39); switchInt(move _14) -> [0: bb9, otherwise: bb8]; - } - - bb26: { - _14 = Eq(move _66, const 0_i32); - StorageDead(_66); - goto -> bb25; + } + -+ bb27: { ++ bb21: { + _24 = discriminant(_2); -+ switchInt(move _24) -> [1: bb28, otherwise: bb15]; ++ switchInt(move _24) -> [1: bb22, otherwise: bb15]; + } + -+ bb28: { ++ bb22: { + goto -> bb15; + } + -+ bb29: { ++ bb23: { + _24 = discriminant(_2); -+ switchInt(move _24) -> [1: bb30, otherwise: bb15]; ++ switchInt(move _24) -> [1: bb24, otherwise: bb15]; + } + -+ bb30: { ++ bb24: { + goto -> bb17; -+ } -+ -+ bb31: { -+ StorageDead(_60); -+ StorageDead(_63); -+ StorageDead(_62); -+ StorageDead(_59); -+ StorageDead(_58); -+ StorageDead(_56); -+ StorageDead(_49); -+ StorageDead(_48); -+ StorageDead(_47); -+ goto -> bb9; -+ } -+ -+ bb32: { -+ StorageDead(_40); -+ StorageDead(_43); -+ StorageDead(_42); -+ StorageDead(_39); -+ StorageDead(_38); -+ StorageDead(_36); -+ StorageDead(_29); -+ StorageDead(_28); -+ StorageDead(_27); -+ goto -> bb6; } } diff --git a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff index 71d91fed6307..2f0d83f92792 100644 --- a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff @@ -57,13 +57,13 @@ scope 11 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 12 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _34: std::ptr::NonNull; - scope 13 (inlined std::ptr::Unique::::cast::) { + scope 13 (inlined Unique::::cast::) { scope 14 (inlined NonNull::::cast::) { scope 15 (inlined NonNull::::as_ptr) { } } } - scope 16 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined Unique::::as_non_null_ptr) { } } scope 17 (inlined NonNull::::as_ptr) { @@ -93,100 +93,64 @@ } scope 25 (inlined std::cmp::impls::::eq) { scope 26 (inlined core::slice::cmp::::eq) { - let _39: usize; - let mut _40: bool; - let mut _41: usize; - let mut _42: *const u8; - let mut _43: *const u8; - scope 27 { - scope 28 (inlined core::slice::::as_ptr) { - let mut _44: *const [u8]; - } - scope 29 (inlined core::slice::::as_ptr) { - let mut _45: *const [u8]; - } - scope 30 (inlined >::equal_same_length) { - let mut _46: i32; - scope 31 { - } - } - } } } } } } - scope 32 (inlined std::cmp::impls:: for &String>::eq) { - let mut _47: &std::string::String; - let mut _48: &str; - scope 33 (inlined >::eq) { - scope 34 (inlined #[track_caller] >::index) { - let _49: &str; - scope 35 (inlined String::as_str) { - let _50: &[u8]; - scope 36 (inlined Vec::::as_slice) { - let _51: *const [u8]; - let mut _52: *const u8; - let mut _53: usize; - scope 37 (inlined Vec::::as_ptr) { - scope 38 (inlined alloc::raw_vec::RawVec::::ptr) { - scope 39 (inlined alloc::raw_vec::RawVecInner::ptr::) { - scope 40 (inlined alloc::raw_vec::RawVecInner::non_null::) { - let mut _54: std::ptr::NonNull; - scope 41 (inlined std::ptr::Unique::::cast::) { - scope 42 (inlined NonNull::::cast::) { - scope 43 (inlined NonNull::::as_ptr) { + scope 27 (inlined std::cmp::impls:: for &String>::eq) { + let mut _39: &std::string::String; + let mut _40: &str; + scope 28 (inlined >::eq) { + scope 29 (inlined #[track_caller] >::index) { + let _41: &str; + scope 30 (inlined String::as_str) { + let _42: &[u8]; + scope 31 (inlined Vec::::as_slice) { + let _43: *const [u8]; + let mut _44: *const u8; + let mut _45: usize; + scope 32 (inlined Vec::::as_ptr) { + scope 33 (inlined alloc::raw_vec::RawVec::::ptr) { + scope 34 (inlined alloc::raw_vec::RawVecInner::ptr::) { + scope 35 (inlined alloc::raw_vec::RawVecInner::non_null::) { + let mut _46: std::ptr::NonNull; + scope 36 (inlined Unique::::cast::) { + scope 37 (inlined NonNull::::cast::) { + scope 38 (inlined NonNull::::as_ptr) { } } } - scope 44 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 39 (inlined Unique::::as_non_null_ptr) { } } - scope 45 (inlined NonNull::::as_ptr) { + scope 40 (inlined NonNull::::as_ptr) { } } } } } - scope 46 (inlined from_utf8_unchecked) { + scope 41 (inlined from_utf8_unchecked) { } } - scope 47 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 42 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 48 (inlined #[track_caller] core::str::traits:: for str>::index) { - scope 49 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 43 (inlined #[track_caller] core::str::traits:: for str>::index) { + scope 44 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 50 (inlined core::str::traits::::eq) { - let mut _55: &&[u8]; - let _56: &[u8]; - let mut _57: &&[u8]; - let _58: &[u8]; - scope 51 (inlined core::str::::as_bytes) { + scope 45 (inlined core::str::traits::::eq) { + let mut _47: &&[u8]; + let _48: &[u8]; + let mut _49: &&[u8]; + let _50: &[u8]; + scope 46 (inlined core::str::::as_bytes) { } - scope 52 (inlined core::str::::as_bytes) { + scope 47 (inlined core::str::::as_bytes) { } - scope 53 (inlined std::cmp::impls::::eq) { - scope 54 (inlined core::slice::cmp::::eq) { - let _59: usize; - let mut _60: bool; - let mut _61: usize; - let mut _62: *const u8; - let mut _63: *const u8; - scope 55 { - scope 56 (inlined core::slice::::as_ptr) { - let mut _64: *const [u8]; - } - scope 57 (inlined core::slice::::as_ptr) { - let mut _65: *const [u8]; - } - scope 58 (inlined >::equal_same_length) { - let mut _66: i32; - scope 59 { - } - } - } + scope 48 (inlined std::cmp::impls::::eq) { + scope 49 (inlined core::slice::cmp::::eq) { } } } @@ -215,7 +179,7 @@ bb3: { _1 = chained_conditions::BacktraceStyle::Off; - goto -> bb19; -+ goto -> bb33; ++ goto -> bb27; } bb4: { @@ -252,17 +216,9 @@ StorageDead(_30); StorageLive(_36); StorageLive(_38); - StorageLive(_39); - StorageLive(_42); - StorageLive(_43); _36 = copy _29 as &[u8] (Transmute); _38 = copy _28 as &[u8] (Transmute); - _39 = PtrMetadata(copy _36); - StorageLive(_40); - StorageLive(_41); - _41 = PtrMetadata(copy _38); - _40 = Eq(copy _39, move _41); - switchInt(move _40) -> [0: bb24, otherwise: bb23]; + _7 = <[u8] as core::slice::cmp::SlicePartialEq>::equal(move _36, move _38) -> [return: bb23, unwind: bb22]; } bb5: { @@ -293,47 +249,39 @@ StorageLive(_17); _20 = const chained_conditions::promoted[0]; _17 = &(*_20); - StorageLive(_47); + StorageLive(_39); + StorageLive(_40); + _39 = copy (*_15); + _40 = copy (*_17); + StorageLive(_41); + StorageLive(_42); + StorageLive(_43); + StorageLive(_44); + StorageLive(_46); + _46 = copy ((((((*_39).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _44 = copy _46 as *const u8 (Transmute); + StorageDead(_46); + StorageLive(_45); + _45 = copy (((*_39).0: std::vec::Vec).1: usize); + _43 = *const [u8] from (copy _44, move _45); + StorageDead(_45); + StorageDead(_44); + _42 = &(*_43); + StorageDead(_43); + _41 = copy _42 as &str (Transmute); + StorageDead(_42); StorageLive(_48); - _47 = copy (*_15); - _48 = copy (*_17); - StorageLive(_49); StorageLive(_50); - StorageLive(_51); - StorageLive(_52); - StorageLive(_54); - _54 = copy ((((((*_47).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); - _52 = copy _54 as *const u8 (Transmute); - StorageDead(_54); - StorageLive(_53); - _53 = copy (((*_47).0: std::vec::Vec).1: usize); - _51 = *const [u8] from (copy _52, move _53); - StorageDead(_53); - StorageDead(_52); - _50 = &(*_51); - StorageDead(_51); - _49 = copy _50 as &str (Transmute); - StorageDead(_50); - StorageLive(_56); - StorageLive(_58); - StorageLive(_59); - StorageLive(_62); - StorageLive(_63); - _56 = copy _49 as &[u8] (Transmute); - _58 = copy _48 as &[u8] (Transmute); - _59 = PtrMetadata(copy _56); - StorageLive(_60); - StorageLive(_61); - _61 = PtrMetadata(copy _58); - _60 = Eq(copy _59, move _61); - switchInt(move _60) -> [0: bb28, otherwise: bb27]; + _48 = copy _41 as &[u8] (Transmute); + _50 = copy _40 as &[u8] (Transmute); + _14 = <[u8] as core::slice::cmp::SlicePartialEq>::equal(move _48, move _50) -> [return: bb24, unwind: bb22]; } bb7: { StorageDead(_5); StorageDead(_6); - goto -> bb19; -+ goto -> bb31; ++ goto -> bb25; } bb8: { @@ -356,14 +304,14 @@ StorageDead(_13); _1 = chained_conditions::BacktraceStyle::Short; - goto -> bb19; -+ goto -> bb33; ++ goto -> bb27; } bb10: { StorageDead(_12); StorageDead(_13); - goto -> bb19; -+ goto -> bb31; ++ goto -> bb25; } bb11: { @@ -425,31 +373,6 @@ } bb23: { - StorageDead(_41); - StorageLive(_44); - _44 = &raw const (*_36); - _42 = copy _44 as *const u8 (PtrToPtr); - StorageDead(_44); - StorageLive(_45); - _45 = &raw const (*_38); - _43 = copy _45 as *const u8 (PtrToPtr); - StorageDead(_45); - StorageLive(_46); - _46 = compare_bytes(move _42, move _43, move _39) -> [return: bb26, unwind unreachable]; - } - - bb24: { - StorageDead(_41); - _7 = const false; -- goto -> bb25; -+ goto -> bb36; - } - - bb25: { - StorageDead(_40); - StorageDead(_43); - StorageDead(_42); - StorageDead(_39); StorageDead(_38); StorageDead(_36); StorageDead(_29); @@ -458,94 +381,31 @@ switchInt(move _7) -> [0: bb6, otherwise: bb5]; } - bb26: { - _7 = Eq(move _46, const 0_i32); - StorageDead(_46); - goto -> bb25; - } - - bb27: { - StorageDead(_61); - StorageLive(_64); - _64 = &raw const (*_56); - _62 = copy _64 as *const u8 (PtrToPtr); - StorageDead(_64); - StorageLive(_65); - _65 = &raw const (*_58); - _63 = copy _65 as *const u8 (PtrToPtr); - StorageDead(_65); - StorageLive(_66); - _66 = compare_bytes(move _62, move _63, move _59) -> [return: bb30, unwind unreachable]; - } - - bb28: { - StorageDead(_61); - _14 = const false; -- goto -> bb29; -+ goto -> bb35; - } - - bb29: { - StorageDead(_60); - StorageDead(_63); - StorageDead(_62); - StorageDead(_59); - StorageDead(_58); - StorageDead(_56); - StorageDead(_49); + bb24: { + StorageDead(_50); StorageDead(_48); - StorageDead(_47); + StorageDead(_41); + StorageDead(_40); + StorageDead(_39); switchInt(move _14) -> [0: bb9, otherwise: bb8]; - } - - bb30: { - _14 = Eq(move _66, const 0_i32); - StorageDead(_66); - goto -> bb29; + } + -+ bb31: { ++ bb25: { + _24 = discriminant(_2); -+ switchInt(move _24) -> [1: bb32, otherwise: bb16]; ++ switchInt(move _24) -> [1: bb26, otherwise: bb16]; + } + -+ bb32: { ++ bb26: { + goto -> bb16; + } + -+ bb33: { ++ bb27: { + _24 = discriminant(_2); -+ switchInt(move _24) -> [1: bb34, otherwise: bb16]; ++ switchInt(move _24) -> [1: bb28, otherwise: bb16]; + } + -+ bb34: { ++ bb28: { + goto -> bb18; -+ } -+ -+ bb35: { -+ StorageDead(_60); -+ StorageDead(_63); -+ StorageDead(_62); -+ StorageDead(_59); -+ StorageDead(_58); -+ StorageDead(_56); -+ StorageDead(_49); -+ StorageDead(_48); -+ StorageDead(_47); -+ goto -> bb9; -+ } -+ -+ bb36: { -+ StorageDead(_40); -+ StorageDead(_43); -+ StorageDead(_42); -+ StorageDead(_39); -+ StorageDead(_38); -+ StorageDead(_36); -+ StorageDead(_29); -+ StorageDead(_28); -+ StorageDead(_27); -+ goto -> bb6; } } diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index 9630f4001494..97b8d484194f 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -16,10 +16,8 @@ debug residual => _6; scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { - let mut _14: isize; - let _15: i32; - let mut _16: i32; - let mut _17: bool; + let _14: i32; + let mut _15: i32; scope 9 { scope 10 (inlined >::from) { } @@ -76,17 +74,10 @@ StorageLive(_8); _8 = copy _6; StorageLive(_14); + _14 = move ((_8 as Err).0: i32); StorageLive(_15); - StorageLive(_17); - _14 = discriminant(_8); - _17 = Eq(copy _14, const 1_isize); - assume(move _17); - _15 = move ((_8 as Err).0: i32); - StorageLive(_16); - _16 = move _15; - _0 = Result::::Err(move _16); - StorageDead(_16); - StorageDead(_17); + _15 = move _14; + _0 = Result::::Err(move _15); StorageDead(_15); StorageDead(_14); StorageDead(_8); diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index 9630f4001494..97b8d484194f 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -16,10 +16,8 @@ debug residual => _6; scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { - let mut _14: isize; - let _15: i32; - let mut _16: i32; - let mut _17: bool; + let _14: i32; + let mut _15: i32; scope 9 { scope 10 (inlined >::from) { } @@ -76,17 +74,10 @@ StorageLive(_8); _8 = copy _6; StorageLive(_14); + _14 = move ((_8 as Err).0: i32); StorageLive(_15); - StorageLive(_17); - _14 = discriminant(_8); - _17 = Eq(copy _14, const 1_isize); - assume(move _17); - _15 = move ((_8 as Err).0: i32); - StorageLive(_16); - _16 = move _15; - _0 = Result::::Err(move _16); - StorageDead(_16); - StorageDead(_17); + _15 = move _14; + _0 = Result::::Err(move _15); StorageDead(_15); StorageDead(_14); StorageDead(_8); diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index e8a770147741..6b8c2a790202 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -197,6 +197,17 @@ pub fn read_via_copy_uninhabited(r: &Never) -> Never { unsafe { core::intrinsics::read_via_copy(r) } } +// EMIT_MIR lower_intrinsics.write_via_move_string.LowerIntrinsics.diff +pub fn write_via_move_string(r: &mut String, v: String) { + // CHECK-LABEL: fn write_via_move_string( + // CHECK: [[ptr:_.*]] = &raw mut (*_1); + // CHECK: [[tmp:_.*]] = move _2; + // CHECK: (*[[ptr]]) = move [[tmp]]; + // CHECK: return; + + unsafe { core::intrinsics::write_via_move(r, v) } +} + pub enum Never {} // EMIT_MIR lower_intrinsics.ptr_offset.LowerIntrinsics.diff diff --git a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-abort.diff new file mode 100644 index 000000000000..cc9177c90027 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-abort.diff @@ -0,0 +1,31 @@ +- // MIR for `write_via_move_string` before LowerIntrinsics ++ // MIR for `write_via_move_string` after LowerIntrinsics + + fn write_via_move_string(_1: &mut String, _2: String) -> () { + debug r => _1; + debug v => _2; + let mut _0: (); + let mut _3: *mut std::string::String; + let mut _4: std::string::String; + + bb0: { + StorageLive(_3); + _3 = &raw mut (*_1); + StorageLive(_4); + _4 = move _2; +- _0 = write_via_move::(move _3, move _4) -> [return: bb1, unwind unreachable]; ++ (*_3) = move _4; ++ goto -> bb1; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + goto -> bb2; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-unwind.diff new file mode 100644 index 000000000000..cc9177c90027 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-unwind.diff @@ -0,0 +1,31 @@ +- // MIR for `write_via_move_string` before LowerIntrinsics ++ // MIR for `write_via_move_string` after LowerIntrinsics + + fn write_via_move_string(_1: &mut String, _2: String) -> () { + debug r => _1; + debug v => _2; + let mut _0: (); + let mut _3: *mut std::string::String; + let mut _4: std::string::String; + + bb0: { + StorageLive(_3); + _3 = &raw mut (*_1); + StorageLive(_4); + _4 = move _2; +- _0 = write_via_move::(move _3, move _4) -> [return: bb1, unwind unreachable]; ++ (*_3) = move _4; ++ goto -> bb1; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + goto -> bb2; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-abort.mir b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-abort.mir index 7933a36c92c2..6e5f6dc9ea89 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-abort.mir +++ b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-abort.mir @@ -24,7 +24,7 @@ fn unwrap(_1: Option) -> T { bb2: { StorageLive(_4); - _4 = std::rt::begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + _4 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb3: { diff --git a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-unwind.mir b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-unwind.mir index 04176b82ccd5..758aa45f2a2b 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-unwind.mir +++ b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-unwind.mir @@ -24,7 +24,7 @@ fn unwrap(_1: Option) -> T { bb2: { StorageLive(_4); - _4 = std::rt::begin_panic::<&str>(const "explicit panic") -> bb4; + _4 = begin_panic::<&str>(const "explicit panic") -> bb4; } bb3: { diff --git a/tests/mir-opt/optimize_none.rs b/tests/mir-opt/optimize_none.rs index 99efcc35e595..a5b541bd2b62 100644 --- a/tests/mir-opt/optimize_none.rs +++ b/tests/mir-opt/optimize_none.rs @@ -15,14 +15,13 @@ pub fn add_noopt() -> i32 { #[optimize(none)] pub fn const_branch() -> i32 { // CHECK-LABEL: fn const_branch( - // CHECK: [[BOOL:_[0-9]+]] = const true; - // CHECK: switchInt(move [[BOOL]]) -> [0: [[BB_FALSE:bb[0-9]+]], otherwise: [[BB_TRUE:bb[0-9]+]]]; + // CHECK: switchInt(const true) -> [0: [[FALSE:bb[0-9]+]], otherwise: [[TRUE:bb[0-9]+]]]; // CHECK-NEXT: } - // CHECK: [[BB_FALSE]]: { + // CHECK: [[FALSE]]: { // CHECK-NEXT: _0 = const 0 // CHECK-NEXT: goto // CHECK-NEXT: } - // CHECK: [[BB_TRUE]]: { + // CHECK: [[TRUE]]: { // CHECK-NEXT: _0 = const 1 // CHECK-NEXT: goto // CHECK-NEXT: } diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.rs b/tests/mir-opt/pre-codegen/deref_nested_borrows.rs index 23ad0189a66d..738cd981ae67 100644 --- a/tests/mir-opt/pre-codegen/deref_nested_borrows.rs +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.rs @@ -2,14 +2,6 @@ fn src(x: &&u8) -> bool { // CHECK-LABEL: fn src( - // CHECK: debug y => [[Y:_.*]]; - // CHECK: bb0: - // CHECK: [[BORROW_u8:_.*]] = copy (*_1); - // CHECK: [[Y]] = copy (*[[BORROW_u8]]); - // CHECK: bb1: - // BORROW_u8 outside its lifetime in bb1. - // CHECK-NOT: copy (*[[BORROW_u8]]); - // CHECK: copy (*_1); // CHECK-NOT: _0 = const true; // CHECK: _0 = Eq({{.*}}, {{.*}}); // CHECK-NOT: _0 = const true; diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir index f8e575f490b0..013361d1d2fb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir @@ -8,64 +8,58 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _11: (); scope 3 { + let _8: std::ptr::alignment::AlignmentEnum; scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined Unique::::as_non_null_ptr) { } } - scope 23 (inlined ::deallocate) { - scope 24 (inlined std::alloc::Global::deallocate_impl) { - scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _9: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + let mut _10: usize; + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::align) { + scope 26 (inlined std::ptr::Alignment::as_usize) { + } } } } } } } - scope 5 (inlined std::ptr::Unique::<[T]>::as_ptr) { + scope 5 (inlined Unique::<[T]>::as_ptr) { scope 6 (inlined NonNull::<[T]>::as_ptr) { } } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: usize; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) { + let mut _7: std::ptr::Alignment; } } scope 9 (inlined size_of_val_raw::<[T]>) { } - scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } + scope 10 (inlined align_of_val_raw::<[T]>) { } } } @@ -78,26 +72,32 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); + StorageLive(_6); _5 = std::intrinsics::size_of_val::<[T]>(move _4) -> [return: bb1, unwind unreachable]; } bb1: { - StorageLive(_6); _6 = const ::ALIGN; + StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); + _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); + StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_9); + _9 = copy _3 as *mut u8 (PtrToPtr); + StorageLive(_10); + _10 = discriminant(_8); + _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); + StorageDead(_9); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir index f8e575f490b0..013361d1d2fb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir @@ -8,64 +8,58 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _11: (); scope 3 { + let _8: std::ptr::alignment::AlignmentEnum; scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined Unique::::as_non_null_ptr) { } } - scope 23 (inlined ::deallocate) { - scope 24 (inlined std::alloc::Global::deallocate_impl) { - scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _9: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + let mut _10: usize; + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::align) { + scope 26 (inlined std::ptr::Alignment::as_usize) { + } } } } } } } - scope 5 (inlined std::ptr::Unique::<[T]>::as_ptr) { + scope 5 (inlined Unique::<[T]>::as_ptr) { scope 6 (inlined NonNull::<[T]>::as_ptr) { } } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: usize; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) { + let mut _7: std::ptr::Alignment; } } scope 9 (inlined size_of_val_raw::<[T]>) { } - scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } + scope 10 (inlined align_of_val_raw::<[T]>) { } } } @@ -78,26 +72,32 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); + StorageLive(_6); _5 = std::intrinsics::size_of_val::<[T]>(move _4) -> [return: bb1, unwind unreachable]; } bb1: { - StorageLive(_6); _6 = const ::ALIGN; + StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); + _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); + StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_9); + _9 = copy _3 as *mut u8 (PtrToPtr); + StorageLive(_10); + _10 = discriminant(_8); + _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); + StorageDead(_9); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir index f8e575f490b0..013361d1d2fb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir @@ -8,64 +8,58 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _11: (); scope 3 { + let _8: std::ptr::alignment::AlignmentEnum; scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined Unique::::as_non_null_ptr) { } } - scope 23 (inlined ::deallocate) { - scope 24 (inlined std::alloc::Global::deallocate_impl) { - scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _9: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + let mut _10: usize; + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::align) { + scope 26 (inlined std::ptr::Alignment::as_usize) { + } } } } } } } - scope 5 (inlined std::ptr::Unique::<[T]>::as_ptr) { + scope 5 (inlined Unique::<[T]>::as_ptr) { scope 6 (inlined NonNull::<[T]>::as_ptr) { } } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: usize; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) { + let mut _7: std::ptr::Alignment; } } scope 9 (inlined size_of_val_raw::<[T]>) { } - scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } + scope 10 (inlined align_of_val_raw::<[T]>) { } } } @@ -78,26 +72,32 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); + StorageLive(_6); _5 = std::intrinsics::size_of_val::<[T]>(move _4) -> [return: bb1, unwind unreachable]; } bb1: { - StorageLive(_6); _6 = const ::ALIGN; + StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); + _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); + StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_9); + _9 = copy _3 as *mut u8 (PtrToPtr); + StorageLive(_10); + _10 = discriminant(_8); + _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); + StorageDead(_9); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir index f8e575f490b0..013361d1d2fb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir @@ -8,64 +8,58 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _11: (); scope 3 { + let _8: std::ptr::alignment::AlignmentEnum; scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined Unique::::as_non_null_ptr) { } } - scope 23 (inlined ::deallocate) { - scope 24 (inlined std::alloc::Global::deallocate_impl) { - scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _9: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + let mut _10: usize; + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::align) { + scope 26 (inlined std::ptr::Alignment::as_usize) { + } } } } } } } - scope 5 (inlined std::ptr::Unique::<[T]>::as_ptr) { + scope 5 (inlined Unique::<[T]>::as_ptr) { scope 6 (inlined NonNull::<[T]>::as_ptr) { } } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: usize; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) { + let mut _7: std::ptr::Alignment; } } scope 9 (inlined size_of_val_raw::<[T]>) { } - scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } + scope 10 (inlined align_of_val_raw::<[T]>) { } } } @@ -78,26 +72,32 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); + StorageLive(_6); _5 = std::intrinsics::size_of_val::<[T]>(move _4) -> [return: bb1, unwind unreachable]; } bb1: { - StorageLive(_6); _6 = const ::ALIGN; + StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); + _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); + StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_9); + _9 = copy _3 as *mut u8 (PtrToPtr); + StorageLive(_10); + _10 = discriminant(_8); + _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); + StorageDead(_9); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs index ae10cfb0b171..83b10f8bd688 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs @@ -11,6 +11,8 @@ pub unsafe fn generic_in_place(ptr: *mut Box<[T]>) { // CHECK: [[SIZE:_.+]] = std::intrinsics::size_of_val::<[T]> // CHECK: [[ALIGN:_.+]] = const ::ALIGN; // CHECK: [[B:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute); - // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[B]]) -> + // CHECK: [[C:_.+]] = move ([[B]].0: std::ptr::alignment::AlignmentEnum); + // CHECK: [[D:_.+]] = discriminant([[C]]); + // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[D]]) -> std::ptr::drop_in_place(ptr) } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index b48e6fc56f43..d0fda06c115c 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -63,7 +63,7 @@ bb3: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x00000000): std::ptr::alignment::AlignmentEnum }} }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; StorageDead(_8); StorageDead(_2); StorageLive(_3); @@ -73,8 +73,8 @@ StorageLive(_7); - _7 = copy _1; - _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb4, unwind unreachable]; -+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x00000000): std::ptr::alignment::AlignmentEnum }} }}; -+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x00000000): std::ptr::alignment::AlignmentEnum }} }}, const false) -> [return: bb4, unwind unreachable]; ++ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; ++ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index d0e59c06ff99..485ff902a7b9 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -64,7 +64,7 @@ bb4: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x00000000): std::ptr::alignment::AlignmentEnum }} }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; StorageDead(_8); StorageDead(_2); StorageLive(_3); @@ -74,8 +74,8 @@ StorageLive(_7); - _7 = copy _1; - _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb5, unwind continue]; -+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x00000000): std::ptr::alignment::AlignmentEnum }} }}; -+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x00000000): std::ptr::alignment::AlignmentEnum }} }}, const false) -> [return: bb5, unwind continue]; ++ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; ++ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 18fc4ac0d87f..b45a0f4a9bdd 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -63,7 +63,7 @@ bb3: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; StorageDead(_8); StorageDead(_2); StorageLive(_3); @@ -73,8 +73,8 @@ StorageLive(_7); - _7 = copy _1; - _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb4, unwind unreachable]; -+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}; -+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}, const false) -> [return: bb4, unwind unreachable]; ++ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; ++ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index c109fe735e89..beee899dafe6 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -64,7 +64,7 @@ bb4: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; StorageDead(_8); StorageDead(_2); StorageLive(_3); @@ -74,8 +74,8 @@ StorageLive(_7); - _7 = copy _1; - _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb5, unwind continue]; -+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}; -+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}, const false) -> [return: bb5, unwind continue]; ++ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; ++ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index c8b9ff1dbed9..6ab4b7712306 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -139,14 +139,14 @@ fn vec_move(_1: Vec) -> () { debug self => _31; scope 23 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _5: std::ptr::NonNull; - scope 24 (inlined std::ptr::Unique::::cast::) { + scope 24 (inlined Unique::::cast::) { scope 25 (inlined NonNull::::cast::) { let mut _6: *const impl Sized; scope 26 (inlined NonNull::::as_ptr) { } } } - scope 27 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 27 (inlined Unique::::as_non_null_ptr) { } } } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir index ef7ccfa5bddf..b921b96966b2 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir @@ -3,66 +3,56 @@ fn map_via_question_mark(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _4: std::option::Option; - let mut _7: std::ops::ControlFlow, i32>; - let _8: i32; - let mut _9: i32; + let mut _4: std::ops::ControlFlow, i32>; + let _5: i32; + let mut _6: i32; scope 1 { debug residual => const Option::::None; scope 2 { scope 7 (inlined as FromResidual>>::from_residual) { - let mut _3: isize; - let mut _5: bool; } } } scope 3 { - debug val => _8; + debug val => _5; scope 4 { } } scope 5 (inlined as Try>::branch) { let mut _2: isize; - let _6: i32; + let _3: i32; scope 6 { } } bb0: { - StorageLive(_9); - StorageLive(_7); - StorageLive(_2); StorageLive(_6); + StorageLive(_4); + StorageLive(_2); + StorageLive(_3); _2 = discriminant(_1); switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; } bb1: { - StorageDead(_6); - StorageDead(_2); - StorageLive(_3); - StorageLive(_5); - _3 = discriminant(_4); - _5 = Eq(copy _3, const 0_isize); - assume(move _5); - _0 = const Option::::None; - StorageDead(_5); StorageDead(_3); - StorageDead(_9); - StorageDead(_7); + StorageDead(_2); + _0 = const Option::::None; + StorageDead(_6); + StorageDead(_4); goto -> bb3; } bb2: { - _6 = copy ((_1 as Some).0: i32); - _7 = ControlFlow::, i32>::Continue(copy _6); - StorageDead(_6); + _3 = copy ((_1 as Some).0: i32); + _4 = ControlFlow::, i32>::Continue(copy _3); + StorageDead(_3); StorageDead(_2); - _8 = copy ((_7 as Continue).0: i32); - _9 = Add(copy _8, const 1_i32); - _0 = Option::::Some(move _9); - StorageDead(_9); - StorageDead(_7); + _5 = copy ((_4 as Continue).0: i32); + _6 = Add(copy _5, const 1_i32); + _0 = Option::::Some(move _6); + StorageDead(_6); + StorageDead(_4); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index afac0d23115e..2cab88182962 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -3,107 +3,101 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2: &&(usize, usize, usize, usize)) -> bool { let mut _0: bool; let mut _3: &(usize, usize, usize, usize); - let mut _4: &(usize, usize, usize, usize); - let mut _5: &(usize, usize, usize, usize); - let mut _6: &(usize, usize, usize, usize); + let mut _6: bool; let mut _9: bool; - let mut _12: bool; - let mut _13: bool; + let mut _10: bool; + let _13: &usize; + let _14: &usize; + let _15: &usize; let _16: &usize; - let _17: &usize; - let _18: &usize; - let _19: &usize; + let mut _17: &&usize; + let mut _18: &&usize; + let mut _19: &&usize; let mut _20: &&usize; let mut _21: &&usize; let mut _22: &&usize; let mut _23: &&usize; let mut _24: &&usize; - let mut _25: &&usize; - let mut _26: &&usize; - let mut _27: &&usize; scope 1 { - debug a => _16; - debug b => _17; - debug c => _18; - debug d => _19; + debug a => _13; + debug b => _14; + debug c => _15; + debug d => _16; scope 2 (inlined std::cmp::impls::::le) { - debug self => _20; - debug other => _21; + debug self => _17; + debug other => _18; scope 3 (inlined std::cmp::impls::::le) { + debug self => _13; + debug other => _15; + let mut _4: usize; + let mut _5: usize; + } + } + scope 4 (inlined std::cmp::impls::::le) { + debug self => _19; + debug other => _20; + scope 5 (inlined std::cmp::impls::::le) { debug self => _16; - debug other => _18; + debug other => _14; let mut _7: usize; let mut _8: usize; } } - scope 4 (inlined std::cmp::impls::::le) { - debug self => _22; - debug other => _23; - scope 5 (inlined std::cmp::impls::::le) { - debug self => _19; - debug other => _17; - let mut _10: usize; - let mut _11: usize; - } - } scope 6 (inlined std::cmp::impls::::le) { - debug self => _24; - debug other => _25; + debug self => _21; + debug other => _22; scope 7 (inlined std::cmp::impls::::le) { - debug self => _18; - debug other => _16; + debug self => _15; + debug other => _13; } } scope 8 (inlined std::cmp::impls::::le) { - debug self => _26; - debug other => _27; + debug self => _23; + debug other => _24; scope 9 (inlined std::cmp::impls::::le) { - debug self => _17; - debug other => _19; - let mut _14: usize; - let mut _15: usize; + debug self => _14; + debug other => _16; + let mut _11: usize; + let mut _12: usize; } } } bb0: { _3 = copy (*_2); - // DBG: _16 = &((*_3).0: usize); - _4 = copy (*_2); - // DBG: _17 = &((*_4).1: usize); - _5 = copy (*_2); - // DBG: _18 = &((*_5).2: usize); - _6 = copy (*_2); - // DBG: _19 = &((*_6).3: usize); - StorageLive(_9); - // DBG: _20 = &_16; - // DBG: _21 = &?; - _7 = copy ((*_3).0: usize); - _8 = copy ((*_5).2: usize); - _9 = Le(copy _7, copy _8); - switchInt(move _9) -> [0: bb2, otherwise: bb1]; + // DBG: _13 = &((*_3).0: usize); + // DBG: _14 = &((*_3).1: usize); + // DBG: _15 = &((*_3).2: usize); + // DBG: _16 = &((*_3).3: usize); + StorageLive(_6); + // DBG: _17 = &_13; + // DBG: _18 = &?; + _4 = copy ((*_3).0: usize); + _5 = copy ((*_3).2: usize); + _6 = Le(copy _4, copy _5); + switchInt(move _6) -> [0: bb2, otherwise: bb1]; } bb1: { - StorageLive(_12); - // DBG: _22 = &_19; - // DBG: _23 = &?; - StorageLive(_10); - _10 = copy ((*_6).3: usize); - StorageLive(_11); - _11 = copy ((*_4).1: usize); - _12 = Le(move _10, move _11); - StorageDead(_11); - StorageDead(_10); - switchInt(move _12) -> [0: bb2, otherwise: bb6]; + StorageLive(_9); + // DBG: _19 = &_16; + // DBG: _20 = &?; + StorageLive(_7); + _7 = copy ((*_3).3: usize); + StorageLive(_8); + _8 = copy ((*_3).1: usize); + _9 = Le(move _7, move _8); + StorageDead(_8); + StorageDead(_7); + switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - StorageLive(_13); - // DBG: _24 = &_18; - // DBG: _25 = &?; - _13 = Le(copy _8, copy _7); - switchInt(move _13) -> [0: bb3, otherwise: bb4]; + StorageLive(_10); + // DBG: _21 = &_15; + // DBG: _22 = &?; + _10 = Le(copy _5, copy _4); + switchInt(move _10) -> [0: bb3, otherwise: bb4]; } bb3: { @@ -112,20 +106,20 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 } bb4: { - // DBG: _26 = &_17; - // DBG: _27 = &?; - StorageLive(_14); - _14 = copy ((*_4).1: usize); - StorageLive(_15); - _15 = copy ((*_6).3: usize); - _0 = Le(move _14, move _15); - StorageDead(_15); - StorageDead(_14); + // DBG: _23 = &_14; + // DBG: _24 = &?; + StorageLive(_11); + _11 = copy ((*_3).1: usize); + StorageLive(_12); + _12 = copy ((*_3).3: usize); + _0 = Le(move _11, move _12); + StorageDead(_12); + StorageDead(_11); goto -> bb5; } bb5: { - StorageDead(_13); + StorageDead(_10); goto -> bb7; } @@ -135,8 +129,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 } bb7: { - StorageDead(_12); StorageDead(_9); + StorageDead(_6); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir index f93f7264dec2..bc7a31d52199 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir @@ -4,46 +4,40 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: usize; - let mut _5: &(usize, usize, usize, usize); + let _5: usize; let _6: usize; - let mut _7: &(usize, usize, usize, usize); - let _8: usize; - let mut _9: &(usize, usize, usize, usize); - let _10: usize; - let mut _11: bool; - let mut _12: bool; - let mut _13: bool; + let _7: usize; + let mut _8: bool; + let mut _9: bool; + let mut _10: bool; scope 1 { debug a => _4; - debug b => _6; - debug c => _8; - debug d => _10; + debug b => _5; + debug c => _6; + debug d => _7; } bb0: { _3 = copy (*_2); _4 = copy ((*_3).0: usize); - _5 = copy (*_2); - _6 = copy ((*_5).1: usize); - _7 = copy (*_2); - _8 = copy ((*_7).2: usize); - _9 = copy (*_2); - _10 = copy ((*_9).3: usize); - StorageLive(_11); - _11 = Le(copy _4, copy _8); - switchInt(move _11) -> [0: bb2, otherwise: bb1]; + _5 = copy ((*_3).1: usize); + _6 = copy ((*_3).2: usize); + _7 = copy ((*_3).3: usize); + StorageLive(_8); + _8 = Le(copy _4, copy _6); + switchInt(move _8) -> [0: bb2, otherwise: bb1]; } bb1: { - StorageLive(_12); - _12 = Le(copy _10, copy _6); - switchInt(move _12) -> [0: bb2, otherwise: bb6]; + StorageLive(_9); + _9 = Le(copy _7, copy _5); + switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - StorageLive(_13); - _13 = Le(copy _8, copy _4); - switchInt(move _13) -> [0: bb3, otherwise: bb4]; + StorageLive(_10); + _10 = Le(copy _6, copy _4); + switchInt(move _10) -> [0: bb3, otherwise: bb4]; } bb3: { @@ -52,12 +46,12 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, } bb4: { - _0 = Le(copy _6, copy _10); + _0 = Le(copy _5, copy _7); goto -> bb5; } bb5: { - StorageDead(_13); + StorageDead(_10); goto -> bb7; } @@ -67,8 +61,8 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, } bb7: { - StorageDead(_12); - StorageDead(_11); + StorageDead(_9); + StorageDead(_8); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index 8444157a1550..6fb1637a6e02 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -15,7 +15,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> let _8: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_mut_noubcheck::) { - let mut _9: *mut u32; + let _9: *mut u32; scope 7 { let _10: *mut u32; scope 8 { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 8444157a1550..6fb1637a6e02 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -15,7 +15,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> let _8: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_mut_noubcheck::) { - let mut _9: *mut u32; + let _9: *mut u32; scope 7 { let _10: *mut u32; scope 8 { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir index 54be39b4293f..2df2c4b85b8f 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir @@ -19,7 +19,7 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { let mut _6: usize; } scope 4 (inlined core::slice::index::get_offset_len_noubcheck::) { - let mut _10: *const u32; + let _10: *const u32; scope 5 { let _11: *const u32; scope 6 { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir index b258603a3d0d..d4b86b9633ac 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir @@ -19,7 +19,7 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { let mut _6: usize; } scope 4 (inlined core::slice::index::get_offset_len_noubcheck::) { - let mut _10: *const u32; + let _10: *const u32; scope 5 { let _11: *const u32; scope 6 { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir index 7e9d9d24d619..ad1ca5dff43a 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir @@ -13,7 +13,7 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - let _7: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_noubcheck::) { - let mut _8: *const u32; + let _8: *const u32; scope 7 { let _9: *const u32; scope 8 { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir index 7e9d9d24d619..ad1ca5dff43a 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir @@ -13,7 +13,7 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - let _7: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_noubcheck::) { - let mut _8: *const u32; + let _8: *const u32; scope 7 { let _9: *const u32; scope 8 { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index f8898d65133a..f72611b7cb8e 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -5,36 +5,33 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug f => _2; let mut _0: (); let mut _10: usize; - let mut _31: std::option::Option<(usize, &T)>; - let mut _34: &impl Fn(usize, &T); - let mut _35: (usize, &T); - let _36: (); + let mut _28: std::option::Option<(usize, &T)>; + let mut _31: &impl Fn(usize, &T); + let mut _32: (usize, &T); + let _33: (); scope 1 { debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _9; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; debug ((iter: Enumerate>).1: usize) => _10; - let _32: usize; - let _33: &T; + let _29: usize; + let _30: &T; scope 2 { - debug i => _32; - debug x => _33; + debug i => _29; + debug x => _30; } scope 18 (inlined > as Iterator>::next) { - let mut _21: std::option::Option; - let mut _26: std::option::Option<&T>; - let mut _29: (usize, bool); - let mut _30: (usize, &T); + let mut _23: std::option::Option<&T>; + let mut _26: (usize, bool); + let mut _27: (usize, &T); scope 19 { - let _28: usize; + let _25: usize; scope 24 { } } scope 20 { scope 21 { scope 27 (inlined as FromResidual>>::from_residual) { - let mut _20: isize; - let mut _22: bool; } } } @@ -43,7 +40,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 25 (inlined as Try>::branch) { - let _27: &T; + let _24: &T; scope 26 { } } @@ -52,8 +49,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _11: std::ptr::NonNull; let _13: std::ptr::NonNull; let mut _16: bool; - let mut _23: usize; - let _25: &T; + let mut _20: usize; + let _22: &T; scope 29 { let _12: *const T; scope 30 { @@ -87,7 +84,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 43 (inlined NonNull::::as_ref::<'_>) { - let _24: *const T; + let _21: *const T; scope 44 (inlined NonNull::::as_ptr) { } scope 45 (inlined std::ptr::mut_ptr::::cast_const) { @@ -172,16 +169,16 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageLive(_31); StorageLive(_28); - StorageLive(_29); + StorageLive(_25); StorageLive(_26); + StorageLive(_23); StorageLive(_11); StorageLive(_12); StorageLive(_19); - StorageLive(_23); + StorageLive(_20); StorageLive(_13); - StorageLive(_25); + StorageLive(_22); _11 = copy _6; _12 = copy _9; switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; @@ -227,23 +224,16 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb10: { - StorageDead(_25); + StorageDead(_22); StorageDead(_13); - StorageDead(_23); + StorageDead(_20); StorageDead(_19); StorageDead(_12); StorageDead(_11); + StorageDead(_23); StorageDead(_26); - StorageLive(_20); - StorageLive(_22); - _20 = discriminant(_21); - _22 = Eq(copy _20, const 0_isize); - assume(move _22); - StorageDead(_22); - StorageDead(_20); - StorageDead(_29); + StorageDead(_25); StorageDead(_28); - StorageDead(_31); StorageDead(_10); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -253,51 +243,51 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb12: { - _23 = SubUnchecked(copy _19, const 1_usize); - _9 = copy _23 as *const T (Transmute); + _20 = SubUnchecked(copy _19, const 1_usize); + _9 = copy _20 as *const T (Transmute); goto -> bb13; } bb13: { - StorageLive(_24); - _24 = copy _11 as *const T (Transmute); - _25 = &(*_24); - StorageDead(_24); - _26 = Option::<&T>::Some(copy _25); - StorageDead(_25); + StorageLive(_21); + _21 = copy _11 as *const T (Transmute); + _22 = &(*_21); + StorageDead(_21); + _23 = Option::<&T>::Some(copy _22); + StorageDead(_22); StorageDead(_13); - StorageDead(_23); + StorageDead(_20); StorageDead(_19); StorageDead(_12); StorageDead(_11); - _27 = copy ((_26 as Some).0: &T); - StorageDead(_26); - _28 = copy _10; - _29 = AddWithOverflow(copy _10, const 1_usize); - assert(!move (_29.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _10, const 1_usize) -> [success: bb14, unwind unreachable]; + _24 = copy ((_23 as Some).0: &T); + StorageDead(_23); + _25 = copy _10; + _26 = AddWithOverflow(copy _10, const 1_usize); + assert(!move (_26.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _10, const 1_usize) -> [success: bb14, unwind unreachable]; } bb14: { - _10 = move (_29.0: usize); - StorageLive(_30); - _30 = (copy _28, copy _27); - _31 = Option::<(usize, &T)>::Some(move _30); - StorageDead(_30); - StorageDead(_29); - StorageDead(_28); - _32 = copy (((_31 as Some).0: (usize, &T)).0: usize); - _33 = copy (((_31 as Some).0: (usize, &T)).1: &T); - StorageLive(_34); - _34 = &_2; - StorageLive(_35); - _35 = (copy _32, copy _33); - _36 = >::call(move _34, move _35) -> [return: bb15, unwind unreachable]; + _10 = move (_26.0: usize); + StorageLive(_27); + _27 = (copy _25, copy _24); + _28 = Option::<(usize, &T)>::Some(move _27); + StorageDead(_27); + StorageDead(_26); + StorageDead(_25); + _29 = copy (((_28 as Some).0: (usize, &T)).0: usize); + _30 = copy (((_28 as Some).0: (usize, &T)).1: &T); + StorageLive(_31); + _31 = &_2; + StorageLive(_32); + _32 = (copy _29, copy _30); + _33 = >::call(move _31, move _32) -> [return: bb15, unwind unreachable]; } bb15: { - StorageDead(_35); - StorageDead(_34); + StorageDead(_32); StorageDead(_31); + StorageDead(_28); goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir index 730aedf4f1a3..8308ecbad716 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir @@ -16,13 +16,13 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _2: std::ptr::NonNull; - scope 7 (inlined std::ptr::Unique::::cast::) { + scope 7 (inlined Unique::::cast::) { scope 8 (inlined NonNull::::cast::) { scope 9 (inlined NonNull::::as_ptr) { } } } - scope 10 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 10 (inlined Unique::::as_non_null_ptr) { } } scope 11 (inlined NonNull::::as_ptr) { diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir index 730aedf4f1a3..8308ecbad716 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir @@ -16,13 +16,13 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _2: std::ptr::NonNull; - scope 7 (inlined std::ptr::Unique::::cast::) { + scope 7 (inlined Unique::::cast::) { scope 8 (inlined NonNull::::cast::) { scope 9 (inlined NonNull::::as_ptr) { } } } - scope 10 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 10 (inlined Unique::::as_non_null_ptr) { } } scope 11 (inlined NonNull::::as_ptr) { diff --git a/tests/mir-opt/range/ssa_range.on_assert.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_assert.SsaRangePropagation.diff deleted file mode 100644 index ae3f49a8847b..000000000000 --- a/tests/mir-opt/range/ssa_range.on_assert.SsaRangePropagation.diff +++ /dev/null @@ -1,69 +0,0 @@ -- // MIR for `on_assert` before SsaRangePropagation -+ // MIR for `on_assert` after SsaRangePropagation - - fn on_assert(_1: usize, _2: &[u8]) -> u8 { - debug i => _1; - debug v => _2; - let mut _0: u8; - let _3: (); - let mut _4: bool; - let mut _5: usize; - let mut _6: usize; - let mut _7: &[u8]; - let mut _8: !; - let _9: usize; - let mut _10: usize; - let mut _11: bool; - scope 1 (inlined core::slice::::len) { - scope 2 (inlined std::ptr::metadata::<[u8]>) { - } - } - - bb0: { - StorageLive(_3); - nop; - StorageLive(_5); - _5 = copy _1; - nop; - StorageLive(_7); - _7 = &(*_2); - _6 = PtrMetadata(copy _2); - StorageDead(_7); - _4 = Lt(copy _1, copy _6); - switchInt(copy _4) -> [0: bb2, otherwise: bb1]; - } - - bb1: { - nop; - StorageDead(_5); - _3 = const (); - nop; - StorageDead(_3); - StorageLive(_9); - _9 = copy _1; - _10 = copy _6; -- _11 = copy _4; -- assert(copy _4, "index out of bounds: the length is {} but the index is {}", copy _6, copy _1) -> [success: bb3, unwind unreachable]; -+ _11 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", copy _6, copy _1) -> [success: bb3, unwind unreachable]; - } - - bb2: { - nop; - StorageDead(_5); - StorageLive(_8); - _8 = panic(const "assertion failed: i < v.len()") -> unwind unreachable; - } - - bb3: { - _0 = copy (*_2)[_1]; - StorageDead(_9); - return; - } - } - - ALLOC0 (size: 29, align: 1) { - 0x00 │ 61 73 73 65 72 74 69 6f 6e 20 66 61 69 6c 65 64 │ assertion failed - 0x10 │ 3a 20 69 20 3c 20 76 2e 6c 65 6e 28 29 │ : i < v.len() - } - diff --git a/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff deleted file mode 100644 index 3be6f083604d..000000000000 --- a/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff +++ /dev/null @@ -1,56 +0,0 @@ -- // MIR for `on_assume` before SsaRangePropagation -+ // MIR for `on_assume` after SsaRangePropagation - - fn on_assume(_1: usize, _2: &[u8]) -> u8 { - debug i => _1; - debug v => _2; - let mut _0: u8; - let _3: (); - let _4: (); - let mut _5: bool; - let mut _6: usize; - let mut _7: usize; - let mut _8: &[u8]; - let _9: usize; - let mut _10: usize; - let mut _11: bool; - scope 1 (inlined core::slice::::len) { - scope 2 (inlined std::ptr::metadata::<[u8]>) { - } - } - - bb0: { - StorageLive(_3); - StorageLive(_4); - nop; - StorageLive(_6); - _6 = copy _1; - nop; - StorageLive(_8); - _8 = &(*_2); - _7 = PtrMetadata(copy _2); - StorageDead(_8); - _5 = Lt(copy _1, copy _7); - nop; - StorageDead(_6); - assume(copy _5); - nop; - StorageDead(_4); - _3 = const (); - StorageDead(_3); - StorageLive(_9); - _9 = copy _1; - _10 = copy _7; -- _11 = copy _5; -- assert(copy _5, "index out of bounds: the length is {} but the index is {}", copy _7, copy _1) -> [success: bb1, unwind unreachable]; -+ _11 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", copy _7, copy _1) -> [success: bb1, unwind unreachable]; - } - - bb1: { - _0 = copy (*_2)[_1]; - StorageDead(_9); - return; - } - } - diff --git a/tests/mir-opt/range/ssa_range.on_if.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_if.SsaRangePropagation.diff deleted file mode 100644 index 2493e069edd4..000000000000 --- a/tests/mir-opt/range/ssa_range.on_if.SsaRangePropagation.diff +++ /dev/null @@ -1,63 +0,0 @@ -- // MIR for `on_if` before SsaRangePropagation -+ // MIR for `on_if` after SsaRangePropagation - - fn on_if(_1: usize, _2: &[u8]) -> u8 { - debug i => _1; - debug v => _2; - let mut _0: u8; - let mut _3: bool; - let mut _4: usize; - let mut _5: usize; - let mut _6: &[u8]; - let _7: usize; - let mut _8: usize; - let mut _9: bool; - scope 1 (inlined core::slice::::len) { - scope 2 (inlined std::ptr::metadata::<[u8]>) { - } - } - - bb0: { - nop; - StorageLive(_4); - _4 = copy _1; - nop; - StorageLive(_6); - _6 = &(*_2); - _5 = PtrMetadata(copy _2); - StorageDead(_6); - _3 = Lt(copy _1, copy _5); - switchInt(copy _3) -> [0: bb3, otherwise: bb1]; - } - - bb1: { - nop; - StorageDead(_4); - StorageLive(_7); - _7 = copy _1; - _8 = copy _5; -- _9 = copy _3; -- assert(copy _3, "index out of bounds: the length is {} but the index is {}", copy _5, copy _1) -> [success: bb2, unwind unreachable]; -+ _9 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", copy _5, copy _1) -> [success: bb2, unwind unreachable]; - } - - bb2: { - _0 = copy (*_2)[_1]; - StorageDead(_7); - goto -> bb4; - } - - bb3: { - nop; - StorageDead(_4); - _0 = const 0_u8; - goto -> bb4; - } - - bb4: { - nop; - return; - } - } - diff --git a/tests/mir-opt/range/ssa_range.on_if_2.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_if_2.SsaRangePropagation.diff deleted file mode 100644 index 8a957238c845..000000000000 --- a/tests/mir-opt/range/ssa_range.on_if_2.SsaRangePropagation.diff +++ /dev/null @@ -1,20 +0,0 @@ -- // MIR for `on_if_2` before SsaRangePropagation -+ // MIR for `on_if_2` after SsaRangePropagation - - fn on_if_2(_1: bool) -> bool { - let mut _0: bool; - - bb0: { - switchInt(copy _1) -> [1: bb2, otherwise: bb1]; - } - - bb1: { - goto -> bb2; - } - - bb2: { - _0 = copy _1; - return; - } - } - diff --git a/tests/mir-opt/range/ssa_range.on_match.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_match.SsaRangePropagation.diff deleted file mode 100644 index f91ac7090dde..000000000000 --- a/tests/mir-opt/range/ssa_range.on_match.SsaRangePropagation.diff +++ /dev/null @@ -1,33 +0,0 @@ -- // MIR for `on_match` before SsaRangePropagation -+ // MIR for `on_match` after SsaRangePropagation - - fn on_match(_1: u8) -> u8 { - debug i => _1; - let mut _0: u8; - - bb0: { - switchInt(copy _1) -> [1: bb3, 2: bb2, otherwise: bb1]; - } - - bb1: { - _0 = const 0_u8; - goto -> bb4; - } - - bb2: { -- _0 = copy _1; -+ _0 = const 2_u8; - goto -> bb4; - } - - bb3: { -- _0 = copy _1; -+ _0 = const 1_u8; - goto -> bb4; - } - - bb4: { - return; - } - } - diff --git a/tests/mir-opt/range/ssa_range.on_match_2.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_match_2.SsaRangePropagation.diff deleted file mode 100644 index 53433d9fe4ba..000000000000 --- a/tests/mir-opt/range/ssa_range.on_match_2.SsaRangePropagation.diff +++ /dev/null @@ -1,26 +0,0 @@ -- // MIR for `on_match_2` before SsaRangePropagation -+ // MIR for `on_match_2` after SsaRangePropagation - - fn on_match_2(_1: u8) -> u8 { - debug i => _1; - let mut _0: u8; - - bb0: { - switchInt(copy _1) -> [1: bb2, 2: bb2, otherwise: bb1]; - } - - bb1: { - _0 = const 0_u8; - goto -> bb3; - } - - bb2: { - _0 = copy _1; - goto -> bb3; - } - - bb3: { - return; - } - } - diff --git a/tests/mir-opt/range/ssa_range.rs b/tests/mir-opt/range/ssa_range.rs deleted file mode 100644 index c8440a10a408..000000000000 --- a/tests/mir-opt/range/ssa_range.rs +++ /dev/null @@ -1,80 +0,0 @@ -//@ test-mir-pass: SsaRangePropagation -//@ compile-flags: -Zmir-enable-passes=+GVN,+Inline --crate-type=lib -Cpanic=abort - -#![feature(custom_mir, core_intrinsics)] - -use std::intrinsics::mir::*; - -// EMIT_MIR ssa_range.on_if.SsaRangePropagation.diff -pub fn on_if(i: usize, v: &[u8]) -> u8 { - // CHECK-LABEL: fn on_if( - // CHECK: assert(const true - if i < v.len() { v[i] } else { 0 } -} - -// EMIT_MIR ssa_range.on_assert.SsaRangePropagation.diff -pub fn on_assert(i: usize, v: &[u8]) -> u8 { - // CHECK-LABEL: fn on_assert( - // CHECK: assert(const true - assert!(i < v.len()); - v[i] -} - -// EMIT_MIR ssa_range.on_assume.SsaRangePropagation.diff -pub fn on_assume(i: usize, v: &[u8]) -> u8 { - // CHECK-LABEL: fn on_assume( - // CHECK: assert(const true - unsafe { - std::intrinsics::assume(i < v.len()); - } - v[i] -} - -// EMIT_MIR ssa_range.on_match.SsaRangePropagation.diff -pub fn on_match(i: u8) -> u8 { - // CHECK-LABEL: fn on_match( - // CHECK: switchInt(copy _1) -> [1: [[BB_V1:bb.*]], 2: [[BB_V2:bb.*]], - // CHECK: [[BB_V2]]: { - // CHECK-NEXT: _0 = const 2_u8; - // CHECK: [[BB_V1]]: { - // CHECK-NEXT: _0 = const 1_u8; - match i { - 1 => i, - 2 => i, - _ => 0, - } -} - -// EMIT_MIR ssa_range.on_match_2.SsaRangePropagation.diff -pub fn on_match_2(i: u8) -> u8 { - // CHECK-LABEL: fn on_match_2( - // CHECK: switchInt(copy _1) -> [1: [[BB:bb.*]], 2: [[BB]], - // CHECK: [[BB]]: { - // CHECK-NEXT: _0 = copy _1; - match i { - 1 | 2 => i, - _ => 0, - } -} - -// EMIT_MIR ssa_range.on_if_2.SsaRangePropagation.diff -#[custom_mir(dialect = "runtime", phase = "post-cleanup")] -pub fn on_if_2(a: bool) -> bool { - // CHECK-LABEL: fn on_if_2( - // CHECK: _0 = copy _1; - mir! { - { - match a { - true => bb2, - _ => bb1 - } - } - bb1 = { - Goto(bb2) - } - bb2 = { - RET = a; - Return() - } - } -} diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index 10ad4ec75414..34f451fc698c 100644 --- a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff @@ -12,9 +12,7 @@ debug residual => _4; scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { - let mut _10: isize; - let _11: i32; - let mut _12: bool; + let _10: i32; scope 9 { scope 10 (inlined >::from) { } @@ -60,15 +58,8 @@ bb3: { _4 = copy ((_2 as Break).0: std::result::Result); - StorageLive(_10); - StorageLive(_12); - _10 = discriminant(_4); - _12 = Eq(copy _10, const 1_isize); - assume(move _12); - _11 = copy ((_4 as Err).0: i32); - _0 = Result::::Err(copy _11); - StorageDead(_12); - StorageDead(_10); + _10 = copy ((_4 as Err).0: i32); + _0 = Result::::Err(copy _10); StorageDead(_2); return; } diff --git a/tests/mir-opt/simplify_match.rs b/tests/mir-opt/simplify_match.rs index ca9dac40aa91..b035b6339fae 100644 --- a/tests/mir-opt/simplify_match.rs +++ b/tests/mir-opt/simplify_match.rs @@ -1,15 +1,9 @@ -//! Test that GVN propagates the constant `false` and eliminates the match. +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY - #[inline(never)] fn noop() {} // EMIT_MIR simplify_match.main.GVN.diff -// CHECK-LABEL: fn main( -// CHECK: debug x => const false; -// CHECK-NOT: switchInt -// CHECK: bb0: { -// CHECK-NEXT: return; fn main() { match { let x = false; diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index f9965a529ebc..7012cc5aa7f6 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -152,7 +152,7 @@ StorageDead(_22); StorageDead(_21); StorageDead(_20); - _10 = std::io::_eprint(move _11) -> [return: bb6, unwind unreachable]; + _10 = _eprint(move _11) -> [return: bb6, unwind unreachable]; } bb6: { diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff index 8c3b8ad9b66a..17ddce0cdf8d 100644 --- a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff @@ -19,23 +19,19 @@ bb1: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb3, 1: bb4, otherwise: bb2]; -+ _5 = Eq(copy _2, const 0_isize); +- switchInt(move _2) -> [1: bb3, otherwise: bb2]; ++ _5 = Ne(copy _2, const 1_isize); + assume(move _5); -+ goto -> bb3; ++ goto -> bb2; } bb2: { - unreachable; - } - - bb3: { _0 = const (); StorageDead(_1); return; } - bb4: { + bb3: { - StorageLive(_3); - _3 = move ((_1 as Some).0: Empty); - StorageLive(_4); diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff index 98f2a0a692ff..2f78092f5bd2 100644 --- a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff @@ -19,23 +19,19 @@ bb1: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb3, 1: bb4, otherwise: bb2]; -+ _5 = Eq(copy _2, const 0_isize); +- switchInt(move _2) -> [1: bb3, otherwise: bb2]; ++ _5 = Ne(copy _2, const 1_isize); + assume(move _5); -+ goto -> bb3; ++ goto -> bb2; } bb2: { - unreachable; - } - - bb3: { _0 = const (); StorageDead(_1); return; } - bb4: { + bb3: { - StorageLive(_3); - _3 = move ((_1 as Some).0: Empty); - StorageLive(_4); diff --git a/tests/mir-opt/unreachable.rs b/tests/mir-opt/unreachable.rs index 97cd15b107c1..afab1291fc3d 100644 --- a/tests/mir-opt/unreachable.rs +++ b/tests/mir-opt/unreachable.rs @@ -45,7 +45,7 @@ fn as_match() { // CHECK: bb0: { // CHECK: {{_.*}} = empty() // CHECK: bb1: { - // CHECK: [[eq:_.*]] = Eq({{.*}}, const 0_isize); + // CHECK: [[eq:_.*]] = Ne({{.*}}, const 1_isize); // CHECK-NEXT: assume(move [[eq]]); // CHECK-NEXT: goto -> [[return:bb.*]]; // CHECK: [[return]]: { diff --git a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff index befee026d6cb..c24bd7e7446d 100644 --- a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff @@ -14,40 +14,40 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; -+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; } bb1: { - unreachable; - } - - bb2: { StorageLive(_5); _5 = const "C"; _1 = &(*_5); StorageDead(_5); - goto -> bb5; + goto -> bb4; } - bb3: { + bb2: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); StorageDead(_4); - goto -> bb5; + goto -> bb4; + } + + bb3: { + _1 = const "A(Empty)"; + goto -> bb4; } bb4: { - _1 = const "A(Empty)"; - goto -> bb5; - } - - bb5: { StorageDead(_2); StorageDead(_1); _0 = const (); return; ++ } ++ ++ bb5: { ++ unreachable; } } diff --git a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff index befee026d6cb..c24bd7e7446d 100644 --- a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff @@ -14,40 +14,40 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; -+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; } bb1: { - unreachable; - } - - bb2: { StorageLive(_5); _5 = const "C"; _1 = &(*_5); StorageDead(_5); - goto -> bb5; + goto -> bb4; } - bb3: { + bb2: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); StorageDead(_4); - goto -> bb5; + goto -> bb4; + } + + bb3: { + _1 = const "A(Empty)"; + goto -> bb4; } bb4: { - _1 = const "A(Empty)"; - goto -> bb5; - } - - bb5: { StorageDead(_2); StorageDead(_1); _0 = const (); return; ++ } ++ ++ bb5: { ++ unreachable; } } diff --git a/tests/pretty/delegation-inherit-attributes.pp b/tests/pretty/delegation-inherit-attributes.pp index 26ca5e99b885..2398cae90fdb 100644 --- a/tests/pretty/delegation-inherit-attributes.pp +++ b/tests/pretty/delegation-inherit-attributes.pp @@ -7,7 +7,7 @@ #![allow(incomplete_features)] #![feature(fn_delegation)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use std::prelude::rust_2021::*; extern crate to_reuse_functions; @@ -21,8 +21,8 @@ mod to_reuse { #[attr = Cold] fn foo_no_reason(x: usize) -> usize { x } - #[attr = Cold] #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] + #[attr = Cold] fn bar(x: usize) -> usize { x } } diff --git a/tests/pretty/delegation-inline-attribute.pp b/tests/pretty/delegation-inline-attribute.pp index 9f362fa863f8..5235fd8d0ef2 100644 --- a/tests/pretty/delegation-inline-attribute.pp +++ b/tests/pretty/delegation-inline-attribute.pp @@ -5,7 +5,7 @@ #![allow(incomplete_features)] #![feature(fn_delegation)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; mod to_reuse { @@ -44,9 +44,9 @@ impl Trait for S { fn foo0(arg0: _) -> _ { to_reuse::foo(self + 1) } // Check that #[inline(hint)] is added when other attributes present in inner reuse - #[attr = Cold] - #[attr = MustUse] #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] + #[attr = MustUse] + #[attr = Cold] #[attr = Inline(Hint)] fn foo1(arg0: _) -> _ { to_reuse::foo(self / 2) } @@ -59,18 +59,18 @@ impl Trait for S { fn foo3(arg0: _) -> _ { to_reuse::foo(self / 2) } // Check that #[inline(never)] is preserved when there are other attributes in inner reuse - #[attr = Cold] - #[attr = MustUse] - #[attr = Inline(Never)] #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] + #[attr = Inline(Never)] + #[attr = MustUse] + #[attr = Cold] fn foo4(arg0: _) -> _ { to_reuse::foo(self / 2) } }.foo() } // Check that #[inline(hint)] is added when there are other attributes present in trait reuse - #[attr = Cold] - #[attr = MustUse] #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] + #[attr = MustUse] + #[attr = Cold] #[attr = Inline(Hint)] fn foo1(self: _) -> _ { self.0.foo1() } @@ -83,10 +83,10 @@ impl Trait for S { fn foo3(self: _) -> _ { self.0.foo3() } // Check that #[inline(never)] is preserved when there are other attributes in trait reuse - #[attr = Cold] - #[attr = MustUse] - #[attr = Inline(Never)] #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] + #[attr = Inline(Never)] + #[attr = MustUse] + #[attr = Cold] fn foo4(self: _) -> _ { self.0.foo4() } } diff --git a/tests/pretty/hir-delegation.pp b/tests/pretty/hir-delegation.pp index 59491b6ebd7c..44a1deb750dc 100644 --- a/tests/pretty/hir-delegation.pp +++ b/tests/pretty/hir-delegation.pp @@ -5,7 +5,7 @@ #![allow(incomplete_features)] #![feature(fn_delegation)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; fn b(e: C) { } diff --git a/tests/pretty/hir-fn-params.pp b/tests/pretty/hir-fn-params.pp index 15373bba24d3..52310d5024cd 100644 --- a/tests/pretty/hir-fn-params.pp +++ b/tests/pretty/hir-fn-params.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ pretty-compare-only //@ pretty-mode:hir diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp index 3837b260cc5d..6356eec80e0e 100644 --- a/tests/pretty/hir-fn-variadic.pp +++ b/tests/pretty/hir-fn-variadic.pp @@ -4,7 +4,7 @@ #![feature(c_variadic)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; extern "C" { diff --git a/tests/pretty/hir-if-else.pp b/tests/pretty/hir-if-else.pp index c2050e1f6e47..d3721e175815 100644 --- a/tests/pretty/hir-if-else.pp +++ b/tests/pretty/hir-if-else.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ pretty-compare-only //@ pretty-mode:hir diff --git a/tests/pretty/hir-lifetimes.pp b/tests/pretty/hir-lifetimes.pp index c35a40eed0c5..ceb0f6e3b7c2 100644 --- a/tests/pretty/hir-lifetimes.pp +++ b/tests/pretty/hir-lifetimes.pp @@ -6,7 +6,7 @@ #![allow(unused)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; struct Foo<'a> { diff --git a/tests/pretty/hir-pretty-attr.pp b/tests/pretty/hir-pretty-attr.pp index be23294e8f7e..a9d8b5e7e577 100644 --- a/tests/pretty/hir-pretty-attr.pp +++ b/tests/pretty/hir-pretty-attr.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ pretty-compare-only //@ pretty-mode:hir diff --git a/tests/pretty/hir-pretty-loop.pp b/tests/pretty/hir-pretty-loop.pp index f9bc7416e4bc..e6614ce318cc 100644 --- a/tests/pretty/hir-pretty-loop.pp +++ b/tests/pretty/hir-pretty-loop.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ pretty-compare-only //@ pretty-mode:hir diff --git a/tests/pretty/hir-struct-expr.pp b/tests/pretty/hir-struct-expr.pp index 2557aa42378a..198d7ad6a9b6 100644 --- a/tests/pretty/hir-struct-expr.pp +++ b/tests/pretty/hir-struct-expr.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ pretty-compare-only //@ pretty-mode:hir diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index d73ad35d6222..568269644bb8 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ pretty-compare-only //@ pretty-mode:hir,typed diff --git a/tests/pretty/issue-85089.pp b/tests/pretty/issue-85089.pp index ab386666da17..919573220fdd 100644 --- a/tests/pretty/issue-85089.pp +++ b/tests/pretty/issue-85089.pp @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; // Test to print lifetimes on HIR pretty-printing. diff --git a/tests/pretty/pin-ergonomics-hir.pp b/tests/pretty/pin-ergonomics-hir.pp index e422edf54e0c..cf9b6707ed2f 100644 --- a/tests/pretty/pin-ergonomics-hir.pp +++ b/tests/pretty/pin-ergonomics-hir.pp @@ -5,7 +5,7 @@ #![feature(pin_ergonomics)] #![allow(dead_code, incomplete_features)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; use std::pin::Pin; diff --git a/tests/run-make-cargo/apple-slow-tls/rmake.rs b/tests/run-make-cargo/apple-slow-tls/rmake.rs index 476414bcfa1e..231e0b1668e9 100644 --- a/tests/run-make-cargo/apple-slow-tls/rmake.rs +++ b/tests/run-make-cargo/apple-slow-tls/rmake.rs @@ -26,7 +26,6 @@ fn main() { "--target", "t.json", "-Zbuild-std=std,core,panic_abort", - "-Zjson-target-spec", ]) .run(); diff --git a/tests/run-make/autodiff/type-trees/array-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/array-typetree/rmake.rs index 41805d26c6f7..20b6a0669062 100644 --- a/tests/run-make/autodiff/type-trees/array-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/array-typetree/rmake.rs @@ -4,6 +4,6 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); llvm_filecheck().patterns("array.check").stdin_buf(rfs::read("test.ll")).run(); } diff --git a/tests/run-make/autodiff/type-trees/mixed-struct-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/mixed-struct-typetree/rmake.rs index d740596907a3..1c19963bc361 100644 --- a/tests/run-make/autodiff/type-trees/mixed-struct-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/mixed-struct-typetree/rmake.rs @@ -9,7 +9,6 @@ fn main() { .arg("-Zautodiff=Enable") .arg("-Zautodiff=NoPostopt") .opt_level("0") - .arg("-Clto=fat") .emit("llvm-ir") .run(); diff --git a/tests/run-make/autodiff/type-trees/nott-flag/rmake.rs b/tests/run-make/autodiff/type-trees/nott-flag/rmake.rs index 2e93d586a353..de540b990cab 100644 --- a/tests/run-make/autodiff/type-trees/nott-flag/rmake.rs +++ b/tests/run-make/autodiff/type-trees/nott-flag/rmake.rs @@ -8,7 +8,6 @@ fn main() { rustc() .input("test.rs") .arg("-Zautodiff=Enable,NoTT") - .arg("-Clto=fat") .emit("llvm-ir") .arg("-o") .arg("nott.ll") @@ -18,7 +17,6 @@ fn main() { rustc() .input("test.rs") .arg("-Zautodiff=Enable") - .arg("-Clto=fat") .emit("llvm-ir") .arg("-o") .arg("with_tt.ll") diff --git a/tests/run-make/autodiff/type-trees/recursion-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/recursion-typetree/rmake.rs index af1eb4197b3b..78718f3a2159 100644 --- a/tests/run-make/autodiff/type-trees/recursion-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/recursion-typetree/rmake.rs @@ -4,6 +4,6 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); llvm_filecheck().patterns("recursion.check").stdin_buf(rfs::read("test.ll")).run(); } diff --git a/tests/run-make/autodiff/type-trees/scalar-types/f128-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/scalar-types/f128-typetree/rmake.rs index b1672cddb811..44320ecdd571 100644 --- a/tests/run-make/autodiff/type-trees/scalar-types/f128-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/scalar-types/f128-typetree/rmake.rs @@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { // Compile with TypeTree enabled and emit LLVM IR - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); // Check that f128 TypeTree metadata is correctly generated llvm_filecheck().patterns("f128.check").stdin_buf(rfs::read("test.ll")).run(); diff --git a/tests/run-make/autodiff/type-trees/scalar-types/f16-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/scalar-types/f16-typetree/rmake.rs index 3e308a91aaff..0aebdbf55209 100644 --- a/tests/run-make/autodiff/type-trees/scalar-types/f16-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/scalar-types/f16-typetree/rmake.rs @@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { // Compile with TypeTree enabled and emit LLVM IR - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); // Check that f16 TypeTree metadata is correctly generated llvm_filecheck().patterns("f16.check").stdin_buf(rfs::read("test.ll")).run(); diff --git a/tests/run-make/autodiff/type-trees/scalar-types/f32-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/scalar-types/f32-typetree/rmake.rs index 3faba69f5bdd..ee3ab753bf50 100644 --- a/tests/run-make/autodiff/type-trees/scalar-types/f32-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/scalar-types/f32-typetree/rmake.rs @@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { // Compile with TypeTree enabled and emit LLVM IR - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); // Check that f32 TypeTree metadata is correctly generated llvm_filecheck().patterns("f32.check").stdin_buf(rfs::read("test.ll")).run(); diff --git a/tests/run-make/autodiff/type-trees/scalar-types/f64-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/scalar-types/f64-typetree/rmake.rs index 4f1c2cec51c4..5fac9b23bc80 100644 --- a/tests/run-make/autodiff/type-trees/scalar-types/f64-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/scalar-types/f64-typetree/rmake.rs @@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { // Compile with TypeTree enabled and emit LLVM IR - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); // Check that f64 TypeTree metadata is correctly generated llvm_filecheck().patterns("f64.check").stdin_buf(rfs::read("test.ll")).run(); diff --git a/tests/run-make/autodiff/type-trees/scalar-types/i32-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/scalar-types/i32-typetree/rmake.rs index 328d690f29c8..a40fd55d88ad 100644 --- a/tests/run-make/autodiff/type-trees/scalar-types/i32-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/scalar-types/i32-typetree/rmake.rs @@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { // Compile with TypeTree enabled and emit LLVM IR - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); // Check that i32 TypeTree metadata is correctly generated llvm_filecheck().patterns("i32.check").stdin_buf(rfs::read("test.ll")).run(); diff --git a/tests/run-make/autodiff/type-trees/slice-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/slice-typetree/rmake.rs index 0cc6b42a0317..b81fb50bf1a7 100644 --- a/tests/run-make/autodiff/type-trees/slice-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/slice-typetree/rmake.rs @@ -4,6 +4,6 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); llvm_filecheck().patterns("slice.check").stdin_buf(rfs::read("test.ll")).run(); } diff --git a/tests/run-make/autodiff/type-trees/struct-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/struct-typetree/rmake.rs index 10499712d1e3..0af1b65ee181 100644 --- a/tests/run-make/autodiff/type-trees/struct-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/struct-typetree/rmake.rs @@ -4,6 +4,6 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); llvm_filecheck().patterns("struct.check").stdin_buf(rfs::read("test.ll")).run(); } diff --git a/tests/run-make/autodiff/type-trees/tuple-typetree/rmake.rs b/tests/run-make/autodiff/type-trees/tuple-typetree/rmake.rs index 4c0458f588a8..76913828901c 100644 --- a/tests/run-make/autodiff/type-trees/tuple-typetree/rmake.rs +++ b/tests/run-make/autodiff/type-trees/tuple-typetree/rmake.rs @@ -4,6 +4,6 @@ use run_make_support::{llvm_filecheck, rfs, rustc}; fn main() { - rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run(); + rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run(); llvm_filecheck().patterns("tuple.check").stdin_buf(rfs::read("test.ll")).run(); } diff --git a/tests/run-make/cdylib-export-c-library-symbols/foo.c b/tests/run-make/cdylib-export-c-library-symbols/foo.c deleted file mode 100644 index a062aca03b31..000000000000 --- a/tests/run-make/cdylib-export-c-library-symbols/foo.c +++ /dev/null @@ -1 +0,0 @@ -void my_function() {} diff --git a/tests/run-make/cdylib-export-c-library-symbols/foo.rs b/tests/run-make/cdylib-export-c-library-symbols/foo.rs deleted file mode 100644 index ac641aaed00f..000000000000 --- a/tests/run-make/cdylib-export-c-library-symbols/foo.rs +++ /dev/null @@ -1,10 +0,0 @@ -extern "C" { - pub fn my_function(); -} - -#[no_mangle] -pub extern "C" fn rust_entry() { - unsafe { - my_function(); - } -} diff --git a/tests/run-make/cdylib-export-c-library-symbols/foo_export.rs b/tests/run-make/cdylib-export-c-library-symbols/foo_export.rs deleted file mode 100644 index 1eda294ef41c..000000000000 --- a/tests/run-make/cdylib-export-c-library-symbols/foo_export.rs +++ /dev/null @@ -1,10 +0,0 @@ -extern "C" { - fn my_function(); -} - -#[no_mangle] -pub extern "C" fn rust_entry() { - unsafe { - my_function(); - } -} diff --git a/tests/run-make/cdylib-export-c-library-symbols/rmake.rs b/tests/run-make/cdylib-export-c-library-symbols/rmake.rs deleted file mode 100644 index cb237eceedad..000000000000 --- a/tests/run-make/cdylib-export-c-library-symbols/rmake.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ ignore-nvptx64 -//@ ignore-wasm -//@ ignore-cross-compile -// FIXME:The symbol mangle rules are slightly different in Windows(32-bit) and Apple. -// Need to be resolved. -//@ ignore-windows -//@ ignore-apple -// Reason: the compiled binary is executed - -use run_make_support::{build_native_static_lib, cc, dynamic_lib_name, is_darwin, llvm_nm, rustc}; - -fn main() { - cc().input("foo.c").arg("-c").out_exe("foo.o").run(); - build_native_static_lib("foo"); - - rustc().input("foo.rs").arg("-lstatic=foo").crate_type("cdylib").run(); - - let out = llvm_nm() - .input(dynamic_lib_name("foo")) - .run() - .assert_stdout_not_contains_regex("T *my_function"); - - rustc().input("foo_export.rs").arg("-lstatic:+export-symbols=foo").crate_type("cdylib").run(); - - if is_darwin() { - let out = llvm_nm() - .input(dynamic_lib_name("foo_export")) - .run() - .assert_stdout_contains("T _my_function"); - } else { - let out = llvm_nm() - .input(dynamic_lib_name("foo_export")) - .run() - .assert_stdout_contains("T my_function"); - } -} diff --git a/tests/run-make/checksum-freshness/binary_file b/tests/run-make/checksum-freshness/binary_file deleted file mode 100644 index 45f1873fb781..000000000000 --- a/tests/run-make/checksum-freshness/binary_file +++ /dev/null @@ -1 +0,0 @@ -binaryÿ \ No newline at end of file diff --git a/tests/run-make/checksum-freshness/expected.d b/tests/run-make/checksum-freshness/expected.d index 4554c509e36e..51467af53a20 100644 --- a/tests/run-make/checksum-freshness/expected.d +++ b/tests/run-make/checksum-freshness/expected.d @@ -1,8 +1,6 @@ -lib.d: lib.rs foo.rs binary_file +lib.d: lib.rs foo.rs lib.rs: foo.rs: -binary_file: -# checksum:blake3=4ac56f3f877798fb762d714c7bcb72e70133f4cc585f80dbd99c07755ae2c7f6 file_len:222 lib.rs +# checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 lib.rs # checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119 foo.rs -# checksum:blake3=119a5db8711914922c5b1c1908be4958175c5afa95c08888de594725329b5439 file_len:7 binary_file diff --git a/tests/run-make/checksum-freshness/lib.rs b/tests/run-make/checksum-freshness/lib.rs index 0cd4243423de..7bc6757959b1 100644 --- a/tests/run-make/checksum-freshness/lib.rs +++ b/tests/run-make/checksum-freshness/lib.rs @@ -1,8 +1,7 @@ // A basic library to be used in tests with no real purpose. mod foo; -// Binary file with invalid UTF-8 sequence. -static BINARY_FILE: &[u8] = include_bytes!("binary_file"); + pub fn sum(a: i32, b: i32) -> i32 { a + b } diff --git a/tests/run-make/crate-loading/multiple-dep-versions.stderr b/tests/run-make/crate-loading/multiple-dep-versions.stderr index ef7fb7082266..f8f8bfaaff6f 100644 --- a/tests/run-make/crate-loading/multiple-dep-versions.stderr +++ b/tests/run-make/crate-loading/multiple-dep-versions.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `dep_2_reexport::Type: dependency::Trait` is not satisfied +error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied --> replaced | LL | do_something(Type); - | ------------ ^^^^ the trait `dependency::Trait` is not implemented for `dep_2_reexport::Type` + | ------------ ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type` | | | required by a bound introduced by this call | @@ -17,7 +17,7 @@ LL | pub trait Trait { LL | pub trait Trait { | --------------- this is the found trait = help: you can use `cargo tree` to explore your dependency tree -help: the trait `dependency::Trait` is implemented for `dependency::Type` +help: the trait `Trait` is implemented for `dependency::Type` --> replaced | LL | impl Trait for Type { @@ -64,11 +64,11 @@ LL | pub trait Trait { | --------------- this is the trait that was imported = help: you can use `cargo tree` to explore your dependency tree -error[E0277]: the trait bound `OtherType: dependency::Trait` is not satisfied +error[E0277]: the trait bound `OtherType: Trait` is not satisfied --> replaced | LL | do_something(OtherType); - | ------------ ^^^^^^^^^ the trait `dependency::Trait` is not implemented for `OtherType` + | ------------ ^^^^^^^^^ the trait `Trait` is not implemented for `OtherType` | | | required by a bound introduced by this call | @@ -83,7 +83,7 @@ LL | pub trait Trait { LL | pub trait Trait { | --------------- this is the found trait = help: you can use `cargo tree` to explore your dependency tree -help: the trait `dependency::Trait` is implemented for `dependency::Type` +help: the trait `Trait` is implemented for `dependency::Type` --> replaced | LL | impl Trait for Type { diff --git a/tests/run-make/frontmatter-no-trailing-newline/rmake.rs b/tests/run-make/frontmatter-no-trailing-newline/rmake.rs deleted file mode 100644 index 204062201ad3..000000000000 --- a/tests/run-make/frontmatter-no-trailing-newline/rmake.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Regression test for issue #151882 -// See https://github.com/rust-lang/rust/issues/151882 - -//@ only-nightly -//@ needs-target-std - -use run_make_support::{rfs, rustc}; - -fn main() { - rfs::write("test.rs", b"----"); - - // Ensure rustc does not ICE when parsing a file with frontmatter syntax - // that has no trailing newline - rustc() - .input("test.rs") - .run_fail() - .assert_stderr_contains("invalid infostring for frontmatter") - .assert_stderr_not_contains("unexpectedly panicked"); -} diff --git a/tests/run-make/issue-149402-suggest-unresolve/foo.rs b/tests/run-make/issue-149402-suggest-unresolve/foo.rs deleted file mode 100644 index 8456990829b4..000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/foo.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn foo() { - let x = Vec::new(); - x.push(Complete::Item { name: "hello" }); -} - -fn main() {} diff --git a/tests/run-make/issue-149402-suggest-unresolve/nightly.err b/tests/run-make/issue-149402-suggest-unresolve/nightly.err deleted file mode 100644 index 8e122e3da388..000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/nightly.err +++ /dev/null @@ -1,18 +0,0 @@ -error[E0433]: cannot find type `Complete` in this scope - --> foo.rs:3:12 - | -3 | x.push(Complete::Item { name: "hello" }); - | ^^^^^^^^ use of undeclared type `Complete` - | -help: there is an enum variant `core::ops::CoroutineState::Complete` and 1 other; try using the variant's enum - | -3 - x.push(Complete::Item { name: "hello" }); -3 + x.push(core::ops::CoroutineState::Item { name: "hello" }); - | -3 - x.push(Complete::Item { name: "hello" }); -3 + x.push(std::ops::CoroutineState::Item { name: "hello" }); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0433`. diff --git a/tests/run-make/issue-149402-suggest-unresolve/output.diff b/tests/run-make/issue-149402-suggest-unresolve/output.diff deleted file mode 100644 index 196c0326a714..000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/output.diff +++ /dev/null @@ -1,16 +0,0 @@ -@@ -3,6 +3,15 @@ - | - 3 | x.push(Complete::Item { name: "hello" }); - | ^^^^^^^^ use of undeclared type `Complete` -+ | -+help: there is an enum variant `core::ops::CoroutineState::Complete` and 1 other; try using the variant's enum -+ | -+3 - x.push(Complete::Item { name: "hello" }); -+3 + x.push(core::ops::CoroutineState::Item { name: "hello" }); -+ | -+3 - x.push(Complete::Item { name: "hello" }); -+3 + x.push(std::ops::CoroutineState::Item { name: "hello" }); -+ | - - error: aborting due to 1 previous error - diff --git a/tests/run-make/issue-149402-suggest-unresolve/rmake.rs b/tests/run-make/issue-149402-suggest-unresolve/rmake.rs deleted file mode 100644 index 5bca0c0206cb..000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/rmake.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Check that unstable name-resolution suggestions are omitted on stable. -//! -//! Regression test for . -//! -//@ only-nightly -//@ needs-target-std - -use run_make_support::{diff, rustc, similar}; - -fn main() { - let stable_like = rustc() - .env("RUSTC_BOOTSTRAP", "-1") - .edition("2024") - .input("foo.rs") - .run_fail() - .stderr_utf8(); - - assert!(!stable_like.contains("CoroutineState::Complete")); - diff().expected_file("stable.err").actual_text("stable_like", &stable_like).run(); - - let nightly = rustc().edition("2024").input("foo.rs").run_fail().stderr_utf8(); - - assert!(nightly.contains("CoroutineState::Complete")); - diff().expected_file("nightly.err").actual_text("nightly", &nightly).run(); - - let stderr_diff = - similar::TextDiff::from_lines(&stable_like, &nightly).unified_diff().to_string(); - diff().expected_file("output.diff").actual_text("diff", stderr_diff).run(); -} diff --git a/tests/run-make/issue-149402-suggest-unresolve/stable.err b/tests/run-make/issue-149402-suggest-unresolve/stable.err deleted file mode 100644 index f980d4548f64..000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/stable.err +++ /dev/null @@ -1,9 +0,0 @@ -error[E0433]: cannot find type `Complete` in this scope - --> foo.rs:3:12 - | -3 | x.push(Complete::Item { name: "hello" }); - | ^^^^^^^^ use of undeclared type `Complete` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0433`. diff --git a/tests/run-make/mir-opt-bisect-limit/main.rs b/tests/run-make/mir-opt-bisect-limit/main.rs deleted file mode 100644 index 674275b10fcd..000000000000 --- a/tests/run-make/mir-opt-bisect-limit/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![crate_type = "lib"] -#![no_std] - -#[inline(never)] -pub fn callee(x: u64) -> u64 { - x.wrapping_mul(3).wrapping_add(7) -} - -pub fn caller(a: u64, b: u64) -> u64 { - callee(a) + callee(b) -} diff --git a/tests/run-make/mir-opt-bisect-limit/rmake.rs b/tests/run-make/mir-opt-bisect-limit/rmake.rs deleted file mode 100644 index fa77cb7d8c35..000000000000 --- a/tests/run-make/mir-opt-bisect-limit/rmake.rs +++ /dev/null @@ -1,119 +0,0 @@ -use std::path::Path; - -use run_make_support::{CompletedProcess, rfs, rustc}; - -struct Case { - name: &'static str, - flags: &'static [&'static str], - expect_inline_dump: bool, - expect_running: ExpectedCount, - expect_not_running: ExpectedCount, -} - -enum ExpectedCount { - Exactly(usize), - AtLeastOne, - Zero, -} - -fn main() { - let cases = [ - Case { - name: "limit0", - flags: &["-Zmir-opt-bisect-limit=0"], - expect_inline_dump: false, - expect_running: ExpectedCount::Exactly(0), - expect_not_running: ExpectedCount::AtLeastOne, - }, - Case { - name: "limit1", - flags: &["-Zmir-opt-bisect-limit=1"], - expect_inline_dump: false, - expect_running: ExpectedCount::Exactly(1), - expect_not_running: ExpectedCount::AtLeastOne, - }, - Case { - name: "huge_limit", - flags: &["-Zmir-opt-bisect-limit=1000000000"], - expect_inline_dump: true, - expect_running: ExpectedCount::AtLeastOne, - expect_not_running: ExpectedCount::Zero, - }, - Case { - name: "limit0_with_force_enable_inline", - flags: &["-Zmir-opt-bisect-limit=0", "-Zmir-enable-passes=+Inline"], - expect_inline_dump: false, - expect_running: ExpectedCount::Exactly(0), - expect_not_running: ExpectedCount::AtLeastOne, - }, - ]; - - for case in cases { - let (inline_dumped, running_count, not_running_count, output) = - compile_case(case.name, case.flags); - - assert_eq!( - inline_dumped, case.expect_inline_dump, - "{}: unexpected Inline dump presence", - case.name - ); - - assert_expected_count( - running_count, - case.expect_running, - &format!("{}: running count", case.name), - ); - assert_expected_count( - not_running_count, - case.expect_not_running, - &format!("{}: NOT running count", case.name), - ); - } -} - -fn compile_case(dump_dir: &str, extra_flags: &[&str]) -> (bool, usize, usize, CompletedProcess) { - if Path::new(dump_dir).exists() { - rfs::remove_dir_all(dump_dir); - } - rfs::create_dir_all(dump_dir); - - let mut cmd = rustc(); - cmd.input("main.rs") - .arg("--emit=mir") - .arg("-Zmir-opt-level=2") - .arg("-Copt-level=2") - .arg("-Zthreads=1") - .arg("-Zdump-mir=Inline") - .arg(format!("-Zdump-mir-dir={dump_dir}")); - - for &flag in extra_flags { - cmd.arg(flag); - } - - let output = cmd.run(); - let (running_count, not_running_count) = bisect_line_counts(&output); - (has_inline_dump_file(dump_dir), running_count, not_running_count, output) -} - -fn assert_expected_count(actual: usize, expected: ExpectedCount, context: &str) { - match expected { - ExpectedCount::Exactly(n) => assert_eq!(actual, n, "{context}"), - ExpectedCount::AtLeastOne => assert!(actual > 0, "{context}"), - ExpectedCount::Zero => assert_eq!(actual, 0, "{context}"), - } -} - -fn has_inline_dump_file(dir: &str) -> bool { - rfs::read_dir(dir) - .flatten() - .any(|entry| entry.file_name().to_string_lossy().contains(".Inline.")) -} - -fn bisect_line_counts(output: &CompletedProcess) -> (usize, usize) { - let stderr = output.stderr_utf8(); - let running_count = - stderr.lines().filter(|line| line.starts_with("BISECT: running pass (")).count(); - let not_running_count = - stderr.lines().filter(|line| line.starts_with("BISECT: NOT running pass (")).count(); - (running_count, not_running_count) -} diff --git a/tests/run-make/remap-path-prefix-consts/rmake.rs b/tests/run-make/remap-path-prefix-consts/rmake.rs index 07b5e2f97414..d07a5e00768a 100644 --- a/tests/run-make/remap-path-prefix-consts/rmake.rs +++ b/tests/run-make/remap-path-prefix-consts/rmake.rs @@ -97,7 +97,7 @@ fn main() { location_caller .crate_type("lib") .remap_path_prefix(cwd(), "/remapped") - .arg("--remap-path-scope=object") + .arg("-Zremap-path-scope=object") .input(cwd().join("location-caller.rs")); location_caller.run(); @@ -105,7 +105,7 @@ fn main() { runner .crate_type("bin") .remap_path_prefix(cwd(), "/remapped") - .arg("--remap-path-scope=diagnostics") + .arg("-Zremap-path-scope=diagnostics") .input(cwd().join("runner.rs")) .output(&runner_bin); runner.run(); diff --git a/tests/run-make/remap-path-prefix-dwarf/rmake.rs b/tests/run-make/remap-path-prefix-dwarf/rmake.rs index ab6c1fb70d68..3b88fca0bb7f 100644 --- a/tests/run-make/remap-path-prefix-dwarf/rmake.rs +++ b/tests/run-make/remap-path-prefix-dwarf/rmake.rs @@ -105,7 +105,7 @@ fn check_dwarf_deps(scope: &str, dwarf_test: DwarfDump) { let mut rustc_sm = rustc(); rustc_sm.input(cwd().join("src/some_value.rs")); rustc_sm.arg("-Cdebuginfo=2"); - rustc_sm.arg(format!("--remap-path-scope={}", scope)); + rustc_sm.arg(format!("-Zremap-path-scope={}", scope)); rustc_sm.arg("--remap-path-prefix"); rustc_sm.arg(format!("{}=/REMAPPED", cwd().display())); rustc_sm.arg("-Csplit-debuginfo=off"); @@ -117,7 +117,7 @@ fn check_dwarf_deps(scope: &str, dwarf_test: DwarfDump) { rustc_pv.input(cwd().join("src/print_value.rs")); rustc_pv.output(&print_value_rlib); rustc_pv.arg("-Cdebuginfo=2"); - rustc_pv.arg(format!("--remap-path-scope={}", scope)); + rustc_pv.arg(format!("-Zremap-path-scope={}", scope)); rustc_pv.arg("--remap-path-prefix"); rustc_pv.arg(format!("{}=/REMAPPED", cwd().display())); rustc_pv.arg("-Csplit-debuginfo=off"); @@ -158,8 +158,8 @@ fn check_dwarf(test: DwarfTest) { rustc.arg("-Cdebuginfo=2"); if let Some(scope) = test.scope { match scope { - ScopeType::Object => rustc.arg("--remap-path-scope=object"), - ScopeType::Diagnostics => rustc.arg("--remap-path-scope=diagnostics"), + ScopeType::Object => rustc.arg("-Zremap-path-scope=object"), + ScopeType::Diagnostics => rustc.arg("-Zremap-path-scope=diagnostics"), }; if is_darwin() { rustc.arg("-Csplit-debuginfo=off"); diff --git a/tests/run-make/remap-path-prefix/rmake.rs b/tests/run-make/remap-path-prefix/rmake.rs index 3b866476e950..b75ca9e796ac 100644 --- a/tests/run-make/remap-path-prefix/rmake.rs +++ b/tests/run-make/remap-path-prefix/rmake.rs @@ -12,9 +12,7 @@ fn main() { let mut out_simple = rustc(); let mut out_object = rustc(); let mut out_macro = rustc(); - let mut out_doc = rustc(); let mut out_diagobj = rustc(); - let mut out_diagdocobj = rustc(); out_simple .remap_path_prefix("auxiliary", "/the/aux") .crate_type("lib") @@ -30,39 +28,23 @@ fn main() { .crate_type("lib") .emit("metadata") .input("auxiliary/lib.rs"); - out_doc - .remap_path_prefix("auxiliary", "/the/aux") - .crate_type("lib") - .emit("metadata") - .input("auxiliary/lib.rs"); out_diagobj .remap_path_prefix("auxiliary", "/the/aux") .crate_type("lib") .emit("metadata") .input("auxiliary/lib.rs"); - out_diagdocobj - .remap_path_prefix("auxiliary", "/the/aux") - .crate_type("lib") - .emit("metadata") - .input("auxiliary/lib.rs"); out_simple.run(); rmeta_contains("/the/aux/lib.rs"); rmeta_not_contains("auxiliary"); - out_object.arg("--remap-path-scope=object"); - out_macro.arg("--remap-path-scope=macro"); - out_doc.arg("--remap-path-scope=documentation").arg("-Zunstable-options"); - out_diagobj.arg("--remap-path-scope=diagnostics,object"); - out_diagdocobj - .arg("--remap-path-scope=diagnostics,documentation,object") - .arg("-Zunstable-options"); + out_object.arg("-Zremap-path-scope=object"); + out_macro.arg("-Zremap-path-scope=macro"); + out_diagobj.arg("-Zremap-path-scope=diagnostics,object"); if is_darwin() { out_object.arg("-Csplit-debuginfo=off"); out_macro.arg("-Csplit-debuginfo=off"); - out_doc.arg("-Csplit-debuginfo=off"); out_diagobj.arg("-Csplit-debuginfo=off"); - out_diagdocobj.arg("-Csplit-debuginfo=off"); } out_object.run(); @@ -71,14 +53,8 @@ fn main() { out_macro.run(); rmeta_contains("/the/aux/lib.rs"); rmeta_contains("auxiliary"); - out_doc.run(); - rmeta_contains("/the/aux/lib.rs"); - rmeta_contains("auxiliary"); out_diagobj.run(); rmeta_contains("/the/aux/lib.rs"); - rmeta_contains("auxiliary"); - out_diagdocobj.run(); - rmeta_contains("/the/aux/lib.rs"); rmeta_not_contains("auxiliary"); } diff --git a/tests/run-make/reproducible-build/rmake.rs b/tests/run-make/reproducible-build/rmake.rs index 993c2c8092a6..93fc30de07d7 100644 --- a/tests/run-make/reproducible-build/rmake.rs +++ b/tests/run-make/reproducible-build/rmake.rs @@ -199,9 +199,13 @@ fn diff_dir_test(crate_type: CrateType, remap_type: RemapType) { .arg(format!("--remap-path-prefix={}=/b", base_dir.join("test").display())); } RemapType::Cwd { is_empty } => { + // FIXME(Oneirical): Building with crate type set to `bin` AND having -Cdebuginfo=2 + // (or `-g`, the shorthand form) enabled will cause reproducibility failures + // for multiple platforms. + // See https://github.com/rust-lang/rust/issues/89911 // FIXME(#129117): Windows rlib + `-Cdebuginfo=2` + `-Z remap-cwd-prefix=.` seems // to be unreproducible. - if !is_windows() { + if !matches!(crate_type, CrateType::Bin) && !is_windows() { compiler1.arg("-Cdebuginfo=2"); compiler2.arg("-Cdebuginfo=2"); } diff --git a/tests/run-make/rust-lld-custom-target/rmake.rs b/tests/run-make/rust-lld-custom-target/rmake.rs index d281d820f47b..90ba424ffe94 100644 --- a/tests/run-make/rust-lld-custom-target/rmake.rs +++ b/tests/run-make/rust-lld-custom-target/rmake.rs @@ -15,11 +15,7 @@ fn main() { // Compile to a custom target spec with rust-lld enabled by default. We'll check that by asking // the linker to display its version number with a link-arg. assert_rustc_uses_lld( - rustc() - .crate_type("cdylib") - .target("custom-target.json") - .arg("-Zunstable-options") - .input("lib.rs"), + rustc().crate_type("cdylib").target("custom-target.json").input("lib.rs"), ); // But it can also be disabled via linker features. diff --git a/tests/run-make/rustc-help/help-v.diff b/tests/run-make/rustc-help/help-v.diff index 94ed6a0ed027..60a9dfbe201d 100644 --- a/tests/run-make/rustc-help/help-v.diff +++ b/tests/run-make/rustc-help/help-v.diff @@ -1,4 +1,4 @@ -@@ -65,10 +65,31 @@ +@@ -65,10 +65,28 @@ Set a codegen option -V, --version Print version info and exit -v, --verbose Use verbose output @@ -20,9 +20,6 @@ + --remap-path-prefix = + Remap source names in all output (compiler messages + and output files) -+ --remap-path-scope -+ Defines which scopes of paths should be remapped by -+ `--remap-path-prefix` + @path Read newline separated options from `path` Additional help: diff --git a/tests/run-make/rustc-help/help-v.stdout b/tests/run-make/rustc-help/help-v.stdout index 0acbb766c155..cf055e220c0d 100644 --- a/tests/run-make/rustc-help/help-v.stdout +++ b/tests/run-make/rustc-help/help-v.stdout @@ -83,9 +83,6 @@ Options: --remap-path-prefix = Remap source names in all output (compiler messages and output files) - --remap-path-scope - Defines which scopes of paths should be remapped by - `--remap-path-prefix` @path Read newline separated options from `path` Additional help: diff --git a/tests/run-make/rustc-help/rmake.rs b/tests/run-make/rustc-help/rmake.rs index 17811ef18449..85e90e6352d0 100644 --- a/tests/run-make/rustc-help/rmake.rs +++ b/tests/run-make/rustc-help/rmake.rs @@ -18,34 +18,4 @@ fn main() { // Check the diff between `rustc --help` and `rustc --help -v`. let help_v_diff = similar::TextDiff::from_lines(&help, &help_v).unified_diff().to_string(); diff().expected_file("help-v.diff").actual_text("actual", &help_v_diff).run(); - - // Check that all help options can be invoked at once - let codegen_help = bare_rustc().arg("-Chelp").run().stdout_utf8(); - let unstable_help = bare_rustc().arg("-Zhelp").run().stdout_utf8(); - let lints_help = bare_rustc().arg("-Whelp").run().stdout_utf8(); - let expected_all = format!("{help}{codegen_help}{unstable_help}{lints_help}"); - let all_help = bare_rustc().args(["--help", "-Chelp", "-Zhelp", "-Whelp"]).run().stdout_utf8(); - diff() - .expected_text( - "(rustc --help && rustc -Chelp && rustc -Zhelp && rustc -Whelp)", - &expected_all, - ) - .actual_text("(rustc --help -Chelp -Zhelp -Whelp)", &all_help) - .run(); - - // Check that the ordering of help options is respected - // Note that this is except for `-Whelp`, which always comes last - let expected_ordered_help = format!("{unstable_help}{codegen_help}{help}{lints_help}"); - let ordered_help = - bare_rustc().args(["-Whelp", "-Zhelp", "-Chelp", "--help"]).run().stdout_utf8(); - diff() - .expected_text( - "(rustc -Whelp && rustc -Zhelp && rustc -Chelp && rustc --help)", - &expected_ordered_help, - ) - .actual_text("(rustc -Whelp -Zhelp -Chelp --help)", &ordered_help) - .run(); - - // Test that `rustc --help` does not suppress invalid flag errors - let help = bare_rustc().arg("--help --invalid-flag").run_fail().stdout_utf8(); } diff --git a/tests/run-make/rustdoc-target-spec-json-path/rmake.rs b/tests/run-make/rustdoc-target-spec-json-path/rmake.rs index 8660556564f1..d43aa9b90ac7 100644 --- a/tests/run-make/rustdoc-target-spec-json-path/rmake.rs +++ b/tests/run-make/rustdoc-target-spec-json-path/rmake.rs @@ -5,14 +5,8 @@ use run_make_support::{cwd, rustc, rustdoc}; fn main() { let out_dir = "rustdoc-target-spec-json-path"; - rustc() - .arg("-Zunstable-options") - .crate_type("lib") - .input("dummy_core.rs") - .target("target.json") - .run(); + rustc().crate_type("lib").input("dummy_core.rs").target("target.json").run(); rustdoc() - .arg("-Zunstable-options") .input("my_crate.rs") .out_dir(out_dir) .library_search_path(cwd()) diff --git a/tests/run-make/short-ice/rmake.rs b/tests/run-make/short-ice/rmake.rs index 043f880abcf7..dbe0f692aefb 100644 --- a/tests/run-make/short-ice/rmake.rs +++ b/tests/run-make/short-ice/rmake.rs @@ -12,53 +12,40 @@ // - FIXME(#143198): On `x86_64-pc-windows-msvc`: full backtrace sometimes do not contain matching // count of short backtrace markers (e.g. 5x end marker, but 3x start marker). -use run_make_support::CompletedProcess; +use run_make_support::rustc; fn main() { - // Run the same command twice with `RUST_BACKTRACE=1` and `RUST_BACKTRACE=full`. - let configure_rustc = || { - let mut rustc = run_make_support::rustc(); - rustc.input("src/lib.rs").arg("-Ztreat-err-as-bug=1"); - rustc - }; - let rustc_bt_short = configure_rustc().set_backtrace_level("1").run_fail(); - let rustc_bt_full = configure_rustc().set_backtrace_level("full").run_fail(); + let rust_test_1 = + rustc().set_backtrace_level("1").input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); + let rust_test_2 = rustc() + .set_backtrace_level("full") + .input("src/lib.rs") + .arg("-Ztreat-err-as-bug=1") + .run_fail(); - // Combine stderr and stdout for subsequent checks. - let concat_stderr_stdout = - |proc: &CompletedProcess| format!("{}\n{}", proc.stderr_utf8(), proc.stdout_utf8()); - let output_bt_short = &concat_stderr_stdout(&rustc_bt_short); - let output_bt_full = &concat_stderr_stdout(&rustc_bt_full); + let mut rust_test_log_1 = rust_test_1.stderr_utf8(); + rust_test_log_1.push_str(&rust_test_1.stdout_utf8()); + let rust_test_log_1 = rust_test_log_1.as_str(); - // Count how many lines of output mention symbols or paths in - // `rustc_query_impl`, which are the kinds of - // stack frames we want to be omitting in short backtraces. - let rustc_query_count_short = count_lines_with(output_bt_short, "rustc_query_impl"); - let rustc_query_count_full = count_lines_with(output_bt_full, "rustc_query_impl"); + let mut rust_test_log_2 = rust_test_2.stderr_utf8(); + rust_test_log_2.push_str(&rust_test_2.stdout_utf8()); + let rust_test_log_2 = rust_test_log_2.as_str(); - // Dump both outputs in full to make debugging easier, especially on CI. - // Use `--no-capture --force-rerun` to view output even when the test is passing. - println!("=== BEGIN SHORT BACKTRACE ===\n{output_bt_short}\n=== END SHORT BACKTRACE === "); - println!("=== BEGIN FULL BACKTRACE ===\n{output_bt_full}\n=== END FULL BACKTRACE === "); + let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_"); assert!( - output_bt_short.lines().count() < output_bt_full.lines().count(), - "Short backtrace should be shorter than full backtrace" + rust_test_log_1.lines().count() < rust_test_log_2.lines().count(), + "Short backtrace should be shorter than full backtrace.\nShort backtrace:\n\ + {rust_test_log_1}\nFull backtrace:\n{rust_test_log_2}" ); - - let n_begin = count_lines_with(output_bt_full, "__rust_begin_short_backtrace"); - let n_end = count_lines_with(output_bt_full, "__rust_end_short_backtrace"); - assert!(n_begin + n_end > 0, "Full backtrace should contain short-backtrace markers"); assert_eq!( - n_begin, n_end, - "Full backtrace should contain equal numbers of begin and end markers" - ); - - assert!( - rustc_query_count_short + 5 < rustc_query_count_full, - "Short backtrace should have omitted more query plumbing lines \ - (actual: {rustc_query_count_short} vs {rustc_query_count_full})" + count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace"), + count_lines_with(rust_test_log_2, "__rust_end_short_backtrace"), + "Full backtrace should contain the short backtrace markers.\nFull backtrace:\n\ + {rust_test_log_2}" ); + assert!(count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full); + assert!(rustc_query_count_full > 5); } fn count_lines_with(s: &str, search: &str) -> usize { diff --git a/tests/run-make/split-debuginfo/rmake.rs b/tests/run-make/split-debuginfo/rmake.rs index 0d311607a11a..e53b71010781 100644 --- a/tests/run-make/split-debuginfo/rmake.rs +++ b/tests/run-make/split-debuginfo/rmake.rs @@ -171,7 +171,8 @@ enum RemapPathPrefix { Unspecified, } -/// `--remap-path-scope` +/// `-Zremap-path-scope`. See +/// . #[derive(Debug, Clone)] enum RemapPathScope { /// Comma-separated list of remap scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`. @@ -920,7 +921,7 @@ mod shared_linux_other_tests { .debuginfo(level.cli_value()) .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) .remap_path_prefix(cwd(), remapped_prefix) - .arg(format!("--remap-path-scope={scope}")) + .arg(format!("-Zremap-path-scope={scope}")) .run(); let found_files = cwd_filenames(); FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } @@ -949,7 +950,7 @@ mod shared_linux_other_tests { .debuginfo(level.cli_value()) .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) .remap_path_prefix(cwd(), remapped_prefix) - .arg(format!("--remap-path-scope={scope}")) + .arg(format!("-Zremap-path-scope={scope}")) .run(); let found_files = cwd_filenames(); FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } @@ -1201,7 +1202,7 @@ mod shared_linux_other_tests { .debuginfo(level.cli_value()) .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) .remap_path_prefix(cwd(), remapped_prefix) - .arg(format!("--remap-path-scope={scope}")) + .arg(format!("-Zremap-path-scope={scope}")) .run(); let found_files = cwd_filenames(); @@ -1241,7 +1242,7 @@ mod shared_linux_other_tests { .debuginfo(level.cli_value()) .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) .remap_path_prefix(cwd(), remapped_prefix) - .arg(format!("--remap-path-scope={scope}")) + .arg(format!("-Zremap-path-scope={scope}")) .run(); let found_files = cwd_filenames(); @@ -1355,7 +1356,7 @@ fn main() { // NOTE: these combinations are not exhaustive, because while porting to rmake.rs initially I // tried to preserve the existing test behavior closely. Notably, no attempt was made to // exhaustively cover all cases in the 6-fold Cartesian product of `{,-Csplit=debuginfo=...}` x - // `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,--remap-path-scope=...}` x + // `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,-Zremap-path-scope=...}` x // `{,-Zsplit-dwarf-kind=...}` x `{,-Clinker-plugin-lto}`. If you really want to, you can // identify which combination isn't exercised with a 6-layers nested for loop iterating through // each of the cli flag enum variants. diff --git a/tests/run-make/target-specs/rmake.rs b/tests/run-make/target-specs/rmake.rs index 6c88f3164e9e..69292af5fd69 100644 --- a/tests/run-make/target-specs/rmake.rs +++ b/tests/run-make/target-specs/rmake.rs @@ -20,20 +20,13 @@ fn main() { .target("my-incomplete-platform.json") .run_fail() .assert_stderr_contains("missing field `llvm-target`"); - let _ = rustc() + let test_platform = rustc() .input("foo.rs") .target("my-x86_64-unknown-linux-gnu-platform") .crate_type("lib") .emit("asm") .run_fail() .assert_stderr_contains("custom targets are unstable and require `-Zunstable-options`"); - let _ = rustc() - .input("foo.rs") - .target("my-awesome-platform.json") - .crate_type("lib") - .emit("asm") - .run_fail() - .assert_stderr_contains("custom targets are unstable and require `-Zunstable-options`"); rustc() .arg("-Zunstable-options") .env("RUST_TARGET_PATH", ".") diff --git a/tests/run-make/translation/rmake.rs b/tests/run-make/translation/rmake.rs index 4d7fd71a2f4a..86078888c2e1 100644 --- a/tests/run-make/translation/rmake.rs +++ b/tests/run-make/translation/rmake.rs @@ -10,9 +10,6 @@ //@ needs-symlink //@ needs-subprocess -// FIXME(151366) Currently `-Ztranslate-additional-ftl` is currently broken -//@ ignore-test - #![deny(warnings)] use std::path::{Path, PathBuf}; diff --git a/tests/run-make/wasm-emscripten-cdylib/foo.rs b/tests/run-make/wasm-emscripten-cdylib/foo.rs deleted file mode 100644 index 08ad8e7b5c61..000000000000 --- a/tests/run-make/wasm-emscripten-cdylib/foo.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[no_mangle] -pub extern "C" fn foo() -> i32 { - 42 -} diff --git a/tests/run-make/wasm-emscripten-cdylib/rmake.rs b/tests/run-make/wasm-emscripten-cdylib/rmake.rs deleted file mode 100644 index ef5fc17c2bbe..000000000000 --- a/tests/run-make/wasm-emscripten-cdylib/rmake.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! Check that cdylib crate type is supported for the wasm32-unknown-emscripten -//! target and produces a valid Emscripten dynamic library. - -//@ only-wasm32-unknown-emscripten - -use run_make_support::{bare_rustc, rfs, wasmparser}; - -fn main() { - bare_rustc().input("foo.rs").target("wasm32-unknown-emscripten").crate_type("cdylib").run(); - - // Verify the output is a valid wasm file with a dylink.0 section - let file = rfs::read("foo.wasm"); - let mut has_dylink = false; - - for payload in wasmparser::Parser::new(0).parse_all(&file) { - let payload = payload.unwrap(); - if let wasmparser::Payload::CustomSection(s) = payload { - if s.name() == "dylink.0" { - has_dylink = true; - } - } - } - - assert!(has_dylink, "expected dylink.0 section in emscripten cdylib output"); -} diff --git a/tests/rustdoc-gui/headings.goml b/tests/rustdoc-gui/headings.goml index 391234b78ebd..94d80a3e3df5 100644 --- a/tests/rustdoc-gui/headings.goml +++ b/tests/rustdoc-gui/headings.goml @@ -221,14 +221,14 @@ call-function: ( define-function: ( "check-since-color", - [theme, color], + [theme], block { call-function: ("switch-theme", {"theme": |theme|}) - assert-css: (".since", {"color": |color|}, ALL) + assert-css: (".since", {"color": "#808080"}, ALL) }, ) go-to: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" -call-function: ("check-since-color", {"theme": "ayu", "color": "#808080"}) -call-function: ("check-since-color", {"theme": "dark", "color": "#d0d0d0"}) -call-function: ("check-since-color", {"theme": "light", "color": "#808080"}) +call-function: ("check-since-color", {"theme": "ayu"}) +call-function: ("check-since-color", {"theme": "dark"}) +call-function: ("check-since-color", {"theme": "light"}) diff --git a/tests/rustdoc-gui/mobile-topbar-menu-popovers.goml b/tests/rustdoc-gui/mobile-topbar-menu-popovers.goml deleted file mode 100644 index 29a2096bba89..000000000000 --- a/tests/rustdoc-gui/mobile-topbar-menu-popovers.goml +++ /dev/null @@ -1,34 +0,0 @@ -// Ensure that topbar popover menus content can be scrolled on mobile. -go-to: "file://" + |DOC_PATH| + "/lib2/index.html" -store-value: (window_height, 500) -set-window-size: (400, |window_height|) - -include: "utils.goml" - -// We open the settings menu -call-function: ("open-settings-menu", {}) -// We ensure it's not scrolled down yet. -assert-property: ("#settings .settings", {"scrollTop": 0}) -// We ensure its height is smaller than the window's, but its content's height is bigger. -store-property: ("#settings .settings", {"offsetHeight": menu_height, "scrollHeight": scroll_height}) -assert: |menu_height| < |window_height| && |scroll_height| > |window_height| - -// We scroll to the last element of the menu. -scroll-to: "#settings .setting-line:last-of-type input" -// The item should be visible now, and so the Y scroll value should have changed. -// Note: The `scrollTop` value will change if settings are added or removed. -assert-property: ("#settings .settings", {"scrollTop": 335}) - -// Now we open the help menu. -click: ".help-menu a" -wait-for: "#help" -// We ensure it's not scrolled down yet. -assert-property: ("#help .content", {"scrollTop": 0}) -// We ensure its height is smaller than the window's, but its content's height is bigger. -store-property: ("#help .content", {"offsetHeight": menu_height, "scrollHeight": scroll_height}) -assert: |menu_height| < |window_height| && |scroll_height| > |window_height| - -// We scroll to the last element of the menu. -scroll-to: "#help .infos > :last-child" -// The item should be visible now, and so the Y scroll value should have changed. -assert-property: ("#help .content", {"scrollTop": 339}) diff --git a/tests/rustdoc-gui/setting-hide-deprecated.goml b/tests/rustdoc-gui/setting-hide-deprecated.goml deleted file mode 100644 index 0fefe00f9457..000000000000 --- a/tests/rustdoc-gui/setting-hide-deprecated.goml +++ /dev/null @@ -1,107 +0,0 @@ -// Test that the "hide deprecated" setting is correctly handled. - -include: "utils.goml" - -go-to: "file://" + |DOC_PATH| + "/lib2/deprecated/index.html" -store-value: (deprecated_class, ".deprecated") - -// There should be two deprecated items listed on the module page: -// `DeprecatedStruct` and `DeprecatedTrait`. -assert-count: ("dt" + |deprecated_class|, 2) -// `DeprecatedStruct` and `DeprecatedTrait` should be displayed for now. -assert-css: ("dt" + |deprecated_class|, {"display": "block"}, ALL) - -// We enable the "hide deprecated items" setting. -call-function: ("open-settings-menu", {}) -click: "#hide-deprecated-items" -// None of them should be displayed anymore. -wait-for-css: ("dt" + |deprecated_class|, {"display": "none"}, ALL) - -// We disable the setting. -click: "#hide-deprecated-items" -// All of them should be displayed back. -wait-for-css: ("dt" + |deprecated_class|, {"display": "block"}, ALL) - -// Now we go to a trait with a deprecated method and a deprecated associated const. -go-to: "file://" + |DOC_PATH| + "/lib2/deprecated/trait.NormalTrait.html" - -// There should be two deprecated items. -assert-count: ("details" + |deprecated_class|, 2) -// They should be displayed for now. -assert-css: ("details" + |deprecated_class|, {"display": "block"}, ALL) - -// We enable the "hide deprecated items" setting. -call-function: ("open-settings-menu", {}) -click: "#hide-deprecated-items" - -// They shouldn't be displayed anymore. -wait-for-css: ("details" + |deprecated_class|, {"display": "none"}, ALL) - -// We disable the setting. -click: "#hide-deprecated-items" -// All of them should be displayed back. -wait-for-css: ("details" + |deprecated_class|, {"display": "block"}, ALL) - -// We now go to a struct with a deprecated method which implements a deprecated trait and a trait -// with deprecated associated items. -go-to: "file://" + |DOC_PATH| + "/lib2/deprecated/struct.NonDeprecatedStruct.html" - -// There should be five deprecated items (six minus one "future" deprecated)... -assert-count: ("details" + |deprecated_class|, 5) -// One of which being a deprecated impl because the trait itself is deprecated. -assert-count: ("details.implementors-toggle" + |deprecated_class|, 1) -// And another has `since = "TBD"` and should NOT have the `deprecated` class. -assert: "details:not(" + |deprecated_class| + ") #method\.future_deprecated_fn" -// They should all be displayed for now. -assert-css: ("details" + |deprecated_class|, {"display": "block"}, ALL) - -// We enable the "hide deprecated items" setting. -call-function: ("open-settings-menu", {}) -click: "#hide-deprecated-items" - -// They shouldn't be displayed anymore. -wait-for-css: ("details" + |deprecated_class|, {"display": "none"}, ALL) - -// We disable the setting. -click: "#hide-deprecated-items" -// All of them should be displayed back. -wait-for-css: ("details" + |deprecated_class|, {"display": "block"}, ALL) - -// And now we check with the search results. -call-function: ("perform-search", {"query": "deprecated::depr"}) -// There should be at least 7 results. -store-count: ("#results ul.search-results.active > a", nb_search_results) -assert: |nb_search_results| >= 7 -// There should be at least 5 deprecated items. -store-count: ("#results ul.search-results.active > a" + |deprecated_class|, nb_deprecated_results) -assert: |nb_search_results| >= 5 -// Deprecated items should all be displayed. -assert-css: ("#results ul.search-results.active > a" + |deprecated_class|, {"display": "grid"}, ALL) -// The "X deprecated items hidden by setting" element should not be displayed. -assert-text: ( - "#results ul.search-results.active .deprecated-count", - "5 deprecated items hidden by setting", -) -assert-css: ("#results ul.search-results.active .deprecated-count", {"display": "none"}) -// We enable the "hide deprecated items" setting. -call-function: ("open-settings-menu", {}) -click: "#hide-deprecated-items" -// None of them should be displayed anymore. -wait-for-css: ( - "#results ul.search-results.active > a" + |deprecated_class|, - {"display": "none"}, - ALL, -) -// The "X deprecated items hidden by setting" element should be displayed. -assert-css: ("#results ul.search-results.active .deprecated-count", {"display": "block"}) - -// Finally we check that the future deprecated item doesn't have the deprecated class in the search -// and therefore isn't impacted by the setting. -call-function: ("perform-search", {"query": '"future_deprecated_fn"'}) -assert-text: ( - "#results ul.search-results.active > a:not(" + |deprecated_class| + ") .path", - " lib2::deprecated::NonDeprecatedStruct::future_deprecated_fn", -) -// The "X deprecated items hidden by setting" element should now be empty, and therefore not displayed. -assert-text: ("#results ul.search-results.active .deprecated-count", "") -assert-css: ("#results ul.search-results.active .deprecated-count", {"display": "none"}) diff --git a/tests/rustdoc-gui/skip-navigation.goml b/tests/rustdoc-gui/skip-navigation.goml deleted file mode 100644 index 50cb2d38b3e0..000000000000 --- a/tests/rustdoc-gui/skip-navigation.goml +++ /dev/null @@ -1,19 +0,0 @@ -// This test ensures that the "Skip to main content" link works correctly -// for keyboard navigation (WCAG 2.4.1 compliance). -go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" - -// The skip link should be hidden initially (positioned off-screen above viewport) -store-position: (".skip-main-content", {"y": y_before}) -store-size: (".skip-main-content", {"height": height_before}) -assert: |y_before| + |height_before| < 0 - -// The skip link should be the first focusable element when pressing Tab -press-key: "Tab" -wait-for: ".skip-main-content:focus" - -// When focused, the link should be visible (top: 0px) -assert-css: (".skip-main-content:focus", {"top": "0px"}) - -// Pressing Enter on the skip link should move focus to main content -press-key: "Enter" -wait-for: "#main-content:focus" diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs index 1367b17b37b2..b87fdeea89da 100644 --- a/tests/rustdoc-gui/src/lib2/lib.rs +++ b/tests/rustdoc-gui/src/lib2/lib.rs @@ -368,46 +368,3 @@ impl std::ops::Deref for Derefer { &self.0 } } - -pub mod deprecated { - #[deprecated(since = "1.26.0", note = "deprecated")] - pub struct DeprecatedStruct; - - pub struct NonDeprecatedStruct; - - pub trait NormalTrait { - #[deprecated(since = "1.26.0", note = "deprecated")] - /// doc - const X: usize = 12; - - #[deprecated(since = "1.26.0", note = "deprecated")] - /// doc - fn normal_deprecated_fn(); - } - - #[deprecated(since = "1.26.0", note = "deprecated")] - pub trait DeprecatedTrait { - fn depr_deprecated_fn(); - } - - impl NonDeprecatedStruct { - #[deprecated(since = "1.26.0", note = "deprecated")] - /// doc - pub fn deprecated_fn() {} - - /// doc - pub fn non_deprecated_fn() {} - - #[deprecated(since = "TBD", note = "deprecated")] - /// doc - pub fn future_deprecated_fn() {} - } - - impl NormalTrait for NonDeprecatedStruct { - fn normal_deprecated_fn() {} - } - - impl DeprecatedTrait for NonDeprecatedStruct { - fn depr_deprecated_fn() {} - } -} diff --git a/tests/rustdoc-gui/utils.goml b/tests/rustdoc-gui/utils.goml index 53ea91b929fe..c5c8ab3b1af8 100644 --- a/tests/rustdoc-gui/utils.goml +++ b/tests/rustdoc-gui/utils.goml @@ -77,41 +77,19 @@ define-function: ( }, ) -define-function: ( - "open-search", - [], - block { - store-count: (".search-input", __search_input_count) - if: (|__search_input_count| != 0, block { - store-css: ("#alternative-display", {"display": __search_input_display}) - }) - else: block { - // Block requests with doubled `//`. - // Amazon S3 doesn't support them, but other web hosts do, - // and so do file:/// URLs, which means we need to block - // it here if we want to avoid breaking the main docs site. - // https://github.com/rust-lang/rust/issues/145646 - block-network-request: "file://*//*" - store-value: (__search_input_display, "none") - } - - if: (|__search_input_display| == "none", block { - // Open search - click: "#search-button" - wait-for: ".search-input" - }) - } -) - define-function: ( "perform-search", [query], block { - call-function: ("open-search", {}) - // We empty the search input in case it wasn't empty. - set-property: (".search-input", {"value": ""}) - focus: ".search-input" - // We write the actual query. + // Block requests with doubled `//`. + // Amazon S3 doesn't support them, but other web hosts do, + // and so do file:/// URLs, which means we need to block + // it here if we want to avoid breaking the main docs site. + // https://github.com/rust-lang/rust/issues/145646 + block-network-request: "file://*//*" + // Perform search + click: "#search-button" + wait-for: ".search-input" write-into: (".search-input", |query|) press-key: 'Enter' // wait for the search to start diff --git a/tests/rustdoc-html/auto/auto-trait-bounds-by-associated-type-50159.rs b/tests/rustdoc-html/auto/auto-trait-bounds-by-associated-type-50159.rs index 14981783e5f3..2803c4da437f 100644 --- a/tests/rustdoc-html/auto/auto-trait-bounds-by-associated-type-50159.rs +++ b/tests/rustdoc-html/auto/auto-trait-bounds-by-associated-type-50159.rs @@ -20,8 +20,7 @@ where //@ has - '//h3[@class="code-header"]' 'impl Send for Switchwhere ::Item: Send' //@ has - '//h3[@class="code-header"]' 'impl Sync for Switchwhere ::Item: Sync' //@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 7 -// The number here will need updating when new auto traits are added: ^ +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 pub struct Switch { pub inner: ::Item2, } diff --git a/tests/rustdoc-html/constant/ice-associated-const-equality-105952.rs b/tests/rustdoc-html/constant/ice-associated-const-equality-105952.rs index bdb82b91ec27..310e56b917fc 100644 --- a/tests/rustdoc-html/constant/ice-associated-const-equality-105952.rs +++ b/tests/rustdoc-html/constant/ice-associated-const-equality-105952.rs @@ -10,7 +10,8 @@ pub enum ParseMode { Raw, } pub trait Parse { - type const PARSE_MODE: ParseMode; + #[type_const] + const PARSE_MODE: ParseMode; } pub trait RenderRaw {} diff --git a/tests/rustdoc-html/display-hidden-items.rs b/tests/rustdoc-html/display-hidden-items.rs index 6b548e394560..8b0854d1ade8 100644 --- a/tests/rustdoc-html/display-hidden-items.rs +++ b/tests/rustdoc-html/display-hidden-items.rs @@ -5,32 +5,25 @@ #![crate_name = "foo"] //@ has 'foo/index.html' +//@ has - '//dt/span[@title="Hidden item"]' '👻' -//@ matches - '//dt[code]' 'pub extern crate .*hidden_core;.*👻' -//@ has - '//dt/code' 'pub extern crate core as hidden_core;' -#[doc(hidden)] -pub extern crate core as hidden_core; - -//@ has - '//*[@id="reexport.hidden_reexport"]/span[@title="Hidden item"]' '👻' -//@ has - '//*[@id="reexport.hidden_reexport"]/code' 'pub use hidden::inside_hidden as hidden_reexport;' +//@ has - '//*[@id="reexport.hidden_reexport"]/code' '#[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport;' #[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport; //@ has - '//dt/a[@class="trait"]' 'TraitHidden' //@ has 'foo/trait.TraitHidden.html' -//@ has 'foo/trait.TraitHidden.html' '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[doc(hidden)]' -//@ has 'foo/trait.TraitHidden.html' '//*[@class="rust item-decl"]/code' 'pub trait TraitHidden' +//@ has - '//code' '#[doc(hidden)] pub trait TraitHidden' #[doc(hidden)] pub trait TraitHidden {} //@ has 'foo/index.html' '//dt/a[@class="trait"]' 'Trait' pub trait Trait { //@ has 'foo/trait.Trait.html' - //@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]' + //@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0' #[doc(hidden)] const BAR: u32 = 0; - //@ has - '//*[@id="method.foo"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]' //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()' #[doc(hidden)] fn foo() {} @@ -51,16 +44,15 @@ impl Struct { } impl Trait for Struct { - //@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]' - //@ has - '//*[@id="method.foo"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]' + //@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0' + //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' '#[doc(hidden)] fn foo()' } //@ has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct' impl TraitHidden for Struct {} //@ has 'foo/index.html' '//dt/a[@class="enum"]' 'HiddenEnum' //@ has 'foo/enum.HiddenEnum.html' -//@ has 'foo/enum.HiddenEnum.html' '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[doc(hidden)]' -//@ has 'foo/enum.HiddenEnum.html' '//*[@class="rust item-decl"]/code' 'pub enum HiddenEnum' +//@ has - '//code' '#[doc(hidden)] pub enum HiddenEnum' #[doc(hidden)] pub enum HiddenEnum { A, @@ -68,7 +60,6 @@ pub enum HiddenEnum { //@ has 'foo/index.html' '//dt/a[@class="enum"]' 'Enum' pub enum Enum { - //@ has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]' //@ has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A' #[doc(hidden)] A, diff --git a/tests/rustdoc-html/empty-section.rs b/tests/rustdoc-html/empty-section.rs index 1e6e725a5a7b..71ebc66d6953 100644 --- a/tests/rustdoc-html/empty-section.rs +++ b/tests/rustdoc-html/empty-section.rs @@ -1,15 +1,13 @@ #![crate_name = "foo"] -#![feature(negative_impls, freeze_impls, freeze, unsafe_unpin)] +#![feature(negative_impls, freeze_impls, freeze)] pub struct Foo; //@ has foo/struct.Foo.html //@ !hasraw - 'Auto Trait Implementations' -// Manually un-implement all auto traits for Foo: impl !Send for Foo {} impl !Sync for Foo {} impl !std::marker::Freeze for Foo {} -impl !std::marker::UnsafeUnpin for Foo {} impl !std::marker::Unpin for Foo {} impl !std::panic::RefUnwindSafe for Foo {} impl !std::panic::UnwindSafe for Foo {} diff --git a/tests/rustdoc-html/final-trait-method.rs b/tests/rustdoc-html/final-trait-method.rs deleted file mode 100644 index 016578a8b0e7..000000000000 --- a/tests/rustdoc-html/final-trait-method.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![feature(final_associated_functions)] - -//@ has final_trait_method/trait.Item.html -pub trait Item { - //@ has - '//*[@id="method.foo"]' 'final fn foo()' - //@ !has - '//*[@id="method.foo"]' 'default fn foo()' - final fn foo() {} - - //@ has - '//*[@id="method.bar"]' 'fn bar()' - //@ !has - '//*[@id="method.bar"]' 'default fn bar()' - //@ !has - '//*[@id="method.bar"]' 'final fn bar()' - fn bar() {} -} - -//@ has final_trait_method/struct.Foo.html -pub struct Foo; -impl Item for Foo { - //@ has - '//*[@id="method.bar"]' 'fn bar()' - //@ !has - '//*[@id="method.bar"]' 'final fn bar()' - //@ !has - '//*[@id="method.bar"]' 'default fn bar()' - fn bar() {} -} diff --git a/tests/rustdoc-html/glob-shadowing.rs b/tests/rustdoc-html/glob-shadowing.rs index c1eeb7e663e7..d9e9ead3f9a9 100644 --- a/tests/rustdoc-html/glob-shadowing.rs +++ b/tests/rustdoc-html/glob-shadowing.rs @@ -1,9 +1,9 @@ //@ has 'glob_shadowing/index.html' -//@ count - '//dt' 7 -//@ !has - '//dd' 'sub1::describe1' +//@ count - '//dt' 6 +//@ !has - '//dd' 'sub1::describe' //@ has - '//dd' 'sub2::describe' -//@ has - '//dd' 'sub1::describe2' +//@ !has - '//dd' 'sub1::describe2' //@ !has - '//dd' 'sub1::prelude' //@ has - '//dd' 'mod::prelude' @@ -18,7 +18,7 @@ mod sub1 { // this should be shadowed by sub2::describe - /// sub1::describe1 + /// sub1::describe pub fn describe() -> &'static str { "sub1::describe" } @@ -33,9 +33,7 @@ mod sub1 { pub struct Foo; // this should be shadowed, - // because both sub1::describe2 and sub3::describe2 are from glob reexport, - // but it is still usable from other crates under the `ambiguous_glob_imports` lint, - // so it is reachable and documented + // because both sub1::describe2 and sub3::describe2 are from glob reexport /// sub1::describe2 pub fn describe2() -> &'static str { "sub1::describe2" diff --git a/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-equality.rs b/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-equality.rs index 939740d8f918..598d2b5bf29d 100644 --- a/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-equality.rs +++ b/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-equality.rs @@ -4,5 +4,6 @@ pub fn accept(_: impl Trait) {} pub trait Trait { - type const K: i32; + #[type_const] + const K: i32; } diff --git a/tests/rustdoc-html/intra-doc/deps.rs b/tests/rustdoc-html/intra-doc/deps.rs index 1670a2d8fe7b..fd40b8326d0f 100644 --- a/tests/rustdoc-html/intra-doc/deps.rs +++ b/tests/rustdoc-html/intra-doc/deps.rs @@ -6,7 +6,7 @@ //@ compile-flags: --extern-html-root-url=empty=https://empty.example/ // This one is to ensure that we don't link to any item we see which has // an external html root URL unless it actually exists. -//@ compile-flags: --extern-html-root-url=non_existent=https://non-existent.example/ +//@ compile-flags: --extern-html-root-url=non_existant=https://non-existant.example/ //@ aux-build: empty.rs #![crate_name = "foo"] @@ -14,10 +14,10 @@ //@ has 'foo/index.html' //@ has - '//a[@href="https://empty.example/empty/index.html"]' 'empty' -// There should only be one intra doc links, we should not link `non_existent`. +// There should only be one intra doc links, we should not link `non_existant`. //@ count - '//*[@class="docblock"]//a' 1 //! [`empty`] //! -//! [`non_existent`] +//! [`non_existant`] extern crate empty; diff --git a/tests/rustdoc-html/source-code-pages/macro-call-2.rs b/tests/rustdoc-html/source-code-pages/macro-call-2.rs deleted file mode 100644 index d9c3df57c602..000000000000 --- a/tests/rustdoc-html/source-code-pages/macro-call-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This is yet another test to ensure that only macro calls are considered as such -// by the rustdoc highlighter, in particular when named `macro_rules`. -// This is a regression test for . - -#![crate_name = "foo"] - -//@ has src/foo/macro-call-2.rs.html -//@ count - '//code/span[@class="macro"]' 2 -//@ has - '//code/span[@class="macro"]' 'macro_rules!' -//@ has - '//code/span[@class="macro"]' 'r#macro_rules!' - -macro_rules! r#macro_rules { - () => { - fn main() {} - } -} - -r#macro_rules!(); diff --git a/tests/rustdoc-html/source-code-pages/macro-call.rs b/tests/rustdoc-html/source-code-pages/macro-call.rs deleted file mode 100644 index df2d22aa9b60..000000000000 --- a/tests/rustdoc-html/source-code-pages/macro-call.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This is yet another test to ensure that only macro calls are considered as such -// by the rustdoc highlighter. -// This is a regression test for . - -#![crate_name = "foo"] - -//@ has src/foo/macro-call.rs.html -//@ count - '//code/span[@class="macro"]' 2 -//@ has - '//code/span[@class="macro"]' 'panic!' -//@ has - '//code/span[@class="macro"]' 'macro_rules!' - -pub struct Layout; - -impl Layout { - pub fn new() {} -} - -pub fn bar() { - let layout = Layout::new::(); - if layout != Layout::new::() { - panic!(); - } - let macro_rules = 3; - if macro_rules != 3 {} -} - -macro_rules! blob { - () => {} -} diff --git a/tests/rustdoc-html/synthetic_auto/basic.rs b/tests/rustdoc-html/synthetic_auto/basic.rs index e8c2f5da9fe6..9daf8963997a 100644 --- a/tests/rustdoc-html/synthetic_auto/basic.rs +++ b/tests/rustdoc-html/synthetic_auto/basic.rs @@ -2,8 +2,7 @@ //@ has - '//h3[@class="code-header"]' 'impl Send for Foowhere T: Send' //@ has - '//h3[@class="code-header"]' 'impl Sync for Foowhere T: Sync' //@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 7 -// The number here will need updating when new auto traits are added: ^ +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 pub struct Foo { field: T, } diff --git a/tests/rustdoc-html/synthetic_auto/manual.rs b/tests/rustdoc-html/synthetic_auto/manual.rs index 830bfccca09e..bbf361a6e596 100644 --- a/tests/rustdoc-html/synthetic_auto/manual.rs +++ b/tests/rustdoc-html/synthetic_auto/manual.rs @@ -6,8 +6,7 @@ // 'impl Send for Foo' // //@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 -// The number here will need updating when new auto traits are added: ^ +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5 pub struct Foo { field: T, } diff --git a/tests/rustdoc-js-std/core-transmute.js b/tests/rustdoc-js-std/core-transmute.js index b15f398902c3..8c9910a32d7f 100644 --- a/tests/rustdoc-js-std/core-transmute.js +++ b/tests/rustdoc-js-std/core-transmute.js @@ -3,9 +3,9 @@ const EXPECTED = [ { 'query': 'generic:T -> generic:U', 'others': [ - { 'path': 'core::mem', 'name': 'transmute' }, { 'path': 'core::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'core::intrinsics::simd', 'name': 'simd_cast' }, + { 'path': 'core::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js-std/transmute-fail.js b/tests/rustdoc-js-std/transmute-fail.js index 459e8dc3f002..ddfb27619481 100644 --- a/tests/rustdoc-js-std/transmute-fail.js +++ b/tests/rustdoc-js-std/transmute-fail.js @@ -6,9 +6,9 @@ const EXPECTED = [ // should-fail tag and the search query below: 'query': 'generic:T -> generic:T', 'others': [ - { 'path': 'std::mem', 'name': 'transmute' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' }, + { 'path': 'std::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js-std/transmute.js b/tests/rustdoc-js-std/transmute.js index a85b02e29947..f52e0ab14362 100644 --- a/tests/rustdoc-js-std/transmute.js +++ b/tests/rustdoc-js-std/transmute.js @@ -5,9 +5,9 @@ const EXPECTED = [ // should-fail tag and the search query below: 'query': 'generic:T -> generic:U', 'others': [ - { 'path': 'std::mem', 'name': 'transmute' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' }, + { 'path': 'std::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js/sort-stability.js b/tests/rustdoc-js/sort-stability.js deleted file mode 100644 index 8c095619a086..000000000000 --- a/tests/rustdoc-js/sort-stability.js +++ /dev/null @@ -1,9 +0,0 @@ -const EXPECTED = [ - { - 'query': 'foo', - 'others': [ - {"path": "sort_stability::old", "name": "foo"}, - {"path": "sort_stability::new", "name": "foo"}, - ], - }, -]; diff --git a/tests/rustdoc-js/sort-stability.rs b/tests/rustdoc-js/sort-stability.rs deleted file mode 100644 index 68662bb3aab6..000000000000 --- a/tests/rustdoc-js/sort-stability.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(staged_api)] -#![stable(feature = "foo_lib", since = "1.0.0")] - -#[stable(feature = "old_foo", since = "1.0.1")] -pub mod old { - /// Old, stable foo - #[stable(feature = "old_foo", since = "1.0.1")] - pub fn foo() {} -} - -#[unstable(feature = "new_foo", issue = "none")] -pub mod new { - /// New, unstable foo - #[unstable(feature = "new_foo", issue = "none")] - pub fn foo() {} -} diff --git a/tests/rustdoc-json/reexport/glob_collision.rs b/tests/rustdoc-json/reexport/glob_collision.rs index dd6eab6517b0..48de1b5e7721 100644 --- a/tests/rustdoc-json/reexport/glob_collision.rs +++ b/tests/rustdoc-json/reexport/glob_collision.rs @@ -1,9 +1,7 @@ // Regression test for https://github.com/rust-lang/rust/issues/100973 -// Update: the rules has changed after #147984, one of the colliding items is now available -// from other crates under a deprecation lint. //@ set m1 = "$.index[?(@.name == 'm1' && @.inner.module)].id" -//@ is "$.index[?(@.name == 'm1')].inner.module.items" [0] +//@ is "$.index[?(@.name == 'm1')].inner.module.items" [] //@ is "$.index[?(@.name == 'm1')].inner.module.is_stripped" true mod m1 { pub fn f() {} diff --git a/tests/rustdoc-ui/associated-constant-not-allowed-102467.rs b/tests/rustdoc-ui/associated-constant-not-allowed-102467.rs index 4168a5653dd5..5b8a90d64121 100644 --- a/tests/rustdoc-ui/associated-constant-not-allowed-102467.rs +++ b/tests/rustdoc-ui/associated-constant-not-allowed-102467.rs @@ -11,7 +11,8 @@ trait T { } trait S { - type const C: i32; + #[type_const] + const C: i32; } fn main() {} diff --git a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout index 8c01c6ff5a41..65989a8ef47c 100644 --- a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout +++ b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout @@ -13,6 +13,8 @@ error: macros that expand to items must be delimited with braces or followed by | LL | println!(); | ^^^^^^^^^^ + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores `{` and any tokens following --> $SRC_DIR/std/src/macros.rs:LL:COL @@ -33,6 +35,8 @@ error: macros that expand to items must be delimited with braces or followed by | LL | println!(); | ^^^^^^^^^^ + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores `{` and any tokens following --> $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/tests/rustdoc-ui/ice-bug-report-url.stderr b/tests/rustdoc-ui/ice-bug-report-url.stderr index bc46b226a703..b6eb8a1792df 100644 --- a/tests/rustdoc-ui/ice-bug-report-url.stderr +++ b/tests/rustdoc-ui/ice-bug-report-url.stderr @@ -9,7 +9,7 @@ LL | fn wrong() aborting due to `-Z treat-err-as-bug=1` stack backtrace: -error: the compiler unexpectedly panicked. This is a bug +error: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md diff --git a/tests/rustdoc-ui/intra-doc/deprecated-note-from-reexported.rs b/tests/rustdoc-ui/intra-doc/deprecated-note-from-reexported.rs deleted file mode 100644 index 91447e5fa166..000000000000 --- a/tests/rustdoc-ui/intra-doc/deprecated-note-from-reexported.rs +++ /dev/null @@ -1,33 +0,0 @@ -// This test ensures that the intra-doc link from reexported deprecated attribute note -// are resolved where they are declared. - -#![deny(rustdoc::broken_intra_doc_links)] - -#[doc(inline)] -pub use bar::sql_function_proc as sql_function; - -pub fn define_sql_function() {} - -pub mod bar { - #[deprecated(note = "Use [`define_sql_function`] instead")] - //~^ ERROR: unresolved link - //~| ERROR: unresolved link - pub fn sql_function_proc() {} -} - -// From here, this is a regression test for . -pub use fuzz_test_helpers::*; - -/// A type referenced in the deprecation note. -pub struct Env; - -impl Env { - pub fn try_invoke(&self) {} -} - -mod fuzz_test_helpers { - #[deprecated(note = "use [Env::try_invoke] instead")] - //~^ ERROR: unresolved link - //~| ERROR: unresolved link - pub fn fuzz_catch_panic() {} -} diff --git a/tests/rustdoc-ui/intra-doc/deprecated-note-from-reexported.stderr b/tests/rustdoc-ui/intra-doc/deprecated-note-from-reexported.stderr deleted file mode 100644 index cb7a5f0c6e02..000000000000 --- a/tests/rustdoc-ui/intra-doc/deprecated-note-from-reexported.stderr +++ /dev/null @@ -1,59 +0,0 @@ -error: unresolved link to `define_sql_function` - --> $DIR/deprecated-note-from-reexported.rs:12:25 - | -LL | #[deprecated(note = "Use [`define_sql_function`] instead")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - Use [`define_sql_function`] instead - ^^^^^^^^^^^^^^^^^^^^^ - = note: no item named `define_sql_function` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` -note: the lint level is defined here - --> $DIR/deprecated-note-from-reexported.rs:4:9 - | -LL | #![deny(rustdoc::broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: unresolved link to `Env::try_invoke` - --> $DIR/deprecated-note-from-reexported.rs:29:25 - | -LL | #[deprecated(note = "use [Env::try_invoke] instead")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - use [Env::try_invoke] instead - ^^^^^^^^^^^^^^^ - = note: no item named `Env` in scope - -error: unresolved link to `define_sql_function` - --> $DIR/deprecated-note-from-reexported.rs:12:25 - | -LL | #[deprecated(note = "Use [`define_sql_function`] instead")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - Use [`define_sql_function`] instead - ^^^^^^^^^^^^^^^^^^^^^ - = note: no item named `define_sql_function` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: unresolved link to `Env::try_invoke` - --> $DIR/deprecated-note-from-reexported.rs:29:25 - | -LL | #[deprecated(note = "use [Env::try_invoke] instead")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - use [Env::try_invoke] instead - ^^^^^^^^^^^^^^^ - = note: no item named `Env` in scope - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 4 previous errors - diff --git a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.rs b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.rs index 290b087916c2..c71e5bee12ea 100644 --- a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.rs +++ b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.rs @@ -1,6 +1,6 @@ // Regression test for issue #95879. -use unresolved_crate::module::Name; //~ ERROR cannot find +use unresolved_crate::module::Name; //~ ERROR failed to resolve /// [Name] pub struct S; diff --git a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr index cbbf7a7f23e7..dcdd230c25a1 100644 --- a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr +++ b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `unresolved_crate` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unresolved_crate` --> $DIR/unresolved-import-recovery.rs:3:5 | LL | use unresolved_crate::module::Name; diff --git a/tests/rustdoc-ui/issues/issue-61732.rs b/tests/rustdoc-ui/issues/issue-61732.rs index b375298ea40e..d5d9ad5e4637 100644 --- a/tests/rustdoc-ui/issues/issue-61732.rs +++ b/tests/rustdoc-ui/issues/issue-61732.rs @@ -1,4 +1,4 @@ // This previously triggered an ICE. pub(in crate::r#mod) fn main() {} -//~^ ERROR cannot find module or crate `r#mod` in `crate` +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `r#mod` diff --git a/tests/rustdoc-ui/issues/issue-61732.stderr b/tests/rustdoc-ui/issues/issue-61732.stderr index 49d5bfc9a2f0..c4e6997ab74d 100644 --- a/tests/rustdoc-ui/issues/issue-61732.stderr +++ b/tests/rustdoc-ui/issues/issue-61732.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `r#mod` in `crate` +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `r#mod` --> $DIR/issue-61732.rs:3:15 | LL | pub(in crate::r#mod) fn main() {} diff --git a/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs b/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs index c15c2dea4c19..48f328f4fad3 100644 --- a/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs +++ b/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs @@ -29,6 +29,10 @@ use rustc_session::config::OutputFilenames; struct TheBackend; impl CodegenBackend for TheBackend { + fn locale_resource(&self) -> &'static str { + "" + } + fn name(&self) -> &'static str { "the-backend" } diff --git a/tests/ui-fulldeps/explain_highlighter.rs b/tests/ui-fulldeps/explain_highlighter.rs deleted file mode 100644 index 337f31738a76..000000000000 --- a/tests/ui-fulldeps/explain_highlighter.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ run-pass -//@ check-run-results - -#![feature(rustc_private)] -use std::io::Write; -extern crate rustc_driver; -extern crate rustc_driver_impl; - -use rustc_driver_impl::highlighter::highlight; - -const TEST_INPUT: &str = " -struct Foo; - -fn baz(x: i32) { - // A function -} - -fn main() { - let foo = Foo; - foo.bar(); -} -"; - -fn main() { - let mut buf = Vec::new(); - highlight(TEST_INPUT, &mut buf).unwrap(); - let mut stdout = std::io::stdout(); - stdout.write_all(&buf).unwrap(); -} diff --git a/tests/ui-fulldeps/explain_highlighter.run.stdout b/tests/ui-fulldeps/explain_highlighter.run.stdout deleted file mode 100644 index f54021c68bb9..000000000000 --- a/tests/ui-fulldeps/explain_highlighter.run.stdout +++ /dev/null @@ -1,12 +0,0 @@ - -struct Foo; - -fn baz(x: i32) { - // A function -} - -fn main() { - let foo = Foo; - foo.bar(); -} - \ No newline at end of file diff --git a/tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl b/tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl new file mode 100644 index 000000000000..9407c5170450 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl @@ -0,0 +1 @@ +a_b_key = Value diff --git a/tests/ui-fulldeps/fluent-messages/duplicate-a.ftl b/tests/ui-fulldeps/fluent-messages/duplicate-a.ftl new file mode 100644 index 000000000000..9407c5170450 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/duplicate-a.ftl @@ -0,0 +1 @@ +a_b_key = Value diff --git a/tests/ui-fulldeps/fluent-messages/duplicate.ftl b/tests/ui-fulldeps/fluent-messages/duplicate.ftl new file mode 100644 index 000000000000..871550b231a3 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/duplicate.ftl @@ -0,0 +1,3 @@ +no_crate_a_b_key = Value + +no_crate_a_b_key = Another Value diff --git a/tests/ui-fulldeps/fluent-messages/invalid-escape.ftl b/tests/ui-fulldeps/fluent-messages/invalid-escape.ftl new file mode 100644 index 000000000000..e28852ea0050 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/invalid-escape.ftl @@ -0,0 +1 @@ +no_crate_bad_escape = don't use \n, \', or \" diff --git a/tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl b/tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl new file mode 100644 index 000000000000..3088b1f8dc83 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl @@ -0,0 +1,2 @@ +no_crate_some_slug = hi + .label-has-hyphens = test diff --git a/tests/ui-fulldeps/fluent-messages/many-lines.ftl b/tests/ui-fulldeps/fluent-messages/many-lines.ftl new file mode 100644 index 000000000000..43660ebeacdc --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/many-lines.ftl @@ -0,0 +1,11 @@ +no_crate_foo = foo + +# This file tests error reporting for +# fluent files with many lines. +# The error message should point to the correct line number +# and include no more context than necessary. + +no_crate_bar = + +no_crate_baz = + baz diff --git a/tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl b/tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl new file mode 100644 index 000000000000..0a64e3894bd5 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl @@ -0,0 +1,2 @@ +with-hyphens = 1234 +no-crate_foo = abcd diff --git a/tests/ui-fulldeps/fluent-messages/missing-message-ref.ftl b/tests/ui-fulldeps/fluent-messages/missing-message-ref.ftl new file mode 100644 index 000000000000..4c6514a97700 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/missing-message-ref.ftl @@ -0,0 +1 @@ +no_crate_missing_message_ref = {message} diff --git a/tests/ui-fulldeps/fluent-messages/missing-message.ftl b/tests/ui-fulldeps/fluent-messages/missing-message.ftl new file mode 100644 index 000000000000..61f56fd4d57b --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/missing-message.ftl @@ -0,0 +1 @@ +no_crate_missing_message = diff --git a/tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl b/tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl new file mode 100644 index 000000000000..a64c85094f1d --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl @@ -0,0 +1 @@ +no_crate_this-slug-has-hyphens = hi diff --git a/tests/ui-fulldeps/fluent-messages/test.rs b/tests/ui-fulldeps/fluent-messages/test.rs new file mode 100644 index 000000000000..c1f5fe730c76 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/test.rs @@ -0,0 +1,87 @@ +//@ normalize-stderr: "could not open Fluent resource:.*" -> "could not open Fluent resource: os-specific message" + +#![feature(rustc_private)] +#![crate_type = "lib"] +extern crate rustc_errors; +extern crate rustc_fluent_macro; + +/// Copy of the relevant `DiagMessage` variant constructed by `fluent_messages` as it +/// expects `crate::DiagMessage` to exist. +pub enum DiagMessage { + FluentIdentifier(std::borrow::Cow<'static, str>, Option>), +} + +/// Copy of the relevant `SubdiagMessage` variant constructed by `fluent_messages` as it +/// expects `crate::SubdiagMessage` to exist. +pub enum SubdiagMessage { + FluentAttr(std::borrow::Cow<'static, str>), +} + +mod missing_absolute { + rustc_fluent_macro::fluent_messages! { "/definitely_does_not_exist.ftl" } + //~^ ERROR could not open Fluent resource +} + +mod missing_relative { + rustc_fluent_macro::fluent_messages! { "../definitely_does_not_exist.ftl" } + //~^ ERROR could not open Fluent resource +} + +mod missing_message { + rustc_fluent_macro::fluent_messages! { "./missing-message.ftl" } + //~^ ERROR could not parse Fluent resource +} + +mod duplicate { + rustc_fluent_macro::fluent_messages! { "./duplicate.ftl" } + //~^ ERROR overrides existing message: `no_crate_a_b_key` +} + +mod slug_with_hyphens { + rustc_fluent_macro::fluent_messages! { "./slug-with-hyphens.ftl" } + //~^ ERROR name `no_crate_this-slug-has-hyphens` contains a '-' character +} + +mod label_with_hyphens { + rustc_fluent_macro::fluent_messages! { "./label-with-hyphens.ftl" } + //~^ ERROR attribute `label-has-hyphens` contains a '-' character +} + +mod valid { + rustc_fluent_macro::fluent_messages! { "./valid.ftl" } + + mod test_generated { + use super::{fluent_generated::no_crate_key, DEFAULT_LOCALE_RESOURCE}; + } +} + +mod missing_crate_name { + rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + //~^ ERROR name `no-crate_foo` contains a '-' character + //~| ERROR name `with-hyphens` contains a '-' character + //~| ERROR name `with-hyphens` does not start with the crate name + + mod test_generated { + use super::{ + fluent_generated::{no_crate_foo, with_hyphens}, + DEFAULT_LOCALE_RESOURCE, + }; + } +} + +mod missing_message_ref { + rustc_fluent_macro::fluent_messages! { "./missing-message-ref.ftl" } + //~^ ERROR referenced message `message` does not exist +} + +mod bad_escape { + rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + //~^ ERROR invalid escape `\n` + //~| ERROR invalid escape `\"` + //~| ERROR invalid escape `\'` +} + +mod many_lines { + rustc_fluent_macro::fluent_messages! { "./many-lines.ftl" } + //~^ ERROR could not parse Fluent resource +} diff --git a/tests/ui-fulldeps/fluent-messages/test.stderr b/tests/ui-fulldeps/fluent-messages/test.stderr new file mode 100644 index 000000000000..0b3bb14ce513 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/test.stderr @@ -0,0 +1,122 @@ +error: could not open Fluent resource: os-specific message + --> $DIR/test.rs:21:44 + | +LL | rustc_fluent_macro::fluent_messages! { "/definitely_does_not_exist.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: could not open Fluent resource: os-specific message + --> $DIR/test.rs:26:44 + | +LL | rustc_fluent_macro::fluent_messages! { "../definitely_does_not_exist.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: could not parse Fluent resource + --> $DIR/test.rs:31:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./missing-message.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: see additional errors emitted + +error: expected a message field for "no_crate_missing_message" + --> ./missing-message.ftl:1:1 + | +1 | no_crate_missing_message = + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + +error: overrides existing message: `no_crate_a_b_key` + --> $DIR/test.rs:36:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./duplicate.ftl" } + | ^^^^^^^^^^^^^^^^^ + +error: name `no_crate_this-slug-has-hyphens` contains a '-' character + --> $DIR/test.rs:41:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./slug-with-hyphens.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: attribute `label-has-hyphens` contains a '-' character + --> $DIR/test.rs:46:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./label-with-hyphens.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: name `with-hyphens` contains a '-' character + --> $DIR/test.rs:59:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: name `with-hyphens` does not start with the crate name + --> $DIR/test.rs:59:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: prepend `no_crate_` to the slug name: `no_crate_with_hyphens` + +error: name `no-crate_foo` contains a '-' character + --> $DIR/test.rs:59:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: referenced message `message` does not exist (in message `no_crate_missing_message_ref`) + --> $DIR/test.rs:73:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./missing-message-ref.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: you may have meant to use a variable reference (`{$message}`) + +error: invalid escape `\n` in Fluent resource + --> $DIR/test.rs:78:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: Fluent does not interpret these escape sequences () + +error: invalid escape `\"` in Fluent resource + --> $DIR/test.rs:78:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: Fluent does not interpret these escape sequences () + +error: invalid escape `\'` in Fluent resource + --> $DIR/test.rs:78:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: Fluent does not interpret these escape sequences () + +error: could not parse Fluent resource + --> $DIR/test.rs:85:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./many-lines.ftl" } + | ^^^^^^^^^^^^^^^^^^ + | + = help: see additional errors emitted + +error: expected a message field for "no_crate_bar" + --> ./many-lines.ftl:8:1 + | +8 | no_crate_bar = + | ^^^^^^^^^^^^^^ + | + +error: aborting due to 14 previous errors + diff --git a/tests/ui-fulldeps/fluent-messages/valid.ftl b/tests/ui-fulldeps/fluent-messages/valid.ftl new file mode 100644 index 000000000000..598473adb680 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/valid.ftl @@ -0,0 +1 @@ +no_crate_key = Valid! diff --git a/tests/ui-fulldeps/hash-stable-is-unstable.rs b/tests/ui-fulldeps/hash-stable-is-unstable.rs index a3dfd7e85ba6..7f62b6044104 100644 --- a/tests/ui-fulldeps/hash-stable-is-unstable.rs +++ b/tests/ui-fulldeps/hash-stable-is-unstable.rs @@ -7,7 +7,7 @@ extern crate rustc_macros; //~^ ERROR use of unstable library feature `rustc_private` //~| NOTE: see issue #27812 for more information //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -extern crate rustc_middle; +extern crate rustc_query_system; //~^ ERROR use of unstable library feature `rustc_private` //~| NOTE: see issue #27812 for more information //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui-fulldeps/hash-stable-is-unstable.stderr b/tests/ui-fulldeps/hash-stable-is-unstable.stderr index 7c69e8f5e631..e7740d744b4f 100644 --- a/tests/ui-fulldeps/hash-stable-is-unstable.stderr +++ b/tests/ui-fulldeps/hash-stable-is-unstable.stderr @@ -21,8 +21,8 @@ LL | extern crate rustc_macros; error[E0658]: use of unstable library feature `rustc_private`: this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:10:1 | -LL | extern crate rustc_middle; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern crate rustc_query_system; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #27812 for more information = help: add `#![feature(rustc_private)]` to the crate attributes to enable diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.ftl b/tests/ui-fulldeps/internal-lints/diagnostics.ftl new file mode 100644 index 000000000000..cb2d476d815d --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/diagnostics.ftl @@ -0,0 +1,5 @@ +no_crate_example = this is an example message used in testing + .note = with a note + .help = with a help + .suggestion = with a suggestion + .label = with a label diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs new file mode 100644 index 000000000000..1238fefd5bc0 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -0,0 +1,125 @@ +//@ compile-flags: -Z unstable-options +//@ ignore-stage1 + +#![crate_type = "lib"] +#![feature(rustc_attrs)] +#![feature(rustc_private)] +#![deny(rustc::untranslatable_diagnostic)] +#![deny(rustc::diagnostic_outside_of_impl)] + +extern crate rustc_errors; +extern crate rustc_fluent_macro; +extern crate rustc_macros; +extern crate rustc_session; +extern crate rustc_span; + +use rustc_errors::{ + Diag, DiagCtxtHandle, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, + LintDiagnostic, SubdiagMessage, Subdiagnostic, +}; +use rustc_macros::{Diagnostic, Subdiagnostic}; +use rustc_span::Span; + +rustc_fluent_macro::fluent_messages! { "./diagnostics.ftl" } + +#[derive(Diagnostic)] +#[diag(no_crate_example)] +struct DeriveDiagnostic { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[note(no_crate_example)] +struct Note { + #[primary_span] + span: Span, +} + +pub struct UntranslatableInDiagnostic; + +impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UntranslatableInDiagnostic { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + Diag::new(dcx, level, "untranslatable diagnostic") + //~^ ERROR diagnostics should be created using translatable messages + } +} + +pub struct TranslatableInDiagnostic; + +impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for TranslatableInDiagnostic { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + Diag::new(dcx, level, crate::fluent_generated::no_crate_example) + } +} + +pub struct UntranslatableInAddtoDiag; + +impl Subdiagnostic for UntranslatableInAddtoDiag { + fn add_to_diag( + self, + diag: &mut Diag<'_, G>, + ) { + diag.note("untranslatable diagnostic"); + //~^ ERROR diagnostics should be created using translatable messages + } +} + +pub struct TranslatableInAddtoDiag; + +impl Subdiagnostic for TranslatableInAddtoDiag { + fn add_to_diag( + self, + diag: &mut Diag<'_, G>, + ) { + diag.note(crate::fluent_generated::no_crate_note); + } +} + +pub struct UntranslatableInLintDiagnostic; + +impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { + diag.note("untranslatable diagnostic"); + //~^ ERROR diagnostics should be created using translatable messages + } +} + +pub struct TranslatableInLintDiagnostic; + +impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { + diag.note(crate::fluent_generated::no_crate_note); + } +} + +pub fn make_diagnostics<'a>(dcx: DiagCtxtHandle<'a>) { + let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); + //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls + + let _diag = dcx.struct_err("untranslatable diagnostic"); + //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls + //~^^ ERROR diagnostics should be created using translatable messages +} + +// Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted for +// `diagnostic_outside_of_impl`. +#[rustc_lint_diagnostics] +pub fn skipped_because_of_annotation<'a>(dcx: DiagCtxtHandle<'a>) { + #[allow(rustc::untranslatable_diagnostic)] + let _diag = dcx.struct_err("untranslatable diagnostic"); // okay! +} + +// Check that multiple translatable params are allowed in a single function (at one point they +// weren't). +fn f(_x: impl Into, _y: impl Into) {} +fn g() { + f(crate::fluent_generated::no_crate_example, crate::fluent_generated::no_crate_example); + f("untranslatable diagnostic", crate::fluent_generated::no_crate_example); + //~^ ERROR diagnostics should be created using translatable messages + f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic"); + //~^ ERROR diagnostics should be created using translatable messages + f("untranslatable diagnostic", "untranslatable diagnostic"); + //~^ ERROR diagnostics should be created using translatable messages + //~^^ ERROR diagnostics should be created using translatable messages +} diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr new file mode 100644 index 000000000000..b260c4b7afef --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -0,0 +1,74 @@ +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:43:31 + | +LL | Diag::new(dcx, level, "untranslatable diagnostic") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/diagnostics.rs:7:9 + | +LL | #![deny(rustc::untranslatable_diagnostic)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:63:19 + | +LL | diag.note("untranslatable diagnostic"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:83:19 + | +LL | diag.note("untranslatable diagnostic"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls + --> $DIR/diagnostics.rs:97:21 + | +LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); + | ^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/diagnostics.rs:8:9 + | +LL | #![deny(rustc::diagnostic_outside_of_impl)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls + --> $DIR/diagnostics.rs:100:21 + | +LL | let _diag = dcx.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:100:32 + | +LL | let _diag = dcx.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:118:7 + | +LL | f("untranslatable diagnostic", crate::fluent_generated::no_crate_example); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:120:50 + | +LL | f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:122:7 + | +LL | f("untranslatable diagnostic", "untranslatable diagnostic"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostics should be created using translatable messages + --> $DIR/diagnostics.rs:122:36 + | +LL | f("untranslatable diagnostic", "untranslatable diagnostic"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors + diff --git a/tests/ui-fulldeps/mod_dir_path_canonicalized.rs b/tests/ui-fulldeps/mod_dir_path_canonicalized.rs index 806d395a90ad..86f2d5f5954a 100644 --- a/tests/ui-fulldeps/mod_dir_path_canonicalized.rs +++ b/tests/ui-fulldeps/mod_dir_path_canonicalized.rs @@ -29,7 +29,7 @@ pub fn main() { } fn parse() { - let psess = ParseSess::new(); + let psess = ParseSess::new(vec![rustc_parse::DEFAULT_LOCALE_RESOURCE]); let path = Path::new(file!()); let path = path.canonicalize().unwrap(); diff --git a/tests/ui-fulldeps/obtain-borrowck.rs b/tests/ui-fulldeps/obtain-borrowck.rs index 46ed23b58ac9..a562d0ccd3df 100644 --- a/tests/ui-fulldeps/obtain-borrowck.rs +++ b/tests/ui-fulldeps/obtain-borrowck.rs @@ -28,7 +28,6 @@ extern crate rustc_session; use std::cell::RefCell; use std::collections::HashMap; -use std::process::ExitCode; use std::thread_local; use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions}; @@ -38,20 +37,21 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; use rustc_interface::Config; use rustc_interface::interface::Compiler; -use rustc_middle::queries::mir_borrowck::ProvidedValue; +use rustc_middle::query::queries::mir_borrowck::ProvidedValue; use rustc_middle::ty::TyCtxt; use rustc_middle::util::Providers; use rustc_session::Session; -fn main() -> ExitCode { - rustc_driver::catch_with_exit_code(move || { +fn main() { + let exit_code = rustc_driver::catch_with_exit_code(move || { let mut rustc_args: Vec<_> = std::env::args().collect(); // We must pass -Zpolonius so that the borrowck information is computed. rustc_args.push("-Zpolonius".to_owned()); let mut callbacks = CompilerCalls::default(); // Call the Rust compiler with our callbacks. rustc_driver::run_compiler(&rustc_args, &mut callbacks); - }) + }); + std::process::exit(exit_code); } #[derive(Default)] diff --git a/tests/ui-fulldeps/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs index 8d7425186680..08ded2aee53d 100644 --- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs @@ -219,7 +219,7 @@ fn main() { } fn run() { - let psess = ParseSess::new(); + let psess = ParseSess::new(vec![rustc_parse::DEFAULT_LOCALE_RESOURCE]); iter_exprs(2, &mut |mut e| { // If the pretty printer is correct, then `parse(print(e))` should be identical to `e`, diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs index 85ee87155a7a..72b5cfb90630 100644 --- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs +++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs @@ -196,7 +196,7 @@ fn main() -> ExitCode { }; rustc_span::create_default_session_globals_then(|| { - let psess = &ParseSess::new(); + let psess = &ParseSess::new(vec![rustc_parse::DEFAULT_LOCALE_RESOURCE]); for &source_code in EXPRS { let Some(expr) = parse_expr(psess, source_code) else { diff --git a/tests/ui-fulldeps/run-compiler-twice.rs b/tests/ui-fulldeps/run-compiler-twice.rs index bd92cc6218f1..241d9e7efbd7 100644 --- a/tests/ui-fulldeps/run-compiler-twice.rs +++ b/tests/ui-fulldeps/run-compiler-twice.rs @@ -64,6 +64,7 @@ fn compile(code: String, output: PathBuf, sysroot: Sysroot, linker: Option<&Path output_dir: None, ice_file: None, file_loader: None, + locale_resources: Vec::new(), lint_caps: Default::default(), psess_created: None, hash_untracked_state: None, @@ -71,6 +72,7 @@ fn compile(code: String, output: PathBuf, sysroot: Sysroot, linker: Option<&Path override_queries: None, extra_symbols: Vec::new(), make_codegen_backend: None, + registry: rustc_driver::diagnostics_registry(), using_internal_features: &rustc_driver::USING_INTERNAL_FEATURES, }; diff --git a/tests/ui-fulldeps/rustc_public/check_abi.rs b/tests/ui-fulldeps/rustc_public/check_abi.rs index 8e97b773db56..b3519a2c60ed 100644 --- a/tests/ui-fulldeps/rustc_public/check_abi.rs +++ b/tests/ui-fulldeps/rustc_public/check_abi.rs @@ -6,6 +6,7 @@ //@ ignore-remote #![feature(rustc_private)] +#![feature(assert_matches)] #![feature(ascii_char, ascii_char_variants)] extern crate rustc_driver; @@ -24,7 +25,7 @@ use rustc_public::mir::mono::Instance; use rustc_public::target::MachineInfo; use rustc_public::ty::{AdtDef, RigidTy, Ty, TyKind}; use rustc_public::{CrateDef, CrateItem, CrateItems, ItemKind}; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::collections::HashSet; use std::convert::TryFrom; use std::io::Write; diff --git a/tests/ui-fulldeps/rustc_public/check_allocation.rs b/tests/ui-fulldeps/rustc_public/check_allocation.rs index 8f3b9693382b..3a0a2382be72 100644 --- a/tests/ui-fulldeps/rustc_public/check_allocation.rs +++ b/tests/ui-fulldeps/rustc_public/check_allocation.rs @@ -8,6 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] #![feature(ascii_char, ascii_char_variants)] extern crate rustc_hir; @@ -19,7 +20,7 @@ extern crate rustc_interface; extern crate rustc_public; use std::ascii::Char; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::cmp::{max, min}; use std::collections::HashMap; use std::ffi::CStr; diff --git a/tests/ui-fulldeps/rustc_public/check_assoc_items.rs b/tests/ui-fulldeps/rustc_public/check_assoc_items.rs index ee0efd083588..194d6be88a76 100644 --- a/tests/ui-fulldeps/rustc_public/check_assoc_items.rs +++ b/tests/ui-fulldeps/rustc_public/check_assoc_items.rs @@ -8,6 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs b/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs index f988452fd52b..75f4f1f5bf4c 100644 --- a/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs +++ b/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs @@ -7,6 +7,7 @@ //@ edition: 2024 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_crate_defs.rs b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs index 2b6a2ff8199c..7d949eae3910 100644 --- a/tests/ui-fulldeps/rustc_public/check_crate_defs.rs +++ b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs @@ -6,6 +6,7 @@ //@ ignore-remote #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_hir; extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_def_ty.rs b/tests/ui-fulldeps/rustc_public/check_def_ty.rs index 19ea731834b7..5984d6f8821a 100644 --- a/tests/ui-fulldeps/rustc_public/check_def_ty.rs +++ b/tests/ui-fulldeps/rustc_public/check_def_ty.rs @@ -8,6 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_defs.rs b/tests/ui-fulldeps/rustc_public/check_defs.rs index f3e27cdeb604..e6f9fb9972b0 100644 --- a/tests/ui-fulldeps/rustc_public/check_defs.rs +++ b/tests/ui-fulldeps/rustc_public/check_defs.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; @@ -18,7 +19,7 @@ use mir::{TerminatorKind::*, mono::Instance}; use rustc_public::mir::mono::InstanceKind; use rustc_public::ty::{RigidTy, Ty, TyKind, UintTy}; use rustc_public::*; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/check_foreign.rs b/tests/ui-fulldeps/rustc_public/check_foreign.rs index 4670fd409b8f..bd34fb5cf8a8 100644 --- a/tests/ui-fulldeps/rustc_public/check_foreign.rs +++ b/tests/ui-fulldeps/rustc_public/check_foreign.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; @@ -19,7 +20,7 @@ use rustc_public::{ ty::{Abi, ForeignItemKind}, *, }; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/check_instance.rs b/tests/ui-fulldeps/rustc_public/check_instance.rs index defea9d2f54b..fd7523963fa9 100644 --- a/tests/ui-fulldeps/rustc_public/check_instance.rs +++ b/tests/ui-fulldeps/rustc_public/check_instance.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_intrinsics.rs b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs index 0cbb9659182a..f722f0bbd718 100644 --- a/tests/ui-fulldeps/rustc_public/check_intrinsics.rs +++ b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs @@ -10,6 +10,7 @@ //@ ignore-remote #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; extern crate rustc_hir; @@ -23,7 +24,7 @@ use rustc_public::mir::mono::{Instance, InstanceKind}; use rustc_public::mir::visit::{Location, MirVisitor}; use rustc_public::mir::{LocalDecl, Terminator, TerminatorKind}; use rustc_public::ty::{FnDef, GenericArgs, RigidTy, TyKind}; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::convert::TryFrom; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/check_item_kind.rs b/tests/ui-fulldeps/rustc_public/check_item_kind.rs index b75ac70d86e3..c687b3af1c63 100644 --- a/tests/ui-fulldeps/rustc_public/check_item_kind.rs +++ b/tests/ui-fulldeps/rustc_public/check_item_kind.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_trait_queries.rs b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs index 44b7275a3df6..5603add82f59 100644 --- a/tests/ui-fulldeps/rustc_public/check_trait_queries.rs +++ b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_transform.rs b/tests/ui-fulldeps/rustc_public/check_transform.rs index f8aa40e47446..815dec57b8be 100644 --- a/tests/ui-fulldeps/rustc_public/check_transform.rs +++ b/tests/ui-fulldeps/rustc_public/check_transform.rs @@ -6,6 +6,7 @@ //@ ignore-remote #![feature(rustc_private)] +#![feature(assert_matches)] #![feature(ascii_char, ascii_char_variants)] extern crate rustc_hir; diff --git a/tests/ui-fulldeps/rustc_public/check_ty_fold.rs b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs index 9ac7f14570e5..93cd30493440 100644 --- a/tests/ui-fulldeps/rustc_public/check_ty_fold.rs +++ b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs @@ -8,6 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_variant.rs b/tests/ui-fulldeps/rustc_public/check_variant.rs index 54ae8b8f83b9..9bdd0c9d80ba 100644 --- a/tests/ui-fulldeps/rustc_public/check_variant.rs +++ b/tests/ui-fulldeps/rustc_public/check_variant.rs @@ -8,6 +8,7 @@ //@ edition: 2024 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/closure-generic-body.rs b/tests/ui-fulldeps/rustc_public/closure-generic-body.rs index a328bc396c54..46aeca76ba65 100644 --- a/tests/ui-fulldeps/rustc_public/closure-generic-body.rs +++ b/tests/ui-fulldeps/rustc_public/closure-generic-body.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/closure_body.rs b/tests/ui-fulldeps/rustc_public/closure_body.rs index 880d7dde34b6..43cbca8baab8 100644 --- a/tests/ui-fulldeps/rustc_public/closure_body.rs +++ b/tests/ui-fulldeps/rustc_public/closure_body.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/compilation-result.rs b/tests/ui-fulldeps/rustc_public/compilation-result.rs index 351ca2c8295f..d33e602e8191 100644 --- a/tests/ui-fulldeps/rustc_public/compilation-result.rs +++ b/tests/ui-fulldeps/rustc_public/compilation-result.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/crate-info.rs b/tests/ui-fulldeps/rustc_public/crate-info.rs index 3729aa7609b5..06cbbfcd69ec 100644 --- a/tests/ui-fulldeps/rustc_public/crate-info.rs +++ b/tests/ui-fulldeps/rustc_public/crate-info.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_hir; extern crate rustc_middle; @@ -21,7 +22,7 @@ use rustc_public::ItemKind; use rustc_public::crate_def::CrateDef; use rustc_public::mir::mono::Instance; use rustc_public::ty::{RigidTy, TyKind}; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/projections.rs b/tests/ui-fulldeps/rustc_public/projections.rs index e864bb9648db..c1cdb5374d46 100644 --- a/tests/ui-fulldeps/rustc_public/projections.rs +++ b/tests/ui-fulldeps/rustc_public/projections.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_hir; extern crate rustc_middle; @@ -20,7 +21,7 @@ use rustc_public::ItemKind; use rustc_public::crate_def::CrateDef; use rustc_public::mir::{ProjectionElem, Rvalue, StatementKind}; use rustc_public::ty::{RigidTy, TyKind, UintTy}; -use std::assert_matches; +use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/smir_internal.rs b/tests/ui-fulldeps/rustc_public/smir_internal.rs index 98335da19dbd..b74bdfe4eb19 100644 --- a/tests/ui-fulldeps/rustc_public/smir_internal.rs +++ b/tests/ui-fulldeps/rustc_public/smir_internal.rs @@ -8,6 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_driver; extern crate rustc_interface; diff --git a/tests/ui-fulldeps/rustc_public/smir_serde.rs b/tests/ui-fulldeps/rustc_public/smir_serde.rs index 6a345023de17..972bc5efe206 100644 --- a/tests/ui-fulldeps/rustc_public/smir_serde.rs +++ b/tests/ui-fulldeps/rustc_public/smir_serde.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_driver; diff --git a/tests/ui-fulldeps/rustc_public/smir_visitor.rs b/tests/ui-fulldeps/rustc_public/smir_visitor.rs index 1ea2ab6f560f..9438f46a59b5 100644 --- a/tests/ui-fulldeps/rustc_public/smir_visitor.rs +++ b/tests/ui-fulldeps/rustc_public/smir_visitor.rs @@ -7,6 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs index c1146de0fef1..37f78a7777c4 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -14,19 +14,21 @@ #![crate_type = "lib"] extern crate rustc_errors; +extern crate rustc_fluent_macro; extern crate rustc_macros; extern crate rustc_session; extern crate rustc_span; -extern crate core; -use rustc_errors::{Applicability, DiagMessage}; +use rustc_errors::{Applicability, DiagMessage, SubdiagMessage}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; +rustc_fluent_macro::fluent_messages! { "./example.ftl" } + struct NotIntoDiagArg; #[derive(Diagnostic)] -#[diag("example message")] +#[diag(no_crate_example)] struct Test { #[primary_span] span: Span, @@ -36,7 +38,7 @@ struct Test { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct SubTest { #[primary_span] span: Span, diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index 2d90b2a96b01..316f23888bc1 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied - --> $DIR/diagnostic-derive-doc-comment-field.rs:34:10 + --> $DIR/diagnostic-derive-doc-comment-field.rs:36:10 | LL | #[derive(Diagnostic)] | ---------- required by a bound introduced by this call @@ -8,7 +8,7 @@ LL | arg: NotIntoDiagArg, | ^^^^^^^^^^^^^^ unsatisfied trait bound | help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `NotIntoDiagArg` - --> $DIR/diagnostic-derive-doc-comment-field.rs:26:1 + --> $DIR/diagnostic-derive-doc-comment-field.rs:28:1 | LL | struct NotIntoDiagArg; | ^^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ note: required by a bound in `Diag::<'a, G>::arg` = note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied - --> $DIR/diagnostic-derive-doc-comment-field.rs:44:10 + --> $DIR/diagnostic-derive-doc-comment-field.rs:46:10 | LL | #[derive(Subdiagnostic)] | ------------- required by a bound introduced by this call @@ -30,7 +30,7 @@ LL | arg: NotIntoDiagArg, | ^^^^^^^^^^^^^^ unsatisfied trait bound | help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `NotIntoDiagArg` - --> $DIR/diagnostic-derive-doc-comment-field.rs:26:1 + --> $DIR/diagnostic-derive-doc-comment-field.rs:28:1 | LL | struct NotIntoDiagArg; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-inline.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-inline.stderr deleted file mode 100644 index b32235c02b07..000000000000 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-inline.stderr +++ /dev/null @@ -1,641 +0,0 @@ -error: derive(Diagnostic): unsupported type attribute for diagnostic derive enum - --> $DIR/diagnostic-derive-inline.rs:44:1 - | -LL | #[diag("this is an example message", code = E0123)] - | ^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:47:5 - | -LL | Foo, - | ^^^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:49:5 - | -LL | Bar, - | ^^^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: expected parentheses: #[diag(...)] - --> $DIR/diagnostic-derive-inline.rs:55:8 - | -LL | #[diag = "E0123"] - | ^ - -error: derive(Diagnostic): `#[nonsense(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:60:1 - | -LL | #[nonsense("this is an example message", code = E0123)] - | ^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:60:1 - | -LL | #[nonsense("this is an example message", code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:67:1 - | -LL | #[diag(code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:72:1 - | -LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:77:1 - | -LL | #[diag(nonsense = "...", code = E0123, slug = "foo")] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:82:1 - | -LL | #[diag(nonsense = 4, code = E0123, slug = "foo")] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): unknown argument - --> $DIR/diagnostic-derive-inline.rs:87:52 - | -LL | #[diag("this is an example message", code = E0123, slug = "foo")] - | ^^^^ - | - = note: only the `code` parameter is valid after the message - -error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:94:5 - | -LL | #[suggestion = "bar"] - | ^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/diagnostic-derive-inline.rs:101:38 - | -LL | #[diag("this is an example message", code = E0456)] - | ^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive-inline.rs:100:38 - | -LL | #[diag("this is an example message", code = E0123)] - | ^^^^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/diagnostic-derive-inline.rs:106:52 - | -LL | #[diag("this is an example message", code = E0123, code = E0456)] - | ^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive-inline.rs:106:38 - | -LL | #[diag("this is an example message", code = E0123, code = E0456)] - | ^^^^ - -error: derive(Diagnostic): diagnostic message must be the first argument - --> $DIR/diagnostic-derive-inline.rs:111:38 - | -LL | #[diag("this is an example message", no_crate::example, code = E0123)] - | ^^^^^^^^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:116:1 - | -LL | struct KindNotProvided {} - | ^^^^^^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:119:1 - | -LL | #[diag(code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive-inline.rs:130:5 - | -LL | #[primary_span] - | ^ - -error: derive(Diagnostic): `#[nonsense]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:138:5 - | -LL | #[nonsense] - | ^ - -error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive-inline.rs:155:5 - | -LL | #[label("with a label")] - | ^ - -error: derive(Diagnostic): `name` doesn't refer to a field on this type - --> $DIR/diagnostic-derive-inline.rs:163:46 - | -LL | #[suggestion("with a suggestion", code = "{name}")] - | ^^^^^^^^ - -error: invalid format string: expected `}` but string was terminated - --> $DIR/diagnostic-derive-inline.rs:168:10 - | -LL | #[derive(Diagnostic)] - | ^^^^^^^^^^ expected `}` in format string - | - = note: if you intended to print `{`, you can escape it using `{{` - = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: invalid format string: unmatched `}` found - --> $DIR/diagnostic-derive-inline.rs:178:10 - | -LL | #[derive(Diagnostic)] - | ^^^^^^^^^^ unmatched `}` in format string - | - = note: if you intended to print `}`, you can escape it using `}}` - = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive-inline.rs:198:5 - | -LL | #[label("with a label")] - | ^ - -error: derive(Diagnostic): suggestion without `code = "..."` - --> $DIR/diagnostic-derive-inline.rs:217:5 - | -LL | #[suggestion("with a suggestion")] - | ^ - -error: derive(Diagnostic): invalid nested attribute - --> $DIR/diagnostic-derive-inline.rs:225:39 - | -LL | #[suggestion("with a suggestion", nonsense = "bar")] - | ^^^^^^^^ - | - = help: only `style`, `code` and `applicability` are valid nested attributes - -error: derive(Diagnostic): suggestion without `code = "..."` - --> $DIR/diagnostic-derive-inline.rs:225:5 - | -LL | #[suggestion("with a suggestion", nonsense = "bar")] - | ^ - -error: derive(Diagnostic): invalid nested attribute - --> $DIR/diagnostic-derive-inline.rs:234:39 - | -LL | #[suggestion("with a suggestion", msg = "bar")] - | ^^^ - | - = help: only `style`, `code` and `applicability` are valid nested attributes - -error: derive(Diagnostic): suggestion without `code = "..."` - --> $DIR/diagnostic-derive-inline.rs:234:5 - | -LL | #[suggestion("with a suggestion", msg = "bar")] - | ^ - -error: derive(Diagnostic): wrong field type for suggestion - --> $DIR/diagnostic-derive-inline.rs:257:5 - | -LL | #[suggestion("with a suggestion", code = "This is suggested code")] - | ^ - | - = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/diagnostic-derive-inline.rs:273:24 - | -LL | suggestion: (Span, Span, Applicability), - | ^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive-inline.rs:273:18 - | -LL | suggestion: (Span, Span, Applicability), - | ^^^^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/diagnostic-derive-inline.rs:281:33 - | -LL | suggestion: (Applicability, Applicability, Span), - | ^^^^^^^^^^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive-inline.rs:281:18 - | -LL | suggestion: (Applicability, Applicability, Span), - | ^^^^^^^^^^^^^ - -error: derive(Diagnostic): `#[label = ...]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:288:5 - | -LL | #[label = "bar"] - | ^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/diagnostic-derive-inline.rs:389:5 - | -LL | #[suggestion("with a suggestion", code = "...", applicability = "maybe-incorrect")] - | ^ - | -note: previously specified here - --> $DIR/diagnostic-derive-inline.rs:391:24 - | -LL | suggestion: (Span, Applicability), - | ^^^^^^^^^^^^^ - -error: derive(Diagnostic): invalid applicability - --> $DIR/diagnostic-derive-inline.rs:397:69 - | -LL | #[suggestion("with a suggestion", code = "...", applicability = "batman")] - | ^^^^^^^^ - -error: derive(Diagnostic): the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()` - --> $DIR/diagnostic-derive-inline.rs:460:5 - | -LL | #[help("with a help")] - | ^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/diagnostic-derive-inline.rs:469:29 - | -LL | #[label("with a label", foo)] - | ^^^ - -error: derive(Diagnostic): a diagnostic message must be the first argument to the attribute - --> $DIR/diagnostic-derive-inline.rs:477:29 - | -LL | #[label("with a label", "and another one?")] - | ^^^^^^^^^^^^^^^^^^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/diagnostic-derive-inline.rs:485:29 - | -LL | #[label("with a label", foo = "...")] - | ^^^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/diagnostic-derive-inline.rs:493:29 - | -LL | #[label("with a label", foo("..."))] - | ^^^ - -error: derive(Diagnostic): `#[primary_span]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:505:5 - | -LL | #[primary_span] - | ^ - | - = help: the `primary_span` field attribute is not valid for lint diagnostics - -error: derive(Diagnostic): `#[error(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:525:1 - | -LL | #[error("this is an example message", code = E0123)] - | ^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:525:1 - | -LL | #[error("this is an example message", code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): `#[warn_(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:532:1 - | -LL | #[warn_("this is an example message", code = E0123)] - | ^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:532:1 - | -LL | #[warn_("this is an example message", code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:539:1 - | -LL | #[lint("this is an example message", code = E0123)] - | ^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:539:1 - | -LL | #[lint("this is an example message", code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:546:1 - | -LL | #[lint("this is an example message", code = E0123)] - | ^ - -error: derive(Diagnostic): diagnostic message not specified - --> $DIR/diagnostic-derive-inline.rs:546:1 - | -LL | #[lint("this is an example message", code = E0123)] - | ^ - | - = help: specify the message as the first argument to the `#[diag(...)]` attribute, such as `#[diag("Example error")]` - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/diagnostic-derive-inline.rs:555:53 - | -LL | #[suggestion("with a suggestion", code = "...", code = ",,,")] - | ^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive-inline.rs:555:39 - | -LL | #[suggestion("with a suggestion", code = "...", code = ",,,")] - | ^^^^ - -error: derive(Diagnostic): wrong types for suggestion - --> $DIR/diagnostic-derive-inline.rs:564:24 - | -LL | suggestion: (Span, usize), - | ^^^^^ - | - = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` - -error: derive(Diagnostic): wrong types for suggestion - --> $DIR/diagnostic-derive-inline.rs:572:17 - | -LL | suggestion: (Span,), - | ^^^^^^^ - | - = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` - -error: derive(Diagnostic): suggestion without `code = "..."` - --> $DIR/diagnostic-derive-inline.rs:579:5 - | -LL | #[suggestion("with a suggestion")] - | ^ - -error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:586:1 - | -LL | #[multipart_suggestion("with a suggestion")] - | ^ - | - = help: consider creating a `Subdiagnostic` instead - -error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:589:1 - | -LL | #[multipart_suggestion()] - | ^ - | - = help: consider creating a `Subdiagnostic` instead - -error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:593:5 - | -LL | #[multipart_suggestion("with a suggestion")] - | ^ - | - = help: consider creating a `Subdiagnostic` instead - -error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:601:1 - | -LL | #[suggestion("with a suggestion", code = "...")] - | ^ - | - = help: `#[label]` and `#[suggestion]` can only be applied to fields - -error: derive(Diagnostic): `#[label]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:610:1 - | -LL | #[label] - | ^ - | - = help: subdiagnostic message is missing - -error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:644:5 - | -LL | #[subdiagnostic(bad)] - | ^ - -error: derive(Diagnostic): `#[subdiagnostic = ...]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:652:5 - | -LL | #[subdiagnostic = "bad"] - | ^ - -error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:660:5 - | -LL | #[subdiagnostic(bad, bad)] - | ^ - -error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:668:5 - | -LL | #[subdiagnostic("bad")] - | ^ - -error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:676:5 - | -LL | #[subdiagnostic(eager)] - | ^ - -error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:684:5 - | -LL | #[subdiagnostic(eager)] - | ^ - -error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:705:5 - | -LL | #[subdiagnostic(eager)] - | ^ - -error: derive(Diagnostic): expected at least one string literal for `code(...)` - --> $DIR/diagnostic-derive-inline.rs:736:44 - | -LL | #[suggestion("with a suggestion", code())] - | ^ - -error: derive(Diagnostic): `code(...)` must contain only string literals - --> $DIR/diagnostic-derive-inline.rs:744:44 - | -LL | #[suggestion("with a suggestion", code(foo))] - | ^^^ - -error: unexpected token, expected `)` - --> $DIR/diagnostic-derive-inline.rs:744:44 - | -LL | #[suggestion("with a suggestion", code(foo))] - | ^^^ - -error: expected string literal - --> $DIR/diagnostic-derive-inline.rs:753:46 - | -LL | #[suggestion("with a suggestion", code = 3)] - | ^ - -error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive-inline.rs:768:5 - | -LL | #[suggestion("with a suggestion", code = "")] - | ^ - | - = note: `#[suggestion(...)]` applied to `Vec` field is ambiguous - = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]` - = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]` - -error: derive(Diagnostic): Variable `nosub` not found in diagnostic - --> $DIR/diagnostic-derive-inline.rs:780:8 - | -LL | #[diag("does not exist: {$nosub}")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: Available fields: "sub" - -error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive-inline.rs:60:3 - | -LL | #[nonsense("this is an example message", code = E0123)] - | ^^^^^^^^ - -error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive-inline.rs:138:7 - | -LL | #[nonsense] - | ^^^^^^^^ - -error: cannot find attribute `error` in this scope - --> $DIR/diagnostic-derive-inline.rs:525:3 - | -LL | #[error("this is an example message", code = E0123)] - | ^^^^^ - | -help: `error` is an attribute that can be used by the derive macro `Error`, you might be missing a `derive` attribute - | -LL + #[derive(Error)] -LL | struct ErrorAttribute {} - | - -error: cannot find attribute `warn_` in this scope - --> $DIR/diagnostic-derive-inline.rs:532:3 - | -LL | #[warn_("this is an example message", code = E0123)] - | ^^^^^ - | -help: a built-in attribute with a similar name exists - | -LL - #[warn_("this is an example message", code = E0123)] -LL + #[warn("this is an example message", code = E0123)] - | - -error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive-inline.rs:539:3 - | -LL | #[lint("this is an example message", code = E0123)] - | ^^^^ - | -help: a built-in attribute with a similar name exists - | -LL - #[lint("this is an example message", code = E0123)] -LL + #[link("this is an example message", code = E0123)] - | - -error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive-inline.rs:546:3 - | -LL | #[lint("this is an example message", code = E0123)] - | ^^^^ - | -help: a built-in attribute with a similar name exists - | -LL - #[lint("this is an example message", code = E0123)] -LL + #[link("this is an example message", code = E0123)] - | - -error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive-inline.rs:586:3 - | -LL | #[multipart_suggestion("with a suggestion")] - | ^^^^^^^^^^^^^^^^^^^^ - | -help: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute - | -LL + #[derive(Subdiagnostic)] -LL | struct MultipartSuggestion { - | - -error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive-inline.rs:589:3 - | -LL | #[multipart_suggestion()] - | ^^^^^^^^^^^^^^^^^^^^ - | -help: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute - | -LL + #[derive(Subdiagnostic)] -LL | struct MultipartSuggestion { - | - -error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive-inline.rs:593:7 - | -LL | #[multipart_suggestion("with a suggestion")] - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute - -error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied - --> $DIR/diagnostic-derive-inline.rs:329:12 - | -LL | #[derive(Diagnostic)] - | ---------- required by a bound introduced by this call -... -LL | other: Hello, - | ^^^^^ unsatisfied trait bound - | -help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `Hello` - --> $DIR/diagnostic-derive-inline.rs:41:1 - | -LL | struct Hello {} - | ^^^^^^^^^^^^ - = help: normalized in stderr -note: required by a bound in `Diag::<'a, G>::arg` - --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC - ::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC - | - = note: in this macro invocation - = note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 81 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-inline.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs similarity index 60% rename from tests/ui-fulldeps/session-diagnostic/diagnostic-derive-inline.rs rename to tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 759a9412f769..fa2d037064d2 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-inline.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -1,7 +1,5 @@ //@ check-fail // Tests error conditions for specifying diagnostics using #[derive(Diagnostic)] -// This test specifically tests diagnostic derives involving the inline fluent syntax. - //@ normalize-stderr: "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" //@ normalize-stderr: "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC" @@ -19,6 +17,7 @@ extern crate rustc_span; use rustc_span::symbol::Ident; use rustc_span::Span; +extern crate rustc_fluent_macro; extern crate rustc_macros; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; @@ -26,70 +25,82 @@ extern crate rustc_middle; use rustc_middle::ty::Ty; extern crate rustc_errors; -use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan}; +use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan, SubdiagMessage}; extern crate rustc_session; -extern crate core; +rustc_fluent_macro::fluent_messages! { "./example.ftl" } // E0123 and E0456 are no longer used, so we define our own constants here just for this test. const E0123: ErrCode = ErrCode::from_u32(0123); const E0456: ErrCode = ErrCode::from_u32(0456); #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct Hello {} #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] +struct HelloWarn {} + +#[derive(Diagnostic)] +#[diag(no_crate_example, code = E0123)] //~^ ERROR unsupported type attribute for diagnostic derive enum enum DiagnosticOnEnum { Foo, - //~^ ERROR diagnostic message not specified + //~^ ERROR diagnostic slug not specified Bar, - //~^ ERROR diagnostic message not specified + //~^ ERROR diagnostic slug not specified } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] #[diag = "E0123"] -//~^ ERROR expected parentheses: #[diag(...)] +//~^ ERROR failed to resolve: you might be missing crate `core` struct WrongStructAttrStyle {} #[derive(Diagnostic)] -#[nonsense("this is an example message", code = E0123)] +#[nonsense(no_crate_example, code = E0123)] //~^ ERROR `#[nonsense(...)]` is not a valid attribute -//~^^ ERROR diagnostic message not specified +//~^^ ERROR diagnostic slug not specified //~^^^ ERROR cannot find attribute `nonsense` in this scope struct InvalidStructAttr {} #[derive(Diagnostic)] #[diag(code = E0123)] -//~^ ERROR diagnostic message not specified +//~^ ERROR diagnostic slug not specified struct InvalidLitNestedAttr {} +#[derive(Diagnostic)] +#[diag(nonsense, code = E0123)] +//~^ ERROR cannot find value `nonsense` in module `crate::fluent_generated` +struct InvalidNestedStructAttr {} + #[derive(Diagnostic)] #[diag(nonsense("foo"), code = E0123, slug = "foo")] -//~^ ERROR derive(Diagnostic): diagnostic message not specified +//~^ ERROR diagnostic slug must be the first argument +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr1 {} #[derive(Diagnostic)] #[diag(nonsense = "...", code = E0123, slug = "foo")] -//~^ ERROR diagnostic message not specified +//~^ ERROR unknown argument +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr2 {} #[derive(Diagnostic)] #[diag(nonsense = 4, code = E0123, slug = "foo")] -//~^ ERROR diagnostic message not specified +//~^ ERROR unknown argument +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr3 {} #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123, slug = "foo")] +#[diag(no_crate_example, code = E0123, slug = "foo")] //~^ ERROR unknown argument struct InvalidNestedStructAttr4 {} #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct WrongPlaceField { #[suggestion = "bar"] //~^ ERROR `#[suggestion = ...]` is not a valid attribute @@ -97,35 +108,36 @@ struct WrongPlaceField { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -#[diag("this is an example message", code = E0456)] +#[diag(no_crate_example, code = E0123)] +#[diag(no_crate_example, code = E0456)] //~^ ERROR specified multiple times +//~^^ ERROR specified multiple times struct DiagSpecifiedTwice {} #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123, code = E0456)] +#[diag(no_crate_example, code = E0123, code = E0456)] //~^ ERROR specified multiple times struct CodeSpecifiedTwice {} #[derive(Diagnostic)] -#[diag("this is an example message", no_crate::example, code = E0123)] -//~^ ERROR diagnostic message must be the first argument +#[diag(no_crate_example, no_crate::example, code = E0123)] +//~^ ERROR diagnostic slug must be the first argument struct SlugSpecifiedTwice {} #[derive(Diagnostic)] -struct KindNotProvided {} //~ ERROR diagnostic message not specified +struct KindNotProvided {} //~ ERROR diagnostic slug not specified #[derive(Diagnostic)] #[diag(code = E0123)] -//~^ ERROR diagnostic message not specified +//~^ ERROR diagnostic slug not specified struct SlugNotProvided {} #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct CodeNotProvided {} #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct MessageWrongType { #[primary_span] //~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` @@ -133,43 +145,43 @@ struct MessageWrongType { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct InvalidPathFieldAttr { #[nonsense] //~^ ERROR `#[nonsense]` is not a valid attribute - //~| ERROR cannot find attribute `nonsense` in this scope + //~^^ ERROR cannot find attribute `nonsense` in this scope foo: String, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorWithField { name: String, - #[label("with a label")] + #[label(no_crate_label)] span: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorWithMessageAppliedToField { - #[label("with a label")] + #[label(no_crate_label)] //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` name: String, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorWithNonexistentField { - #[suggestion("with a suggestion", code = "{name}")] + #[suggestion(no_crate_suggestion, code = "{name}")] //~^ ERROR `name` doesn't refer to a field on this type suggestion: (Span, Applicability), } #[derive(Diagnostic)] //~^ ERROR invalid format string: expected `}` -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorMissingClosingBrace { - #[suggestion("with a suggestion", code = "{name")] + #[suggestion(no_crate_suggestion, code = "{name")] suggestion: (Span, Applicability), name: String, val: usize, @@ -177,113 +189,113 @@ struct ErrorMissingClosingBrace { #[derive(Diagnostic)] //~^ ERROR invalid format string: unmatched `}` -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorMissingOpeningBrace { - #[suggestion("with a suggestion", code = "name}")] + #[suggestion(no_crate_suggestion, code = "name}")] suggestion: (Span, Applicability), name: String, val: usize, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct LabelOnSpan { - #[label("with a label")] + #[label(no_crate_label)] sp: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct LabelOnNonSpan { - #[label("with a label")] + #[label(no_crate_label)] //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` id: u32, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct Suggest { - #[suggestion("with a suggestion", code = "This is the suggested code")] - #[suggestion("with a suggestion", code = "This is the suggested code", style = "normal")] - #[suggestion("with a suggestion", code = "This is the suggested code", style = "short")] - #[suggestion("with a suggestion", code = "This is the suggested code", style = "hidden")] - #[suggestion("with a suggestion", code = "This is the suggested code", style = "verbose")] + #[suggestion(no_crate_suggestion, code = "This is the suggested code")] + #[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "normal")] + #[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "short")] + #[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "hidden")] + #[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "verbose")] suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithoutCode { - #[suggestion("with a suggestion")] + #[suggestion(no_crate_suggestion)] //~^ ERROR suggestion without `code = "..."` suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithBadKey { - #[suggestion("with a suggestion", nonsense = "bar")] + #[suggestion(nonsense = "bar")] //~^ ERROR invalid nested attribute //~| ERROR suggestion without `code = "..."` suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithShorthandMsg { - #[suggestion("with a suggestion", msg = "bar")] + #[suggestion(msg = "bar")] //~^ ERROR invalid nested attribute //~| ERROR suggestion without `code = "..."` suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithoutMsg { - #[suggestion("with a suggestion", code = "bar")] + #[suggestion(code = "bar")] suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithTypesSwapped { - #[suggestion("with a suggestion", code = "This is suggested code")] + #[suggestion(no_crate_suggestion, code = "This is suggested code")] suggestion: (Applicability, Span), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithWrongTypeApplicabilityOnly { - #[suggestion("with a suggestion", code = "This is suggested code")] + #[suggestion(no_crate_suggestion, code = "This is suggested code")] //~^ ERROR wrong field type for suggestion suggestion: Applicability, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithSpanOnly { - #[suggestion("with a suggestion", code = "This is suggested code")] + #[suggestion(no_crate_suggestion, code = "This is suggested code")] suggestion: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithDuplicateSpanAndApplicability { - #[suggestion("with a suggestion", code = "This is suggested code")] + #[suggestion(no_crate_suggestion, code = "This is suggested code")] suggestion: (Span, Span, Applicability), //~^ ERROR specified multiple times } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct SuggestWithDuplicateApplicabilityAndSpan { - #[suggestion("with a suggestion", code = "This is suggested code")] + #[suggestion(no_crate_suggestion, code = "This is suggested code")] suggestion: (Applicability, Applicability, Span), //~^ ERROR specified multiple times } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct WrongKindOfAnnotation { #[label = "bar"] //~^ ERROR `#[label = ...]` is not a valid attribute @@ -291,38 +303,46 @@ struct WrongKindOfAnnotation { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct OptionsInErrors { - #[label("with a label")] + #[label(no_crate_label)] label: Option, - #[suggestion("with a suggestion", code = "...")] + #[suggestion(no_crate_suggestion, code = "...")] opt_sugg: Option<(Span, Applicability)>, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct MoveOutOfBorrowError<'tcx> { name: Ident, ty: Ty<'tcx>, #[primary_span] - #[label("with a label")] + #[label(no_crate_label)] span: Span, - #[label("with a label")] + #[label(no_crate_label)] other_span: Span, - #[suggestion("with a suggestion", code = "{name}.clone()")] + #[suggestion(no_crate_suggestion, code = "{name}.clone()")] opt_sugg: Option<(Span, Applicability)>, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorWithLifetime<'a> { - #[label("with a label")] + #[label(no_crate_label)] span: Span, name: &'a str, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] +struct ErrorWithDefaultLabelAttr<'a> { + #[label] + span: Span, + name: &'a str, +} + +#[derive(Diagnostic)] +#[diag(no_crate_example, code = E0123)] struct ArgFieldWithoutSkip { #[primary_span] span: Span, @@ -331,7 +351,7 @@ struct ArgFieldWithoutSkip { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ArgFieldWithSkip { #[primary_span] span: Span, @@ -342,165 +362,203 @@ struct ArgFieldWithSkip { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorWithSpannedNote { - #[note("with a note")] + #[note] span: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -#[note("with a note")] +#[diag(no_crate_example, code = E0123)] +struct ErrorWithSpannedNoteCustom { + #[note(no_crate_note)] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(no_crate_example, code = E0123)] +#[note] struct ErrorWithNote { val: String, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -struct ErrorWithSpannedHelpCustom { - #[help("with a help")] +#[diag(no_crate_example, code = E0123)] +#[note(no_crate_note)] +struct ErrorWithNoteCustom { + val: String, +} + +#[derive(Diagnostic)] +#[diag(no_crate_example, code = E0123)] +struct ErrorWithSpannedHelp { + #[help] span: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -#[help("with a help")] +#[diag(no_crate_example, code = E0123)] +struct ErrorWithSpannedHelpCustom { + #[help(no_crate_help)] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(no_crate_example, code = E0123)] +#[help] struct ErrorWithHelp { val: String, } #[derive(Diagnostic)] -#[help("with a help")] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] +#[help(no_crate_help)] +struct ErrorWithHelpCustom { + val: String, +} + +#[derive(Diagnostic)] +#[help] +#[diag(no_crate_example, code = E0123)] struct ErrorWithHelpWrongOrder { val: String, } #[derive(Diagnostic)] -#[note("with a note")] -#[diag("this is an example message", code = E0123)] +#[help(no_crate_help)] +#[diag(no_crate_example, code = E0123)] +struct ErrorWithHelpCustomWrongOrder { + val: String, +} + +#[derive(Diagnostic)] +#[note] +#[diag(no_crate_example, code = E0123)] struct ErrorWithNoteWrongOrder { val: String, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[note(no_crate_note)] +#[diag(no_crate_example, code = E0123)] +struct ErrorWithNoteCustomWrongOrder { + val: String, +} + +#[derive(Diagnostic)] +#[diag(no_crate_example, code = E0123)] struct ApplicabilityInBoth { - #[suggestion("with a suggestion", code = "...", applicability = "maybe-incorrect")] + #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")] //~^ ERROR specified multiple times suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct InvalidApplicability { - #[suggestion("with a suggestion", code = "...", applicability = "batman")] + #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")] //~^ ERROR invalid applicability suggestion: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ValidApplicability { - #[suggestion("with a suggestion", code = "...", applicability = "maybe-incorrect")] + #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")] suggestion: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct NoApplicability { - #[suggestion("with a suggestion", code = "...")] + #[suggestion(no_crate_suggestion, code = "...")] suggestion: Span, } #[derive(Subdiagnostic)] -#[note("this is an example message")] +#[note(no_crate_example)] struct Note; #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct Subdiagnostic { #[subdiagnostic] note: Note, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct VecField { #[primary_span] - #[label("with a label")] + #[label] spans: Vec, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct UnitField { #[primary_span] spans: Span, - #[help("with a help")] + #[help] + foo: (), + #[help(no_crate_help)] bar: (), } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct OptUnitField { #[primary_span] spans: Span, - #[help("with a help")] + #[help] foo: Option<()>, + #[help(no_crate_help)] + bar: Option<()>, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct BoolField { #[primary_span] spans: Span, - #[help("with a help")] + #[help] foo: bool, - #[help("with a help")] + #[help(no_crate_help)] //~^ ERROR the `#[help(...)]` attribute can only be applied to fields of type // only allow plain 'bool' fields bar: Option, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct LabelWithTrailingPath { - #[label("with a label", foo)] - //~^ ERROR derive(Diagnostic): no nested attribute expected here + #[label(no_crate_label, foo)] + //~^ ERROR a diagnostic slug must be the first argument to the attribute span: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -struct LabelWithTrailingMessage { - #[label("with a label", "and another one?")] - //~^ ERROR derive(Diagnostic): a diagnostic message must be the first argument to the attribute - span: Span, -} - -#[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct LabelWithTrailingNameValue { - #[label("with a label", foo = "...")] - //~^ ERROR no nested attribute expected here + #[label(no_crate_label, foo = "...")] + //~^ ERROR only `no_span` is a valid nested attribute span: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct LabelWithTrailingList { - #[label("with a label", foo("..."))] - //~^ ERROR no nested attribute expected here + #[label(no_crate_label, foo("..."))] + //~^ ERROR only `no_span` is a valid nested attribute span: Span, } #[derive(LintDiagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct LintsGood {} #[derive(LintDiagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct PrimarySpanOnLint { #[primary_span] //~^ ERROR `#[primary_span]` is not a valid attribute @@ -508,97 +566,97 @@ struct PrimarySpanOnLint { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct ErrorWithMultiSpan { #[primary_span] span: MultiSpan, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -#[warning("with a warning")] +#[diag(no_crate_example, code = E0123)] +#[warning] struct ErrorWithWarn { val: String, } #[derive(Diagnostic)] -#[error("this is an example message", code = E0123)] +#[error(no_crate_example, code = E0123)] //~^ ERROR `#[error(...)]` is not a valid attribute -//~| ERROR diagnostic message not specified +//~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `error` in this scope struct ErrorAttribute {} #[derive(Diagnostic)] -#[warn_("this is an example message", code = E0123)] +#[warn_(no_crate_example, code = E0123)] //~^ ERROR `#[warn_(...)]` is not a valid attribute -//~| ERROR diagnostic message not specified +//~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `warn_` in this scope struct WarnAttribute {} #[derive(Diagnostic)] -#[lint("this is an example message", code = E0123)] +#[lint(no_crate_example, code = E0123)] //~^ ERROR `#[lint(...)]` is not a valid attribute -//~| ERROR diagnostic message not specified +//~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `lint` in this scope struct LintAttributeOnSessionDiag {} #[derive(LintDiagnostic)] -#[lint("this is an example message", code = E0123)] +#[lint(no_crate_example, code = E0123)] //~^ ERROR `#[lint(...)]` is not a valid attribute -//~| ERROR diagnostic message not specified +//~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `lint` in this scope struct LintAttributeOnLintDiag {} #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct DuplicatedSuggestionCode { - #[suggestion("with a suggestion", code = "...", code = ",,,")] + #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] //~^ ERROR specified multiple times suggestion: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct InvalidTypeInSuggestionTuple { - #[suggestion("with a suggestion", code = "...")] + #[suggestion(no_crate_suggestion, code = "...")] suggestion: (Span, usize), //~^ ERROR wrong types for suggestion } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct MissingApplicabilityInSuggestionTuple { - #[suggestion("with a suggestion", code = "...")] + #[suggestion(no_crate_suggestion, code = "...")] suggestion: (Span,), //~^ ERROR wrong types for suggestion } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct MissingCodeInSuggestion { - #[suggestion("with a suggestion")] + #[suggestion(no_crate_suggestion)] //~^ ERROR suggestion without `code = "..."` suggestion: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -#[multipart_suggestion("with a suggestion")] +#[diag(no_crate_example, code = E0123)] +#[multipart_suggestion(no_crate_suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute //~| ERROR cannot find attribute `multipart_suggestion` in this scope #[multipart_suggestion()] //~^ ERROR cannot find attribute `multipart_suggestion` in this scope //~| ERROR `#[multipart_suggestion(...)]` is not a valid attribute struct MultipartSuggestion { - #[multipart_suggestion("with a suggestion")] + #[multipart_suggestion(no_crate_suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute //~| ERROR cannot find attribute `multipart_suggestion` in this scope suggestion: Span, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] -#[suggestion("with a suggestion", code = "...")] +#[diag(no_crate_example, code = E0123)] +#[suggestion(no_crate_suggestion, code = "...")] //~^ ERROR `#[suggestion(...)]` is not a valid attribute struct SuggestionOnStruct { #[primary_span] @@ -606,7 +664,7 @@ struct SuggestionOnStruct { } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] #[label] //~^ ERROR `#[label]` is not a valid attribute struct LabelOnStruct { @@ -616,30 +674,30 @@ struct LabelOnStruct { #[derive(Diagnostic)] enum ExampleEnum { - #[diag("this is an example message")] + #[diag(no_crate_example)] Foo { #[primary_span] sp: Span, - #[note("with a note")] + #[note] note_sp: Span, }, - #[diag("this is an example message")] + #[diag(no_crate_example)] Bar { #[primary_span] sp: Span, }, - #[diag("this is an example message")] + #[diag(no_crate_example)] Baz, } #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct RawIdentDiagnosticArg { pub r#type: String, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticBad { #[subdiagnostic(bad)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -647,7 +705,7 @@ struct SubdiagnosticBad { } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticBadStr { #[subdiagnostic = "bad"] //~^ ERROR `#[subdiagnostic = ...]` is not a valid attribute @@ -655,7 +713,7 @@ struct SubdiagnosticBadStr { } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticBadTwice { #[subdiagnostic(bad, bad)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -663,7 +721,7 @@ struct SubdiagnosticBadTwice { } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticBadLitStr { #[subdiagnostic("bad")] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -671,7 +729,7 @@ struct SubdiagnosticBadLitStr { } #[derive(LintDiagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticEagerLint { #[subdiagnostic(eager)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -679,7 +737,7 @@ struct SubdiagnosticEagerLint { } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticEagerFormerlyCorrect { #[subdiagnostic(eager)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -691,7 +749,7 @@ struct SubdiagnosticEagerFormerlyCorrect { // after the `span_suggestion` call - which breaks eager translation. #[derive(Subdiagnostic)] -#[suggestion("example message", applicability = "machine-applicable", code = "{correct}")] +#[suggestion(no_crate_example, applicability = "machine-applicable", code = "{correct}")] pub(crate) struct SubdiagnosticWithSuggestion { #[primary_span] span: Span, @@ -700,7 +758,7 @@ pub(crate) struct SubdiagnosticWithSuggestion { } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SubdiagnosticEagerSuggestion { #[subdiagnostic(eager)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -709,7 +767,7 @@ struct SubdiagnosticEagerSuggestion { /// with a doc comment on the type.. #[derive(Diagnostic)] -#[diag("this is an example message", code = E0123)] +#[diag(no_crate_example, code = E0123)] struct WithDocComment { /// ..and the field #[primary_span] @@ -717,68 +775,55 @@ struct WithDocComment { } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SuggestionsGood { - #[suggestion("with a suggestion", code("foo", "bar"))] + #[suggestion(code("foo", "bar"))] sub: Span, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SuggestionsSingleItem { - #[suggestion("with a suggestion", code("foo"))] + #[suggestion(code("foo"))] sub: Span, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SuggestionsNoItem { - #[suggestion("with a suggestion", code())] + #[suggestion(code())] //~^ ERROR expected at least one string literal for `code(...)` sub: Span, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SuggestionsInvalidItem { - #[suggestion("with a suggestion", code(foo))] + #[suggestion(code(foo))] //~^ ERROR `code(...)` must contain only string literals - //~| ERROR unexpected token, expected `)` + //~| ERROR failed to resolve: you might be missing crate `core` sub: Span, } -#[derive(Diagnostic)] -#[diag("this is an example message")] +#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` in this scope +#[diag(no_crate_example)] struct SuggestionsInvalidLiteral { - #[suggestion("with a suggestion", code = 3)] - //~^ ERROR expected string literal + #[suggestion(code = 3)] + //~^ ERROR failed to resolve: you might be missing crate `core` sub: Span, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SuggestionStyleGood { - #[suggestion("with a suggestion", code = "", style = "hidden")] + #[suggestion(code = "", style = "hidden")] sub: Span, } #[derive(Diagnostic)] -#[diag("this is an example message")] +#[diag(no_crate_example)] struct SuggestionOnVec { - #[suggestion("with a suggestion", code = "")] + #[suggestion(no_crate_suggestion, code = "")] //~^ ERROR `#[suggestion(...)]` is not a valid attribute sub: Vec, } - -#[derive(Diagnostic)] -#[diag("exists: {$sub}")] -struct VariableExists { - sub: String, -} - -#[derive(Diagnostic)] -#[diag("does not exist: {$nosub}")] -//~^ ERROR Variable `nosub` not found in diagnostic -struct VariableDoesNotExist { - sub: String, -} diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr new file mode 100644 index 000000000000..90ad21ef08f9 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -0,0 +1,676 @@ +error: derive(Diagnostic): unsupported type attribute for diagnostic derive enum + --> $DIR/diagnostic-derive.rs:47:1 + | +LL | #[diag(no_crate_example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:50:5 + | +LL | Foo, + | ^^^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:52:5 + | +LL | Bar, + | ^^^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): `#[nonsense(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:63:1 + | +LL | #[nonsense(no_crate_example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:63:1 + | +LL | #[nonsense(no_crate_example, code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:70:1 + | +LL | #[diag(code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): diagnostic slug must be the first argument + --> $DIR/diagnostic-derive.rs:80:16 + | +LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:80:1 + | +LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): unknown argument + --> $DIR/diagnostic-derive.rs:86:8 + | +LL | #[diag(nonsense = "...", code = E0123, slug = "foo")] + | ^^^^^^^^ + | + = note: only the `code` parameter is valid after the slug + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:86:1 + | +LL | #[diag(nonsense = "...", code = E0123, slug = "foo")] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): unknown argument + --> $DIR/diagnostic-derive.rs:92:8 + | +LL | #[diag(nonsense = 4, code = E0123, slug = "foo")] + | ^^^^^^^^ + | + = note: only the `code` parameter is valid after the slug + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:92:1 + | +LL | #[diag(nonsense = 4, code = E0123, slug = "foo")] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): unknown argument + --> $DIR/diagnostic-derive.rs:98:40 + | +LL | #[diag(no_crate_example, code = E0123, slug = "foo")] + | ^^^^ + | + = note: only the `code` parameter is valid after the slug + +error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:105:5 + | +LL | #[suggestion = "bar"] + | ^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:112:8 + | +LL | #[diag(no_crate_example, code = E0456)] + | ^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:111:8 + | +LL | #[diag(no_crate_example, code = E0123)] + | ^^^^^^^^^^^^^^^^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:112:26 + | +LL | #[diag(no_crate_example, code = E0456)] + | ^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:111:26 + | +LL | #[diag(no_crate_example, code = E0123)] + | ^^^^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:118:40 + | +LL | #[diag(no_crate_example, code = E0123, code = E0456)] + | ^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:118:26 + | +LL | #[diag(no_crate_example, code = E0123, code = E0456)] + | ^^^^ + +error: derive(Diagnostic): diagnostic slug must be the first argument + --> $DIR/diagnostic-derive.rs:123:43 + | +LL | #[diag(no_crate_example, no_crate::example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:128:1 + | +LL | struct KindNotProvided {} + | ^^^^^^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:131:1 + | +LL | #[diag(code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/diagnostic-derive.rs:142:5 + | +LL | #[primary_span] + | ^ + +error: derive(Diagnostic): `#[nonsense]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:150:5 + | +LL | #[nonsense] + | ^ + +error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/diagnostic-derive.rs:167:5 + | +LL | #[label(no_crate_label)] + | ^ + +error: derive(Diagnostic): `name` doesn't refer to a field on this type + --> $DIR/diagnostic-derive.rs:175:46 + | +LL | #[suggestion(no_crate_suggestion, code = "{name}")] + | ^^^^^^^^ + +error: invalid format string: expected `}` but string was terminated + --> $DIR/diagnostic-derive.rs:180:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ expected `}` in format string + | + = note: if you intended to print `{`, you can escape it using `{{` + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: invalid format string: unmatched `}` found + --> $DIR/diagnostic-derive.rs:190:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ unmatched `}` in format string + | + = note: if you intended to print `}`, you can escape it using `}}` + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/diagnostic-derive.rs:210:5 + | +LL | #[label(no_crate_label)] + | ^ + +error: derive(Diagnostic): suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:229:5 + | +LL | #[suggestion(no_crate_suggestion)] + | ^ + +error: derive(Diagnostic): invalid nested attribute + --> $DIR/diagnostic-derive.rs:237:18 + | +LL | #[suggestion(nonsense = "bar")] + | ^^^^^^^^ + | + = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes + +error: derive(Diagnostic): suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:237:5 + | +LL | #[suggestion(nonsense = "bar")] + | ^ + +error: derive(Diagnostic): invalid nested attribute + --> $DIR/diagnostic-derive.rs:246:18 + | +LL | #[suggestion(msg = "bar")] + | ^^^ + | + = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes + +error: derive(Diagnostic): suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:246:5 + | +LL | #[suggestion(msg = "bar")] + | ^ + +error: derive(Diagnostic): wrong field type for suggestion + --> $DIR/diagnostic-derive.rs:269:5 + | +LL | #[suggestion(no_crate_suggestion, code = "This is suggested code")] + | ^ + | + = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:285:24 + | +LL | suggestion: (Span, Span, Applicability), + | ^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:285:18 + | +LL | suggestion: (Span, Span, Applicability), + | ^^^^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:293:33 + | +LL | suggestion: (Applicability, Applicability, Span), + | ^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:293:18 + | +LL | suggestion: (Applicability, Applicability, Span), + | ^^^^^^^^^^^^^ + +error: derive(Diagnostic): `#[label = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:300:5 + | +LL | #[label = "bar"] + | ^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:451:5 + | +LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")] + | ^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:453:24 + | +LL | suggestion: (Span, Applicability), + | ^^^^^^^^^^^^^ + +error: derive(Diagnostic): invalid applicability + --> $DIR/diagnostic-derive.rs:459:69 + | +LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")] + | ^^^^^^^^ + +error: derive(Diagnostic): the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()` + --> $DIR/diagnostic-derive.rs:526:5 + | +LL | #[help(no_crate_help)] + | ^ + +error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute + --> $DIR/diagnostic-derive.rs:535:32 + | +LL | #[label(no_crate_label, foo)] + | ^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/diagnostic-derive.rs:543:29 + | +LL | #[label(no_crate_label, foo = "...")] + | ^^^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/diagnostic-derive.rs:551:29 + | +LL | #[label(no_crate_label, foo("..."))] + | ^^^ + +error: derive(Diagnostic): `#[primary_span]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:563:5 + | +LL | #[primary_span] + | ^ + | + = help: the `primary_span` field attribute is not valid for lint diagnostics + +error: derive(Diagnostic): `#[error(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:583:1 + | +LL | #[error(no_crate_example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:583:1 + | +LL | #[error(no_crate_example, code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): `#[warn_(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:590:1 + | +LL | #[warn_(no_crate_example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:590:1 + | +LL | #[warn_(no_crate_example, code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:597:1 + | +LL | #[lint(no_crate_example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:597:1 + | +LL | #[lint(no_crate_example, code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:604:1 + | +LL | #[lint(no_crate_example, code = E0123)] + | ^ + +error: derive(Diagnostic): diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:604:1 + | +LL | #[lint(no_crate_example, code = E0123)] + | ^ + | + = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/diagnostic-derive.rs:613:53 + | +LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] + | ^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:613:39 + | +LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] + | ^^^^ + +error: derive(Diagnostic): wrong types for suggestion + --> $DIR/diagnostic-derive.rs:622:24 + | +LL | suggestion: (Span, usize), + | ^^^^^ + | + = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` + +error: derive(Diagnostic): wrong types for suggestion + --> $DIR/diagnostic-derive.rs:630:17 + | +LL | suggestion: (Span,), + | ^^^^^^^ + | + = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` + +error: derive(Diagnostic): suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:637:5 + | +LL | #[suggestion(no_crate_suggestion)] + | ^ + +error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:644:1 + | +LL | #[multipart_suggestion(no_crate_suggestion)] + | ^ + | + = help: consider creating a `Subdiagnostic` instead + +error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:647:1 + | +LL | #[multipart_suggestion()] + | ^ + | + = help: consider creating a `Subdiagnostic` instead + +error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:651:5 + | +LL | #[multipart_suggestion(no_crate_suggestion)] + | ^ + | + = help: consider creating a `Subdiagnostic` instead + +error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:659:1 + | +LL | #[suggestion(no_crate_suggestion, code = "...")] + | ^ + | + = help: `#[label]` and `#[suggestion]` can only be applied to fields + +error: derive(Diagnostic): `#[label]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:668:1 + | +LL | #[label] + | ^ + | + = help: `#[label]` and `#[suggestion]` can only be applied to fields + +error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:702:5 + | +LL | #[subdiagnostic(bad)] + | ^ + +error: derive(Diagnostic): `#[subdiagnostic = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:710:5 + | +LL | #[subdiagnostic = "bad"] + | ^ + +error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:718:5 + | +LL | #[subdiagnostic(bad, bad)] + | ^ + +error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:726:5 + | +LL | #[subdiagnostic("bad")] + | ^ + +error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:734:5 + | +LL | #[subdiagnostic(eager)] + | ^ + +error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:742:5 + | +LL | #[subdiagnostic(eager)] + | ^ + +error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:763:5 + | +LL | #[subdiagnostic(eager)] + | ^ + +error: derive(Diagnostic): expected at least one string literal for `code(...)` + --> $DIR/diagnostic-derive.rs:794:23 + | +LL | #[suggestion(code())] + | ^ + +error: derive(Diagnostic): `code(...)` must contain only string literals + --> $DIR/diagnostic-derive.rs:802:23 + | +LL | #[suggestion(code(foo))] + | ^^^ + +error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:826:5 + | +LL | #[suggestion(no_crate_suggestion, code = "")] + | ^ + | + = note: `#[suggestion(...)]` applied to `Vec` field is ambiguous + = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]` + = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/diagnostic-derive.rs:58:8 + | +LL | #[diag = "E0123"] + | ^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/diagnostic-derive.rs:802:23 + | +LL | #[suggestion(code(foo))] + | ^^^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/diagnostic-derive.rs:811:25 + | +LL | #[suggestion(code = 3)] + | ^ you might be missing crate `core` + +error: cannot find attribute `nonsense` in this scope + --> $DIR/diagnostic-derive.rs:63:3 + | +LL | #[nonsense(no_crate_example, code = E0123)] + | ^^^^^^^^ + +error: cannot find attribute `nonsense` in this scope + --> $DIR/diagnostic-derive.rs:150:7 + | +LL | #[nonsense] + | ^^^^^^^^ + +error: cannot find attribute `error` in this scope + --> $DIR/diagnostic-derive.rs:583:3 + | +LL | #[error(no_crate_example, code = E0123)] + | ^^^^^ + | +help: `error` is an attribute that can be used by the derive macro `Error`, you might be missing a `derive` attribute + | +LL + #[derive(Error)] +LL | struct ErrorAttribute {} + | + +error: cannot find attribute `warn_` in this scope + --> $DIR/diagnostic-derive.rs:590:3 + | +LL | #[warn_(no_crate_example, code = E0123)] + | ^^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[warn_(no_crate_example, code = E0123)] +LL + #[warn(no_crate_example, code = E0123)] + | + +error: cannot find attribute `lint` in this scope + --> $DIR/diagnostic-derive.rs:597:3 + | +LL | #[lint(no_crate_example, code = E0123)] + | ^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[lint(no_crate_example, code = E0123)] +LL + #[link(no_crate_example, code = E0123)] + | + +error: cannot find attribute `lint` in this scope + --> $DIR/diagnostic-derive.rs:604:3 + | +LL | #[lint(no_crate_example, code = E0123)] + | ^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[lint(no_crate_example, code = E0123)] +LL + #[link(no_crate_example, code = E0123)] + | + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:644:3 + | +LL | #[multipart_suggestion(no_crate_suggestion)] + | ^^^^^^^^^^^^^^^^^^^^ + | +help: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute + | +LL + #[derive(Subdiagnostic)] +LL | struct MultipartSuggestion { + | + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:647:3 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^ + | +help: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute + | +LL + #[derive(Subdiagnostic)] +LL | struct MultipartSuggestion { + | + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:651:7 + | +LL | #[multipart_suggestion(no_crate_suggestion)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute + +error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated` + --> $DIR/diagnostic-derive.rs:75:8 + | +LL | #[diag(nonsense, code = E0123)] + | ^^^^^^^^ not found in `crate::fluent_generated` + +error[E0425]: cannot find value `__code_34` in this scope + --> $DIR/diagnostic-derive.rs:808:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ not found in this scope + | + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied + --> $DIR/diagnostic-derive.rs:349:12 + | +LL | #[derive(Diagnostic)] + | ---------- required by a bound introduced by this call +... +LL | other: Hello, + | ^^^^^ unsatisfied trait bound + | +help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `Hello` + --> $DIR/diagnostic-derive.rs:40:1 + | +LL | struct Hello {} + | ^^^^^^^^^^^^ + = help: normalized in stderr +note: required by a bound in `Diag::<'a, G>::arg` + --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC + ::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC + | + = note: in this macro invocation + = note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 85 previous errors + +Some errors have detailed explanations: E0277, E0425, E0433. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs new file mode 100644 index 000000000000..6402b00ef0a9 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs @@ -0,0 +1,24 @@ +//@ rustc-env:CARGO_CRATE_NAME=rustc_dummy + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_span; +use rustc_span::symbol::Ident; +use rustc_span::Span; + +extern crate rustc_macros; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; + +extern crate rustc_middle; +use rustc_middle::ty::Ty; + +extern crate rustc_errors; +use rustc_errors::{Applicability, MultiSpan}; + +extern crate rustc_session; + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = E0123)] +//~^ ERROR diagnostic slug and crate name do not match +struct Hello {} diff --git a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr new file mode 100644 index 000000000000..4f54239f0fa3 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr @@ -0,0 +1,11 @@ +error: derive(Diagnostic): diagnostic slug and crate name do not match + --> $DIR/enforce_slug_naming.rs:22:8 + | +LL | #[diag(compiletest_example, code = E0123)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: slug is `compiletest_example` but the crate name is `rustc_dummy` + = help: expected a slug starting with `dummy_...` + +error: aborting due to 1 previous error + diff --git a/tests/ui-fulldeps/session-diagnostic/example.ftl b/tests/ui-fulldeps/session-diagnostic/example.ftl new file mode 100644 index 000000000000..1d1ba8e1bd5c --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/example.ftl @@ -0,0 +1,7 @@ +no_crate_example = this is an example message used in testing + .note = with a note + .help = with a help + .suggestion = with a suggestion + .label = with a label + +no_crate_bad_reference = {$r} does not exist diff --git a/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs new file mode 100644 index 000000000000..cbe9e3f4ef4c --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs @@ -0,0 +1,20 @@ +//@ run-fail +//@ compile-flags: --test +// test that messages referencing non-existent fields cause test failures + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_driver; +extern crate rustc_fluent_macro; +extern crate rustc_macros; +extern crate rustc_errors; +use rustc_macros::Diagnostic; +use rustc_errors::{DiagMessage, SubdiagMessage}; +extern crate rustc_session; + +rustc_fluent_macro::fluent_messages! { "./example.ftl" } + +#[derive(Diagnostic)] +#[diag(no_crate_bad_reference)] +struct BadRef; diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr deleted file mode 100644 index 8e634bf78797..000000000000 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr +++ /dev/null @@ -1,549 +0,0 @@ -error: derive(Diagnostic): label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive-inline.rs:49:1 - | -LL | #[label("example message")] - | ^ - -error: derive(Diagnostic): diagnostic message must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive-inline.rs:56:1 - | -LL | #[label] - | ^ - -error: derive(Diagnostic): `#[foo]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:65:1 - | -LL | #[foo] - | ^ - -error: derive(Diagnostic): `#[label = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:75:1 - | -LL | #[label = "..."] - | ^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/subdiagnostic-derive-inline.rs:84:9 - | -LL | #[label(bug = "...")] - | ^^^ - -error: derive(Diagnostic): diagnostic message must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive-inline.rs:84:1 - | -LL | #[label(bug = "...")] - | ^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/subdiagnostic-derive-inline.rs:102:9 - | -LL | #[label(slug = 4)] - | ^^^^ - -error: derive(Diagnostic): diagnostic message must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive-inline.rs:102:1 - | -LL | #[label(slug = 4)] - | ^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/subdiagnostic-derive-inline.rs:112:9 - | -LL | #[label(slug("..."))] - | ^^^^ - -error: derive(Diagnostic): diagnostic message must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive-inline.rs:112:1 - | -LL | #[label(slug("..."))] - | ^ - -error: derive(Diagnostic): diagnostic message must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive-inline.rs:122:1 - | -LL | #[label()] - | ^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/subdiagnostic-derive-inline.rs:131:28 - | -LL | #[label("example message", code = "...")] - | ^^^^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/subdiagnostic-derive-inline.rs:140:28 - | -LL | #[label("example message", applicability = "machine-applicable")] - | ^^^^^^^^^^^^^ - -error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive-inline.rs:149:1 - | -LL | #[foo] - | ^ - -error: derive(Diagnostic): `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:163:5 - | -LL | #[bar] - | ^ - -error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:175:5 - | -LL | #[bar = "..."] - | ^ - -error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:187:5 - | -LL | #[bar = 4] - | ^ - -error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:199:5 - | -LL | #[bar("...")] - | ^ - -error: derive(Diagnostic): no nested attribute expected here - --> $DIR/subdiagnostic-derive-inline.rs:211:13 - | -LL | #[label(code = "...")] - | ^^^^ - -error: derive(Diagnostic): diagnostic message must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive-inline.rs:211:5 - | -LL | #[label(code = "...")] - | ^ - -error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive-inline.rs:240:5 - | -LL | #[primary_span] - | ^ - -error: derive(Diagnostic): label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive-inline.rs:237:1 - | -LL | #[label("example message")] - | ^ - -error: derive(Diagnostic): `#[applicability]` is only valid on suggestions - --> $DIR/subdiagnostic-derive-inline.rs:250:5 - | -LL | #[applicability] - | ^ - -error: derive(Diagnostic): `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:260:5 - | -LL | #[bar] - | ^ - | - = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes - -error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:271:5 - | -LL | #[bar = "..."] - | ^ - -error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:282:5 - | -LL | #[bar("...")] - | ^ - | - = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes - -error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive-inline.rs:298:1 - | -LL | / union AC { -LL | | -LL | | span: u32, -LL | | b: u64, -LL | | } - | |_^ - -error: expected this path to be an identifier - --> $DIR/subdiagnostic-derive-inline.rs:313:28 - | -LL | #[label("example message", no_crate::example)] - | ^^^^^^^^^^^^^^^^^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/subdiagnostic-derive-inline.rs:326:5 - | -LL | #[primary_span] - | ^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive-inline.rs:323:5 - | -LL | #[primary_span] - | ^ - -error: derive(Diagnostic): subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive-inline.rs:332:8 - | -LL | struct AG { - | ^^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/subdiagnostic-derive-inline.rs:369:47 - | -LL | #[suggestion("example message", code = "...", code = "...")] - | ^^^^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive-inline.rs:369:33 - | -LL | #[suggestion("example message", code = "...", code = "...")] - | ^^^^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/subdiagnostic-derive-inline.rs:387:5 - | -LL | #[applicability] - | ^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive-inline.rs:384:5 - | -LL | #[applicability] - | ^ - -error: derive(Diagnostic): the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive-inline.rs:397:5 - | -LL | #[applicability] - | ^ - -error: derive(Diagnostic): suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive-inline.rs:410:1 - | -LL | #[suggestion("example message")] - | ^ - -error: derive(Diagnostic): invalid applicability - --> $DIR/subdiagnostic-derive-inline.rs:420:63 - | -LL | #[suggestion("example message", code = "...", applicability = "foo")] - | ^^^^^ - -error: derive(Diagnostic): suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive-inline.rs:438:1 - | -LL | #[suggestion("example message", code = "...")] - | ^ - -error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive-inline.rs:452:1 - | -LL | #[label] - | ^ - -error: derive(Diagnostic): `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive-inline.rs:472:40 - | -LL | #[suggestion("example message", code = "{var}", applicability = "machine-applicable")] - | ^^^^^^^ - -error: derive(Diagnostic): `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive-inline.rs:491:44 - | -LL | #[suggestion("example message", code = "{var}", applicability = "machine-applicable")] - | ^^^^^^^ - -error: derive(Diagnostic): `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:514:5 - | -LL | #[suggestion_part] - | ^ - | - = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead - -error: derive(Diagnostic): `#[suggestion_part(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:517:5 - | -LL | #[suggestion_part(code = "...")] - | ^ - | - = help: `#[suggestion_part(...)]` is only valid in multipart suggestions - -error: derive(Diagnostic): suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive-inline.rs:511:1 - | -LL | #[suggestion("example message", code = "...")] - | ^ - -error: derive(Diagnostic): invalid nested attribute - --> $DIR/subdiagnostic-derive-inline.rs:526:43 - | -LL | #[multipart_suggestion("example message", code = "...", applicability = "machine-applicable")] - | ^^^^ - | - = help: only `style` and `applicability` are valid nested attributes - -error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive-inline.rs:526:1 - | -LL | #[multipart_suggestion("example message", code = "...", applicability = "machine-applicable")] - | ^ - -error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive-inline.rs:536:5 - | -LL | #[suggestion_part] - | ^ - -error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive-inline.rs:544:5 - | -LL | #[suggestion_part()] - | ^ - -error: derive(Diagnostic): `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:553:5 - | -LL | #[primary_span] - | ^ - | - = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` - -error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive-inline.rs:550:1 - | -LL | #[multipart_suggestion("example message")] - | ^ - -error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive-inline.rs:561:5 - | -LL | #[suggestion_part] - | ^ - -error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive-inline.rs:564:5 - | -LL | #[suggestion_part()] - | ^ - -error: derive(Diagnostic): `code` is the only valid nested attribute - --> $DIR/subdiagnostic-derive-inline.rs:567:23 - | -LL | #[suggestion_part(foo = "bar")] - | ^^^ - -error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive-inline.rs:571:5 - | -LL | #[suggestion_part(code = "...")] - | ^ - -error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive-inline.rs:574:5 - | -LL | #[suggestion_part()] - | ^ - -error: expected `,` - --> $DIR/subdiagnostic-derive-inline.rs:567:27 - | -LL | #[suggestion_part(foo = "bar")] - | ^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/subdiagnostic-derive-inline.rs:582:37 - | -LL | #[suggestion_part(code = "...", code = ",,,")] - | ^^^^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive-inline.rs:582:23 - | -LL | #[suggestion_part(code = "...", code = ",,,")] - | ^^^^ - -error: derive(Diagnostic): `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` - --> $DIR/subdiagnostic-derive-inline.rs:611:5 - | -LL | #[applicability] - | ^ - -error: derive(Diagnostic): expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive-inline.rs:659:28 - | -LL | #[suggestion_part(code("foo"))] - | ^^^^^ - -error: unexpected token, expected `)` - --> $DIR/subdiagnostic-derive-inline.rs:659:28 - | -LL | #[suggestion_part(code("foo"))] - | ^^^^^ - -error: derive(Diagnostic): expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive-inline.rs:669:28 - | -LL | #[suggestion_part(code("foo", "bar"))] - | ^^^^^ - -error: unexpected token, expected `)` - --> $DIR/subdiagnostic-derive-inline.rs:669:28 - | -LL | #[suggestion_part(code("foo", "bar"))] - | ^^^^^ - -error: derive(Diagnostic): expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive-inline.rs:679:28 - | -LL | #[suggestion_part(code(3))] - | ^ - -error: unexpected token, expected `)` - --> $DIR/subdiagnostic-derive-inline.rs:679:28 - | -LL | #[suggestion_part(code(3))] - | ^ - -error: derive(Diagnostic): expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive-inline.rs:689:28 - | -LL | #[suggestion_part(code())] - | ^ - -error: expected string literal - --> $DIR/subdiagnostic-derive-inline.rs:698:30 - | -LL | #[suggestion_part(code = 3)] - | ^ - -error: derive(Diagnostic): attribute specified multiple times - --> $DIR/subdiagnostic-derive-inline.rs:740:1 - | -LL | #[suggestion("example message", code = "", style = "hidden", style = "normal")] - | ^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive-inline.rs:740:1 - | -LL | #[suggestion("example message", code = "", style = "hidden", style = "normal")] - | ^ - -error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:749:1 - | -LL | #[suggestion_hidden("example message", code = "")] - | ^ - | - = help: Use `#[suggestion(..., style = "hidden")]` instead - -error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:757:1 - | -LL | #[suggestion_hidden("example message", code = "", style = "normal")] - | ^ - | - = help: Use `#[suggestion(..., style = "hidden")]` instead - -error: derive(Diagnostic): invalid suggestion style - --> $DIR/subdiagnostic-derive-inline.rs:765:52 - | -LL | #[suggestion("example message", code = "", style = "foo")] - | ^^^^^ - | - = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` - -error: expected string literal - --> $DIR/subdiagnostic-derive-inline.rs:773:52 - | -LL | #[suggestion("example message", code = "", style = 42)] - | ^^ - -error: expected `=` - --> $DIR/subdiagnostic-derive-inline.rs:781:49 - | -LL | #[suggestion("example message", code = "", style)] - | ^ - -error: expected `=` - --> $DIR/subdiagnostic-derive-inline.rs:789:49 - | -LL | #[suggestion("example message", code = "", style("foo"))] - | ^ - -error: derive(Diagnostic): `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive-inline.rs:800:5 - | -LL | #[primary_span] - | ^ - | - = note: there must be exactly one primary span - = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead - -error: derive(Diagnostic): suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive-inline.rs:797:1 - | -LL | #[suggestion("example message", code = "")] - | ^ - -error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:65:3 - | -LL | #[foo] - | ^^^ - -error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:149:3 - | -LL | #[foo] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:163:7 - | -LL | #[bar] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:175:7 - | -LL | #[bar = "..."] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:187:7 - | -LL | #[bar = 4] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:199:7 - | -LL | #[bar("...")] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:260:7 - | -LL | #[bar] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:271:7 - | -LL | #[bar = "..."] - | ^^^ - -error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive-inline.rs:282:7 - | -LL | #[bar("...")] - | ^^^ - -error: aborting due to 82 previous errors - diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs similarity index 70% rename from tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs rename to tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 2aed4fa9465c..c837372a7a7a 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -1,5 +1,5 @@ //@ check-fail -// Tests error conditions for specifying inline subdiagnostics using #[derive(Subdiagnostic)] +// Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)] // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, // changing the output of this test. Since Subdiagnostic is strictly internal to the compiler @@ -12,17 +12,19 @@ #![crate_type = "lib"] extern crate rustc_errors; +extern crate rustc_fluent_macro; extern crate rustc_macros; extern crate rustc_session; extern crate rustc_span; -extern crate core; -use rustc_errors::{Applicability, DiagMessage}; +use rustc_errors::{Applicability, DiagMessage, SubdiagMessage}; use rustc_macros::Subdiagnostic; use rustc_span::Span; +rustc_fluent_macro::fluent_messages! { "./example.ftl" } + #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct A { #[primary_span] span: Span, @@ -31,13 +33,13 @@ struct A { #[derive(Subdiagnostic)] enum B { - #[label("example message")] + #[label(no_crate_example)] A { #[primary_span] span: Span, var: String, }, - #[label("example message")] + #[label(no_crate_example)] B { #[primary_span] span: Span, @@ -46,7 +48,7 @@ enum B { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] //~^ ERROR label without `#[primary_span]` field struct C { var: String, @@ -54,7 +56,7 @@ struct C { #[derive(Subdiagnostic)] #[label] -//~^ ERROR diagnostic message must be first argument +//~^ ERROR diagnostic slug must be first argument struct D { #[primary_span] span: Span, @@ -82,8 +84,8 @@ struct F { #[derive(Subdiagnostic)] #[label(bug = "...")] -//~^ ERROR no nested attribute expected here -//~| ERROR diagnostic message must be first argument +//~^ ERROR only `no_span` is a valid nested attribute +//~| ERROR diagnostic slug must be first argument struct G { #[primary_span] span: Span, @@ -92,6 +94,8 @@ struct G { #[derive(Subdiagnostic)] #[label("...")] +//~^ ERROR failed to resolve: you might be missing crate `core` +//~| NOTE you might be missing crate `core` struct H { #[primary_span] span: Span, @@ -100,8 +104,8 @@ struct H { #[derive(Subdiagnostic)] #[label(slug = 4)] -//~^ ERROR no nested attribute expected here -//~| ERROR diagnostic message must be first argument +//~^ ERROR only `no_span` is a valid nested attribute +//~| ERROR diagnostic slug must be first argument struct J { #[primary_span] span: Span, @@ -110,17 +114,27 @@ struct J { #[derive(Subdiagnostic)] #[label(slug("..."))] -//~^ ERROR no nested attribute expected here -//~| ERROR diagnostic message must be first argument +//~^ ERROR only `no_span` is a valid nested attribute +//~| ERROR diagnostic slug must be first argument struct K { #[primary_span] span: Span, var: String, } +#[derive(Subdiagnostic)] +#[label(slug)] +//~^ ERROR cannot find value `slug` in module `crate::fluent_generated` +//~^^ NOTE not found in `crate::fluent_generated` +struct L { + #[primary_span] + span: Span, + var: String, +} + #[derive(Subdiagnostic)] #[label()] -//~^ ERROR diagnostic message must be first argument of a `#[label(...)]` attribute +//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { #[primary_span] span: Span, @@ -128,8 +142,8 @@ struct M { } #[derive(Subdiagnostic)] -#[label("example message", code = "...")] -//~^ ERROR no nested attribute expected here +#[label(no_crate_example, code = "...")] +//~^ ERROR only `no_span` is a valid nested attribute struct N { #[primary_span] span: Span, @@ -137,8 +151,8 @@ struct N { } #[derive(Subdiagnostic)] -#[label("example message", applicability = "machine-applicable")] -//~^ ERROR no nested attribute expected here +#[label(no_crate_example, applicability = "machine-applicable")] +//~^ ERROR only `no_span` is a valid nested attribute struct O { #[primary_span] span: Span, @@ -150,7 +164,7 @@ struct O { //~^ ERROR cannot find attribute `foo` in this scope //~^^ ERROR unsupported type attribute for subdiagnostic enum enum P { - #[label("example message")] + #[label(no_crate_example)] A { #[primary_span] span: Span, @@ -209,8 +223,8 @@ enum T { #[derive(Subdiagnostic)] enum U { #[label(code = "...")] - //~^ ERROR diagnostic message must be first argument of a `#[label(...)]` attribute - //~| ERROR no nested attribute expected here + //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute + //~| ERROR only `no_span` is a valid nested attribute A { #[primary_span] span: Span, @@ -220,7 +234,7 @@ enum U { #[derive(Subdiagnostic)] enum V { - #[label("example message")] + #[label(no_crate_example)] A { #[primary_span] span: Span, @@ -234,7 +248,7 @@ enum V { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] //~^ ERROR label without `#[primary_span]` field struct W { #[primary_span] @@ -243,7 +257,7 @@ struct W { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct X { #[primary_span] span: Span, @@ -253,7 +267,7 @@ struct X { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct Y { #[primary_span] span: Span, @@ -264,7 +278,7 @@ struct Y { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct Z { #[primary_span] span: Span, @@ -275,7 +289,7 @@ struct Z { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct AA { #[primary_span] span: Span, @@ -286,7 +300,7 @@ struct AA { } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct AB { #[primary_span] span: Span, @@ -296,29 +310,30 @@ struct AB { #[derive(Subdiagnostic)] union AC { - //~^ ERROR unexpected unsupported untagged union + //~^ ERROR failed to resolve: you might be missing crate `core` + //~| NOTE you might be missing crate `core` span: u32, b: u64, } #[derive(Subdiagnostic)] -#[label("example message")] -#[label("example message")] +#[label(no_crate_example)] +#[label(no_crate_example)] struct AD { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[label("example message", no_crate::example)] -//~^ ERROR expected this path to be an identifier +#[label(no_crate_example, no_crate::example)] +//~^ ERROR a diagnostic slug must be the first argument to the attribute struct AE { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct AF { #[primary_span] //~^ NOTE previously specified here @@ -336,7 +351,7 @@ struct AG { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...")] +#[suggestion(no_crate_example, code = "...")] struct AH { #[primary_span] span: Span, @@ -347,7 +362,7 @@ struct AH { #[derive(Subdiagnostic)] enum AI { - #[suggestion("example message", code = "...")] + #[suggestion(no_crate_example, code = "...")] A { #[primary_span] span: Span, @@ -355,7 +370,7 @@ enum AI { applicability: Applicability, var: String, }, - #[suggestion("example message", code = "...")] + #[suggestion(no_crate_example, code = "...")] B { #[primary_span] span: Span, @@ -366,7 +381,7 @@ enum AI { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...", code = "...")] +#[suggestion(no_crate_example, code = "...", code = "...")] //~^ ERROR specified multiple times //~^^ NOTE previously specified here struct AJ { @@ -377,7 +392,7 @@ struct AJ { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...")] +#[suggestion(no_crate_example, code = "...")] struct AK { #[primary_span] span: Span, @@ -390,7 +405,7 @@ struct AK { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...")] +#[suggestion(no_crate_example, code = "...")] struct AL { #[primary_span] span: Span, @@ -400,14 +415,14 @@ struct AL { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...")] +#[suggestion(no_crate_example, code = "...")] struct AM { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message")] +#[suggestion(no_crate_example)] //~^ ERROR suggestion without `code = "..."` struct AN { #[primary_span] @@ -417,7 +432,7 @@ struct AN { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...", applicability = "foo")] +#[suggestion(no_crate_example, code = "...", applicability = "foo")] //~^ ERROR invalid applicability struct AO { #[primary_span] @@ -425,24 +440,24 @@ struct AO { } #[derive(Subdiagnostic)] -#[help("example message")] +#[help(no_crate_example)] struct AP { var: String, } #[derive(Subdiagnostic)] -#[note("example message")] +#[note(no_crate_example)] struct AQ; #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...")] +#[suggestion(no_crate_example, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct AR { var: String, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...", applicability = "machine-applicable")] +#[suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] struct AS { #[primary_span] span: Span, @@ -452,7 +467,7 @@ struct AS { #[label] //~^ ERROR unsupported type attribute for subdiagnostic enum enum AT { - #[label("example message")] + #[label(no_crate_example)] A { #[primary_span] span: Span, @@ -461,7 +476,7 @@ enum AT { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "{var}", applicability = "machine-applicable")] +#[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] struct AU { #[primary_span] span: Span, @@ -469,7 +484,7 @@ struct AU { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "{var}", applicability = "machine-applicable")] +#[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type struct AV { #[primary_span] @@ -478,7 +493,7 @@ struct AV { #[derive(Subdiagnostic)] enum AW { - #[suggestion("example message", code = "{var}", applicability = "machine-applicable")] + #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] A { #[primary_span] span: Span, @@ -488,7 +503,7 @@ enum AW { #[derive(Subdiagnostic)] enum AX { - #[suggestion("example message", code = "{var}", applicability = "machine-applicable")] + #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type A { #[primary_span] @@ -497,18 +512,18 @@ enum AX { } #[derive(Subdiagnostic)] -#[warning("example message")] +#[warning(no_crate_example)] struct AY {} #[derive(Subdiagnostic)] -#[warning("example message")] +#[warning(no_crate_example)] struct AZ { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "...")] +#[suggestion(no_crate_example, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct BA { #[suggestion_part] @@ -523,7 +538,7 @@ struct BA { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", code = "...", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~| ERROR invalid nested attribute struct BBa { @@ -531,7 +546,7 @@ struct BBa { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BBb { #[suggestion_part] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -539,7 +554,7 @@ struct BBb { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -547,7 +562,7 @@ struct BBc { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields struct BC { #[primary_span] @@ -556,7 +571,7 @@ struct BC { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] struct BD { #[suggestion_part] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -566,7 +581,8 @@ struct BD { span2: Span, #[suggestion_part(foo = "bar")] //~^ ERROR `code` is the only valid nested attribute - //~| ERROR expected `,` + //~| ERROR failed to resolve: you might be missing crate `core` + //~| NOTE you might be missing crate `core` span4: Span, #[suggestion_part(code = "...")] //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` @@ -577,7 +593,7 @@ struct BD { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BE { #[suggestion_part(code = "...", code = ",,,")] //~^ ERROR specified multiple times @@ -586,7 +602,7 @@ struct BE { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BF { #[suggestion_part(code = "(")] first: Span, @@ -595,7 +611,7 @@ struct BF { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] struct BG { #[applicability] appl: Applicability, @@ -606,7 +622,7 @@ struct BG { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BH { #[applicability] //~^ ERROR `#[applicability]` has no effect @@ -618,14 +634,14 @@ struct BH { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message", applicability = "machine-applicable")] +#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BI { #[suggestion_part(code = "")] spans: Vec, } #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct BJ { #[primary_span] span: Span, @@ -634,7 +650,7 @@ struct BJ { /// with a doc comment on the type.. #[derive(Subdiagnostic)] -#[label("example message")] +#[label(no_crate_example)] struct BK { /// ..and the field #[primary_span] @@ -645,7 +661,7 @@ struct BK { #[derive(Subdiagnostic)] enum BL { /// ..and the variant.. - #[label("example message")] + #[label(no_crate_example)] Foo { /// ..and the field #[primary_span] @@ -654,37 +670,40 @@ enum BL { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] struct BM { #[suggestion_part(code("foo"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token, expected `)` + //~| ERROR failed to resolve: you might be missing crate `core` + //~| NOTE you might be missing crate `core` span: Span, r#type: String, } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] struct BN { #[suggestion_part(code("foo", "bar"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token, expected `)` + //~| ERROR failed to resolve: you might be missing crate `core` + //~| NOTE you might be missing crate `core` span: Span, r#type: String, } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] struct BO { #[suggestion_part(code(3))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token, expected `)` + //~| ERROR failed to resolve: you might be missing crate `core` + //~| NOTE you might be missing crate `core` span: Span, r#type: String, } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +#[multipart_suggestion(no_crate_example)] struct BP { #[suggestion_part(code())] //~^ ERROR expected exactly one string literal for `code = ...` @@ -693,51 +712,55 @@ struct BP { } #[derive(Subdiagnostic)] -#[multipart_suggestion("example message")] +//~^ ERROR cannot find value `__code_29` in this scope +//~| NOTE in this expansion +//~| NOTE not found in this scope +#[multipart_suggestion(no_crate_example)] struct BQ { #[suggestion_part(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: you might be missing crate `core` + //~| NOTE you might be missing crate `core` span: Span, r#type: String, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "")] +#[suggestion(no_crate_example, code = "")] struct SuggestionStyleDefault { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = "short")] +#[suggestion(no_crate_example, code = "", style = "short")] struct SuggestionStyleShort { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = "hidden")] +#[suggestion(no_crate_example, code = "", style = "hidden")] struct SuggestionStyleHidden { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = "verbose")] +#[suggestion(no_crate_example, code = "", style = "verbose")] struct SuggestionStyleVerbose { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = "tool-only")] +#[suggestion(no_crate_example, code = "", style = "tool-only")] struct SuggestionStyleToolOnly { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = "hidden", style = "normal")] +#[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] //~^ ERROR specified multiple times //~| NOTE previously specified here struct SuggestionStyleTwice { @@ -746,7 +769,7 @@ struct SuggestionStyleTwice { } #[derive(Subdiagnostic)] -#[suggestion_hidden("example message", code = "")] +#[suggestion_hidden(no_crate_example, code = "")] //~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute struct SuggestionStyleOldSyntax { #[primary_span] @@ -754,7 +777,7 @@ struct SuggestionStyleOldSyntax { } #[derive(Subdiagnostic)] -#[suggestion_hidden("example message", code = "", style = "normal")] +#[suggestion_hidden(no_crate_example, code = "", style = "normal")] //~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute struct SuggestionStyleOldAndNewSyntax { #[primary_span] @@ -762,7 +785,7 @@ struct SuggestionStyleOldAndNewSyntax { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = "foo")] +#[suggestion(no_crate_example, code = "", style = "foo")] //~^ ERROR invalid suggestion style struct SuggestionStyleInvalid1 { #[primary_span] @@ -770,31 +793,33 @@ struct SuggestionStyleInvalid1 { } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style = 42)] -//~^ ERROR expected string literal +#[suggestion(no_crate_example, code = "", style = 42)] +//~^ ERROR expected `= "xxx"` struct SuggestionStyleInvalid2 { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style)] -//~^ ERROR expected `=` +#[suggestion(no_crate_example, code = "", style)] +//~^ ERROR a diagnostic slug must be the first argument to the attribute struct SuggestionStyleInvalid3 { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "", style("foo"))] -//~^ ERROR expected `=` +#[suggestion(no_crate_example, code = "", style("foo"))] +//~^ ERROR expected `= "xxx"` +//~| ERROR failed to resolve: you might be missing crate `core` +//~| NOTE you might be missing crate `core` struct SuggestionStyleInvalid4 { #[primary_span] sub: Span, } #[derive(Subdiagnostic)] -#[suggestion("example message", code = "")] +#[suggestion(no_crate_example, code = "")] //~^ ERROR suggestion without `#[primary_span]` field struct PrimarySpanOnVec { #[primary_span] diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr new file mode 100644 index 000000000000..0ae7ba4c4973 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -0,0 +1,573 @@ +error: derive(Diagnostic): label without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:51:1 + | +LL | #[label(no_crate_example)] + | ^ + +error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:58:1 + | +LL | #[label] + | ^ + +error: derive(Diagnostic): `#[foo]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:67:1 + | +LL | #[foo] + | ^ + +error: derive(Diagnostic): `#[label = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:77:1 + | +LL | #[label = "..."] + | ^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:86:9 + | +LL | #[label(bug = "...")] + | ^^^ + +error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:86:1 + | +LL | #[label(bug = "...")] + | ^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:106:9 + | +LL | #[label(slug = 4)] + | ^^^^ + +error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:106:1 + | +LL | #[label(slug = 4)] + | ^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:116:9 + | +LL | #[label(slug("..."))] + | ^^^^ + +error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:116:1 + | +LL | #[label(slug("..."))] + | ^ + +error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:136:1 + | +LL | #[label()] + | ^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:145:27 + | +LL | #[label(no_crate_example, code = "...")] + | ^^^^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:154:27 + | +LL | #[label(no_crate_example, applicability = "machine-applicable")] + | ^^^^^^^^^^^^^ + +error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:163:1 + | +LL | #[foo] + | ^ + +error: derive(Diagnostic): `#[bar]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:177:5 + | +LL | #[bar] + | ^ + +error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:189:5 + | +LL | #[bar = "..."] + | ^ + +error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:201:5 + | +LL | #[bar = 4] + | ^ + +error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:213:5 + | +LL | #[bar("...")] + | ^ + +error: derive(Diagnostic): only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:225:13 + | +LL | #[label(code = "...")] + | ^^^^ + +error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:225:5 + | +LL | #[label(code = "...")] + | ^ + +error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:254:5 + | +LL | #[primary_span] + | ^ + +error: derive(Diagnostic): label without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:251:1 + | +LL | #[label(no_crate_example)] + | ^ + +error: derive(Diagnostic): `#[applicability]` is only valid on suggestions + --> $DIR/subdiagnostic-derive.rs:264:5 + | +LL | #[applicability] + | ^ + +error: derive(Diagnostic): `#[bar]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:274:5 + | +LL | #[bar] + | ^ + | + = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes + +error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:285:5 + | +LL | #[bar = "..."] + | ^ + +error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:296:5 + | +LL | #[bar("...")] + | ^ + | + = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes + +error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute + --> $DIR/subdiagnostic-derive.rs:328:44 + | +LL | #[label(no_crate_example, no_crate::example)] + | ^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/subdiagnostic-derive.rs:341:5 + | +LL | #[primary_span] + | ^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:338:5 + | +LL | #[primary_span] + | ^ + +error: derive(Diagnostic): subdiagnostic kind not specified + --> $DIR/subdiagnostic-derive.rs:347:8 + | +LL | struct AG { + | ^^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/subdiagnostic-derive.rs:384:46 + | +LL | #[suggestion(no_crate_example, code = "...", code = "...")] + | ^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:384:32 + | +LL | #[suggestion(no_crate_example, code = "...", code = "...")] + | ^^^^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/subdiagnostic-derive.rs:402:5 + | +LL | #[applicability] + | ^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:399:5 + | +LL | #[applicability] + | ^ + +error: derive(Diagnostic): the `#[applicability]` attribute can only be applied to fields of type `Applicability` + --> $DIR/subdiagnostic-derive.rs:412:5 + | +LL | #[applicability] + | ^ + +error: derive(Diagnostic): suggestion without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:425:1 + | +LL | #[suggestion(no_crate_example)] + | ^ + +error: derive(Diagnostic): invalid applicability + --> $DIR/subdiagnostic-derive.rs:435:62 + | +LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")] + | ^^^^^ + +error: derive(Diagnostic): suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:453:1 + | +LL | #[suggestion(no_crate_example, code = "...")] + | ^ + +error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:467:1 + | +LL | #[label] + | ^ + +error: derive(Diagnostic): `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:487:39 + | +LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: derive(Diagnostic): `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:506:43 + | +LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: derive(Diagnostic): `#[suggestion_part]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:529:5 + | +LL | #[suggestion_part] + | ^ + | + = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead + +error: derive(Diagnostic): `#[suggestion_part(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:532:5 + | +LL | #[suggestion_part(code = "...")] + | ^ + | + = help: `#[suggestion_part(...)]` is only valid in multipart suggestions + +error: derive(Diagnostic): suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:526:1 + | +LL | #[suggestion(no_crate_example, code = "...")] + | ^ + +error: derive(Diagnostic): invalid nested attribute + --> $DIR/subdiagnostic-derive.rs:541:42 + | +LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] + | ^^^^ + | + = help: only `no_span`, `style` and `applicability` are valid nested attributes + +error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields + --> $DIR/subdiagnostic-derive.rs:541:1 + | +LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] + | ^ + +error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:551:5 + | +LL | #[suggestion_part] + | ^ + +error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:559:5 + | +LL | #[suggestion_part()] + | ^ + +error: derive(Diagnostic): `#[primary_span]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:568:5 + | +LL | #[primary_span] + | ^ + | + = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` + +error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields + --> $DIR/subdiagnostic-derive.rs:565:1 + | +LL | #[multipart_suggestion(no_crate_example)] + | ^ + +error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:576:5 + | +LL | #[suggestion_part] + | ^ + +error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:579:5 + | +LL | #[suggestion_part()] + | ^ + +error: derive(Diagnostic): `code` is the only valid nested attribute + --> $DIR/subdiagnostic-derive.rs:582:23 + | +LL | #[suggestion_part(foo = "bar")] + | ^^^ + +error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:587:5 + | +LL | #[suggestion_part(code = "...")] + | ^ + +error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:590:5 + | +LL | #[suggestion_part()] + | ^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/subdiagnostic-derive.rs:598:37 + | +LL | #[suggestion_part(code = "...", code = ",,,")] + | ^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:598:23 + | +LL | #[suggestion_part(code = "...", code = ",,,")] + | ^^^^ + +error: derive(Diagnostic): `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` + --> $DIR/subdiagnostic-derive.rs:627:5 + | +LL | #[applicability] + | ^ + +error: derive(Diagnostic): expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:675:34 + | +LL | #[suggestion_part(code("foo"))] + | ^ + +error: derive(Diagnostic): expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:686:41 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^ + +error: derive(Diagnostic): expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:697:30 + | +LL | #[suggestion_part(code(3))] + | ^ + +error: derive(Diagnostic): expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:708:29 + | +LL | #[suggestion_part(code())] + | ^ + +error: derive(Diagnostic): attribute specified multiple times + --> $DIR/subdiagnostic-derive.rs:763:1 + | +LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] + | ^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:763:1 + | +LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] + | ^ + +error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:772:1 + | +LL | #[suggestion_hidden(no_crate_example, code = "")] + | ^ + | + = help: Use `#[suggestion(..., style = "hidden")]` instead + +error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:780:1 + | +LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] + | ^ + | + = help: Use `#[suggestion(..., style = "hidden")]` instead + +error: derive(Diagnostic): invalid suggestion style + --> $DIR/subdiagnostic-derive.rs:788:51 + | +LL | #[suggestion(no_crate_example, code = "", style = "foo")] + | ^^^^^ + | + = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` + +error: derive(Diagnostic): expected `= "xxx"` + --> $DIR/subdiagnostic-derive.rs:796:49 + | +LL | #[suggestion(no_crate_example, code = "", style = 42)] + | ^ + +error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute + --> $DIR/subdiagnostic-derive.rs:804:48 + | +LL | #[suggestion(no_crate_example, code = "", style)] + | ^ + +error: derive(Diagnostic): expected `= "xxx"` + --> $DIR/subdiagnostic-derive.rs:812:48 + | +LL | #[suggestion(no_crate_example, code = "", style("foo"))] + | ^ + +error: derive(Diagnostic): `#[primary_span]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:825:5 + | +LL | #[primary_span] + | ^ + | + = note: there must be exactly one primary span + = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead + +error: derive(Diagnostic): suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:822:1 + | +LL | #[suggestion(no_crate_example, code = "")] + | ^ + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:96:9 + | +LL | #[label("...")] + | ^^^^^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:312:1 + | +LL | union AC { + | ^^^^^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:582:27 + | +LL | #[suggestion_part(foo = "bar")] + | ^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:675:28 + | +LL | #[suggestion_part(code("foo"))] + | ^^^^^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:686:28 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^^^^^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:697:28 + | +LL | #[suggestion_part(code(3))] + | ^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:720:30 + | +LL | #[suggestion_part(code = 3)] + | ^ you might be missing crate `core` + +error[E0433]: failed to resolve: you might be missing crate `core` + --> $DIR/subdiagnostic-derive.rs:812:48 + | +LL | #[suggestion(no_crate_example, code = "", style("foo"))] + | ^ you might be missing crate `core` + +error: cannot find attribute `foo` in this scope + --> $DIR/subdiagnostic-derive.rs:67:3 + | +LL | #[foo] + | ^^^ + +error: cannot find attribute `foo` in this scope + --> $DIR/subdiagnostic-derive.rs:163:3 + | +LL | #[foo] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:177:7 + | +LL | #[bar] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:189:7 + | +LL | #[bar = "..."] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:201:7 + | +LL | #[bar = 4] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:213:7 + | +LL | #[bar("...")] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:274:7 + | +LL | #[bar] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:285:7 + | +LL | #[bar = "..."] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:296:7 + | +LL | #[bar("...")] + | ^^^ + +error[E0425]: cannot find value `slug` in module `crate::fluent_generated` + --> $DIR/subdiagnostic-derive.rs:126:9 + | +LL | #[label(slug)] + | ^^^^ not found in `crate::fluent_generated` + +error[E0425]: cannot find value `__code_29` in this scope + --> $DIR/subdiagnostic-derive.rs:714:10 + | +LL | #[derive(Subdiagnostic)] + | ^^^^^^^^^^^^^ not found in this scope + | + = note: this error originates in the derive macro `Subdiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 86 previous errors + +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/README.md b/tests/ui/README.md index 16cdde08431c..4c91f313a735 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -10,23 +10,17 @@ These tests deal with *Application Binary Interfaces* (ABI), mostly relating to Tests for unsupported ABIs can be made cross-platform by using the `extern "rust-invalid"` ABI, which is considered unsupported on every platform. -## `tests/ui/alloc-error` - -These tests exercise alloc error handling. - -See . - ## `tests/ui/allocator` These tests exercise `#![feature(allocator_api)]` and the `#[global_allocator]` attribute. See [Allocator traits and `std::heap` #32838](https://github.com/rust-lang/rust/issues/32838). -## `tests/ui/annotate-moves` +## `tests/ui/alloc-error` -These tests exercise the `annotate-moves` feature. +These tests exercise alloc error handling. -See [`annotate-moves` | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/annotate-moves.html) +See . ## `tests/ui/annotate-snippet` @@ -40,26 +34,20 @@ These tests exercise the [`annotate-snippets`]-based emitter implementation. These tests deal with anonymous parameters (no name, only type), a deprecated feature that becomes a hard error in Edition 2018. -## `tests/ui/any` - -These tests exercise the `try_as_dyn` feature. - -See [`core::any::try_as_dyn`](https://doc.rust-lang.org/nightly/core/any/fn.try_as_dyn.html) - ## `tests/ui/argfile`: External files providing command line arguments These tests exercise rustc reading command line arguments from an externally provided argfile (`@argsfile`). See [Implement `@argsfile` to read arguments from command line #63576](https://github.com/rust-lang/rust/issues/63576). -## `tests/ui/argument-suggestions`: Argument suggestions - -Calling a function with the wrong number of arguments causes a compilation failure, but the compiler is able to, in some cases, provide suggestions on how to fix the error, such as which arguments to add or delete. These tests exercise the quality of such diagnostics. - ## `tests/ui/array-slice-vec`: Arrays, slices and vectors Exercises various aspects surrounding basic collection types `[]`, `&[]` and `Vec`. E.g. type-checking, out-of-bounds indices, attempted instructions which are allowed in other programming languages, and more. +## `tests/ui/argument-suggestions`: Argument suggestions + +Calling a function with the wrong number of arguments causes a compilation failure, but the compiler is able to, in some cases, provide suggestions on how to fix the error, such as which arguments to add or delete. These tests exercise the quality of such diagnostics. + ## `tests/ui/asm`: `asm!` macro These tests exercise the `asm!` macro, which is used for adding inline assembly. @@ -172,6 +160,10 @@ See: - [`std::box::Boxed`](https://doc.rust-lang.org/std/boxed/struct.Box.html) - [Tracking issue for `box_patterns` feature #29641](https://github.com/rust-lang/rust/issues/29641) +## `tests/ui/btreemap/`: B-Tree Maps + +Tests focused on `BTreeMap` collections and their compiler interactions. E.g. collection patterns, iterator behavior, and trait implementations specific to `BTreeMap`. See [`std::collections::BTreeMap`](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html). + ## `tests/ui/builtin-superkinds/`: Built-in Trait Hierarchy Tests Tests for built-in trait hierarchy (Send, Sync, Sized, etc.) and their supertrait relationships. E.g. auto traits and marker trait constraints. @@ -180,10 +172,6 @@ See [RFC 3729: Hierarchy of Sized traits](https://github.com/rust-lang/rfcs/pull Defining custom auto traits with the `auto` keyword belongs to `tests/ui/auto-traits/` instead. -## `tests/ui/c-variadic`: C Variadic Function - -Tests for FFI with C varargs (`va_list`). - ## `tests/ui/cast/`: Type Casting Tests for type casting using the `as` operator. Includes tests for valid/invalid casts between primitive types, trait objects, and custom types. For example, check that trying to cast `i32` into `bool` results in a helpful error message. @@ -202,16 +190,16 @@ Tests for the `--check-cfg` compiler mechanism for checking cfg configurations, See [Checking conditional configurations | The rustc book](https://doc.rust-lang.org/rustc/check-cfg.html). +## `tests/ui/closure_context/`: Closure type inference in context + +Tests for closure type inference with respect to surrounding scopes, mostly quality of diagnostics. + ## `tests/ui/closure-expected-type/`: Closure type inference Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the *expected type* we have alongside the *actual types* that we get from inputs. **FIXME**: Appears to have significant overlap with `tests/ui/closure_context` and `tests/ui/functions-closures/closure-expected-type`. Needs further investigation. -## `tests/ui/closure_context`: Closure type inference in context - -Tests for closure type inference with respect to surrounding scopes, mostly quality of diagnostics. - ## `tests/ui/closures/`: General Closure Tests Any closure-focused tests that does not fit in the other more specific closure subdirectories belong here. E.g. syntax, `move`, lifetimes. @@ -256,12 +244,6 @@ See: This directory only contains one highly specific test. Other coinduction tests can be found down the deeply located `tests/ui/traits/next-solver/cycles/coinduction/` subdirectory. -## `tests/ui/collections` - -These tests exercise the `collections` library. For example, `BTreeMap` and `HashMap`. - -See [`std::collections`](https://doc.rust-lang.org/std/collections/index.html) - ## `tests/ui/command/`: `std::process::Command` This directory is actually for the standard library [`std::process::Command`](https://doc.rust-lang.org/std/process/struct.Command.html) type, where some tests are too difficult or inconvenient to write as unit tests or integration tests within the standard library itself. @@ -303,6 +285,10 @@ See: - [Tracking Issue for complex generic constants: `feature(generic_const_exprs)` #76560](https://github.com/rust-lang/rust/issues/76560) - [Const generics | Reference](https://doc.rust-lang.org/reference/items/generics.html#const-generics) +## `tests/ui/const_prop/`: Constant Propagation + +Tests exercising `ConstProp` mir-opt pass (mostly regression tests). See . + ## `tests/ui/const-ptr/`: Constant Pointers Tests exercise const raw pointers. E.g. pointer arithmetic, casting and dereferencing, always with a `const`. @@ -313,10 +299,6 @@ See: - [`std::ptr`](https://doc.rust-lang.org/std/ptr/index.html) - [Pointer types | Reference](https://doc.rust-lang.org/reference/types/pointer.html) -## `tests/ui/const_prop`: Constant Propagation - -Tests exercising `ConstProp` mir-opt pass (mostly regression tests). See . - ## `tests/ui/consts/`: General Constant Evaluation Anything to do with constants, which does not fit in the previous two `const` categories, goes here. This does not always imply use of the `const` keyword - other values considered constant, such as defining an enum variant as `enum Foo { Variant = 5 }` also counts. @@ -358,6 +340,10 @@ Tests for `#[bench]`, `#[test_case]` attributes and the `custom_test_frameworks` See [Tracking issue for eRFC 2318, Custom test frameworks #50297](https://github.com/rust-lang/rust/issues/50297). +## `tests/ui/c-variadic/`: C Variadic Function + +Tests for FFI with C varargs (`va_list`). + ## `tests/ui/cycle-trait/`: Trait Cycle Detection Tests for detection and handling of cyclic trait dependencies. @@ -394,18 +380,6 @@ These tests use the unstable command line option `query-dep-graph` to examine th Tests for `#[deprecated]` attribute and `deprecated_in_future` internal lint. -## `tests/ui/deref` - -Tests for `Deref` and `DerefMut` traits. - -## `tests/ui/deref-patterns`: `#![feature(deref_patterns)]` and `#![feature(string_deref_patterns)]` - -Tests for `#![feature(deref_patterns)]` and `#![feature(string_deref_patterns)]`. See [Deref patterns | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/language-features/deref-patterns.html). - -**FIXME**: May have some overlap with `tests/ui/pattern/deref-patterns`. - -See [`std::ops::Deref`](https://doc.rust-lang.org/std/ops/trait.Deref.html) and [`std::ops::DerefMut`](https://doc.rust-lang.org/std/ops/trait.DerefMut.html) - ## `tests/ui/derived-errors/`: Derived Error Messages Tests for quality of diagnostics involving suppression of cascading errors in some cases to avoid overwhelming the user. @@ -432,10 +406,6 @@ These tests revolve around command-line flags which change the way error/warning **FIXME**: Check redundancy with `annotate-snippet`, which is another emitter. -## `tests/ui/diagnostic-width`: `--diagnostic-width` - -Everything to do with `--diagnostic-width`. - ## `tests/ui/diagnostic_namespace/` Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic attribute namespace](https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md). @@ -444,6 +414,10 @@ Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic att This directory contains tests and infrastructure related to the diagnostics system, including support for translatable diagnostics +## `tests/ui/diagnostic-width/`: `--diagnostic-width` + +Everything to do with `--diagnostic-width`. + ## `tests/ui/did_you_mean/` Tests for miscellaneous suggestions. @@ -456,10 +430,6 @@ Exercises diagnostics for when a code block attempts to gain ownership of a non- Exercises diagnostics for disallowed struct destructuring. -## `tests/ui/dist` - -Tests that require distribution artifacts. - ## `tests/ui/dollar-crate/`: `$crate` used with the `use` keyword There are a few rules - which are checked in this directory - to follow when using `$crate` - it must be used in the start of a `use` line and is a reserved identifier. @@ -491,6 +461,10 @@ Tests for dynamically-sized types (DSTs). See [Dynamically Sized Types | Referen Tests about duplicated symbol names and associated errors, such as using the `#[export_name]` attribute to rename a function with the same name as another function. +## `tests/ui/dynamically-sized-types/`: Dynamically Sized Types + +**FIXME**: should be coalesced with `tests/ui/dst`. + ## `tests/ui/dyn-compatibility/`: Dyn-compatibility Tests for dyn-compatibility of traits. @@ -518,10 +492,6 @@ These tests run in specific Rust editions, such as Rust 2015 or Rust 2018, and c **FIXME**: Maybe regroup `rust-2018`, `rust-2021` and `rust-2024` under this umbrella? -## `tests/ui/eii`: Externally Implementable Items - -Exercises `eii` keyword. - ## `tests/ui/empty/`: Various tests related to the concept of "empty" **FIXME**: These tests need better homes, this is not very informative. @@ -601,10 +571,6 @@ See: - [`ffi_const` | The Unstable book](https://doc.rust-lang.org/unstable-book/language-features/ffi-const.html) - [`ffi_pure` | The Unstable book](https://doc.rust-lang.org/beta/unstable-book/language-features/ffi-pure.html) -## `tests/ui/float` - -See: [Tracking Issue for `f16` and `f128` float types #116909](https://github.com/rust-lang/rust/issues/116909) - ## `tests/ui/fmt/` Exercises the `format!` macro. @@ -613,16 +579,6 @@ Exercises the `format!` macro. A broad category of tests on functions. -## `tests/ui/fn_traits` - -Tests for `#![feature(fn_traits)]`. See [`fn_traits` | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/library-features/fn-traits.html). - -## `tests/ui/for-loop-while` - -Anything to do with loops and `for`, `loop` and `while` keywords to express them. - -**FIXME**: After `ui/for` is merged into this, also carry over its SUMMARY text. - ## `tests/ui/force-inlining/`: `#[rustc_force_inline]` Tests for `#[rustc_force_inline]`, which will force a function to always be labelled as inline by the compiler (it will be inserted at the point of its call instead of being used as a normal function call.) If the compiler is unable to inline the function, an error will be reported. See . @@ -633,6 +589,12 @@ Tests for `extern "C"` and `extern "Rust`. **FIXME**: Check for potential overlap/merge with `ui/c-variadic` and/or `ui/extern`. +## `tests/ui/for-loop-while/` + +Anything to do with loops and `for`, `loop` and `while` keywords to express them. + +**FIXME**: After `ui/for` is merged into this, also carry over its SUMMARY text. + ## `tests/ui/frontmatter/` Tests for `#![feature(frontmatter)]`. See [Tracking Issue for `frontmatter` #136889](https://github.com/rust-lang/rust/issues/136889). @@ -641,6 +603,12 @@ Tests for `#![feature(frontmatter)]`. See [Tracking Issue for `frontmatter` #136 Tests for diagnostics when there may be identically named types that need further qualifications to disambiguate. +## `tests/ui/functional-struct-update/` + +Functional Struct Update is the name for the idiom by which one can write `..` at the end of a struct literal expression to fill in all remaining fields of the struct literal by using `` as the source for them. + +See [RFC 0736 Privacy-respecting Functional Struct Update](https://github.com/rust-lang/rfcs/blob/master/text/0736-privacy-respecting-fru.md). + ## `tests/ui/function-pointer/` Tests on function pointers, such as testing their compatibility with higher-ranked trait bounds. @@ -650,12 +618,6 @@ See: - [Function pointer types | Reference](https://doc.rust-lang.org/reference/types/function-pointer.html) - [Higher-ranked trait bounds | Nomicon](https://doc.rust-lang.org/nomicon/hrtb.html) -## `tests/ui/functional-struct-update/` - -Functional Struct Update is the name for the idiom by which one can write `..` at the end of a struct literal expression to fill in all remaining fields of the struct literal by using `` as the source for them. - -See [RFC 0736 Privacy-respecting Functional Struct Update](https://github.com/rust-lang/rfcs/blob/master/text/0736-privacy-respecting-fru.md). - ## `tests/ui/functions-closures/` Tests on closures. See [Closure expressions | Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html). @@ -678,6 +640,10 @@ Tests on range patterns where one of the bounds is not a direct value. **FIXME**: Overlaps with `ui/range`. `impossible_range.rs` is particularly suspected to be a duplicate test. +## `tests/ui/hashmap/` + +Tests for the standard library collection [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html). + ## `tests/ui/higher-ranked/` Tests for higher-ranked trait bounds. @@ -703,14 +669,14 @@ This test category revolves around trait objects with `Sized` having illegal ope Tests on lifetime elision in impl function signatures. See [Lifetime elision | Nomicon](https://doc.rust-lang.org/nomicon/lifetime-elision.html). -## `tests/ui/impl-trait/` - -Tests for trait impls. - ## `tests/ui/implied-bounds/` See [Implied bounds | Reference](https://doc.rust-lang.org/reference/trait-bounds.html#implied-bounds). +## `tests/ui/impl-trait/` + +Tests for trait impls. + ## `tests/ui/imports/` Tests for module system and imports. @@ -836,12 +802,6 @@ Broad directory on lifetimes, including proper specifiers, lifetimes not living These tests exercises numerical limits, such as `[[u8; 1518599999]; 1518600000]`. -## `tests/ui/link-native-libs/` - -Tests for `#[link(name = "", kind = "")]` and `-l` command line flag. - -See [Tracking Issue for linking modifiers for native libraries #81490](https://github.com/rust-lang/rust/issues/81490). - ## `tests/ui/linkage-attr/` Tests for the linkage attribute `#[linkage]` of `#![feature(linkage)]`. @@ -854,6 +814,12 @@ Tests on code which fails during the linking stage, or which contain arguments a See [Linkage | Reference](https://doc.rust-lang.org/reference/linkage.html). +## `tests/ui/link-native-libs/` + +Tests for `#[link(name = "", kind = "")]` and `-l` command line flag. + +See [Tracking Issue for linking modifiers for native libraries #81490](https://github.com/rust-lang/rust/issues/81490). + ## `tests/ui/lint/` Tests for the lint infrastructure, lint levels, lint reasons, etc. @@ -869,10 +835,6 @@ Tests exercising analysis for unused variables, unreachable statements, function **FIXME**: This seems unrelated to "liveness" as defined in the rustc compiler guide. Is this misleadingly named? https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/lifetime_parameters.html#liveness-and-universal-regions -## `tests/ui/loop-match` - -Tests for `loop` with `match` expressions. - ## `tests/ui/loops/` Tests on the `loop` construct. @@ -909,6 +871,12 @@ See [Tracking issue for allowing overlapping implementations for marker trait #2 Broad category of tests on `match` constructs. +## `tests/ui/meta/`: Tests for compiletest itself + +These tests check the function of the UI test suite at large and Compiletest in itself. + +**FIXME**: This should absolutely be merged with `tests/ui/compiletest-self-test/`. + ## `tests/ui/methods/` A broad category for anything related to methods and method resolution. @@ -973,10 +941,6 @@ See [RFC 3550 New Range](https://github.com/rust-lang/rfcs/blob/master/text/3550 Tests for Non-lexical lifetimes. See [RFC 2094 NLL](https://rust-lang.github.io/rfcs/2094-nll.html). -## `tests/ui/no_std/` - -Tests for where the standard library is disabled through `#![no_std]`. - ## `tests/ui/non_modrs_mods/` Despite the size of the directory, this is a single test, spawning a sprawling `mod` dependency tree and checking its successful build. @@ -989,6 +953,10 @@ A very similar principle as `non_modrs_mods`, but with an added inline `mod` sta **FIXME**: Consider merge with `tests/ui/modules/`, keeping the directory structure. +## `tests/ui/no_std/` + +Tests for where the standard library is disabled through `#![no_std]`. + ## `tests/ui/not-panic/` Tests checking various types, such as `&RefCell`, and whether they are not `UnwindSafe` as expected. @@ -1013,15 +981,6 @@ Contains a single test. Check that we reject the ancient Rust syntax `x <- y` an **FIXME**: Definitely should be rehomed, maybe to `tests/ui/deprecation/`. -## `tests/ui/offload` - -Exercises the offload feature. - -See: - -- [`std::offload` | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/offload/internals.html) -- [Tracking Issue for GPU-offload #131513](https://github.com/rust-lang/rust/issues/131513) - ## `tests/ui/offset-of/` Exercises the [`std::mem::offset_of` macro](https://doc.rust-lang.org/beta/std/mem/macro.offset_of.html). @@ -1080,16 +1039,6 @@ Broad category of tests surrounding patterns. See [Patterns | Reference](https:/ **FIXME**: Some overlap with `tests/ui/match/`. -## `tests/ui/pin` - -**FIXME**: Consider merging with `tests/ui/pin-macro`. - -## `tests/ui/pin-ergonomics` - -Exercises the `#![feature(pin_ergonomics)]` feature. - -See [Tracking issue for pin ergonomics #130494](https://github.com/rust-lang/rust/issues/130494) - ## `tests/ui/pin-macro/` See [`std::pin`](https://doc.rust-lang.org/std/pin/). @@ -1110,10 +1059,6 @@ Exercises the `-Z print-type-sizes` flag. Exercises on name privacy. E.g. the meaning of `pub`, `pub(crate)`, etc. -## `tests/ui/proc-macro/` - -Broad category of tests on proc-macros. See [Procedural Macros | Reference](https://doc.rust-lang.org/reference/procedural-macros.html). - ## `tests/ui/process/` Some standard library process tests which are hard to write within standard library crate tests. @@ -1122,6 +1067,10 @@ Some standard library process tests which are hard to write within standard libr Some standard library process termination tests which are hard to write within standard library crate tests. +## `tests/ui/proc-macro/` + +Broad category of tests on proc-macros. See [Procedural Macros | Reference](https://doc.rust-lang.org/reference/procedural-macros.html). + ## `tests/ui/ptr_ops/`: Using operations on a pointer Contains only 2 tests, related to a single issue, which was about an error caused by using addition on a pointer to `i8`. @@ -1154,12 +1103,6 @@ Reachability tests, primarily unreachable code and coercions into the never type **FIXME**: Check for overlap with `ui/liveness`. -## `tests/ui/reborrow` - -Exercises the `#![feature(reborrow)]` feature. - -See [Tracking Issue for Reborrow trait lang experiment #145612](https://github.com/rust-lang/rust/issues/145612) - ## `tests/ui/recursion/` Broad category of tests exercising recursions (compile test and run time), in functions, macros, `type` definitions, and more. @@ -1172,12 +1115,6 @@ Sets a recursion limit on recursive code. **FIXME**: Should be merged with `tests/ui/recursion/`. -## `tests/ui/reflection/` - -Exercises the `#![feature(type_info)]` feature. - -See [Tracking Issue for type_info #146922](https://github.com/rust-lang/rust/issues/146922) - ## `tests/ui/regions/` **FIXME**: Maybe merge with `ui/lifetimes`. @@ -1220,44 +1157,22 @@ Exercises `.rmeta` crate metadata and the `--emit=metadata` cli flag. Tests for runtime environment on which Rust programs are executed. E.g. Unix `SIGPIPE`. -## `tests/ui/rust-2018` +## `tests/ui/rust-{2018,2021,2024}/` -Tests that exercise behaviors and features specific to the Rust 2018 edition. - -## `tests/ui/rust-2021` - -Tests that exercise behaviors and features specific to the Rust 2021 edition. - -## `tests/ui/rust-2024` - -Tests that exercise behaviors and features specific to the Rust 2024 edition. +Tests that exercise behaviors and features that are specific to editions. ## `tests/ui/rustc-env` Tests on environmental variables that affect `rustc`. -## `tests/ui/rustc_public-ir-print` - -Some tests for pretty printing of rustc_public's IR. - ## `tests/ui/rustdoc` Hybrid tests that exercises `rustdoc`, and also some joint `rustdoc`/`rustc` interactions. -## `tests/ui/sanitize-attr` - -Tests for the `#![feature(sanitize)]` attribute. - -See [Sanitize | The Unstable Book](https://doc.rust-lang.org/unstable-book/language-features/sanitize.html). - ## `tests/ui/sanitizer/` Exercises sanitizer support. See [Sanitizer | The rustc book](https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html). -## `tests/ui/scalable-vectors` - -See [Tracking Issue for Scalable Vectors #145052](https://github.com/rust-lang/rust/issues/145052) - ## `tests/ui/self/`: `self` keyword Tests with erroneous ways of using `self`, such as using `this.x` syntax as seen in other languages, having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`). It also contains correct uses of `self` which have previously been observed to cause ICEs. @@ -1296,12 +1211,6 @@ This is a test directory for the specific error case where a lifetime never gets While many tests here involve the `Sized` trait directly, some instead test, for example the slight variations between returning a zero-sized `Vec` and a `Vec` with one item, where one has no known type and the other does. -## `tests/ui/sized-hierarchy` - -Tests for `#![feature(sized_hierarchy)]` attribute. - -See [Tracking Issue for Sized Hierarchy #144404](https://github.com/rust-lang/rust/issues/144404) - ## `tests/ui/span/` An assorted collection of tests that involves specific diagnostic spans. @@ -1316,9 +1225,9 @@ See [Tracking issue for specialization (RFC 1210) #31844](https://github.com/rus Stability attributes used internally by the standard library: `#[stable()]` and `#[unstable()]`. -## `tests/ui/stack-probes` +## `tests/ui/rustc_public-ir-print/` -**FIXME**: Contains a single test, should likely be rehomed to `tests/ui/abi`. +Some tests for pretty printing of rustc_public's IR. ## `tests/ui/stack-protector/`: `-Z stack-protector` command line flag @@ -1450,10 +1359,6 @@ Tests surrounding [`std::mem::transmute`](https://doc.rust-lang.org/std/mem/fn.t Exercises compiler development support flag `-Z treat-err-as-bug`. -## `tests/ui/trimmed-paths/` - -Tests for the `#[doc(hidden)]` items. - ## `tests/ui/trivial-bounds/` `#![feature(trivial_bounds)]`. See [RFC 2056 Allow trivial where clause constraints](https://github.com/rust-lang/rfcs/blob/master/text/2056-allow-trivial-where-clause-constraints.md). @@ -1488,13 +1393,17 @@ Tests for `type` aliases in the context of `enum` variants, such as that applied `#![feature(type_alias_impl_trait)]`. See [Type Alias Impl Trait | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/language-features/type-alias-impl-trait.html). +## `tests/ui/typeck/` + +General collection of type checking related tests. + ## `tests/ui/type-inference/` General collection of type inference related tests. -## `tests/ui/typeck` +## `tests/ui/typeof/` -General collection of type checking related tests. +`typeof` keyword, reserved but unimplemented. ## `tests/ui/ufcs/` @@ -1506,6 +1415,12 @@ See [RFC 0132 Unified Function Call Syntax](https://github.com/rust-lang/rfcs/bl See [Tracking issue for Fn traits (`unboxed_closures` & `fn_traits` feature)](https://github.com/rust-lang/rust/issues/29625). +## `tests/ui/underscore-imports/` + +See [Underscore imports | Reference](https://doc.rust-lang.org/reference/items/use-declarations.html#underscore-imports). + +**FIXME**: should become a subdirectory of `tests/ui/imports/`. + ## `tests/ui/underscore-lifetime/`: `'_` elided lifetime Exercises [anonymous elided lifetimes](https://doc.rust-lang.org/reference/lifetime-elision.html). @@ -1568,11 +1483,7 @@ See: **FIXME**: Seems to also contain more generic tests that fit in `tests/ui/unsized/`. -## `tests/ui/unstable-feature-bound` - -Tests for gating and diagnostics when unstable features are used. - -## `tests/ui/unused-crate-deps` +## `tests/ui/unused-crate-deps/` Exercises the `unused_crate_dependencies` lint. diff --git a/tests/ui/abi/avr-sram.disable_sram.stderr b/tests/ui/abi/avr-sram.disable_sram.stderr deleted file mode 100644 index 31b9084f73a4..000000000000 --- a/tests/ui/abi/avr-sram.disable_sram.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: target feature `sram` cannot be disabled with `-Ctarget-feature`: devices that have no SRAM are unsupported - | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 - -warning: target feature `sram` must be enabled to ensure that the ABI of the current target can be implemented correctly - | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 - -warning: 2 warnings emitted - diff --git a/tests/ui/abi/avr-sram.no_sram.stderr b/tests/ui/abi/avr-sram.no_sram.stderr deleted file mode 100644 index 3f74bf66f190..000000000000 --- a/tests/ui/abi/avr-sram.no_sram.stderr +++ /dev/null @@ -1,7 +0,0 @@ -warning: target feature `sram` must be enabled to ensure that the ABI of the current target can be implemented correctly - | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 - -warning: 1 warning emitted - diff --git a/tests/ui/abi/avr-sram.rs b/tests/ui/abi/avr-sram.rs deleted file mode 100644 index 0266f7d6b22c..000000000000 --- a/tests/ui/abi/avr-sram.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ revisions: has_sram no_sram disable_sram -//@ build-pass -//@[has_sram] compile-flags: --target avr-none -C target-cpu=atmega328p -//@[has_sram] needs-llvm-components: avr -//@[no_sram] compile-flags: --target avr-none -C target-cpu=attiny11 -//@[no_sram] needs-llvm-components: avr -//@[disable_sram] compile-flags: --target avr-none -C target-cpu=atmega328p -C target-feature=-sram -//@[disable_sram] needs-llvm-components: avr -//@ ignore-backends: gcc -//[no_sram,disable_sram]~? WARN target feature `sram` must be enabled -//[disable_sram]~? WARN target feature `sram` cannot be disabled with `-Ctarget-feature` - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 6071ad9bb435..84294ab34311 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -78,6 +78,7 @@ // FIXME: some targets are broken in various ways. // Hence there are `cfg` throughout this test to disable parts of it on those targets. +// sparc64: https://github.com/rust-lang/rust/issues/115336 // mips64: https://github.com/rust-lang/rust/issues/115404 extern crate minicore; @@ -245,7 +246,7 @@ test_transparent!(zst, Zst); test_transparent!(unit, ()); test_transparent!(enum_, Option); test_transparent!(enum_niched, Option<&'static i32>); -#[cfg(not(any(target_arch = "mips64")))] +#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] mod tuples { use super::*; // mixing in some floats since they often get special treatment @@ -259,6 +260,7 @@ mod tuples { test_transparent!(tuple, (i32, f32, i64, f64)); } // Some targets have special rules for arrays. +#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] mod arrays { use super::*; test_transparent!(empty_array, [u32; 0]); diff --git a/tests/ui/abi/debug.generic.stderr b/tests/ui/abi/debug.generic.stderr index b154c3fa201e..8a031b79780a 100644 --- a/tests/ui/abi/debug.generic.stderr +++ b/tests/ui/abi/debug.generic.stderr @@ -1,36 +1,3 @@ -error: `#[rustc_abi]` attribute cannot be used on constants - --> $DIR/debug.rs:42:1 - | -LL | #[rustc_abi(debug)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_abi]` can be applied to functions and type aliases - -error: `#[rustc_abi]` attribute cannot be used on associated consts - --> $DIR/debug.rs:46:5 - | -LL | #[rustc_abi(debug)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_abi]` can be applied to functions and type aliases - -error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/debug.rs:74:1 - | -LL | #[rustc_abi("assert_eq")] - | ^^^^^^^^^^^-------------^ - | | - | valid arguments are `assert_eq` or `debug` - | -help: try changing it to one of the following valid forms of the attribute - | -LL - #[rustc_abi("assert_eq")] -LL + #[rustc_abi(assert_eq)] - | -LL - #[rustc_abi("assert_eq")] -LL + #[rustc_abi(debug)] - | - error: fn_abi_of(test) = FnAbi { args: [ ArgAbi { @@ -917,6 +884,12 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = help: the trait `Sized` is not implemented for `str` = note: only the last element of a tuple may have a dynamically sized type +error: unrecognized argument + --> $DIR/debug.rs:74:13 + | +LL | #[rustc_abi("assert_eq")] + | ^^^^^^^^^^^ + error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions --> $DIR/debug.rs:47:5 | @@ -1013,7 +986,6 @@ error: fn_abi_of(assoc_test) = FnAbi { LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 12 previous errors -Some errors have detailed explanations: E0277, E0539. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.loongarch64.stderr b/tests/ui/abi/debug.loongarch64.stderr index 68bcd736e47c..00bd3febde4e 100644 --- a/tests/ui/abi/debug.loongarch64.stderr +++ b/tests/ui/abi/debug.loongarch64.stderr @@ -1,36 +1,3 @@ -error: `#[rustc_abi]` attribute cannot be used on constants - --> $DIR/debug.rs:42:1 - | -LL | #[rustc_abi(debug)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_abi]` can be applied to functions and type aliases - -error: `#[rustc_abi]` attribute cannot be used on associated consts - --> $DIR/debug.rs:46:5 - | -LL | #[rustc_abi(debug)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_abi]` can be applied to functions and type aliases - -error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/debug.rs:74:1 - | -LL | #[rustc_abi("assert_eq")] - | ^^^^^^^^^^^-------------^ - | | - | valid arguments are `assert_eq` or `debug` - | -help: try changing it to one of the following valid forms of the attribute - | -LL - #[rustc_abi("assert_eq")] -LL + #[rustc_abi(assert_eq)] - | -LL - #[rustc_abi("assert_eq")] -LL + #[rustc_abi(debug)] - | - error: fn_abi_of(test) = FnAbi { args: [ ArgAbi { @@ -917,6 +884,12 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = help: the trait `Sized` is not implemented for `str` = note: only the last element of a tuple may have a dynamically sized type +error: unrecognized argument + --> $DIR/debug.rs:74:13 + | +LL | #[rustc_abi("assert_eq")] + | ^^^^^^^^^^^ + error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions --> $DIR/debug.rs:47:5 | @@ -1013,7 +986,6 @@ error: fn_abi_of(assoc_test) = FnAbi { LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 12 previous errors -Some errors have detailed explanations: E0277, E0539. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.riscv64.stderr b/tests/ui/abi/debug.riscv64.stderr index 68bcd736e47c..00bd3febde4e 100644 --- a/tests/ui/abi/debug.riscv64.stderr +++ b/tests/ui/abi/debug.riscv64.stderr @@ -1,36 +1,3 @@ -error: `#[rustc_abi]` attribute cannot be used on constants - --> $DIR/debug.rs:42:1 - | -LL | #[rustc_abi(debug)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_abi]` can be applied to functions and type aliases - -error: `#[rustc_abi]` attribute cannot be used on associated consts - --> $DIR/debug.rs:46:5 - | -LL | #[rustc_abi(debug)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_abi]` can be applied to functions and type aliases - -error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/debug.rs:74:1 - | -LL | #[rustc_abi("assert_eq")] - | ^^^^^^^^^^^-------------^ - | | - | valid arguments are `assert_eq` or `debug` - | -help: try changing it to one of the following valid forms of the attribute - | -LL - #[rustc_abi("assert_eq")] -LL + #[rustc_abi(assert_eq)] - | -LL - #[rustc_abi("assert_eq")] -LL + #[rustc_abi(debug)] - | - error: fn_abi_of(test) = FnAbi { args: [ ArgAbi { @@ -917,6 +884,12 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = help: the trait `Sized` is not implemented for `str` = note: only the last element of a tuple may have a dynamically sized type +error: unrecognized argument + --> $DIR/debug.rs:74:13 + | +LL | #[rustc_abi("assert_eq")] + | ^^^^^^^^^^^ + error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions --> $DIR/debug.rs:47:5 | @@ -1013,7 +986,6 @@ error: fn_abi_of(assoc_test) = FnAbi { LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 12 previous errors -Some errors have detailed explanations: E0277, E0539. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.rs b/tests/ui/abi/debug.rs index 42ea14ec51d0..2e34fa5d7df4 100644 --- a/tests/ui/abi/debug.rs +++ b/tests/ui/abi/debug.rs @@ -39,12 +39,12 @@ type TestFnPtr = fn(bool) -> u8; //~ ERROR: fn_abi #[rustc_abi(debug)] fn test_generic(_x: *const T) {} //~ ERROR: fn_abi -#[rustc_abi(debug)] //~ ERROR: `#[rustc_abi]` attribute cannot be used on constants -const C: () = (); //~ ERROR: `#[rustc_abi]` can only be applied to +#[rustc_abi(debug)] +const C: () = (); //~ ERROR: can only be applied to impl S { - #[rustc_abi(debug)] //~ ERROR: `#[rustc_abi]` attribute cannot be used on assoc - const C: () = (); //~ ERROR: `#[rustc_abi]` can only be applied to + #[rustc_abi(debug)] + const C: () = (); //~ ERROR: can only be applied to } impl S { @@ -71,5 +71,5 @@ type TestAbiNeSign = (fn(i32), fn(u32)); //~ ERROR: ABIs are not compatible #[rustc_abi(assert_eq)] type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); //~ ERROR: cannot be known at compilation time -#[rustc_abi("assert_eq")] //~ ERROR malformed `rustc_abi` attribute input +#[rustc_abi("assert_eq")] //~ ERROR unrecognized argument type Bad = u32; diff --git a/tests/ui/abi/rust-preserve-none-cc.rs b/tests/ui/abi/rust-preserve-none-cc.rs deleted file mode 100644 index deacb926971c..000000000000 --- a/tests/ui/abi/rust-preserve-none-cc.rs +++ /dev/null @@ -1,67 +0,0 @@ -//@ run-pass -//@ needs-unwind - -#![feature(rust_preserve_none_cc)] - -struct CrateOf<'a> { - mcintosh: f64, - golden_delicious: u64, - jonagold: Option<&'a u64>, - rome: [u64; 12], -} - -#[inline(never)] -extern "rust-preserve-none" fn oven_explosion() { - panic!("bad time"); -} - -#[inline(never)] -fn bite_into(yummy: u64) -> u64 { - let did_it_actually = std::panic::catch_unwind(move || { - oven_explosion() - }); - assert!(did_it_actually.is_err()); - yummy - 25 -} - -#[inline(never)] -extern "rust-preserve-none" fn lotsa_apples( - honeycrisp: u64, - gala: u32, - fuji: f64, - granny_smith: &[u64], - pink_lady: (), - and_a: CrateOf<'static>, - cosmic_crisp: u64, - ambrosia: f64, - winesap: &[u64], -) -> (u64, f64, u64, u64) { - assert_eq!(honeycrisp, 220); - assert_eq!(gala, 140); - assert_eq!(fuji, 210.54201234); - assert_eq!(granny_smith, &[180, 210]); - assert_eq!(pink_lady, ()); - assert_eq!(and_a.mcintosh, 150.0); - assert_eq!(and_a.golden_delicious, 185); - assert_eq!(and_a.jonagold, None); // my scales can't weight these gargantuans. - assert_eq!(and_a.rome, [180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202]); - assert_eq!(cosmic_crisp, 270); - assert_eq!(ambrosia, 193.1); - assert_eq!(winesap, &[]); - ( - and_a.rome.iter().sum(), - fuji + ambrosia, - cosmic_crisp - honeycrisp, - bite_into(and_a.golden_delicious) - ) -} - -fn main() { - let pie = lotsa_apples(220, 140, 210.54201234, &[180, 210], (), CrateOf { - mcintosh: 150.0, - golden_delicious: 185, - jonagold: None, - rome: [180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202] - }, 270, 193.1, &[]); - assert_eq!(pie, (2292, 403.64201234, 50, 160)); -} diff --git a/tests/ui/abi/s390x-softfloat-gate.disable-softfloat.stderr b/tests/ui/abi/s390x-softfloat-gate.disable-softfloat.stderr deleted file mode 100644 index e82d5b744a26..000000000000 --- a/tests/ui/abi/s390x-softfloat-gate.disable-softfloat.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsupported ABI-configuration feature - | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 - -warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly - | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 - -warning: 2 warnings emitted - diff --git a/tests/ui/abi/s390x-softfloat-gate.enable-softfloat.stderr b/tests/ui/abi/s390x-softfloat-gate.enable-softfloat.stderr deleted file mode 100644 index ecc96e448dcf..000000000000 --- a/tests/ui/abi/s390x-softfloat-gate.enable-softfloat.stderr +++ /dev/null @@ -1,7 +0,0 @@ -warning: target feature `vector` must be disabled to ensure that the ABI of the current target can be implemented correctly - | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 - -warning: 1 warning emitted - diff --git a/tests/ui/abi/s390x-softfloat-gate.rs b/tests/ui/abi/s390x-softfloat-gate.rs deleted file mode 100644 index 496929eb0955..000000000000 --- a/tests/ui/abi/s390x-softfloat-gate.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ add-minicore -//@ revisions: disable-softfloat enable-softfloat -//@ assembly-output: emit-asm -//@ compile-flags: -Copt-level=3 --crate-type=lib - -// we expect the build to fail in the feature -//@ build-pass -//@ [enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat -//@ [enable-softfloat] compile-flags: -C target-feature=+vector -//@ [enable-softfloat] needs-llvm-components: systemz -//@ [disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu -//@ [disable-softfloat] compile-flags: -C target-feature=+soft-float -//@ [disable-softfloat] needs-llvm-components: systemz -//@ ignore-backends: gcc - -//[disable-softfloat]~? WARN target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly -//[disable-softfloat]~? WARN target feature `soft-float` cannot be enabled with `-Ctarget-feature` -//[enable-softfloat]~? WARN target feature `vector` must be disabled to ensure that the ABI of the current target can be implemented correctly - -#![feature(no_core, lang_items)] -#![no_std] -#![no_core] - -extern crate minicore; -use minicore::*; - -extern "C" { - fn extern_func(value: f64) -> f64; -} - -#[no_mangle] -extern "C" fn test_softfloat() -> f64 { - let value = 3.141_f64; - - unsafe { extern_func(value) } ; - - 2.718_f64 -} diff --git a/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr index cda51a211324..0e8e6637507d 100644 --- a/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr +++ b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr @@ -1,4 +1,4 @@ -warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsupported ABI-configuration feature +warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: currently unsupported ABI-configuration feature | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116344 diff --git a/tests/ui/argument-suggestions/disjoint-spans-issue-151607.rs b/tests/ui/argument-suggestions/disjoint-spans-issue-151607.rs deleted file mode 100644 index 31390faa488b..000000000000 --- a/tests/ui/argument-suggestions/disjoint-spans-issue-151607.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Regression test for #151607 -// The ICE was "all spans must be disjoint" when emitting diagnostics -// with overlapping suggestion spans. - -struct B; -struct D; -struct F; -fn foo(g: F, y: F, e: &E) { - //~^ ERROR cannot find type `E` in this scope - foo(B, g, D, E, F, G) - //~^ ERROR this function takes 3 arguments but 6 arguments were supplied - //~| ERROR cannot find value `E` in this scope - //~| ERROR cannot find value `G` in this scope -} - -fn main() {} diff --git a/tests/ui/argument-suggestions/disjoint-spans-issue-151607.stderr b/tests/ui/argument-suggestions/disjoint-spans-issue-151607.stderr deleted file mode 100644 index f1bda1203347..000000000000 --- a/tests/ui/argument-suggestions/disjoint-spans-issue-151607.stderr +++ /dev/null @@ -1,85 +0,0 @@ -error[E0425]: cannot find type `E` in this scope - --> $DIR/disjoint-spans-issue-151607.rs:8:24 - | -LL | struct B; - | --------- similarly named struct `B` defined here -... -LL | fn foo(g: F, y: F, e: &E) { - | ^ - | -help: a struct with a similar name exists - | -LL - fn foo(g: F, y: F, e: &E) { -LL + fn foo(g: F, y: F, e: &B) { - | -help: you might be missing a type parameter - | -LL | fn foo(g: F, y: F, e: &E) { - | +++ - -error[E0425]: cannot find value `E` in this scope - --> $DIR/disjoint-spans-issue-151607.rs:10:18 - | -LL | foo(B, g, D, E, F, G) - | ^ - | -help: a local variable with a similar name exists - | -LL - foo(B, g, D, E, F, G) -LL + foo(B, g, D, e, F, G) - | -help: consider importing one of these constants - | -LL + use std::f128::consts::E; - | -LL + use std::f16::consts::E; - | -LL + use std::f32::consts::E; - | -LL + use std::f64::consts::E; - | - -error[E0425]: cannot find value `G` in this scope - --> $DIR/disjoint-spans-issue-151607.rs:10:24 - | -LL | foo(B, g, D, E, F, G) - | ^ - | -help: a local variable with a similar name exists - | -LL - foo(B, g, D, E, F, G) -LL + foo(B, g, D, E, F, g) - | -help: you might be missing a const parameter - | -LL | fn foo(g: F, y: F, e: &E) { - | +++++++++++++++++++++ - -error[E0061]: this function takes 3 arguments but 6 arguments were supplied - --> $DIR/disjoint-spans-issue-151607.rs:10:5 - | -LL | foo(B, g, D, E, F, G) - | ^^^ - - - unexpected argument #4 - | | | - | | unexpected argument #3 of type `D` - | unexpected argument #1 of type `B` - | -note: function defined here - --> $DIR/disjoint-spans-issue-151607.rs:8:4 - | -LL | fn foo(g: F, y: F, e: &E) { - | ^^^ ----- -help: consider borrowing here - | -LL | foo(B, g, D, E, F, &G) - | + -help: remove the extra arguments - | -LL - foo(B, g, D, E, F, G) -LL + foo(, g, F, G) - | - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0061, E0425. -For more information about an error, try `rustc --explain E0061`. diff --git a/tests/ui/array-slice-vec/array_const_index-2.rs b/tests/ui/array-slice-vec/array_const_index-2.rs index 8dcfc294aae5..30338e0ab87c 100644 --- a/tests/ui/array-slice-vec/array_const_index-2.rs +++ b/tests/ui/array-slice-vec/array_const_index-2.rs @@ -1,5 +1,8 @@ //@ run-pass #![allow(dead_code)] +#![allow(stable_features)] + +#![feature(const_indexing)] fn main() { const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; diff --git a/tests/ui/array-slice-vec/slice-of-zero-size-elements.rs b/tests/ui/array-slice-vec/slice-of-zero-size-elements.rs index ea7d8f8be2bf..7aa8a251fec5 100644 --- a/tests/ui/array-slice-vec/slice-of-zero-size-elements.rs +++ b/tests/ui/array-slice-vec/slice-of-zero-size-elements.rs @@ -1,6 +1,10 @@ //@ run-pass +#![allow(stable_features)] + //@ compile-flags: -C debug-assertions +#![feature(iter_to_slice)] + use std::slice; fn foo(v: &[T]) -> Option<&[T]> { diff --git a/tests/ui/asm/.gitattributes b/tests/ui/asm/.gitattributes deleted file mode 100644 index 5d6f83c0e18c..000000000000 --- a/tests/ui/asm/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Disable EOL normalization, as it is deliberately denormalized -normalize-offsets-for-crlf.s -text diff --git a/tests/ui/asm/aarch64/type-check-2.stderr b/tests/ui/asm/aarch64/type-check-2.stderr index 2cd767db0334..84bc5f08b4ed 100644 --- a/tests/ui/asm/aarch64/type-check-2.stderr +++ b/tests/ui/asm/aarch64/type-check-2.stderr @@ -21,6 +21,7 @@ LL | asm!("{}", in(reg) vec![0]); | ^^^^^^^ | = note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot use value of type `(i32, i32, i32)` for inline assembly --> $DIR/type-check-2.rs:36:28 diff --git a/tests/ui/asm/aarch64v8r.rs b/tests/ui/asm/aarch64v8r.rs deleted file mode 100644 index abc254ad5f8e..000000000000 --- a/tests/ui/asm/aarch64v8r.rs +++ /dev/null @@ -1,144 +0,0 @@ -// Codegen test of mandatory Armv8-R AArch64 extensions - -// The Cortex-R82 CPU is an implementation of the Arm v8-R AArch64 ISA so -// it also implements the ISA-level mandatory extensions. We check that with a revision -//@ add-minicore -//@ revisions: hf sf r82 -//@ [hf] compile-flags: --target aarch64v8r-unknown-none -//@ [hf] needs-llvm-components: aarch64 -//@ [sf] compile-flags: --target aarch64v8r-unknown-none-softfloat -//@ [sf] needs-llvm-components: aarch64 -//@ [r82] compile-flags: --target aarch64v8r-unknown-none -C target-cpu=cortex-r82 -//@ [r82] needs-llvm-components: aarch64 -//@ build-pass -//@ ignore-backends: gcc - -#![feature(no_core)] -#![no_core] -#![no_main] -#![crate_type = "rlib"] -#![deny(dead_code)] // ensures we call all private functions from the public one - -extern crate minicore; -use minicore::*; - -/* # Mandatory extensions - * - * A comment indicates that the extension has no associated assembly instruction and cannot be - * codegen tested - * - * ## References: - * - * - Arm Architecture Reference Manual for R-profile AArch64 architecture (DDI 0628) -- has the - * list of mandatory extensions - * - Arm Architecture Reference Manual for A-profile architecture (ARM DDI 0487) -- has the - * mapping from features to instructions - * - Feature names in A-profile architecture (109697_0100_02_en Version 1.0) -- overview of - * what each extension mean - * */ -pub fn mandatory_extensions() { - /* ## ARMv8.0 */ - feat_aa64(); - // FEAT_AA64EL0 - // FEAT_AA64EL1 - // FEAT_AA64EL2 - feat_crc32(); - // FEAT_EL0 - // FEAT_EL1 - // FEAT_EL2 - // FEAT_IVIPT - - /* ## ARMv8.1 */ - // FEAT_HPDS - feat_lse(); - feat_pan(); - - /* ## ARMv8.2 */ - feat_asmv8p2(); - feat_dpb(); - // FEAT_Debugv8p2 - // FEAT_PAN2 - feat_ras(); - // FEAT_TTCNP - feat_uao(); - // FEAT_XNX - - /* ## ARMv8.3 */ - feat_lrcpc(); - feat_pauth(); - - /* ## ARMv8.4 */ - feat_dit(); - // FEAT_Debugv8p4 - feat_flagm(); - // FEAT_IDST - feat_lrcpc2(); - // FEAT_LSE2 - // FEAT_S2FWB - feat_tlbios(); - feat_tlbirange(); - // FEAT_TTL -} - -fn feat_aa64() { - // CurrentEL register only present when FEAT_AA64 is implemented - unsafe { asm!("mrs x0, CurrentEL") } -} - -fn feat_crc32() { - // instruction is present when FEAT_CRC32 is implemented - unsafe { asm!("crc32b w0, w1, w2") } -} - -fn feat_lse() { - // instruction is present when FEAT_LSE is implemented - unsafe { asm!("casp w0, w1, w2, w3, [x4]") } -} - -fn feat_pan() { - unsafe { asm!("mrs x0, PAN") } -} - -fn feat_asmv8p2() { - unsafe { asm!("BFC w0, #0, #1") } -} - -fn feat_dpb() { - unsafe { asm!("DC CVAP, x0") } -} - -fn feat_ras() { - unsafe { asm!("ESB") } -} - -fn feat_uao() { - unsafe { asm!("mrs x0, UAO") } -} - -fn feat_lrcpc() { - unsafe { asm!("ldaprb w0, [x1]") } -} - -fn feat_pauth() { - unsafe { asm!("xpacd x0") } -} - -fn feat_dit() { - unsafe { asm!("mrs x0, DIT") } -} - -fn feat_flagm() { - unsafe { asm!("cfinv") } -} - -fn feat_lrcpc2() { - unsafe { asm!("stlurb w0, [x1]") } -} - -fn feat_tlbios() { - unsafe { asm!("tlbi VMALLE1OS") } -} - -fn feat_tlbirange() { - unsafe { asm!("tlbi RVAE1IS, x0") } -} diff --git a/tests/ui/asm/cortex-r82.rs b/tests/ui/asm/cortex-r82.rs deleted file mode 100644 index 74313e5cb48c..000000000000 --- a/tests/ui/asm/cortex-r82.rs +++ /dev/null @@ -1,180 +0,0 @@ -// Codegen test of mandatory Cortex-R82 extensions - -//@ add-minicore -//@ compile-flags: --target aarch64v8r-unknown-none -C target-cpu=cortex-r82 -//@ needs-llvm-components: aarch64 -//@ build-pass -//@ ignore-backends: gcc - -#![deny(dead_code)] -#![feature(no_core)] -#![no_core] -#![no_main] -#![crate_type = "rlib"] - -extern crate minicore; -use minicore::*; - -/* # Mandatory extensions - * - * A `//` comment indicates that the extension has no associated assembly instruction and cannot - * be codegen tested - * A `/* */` comment indicates that the extension is being tested in the ISA level codegen test - * (`tests/ui/asm/aarch64v8r.rs`) - * - * Note that as we use the hard-float `aarch64v8r-unknown-none` target as the base, the neon - * extension is present (`NEON_FPm=1`). This affects which R82-specific extensions are enabled - * (see "when `NEON_FPm == 1`" note in Cortex-R82 Processor Technical Reference Manual) - * - * ## References: - * - * - Arm Cortex-R82 Processor Technical Reference Manual Revision r3p1 (102670_0301_06_en Issue 6) - * section 3.2.1 has the list of mandatory extensions - * - Arm Architecture Reference Manual for A-profile architecture (ARM DDI 0487) -- has the - * mapping from features to instructions - * - Feature names in A-profile architecture (109697_0100_02_en Version 1.0) -- overview of what - * each extension mean - * */ -pub fn mandatory_extensions() { - // FEAT_GICv3 - // FEAT_GICv3p1 - // FEAT_GICv3_TDIR - feat_pmuv3(); - // FEAT_ETMv4 - // FEAT_ETMv4p1 - // FEAT_ETMv4p2 - // FEAT_ETMv4p3 - // FEAT_ETMv4p4 - // FEAT_ETMv4p5 - /* FEAT_RAS */ - // FEAT_PCSRv8 - feat_ssbs(); - feat_ssbs2(); - // FEAT_CSV2 - // FEAT_CSV2_1p1 - // FEAT_CSV3 - feat_sb(); - feat_specres(); - feat_dgh(); - // FEAT_nTLBPA - /* FEAT_CRC32 */ - /* FEAT_LSE */ - feat_rdm(); // mandatory given that NEON_FPm=1 - /* FEAT_HPDS */ - /* FEAT_PAN */ - // FEAT_HAFDBS - // FEAT_PMUv3p1 - // FEAT_TTCNP - // FEAT_XNX - /* FEAT_UAO */ - feat_pan2(); - feat_dpb(); - /* FEAT_Debugv8p2 */ - /* FEAT_ASMv8p2 */ - // FEAT_IESB - feat_fp16(); // mandatory given that NEON_FPm=1 - // FEAT_PCSRv8p2 - feat_dotprod(); // mandatory given that NEON_FPm=1 - feat_fhm(); // mandatory given that NEON_FPm=1 - feat_dpb2(); - /* FEAT_PAuth */ - // FEAT_PACQARMA3 - // FEAT_PAuth2 - // FEAT_FPAC - // FEAT_FPACCOMBINE - // FEAT_CONSTPACFIELD - feat_jscvt(); // mandatory given that NEON_FPm=1 - /* FEAT_LRCPC */ - feat_fcma(); // mandatory given that NEON_FPm=1 - // FEAT_DoPD - // FEAT_SEL2 - /* FEAT_S2FWB */ - /* FEAT_DIT */ - /* FEAT_IDST */ - /* FEAT_FlagM */ - /* FEAT_LSE2 */ - /* FEAT_LRCPC2 */ - /* FEAT_TLBIOS */ - /* FEAT_TLBIRANGE */ - /* FEAT_TTL */ - // FEAT_BBM - // FEAT_CNTSC - feat_rasv1p1(); - // FEAT_Debugv8p4 - feat_pmuv3p4(); - feat_trf(); - // FEAT_TTST - // FEAT_E0PD -} - -fn feat_pmuv3() { - unsafe { asm!("mrs x0, PMCCFILTR_EL0") } -} - -fn feat_ssbs() { - unsafe { asm!("msr SSBS, 1") } -} - -fn feat_ssbs2() { - unsafe { asm!("mrs x0, SSBS") } -} - -fn feat_sb() { - unsafe { asm!("sb") } -} - -fn feat_specres() { - unsafe { asm!("cfp rctx, x0") } -} - -fn feat_dgh() { - unsafe { asm!("dgh") } -} - -fn feat_rdm() { - unsafe { asm!("sqrdmlah v0.4h, v1.4h, v2.4h") } -} - -fn feat_pan2() { - unsafe { asm!("AT S1E1RP, x0") } -} - -fn feat_dpb() { - unsafe { asm!("DC CVAP, x0") } -} - -fn feat_fp16() { - unsafe { asm!("fmulx h0, h1, h2") } -} - -fn feat_dotprod() { - unsafe { asm!("sdot V0.4S, V1.16B, V2.16B") } -} - -fn feat_fhm() { - unsafe { asm!("fmlal v0.2s, v1.2h, v2.2h") } -} - -fn feat_dpb2() { - unsafe { asm!("DC CVADP, x0") } -} - -fn feat_jscvt() { - unsafe { asm!("fjcvtzs w0, d1") } -} - -fn feat_fcma() { - unsafe { asm!("fcadd v0.4h, v1.4h, v2.4h, #90") } -} - -fn feat_rasv1p1() { - unsafe { asm!("mrs x0, ERXMISC2_EL1") } -} - -fn feat_pmuv3p4() { - unsafe { asm!("mrs x0, PMMIR_EL1") } -} - -fn feat_trf() { - unsafe { asm!("tsb csync") } -} diff --git a/tests/ui/asm/ice-bad-err-span-in-template-129503.rs b/tests/ui/asm/ice-bad-err-span-in-template-129503.rs index 0a7d0d405d17..3b4390f881a7 100644 --- a/tests/ui/asm/ice-bad-err-span-in-template-129503.rs +++ b/tests/ui/asm/ice-bad-err-span-in-template-129503.rs @@ -1,22 +1,17 @@ -// Regression test for ICEs #129503 and #131292 -// +// Regression test for ICE #129503 + + // Tests that we come up with decent error spans // when the template fed to `asm!()` is itself a // macro call like `concat!()` and should not ICE -//@ needs-asm-support - use std::arch::asm; fn main() { - // Should not ICE (test case for #129503) + // Should not ICE asm!(concat!(r#"lJð¿Ã†ï¿½.ð¿ï¿½"#, "r} {}")); //~^ ERROR invalid asm template string: unmatched `}` found - // Should not ICE (test case for #131292) - asm!(concat!(r#"lJð¿Ã†ï¿½.ð¿ï¿½"#, "{}/day{:02}.txt")); - //~^ ERROR invalid asm template string: expected `}`, found `0` - // Macro call template: should point to // everything within `asm!()` as error span diff --git a/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr b/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr index 980338138c66..066959a052d9 100644 --- a/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr +++ b/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr @@ -1,24 +1,13 @@ error: invalid asm template string: unmatched `}` found - --> $DIR/ice-bad-err-span-in-template-129503.rs:13:10 + --> $DIR/ice-bad-err-span-in-template-129503.rs:12:10 | LL | asm!(concat!(r#"lJð¿Ã†ï¿½.ð¿ï¿½"#, "r} {}")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` -error: invalid asm template string: expected `}`, found `0` - --> $DIR/ice-bad-err-span-in-template-129503.rs:17:10 - | -LL | asm!(concat!(r#"lJð¿Ã†ï¿½.ð¿ï¿½"#, "{}/day{:02}.txt")); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected `}` in asm template string - | because of this opening brace - | - = note: if you intended to print `{`, you can escape it using `{{` - error: invalid asm template string: unmatched `}` found - --> $DIR/ice-bad-err-span-in-template-129503.rs:23:10 + --> $DIR/ice-bad-err-span-in-template-129503.rs:18:10 | LL | asm!(concat!("abc", "r} {}")); | ^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string @@ -26,12 +15,12 @@ LL | asm!(concat!("abc", "r} {}")); = note: if you intended to print `}`, you can escape it using `}}` error: invalid asm template string: unmatched `}` found - --> $DIR/ice-bad-err-span-in-template-129503.rs:29:19 + --> $DIR/ice-bad-err-span-in-template-129503.rs:24:19 | LL | asm!("abc", "r} {}"); | ^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/asm/naked-invalid-attr.rs b/tests/ui/asm/naked-invalid-attr.rs index d020fae41cf9..eba7cf01b7b2 100644 --- a/tests/ui/asm/naked-invalid-attr.rs +++ b/tests/ui/asm/naked-invalid-attr.rs @@ -56,7 +56,7 @@ fn main() { // Check that the path of an attribute without a name is printed correctly (issue #140082) #[::a] //~^ ERROR attribute incompatible with `#[unsafe(naked)]` -//~| ERROR cannot find module or crate `a` in the crate root +//~| ERROR failed to resolve: use of unresolved module or unlinked crate `a` #[unsafe(naked)] extern "C" fn issue_140082() { naked_asm!("") diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr index 9962cbafc37f..a6348923277d 100644 --- a/tests/ui/asm/naked-invalid-attr.stderr +++ b/tests/ui/asm/naked-invalid-attr.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `a` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a` --> $DIR/naked-invalid-attr.rs:57:5 | LL | #[::a] diff --git a/tests/ui/asm/normalize-offsets-for-crlf.rs b/tests/ui/asm/normalize-offsets-for-crlf.rs deleted file mode 100644 index 7b4ec386ebb0..000000000000 --- a/tests/ui/asm/normalize-offsets-for-crlf.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Byte positions into inline assembly reported by codegen errors require normalization or else -// they may not identify the appropriate span. Worse still, an ICE can occur if the erroneous -// span begins or ends part-way through a multibyte character. -// -// Regression test for https://github.com/rust-lang/rust/issues/110885 - -// This test is tied to assembler syntax and errors, which can vary by backend and architecture. -//@only-x86_64 -//@needs-backends: llvm -//@build-fail - -//~? ERROR instruction mnemonic -std::arch::global_asm!(include_str!("normalize-offsets-for-crlf.s")); -fn main() {} diff --git a/tests/ui/asm/normalize-offsets-for-crlf.s b/tests/ui/asm/normalize-offsets-for-crlf.s deleted file mode 100644 index ec48aad44123..000000000000 --- a/tests/ui/asm/normalize-offsets-for-crlf.s +++ /dev/null @@ -1,13 +0,0 @@ -// This file contains (some) CRLF line endings. When codegen reports an error, the byte -// offsets into this file that it identifies require normalization or else they will not -// identify the appropriate span. Worse still, an ICE can result if the erroneous span -// begins or ends part-way through a multibyte character such as £. -non_existent_mnemonic - -// Without normalization, the three CRLF line endings below cause the diagnostic on the -// `non_existent_mnemonic` above to be spanned three bytes backward, and thus begin -// part-way inside the multibyte character in the preceding comment. -// -// NOTE: The lines of this note DELIBERATELY end with CRLF - DO NOT strip/convert them! -// It may not be obvious if you accidentally do, eg `git diff` may appear to show -// that the lines have been updated to the exact same content. diff --git a/tests/ui/asm/normalize-offsets-for-crlf.stderr b/tests/ui/asm/normalize-offsets-for-crlf.stderr deleted file mode 100644 index 28f5510308be..000000000000 --- a/tests/ui/asm/normalize-offsets-for-crlf.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: invalid instruction mnemonic 'non_existent_mnemonic' - | -note: instantiated into assembly here - --> :6:1 - | -LL | non_existent_mnemonic - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr index fe6802b0c0c9..dff85a601b73 100644 --- a/tests/ui/asm/parse-error.stderr +++ b/tests/ui/asm/parse-error.stderr @@ -193,12 +193,16 @@ error: asm template must be a string literal | LL | asm!(format!("{{{}}}", 0), in(reg) foo); | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal --> $DIR/parse-error.rs:86:21 | LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: _ cannot be used for input operands --> $DIR/parse-error.rs:88:28 @@ -353,12 +357,16 @@ error: asm template must be a string literal | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal --> $DIR/parse-error.rs:143:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `in` operand cannot be used with `global_asm!` --> $DIR/parse-error.rs:146:19 diff --git a/tests/ui/asm/x86_64/global_asm_escape.rs b/tests/ui/asm/x86_64/global_asm_escape.rs deleted file mode 100644 index 59214e958a85..000000000000 --- a/tests/ui/asm/x86_64/global_asm_escape.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -//@ only-x86_64-unknown-linux-gnu -//@ ignore-backends: gcc - -// https://github.com/rust-lang/rust/issues/151950 - -unsafe extern "C" { - #[link_name = "exit@GLIBC_2.2.5"] - safe fn exit(status: i32) -> !; - safe fn my_exit(status: i32) -> !; -} - -core::arch::global_asm!(".global my_exit", "my_exit:", "jmp {}", sym exit); - -fn main() { - my_exit(0); -} diff --git a/tests/ui/asm/x86_64/naked_asm_escape.rs b/tests/ui/asm/x86_64/naked_asm_escape.rs deleted file mode 100644 index 57962993ef91..000000000000 --- a/tests/ui/asm/x86_64/naked_asm_escape.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ build-fail -//@ only-x86_64-unknown-linux-gnu -//@ dont-check-compiler-stderr -//@ dont-check-compiler-stdout -//@ ignore-backends: gcc - -// https://github.com/rust-lang/rust/issues/151950 - -unsafe extern "C" { - #[link_name = "memset]; mov eax, 1; #"] - unsafe fn inject(); -} - -#[unsafe(export_name = "memset]; mov eax, 1; #")] -extern "C" fn inject_() {} - -#[unsafe(naked)] -extern "C" fn print_0() -> usize { - core::arch::naked_asm!("lea rax, [{}]", "ret", sym inject) -} - -#[unsafe(naked)] -extern "C" fn print_1() -> usize { - core::arch::naked_asm!("lea rax, [{}]", "ret", sym inject_) -} - -fn main() { - dbg!(print_0()); - dbg!(print_1()); -} - -//~? ERROR linking diff --git a/tests/ui/asm/x86_64/type-check-2.stderr b/tests/ui/asm/x86_64/type-check-2.stderr index e5d39b2fbd05..d5c5a3ff1f84 100644 --- a/tests/ui/asm/x86_64/type-check-2.stderr +++ b/tests/ui/asm/x86_64/type-check-2.stderr @@ -21,6 +21,7 @@ LL | asm!("{}", in(reg) vec![0]); | ^^^^^^^ | = note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot use value of type `(i32, i32, i32)` for inline assembly --> $DIR/type-check-2.rs:52:28 diff --git a/tests/ui/associated-consts/associated-const-in-trait.rs b/tests/ui/associated-consts/associated-const-in-trait.rs index 6b0b43feb109..4d88f4ff5316 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.rs +++ b/tests/ui/associated-consts/associated-const-in-trait.rs @@ -7,6 +7,8 @@ trait Trait { impl dyn Trait { //~^ ERROR the trait `Trait` is not dyn compatible [E0038] const fn n() -> usize { Self::N } + //~^ ERROR the trait `Trait` is not dyn compatible [E0038] + //~| ERROR the trait `Trait` is not dyn compatible } fn main() {} diff --git a/tests/ui/associated-consts/associated-const-in-trait.stderr b/tests/ui/associated-consts/associated-const-in-trait.stderr index fb4a55110b4e..fba7f53c097f 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.stderr +++ b/tests/ui/associated-consts/associated-const-in-trait.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/associated-const-in-trait.rs:7:10 + --> $DIR/associated-const-in-trait.rs:7:6 | LL | impl dyn Trait { - | ^^^^^ `Trait` is not dyn compatible + | ^^^^^^^^^ `Trait` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit @@ -11,9 +11,41 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait Trait { | ----- this trait is not dyn compatible... LL | const N: usize; - | ^ ...because it contains associated const `N` + | ^ ...because it contains this associated `const` = help: consider moving `N` to another trait -error: aborting due to 1 previous error +error[E0038]: the trait `Trait` is not dyn compatible + --> $DIR/associated-const-in-trait.rs:9:29 + | +LL | const fn n() -> usize { Self::N } + | ^^^^ `Trait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $DIR/associated-const-in-trait.rs:4:11 + | +LL | trait Trait { + | ----- this trait is not dyn compatible... +LL | const N: usize; + | ^ ...because it contains this associated `const` + = help: consider moving `N` to another trait + +error[E0038]: the trait `Trait` is not dyn compatible + --> $DIR/associated-const-in-trait.rs:9:29 + | +LL | const fn n() -> usize { Self::N } + | ^^^^^^^ `Trait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $DIR/associated-const-in-trait.rs:4:11 + | +LL | trait Trait { + | ----- this trait is not dyn compatible... +LL | const N: usize; + | ^ ...because it contains this associated `const` + = help: consider moving `N` to another trait + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 8b38905e1c57..40f5f889f361 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -23,6 +23,8 @@ note: erroneous constant encountered | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered --> $DIR/defaults-not-assumed-fail.rs:34:5 @@ -31,6 +33,7 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/associated-consts/issue-110933.rs b/tests/ui/associated-consts/issue-110933.rs index 0115fb7d6e65..9a013ee71274 100644 --- a/tests/ui/associated-consts/issue-110933.rs +++ b/tests/ui/associated-consts/issue-110933.rs @@ -4,7 +4,8 @@ #![allow(incomplete_features)] pub trait Trait { - type const ASSOC: usize; + #[type_const] + const ASSOC: usize; } pub fn foo< diff --git a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs deleted file mode 100644 index cb0b8a102eb4..000000000000 --- a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(generic_const_exprs)] -//~^ WARN the feature `generic_const_exprs` is incomplete -#![feature(min_generic_const_args)] -//~^ WARN the feature `min_generic_const_args` is incomplete -#![feature(inherent_associated_types)] -//~^ WARN the feature `inherent_associated_types` is incomplete - -struct OnDiskDirEntry<'a>(&'a ()); - -impl<'a> OnDiskDirEntry<'a> { - type const LFN_FRAGMENT_LEN: i64 = 2; - - fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { - //~^ ERROR the constant `2` is not of type `usize` - loop {} - } -} - -fn main() {} diff --git a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr deleted file mode 100644 index b69a1b7fd7de..000000000000 --- a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr +++ /dev/null @@ -1,35 +0,0 @@ -warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/type-const-in-array-len-wrong-type.rs:1:12 - | -LL | #![feature(generic_const_exprs)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #76560 for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/type-const-in-array-len-wrong-type.rs:3:12 - | -LL | #![feature(min_generic_const_args)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #132980 for more information - -warning: the feature `inherent_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/type-const-in-array-len-wrong-type.rs:5:12 - | -LL | #![feature(inherent_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #8995 for more information - -error: the constant `2` is not of type `usize` - --> $DIR/type-const-in-array-len-wrong-type.rs:13:26 - | -LL | fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i64` - | - = note: the length of array `[char; 2]` must be type `usize` - -error: aborting due to 1 previous error; 3 warnings emitted - diff --git a/tests/ui/associated-consts/type-const-in-array-len.rs b/tests/ui/associated-consts/type-const-in-array-len.rs deleted file mode 100644 index d33eacaade2d..000000000000 --- a/tests/ui/associated-consts/type-const-in-array-len.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ check-pass - -#![feature(min_generic_const_args)] -//~^ WARN the feature `min_generic_const_args` is incomplete -#![feature(inherent_associated_types)] -//~^ WARN the feature `inherent_associated_types` is incomplete - -// Test case from #138226: generic impl with multiple type parameters -struct Foo(A, B); -impl Foo { - type const LEN: usize = 4; - - fn foo() { - let _ = [5; Self::LEN]; - } -} - -// Test case from #138226: generic impl with const parameter -struct Bar; -impl Bar { - type const LEN: usize = 4; - - fn bar() { - let _ = [0; Self::LEN]; - } -} - -// Test case from #150960: non-generic impl with const block -struct Baz; -impl Baz { - type const LEN: usize = 4; - - fn baz() { - let _ = [0; { Self::LEN }]; - } -} - -fn main() {} diff --git a/tests/ui/associated-consts/type-const-in-array-len.stderr b/tests/ui/associated-consts/type-const-in-array-len.stderr deleted file mode 100644 index 546995d13a0a..000000000000 --- a/tests/ui/associated-consts/type-const-in-array-len.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/type-const-in-array-len.rs:3:12 - | -LL | #![feature(min_generic_const_args)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #132980 for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: the feature `inherent_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/type-const-in-array-len.rs:5:12 - | -LL | #![feature(inherent_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #8995 for more information - -warning: 2 warnings emitted - diff --git a/tests/ui/associated-inherent-types/inference-fail.stderr b/tests/ui/associated-inherent-types/inference-fail.stderr index 12cc3ae7960c..bf329c69e99c 100644 --- a/tests/ui/associated-inherent-types/inference-fail.stderr +++ b/tests/ui/associated-inherent-types/inference-fail.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/inference-fail.rs:10:12 | LL | let _: S<_>::P = (); - | ^^^^^^^ cannot infer type + | ^^^^^^^ cannot infer type for type parameter `T` error: aborting due to 1 previous error diff --git a/tests/ui/associated-item/issue-48027.stderr b/tests/ui/associated-item/issue-48027.stderr index 7abcabc1c79d..e5c1ced93413 100644 --- a/tests/ui/associated-item/issue-48027.stderr +++ b/tests/ui/associated-item/issue-48027.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-48027.rs:6:10 + --> $DIR/issue-48027.rs:6:6 | LL | impl dyn Bar {} - | ^^^ `Bar` is not dyn compatible + | ^^^^^^^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit @@ -11,7 +11,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait Bar { | --- this trait is not dyn compatible... LL | const X: usize; - | ^ ...because it contains associated const `X` + | ^ ...because it contains this associated `const` = help: consider moving `X` to another trait error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.rs b/tests/ui/associated-type-bounds/duplicate-bound-err.rs index 56403fdf6630..1587be7200e7 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.rs +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.rs @@ -50,7 +50,8 @@ fn mismatch_2() -> impl Iterator { trait Trait { type Gat; - type const ASSOC: i32; + #[type_const] + const ASSOC: i32; fn foo() -> impl Sized; } @@ -58,7 +59,8 @@ trait Trait { impl Trait for () { type Gat = (); - type const ASSOC: i32 = 3; + #[type_const] + const ASSOC: i32 = 3; fn foo() {} } @@ -66,7 +68,8 @@ impl Trait for () { impl Trait for u32 { type Gat = (); - type const ASSOC: i32 = 4; + #[type_const] + const ASSOC: i32 = 4; fn foo() -> u32 { 42 @@ -83,15 +86,16 @@ fn uncallable_rtn( type MustFail = dyn Iterator; //~^ ERROR [E0719] -//~| ERROR conflicting associated type bindings +//~| ERROR conflicting associated type bounds trait Trait2 { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } type MustFail2 = dyn Trait2; //~^ ERROR [E0719] -//~| ERROR conflicting associated constant bindings +//~| ERROR conflicting associated type bounds type MustFail3 = dyn Iterator; //~^ ERROR [E0719] diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr index e6bf93970d0a..ec864c1dd96e 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr @@ -100,7 +100,7 @@ LL | iter::empty::() | ----------------------- return type was inferred to be `std::iter::Empty` here error[E0271]: expected `IntoIter` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/duplicate-bound-err.rs:107:17 + --> $DIR/duplicate-bound-err.rs:111:17 | LL | fn foo() -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` @@ -108,28 +108,16 @@ LL | fn foo() -> impl Iterator { LL | [2u32].into_iter() | ------------------ return type was inferred to be `std::array::IntoIter` here -error[E0271]: expected `impl Iterator` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/duplicate-bound-err.rs:107:17 - | -LL | fn foo() -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` - | -note: required by a bound in `Trait3::foo::{anon_assoc#0}` - --> $DIR/duplicate-bound-err.rs:103:31 - | -LL | fn foo() -> impl Iterator; - | ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}` - error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate-bound-err.rs:84:42 + --> $DIR/duplicate-bound-err.rs:87:42 | LL | type MustFail = dyn Iterator; | ---------- ^^^^^^^^^^ re-bound here | | | `Item` bound here first -error: conflicting associated type bindings for `Item` - --> $DIR/duplicate-bound-err.rs:84:17 +error: conflicting associated type bounds for `Item` + --> $DIR/duplicate-bound-err.rs:87:17 | LL | type MustFail = dyn Iterator; | ^^^^^^^^^^^^^----------^^----------^ @@ -138,15 +126,15 @@ LL | type MustFail = dyn Iterator; | `Item` is specified to be `i32` here error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified - --> $DIR/duplicate-bound-err.rs:92:43 + --> $DIR/duplicate-bound-err.rs:96:43 | LL | type MustFail2 = dyn Trait2; | ------------ ^^^^^^^^^^^^ re-bound here | | | `ASSOC` bound here first -error: conflicting associated constant bindings for `ASSOC` - --> $DIR/duplicate-bound-err.rs:92:18 +error: conflicting associated type bounds for `ASSOC` + --> $DIR/duplicate-bound-err.rs:96:18 | LL | type MustFail2 = dyn Trait2; | ^^^^^^^^^^^------------^^------------^ @@ -155,7 +143,7 @@ LL | type MustFail2 = dyn Trait2; | `ASSOC` is specified to be `3` here error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate-bound-err.rs:96:43 + --> $DIR/duplicate-bound-err.rs:100:43 | LL | type MustFail3 = dyn Iterator; | ---------- ^^^^^^^^^^ re-bound here @@ -163,15 +151,27 @@ LL | type MustFail3 = dyn Iterator; | `Item` bound here first error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified - --> $DIR/duplicate-bound-err.rs:99:43 + --> $DIR/duplicate-bound-err.rs:103:43 | LL | type MustFail4 = dyn Trait2; | ------------ ^^^^^^^^^^^^ re-bound here | | | `ASSOC` bound here first +error[E0271]: expected `impl Iterator` to be an iterator that yields `i32`, but it yields `u32` + --> $DIR/duplicate-bound-err.rs:111:17 + | +LL | fn foo() -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` + | +note: required by a bound in `Trait3::foo::{anon_assoc#0}` + --> $DIR/duplicate-bound-err.rs:107:31 + | +LL | fn foo() -> impl Iterator; + | ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}` + error[E0271]: expected `Empty` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/duplicate-bound-err.rs:115:16 + --> $DIR/duplicate-bound-err.rs:119:16 | LL | uncallable(iter::empty::()); | ---------- ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` @@ -179,13 +179,13 @@ LL | uncallable(iter::empty::()); | required by a bound introduced by this call | note: required by a bound in `uncallable` - --> $DIR/duplicate-bound-err.rs:76:32 + --> $DIR/duplicate-bound-err.rs:79:32 | LL | fn uncallable(_: impl Iterator) {} | ^^^^^^^^^^ required by this bound in `uncallable` error[E0271]: expected `Empty` to be an iterator that yields `u32`, but it yields `i32` - --> $DIR/duplicate-bound-err.rs:116:16 + --> $DIR/duplicate-bound-err.rs:120:16 | LL | uncallable(iter::empty::()); | ---------- ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32` @@ -193,13 +193,13 @@ LL | uncallable(iter::empty::()); | required by a bound introduced by this call | note: required by a bound in `uncallable` - --> $DIR/duplicate-bound-err.rs:76:44 + --> $DIR/duplicate-bound-err.rs:79:44 | LL | fn uncallable(_: impl Iterator) {} | ^^^^^^^^^^ required by this bound in `uncallable` error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4` - --> $DIR/duplicate-bound-err.rs:117:22 + --> $DIR/duplicate-bound-err.rs:121:22 | LL | uncallable_const(()); | ---------------- ^^ expected `4`, found `3` @@ -209,13 +209,13 @@ LL | uncallable_const(()); = note: expected constant `4` found constant `3` note: required by a bound in `uncallable_const` - --> $DIR/duplicate-bound-err.rs:78:46 + --> $DIR/duplicate-bound-err.rs:81:46 | LL | fn uncallable_const(_: impl Trait) {} | ^^^^^^^^^ required by this bound in `uncallable_const` error[E0271]: type mismatch resolving `::ASSOC == 3` - --> $DIR/duplicate-bound-err.rs:118:22 + --> $DIR/duplicate-bound-err.rs:122:22 | LL | uncallable_const(4u32); | ---------------- ^^^^ expected `3`, found `4` @@ -225,13 +225,13 @@ LL | uncallable_const(4u32); = note: expected constant `3` found constant `4` note: required by a bound in `uncallable_const` - --> $DIR/duplicate-bound-err.rs:78:35 + --> $DIR/duplicate-bound-err.rs:81:35 | LL | fn uncallable_const(_: impl Trait) {} | ^^^^^^^^^ required by this bound in `uncallable_const` error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4` - --> $DIR/duplicate-bound-err.rs:119:20 + --> $DIR/duplicate-bound-err.rs:123:20 | LL | uncallable_rtn(()); | -------------- ^^ expected `4`, found `3` @@ -241,7 +241,7 @@ LL | uncallable_rtn(()); = note: expected constant `4` found constant `3` note: required by a bound in `uncallable_rtn` - --> $DIR/duplicate-bound-err.rs:81:61 + --> $DIR/duplicate-bound-err.rs:84:61 | LL | fn uncallable_rtn( | -------------- required by a bound in this function @@ -249,7 +249,7 @@ LL | _: impl Trait, foo(..): Trait> | ^^^^^^^^^ required by this bound in `uncallable_rtn` error[E0271]: type mismatch resolving `::ASSOC == 3` - --> $DIR/duplicate-bound-err.rs:120:20 + --> $DIR/duplicate-bound-err.rs:124:20 | LL | uncallable_rtn(17u32); | -------------- ^^^^^ expected `3`, found `4` @@ -259,7 +259,7 @@ LL | uncallable_rtn(17u32); = note: expected constant `3` found constant `4` note: required by a bound in `uncallable_rtn` - --> $DIR/duplicate-bound-err.rs:81:34 + --> $DIR/duplicate-bound-err.rs:84:34 | LL | fn uncallable_rtn( | -------------- required by a bound in this function diff --git a/tests/ui/associated-type-bounds/duplicate-bound.rs b/tests/ui/associated-type-bounds/duplicate-bound.rs index 39cfa9db072c..1aeb0022a04f 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound.rs +++ b/tests/ui/associated-type-bounds/duplicate-bound.rs @@ -189,7 +189,8 @@ trait Tra3 { trait Trait { type Gat; - type const ASSOC: i32; + #[type_const] + const ASSOC: i32; fn foo() -> impl Sized; } @@ -197,7 +198,8 @@ trait Trait { impl Trait for () { type Gat = (); - type const ASSOC: i32 = 3; + #[type_const] + const ASSOC: i32 = 3; fn foo() {} } diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr index 54bcef455746..ad97df377b75 100644 --- a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr +++ b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr @@ -2,7 +2,7 @@ error[E0191]: the value of the associated types `Item` and `IntoIter` in `IntoIt --> $DIR/overlaping-bound-suggestion.rs:7:13 | LL | inner: >::IntoIterator as Item>::Core, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated types: `IntoIterator, Item = /* Type */, IntoIter = /* Type */>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated types: `IntoIterator, Item = Type, IntoIter = Type>` error: aborting due to 1 previous error diff --git a/tests/ui/associated-type-bounds/return-type-notation/trait-alias.rs b/tests/ui/associated-type-bounds/return-type-notation/trait-alias.rs deleted file mode 100644 index 88f60a72afa1..000000000000 --- a/tests/ui/associated-type-bounds/return-type-notation/trait-alias.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Regression test for . -//@ check-pass -#![feature(return_type_notation, trait_alias)] - -trait Tr { - fn f() -> impl Sized; -} - -trait Al = Tr; - -fn f>() {} - -fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr index 3b89ed66b355..21bc37bb3ea2 100644 --- a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr @@ -6,8 +6,6 @@ LL | const N: C::M = 4u8; | = note: expected associated type `::M` found type `u8` - = note: the associated type `::M` is defined as `u8` in the implementation, but the where-bound `C` shadows this definition - see issue #152409 for more information help: consider constraining the associated type `::M` to `u8` | LL | impl> U for u16 { diff --git a/tests/ui/associated-type-bounds/trait-alias-bound-vars.rs b/tests/ui/associated-type-bounds/trait-alias-bound-vars.rs deleted file mode 100644 index 4644cee21008..000000000000 --- a/tests/ui/associated-type-bounds/trait-alias-bound-vars.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Check that we're successfully collecting bound vars behind trait aliases. -// Regression test for . -//@ check-pass -//@ needs-rustc-debug-assertions -#![feature(trait_alias)] - -trait A<'a> { type X; } -trait B: for<'a> A<'a> {} -trait C = B; - -fn f() where T: C {} -fn g() where T: C A<'r>> {} - -fn main() {} diff --git a/tests/ui/associated-types/associated-types-eq-1.stderr b/tests/ui/associated-types/associated-types-eq-1.stderr index 54e50f36fb6a..869583df644f 100644 --- a/tests/ui/associated-types/associated-types-eq-1.stderr +++ b/tests/ui/associated-types/associated-types-eq-1.stderr @@ -1,13 +1,16 @@ error[E0425]: cannot find type `A` in this scope --> $DIR/associated-types-eq-1.rs:10:12 | +LL | fn foo2(x: I) { + | - similarly named type parameter `I` defined here LL | let _: A = x.boo(); | ^ | -help: you might have meant to use an associated type of the same name +help: a type parameter with a similar name exists + | +LL - let _: A = x.boo(); +LL + let _: I = x.boo(); | -LL | let _: I::A = x.boo(); - | +++ help: you might be missing a type parameter | LL | fn foo2(x: I) { diff --git a/tests/ui/associated-types/associated-types-incomplete-object.stderr b/tests/ui/associated-types/associated-types-incomplete-object.stderr index 52aa6adc4695..0c9761afeb51 100644 --- a/tests/ui/associated-types/associated-types-incomplete-object.stderr +++ b/tests/ui/associated-types/associated-types-incomplete-object.stderr @@ -5,7 +5,7 @@ LL | type B; | ------ `B` defined here ... LL | let b = &42isize as &dyn Foo; - | ^^^^^^^^^^^^ help: specify the associated type: `Foo` + | ^^^^^^^^^^^^ help: specify the associated type: `Foo` error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:26:30 @@ -14,7 +14,7 @@ LL | type A; | ------ `A` defined here ... LL | let c = &42isize as &dyn Foo; - | ^^^^^^^^^^^ help: specify the associated type: `Foo` + | ^^^^^^^^^^^ help: specify the associated type: `Foo` error[E0191]: the value of the associated types `A` and `B` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:29:30 @@ -25,7 +25,7 @@ LL | type B; | ------ `B` defined here ... LL | let d = &42isize as &dyn Foo; - | ^^^ help: specify the associated types: `Foo` + | ^^^ help: specify the associated types: `Foo` error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/associated-types-overridden-binding-2.rs b/tests/ui/associated-types/associated-types-overridden-binding-2.rs index fe8041363246..247724eaaf11 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding-2.rs +++ b/tests/ui/associated-types/associated-types-overridden-binding-2.rs @@ -4,5 +4,5 @@ trait I32Iterator = Iterator; fn main() { let _: &dyn I32Iterator = &vec![42].into_iter(); - //~^ ERROR conflicting associated type bindings + //~^ ERROR conflicting associated type bounds } diff --git a/tests/ui/associated-types/associated-types-overridden-binding-2.stderr b/tests/ui/associated-types/associated-types-overridden-binding-2.stderr index 1594e5729781..e96a2446b6ce 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/tests/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -1,4 +1,4 @@ -error: conflicting associated type bindings for `Item` +error: conflicting associated type bounds for `Item` --> $DIR/associated-types-overridden-binding-2.rs:6:13 | LL | trait I32Iterator = Iterator; diff --git a/tests/ui/associated-types/associated-types-overridden-binding.rs b/tests/ui/associated-types/associated-types-overridden-binding.rs index 82004f042ea1..333a3e30c7dc 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding.rs +++ b/tests/ui/associated-types/associated-types-overridden-binding.rs @@ -8,5 +8,5 @@ trait U32Iterator = I32Iterator; //~ ERROR type annotations needed fn main() { let _: &dyn I32Iterator; - //~^ ERROR conflicting associated type bindings + //~^ ERROR conflicting associated type bounds } diff --git a/tests/ui/associated-types/associated-types-overridden-binding.stderr b/tests/ui/associated-types/associated-types-overridden-binding.stderr index d31b05065719..08ab9b63ee9f 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding.stderr +++ b/tests/ui/associated-types/associated-types-overridden-binding.stderr @@ -22,7 +22,7 @@ note: required by a bound in `I32Iterator` LL | trait I32Iterator = Iterator; | ^^^^^^^^^^ required by this bound in `I32Iterator` -error: conflicting associated type bindings for `Item` +error: conflicting associated type bounds for `Item` --> $DIR/associated-types-overridden-binding.rs:10:13 | LL | trait I32Iterator = Iterator; diff --git a/tests/ui/associated-types/defaults-specialization.stderr b/tests/ui/associated-types/defaults-specialization.stderr index d22d9ce659a7..7d19ac85982a 100644 --- a/tests/ui/associated-types/defaults-specialization.stderr +++ b/tests/ui/associated-types/defaults-specialization.stderr @@ -75,8 +75,6 @@ LL | fn make() -> Self::Ty { 0u8 } found type `u8` = help: consider constraining the associated type ` as Tr>::Ty` to `u8` or calling a method that returns ` as Tr>::Ty` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type ` as Tr>::Ty` is defined as `u8` in the implementation, but the where-bound `A2` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:44:29 @@ -91,8 +89,6 @@ LL | fn make() -> Self::Ty { true } | = note: expected associated type ` as Tr>::Ty` found type `bool` - = note: the associated type ` as Tr>::Ty` is defined as `bool` in the implementation, but the where-bound `B2` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:87:32 @@ -125,8 +121,6 @@ help: a method is available that returns ` as Tr>::Ty` | LL | fn make() -> Self::Ty { | ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make` - = note: the associated type ` as Tr>::Ty` is defined as `bool` in the implementation, but the where-bound `B<()>` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:89:33 @@ -159,8 +153,6 @@ help: a method is available that returns ` as Tr>::Ty` | LL | fn make() -> Self::Ty { | ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make` - = note: the associated type ` as Tr>::Ty` is defined as `bool` in the implementation, but the where-bound `B2<()>` shadows this definition - see issue #152409 for more information error: aborting due to 9 previous errors; 1 warning emitted diff --git a/tests/ui/associated-types/issue-23595-1.stderr b/tests/ui/associated-types/issue-23595-1.stderr index 8083355deb76..694b68ef0901 100644 --- a/tests/ui/associated-types/issue-23595-1.stderr +++ b/tests/ui/associated-types/issue-23595-1.stderr @@ -6,7 +6,7 @@ LL | type Value; LL | type ChildKey; | ------------- `ChildKey` defined here LL | type Children = dyn Index; - | ------------- `Children` defined here ^^^^^^^^^ help: specify the associated types: `Hierarchy` + | ------------- `Children` defined here ^^^^^^^^^ help: specify the associated types: `Hierarchy` error: aborting due to 1 previous error diff --git a/tests/ui/associated-types/issue-38821.rs b/tests/ui/associated-types/issue-38821.rs index 35c371235e64..5212bc886f0d 100644 --- a/tests/ui/associated-types/issue-38821.rs +++ b/tests/ui/associated-types/issue-38821.rs @@ -34,11 +34,11 @@ pub trait Column: Expression {} //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied +//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied +//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied +//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied pub enum ColumnInsertValue where //~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied Col: Column, Expr: Expression::Nullable>, //~^ ERROR the trait bound `::SqlType: IntoNullable` is not satisfied diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr index 07b146f8bfca..01329f69c3be 100644 --- a/tests/ui/associated-types/issue-38821.stderr +++ b/tests/ui/associated-types/issue-38821.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:1 + --> $DIR/issue-38821.rs:40:1 | LL | pub enum ColumnInsertValue where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` @@ -82,13 +82,10 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:10 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -98,17 +95,13 @@ LL | impl IntoNullable for T { | | | unsatisfied trait bound introduced here note: required for `ColumnInsertValue` to implement `Debug` - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:10 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ + | ^^^^^ ... LL | Expr: Expression::Nullable>, - | ------------------------------------------------ unsatisfied trait bound - = help: consider manually implementing `Debug` to avoid undesired bounds + | ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro help: consider further restricting the associated type | LL | Expr: Expression::Nullable>, ::SqlType: NotNull, @@ -133,13 +126,10 @@ LL | Expr: Expression::Nullable>, ::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:17 | LL | #[derive(Debug, Copy, Clone)] - | ---- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -149,16 +139,13 @@ LL | impl IntoNullable for T { | | | unsatisfied trait bound introduced here note: required for `ColumnInsertValue` to implement `Copy` - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:17 | LL | #[derive(Debug, Copy, Clone)] - | ---- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ + | ^^^^ ... LL | Expr: Expression::Nullable>, - | ------------------------------------------------ unsatisfied trait bound + | ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro help: consider further restricting the associated type | LL | Expr: Expression::Nullable>, ::SqlType: NotNull, @@ -212,13 +199,10 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:23 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -228,17 +212,13 @@ LL | impl IntoNullable for T { | | | unsatisfied trait bound introduced here note: required for `ColumnInsertValue` to implement `Clone` - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:23 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ + | ^^^^^ ... LL | Expr: Expression::Nullable>, - | ------------------------------------------------ unsatisfied trait bound - = help: consider manually implementing `Clone` to avoid undesired bounds + | ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro help: consider further restricting the associated type | LL | Expr: Expression::Nullable>, ::SqlType: NotNull, diff --git a/tests/ui/associated-types/normalization-generality-2.rs b/tests/ui/associated-types/normalization-generality-2.rs index 2a50f7e449ad..50287f9ee9b8 100644 --- a/tests/ui/associated-types/normalization-generality-2.rs +++ b/tests/ui/associated-types/normalization-generality-2.rs @@ -1,7 +1,4 @@ //@ build-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver // Ensures that we don't regress on "implementation is not general enough" when // normalizating under binders. Unlike `normalization-generality.rs`, this also produces diff --git a/tests/ui/associated-types/normalization-generality.rs b/tests/ui/associated-types/normalization-generality.rs index fca70bc7ec67..35fcf53b6414 100644 --- a/tests/ui/associated-types/normalization-generality.rs +++ b/tests/ui/associated-types/normalization-generality.rs @@ -1,7 +1,4 @@ //@ build-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver // Ensures that we don't regress on "implementation is not general enough" when // normalizating under binders. diff --git a/tests/ui/associated-types/param-env-shadowing-false-positive.rs b/tests/ui/associated-types/param-env-shadowing-false-positive.rs deleted file mode 100644 index 41993f5cba19..000000000000 --- a/tests/ui/associated-types/param-env-shadowing-false-positive.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Regression test for issue #149910. -// The compiler previously incorrectly claimed that the local param-env bound -// shadowed the global impl, but they are actually the same. - -trait Trait { - type Assoc; -} - -impl Trait for T { - type Assoc = T; -} - -fn foo(x: T::Assoc) -> u32 { - x //~ ERROR mismatched types -} - -fn main() {} diff --git a/tests/ui/associated-types/param-env-shadowing-false-positive.stderr b/tests/ui/associated-types/param-env-shadowing-false-positive.stderr deleted file mode 100644 index 64d7950f41ef..000000000000 --- a/tests/ui/associated-types/param-env-shadowing-false-positive.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/param-env-shadowing-false-positive.rs:14:5 - | -LL | fn foo(x: T::Assoc) -> u32 { - | --- expected `u32` because of return type -LL | x - | ^ expected `u32`, found associated type - | - = note: expected type `u32` - found associated type `::Assoc` -help: consider constraining the associated type `::Assoc` to `u32` - | -LL | fn foo>(x: T::Assoc) -> u32 { - | +++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-types/param-env-shadowing-gat.rs b/tests/ui/associated-types/param-env-shadowing-gat.rs deleted file mode 100644 index 9dc91a1a1465..000000000000 --- a/tests/ui/associated-types/param-env-shadowing-gat.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Regression test for issue #149910. -// This ensures that the diagnostics logic handles Generic Associated Types (GATs) -// correctly without crashing (ICE). - -trait Trait { - type Assoc; -} - -impl Trait for T { - type Assoc = U; -} - -fn foo(x: T::Assoc) -> u32 { - x //~ ERROR mismatched types -} - -fn main() {} diff --git a/tests/ui/associated-types/param-env-shadowing-gat.stderr b/tests/ui/associated-types/param-env-shadowing-gat.stderr deleted file mode 100644 index 02c024341724..000000000000 --- a/tests/ui/associated-types/param-env-shadowing-gat.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/param-env-shadowing-gat.rs:14:5 - | -LL | fn foo(x: T::Assoc) -> u32 { - | --- expected `u32` because of return type -LL | x - | ^ expected `u32`, found associated type - | - = note: expected type `u32` - found associated type `::Assoc` -help: consider constraining the associated type `::Assoc` to `u32` - | -LL | fn foo = u32>>(x: T::Assoc) -> u32 { - | ++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-types/param-env-shadowing-issue-149910.rs b/tests/ui/associated-types/param-env-shadowing-issue-149910.rs deleted file mode 100644 index 368b80e66189..000000000000 --- a/tests/ui/associated-types/param-env-shadowing-issue-149910.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Regression test for issue #149910. -// We want to tell the user about param_env shadowing here. - -trait Trait { - type Assoc; -} - -impl Trait for T { - type Assoc = T; -} - -fn foo(x: T) -> T::Assoc { - x - //~^ ERROR mismatched types -} - -fn main() {} diff --git a/tests/ui/associated-types/param-env-shadowing-issue-149910.stderr b/tests/ui/associated-types/param-env-shadowing-issue-149910.stderr deleted file mode 100644 index 71ce456bfc1a..000000000000 --- a/tests/ui/associated-types/param-env-shadowing-issue-149910.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/param-env-shadowing-issue-149910.rs:13:5 - | -LL | fn foo(x: T) -> T::Assoc { - | - -------- expected `::Assoc` because of return type - | | - | found this type parameter -LL | x - | ^ expected associated type, found type parameter `T` - | - = note: expected associated type `::Assoc` - found type parameter `T` - = note: the associated type `::Assoc` is defined as `T` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information -help: consider further restricting this bound - | -LL | fn foo>(x: T) -> T::Assoc { - | +++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-types/suggest-assoc-type-from-bounds.rs b/tests/ui/associated-types/suggest-assoc-type-from-bounds.rs deleted file mode 100644 index 8b349f325cd7..000000000000 --- a/tests/ui/associated-types/suggest-assoc-type-from-bounds.rs +++ /dev/null @@ -1,64 +0,0 @@ -pub trait Trait { - type Assoc; -} - -fn f + Trait>() { - let _: Assoc = todo!(); //~ ERROR cannot find type `Assoc` in this scope -} - -pub trait Foo<'a> { - type A; -} - -pub mod inner { - pub trait Foo<'a> { - type A; - } -} - -fn g<'a, T: ::Foo<'a> + inner::Foo<'a>>() { - let _: A = todo!(); //~ ERROR cannot find type `A` in this scope -} - -pub trait First { - type Assoc; -} - -pub trait Second { - type Assoc; -} - -fn h + Second>() { - let _: Assoc = todo!(); //~ ERROR cannot find type `Assoc` in this scope -} - -pub trait Gat { - type Assoc<'a>; -} - -fn i() { - let _: Assoc = todo!(); //~ ERROR cannot find type `Assoc` in this scope -} - -fn j() { - struct Local; - impl Local { - fn method() { - let _: Assoc = todo!(); //~ ERROR cannot find type `Assoc` in this scope - } - } - - let _ = std::marker::PhantomData::; -} - -pub struct S; -impl S { - fn method() { - fn inner() { - let _: Assoc = todo!(); //~ ERROR cannot find type `Assoc` in this scope - } - inner(); - } -} - -fn main() {} diff --git a/tests/ui/associated-types/suggest-assoc-type-from-bounds.stderr b/tests/ui/associated-types/suggest-assoc-type-from-bounds.stderr deleted file mode 100644 index b5ce2d91ca4d..000000000000 --- a/tests/ui/associated-types/suggest-assoc-type-from-bounds.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0425]: cannot find type `Assoc` in this scope - --> $DIR/suggest-assoc-type-from-bounds.rs:6:12 - | -LL | let _: Assoc = todo!(); - | ^^^^^ - | -help: you might have meant to use an associated type of the same name - | -LL | let _: >::Assoc = todo!(); - | +++++++++++++++++++ -LL | let _: >::Assoc = todo!(); - | +++++++++++++++++++ - -error[E0425]: cannot find type `A` in this scope - --> $DIR/suggest-assoc-type-from-bounds.rs:20:12 - | -LL | let _: A = todo!(); - | ^ - | -help: you might have meant to use an associated type of the same name - | -LL | let _: >::A = todo!(); - | ++++++++++++++++++ -LL | let _: >::A = todo!(); - | +++++++++++++++++++++++ -help: you might be missing a type parameter - | -LL | fn g<'a, T: ::Foo<'a> + inner::Foo<'a>, A>() { - | +++ - -error[E0425]: cannot find type `Assoc` in this scope - --> $DIR/suggest-assoc-type-from-bounds.rs:32:12 - | -LL | let _: Assoc = todo!(); - | ^^^^^ - | -help: you might have meant to use an associated type of the same name - | -LL | let _: ::Assoc = todo!(); - | ++++++++++++++ -LL | let _: ::Assoc = todo!(); - | +++++++++++++++ - -error[E0425]: cannot find type `Assoc` in this scope - --> $DIR/suggest-assoc-type-from-bounds.rs:40:12 - | -LL | let _: Assoc = todo!(); - | ^^^^^ - | -help: you might have meant to use an associated type of the same name - | -LL - let _: Assoc = todo!(); -LL + let _: T::Assoc<'_> = todo!(); - | - -error[E0425]: cannot find type `Assoc` in this scope - --> $DIR/suggest-assoc-type-from-bounds.rs:47:20 - | -LL | let _: Assoc = todo!(); - | ^^^^^ - | -help: you might have meant to use an associated type of the same name - | -LL | let _: U::Assoc = todo!(); - | +++ - -error[E0425]: cannot find type `Assoc` in this scope - --> $DIR/suggest-assoc-type-from-bounds.rs:58:20 - | -LL | let _: Assoc = todo!(); - | ^^^^^ not found in this scope - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.rs b/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.rs deleted file mode 100644 index 4a3ccc287f7f..000000000000 --- a/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ compile-flags: -Znext-solver=globally - -// Regression test for https://github.com/rust-lang/rust/issues/152684. - -#![feature(associated_type_defaults)] - -trait Foo { - type Assoc = T; - //~^ ERROR defaults for generic parameters are not allowed here - fn foo() -> Self::Assoc; -} -impl Foo for () { - fn foo() -> Self::Assoc { - [] //~ ERROR mismatched types - } -} - -fn main() {} diff --git a/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr b/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr deleted file mode 100644 index c40123324248..000000000000 --- a/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: defaults for generic parameters are not allowed here - --> $DIR/suggest-param-env-shadowing-incompatible-args.rs:8:16 - | -LL | type Assoc = T; - | ^^^^^^ - -error[E0308]: mismatched types - --> $DIR/suggest-param-env-shadowing-incompatible-args.rs:14:9 - | -LL | fn foo() -> Self::Assoc { - | ----------- expected `<() as Foo>::Assoc` because of return type -LL | [] - | ^^ expected `u8`, found `[_; 0]` - | - = note: expected type `u8` - found array `[_; 0]` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-types/type-const-inherent-impl-normalize.rs b/tests/ui/associated-types/type-const-inherent-impl-normalize.rs deleted file mode 100644 index a9c7373b4f44..000000000000 --- a/tests/ui/associated-types/type-const-inherent-impl-normalize.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct S; -impl S { - type const LEN: usize = 1; - //~^ ERROR: associated `type const` are unstable [E0658] - //~| ERROR: `type const` syntax is experimental [E0658] - fn arr() { - [8; Self::LEN] - //~^ WARN: cannot use constants which depend on generic parameters in types - //~| WARN: this was previously accepted by the compiler but is being phased out - //~| WARN: cannot use constants which depend on generic parameters in types - //~| WARN: this was previously accepted by the compiler but is being phased out - //~| ERROR: mismatched types - } -} - -pub fn main() {} diff --git a/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr b/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr deleted file mode 100644 index b86859f4a993..000000000000 --- a/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr +++ /dev/null @@ -1,52 +0,0 @@ -error[E0658]: `type const` syntax is experimental - --> $DIR/type-const-inherent-impl-normalize.rs:3:5 - | -LL | type const LEN: usize = 1; - | ^^^^^^^^^^ - | - = note: see issue #132980 for more information - = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: associated `type const` are unstable - --> $DIR/type-const-inherent-impl-normalize.rs:3:5 - | -LL | type const LEN: usize = 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #132980 for more information - = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: cannot use constants which depend on generic parameters in types - --> $DIR/type-const-inherent-impl-normalize.rs:7:13 - | -LL | [8; Self::LEN] - | ^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #76200 - = note: `#[warn(const_evaluatable_unchecked)]` (part of `#[warn(future_incompatible)]`) on by default - -warning: cannot use constants which depend on generic parameters in types - --> $DIR/type-const-inherent-impl-normalize.rs:7:13 - | -LL | [8; Self::LEN] - | ^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #76200 - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0308]: mismatched types - --> $DIR/type-const-inherent-impl-normalize.rs:7:9 - | -LL | fn arr() { - | - help: try adding a return type: `-> [i32; 1]` -LL | [8; Self::LEN] - | ^^^^^^^^^^^^^^ expected `()`, found `[{integer}; 1]` - -error: aborting due to 3 previous errors; 2 warnings emitted - -Some errors have detailed explanations: E0308, E0658. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/async-closures/def-path.stderr b/tests/ui/async-await/async-closures/def-path.stderr index e140e9b94b30..a507fa697604 100644 --- a/tests/ui/async-await/async-closures/def-path.stderr +++ b/tests/ui/async-await/async-closures/def-path.stderr @@ -5,11 +5,11 @@ LL | let x = async || {}; | -- the expected `async` closure body LL | LL | let () = x(); - | ^^ --- this expression has type `{static main::{closure#0}::{closure#0} upvar_tys=?14t resume_ty=std::future::ResumeTy yield_ty=() return_ty=()}` + | ^^ --- this expression has type `{static main::{closure#0}::{closure#0} upvar_tys=?14t resume_ty=ResumeTy yield_ty=() return_ty=()}` | | | expected `async` closure body, found `()` | - = note: expected `async` closure body `{static main::{closure#0}::{closure#0} upvar_tys=?14t resume_ty=std::future::ResumeTy yield_ty=() return_ty=()}` + = note: expected `async` closure body `{static main::{closure#0}::{closure#0} upvar_tys=?14t resume_ty=ResumeTy yield_ty=() return_ty=()}` found unit type `()` error: aborting due to 1 previous error diff --git a/tests/ui/async-await/async-closures/move-from-async-fn-bound.rs b/tests/ui/async-await/async-closures/move-from-async-fn-bound.rs deleted file mode 100644 index fbd8aac2515b..000000000000 --- a/tests/ui/async-await/async-closures/move-from-async-fn-bound.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ edition:2021 -// Test that a by-ref `AsyncFn` closure gets an error when it tries to -// consume a value, with a helpful diagnostic pointing to the bound. - -fn call(_: F) where F: AsyncFn() {} - -fn main() { - let y = vec![format!("World")]; - call(async || { - //~^ ERROR cannot move out of `y`, a captured variable in an `AsyncFn` closure - y.into_iter(); - }); -} diff --git a/tests/ui/async-await/async-closures/move-from-async-fn-bound.stderr b/tests/ui/async-await/async-closures/move-from-async-fn-bound.stderr deleted file mode 100644 index 1a881db2a37d..000000000000 --- a/tests/ui/async-await/async-closures/move-from-async-fn-bound.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0507]: cannot move out of `y`, a captured variable in an `AsyncFn` closure - --> $DIR/move-from-async-fn-bound.rs:9:10 - | -LL | let y = vec![format!("World")]; - | - captured outer variable -LL | call(async || { - | ^^^^^^^^ - | | - | captured by this `AsyncFn` closure - | `y` is moved here -LL | -LL | y.into_iter(); - | - - | | - | variable moved due to use in coroutine - | move occurs because `y` has type `Vec`, which does not implement the `Copy` trait - | -help: `AsyncFn` and `AsyncFnMut` closures require captured values to be able to be consumed multiple times, but `AsyncFnOnce` closures may consume them only once - --> $DIR/move-from-async-fn-bound.rs:5:27 - | -LL | fn call(_: F) where F: AsyncFn() {} - | ^^^^^^^^^ -help: consider cloning the value if the performance cost is acceptable - | -LL | y.clone().into_iter(); - | ++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/async-await/async-fn/dyn-pos.stderr b/tests/ui/async-await/async-fn/dyn-pos.stderr index efd3357ca679..7d5b37bdbe73 100644 --- a/tests/ui/async-await/async-fn/dyn-pos.stderr +++ b/tests/ui/async-await/async-fn/dyn-pos.stderr @@ -8,7 +8,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | - = note: the trait is not dyn compatible because it contains generic associated type `CallRefFuture` + = note: the trait is not dyn compatible because it contains the generic associated type `CallRefFuture` error: aborting due to 1 previous error diff --git a/tests/ui/async-await/issue-70818.rs b/tests/ui/async-await/issue-70818.rs index af9f33d9050b..c11332fe7d84 100644 --- a/tests/ui/async-await/issue-70818.rs +++ b/tests/ui/async-await/issue-70818.rs @@ -2,8 +2,9 @@ use std::future::Future; fn foo(ty: T, ty1: U) -> impl Future + Send { - //~^ ERROR: future cannot be sent between threads safely + //~^ ERROR future cannot be sent between threads safely async { (ty, ty1) } + //~^ ERROR future cannot be sent between threads safely } fn main() {} diff --git a/tests/ui/async-await/issue-70818.stderr b/tests/ui/async-await/issue-70818.stderr index 8de6a825042b..07fd20cdd77e 100644 --- a/tests/ui/async-await/issue-70818.stderr +++ b/tests/ui/async-await/issue-70818.stderr @@ -1,3 +1,24 @@ +error: future cannot be sent between threads safely + --> $DIR/issue-70818.rs:6:5 + | +LL | async { (ty, ty1) } + | ^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` + | +note: captured value is not `Send` + --> $DIR/issue-70818.rs:6:18 + | +LL | async { (ty, ty1) } + | ^^^ has type `U` which is not `Send` +note: required by a bound in an opaque type + --> $DIR/issue-70818.rs:4:69 + | +LL | fn foo(ty: T, ty1: U) -> impl Future + Send { + | ^^^^ +help: consider restricting type parameter `U` with trait `Send` + | +LL | fn foo(ty: T, ty1: U) -> impl Future + Send { + | +++++++++++++++++++ + error: future cannot be sent between threads safely --> $DIR/issue-70818.rs:4:38 | @@ -14,5 +35,5 @@ help: consider restricting type parameter `U` with trait `Send` LL | fn foo(ty: T, ty1: U) -> impl Future + Send { | +++++++++++++++++++ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/issue-70935-complex-spans.rs b/tests/ui/async-await/issue-70935-complex-spans.rs index 27826f79dcd9..2851637ae78f 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.rs +++ b/tests/ui/async-await/issue-70935-complex-spans.rs @@ -15,6 +15,7 @@ async fn baz(_c: impl FnMut() -> T) where T: Future { fn foo(x: NotSync) -> impl Future + Send { //~^ ERROR `*mut ()` cannot be shared between threads safely async move { + //~^ ERROR `*mut ()` cannot be shared between threads safely baz(|| async { foo(x.clone()); }).await; diff --git a/tests/ui/async-await/issue-70935-complex-spans.stderr b/tests/ui/async-await/issue-70935-complex-spans.stderr index b9180c620b0d..31d15c459217 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.stderr @@ -1,3 +1,46 @@ +error[E0277]: `*mut ()` cannot be shared between threads safely + --> $DIR/issue-70935-complex-spans.rs:17:5 + | +LL | / async move { +LL | | +LL | | baz(|| async { +LL | | foo(x.clone()); +LL | | }).await; +LL | | } + | |_____^ `*mut ()` cannot be shared between threads safely + | + = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` +note: required because it appears within the type `PhantomData<*mut ()>` + --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required because it appears within the type `NotSync` + --> $DIR/issue-70935-complex-spans.rs:9:8 + | +LL | struct NotSync(PhantomData<*mut ()>); + | ^^^^^^^ + = note: required for `&NotSync` to implement `Send` +note: required because it's used within this closure + --> $DIR/issue-70935-complex-spans.rs:19:13 + | +LL | baz(|| async { + | ^^ +note: required because it's used within this `async` fn body + --> $DIR/issue-70935-complex-spans.rs:12:67 + | +LL | async fn baz(_c: impl FnMut() -> T) where T: Future { + | ___________________________________________________________________^ +LL | | } + | |_^ +note: required because it's used within this `async` block + --> $DIR/issue-70935-complex-spans.rs:17:5 + | +LL | async move { + | ^^^^^^^^^^ +note: required by a bound in an opaque type + --> $DIR/issue-70935-complex-spans.rs:15:37 + | +LL | fn foo(x: NotSync) -> impl Future + Send { + | ^^^^ + error[E0277]: `*mut ()` cannot be shared between threads safely --> $DIR/issue-70935-complex-spans.rs:15:23 | @@ -14,7 +57,7 @@ LL | struct NotSync(PhantomData<*mut ()>); | ^^^^^^^ = note: required for `&NotSync` to implement `Send` note: required because it's used within this closure - --> $DIR/issue-70935-complex-spans.rs:18:13 + --> $DIR/issue-70935-complex-spans.rs:19:13 | LL | baz(|| async { | ^^ @@ -31,6 +74,6 @@ note: required because it's used within this `async` block LL | async move { | ^^^^^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unreachable-lint-2.stderr b/tests/ui/async-await/unreachable-lint-2.stderr index 5e7b328cf523..cbebc9951f32 100644 --- a/tests/ui/async-await/unreachable-lint-2.stderr +++ b/tests/ui/async-await/unreachable-lint-2.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/attributes/ambiguous_derive_helpers.rs b/tests/ui/attributes/ambiguous_derive_helpers.rs deleted file mode 100644 index aee498a7067a..000000000000 --- a/tests/ui/attributes/ambiguous_derive_helpers.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ force-host -//@ no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![deny(ambiguous_derive_helpers)] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Trait, attributes(ignore))] //~ ERROR there exists a built-in attribute with the same name -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -pub fn deriving(input: TokenStream) -> TokenStream { - TokenStream::new() -} diff --git a/tests/ui/attributes/ambiguous_derive_helpers.stderr b/tests/ui/attributes/ambiguous_derive_helpers.stderr deleted file mode 100644 index a1eb8d172c25..000000000000 --- a/tests/ui/attributes/ambiguous_derive_helpers.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: there exists a built-in attribute with the same name - --> $DIR/ambiguous_derive_helpers.rs:11:39 - | -LL | #[proc_macro_derive(Trait, attributes(ignore))] - | ^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #151276 -note: the lint level is defined here - --> $DIR/ambiguous_derive_helpers.rs:5:9 - | -LL | #![deny(ambiguous_derive_helpers)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/attributes/attr-on-mac-call.stderr b/tests/ui/attributes/attr-on-mac-call.stderr index 3bb50f2d6f65..1aeec463c71c 100644 --- a/tests/ui/attributes/attr-on-mac-call.stderr +++ b/tests/ui/attributes/attr-on-mac-call.stderr @@ -55,7 +55,7 @@ LL | #[deprecated] | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements warning: `#[inline]` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:24:5 @@ -136,7 +136,7 @@ LL | #[deprecated] | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements warning: `#[automatically_derived]` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:51:5 @@ -163,7 +163,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_implicit_prelude]` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:60:5 diff --git a/tests/ui/attributes/builtin-attribute-prefix.rs b/tests/ui/attributes/builtin-attribute-prefix.rs index 02af7f536f86..d184c6d008df 100644 --- a/tests/ui/attributes/builtin-attribute-prefix.rs +++ b/tests/ui/attributes/builtin-attribute-prefix.rs @@ -1,8 +1,8 @@ // Regression test for https://github.com/rust-lang/rust/issues/143789 #[must_use::skip] -//~^ ERROR: cannot find module or crate `must_use` +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `must_use` fn main() { } // Regression test for https://github.com/rust-lang/rust/issues/137590 struct S(#[stable::skip] u8, u16, u32); -//~^ ERROR: cannot find module or crate `stable` +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `stable` diff --git a/tests/ui/attributes/builtin-attribute-prefix.stderr b/tests/ui/attributes/builtin-attribute-prefix.stderr index a3e6c2e0172b..a16080c003fb 100644 --- a/tests/ui/attributes/builtin-attribute-prefix.stderr +++ b/tests/ui/attributes/builtin-attribute-prefix.stderr @@ -1,10 +1,10 @@ -error[E0433]: cannot find module or crate `stable` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `stable` --> $DIR/builtin-attribute-prefix.rs:7:12 | LL | struct S(#[stable::skip] u8, u16, u32); | ^^^^^^ use of unresolved module or unlinked crate `stable` -error[E0433]: cannot find module or crate `must_use` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `must_use` --> $DIR/builtin-attribute-prefix.rs:2:3 | LL | #[must_use::skip] diff --git a/tests/ui/attributes/check-builtin-attr-ice.rs b/tests/ui/attributes/check-builtin-attr-ice.rs index bf4e3492f709..811210e2ccaf 100644 --- a/tests/ui/attributes/check-builtin-attr-ice.rs +++ b/tests/ui/attributes/check-builtin-attr-ice.rs @@ -43,11 +43,11 @@ struct Foo { #[should_panic::skip] - //~^ ERROR cannot find + //~^ ERROR failed to resolve pub field: u8, #[should_panic::a::b::c] - //~^ ERROR cannot find + //~^ ERROR failed to resolve pub field2: u8, } @@ -55,6 +55,6 @@ fn foo() {} fn main() { #[deny::skip] - //~^ ERROR cannot find + //~^ ERROR failed to resolve foo(); } diff --git a/tests/ui/attributes/check-builtin-attr-ice.stderr b/tests/ui/attributes/check-builtin-attr-ice.stderr index 35c97a05918e..07bbe01898a7 100644 --- a/tests/ui/attributes/check-builtin-attr-ice.stderr +++ b/tests/ui/attributes/check-builtin-attr-ice.stderr @@ -1,16 +1,16 @@ -error[E0433]: cannot find module or crate `should_panic` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `should_panic` --> $DIR/check-builtin-attr-ice.rs:45:7 | LL | #[should_panic::skip] | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `should_panic` -error[E0433]: cannot find module or crate `should_panic` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `should_panic` --> $DIR/check-builtin-attr-ice.rs:49:7 | LL | #[should_panic::a::b::c] | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `should_panic` -error[E0433]: cannot find module or crate `deny` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `deny` --> $DIR/check-builtin-attr-ice.rs:57:7 | LL | #[deny::skip] diff --git a/tests/ui/attributes/check-cfg_attr-ice.rs b/tests/ui/attributes/check-cfg_attr-ice.rs index 5fb3f2798ba7..5bf8baab1414 100644 --- a/tests/ui/attributes/check-cfg_attr-ice.rs +++ b/tests/ui/attributes/check-cfg_attr-ice.rs @@ -10,27 +10,27 @@ #![crate_type = "lib"] #[cfg_attr::no_such_thing] -//~^ ERROR cannot find +//~^ ERROR failed to resolve mod we_are_no_strangers_to_love {} #[cfg_attr::no_such_thing] -//~^ ERROR cannot find +//~^ ERROR failed to resolve struct YouKnowTheRules { #[cfg_attr::no_such_thing] - //~^ ERROR cannot find + //~^ ERROR failed to resolve and_so_do_i: u8, } #[cfg_attr::no_such_thing] -//~^ ERROR cannot find +//~^ ERROR failed to resolve fn a_full_commitment() { #[cfg_attr::no_such_thing] - //~^ ERROR cannot find + //~^ ERROR failed to resolve let is_what_i_am_thinking_of = (); } #[cfg_attr::no_such_thing] -//~^ ERROR cannot find +//~^ ERROR failed to resolve union AnyOtherGuy { owo: () } @@ -39,30 +39,30 @@ struct This; #[cfg_attr(FALSE, doc = "you wouldn't get this")] impl From for This { #[cfg_attr::no_such_thing] - //~^ ERROR cannot find + //~^ ERROR failed to resolve fn from(#[cfg_attr::no_such_thing] any_other_guy: AnyOtherGuy) -> This { - //~^ ERROR cannot find + //~^ ERROR failed to resolve #[cfg_attr::no_such_thing] //~^ ERROR attributes on expressions are experimental - //~| ERROR cannot find + //~| ERROR failed to resolve unreachable!() } } #[cfg_attr::no_such_thing] -//~^ ERROR cannot find +//~^ ERROR failed to resolve enum NeverGonna { #[cfg_attr::no_such_thing] - //~^ ERROR cannot find + //~^ ERROR failed to resolve GiveYouUp(#[cfg_attr::no_such_thing] u8), - //~^ ERROR cannot find + //~^ ERROR failed to resolve LetYouDown { #![cfg_attr::no_such_thing] //~^ ERROR an inner attribute is not permitted in this context never_gonna: (), round_around: (), #[cfg_attr::no_such_thing] - //~^ ERROR cannot find + //~^ ERROR failed to resolve and_desert_you: (), }, } diff --git a/tests/ui/attributes/check-cfg_attr-ice.stderr b/tests/ui/attributes/check-cfg_attr-ice.stderr index 65476e2f76b6..bed3150bdc2f 100644 --- a/tests/ui/attributes/check-cfg_attr-ice.stderr +++ b/tests/ui/attributes/check-cfg_attr-ice.stderr @@ -17,79 +17,79 @@ LL | #[cfg_attr::no_such_thing] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:52:3 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:55:7 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:57:17 | LL | GiveYouUp(#[cfg_attr::no_such_thing] u8), | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:64:11 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:41:7 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:43:15 | LL | fn from(#[cfg_attr::no_such_thing] any_other_guy: AnyOtherGuy) -> This { | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:45:11 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:32:3 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:24:3 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:27:7 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:16:3 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:19:7 | LL | #[cfg_attr::no_such_thing] | ^^^^^^^^ use of unresolved module or unlinked crate `cfg_attr` -error[E0433]: cannot find module or crate `cfg_attr` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cfg_attr` --> $DIR/check-cfg_attr-ice.rs:12:3 | LL | #[cfg_attr::no_such_thing] diff --git a/tests/ui/attributes/const-stability-on-macro.rs b/tests/ui/attributes/const-stability-on-macro.rs index 4336370430d4..af268ccd5366 100644 --- a/tests/ui/attributes/const-stability-on-macro.rs +++ b/tests/ui/attributes/const-stability-on-macro.rs @@ -2,13 +2,13 @@ #![stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "foo", since = "3.3.3")] -//~^ ERROR attribute cannot be used on macro defs +//~^ ERROR macros cannot have const stability attributes macro_rules! foo { () => {}; } -#[rustc_const_unstable(feature = "bar", issue = "none")] -//~^ ERROR attribute cannot be used on macro defs +#[rustc_const_unstable(feature = "bar", issue="none")] +//~^ ERROR macros cannot have const stability attributes macro_rules! bar { () => {}; } diff --git a/tests/ui/attributes/const-stability-on-macro.stderr b/tests/ui/attributes/const-stability-on-macro.stderr index a8b56edfa59d..28f31e3d4f61 100644 --- a/tests/ui/attributes/const-stability-on-macro.stderr +++ b/tests/ui/attributes/const-stability-on-macro.stderr @@ -1,18 +1,20 @@ -error: `#[rustc_const_stable]` attribute cannot be used on macro defs +error: macros cannot have const stability attributes --> $DIR/const-stability-on-macro.rs:4:1 | LL | #[rustc_const_stable(feature = "foo", since = "3.3.3")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_const_stable]` can be applied to associated consts, constants, crates, functions, impl blocks, statics, traits, and use statements + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute +LL | +LL | macro_rules! foo { + | ---------------- const stability attribute affects this macro -error: `#[rustc_const_unstable]` attribute cannot be used on macro defs +error: macros cannot have const stability attributes --> $DIR/const-stability-on-macro.rs:10:1 | -LL | #[rustc_const_unstable(feature = "bar", issue = "none")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_const_unstable]` can be applied to associated consts, constants, crates, functions, impl blocks, statics, traits, and use statements +LL | #[rustc_const_unstable(feature = "bar", issue="none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute +LL | +LL | macro_rules! bar { + | ---------------- const stability attribute affects this macro error: aborting due to 2 previous errors diff --git a/tests/ui/attributes/crate-only-as-outer.stderr b/tests/ui/attributes/crate-only-as-outer.stderr index c1787a73d290..270f02af9873 100644 --- a/tests/ui/attributes/crate-only-as-outer.stderr +++ b/tests/ui/attributes/crate-only-as-outer.stderr @@ -4,7 +4,7 @@ error: crate-level attribute should be an inner attribute: add an exclamation ma LL | #[crate_name = "owo"] | ^^^^^^^^^^^^^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this function +note: This attribute does not have an `!`, which means it is applied to this function --> $DIR/crate-only-as-outer.rs:5:1 | LL | fn main() {} diff --git a/tests/ui/attributes/crate-type-delimited.stderr b/tests/ui/attributes/crate-type-delimited.stderr index a31d8dadc66e..e9616f27174c 100644 --- a/tests/ui/attributes/crate-type-delimited.stderr +++ b/tests/ui/attributes/crate-type-delimited.stderr @@ -1,11 +1,10 @@ -error[E0539]: malformed `crate_type` attribute input +error: malformed `crate_type` attribute input --> $DIR/crate-type-delimited.rs:2:1 | LL | #![crate_type(lib)] - | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "crate type"]` + | ^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/attributes/crate-type-empty.stderr b/tests/ui/attributes/crate-type-empty.stderr index bc085b8c7c07..b8eca61748ea 100644 --- a/tests/ui/attributes/crate-type-empty.stderr +++ b/tests/ui/attributes/crate-type-empty.stderr @@ -1,11 +1,10 @@ -error[E0539]: malformed `crate_type` attribute input +error: malformed `crate_type` attribute input --> $DIR/crate-type-empty.rs:2:1 | LL | #![crate_type] - | ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "crate type"]` + | ^^^^^^^^^^^^^^ | = note: for more information, visit error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/attributes/crate-type-macro-call.rs b/tests/ui/attributes/crate-type-macro-call.rs index 0d074422d951..9ba5e79ba947 100644 --- a/tests/ui/attributes/crate-type-macro-call.rs +++ b/tests/ui/attributes/crate-type-macro-call.rs @@ -1,5 +1,4 @@ -#![crate_type = foo!()] -//~^ ERROR attribute value must be a literal +#![crate_type = foo!()] //~ ERROR malformed `crate_type` attribute macro_rules! foo { () => {"rlib"}; diff --git a/tests/ui/attributes/crate-type-macro-call.stderr b/tests/ui/attributes/crate-type-macro-call.stderr index 690f09984710..b3927fef4718 100644 --- a/tests/ui/attributes/crate-type-macro-call.stderr +++ b/tests/ui/attributes/crate-type-macro-call.stderr @@ -1,8 +1,10 @@ -error: attribute value must be a literal - --> $DIR/crate-type-macro-call.rs:1:17 +error: malformed `crate_type` attribute input + --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit error: aborting due to 1 previous error diff --git a/tests/ui/attributes/crate-type-macro-empty.rs b/tests/ui/attributes/crate-type-macro-empty.rs index d55074ed686c..cfc71e6b938f 100644 --- a/tests/ui/attributes/crate-type-macro-empty.rs +++ b/tests/ui/attributes/crate-type-macro-empty.rs @@ -1,7 +1,7 @@ // Tests for the issue in #137589 #[crate_type = foo!()] //~^ ERROR cannot find macro `foo` in this scope -//~| ERROR attribute value must be a literal +//~| WARN crate-level attribute should be an inner attribute macro_rules! foo {} //~ ERROR macros must contain at least one rule diff --git a/tests/ui/attributes/crate-type-macro-empty.stderr b/tests/ui/attributes/crate-type-macro-empty.stderr index 2e24a9972287..0c2c4cf2a9b2 100644 --- a/tests/ui/attributes/crate-type-macro-empty.stderr +++ b/tests/ui/attributes/crate-type-macro-empty.stderr @@ -16,11 +16,17 @@ note: a macro with the same name exists, but it appears later LL | macro_rules! foo {} | ^^^ -error: attribute value must be a literal - --> $DIR/crate-type-macro-empty.rs:2:16 +warning: crate-level attribute should be an inner attribute + --> $DIR/crate-type-macro-empty.rs:2:1 | LL | #[crate_type = foo!()] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: requested on the command line with `-W unused-attributes` +help: add a `!` + | +LL | #![crate_type = foo!()] + | + -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/attributes/crate-type-macro-not-found.rs b/tests/ui/attributes/crate-type-macro-not-found.rs index eac780944572..b9f05fa7caa1 100644 --- a/tests/ui/attributes/crate-type-macro-not-found.rs +++ b/tests/ui/attributes/crate-type-macro-not-found.rs @@ -1,7 +1,6 @@ // Tests for the issue in #137589 -#[crate_type = foo!()] -//~^ ERROR cannot find macro `foo` in this scope -//~| ERROR attribute value must be a literal +#[crate_type = foo!()] //~ ERROR cannot find macro `foo` in this scope +//~| WARN crate-level attribute should be an inner attribute macro_rules! foo { ($x:expr) => {"rlib"} diff --git a/tests/ui/attributes/crate-type-macro-not-found.stderr b/tests/ui/attributes/crate-type-macro-not-found.stderr index 9db7f7f6ec0b..7b8c6a808349 100644 --- a/tests/ui/attributes/crate-type-macro-not-found.stderr +++ b/tests/ui/attributes/crate-type-macro-not-found.stderr @@ -5,16 +5,22 @@ LL | #[crate_type = foo!()] | ^^^ consider moving the definition of `foo` before this call | note: a macro with the same name exists, but it appears later - --> $DIR/crate-type-macro-not-found.rs:6:14 + --> $DIR/crate-type-macro-not-found.rs:5:14 | LL | macro_rules! foo { | ^^^ -error: attribute value must be a literal - --> $DIR/crate-type-macro-not-found.rs:2:16 +warning: crate-level attribute should be an inner attribute + --> $DIR/crate-type-macro-not-found.rs:2:1 | LL | #[crate_type = foo!()] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: requested on the command line with `-W unused-attributes` +help: add a `!` + | +LL | #![crate_type = foo!()] + | + -error: aborting due to 2 previous errors +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/attributes/crate-type-non-crate.rs b/tests/ui/attributes/crate-type-non-crate.rs deleted file mode 100644 index bd667b4b0a45..000000000000 --- a/tests/ui/attributes/crate-type-non-crate.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! Test the behavior of various malformed `crate_type` attributes applied to a non-crate target. -#![allow(unused_attributes)] - -// No arguments -#[crate_type] //~ ERROR malformed `crate_type` attribute input -// List/NameValue with/without strings -#[crate_type(lib)] //~ ERROR malformed `crate_type` attribute input -#[crate_type("lib")] //~ ERROR malformed `crate_type` attribute input -#[crate_type = lib] //~ ERROR attribute value must be a literal -#[crate_type = "lib"] // OK -// Same as above but with invalid names -#[crate_type(foo)] //~ ERROR malformed `crate_type` attribute input -#[crate_type("foo")] //~ ERROR malformed `crate_type` attribute input -#[crate_type = foo] //~ ERROR attribute value must be a literal -#[crate_type = "foo"] // OK - we don't report errors on invalid crate types here -// Non-string literals -#[crate_type(1)] //~ ERROR malformed `crate_type` attribute input -#[crate_type = 1] //~ ERROR malformed `crate_type` attribute input -fn main() {} diff --git a/tests/ui/attributes/crate-type-non-crate.stderr b/tests/ui/attributes/crate-type-non-crate.stderr deleted file mode 100644 index 03bafeaf5ebd..000000000000 --- a/tests/ui/attributes/crate-type-non-crate.stderr +++ /dev/null @@ -1,74 +0,0 @@ -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:5:1 - | -LL | #[crate_type] - | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:7:1 - | -LL | #[crate_type(lib)] - | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:8:1 - | -LL | #[crate_type("lib")] - | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error: attribute value must be a literal - --> $DIR/crate-type-non-crate.rs:9:16 - | -LL | #[crate_type = lib] - | ^^^ - -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:12:1 - | -LL | #[crate_type(foo)] - | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:13:1 - | -LL | #[crate_type("foo")] - | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error: attribute value must be a literal - --> $DIR/crate-type-non-crate.rs:14:16 - | -LL | #[crate_type = foo] - | ^^^ - -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:17:1 - | -LL | #[crate_type(1)] - | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error[E0539]: malformed `crate_type` attribute input - --> $DIR/crate-type-non-crate.rs:18:1 - | -LL | #[crate_type = 1] - | ^^^^^^^^^^^^^^^-^ - | | | - | | expected a string literal here - | help: must be of the form: `#[crate_type = "crate type"]` - | - = note: for more information, visit - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/attributes/custom_attr_multisegment_error.rs b/tests/ui/attributes/custom_attr_multisegment_error.rs index f42c35ffea13..1045282c3a33 100644 --- a/tests/ui/attributes/custom_attr_multisegment_error.rs +++ b/tests/ui/attributes/custom_attr_multisegment_error.rs @@ -2,5 +2,5 @@ mod existent {} -#[existent::nonexistent] //~ ERROR cannot find `nonexistent` in `existent` +#[existent::nonexistent] //~ ERROR failed to resolve: could not find `nonexistent` in `existent` fn main() {} diff --git a/tests/ui/attributes/custom_attr_multisegment_error.stderr b/tests/ui/attributes/custom_attr_multisegment_error.stderr index 8066fc74de4b..02bed225d53e 100644 --- a/tests/ui/attributes/custom_attr_multisegment_error.stderr +++ b/tests/ui/attributes/custom_attr_multisegment_error.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `nonexistent` in `existent` +error[E0433]: failed to resolve: could not find `nonexistent` in `existent` --> $DIR/custom_attr_multisegment_error.rs:5:13 | LL | #[existent::nonexistent] diff --git a/tests/ui/attributes/field-attributes-vis-unresolved.rs b/tests/ui/attributes/field-attributes-vis-unresolved.rs index bcdabe42fcc2..be710a3cd744 100644 --- a/tests/ui/attributes/field-attributes-vis-unresolved.rs +++ b/tests/ui/attributes/field-attributes-vis-unresolved.rs @@ -15,12 +15,12 @@ mod internal { struct S { #[rustfmt::skip] - pub(in nonexistent) field: u8 //~ ERROR cannot find + pub(in nonexistent) field: u8 //~ ERROR failed to resolve } struct Z( #[rustfmt::skip] - pub(in nonexistent) u8 //~ ERROR cannot find + pub(in nonexistent) u8 //~ ERROR failed to resolve ); fn main() {} diff --git a/tests/ui/attributes/field-attributes-vis-unresolved.stderr b/tests/ui/attributes/field-attributes-vis-unresolved.stderr index f1148385d8a1..1ebfde4cd67e 100644 --- a/tests/ui/attributes/field-attributes-vis-unresolved.stderr +++ b/tests/ui/attributes/field-attributes-vis-unresolved.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `nonexistent` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nonexistent` --> $DIR/field-attributes-vis-unresolved.rs:18:12 | LL | pub(in nonexistent) field: u8 @@ -9,7 +9,7 @@ help: you might be missing a crate named `nonexistent`, add it to your project a LL + extern crate nonexistent; | -error[E0433]: cannot find module or crate `nonexistent` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nonexistent` --> $DIR/field-attributes-vis-unresolved.rs:23:12 | LL | pub(in nonexistent) u8 diff --git a/tests/ui/attributes/illegal-macro-use.rs b/tests/ui/attributes/illegal-macro-use.rs index e16a223c75ff..5a567107a6e2 100644 --- a/tests/ui/attributes/illegal-macro-use.rs +++ b/tests/ui/attributes/illegal-macro-use.rs @@ -1,15 +1,15 @@ // issue#140255 -#[macro_use::a] //~ ERROR cannot find +#[macro_use::a] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_use` fn f0() {} -#[macro_use::a::b] //~ ERROR cannot find +#[macro_use::a::b] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_use` fn f1() {} -#[macro_escape::a] //~ ERROR cannot find +#[macro_escape::a] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_escape` fn f2() {} -#[macro_escape::a::b] //~ ERROR cannot find +#[macro_escape::a::b] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_escape` fn f3() {} fn main() {} diff --git a/tests/ui/attributes/illegal-macro-use.stderr b/tests/ui/attributes/illegal-macro-use.stderr index 13c9f05ccd66..fa6bb83d588a 100644 --- a/tests/ui/attributes/illegal-macro-use.stderr +++ b/tests/ui/attributes/illegal-macro-use.stderr @@ -1,22 +1,22 @@ -error[E0433]: cannot find module or crate `macro_escape` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_escape` --> $DIR/illegal-macro-use.rs:12:3 | LL | #[macro_escape::a::b] | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `macro_escape` -error[E0433]: cannot find module or crate `macro_escape` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_escape` --> $DIR/illegal-macro-use.rs:9:3 | LL | #[macro_escape::a] | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `macro_escape` -error[E0433]: cannot find module or crate `macro_use` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_use` --> $DIR/illegal-macro-use.rs:6:3 | LL | #[macro_use::a::b] | ^^^^^^^^^ use of unresolved module or unlinked crate `macro_use` -error[E0433]: cannot find module or crate `macro_use` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_use` --> $DIR/illegal-macro-use.rs:3:3 | LL | #[macro_use::a] diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs index 6193a101918b..6dc3086b63e1 100644 --- a/tests/ui/attributes/malformed-attrs.rs +++ b/tests/ui/attributes/malformed-attrs.rs @@ -2,6 +2,7 @@ // We enable a bunch of features to not get feature-gate errs in this test. #![deny(invalid_doc_attributes)] #![feature(rustc_attrs)] +#![feature(rustc_allow_const_fn_unstable)] #![feature(allow_internal_unstable)] // FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity #![feature(fn_align)] @@ -144,6 +145,8 @@ struct Test; #[diagnostic::on_unimplemented = 1] //~^ WARN malformed trait Hey { + #[type_const = 1] + //~^ ERROR malformed const HEY: usize = 5; } diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 01e70adf4ee9..17215f02f787 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `cfg` attribute input - --> $DIR/malformed-attrs.rs:106:1 + --> $DIR/malformed-attrs.rs:107:1 | LL | #[cfg] | ^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg] = note: for more information, visit error[E0539]: malformed `cfg_attr` attribute input - --> $DIR/malformed-attrs.rs:108:1 + --> $DIR/malformed-attrs.rs:109:1 | LL | #[cfg_attr] | ^^^^^^^^^^^ @@ -21,13 +21,19 @@ LL | #[cfg_attr] = note: for more information, visit error[E0463]: can't find crate for `wloop` - --> $DIR/malformed-attrs.rs:214:1 + --> $DIR/malformed-attrs.rs:217:1 | LL | extern crate wloop; | ^^^^^^^^^^^^^^^^^^^ can't find crate +error: malformed `patchable_function_entry` attribute input + --> $DIR/malformed-attrs.rs:113:1 + | +LL | #[patchable_function_entry] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` + error: malformed `allow` attribute input - --> $DIR/malformed-attrs.rs:180:1 + --> $DIR/malformed-attrs.rs:183:1 | LL | #[allow] | ^^^^^^^^ @@ -43,7 +49,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `expect` attribute input - --> $DIR/malformed-attrs.rs:182:1 + --> $DIR/malformed-attrs.rs:185:1 | LL | #[expect] | ^^^^^^^^^ @@ -59,7 +65,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `warn` attribute input - --> $DIR/malformed-attrs.rs:184:1 + --> $DIR/malformed-attrs.rs:187:1 | LL | #[warn] | ^^^^^^^ @@ -75,7 +81,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `deny` attribute input - --> $DIR/malformed-attrs.rs:186:1 + --> $DIR/malformed-attrs.rs:189:1 | LL | #[deny] | ^^^^^^^ @@ -91,7 +97,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `forbid` attribute input - --> $DIR/malformed-attrs.rs:188:1 + --> $DIR/malformed-attrs.rs:191:1 | LL | #[forbid] | ^^^^^^^^^ @@ -107,25 +113,25 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:103:1 + --> $DIR/malformed-attrs.rs:104:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^^^^^^ error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:120:1 + --> $DIR/malformed-attrs.rs:121:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:127:1 + --> $DIR/malformed-attrs.rs:128:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint - --> $DIR/malformed-attrs.rs:219:1 + --> $DIR/malformed-attrs.rs:222:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -134,7 +140,7 @@ LL | #[allow_internal_unsafe = 1] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0539]: malformed `windows_subsystem` attribute input - --> $DIR/malformed-attrs.rs:26:1 + --> $DIR/malformed-attrs.rs:27:1 | LL | #![windows_subsystem] | ^^^-----------------^ @@ -150,25 +156,25 @@ LL | #![windows_subsystem = "windows"] | +++++++++++ error[E0539]: malformed `export_name` attribute input - --> $DIR/malformed-attrs.rs:29:1 + --> $DIR/malformed-attrs.rs:30:1 | LL | #[unsafe(export_name)] | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` error: `rustc_allow_const_fn_unstable` expects a list of feature names - --> $DIR/malformed-attrs.rs:31:1 + --> $DIR/malformed-attrs.rs:32:1 | LL | #[rustc_allow_const_fn_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `allow_internal_unstable` expects a list of feature names - --> $DIR/malformed-attrs.rs:34:1 + --> $DIR/malformed-attrs.rs:35:1 | LL | #[allow_internal_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0539]: malformed `rustc_confusables` attribute input - --> $DIR/malformed-attrs.rs:36:1 + --> $DIR/malformed-attrs.rs:37:1 | LL | #[rustc_confusables] | ^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +183,7 @@ LL | #[rustc_confusables] | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` error: `#[rustc_confusables]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:36:1 + --> $DIR/malformed-attrs.rs:37:1 | LL | #[rustc_confusables] | ^^^^^^^^^^^^^^^^^^^^ @@ -185,7 +191,7 @@ LL | #[rustc_confusables] = help: `#[rustc_confusables]` can only be applied to inherent methods error[E0539]: malformed `deprecated` attribute input - --> $DIR/malformed-attrs.rs:39:1 + --> $DIR/malformed-attrs.rs:40:1 | LL | #[deprecated = 5] | ^^^^^^^^^^^^^^^-^ @@ -193,7 +199,7 @@ LL | #[deprecated = 5] | expected a string literal here error[E0539]: malformed `rustc_macro_transparency` attribute input - --> $DIR/malformed-attrs.rs:43:1 + --> $DIR/malformed-attrs.rs:44:1 | LL | #[rustc_macro_transparency] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -208,7 +214,7 @@ LL | #[rustc_macro_transparency = "transparent"] | +++++++++++++++ error: `#[rustc_macro_transparency]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:43:1 + --> $DIR/malformed-attrs.rs:44:1 | LL | #[rustc_macro_transparency] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -216,7 +222,7 @@ LL | #[rustc_macro_transparency] = help: `#[rustc_macro_transparency]` can only be applied to macro defs error[E0539]: malformed `repr` attribute input - --> $DIR/malformed-attrs.rs:46:1 + --> $DIR/malformed-attrs.rs:47:1 | LL | #[repr] | ^^^^^^^ expected this to be a list @@ -224,7 +230,7 @@ LL | #[repr] = note: for more information, visit error[E0565]: malformed `rustc_as_ptr` attribute input - --> $DIR/malformed-attrs.rs:49:1 + --> $DIR/malformed-attrs.rs:50:1 | LL | #[rustc_as_ptr = 5] | ^^^^^^^^^^^^^^^---^ @@ -233,7 +239,7 @@ LL | #[rustc_as_ptr = 5] | help: must be of the form: `#[rustc_as_ptr]` error[E0539]: malformed `rustc_align` attribute input - --> $DIR/malformed-attrs.rs:54:1 + --> $DIR/malformed-attrs.rs:55:1 | LL | #[rustc_align] | ^^^^^^^^^^^^^^ @@ -242,7 +248,7 @@ LL | #[rustc_align] | help: must be of the form: `#[rustc_align()]` error[E0539]: malformed `optimize` attribute input - --> $DIR/malformed-attrs.rs:56:1 + --> $DIR/malformed-attrs.rs:57:1 | LL | #[optimize] | ^^^^^^^^^^^ expected this to be a list @@ -257,7 +263,7 @@ LL | #[optimize(speed)] | +++++++ error[E0565]: malformed `cold` attribute input - --> $DIR/malformed-attrs.rs:58:1 + --> $DIR/malformed-attrs.rs:59:1 | LL | #[cold = 1] | ^^^^^^^---^ @@ -266,7 +272,7 @@ LL | #[cold = 1] | help: must be of the form: `#[cold]` error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:60:1 + --> $DIR/malformed-attrs.rs:61:1 | LL | #[must_use()] | ^^^^^^^^^^--^ @@ -284,7 +290,7 @@ LL + #[must_use] | error[E0565]: malformed `no_mangle` attribute input - --> $DIR/malformed-attrs.rs:62:1 + --> $DIR/malformed-attrs.rs:63:1 | LL | #[no_mangle = 1] | ^^^^^^^^^^^^---^ @@ -293,7 +299,7 @@ LL | #[no_mangle = 1] | help: must be of the form: `#[no_mangle]` error[E0565]: malformed `naked` attribute input - --> $DIR/malformed-attrs.rs:64:1 + --> $DIR/malformed-attrs.rs:65:1 | LL | #[unsafe(naked())] | ^^^^^^^^^^^^^^--^^ @@ -302,7 +308,7 @@ LL | #[unsafe(naked())] | help: must be of the form: `#[naked]` error[E0565]: malformed `track_caller` attribute input - --> $DIR/malformed-attrs.rs:66:1 + --> $DIR/malformed-attrs.rs:67:1 | LL | #[track_caller()] | ^^^^^^^^^^^^^^--^ @@ -311,13 +317,13 @@ LL | #[track_caller()] | help: must be of the form: `#[track_caller]` error[E0539]: malformed `export_name` attribute input - --> $DIR/malformed-attrs.rs:68:1 + --> $DIR/malformed-attrs.rs:69:1 | LL | #[export_name()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` error[E0805]: malformed `used` attribute input - --> $DIR/malformed-attrs.rs:70:1 + --> $DIR/malformed-attrs.rs:71:1 | LL | #[used()] | ^^^^^^--^ @@ -335,7 +341,7 @@ LL + #[used] | error: `#[used]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:70:1 + --> $DIR/malformed-attrs.rs:71:1 | LL | #[used()] | ^^^^^^^^^ @@ -343,13 +349,13 @@ LL | #[used()] = help: `#[used]` can only be applied to statics error[E0539]: malformed `crate_name` attribute input - --> $DIR/malformed-attrs.rs:73:1 + --> $DIR/malformed-attrs.rs:74:1 | LL | #[crate_name] | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]` error[E0539]: malformed `target_feature` attribute input - --> $DIR/malformed-attrs.rs:78:1 + --> $DIR/malformed-attrs.rs:79:1 | LL | #[target_feature] | ^^^^^^^^^^^^^^^^^ @@ -358,7 +364,7 @@ LL | #[target_feature] | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` error[E0565]: malformed `export_stable` attribute input - --> $DIR/malformed-attrs.rs:80:1 + --> $DIR/malformed-attrs.rs:81:1 | LL | #[export_stable = 1] | ^^^^^^^^^^^^^^^^---^ @@ -367,7 +373,7 @@ LL | #[export_stable = 1] | help: must be of the form: `#[export_stable]` error[E0539]: malformed `link` attribute input - --> $DIR/malformed-attrs.rs:82:1 + --> $DIR/malformed-attrs.rs:83:1 | LL | #[link] | ^^^^^^^ expected this to be a list @@ -375,7 +381,7 @@ LL | #[link] = note: for more information, visit error[E0539]: malformed `link_name` attribute input - --> $DIR/malformed-attrs.rs:86:1 + --> $DIR/malformed-attrs.rs:87:1 | LL | #[link_name] | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` @@ -383,7 +389,7 @@ LL | #[link_name] = note: for more information, visit error[E0539]: malformed `link_section` attribute input - --> $DIR/malformed-attrs.rs:90:1 + --> $DIR/malformed-attrs.rs:91:1 | LL | #[link_section] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]` @@ -391,7 +397,7 @@ LL | #[link_section] = note: for more information, visit error[E0539]: malformed `coverage` attribute input - --> $DIR/malformed-attrs.rs:92:1 + --> $DIR/malformed-attrs.rs:93:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -404,13 +410,13 @@ LL | #[coverage(on)] | ++++ error[E0539]: malformed `sanitize` attribute input - --> $DIR/malformed-attrs.rs:94:1 + --> $DIR/malformed-attrs.rs:95:1 | LL | #[sanitize] | ^^^^^^^^^^^ expected this to be a list error[E0565]: malformed `no_implicit_prelude` attribute input - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:100:1 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^^^----^ @@ -419,7 +425,7 @@ LL | #[no_implicit_prelude = 23] | help: must be of the form: `#[no_implicit_prelude]` error[E0565]: malformed `proc_macro` attribute input - --> $DIR/malformed-attrs.rs:103:1 + --> $DIR/malformed-attrs.rs:104:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^----^ @@ -428,7 +434,7 @@ LL | #[proc_macro = 18] | help: must be of the form: `#[proc_macro]` error[E0539]: malformed `instruction_set` attribute input - --> $DIR/malformed-attrs.rs:110:1 + --> $DIR/malformed-attrs.rs:111:1 | LL | #[instruction_set] | ^^^^^^^^^^^^^^^^^^ @@ -438,17 +444,8 @@ LL | #[instruction_set] | = note: for more information, visit -error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/malformed-attrs.rs:112:1 - | -LL | #[patchable_function_entry] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` - error[E0565]: malformed `coroutine` attribute input - --> $DIR/malformed-attrs.rs:115:5 + --> $DIR/malformed-attrs.rs:116:5 | LL | #[coroutine = 63] || {} | ^^^^^^^^^^^^----^ @@ -457,7 +454,7 @@ LL | #[coroutine = 63] || {} | help: must be of the form: `#[coroutine]` error[E0565]: malformed `proc_macro_attribute` attribute input - --> $DIR/malformed-attrs.rs:120:1 + --> $DIR/malformed-attrs.rs:121:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -466,7 +463,7 @@ LL | #[proc_macro_attribute = 19] | help: must be of the form: `#[proc_macro_attribute]` error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:123:1 + --> $DIR/malformed-attrs.rs:124:1 | LL | #[must_use = 1] | ^^^^^^^^^^^^^-^ @@ -484,7 +481,7 @@ LL + #[must_use] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/malformed-attrs.rs:127:1 + --> $DIR/malformed-attrs.rs:128:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -498,7 +495,7 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input - --> $DIR/malformed-attrs.rs:132:1 + --> $DIR/malformed-attrs.rs:133:1 | LL | #[rustc_layout_scalar_valid_range_start] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +504,7 @@ LL | #[rustc_layout_scalar_valid_range_start] | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input - --> $DIR/malformed-attrs.rs:134:1 + --> $DIR/malformed-attrs.rs:135:1 | LL | #[rustc_layout_scalar_valid_range_end] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -516,7 +513,7 @@ LL | #[rustc_layout_scalar_valid_range_end] | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` error[E0539]: malformed `must_not_suspend` attribute input - --> $DIR/malformed-attrs.rs:136:1 + --> $DIR/malformed-attrs.rs:137:1 | LL | #[must_not_suspend()] | ^^^^^^^^^^^^^^^^^^--^ @@ -532,7 +529,7 @@ LL + #[must_not_suspend] | error[E0539]: malformed `cfi_encoding` attribute input - --> $DIR/malformed-attrs.rs:138:1 + --> $DIR/malformed-attrs.rs:139:1 | LL | #[cfi_encoding = ""] | ^^^^^^^^^^^^^^^^^--^ @@ -541,7 +538,7 @@ LL | #[cfi_encoding = ""] | help: must be of the form: `#[cfi_encoding = "encoding"]` error[E0565]: malformed `marker` attribute input - --> $DIR/malformed-attrs.rs:157:1 + --> $DIR/malformed-attrs.rs:160:1 | LL | #[marker = 3] | ^^^^^^^^^---^ @@ -550,7 +547,7 @@ LL | #[marker = 3] | help: must be of the form: `#[marker]` error[E0565]: malformed `fundamental` attribute input - --> $DIR/malformed-attrs.rs:159:1 + --> $DIR/malformed-attrs.rs:162:1 | LL | #[fundamental()] | ^^^^^^^^^^^^^--^ @@ -559,7 +556,7 @@ LL | #[fundamental()] | help: must be of the form: `#[fundamental]` error[E0565]: malformed `ffi_pure` attribute input - --> $DIR/malformed-attrs.rs:167:5 + --> $DIR/malformed-attrs.rs:170:5 | LL | #[unsafe(ffi_pure = 1)] | ^^^^^^^^^^^^^^^^^^---^^ @@ -568,7 +565,7 @@ LL | #[unsafe(ffi_pure = 1)] | help: must be of the form: `#[ffi_pure]` error[E0539]: malformed `link_ordinal` attribute input - --> $DIR/malformed-attrs.rs:169:5 + --> $DIR/malformed-attrs.rs:172:5 | LL | #[link_ordinal] | ^^^^^^^^^^^^^^^ @@ -579,7 +576,7 @@ LL | #[link_ordinal] = note: for more information, visit error[E0565]: malformed `ffi_const` attribute input - --> $DIR/malformed-attrs.rs:173:5 + --> $DIR/malformed-attrs.rs:176:5 | LL | #[unsafe(ffi_const = 1)] | ^^^^^^^^^^^^^^^^^^^---^^ @@ -588,13 +585,13 @@ LL | #[unsafe(ffi_const = 1)] | help: must be of the form: `#[ffi_const]` error[E0539]: malformed `linkage` attribute input - --> $DIR/malformed-attrs.rs:175:5 + --> $DIR/malformed-attrs.rs:178:5 | LL | #[linkage] | ^^^^^^^^^^ expected this to be of the form `linkage = "..."` error[E0539]: malformed `debugger_visualizer` attribute input - --> $DIR/malformed-attrs.rs:190:1 + --> $DIR/malformed-attrs.rs:193:1 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -605,7 +602,7 @@ LL | #[debugger_visualizer] = note: for more information, visit error[E0565]: malformed `automatically_derived` attribute input - --> $DIR/malformed-attrs.rs:192:1 + --> $DIR/malformed-attrs.rs:195:1 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -614,7 +611,7 @@ LL | #[automatically_derived = 18] | help: must be of the form: `#[automatically_derived]` error[E0565]: malformed `non_exhaustive` attribute input - --> $DIR/malformed-attrs.rs:200:1 + --> $DIR/malformed-attrs.rs:203:1 | LL | #[non_exhaustive = 1] | ^^^^^^^^^^^^^^^^^---^ @@ -623,7 +620,7 @@ LL | #[non_exhaustive = 1] | help: must be of the form: `#[non_exhaustive]` error[E0565]: malformed `thread_local` attribute input - --> $DIR/malformed-attrs.rs:206:1 + --> $DIR/malformed-attrs.rs:209:1 | LL | #[thread_local()] | ^^^^^^^^^^^^^^--^ @@ -632,7 +629,7 @@ LL | #[thread_local()] | help: must be of the form: `#[thread_local]` error[E0565]: malformed `no_link` attribute input - --> $DIR/malformed-attrs.rs:210:1 + --> $DIR/malformed-attrs.rs:213:1 | LL | #[no_link()] | ^^^^^^^^^--^ @@ -641,7 +638,7 @@ LL | #[no_link()] | help: must be of the form: `#[no_link]` error[E0539]: malformed `macro_use` attribute input - --> $DIR/malformed-attrs.rs:212:1 + --> $DIR/malformed-attrs.rs:215:1 | LL | #[macro_use = 1] | ^^^^^^^^^^^^---^ @@ -659,7 +656,7 @@ LL + #[macro_use] | error[E0539]: malformed `macro_export` attribute input - --> $DIR/malformed-attrs.rs:217:1 + --> $DIR/malformed-attrs.rs:220:1 | LL | #[macro_export = 18] | ^^^^^^^^^^^^^^^----^ @@ -676,7 +673,7 @@ LL + #[macro_export] | error[E0565]: malformed `allow_internal_unsafe` attribute input - --> $DIR/malformed-attrs.rs:219:1 + --> $DIR/malformed-attrs.rs:222:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^---^ @@ -684,8 +681,17 @@ LL | #[allow_internal_unsafe = 1] | | didn't expect any arguments here | help: must be of the form: `#[allow_internal_unsafe]` +error[E0565]: malformed `type_const` attribute input + --> $DIR/malformed-attrs.rs:148:5 + | +LL | #[type_const = 1] + | ^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[type_const]` + error: attribute should be applied to `const fn` - --> $DIR/malformed-attrs.rs:31:1 + --> $DIR/malformed-attrs.rs:32:1 | LL | #[rustc_allow_const_fn_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -697,7 +703,7 @@ LL | | } | |_- not a `const fn` warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/malformed-attrs.rs:82:1 + --> $DIR/malformed-attrs.rs:83:1 | LL | #[link] | ^^^^^^^ @@ -712,19 +718,19 @@ LL | | } = note: requested on the command line with `-W unused-attributes` error: `#[repr(align(...))]` is not supported on functions - --> $DIR/malformed-attrs.rs:46:1 + --> $DIR/malformed-attrs.rs:47:1 | LL | #[repr] | ^^^^^^^ | help: use `#[rustc_align(...)]` instead - --> $DIR/malformed-attrs.rs:46:1 + --> $DIR/malformed-attrs.rs:47:1 | LL | #[repr] | ^^^^^^^ warning: missing options for `on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:142:1 + --> $DIR/malformed-attrs.rs:143:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -733,7 +739,7 @@ LL | #[diagnostic::on_unimplemented] = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default warning: malformed `on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:144:1 + --> $DIR/malformed-attrs.rs:145:1 | LL | #[diagnostic::on_unimplemented = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here @@ -741,7 +747,7 @@ LL | #[diagnostic::on_unimplemented = 1] = help: only `message`, `note` and `label` are allowed as options error: valid forms for the attribute are `#[doc = "string"]`, `#[doc(alias)]`, `#[doc(attribute)]`, `#[doc(auto_cfg)]`, `#[doc(cfg)]`, `#[doc(fake_variadic)]`, `#[doc(hidden)]`, `#[doc(html_favicon_url)]`, `#[doc(html_logo_url)]`, `#[doc(html_no_source)]`, `#[doc(html_playground_url)]`, `#[doc(html_root_url)]`, `#[doc(include)]`, `#[doc(inline)]`, `#[doc(issue_tracker_base_url)]`, `#[doc(keyword)]`, `#[doc(masked)]`, `#[doc(no_default_passes)]`, `#[doc(no_inline)]`, `#[doc(notable_trait)]`, `#[doc(passes)]`, `#[doc(plugins)]`, `#[doc(rust_logo)]`, `#[doc(search_unbox)]`, `#[doc(spotlight)]`, and `#[doc(test)]` - --> $DIR/malformed-attrs.rs:41:1 + --> $DIR/malformed-attrs.rs:42:1 | LL | #[doc] | ^^^^^^ @@ -753,7 +759,7 @@ LL | #![deny(invalid_doc_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^ error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` - --> $DIR/malformed-attrs.rs:51:1 + --> $DIR/malformed-attrs.rs:52:1 | LL | #[inline = 5] | ^^^^^^^^^^^^^ @@ -763,13 +769,13 @@ LL | #[inline = 5] = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/malformed-attrs.rs:73:1 + --> $DIR/malformed-attrs.rs:74:1 | LL | #[crate_name] | ^^^^^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this function - --> $DIR/malformed-attrs.rs:114:1 +note: This attribute does not have an `!`, which means it is applied to this function + --> $DIR/malformed-attrs.rs:115:1 | LL | / fn test() { LL | | #[coroutine = 63] || {} @@ -778,13 +784,13 @@ LL | | } | |_^ error: valid forms for the attribute are `#[doc = "string"]`, `#[doc(alias)]`, `#[doc(attribute)]`, `#[doc(auto_cfg)]`, `#[doc(cfg)]`, `#[doc(fake_variadic)]`, `#[doc(hidden)]`, `#[doc(html_favicon_url)]`, `#[doc(html_logo_url)]`, `#[doc(html_no_source)]`, `#[doc(html_playground_url)]`, `#[doc(html_root_url)]`, `#[doc(include)]`, `#[doc(inline)]`, `#[doc(issue_tracker_base_url)]`, `#[doc(keyword)]`, `#[doc(masked)]`, `#[doc(no_default_passes)]`, `#[doc(no_inline)]`, `#[doc(notable_trait)]`, `#[doc(passes)]`, `#[doc(plugins)]`, `#[doc(rust_logo)]`, `#[doc(search_unbox)]`, `#[doc(spotlight)]`, and `#[doc(test)]` - --> $DIR/malformed-attrs.rs:76:1 + --> $DIR/malformed-attrs.rs:77:1 | LL | #[doc] | ^^^^^^ warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:86:1 + --> $DIR/malformed-attrs.rs:87:1 | LL | #[link_name] | ^^^^^^^^^^^^ @@ -793,7 +799,7 @@ LL | #[link_name] = help: `#[link_name]` can be applied to foreign functions and foreign statics error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:96:1 + --> $DIR/malformed-attrs.rs:97:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -802,7 +808,7 @@ LL | #[ignore()] = note: for more information, see issue #57571 warning: `#[no_implicit_prelude]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:100:1 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -811,13 +817,13 @@ LL | #[no_implicit_prelude = 23] = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[diagnostic::do_not_recommend]` does not expect any arguments - --> $DIR/malformed-attrs.rs:151:1 + --> $DIR/malformed-attrs.rs:154:1 | LL | #[diagnostic::do_not_recommend()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/malformed-attrs.rs:192:1 + --> $DIR/malformed-attrs.rs:195:1 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -826,7 +832,7 @@ LL | #[automatically_derived = 18] = help: `#[automatically_derived]` can only be applied to trait impl blocks error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:226:1 + --> $DIR/malformed-attrs.rs:229:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ @@ -835,7 +841,7 @@ LL | #[ignore = 1] = note: for more information, see issue #57571 error[E0308]: mismatched types - --> $DIR/malformed-attrs.rs:115:23 + --> $DIR/malformed-attrs.rs:116:23 | LL | fn test() { | - help: a return type might be missing here: `-> _` @@ -843,15 +849,15 @@ LL | #[coroutine = 63] || {} | ^^^^^ expected `()`, found coroutine | = note: expected unit type `()` - found coroutine `{coroutine@$DIR/malformed-attrs.rs:115:23: 115:25}` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:116:23: 116:25}` -error: aborting due to 75 previous errors; 8 warnings emitted +error: aborting due to 76 previous errors; 8 warnings emitted Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805. For more information about an error, try `rustc --explain E0308`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` - --> $DIR/malformed-attrs.rs:51:1 + --> $DIR/malformed-attrs.rs:52:1 | LL | #[inline = 5] | ^^^^^^^^^^^^^ @@ -862,7 +868,7 @@ LL | #[inline = 5] Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:96:1 + --> $DIR/malformed-attrs.rs:97:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -873,7 +879,7 @@ LL | #[ignore()] Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:226:1 + --> $DIR/malformed-attrs.rs:229:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ diff --git a/tests/ui/attributes/malformed-never-type-options.rs b/tests/ui/attributes/malformed-never-type-options.rs index 7dd7a854ed2e..0c384be0e226 100644 --- a/tests/ui/attributes/malformed-never-type-options.rs +++ b/tests/ui/attributes/malformed-never-type-options.rs @@ -2,7 +2,7 @@ //! The `rustc_*` attribute is malformed, but ICEing without a `feature(rustc_attrs)` is still bad. #![rustc_never_type_options(: Unsize = "hi")] -//~^ ERROR expected a literal +//~^ ERROR expected unsuffixed literal, found `:` //~| ERROR use of an internal attribute fn main() {} diff --git a/tests/ui/attributes/malformed-never-type-options.stderr b/tests/ui/attributes/malformed-never-type-options.stderr index 98870c8bdded..0d2ff4881f2a 100644 --- a/tests/ui/attributes/malformed-never-type-options.stderr +++ b/tests/ui/attributes/malformed-never-type-options.stderr @@ -1,3 +1,9 @@ +error: expected unsuffixed literal, found `:` + --> $DIR/malformed-never-type-options.rs:4:29 + | +LL | #![rustc_never_type_options(: Unsize = "hi")] + | ^ + error[E0658]: use of an internal attribute --> $DIR/malformed-never-type-options.rs:4:1 | @@ -8,12 +14,6 @@ LL | #![rustc_never_type_options(: Unsize = "hi")] = note: the `#[rustc_never_type_options]` attribute is an internal implementation detail that will never be stable = note: `rustc_never_type_options` is used to experiment with never type fallback and work on never type stabilization -error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `:` - --> $DIR/malformed-never-type-options.rs:4:29 - | -LL | #![rustc_never_type_options(: Unsize = "hi")] - | ^ - error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/attributes/malformed-no-std.stderr b/tests/ui/attributes/malformed-no-std.stderr index e994e28e030f..89d7ee410d70 100644 --- a/tests/ui/attributes/malformed-no-std.stderr +++ b/tests/ui/attributes/malformed-no-std.stderr @@ -58,7 +58,7 @@ error: crate-level attribute should be an inner attribute: add an exclamation ma LL | #[no_std] | ^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this extern crate +note: This attribute does not have an `!`, which means it is applied to this extern crate --> $DIR/malformed-no-std.rs:26:1 | LL | extern crate core; @@ -75,7 +75,7 @@ error: crate-level attribute should be an inner attribute: add an exclamation ma LL | #[no_core] | ^^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this extern crate +note: This attribute does not have an `!`, which means it is applied to this extern crate --> $DIR/malformed-no-std.rs:26:1 | LL | extern crate core; diff --git a/tests/ui/attributes/use-doc-alias-name.rs b/tests/ui/attributes/use-doc-alias-name.rs index 4d27249b89a7..1fc9199b6e38 100644 --- a/tests/ui/attributes/use-doc-alias-name.rs +++ b/tests/ui/attributes/use-doc-alias-name.rs @@ -42,7 +42,7 @@ fn main() { //~| HELP: `S5` has a name defined in the doc alias attribute as `DocAliasS5` not_exist_module::DocAliasS1; - //~^ ERROR: cannot find module or crate `not_exist_module` + //~^ ERROR: use of unresolved module or unlinked crate `not_exist_module` //~| HELP: you might be missing a crate named `not_exist_module` use_doc_alias_name_extern::DocAliasS1; @@ -50,7 +50,7 @@ fn main() { //~| HELP: `S1` has a name defined in the doc alias attribute as `DocAliasS1` m::n::DocAliasX::y::S6; - //~^ ERROR: cannot find `DocAliasX` in `n` + //~^ ERROR: could not find `DocAliasX` in `n` //~| HELP: `x` has a name defined in the doc alias attribute as `DocAliasX` m::n::x::y::DocAliasS6; diff --git a/tests/ui/attributes/use-doc-alias-name.stderr b/tests/ui/attributes/use-doc-alias-name.stderr index 3b4a0a919b17..07f4865e4152 100644 --- a/tests/ui/attributes/use-doc-alias-name.stderr +++ b/tests/ui/attributes/use-doc-alias-name.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `DocAliasX` in `n` +error[E0433]: failed to resolve: could not find `DocAliasX` in `n` --> $DIR/use-doc-alias-name.rs:52:11 | LL | m::n::DocAliasX::y::S6; @@ -136,7 +136,7 @@ LL - doc_alias_f2(); LL + f(); | -error[E0433]: cannot find module or crate `not_exist_module` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `not_exist_module` --> $DIR/use-doc-alias-name.rs:44:5 | LL | not_exist_module::DocAliasS1; diff --git a/tests/ui/auto-traits/assoc-ty.current.stderr b/tests/ui/auto-traits/assoc-ty.current.stderr index 5d3df17d26b1..d793ae665267 100644 --- a/tests/ui/auto-traits/assoc-ty.current.stderr +++ b/tests/ui/auto-traits/assoc-ty.current.stderr @@ -1,9 +1,9 @@ error[E0380]: auto traits cannot have associated items - --> $DIR/assoc-ty.rs:11:10 + --> $DIR/assoc-ty.rs:10:10 | LL | auto trait Trait { | ----- auto traits cannot have associated items -... +LL | LL | type Output; | ^^^^^^ @@ -12,9 +12,8 @@ error[E0658]: auto traits are experimental and possibly buggy | LL | / auto trait Trait { LL | | -LL | | LL | | type Output; -... | +LL | | LL | | } | |_^ | @@ -23,7 +22,7 @@ LL | | } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0308]: mismatched types - --> $DIR/assoc-ty.rs:17:36 + --> $DIR/assoc-ty.rs:15:36 | LL | let _: <() as Trait>::Output = (); | --------------------- ^^ expected associated type, found `()` diff --git a/tests/ui/auto-traits/assoc-ty.next.stderr b/tests/ui/auto-traits/assoc-ty.next.stderr index 19621064aa42..a41f7d992785 100644 --- a/tests/ui/auto-traits/assoc-ty.next.stderr +++ b/tests/ui/auto-traits/assoc-ty.next.stderr @@ -1,9 +1,9 @@ error[E0380]: auto traits cannot have associated items - --> $DIR/assoc-ty.rs:11:10 + --> $DIR/assoc-ty.rs:10:10 | LL | auto trait Trait { | ----- auto traits cannot have associated items -... +LL | LL | type Output; | ^^^^^^ @@ -12,9 +12,8 @@ error[E0658]: auto traits are experimental and possibly buggy | LL | / auto trait Trait { LL | | -LL | | LL | | type Output; -... | +LL | | LL | | } | |_^ | @@ -23,13 +22,13 @@ LL | | } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0271]: type mismatch resolving `<() as Trait>::Output normalizes-to _` - --> $DIR/assoc-ty.rs:17:12 + --> $DIR/assoc-ty.rs:15:12 | LL | let _: <() as Trait>::Output = (); | ^^^^^^^^^^^^^^^^^^^^^ types differ error[E0271]: type mismatch resolving `<() as Trait>::Output normalizes-to _` - --> $DIR/assoc-ty.rs:17:12 + --> $DIR/assoc-ty.rs:15:12 | LL | let _: <() as Trait>::Output = (); | ^^^^^^^^^^^^^^^^^^^^^ types differ diff --git a/tests/ui/auto-traits/assoc-ty.rs b/tests/ui/auto-traits/assoc-ty.rs index 98a86d9a7540..efbfead9cd03 100644 --- a/tests/ui/auto-traits/assoc-ty.rs +++ b/tests/ui/auto-traits/assoc-ty.rs @@ -7,16 +7,13 @@ auto trait Trait { //~^ ERROR auto traits are experimental and possibly buggy - //~| HELP add `#![feature(auto_traits)]` to the crate attributes to enable type Output; //~^ ERROR auto traits cannot have associated items - //~| HELP remove the associated items } fn main() { let _: <() as Trait>::Output = (); //[current]~^ ERROR mismatched types - //[current]~| HELP consider constraining the associated type `<() as Trait>::Output` to `()` or calling a method that returns `<() as Trait>::Output` - //[next]~^^^ ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _` + //[next]~^^ ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _` //[next]~| ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _` } diff --git a/tests/ui/autodiff/incremental.rs b/tests/ui/autodiff/incremental.rs index 00dd632712ab..a79059deaa77 100644 --- a/tests/ui/autodiff/incremental.rs +++ b/tests/ui/autodiff/incremental.rs @@ -1,6 +1,6 @@ //@ revisions: DEBUG RELEASE //@[RELEASE] compile-flags: -Zautodiff=Enable,NoTT -C opt-level=3 -Clto=fat -//@[DEBUG] compile-flags: -Zautodiff=Enable,NoTT -Copt-level=0 -Clto=fat -Cdebuginfo=2 -Ccodegen-units=8 +//@[DEBUG] compile-flags: -Zautodiff=Enable,NoTT -C opt-level=0 -Clto=fat -C debuginfo=2 //@ needs-enzyme //@ incremental //@ no-prefer-dynamic @@ -13,10 +13,6 @@ // dropped. We now use globals instead and add this test to verify that incremental // keeps working. Also testing debug mode while at it. -// We extended this test to use 8 codegen-units in debug mode and call an intrinsic like powi, -// rather than just simple arithmetic. This caused a compilation failure, since the definition of -// the intrinsic was not available in the same cgu as the function being differentiated. - use std::autodiff::autodiff_reverse; #[autodiff_reverse(bar, Duplicated, Duplicated)] @@ -24,7 +20,7 @@ pub fn foo(r: &[f64; 10], res: &mut f64) { let mut output = [0.0; 10]; output[0] = r[0]; output[1] = r[1] * r[2]; - output[2] = r[4] * r[5].powi(2); + output[2] = r[4] * r[5]; output[3] = r[2] * r[6]; output[4] = r[1] * r[7]; output[5] = r[2] * r[8]; diff --git a/tests/ui/binop/binary-operation-error-on-function-70724.stderr b/tests/ui/binop/binary-operation-error-on-function-70724.stderr index 2eb980764a39..11b0e4ba19c5 100644 --- a/tests/ui/binop/binary-operation-error-on-function-70724.stderr +++ b/tests/ui/binop/binary-operation-error-on-function-70724.stderr @@ -6,6 +6,8 @@ LL | assert_eq!(a, 0); | | | fn() -> i32 {a} | {integer} + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/binary-operation-error-on-function-70724.rs:7:5 @@ -15,6 +17,7 @@ LL | assert_eq!(a, 0); | = note: expected fn item `fn() -> i32 {a}` found type `{integer}` + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn() -> i32 {a}` doesn't implement `Debug` --> $DIR/binary-operation-error-on-function-70724.rs:7:5 @@ -26,6 +29,7 @@ LL | assert_eq!(a, 0); | ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn() -> i32 {a}` | = help: use parentheses to call this function: `a()` + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/binop/eq-vec.stderr b/tests/ui/binop/eq-vec.stderr index 158bfe625934..14739752877c 100644 --- a/tests/ui/binop/eq-vec.stderr +++ b/tests/ui/binop/eq-vec.stderr @@ -12,6 +12,7 @@ note: an implementation of `PartialEq` might be missing for `Foo` | LL | enum Foo { | ^^^^^^^^ must implement `PartialEq` + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Foo` with `#[derive(PartialEq)]` | LL + #[derive(PartialEq)] diff --git a/tests/ui/binop/function-comparison-errors-59488.stderr b/tests/ui/binop/function-comparison-errors-59488.stderr index 43ecd6a36f38..615458bc45b4 100644 --- a/tests/ui/binop/function-comparison-errors-59488.stderr +++ b/tests/ui/binop/function-comparison-errors-59488.stderr @@ -80,18 +80,24 @@ LL | assert_eq!(Foo::Bar, i); | | | fn(usize) -> Foo {Foo::Bar} | fn(usize) -> Foo {Foo::Bar} + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` --> $DIR/function-comparison-errors-59488.rs:31:5 | LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` --> $DIR/function-comparison-errors-59488.rs:31:5 | LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/binop/issue-77910-1.stderr b/tests/ui/binop/issue-77910-1.stderr index 9503813f4eb8..80c384f39bd1 100644 --- a/tests/ui/binop/issue-77910-1.stderr +++ b/tests/ui/binop/issue-77910-1.stderr @@ -6,6 +6,8 @@ LL | assert_eq!(foo, y); | | | for<'a> fn(&'a i32) -> &'a i32 {foo} | _ + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `for<'a> fn(&'a i32) -> &'a i32 {foo}` doesn't implement `Debug` --> $DIR/issue-77910-1.rs:8:5 @@ -17,6 +19,7 @@ LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}` | = help: use parentheses to call this function: `foo(/* &i32 */)` + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0381]: used binding `xs` isn't initialized --> $DIR/issue-77910-1.rs:3:5 diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr index c82821b04a35..b5c2b662f315 100644 --- a/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr +++ b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr @@ -8,6 +8,8 @@ LL | test(&vec![]) | argument requires that borrow lasts for `'static` LL | } | - temporary value is freed at the end of this statement + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-and-init.stderr b/tests/ui/borrowck/borrowck-and-init.stderr index e6d49bc6e471..37386f1c4651 100644 --- a/tests/ui/borrowck/borrowck-and-init.stderr +++ b/tests/ui/borrowck/borrowck-and-init.stderr @@ -8,6 +8,8 @@ LL | println!("{}", false && { i = 5; true }); | ----- binding initialized here in some conditions LL | println!("{}", i); | ^ `i` used here but it is possibly-uninitialized + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr index 9fd4ee9b99ba..7f0ecf7b3596 100644 --- a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr +++ b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr @@ -8,6 +8,7 @@ LL | let x = defer(&vec!["Goodbye", "world!"]); LL | x.x[0]; | ------ borrow later used here | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider using a `let` binding to create a longer lived value | LL ~ let binding = vec!["Goodbye", "world!"]; diff --git a/tests/ui/borrowck/borrowck-break-uninit-2.stderr b/tests/ui/borrowck/borrowck-break-uninit-2.stderr index 03730e338ee0..e23ca534e745 100644 --- a/tests/ui/borrowck/borrowck-break-uninit-2.stderr +++ b/tests/ui/borrowck/borrowck-break-uninit-2.stderr @@ -7,6 +7,7 @@ LL | let x: isize; LL | println!("{}", x); | ^ `x` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: isize = 42; diff --git a/tests/ui/borrowck/borrowck-break-uninit.stderr b/tests/ui/borrowck/borrowck-break-uninit.stderr index 6ed095f2e4a3..0367d224f801 100644 --- a/tests/ui/borrowck/borrowck-break-uninit.stderr +++ b/tests/ui/borrowck/borrowck-break-uninit.stderr @@ -7,6 +7,7 @@ LL | let x: isize; LL | println!("{}", x); | ^ `x` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: isize = 42; diff --git a/tests/ui/borrowck/borrowck-or-init.stderr b/tests/ui/borrowck/borrowck-or-init.stderr index 63c0c982351b..7b43f2aee30e 100644 --- a/tests/ui/borrowck/borrowck-or-init.stderr +++ b/tests/ui/borrowck/borrowck-or-init.stderr @@ -8,6 +8,8 @@ LL | println!("{}", false || { i = 5; true }); | ----- binding initialized here in some conditions LL | println!("{}", i); | ^ `i` used here but it is possibly-uninitialized + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-while-break.stderr b/tests/ui/borrowck/borrowck-while-break.stderr index 68333ce0a75d..e91af728b649 100644 --- a/tests/ui/borrowck/borrowck-while-break.stderr +++ b/tests/ui/borrowck/borrowck-while-break.stderr @@ -8,6 +8,8 @@ LL | while cond { ... LL | println!("{}", v); | ^ `v` used here but it is possibly-uninitialized + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/derive-clone-implicit-bound.rs b/tests/ui/borrowck/derive-clone-implicit-bound.rs deleted file mode 100644 index cd92ac1e9e59..000000000000 --- a/tests/ui/borrowck/derive-clone-implicit-bound.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Issue #108894 - -use std::marker::PhantomData; - -#[derive(Clone, Copy)] //~ NOTE: derived `Clone` adds implicit bounds on type parameters -pub struct TypedAddress{ -//~^ NOTE: if all bounds were met, you could clone the value -//~| NOTE: introduces an implicit `T: Clone` bound - inner: u64, - phantom: PhantomData, -} - -pub trait Memory { - fn write_value(&self, offset: TypedAddress, value: &T); - fn return_value(&self, offset: TypedAddress) -> T; - //~^ NOTE: consider changing this parameter type in method `return_value` to borrow instead if owning the value isn't necessary - //~| NOTE: in this method - //~| NOTE: this parameter takes ownership of the value - fn update_value(&self, offset: TypedAddress, update: F) - //~^ NOTE: move occurs because `offset` has type `TypedAddress`, which does not implement the `Copy` trait - where F: FnOnce(T) -> T //~ HELP: consider further restricting type parameter `T` - { - let old = self.return_value(offset); //~ NOTE: value moved here - //~^ NOTE: you could clone this value - let new = update(old); - self.write_value(offset, &new); //~ ERROR: use of moved value: `offset` - //~^ NOTE: value used here after move - //~| HELP: consider manually implementing `Clone` to avoid undesired bounds - } -} - -fn main() {} diff --git a/tests/ui/borrowck/derive-clone-implicit-bound.stderr b/tests/ui/borrowck/derive-clone-implicit-bound.stderr deleted file mode 100644 index 246fd1eaf075..000000000000 --- a/tests/ui/borrowck/derive-clone-implicit-bound.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0382]: use of moved value: `offset` - --> $DIR/derive-clone-implicit-bound.rs:26:26 - | -LL | fn update_value(&self, offset: TypedAddress, update: F) - | ------ move occurs because `offset` has type `TypedAddress`, which does not implement the `Copy` trait -... -LL | let old = self.return_value(offset); - | ------ value moved here -... -LL | self.write_value(offset, &new); - | ^^^^^^ value used here after move - | -note: consider changing this parameter type in method `return_value` to borrow instead if owning the value isn't necessary - --> $DIR/derive-clone-implicit-bound.rs:15:39 - | -LL | fn return_value(&self, offset: TypedAddress) -> T; - | ------------ in this method ^^^^^^^^^^^^^^^ this parameter takes ownership of the value -note: if all bounds were met, you could clone the value - --> $DIR/derive-clone-implicit-bound.rs:6:1 - | -LL | #[derive(Clone, Copy)] - | ----- derived `Clone` adds implicit bounds on type parameters -LL | pub struct TypedAddress{ - | ^^^^^^^^^^^^^^^^^^^^^^^^-^ - | | - | introduces an implicit `T: Clone` bound -... -LL | let old = self.return_value(offset); - | ------ you could clone this value - = help: consider manually implementing `Clone` to avoid undesired bounds -help: consider further restricting type parameter `T` with trait `Copy` - | -LL | where F: FnOnce(T) -> T, T: Copy - | +++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/borrowck/fsu-moves-and-copies.rs b/tests/ui/borrowck/fsu-moves-and-copies.rs index 6576fb51a5d2..397e4199bc05 100644 --- a/tests/ui/borrowck/fsu-moves-and-copies.rs +++ b/tests/ui/borrowck/fsu-moves-and-copies.rs @@ -1,9 +1,11 @@ //@ run-pass #![allow(non_camel_case_types)] +#![allow(stable_features)] // Issue 4691: Ensure that functional-struct-updates operates // correctly and moves rather than copy when appropriate. +#![feature(core)] struct ncint { v: isize } fn ncint(v: isize) -> ncint { ncint { v: v } } diff --git a/tests/ui/borrowck/issue-24267-flow-exit.stderr b/tests/ui/borrowck/issue-24267-flow-exit.stderr index e81f00f8c157..216f8d49b1b0 100644 --- a/tests/ui/borrowck/issue-24267-flow-exit.stderr +++ b/tests/ui/borrowck/issue-24267-flow-exit.stderr @@ -7,6 +7,7 @@ LL | loop { x = break; } LL | println!("{}", x); | ^ `x` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: i32 = 42; @@ -21,6 +22,7 @@ LL | for _ in 0..10 { x = continue; } LL | println!("{}", x); | ^ `x` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: i32 = 42; diff --git a/tests/ui/borrowck/issue-47646.stderr b/tests/ui/borrowck/issue-47646.stderr index c8d48b76757a..cfe6f3f39938 100644 --- a/tests/ui/borrowck/issue-47646.stderr +++ b/tests/ui/borrowck/issue-47646.stderr @@ -12,6 +12,8 @@ LL | println!("{:?}", heap); ... LL | }; | - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option>, ())` + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index 9136d6a7dc33..29a7363705cd 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -8,6 +8,7 @@ note: function `format` is not const --> $SRC_DIR/alloc/src/fmt.rs:LL:COL = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0507]: cannot move out of static item `settings_dir` --> $DIR/issue-64453.rs:13:37 diff --git a/tests/ui/borrowck/mut-borrow-of-mut-ref.fixed b/tests/ui/borrowck/mut-borrow-of-mut-ref.fixed deleted file mode 100644 index f70983c65223..000000000000 --- a/tests/ui/borrowck/mut-borrow-of-mut-ref.fixed +++ /dev/null @@ -1,37 +0,0 @@ -// Suggest not mutably borrowing a mutable reference -//@ run-rustfix -#![crate_type = "rlib"] - -pub fn f(mut b: &mut i32) { - //~^ ERROR: cannot borrow - //~| NOTE: not mutable - //~| NOTE: the binding is already a mutable borrow - //~| HELP: consider making the binding mutable if you need to reborrow multiple times - h(b); - //~^ NOTE: cannot borrow as mutable - //~| HELP: if there is only one mutable reborrow, remove the `&mut` - g(&mut &mut b); - //~^ NOTE: cannot borrow as mutable -} - -pub fn g(mut b: &mut i32) { //~ NOTE: the binding is already a mutable borrow - //~^ HELP: consider making the binding mutable if you need to reborrow multiple times - h(&mut &mut b); - //~^ ERROR: cannot borrow - //~| NOTE: cannot borrow as mutable -} - -pub fn h(_: &mut i32) {} - -trait Foo { - fn bar(&mut self); -} - -impl Foo for &mut String { - fn bar(&mut self) {} -} - -pub fn baz(mut f: &mut String) { //~ HELP consider making the binding mutable - f.bar(); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable - //~^ NOTE cannot borrow as mutable -} diff --git a/tests/ui/borrowck/mut-borrow-of-mut-ref.rs b/tests/ui/borrowck/mut-borrow-of-mut-ref.rs index d150b249bf2d..33954592bf65 100644 --- a/tests/ui/borrowck/mut-borrow-of-mut-ref.rs +++ b/tests/ui/borrowck/mut-borrow-of-mut-ref.rs @@ -1,5 +1,4 @@ // Suggest not mutably borrowing a mutable reference -//@ run-rustfix #![crate_type = "rlib"] pub fn f(b: &mut i32) { @@ -12,6 +11,7 @@ pub fn f(b: &mut i32) { //~| HELP: if there is only one mutable reborrow, remove the `&mut` g(&mut &mut b); //~^ NOTE: cannot borrow as mutable + //~| HELP: if there is only one mutable reborrow, remove the `&mut` } pub fn g(b: &mut i32) { //~ NOTE: the binding is already a mutable borrow @@ -19,6 +19,7 @@ pub fn g(b: &mut i32) { //~ NOTE: the binding is already a mutable borrow h(&mut &mut b); //~^ ERROR: cannot borrow //~| NOTE: cannot borrow as mutable + //~| HELP: if there is only one mutable reborrow, remove the `&mut` } pub fn h(_: &mut i32) {} diff --git a/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr b/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr index 01ceba90c943..4c4a5e718393 100644 --- a/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr +++ b/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable - --> $DIR/mut-borrow-of-mut-ref.rs:5:10 + --> $DIR/mut-borrow-of-mut-ref.rs:4:10 | LL | pub fn f(b: &mut i32) { | ^ not mutable @@ -11,7 +11,7 @@ LL | g(&mut &mut b); | ------ cannot borrow as mutable | note: the binding is already a mutable borrow - --> $DIR/mut-borrow-of-mut-ref.rs:5:13 + --> $DIR/mut-borrow-of-mut-ref.rs:4:13 | LL | pub fn f(b: &mut i32) { | ^^^^^^^^ @@ -24,6 +24,11 @@ help: if there is only one mutable reborrow, remove the `&mut` LL - h(&mut b); LL + h(b); | +help: if there is only one mutable reborrow, remove the `&mut` + | +LL - g(&mut &mut b); +LL + g(&mut b); + | error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable --> $DIR/mut-borrow-of-mut-ref.rs:19:12 @@ -40,9 +45,14 @@ help: consider making the binding mutable if you need to reborrow multiple times | LL | pub fn g(mut b: &mut i32) { | +++ +help: if there is only one mutable reborrow, remove the `&mut` + | +LL - h(&mut &mut b); +LL + h(&mut b); + | error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable - --> $DIR/mut-borrow-of-mut-ref.rs:35:5 + --> $DIR/mut-borrow-of-mut-ref.rs:36:5 | LL | f.bar(); | ^ cannot borrow as mutable diff --git a/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.rs b/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.rs index 48466af50481..cf927e34fb41 100644 --- a/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.rs +++ b/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.rs @@ -4,9 +4,9 @@ fn main() { let mut a = E::StructVar { boxed: Box::new(5_i32) }; - //~^ ERROR cannot find type `E` + //~^ ERROR failed to resolve: use of undeclared type `E` match a { E::StructVar { box boxed } => { } - //~^ ERROR cannot find type `E` + //~^ ERROR failed to resolve: use of undeclared type `E` } } diff --git a/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr b/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr index 7be9ed27db0e..ae5c67eae9a6 100644 --- a/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr +++ b/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `E` in this scope +error[E0433]: failed to resolve: use of undeclared type `E` --> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:6:17 | LL | let mut a = E::StructVar { boxed: Box::new(5_i32) }; @@ -9,7 +9,7 @@ help: a trait with a similar name exists LL | let mut a = Eq::StructVar { boxed: Box::new(5_i32) }; | + -error[E0433]: cannot find type `E` in this scope +error[E0433]: failed to resolve: use of undeclared type `E` --> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:9:9 | LL | E::StructVar { box boxed } => { } diff --git a/tests/ui/borrowck/ownership-struct-update-moved-error.stderr b/tests/ui/borrowck/ownership-struct-update-moved-error.stderr index f081bea76b7a..83cfc7bb412c 100644 --- a/tests/ui/borrowck/ownership-struct-update-moved-error.stderr +++ b/tests/ui/borrowck/ownership-struct-update-moved-error.stderr @@ -13,6 +13,7 @@ note: `Mine::make_string_bar` takes ownership of the receiver `self`, which move | LL | fn make_string_bar(mut self) -> Mine { | ^^^^ + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/reborrow-in-match-suggest-deref.fixed b/tests/ui/borrowck/reborrow-in-match-suggest-deref.fixed deleted file mode 100644 index 3f52e57a804c..000000000000 --- a/tests/ui/borrowck/reborrow-in-match-suggest-deref.fixed +++ /dev/null @@ -1,23 +0,0 @@ -// Regression test for #81059. -// edition:2024 -//@ run-rustfix - -#![allow(unused)] - -fn test(mut outer: &mut Option) { - //~^ NOTE: the binding is already a mutable borrow - //~| HELP: consider making the binding mutable if you need to reborrow multiple times - match (&mut *outer, 23) { - //~^ ERROR: cannot borrow `outer` as mutable, as it is not declared as mutable - //~| NOTE: cannot borrow as mutable - //~| HELP: to reborrow the mutable reference, add `*` - (Some(inner), _) => { - *inner = 17; - } - _ => { - *outer = Some(2); - } - } -} - -fn main() {} diff --git a/tests/ui/borrowck/reborrow-in-match-suggest-deref.rs b/tests/ui/borrowck/reborrow-in-match-suggest-deref.rs deleted file mode 100644 index 34c299f4f7b1..000000000000 --- a/tests/ui/borrowck/reborrow-in-match-suggest-deref.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Regression test for #81059. -// edition:2024 -//@ run-rustfix - -#![allow(unused)] - -fn test(outer: &mut Option) { - //~^ NOTE: the binding is already a mutable borrow - //~| HELP: consider making the binding mutable if you need to reborrow multiple times - match (&mut outer, 23) { - //~^ ERROR: cannot borrow `outer` as mutable, as it is not declared as mutable - //~| NOTE: cannot borrow as mutable - //~| HELP: to reborrow the mutable reference, add `*` - (Some(inner), _) => { - *inner = 17; - } - _ => { - *outer = Some(2); - } - } -} - -fn main() {} diff --git a/tests/ui/borrowck/reborrow-in-match-suggest-deref.stderr b/tests/ui/borrowck/reborrow-in-match-suggest-deref.stderr deleted file mode 100644 index db3129461518..000000000000 --- a/tests/ui/borrowck/reborrow-in-match-suggest-deref.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0596]: cannot borrow `outer` as mutable, as it is not declared as mutable - --> $DIR/reborrow-in-match-suggest-deref.rs:10:12 - | -LL | match (&mut outer, 23) { - | ^^^^^^^^^^ cannot borrow as mutable - | -note: the binding is already a mutable borrow - --> $DIR/reborrow-in-match-suggest-deref.rs:7:16 - | -LL | fn test(outer: &mut Option) { - | ^^^^^^^^^^^^^^^^ -help: consider making the binding mutable if you need to reborrow multiple times - | -LL | fn test(mut outer: &mut Option) { - | +++ -help: to reborrow the mutable reference, add `*` - | -LL | match (&mut *outer, 23) { - | + - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/borrowck/suggest-assign-rvalue.stderr b/tests/ui/borrowck/suggest-assign-rvalue.stderr index 6ae893915aa9..daaef6e3892d 100644 --- a/tests/ui/borrowck/suggest-assign-rvalue.stderr +++ b/tests/ui/borrowck/suggest-assign-rvalue.stderr @@ -19,6 +19,7 @@ LL | let my_float: f32; LL | println!("my_float: {}", my_float); | ^^^^^^^^ `my_float` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let my_float: f32 = 3.14159; @@ -32,6 +33,7 @@ LL | let demo: Demo; LL | println!("demo: {:?}", demo); | ^^^^ `demo` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let demo: Demo = Default::default(); @@ -45,6 +47,7 @@ LL | let demo_no: DemoNoDef; LL | println!("demo_no: {:?}", demo_no); | ^^^^^^^ `demo_no` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let demo_no: DemoNoDef = /* value */; @@ -58,6 +61,7 @@ LL | let arr: [i32; 5]; LL | println!("arr: {:?}", arr); | ^^^ `arr` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let arr: [i32; 5] = [42; 5]; @@ -71,6 +75,7 @@ LL | let foo: Vec<&str>; LL | println!("foo: {:?}", foo); | ^^^ `foo` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let foo: Vec<&str> = vec![]; @@ -84,6 +89,7 @@ LL | let my_string: String; LL | println!("my_string: {}", my_string); | ^^^^^^^^^ `my_string` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let my_string: String = Default::default(); @@ -97,6 +103,7 @@ LL | let my_int: &i32; LL | println!("my_int: {}", *my_int); | ^^^^^^^ `*my_int` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let my_int: &i32 = &42; @@ -110,6 +117,7 @@ LL | let hello: &str; LL | println!("hello: {}", hello); | ^^^^^ `hello` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let hello: &str = ""; @@ -122,6 +130,8 @@ LL | let never: !; | ----- binding declared here but left uninitialized LL | println!("never: {}", never); | ^^^^^ `never` used here but it isn't initialized + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/collections/btreemap/btreemap-index-mut-2.rs b/tests/ui/btreemap/btreemap-index-mut-2.rs similarity index 100% rename from tests/ui/collections/btreemap/btreemap-index-mut-2.rs rename to tests/ui/btreemap/btreemap-index-mut-2.rs diff --git a/tests/ui/collections/btreemap/btreemap-index-mut-2.stderr b/tests/ui/btreemap/btreemap-index-mut-2.stderr similarity index 100% rename from tests/ui/collections/btreemap/btreemap-index-mut-2.stderr rename to tests/ui/btreemap/btreemap-index-mut-2.stderr diff --git a/tests/ui/collections/btreemap/btreemap-index-mut.rs b/tests/ui/btreemap/btreemap-index-mut.rs similarity index 100% rename from tests/ui/collections/btreemap/btreemap-index-mut.rs rename to tests/ui/btreemap/btreemap-index-mut.rs diff --git a/tests/ui/collections/btreemap/btreemap-index-mut.stderr b/tests/ui/btreemap/btreemap-index-mut.stderr similarity index 100% rename from tests/ui/collections/btreemap/btreemap-index-mut.stderr rename to tests/ui/btreemap/btreemap-index-mut.stderr diff --git a/tests/ui/collections/btreemap/btreemap_dropck.rs b/tests/ui/btreemap/btreemap_dropck.rs similarity index 100% rename from tests/ui/collections/btreemap/btreemap_dropck.rs rename to tests/ui/btreemap/btreemap_dropck.rs diff --git a/tests/ui/collections/btreemap/btreemap_dropck.stderr b/tests/ui/btreemap/btreemap_dropck.stderr similarity index 100% rename from tests/ui/collections/btreemap/btreemap_dropck.stderr rename to tests/ui/btreemap/btreemap_dropck.stderr diff --git a/tests/ui/collections/btreemap/btreemap_into_iterator_lifetime.rs b/tests/ui/btreemap/btreemap_into_iterator_lifetime.rs similarity index 100% rename from tests/ui/collections/btreemap/btreemap_into_iterator_lifetime.rs rename to tests/ui/btreemap/btreemap_into_iterator_lifetime.rs diff --git a/tests/ui/c-variadic/copy.rs b/tests/ui/c-variadic/copy.rs deleted file mode 100644 index e9171738aa15..000000000000 --- a/tests/ui/c-variadic/copy.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass -//@ ignore-backends: gcc -#![feature(c_variadic)] - -// Test the behavior of `VaList::clone`. In C a `va_list` is duplicated using `va_copy`, but the -// rust api just uses `Clone`. This should create a completely independent cursor into the -// variable argument list: advancing the original has no effect on the copy and vice versa. - -fn main() { - unsafe { variadic(1, 2, 3) } -} - -unsafe extern "C" fn variadic(mut ap1: ...) { - let mut ap2 = ap1.clone(); - - assert_eq!(ap1.arg::(), 1); - assert_eq!(ap2.arg::(), 1); - - assert_eq!(ap2.arg::(), 2); - assert_eq!(ap1.arg::(), 2); - - drop(ap1); - assert_eq!(ap2.arg::(), 3); -} diff --git a/tests/ui/cast/fat-ptr-cast.stderr b/tests/ui/cast/fat-ptr-cast.stderr index c6354122f568..2b0bceebf15c 100644 --- a/tests/ui/cast/fat-ptr-cast.stderr +++ b/tests/ui/cast/fat-ptr-cast.stderr @@ -81,8 +81,6 @@ LL | let s = 0 as *const T; | - ^^^^^^^^ creating a `*const T` requires both an address and type-specific metadata | | | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` - | - = note: the type parameter `T` is not known to be `Sized`, so this pointer may be wide error: aborting due to 11 previous errors diff --git a/tests/ui/cast/generic-trait-object-call.rs b/tests/ui/cast/generic-trait-object-call.rs deleted file mode 100644 index a6703dfd8aa6..000000000000 --- a/tests/ui/cast/generic-trait-object-call.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2288 - -//@ run-pass -#![allow(non_camel_case_types)] - -trait clam { - fn chowder(&self, y: A); -} - -#[derive(Copy, Clone)] -struct foo { - x: A, -} - -impl clam for foo { - fn chowder(&self, _y: A) {} -} - -fn foo(b: A) -> foo { - foo { x: b } -} - -fn f(x: Box>, a: A) { - x.chowder(a); -} - -pub fn main() { - let c = foo(42); - let d: Box> = Box::new(c) as Box>; - f(d, c.x); -} diff --git a/tests/ui/cast/ice-cast-type-with-error-124848.rs b/tests/ui/cast/ice-cast-type-with-error-124848.rs index 0c623de8050b..9b3732b02db4 100644 --- a/tests/ui/cast/ice-cast-type-with-error-124848.rs +++ b/tests/ui/cast/ice-cast-type-with-error-124848.rs @@ -14,4 +14,5 @@ fn main() { let bad_addr = &unpinned as *const Cell>> as usize; //~^ ERROR use of undeclared lifetime name `'a` //~| ERROR use of undeclared lifetime name `'a` + //~| ERROR casting `&MyType<'_>` as `*const Cell>>` is invalid } diff --git a/tests/ui/cast/ice-cast-type-with-error-124848.stderr b/tests/ui/cast/ice-cast-type-with-error-124848.stderr index 665b0e0a0dd4..dff227727324 100644 --- a/tests/ui/cast/ice-cast-type-with-error-124848.stderr +++ b/tests/ui/cast/ice-cast-type-with-error-124848.stderr @@ -58,7 +58,13 @@ help: provide the argument LL | let mut unpinned = MyType(Cell::new(None), /* value */); | +++++++++++++ -error: aborting due to 5 previous errors +error[E0606]: casting `&MyType<'_>` as `*const Cell>>` is invalid + --> $DIR/ice-cast-type-with-error-124848.rs:14:20 + | +LL | let bad_addr = &unpinned as *const Cell>> as usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Some errors have detailed explanations: E0061, E0261, E0425. +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0061, E0261, E0425, E0606. For more information about an error, try `rustc --explain E0061`. diff --git a/tests/ui/cfg/crt-static-off-works.rs b/tests/ui/cfg/crt-static-off-works.rs index 520d139915cc..1d77dba24b1c 100644 --- a/tests/ui/cfg/crt-static-off-works.rs +++ b/tests/ui/cfg/crt-static-off-works.rs @@ -1,6 +1,10 @@ //@ run-pass + +#![allow(stable_features)] //@ compile-flags:-C target-feature=-crt-static -Z unstable-options //@ ignore-musl - requires changing the linker which is hard +#![feature(cfg_target_feature)] + #[cfg(not(target_feature = "crt-static"))] fn main() {} diff --git a/tests/ui/cfg/diagnostics-cross-crate.rs b/tests/ui/cfg/diagnostics-cross-crate.rs index c5d8dcdc62f0..f959332c817f 100644 --- a/tests/ui/cfg/diagnostics-cross-crate.rs +++ b/tests/ui/cfg/diagnostics-cross-crate.rs @@ -14,7 +14,7 @@ fn main() { // The module isn't found - we would like to get a diagnostic, but currently don't due to // the awkward way the resolver diagnostics are currently implemented. - cfged_out::inner::doesnt_exist::hello(); //~ ERROR cannot find + cfged_out::inner::doesnt_exist::hello(); //~ ERROR failed to resolve //~^ NOTE could not find `doesnt_exist` in `inner` //~| NOTE found an item that was configured out diff --git a/tests/ui/cfg/diagnostics-cross-crate.stderr b/tests/ui/cfg/diagnostics-cross-crate.stderr index 15e60cc43a3c..658e5a442bda 100644 --- a/tests/ui/cfg/diagnostics-cross-crate.stderr +++ b/tests/ui/cfg/diagnostics-cross-crate.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `doesnt_exist` in `inner` +error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-cross-crate.rs:17:23 | LL | cfged_out::inner::doesnt_exist::hello(); diff --git a/tests/ui/cfg/diagnostics-reexport-2.rs b/tests/ui/cfg/diagnostics-reexport-2.rs index bef832517061..f66b9ed99ee6 100644 --- a/tests/ui/cfg/diagnostics-reexport-2.rs +++ b/tests/ui/cfg/diagnostics-reexport-2.rs @@ -40,22 +40,22 @@ mod reexport32 { fn main() { reexport::gated::foo(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: could not find `gated` in `reexport` //~| NOTE could not find `gated` in `reexport` reexport2::gated::foo(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: could not find `gated` in `reexport2` //~| NOTE could not find `gated` in `reexport2` reexport30::gated::foo(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: could not find `gated` in `reexport30` //~| NOTE could not find `gated` in `reexport30` reexport31::gated::foo(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: could not find `gated` in `reexport31` //~| NOTE could not find `gated` in `reexport31` reexport32::gated::foo(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: could not find `gated` in `reexport32` //~| NOTE could not find `gated` in `reexport32` } diff --git a/tests/ui/cfg/diagnostics-reexport-2.stderr b/tests/ui/cfg/diagnostics-reexport-2.stderr index a79c623856ff..713cffce65b6 100644 --- a/tests/ui/cfg/diagnostics-reexport-2.stderr +++ b/tests/ui/cfg/diagnostics-reexport-2.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `gated` in `reexport` +error[E0433]: failed to resolve: could not find `gated` in `reexport` --> $DIR/diagnostics-reexport-2.rs:42:15 | LL | reexport::gated::foo(); @@ -13,7 +13,7 @@ LL | #[cfg(false)] LL | pub mod gated { | ^^^^^ -error[E0433]: cannot find `gated` in `reexport2` +error[E0433]: failed to resolve: could not find `gated` in `reexport2` --> $DIR/diagnostics-reexport-2.rs:46:16 | LL | reexport2::gated::foo(); @@ -28,7 +28,7 @@ LL | #[cfg(false)] LL | pub mod gated { | ^^^^^ -error[E0433]: cannot find `gated` in `reexport30` +error[E0433]: failed to resolve: could not find `gated` in `reexport30` --> $DIR/diagnostics-reexport-2.rs:50:17 | LL | reexport30::gated::foo(); @@ -43,7 +43,7 @@ LL | #[cfg(false)] LL | pub mod gated { | ^^^^^ -error[E0433]: cannot find `gated` in `reexport31` +error[E0433]: failed to resolve: could not find `gated` in `reexport31` --> $DIR/diagnostics-reexport-2.rs:54:17 | LL | reexport31::gated::foo(); @@ -58,7 +58,7 @@ LL | #[cfg(false)] LL | pub mod gated { | ^^^^^ -error[E0433]: cannot find `gated` in `reexport32` +error[E0433]: failed to resolve: could not find `gated` in `reexport32` --> $DIR/diagnostics-reexport-2.rs:58:17 | LL | reexport32::gated::foo(); diff --git a/tests/ui/cfg/diagnostics-same-crate.rs b/tests/ui/cfg/diagnostics-same-crate.rs index 40babaa3d4c9..29209d5f3eaa 100644 --- a/tests/ui/cfg/diagnostics-same-crate.rs +++ b/tests/ui/cfg/diagnostics-same-crate.rs @@ -50,7 +50,7 @@ fn main() { //~| NOTE not found in `inner` // The module isn't found - we get a diagnostic. - inner::doesnt_exist::hello(); //~ ERROR cannot find + inner::doesnt_exist::hello(); //~ ERROR failed to resolve //~| NOTE could not find `doesnt_exist` in `inner` // It should find the one in the right module, not the wrong one. diff --git a/tests/ui/cfg/diagnostics-same-crate.stderr b/tests/ui/cfg/diagnostics-same-crate.stderr index c20542e19eaf..a8d789e61d1a 100644 --- a/tests/ui/cfg/diagnostics-same-crate.stderr +++ b/tests/ui/cfg/diagnostics-same-crate.stderr @@ -28,7 +28,7 @@ LL | #[cfg(false)] LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ -error[E0433]: cannot find `doesnt_exist` in `inner` +error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-same-crate.rs:53:12 | LL | inner::doesnt_exist::hello(); diff --git a/tests/ui/check-cfg/cfg-select.rs b/tests/ui/check-cfg/cfg-select.rs index ffa5e40bff08..39703489818d 100644 --- a/tests/ui/check-cfg/cfg-select.rs +++ b/tests/ui/check-cfg/cfg-select.rs @@ -4,7 +4,7 @@ #![crate_type = "lib"] cfg_select! { - false => {} + true => {} invalid_cfg1 => {} //~^ WARN unexpected `cfg` condition name _ => {} @@ -13,6 +13,6 @@ cfg_select! { cfg_select! { invalid_cfg2 => {} //~^ WARN unexpected `cfg` condition name - false => {} + true => {} _ => {} } diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 06a7f477a7fd..6125e66320c8 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -14,7 +14,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `7e10` `a` `aclass` -`addsubiw` `adx` `aes` `altivec` @@ -58,7 +57,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `bf16` `bmi1` `bmi2` -`break` `bti` `bulk-memory` `c` @@ -85,9 +83,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `e2` `ecv` `edsp` -`eijmpcall` -`elpm` -`elpmx` `elrw` `enhanced-sort` `ermsb` @@ -136,24 +131,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `high-registers` `high-word` `hvx` -`hvx-ieee-fp` `hvx-length128b` -`hvx-length64b` -`hvx-qfloat` -`hvxv60` -`hvxv62` -`hvxv65` -`hvxv66` -`hvxv67` -`hvxv68` -`hvxv69` -`hvxv71` -`hvxv73` -`hvxv75` -`hvxv79` `hwdiv` `i8mm` -`ijmpcall` `isa-68000` `isa-68010` `isa-68020` @@ -162,7 +142,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `isa-68060` `isa-68881` `isa-68882` -`jmpcall` `jsconv` `kl` `lahfsahf` @@ -173,9 +152,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `ld-seq-sa` `leoncasa` `lor` -`lowbytefirst` -`lpm` -`lpmx` `lse` `lse128` `lse2` @@ -197,13 +173,11 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `mops` `movbe` `movrs` -`movw` `mp` `mp1e2` `msa` `msync` `mte` -`mul` `multivalue` `mutable-globals` `neon` @@ -268,7 +242,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `reference-types` `relax` `relaxed-simd` -`rmw` `rtm` `rva23u64` `sb` @@ -321,8 +294,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `sme2p1` `soft-float` `spe` -`spm` -`spmx` `ssbs` `sse` `sse2` @@ -347,7 +318,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `tbm` `thumb-mode` `thumb2` -`tinyencoding` `tme` `transactional-execution` `trust` @@ -461,7 +431,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `zksed` `zksh` `zkt` -`zreg` `ztso` `zvbb` `zvbc` diff --git a/tests/ui/check-cfg/values-target-json.rs b/tests/ui/check-cfg/values-target-json.rs index 21b6af9b5560..defb286ed19b 100644 --- a/tests/ui/check-cfg/values-target-json.rs +++ b/tests/ui/check-cfg/values-target-json.rs @@ -4,8 +4,7 @@ //@ check-pass //@ no-auto-check-cfg //@ needs-llvm-components: x86 -//@ compile-flags: --crate-type=lib --check-cfg=cfg() -//@ compile-flags: -Zunstable-options --target={{src-base}}/check-cfg/my-awesome-platform.json +//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json //@ ignore-backends: gcc #![feature(lang_items, no_core, auto_traits, rustc_attrs)] diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr index 4249dea10a36..97ecdfab8205 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr @@ -53,6 +53,8 @@ LL | println!("{}", arr[3]); ... LL | c(); | - mutable borrow later used here + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable --> $DIR/arrays.rs:71:24 diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr index 09143f44dc83..2e3259e64059 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr @@ -25,6 +25,8 @@ LL | println!("{}", e.0.0.m.x); LL | LL | c(); | - mutable borrow later used here + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed --> $DIR/box.rs:55:5 diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr index f59be6b7a720..0e93e033c022 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr @@ -7,6 +7,7 @@ LL | println!("{}", foo.x); = note: this struct is 1-byte aligned, but the type of this field may require higher alignment = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr index 406f7c63b734..68fdb3ce131f 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr @@ -13,6 +13,8 @@ LL | println!("{:?}", p); LL | LL | c(); | - mutable borrow later used here + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/closures/2229_closure_analysis/match/auxiliary/partial_move_drop_order_lib.rs b/tests/ui/closures/2229_closure_analysis/match/auxiliary/partial_move_drop_order_lib.rs deleted file mode 100644 index 8cf25c6ba7b2..000000000000 --- a/tests/ui/closures/2229_closure_analysis/match/auxiliary/partial_move_drop_order_lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub struct LoudDrop(pub &'static str); -impl Drop for LoudDrop { - fn drop(&mut self) { - println!("dropping {}", self.0); - } -} - -#[non_exhaustive] -pub enum ExtNonExhaustive { - One(i32, LoudDrop), -} diff --git a/tests/ui/closures/2229_closure_analysis/match/auxiliary/partial_move_lib.rs b/tests/ui/closures/2229_closure_analysis/match/auxiliary/partial_move_lib.rs deleted file mode 100644 index b0646f1d0032..000000000000 --- a/tests/ui/closures/2229_closure_analysis/match/auxiliary/partial_move_lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[non_exhaustive] -pub enum ExtNonExhaustive { - A(u32, String), -} diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs index f47d70b52f20..5b7259c6c2cc 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs @@ -28,6 +28,12 @@ fn main() { let _b = || { match l1 { L1::A => () } }; //~^ ERROR: non-exhaustive patterns: `L1::B` not covered [E0004] + // l2 should not be captured as it is a non-exhaustive SingleVariant + // defined in this crate + let _c = || { match l2 { L2::C => (), _ => () } }; + let mut mut_l2 = l2; + _c(); + // E1 is not visibly uninhabited from here let (e1, e2, e3, e4) = bar(); let _d = || { match e1 {} }; @@ -36,14 +42,8 @@ fn main() { //~^ ERROR: non-exhaustive patterns: `_` not covered [E0004] let _f = || { match e2 { E2::A => (), E2::B => (), _ => () } }; - // non-exhaustive enums should always be captured, regardless if they - // are defined in the current crate: - let _c = || { match l2 { L2::C => (), _ => () } }; - let mut mut_l2 = l2; - //~^ ERROR: cannot move out of `l2` because it is borrowed - _c(); - - // ...or in another crate: + // e3 should be captured as it is a non-exhaustive SingleVariant + // defined in another crate let _g = || { match e3 { E3::C => (), _ => () } }; let mut mut_e3 = e3; //~^ ERROR: cannot move out of `e3` because it is borrowed diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index e34d1889803a..99d33b05429e 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -16,7 +16,7 @@ LL | let _b = || { match l1 { L1::A => (), L1::B => todo!() } }; | ++++++++++++++++++ error[E0004]: non-exhaustive patterns: type `E1` is non-empty - --> $DIR/non-exhaustive-match.rs:33:25 + --> $DIR/non-exhaustive-match.rs:39:25 | LL | let _d = || { match e1 {} }; | ^^ @@ -35,7 +35,7 @@ LL ~ } }; | error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/non-exhaustive-match.rs:35:25 + --> $DIR/non-exhaustive-match.rs:41:25 | LL | let _e = || { match e2 { E2::A => (), E2::B => () } }; | ^^ pattern `_` not covered @@ -52,19 +52,6 @@ help: ensure that all possible cases are being handled by adding a match arm wit LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; | ++++++++++++++ -error[E0505]: cannot move out of `l2` because it is borrowed - --> $DIR/non-exhaustive-match.rs:42:22 - | -LL | let _c = || { match l2 { L2::C => (), _ => () } }; - | -- -- borrow occurs due to use in closure - | | - | borrow of `l2` occurs here -LL | let mut mut_l2 = l2; - | ^^ move out of `l2` occurs here -LL | -LL | _c(); - | -- borrow later used here - error[E0505]: cannot move out of `e3` because it is borrowed --> $DIR/non-exhaustive-match.rs:48:22 | @@ -78,7 +65,7 @@ LL | LL | _g(); | -- borrow later used here -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0004, E0505. For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/closures/2229_closure_analysis/match/partial-move-drop-order.rs b/tests/ui/closures/2229_closure_analysis/match/partial-move-drop-order.rs deleted file mode 100644 index 348d558dd980..000000000000 --- a/tests/ui/closures/2229_closure_analysis/match/partial-move-drop-order.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Make sure that #[non_exhaustive] cannot cause drop order to depend on which -// crate the code is in. -// -// See rust-lang/rust#147722 -// -//@ edition:2021 -//@ run-pass -//@ check-run-results -//@ aux-build:partial_move_drop_order_lib.rs - -extern crate partial_move_drop_order_lib; -use partial_move_drop_order_lib::{LoudDrop, ExtNonExhaustive}; - -pub enum OneVariant { - One(i32, LoudDrop), -} - -pub enum TwoVariants { - One(i32, LoudDrop), - Two, -} - -#[non_exhaustive] -pub enum NonExhaustive { - One(i32, LoudDrop), -} - -#[allow(unused)] -fn one_variant() { - println!("one variant:"); - let mut thing = OneVariant::One(0, LoudDrop("a")); - let closure = move || match thing { - OneVariant::One(x, _) => {} - _ => unreachable!(), - }; - println!("before assign"); - thing = OneVariant::One(1, LoudDrop("b")); - println!("after assign"); -} - -#[allow(unused)] -fn two_variants() { - println!("two variants:"); - let mut thing = TwoVariants::One(0, LoudDrop("a")); - let closure = move || match thing { - TwoVariants::One(x, _) => {} - _ => unreachable!(), - }; - println!("before assign"); - thing = TwoVariants::One(1, LoudDrop("b")); - println!("after assign"); -} - -#[allow(unused)] -fn non_exhaustive() { - println!("non exhaustive:"); - let mut thing = NonExhaustive::One(0, LoudDrop("a")); - let closure = move || match thing { - NonExhaustive::One(x, _) => {} - _ => unreachable!(), - }; - println!("before assign"); - thing = NonExhaustive::One(1, LoudDrop("b")); - println!("after assign"); -} - -#[allow(unused)] -fn ext_non_exhaustive() { - println!("external non exhaustive:"); - let mut thing = ExtNonExhaustive::One(0, LoudDrop("a")); - let closure = move || match thing { - ExtNonExhaustive::One(x, _) => {} - _ => unreachable!(), - }; - println!("before assign"); - thing = ExtNonExhaustive::One(1, LoudDrop("b")); - println!("after assign"); -} - -fn main() { - one_variant(); - println!(); - two_variants(); - println!(); - non_exhaustive(); - println!(); - ext_non_exhaustive(); -} diff --git a/tests/ui/closures/2229_closure_analysis/match/partial-move-drop-order.run.stdout b/tests/ui/closures/2229_closure_analysis/match/partial-move-drop-order.run.stdout deleted file mode 100644 index 3fa346d87b07..000000000000 --- a/tests/ui/closures/2229_closure_analysis/match/partial-move-drop-order.run.stdout +++ /dev/null @@ -1,23 +0,0 @@ -one variant: -before assign -dropping a -after assign -dropping b - -two variants: -before assign -after assign -dropping a -dropping b - -non exhaustive: -before assign -after assign -dropping a -dropping b - -external non exhaustive: -before assign -after assign -dropping a -dropping b diff --git a/tests/ui/closures/2229_closure_analysis/match/partial-move.rs b/tests/ui/closures/2229_closure_analysis/match/partial-move.rs deleted file mode 100644 index 7bd435bd1856..000000000000 --- a/tests/ui/closures/2229_closure_analysis/match/partial-move.rs +++ /dev/null @@ -1,116 +0,0 @@ -// This test measures the effect of matching-induced partial captures on the borrow checker. -// In particular, in each of the cases below, the closure either captures the entire enum/struct, -// or each field separately. -// -// If the entire ADT gets captured, it'll happen by move, and the closure will live for 'static. -// On the other hand, if each field gets captured separately, the u32 field, being Copy, will only -// get captured by an immutable borrow, resulting in a borrow checker error. -// -// See rust-lang/rust#147722 -// -//@ edition:2021 -//@ aux-build:partial_move_lib.rs -pub struct Struct(u32, String); - -pub enum Enum { - A(u32, String), -} - -pub enum TwoVariants { - A(u32, String), - B, -} - -#[non_exhaustive] -pub enum NonExhaustive { - A(u32, String), -} - -extern crate partial_move_lib; -use partial_move_lib::ExtNonExhaustive; - -// First, let's assert that the additional wildcard arm is not a source of any behavior -// differences: -pub fn test_enum1(x: Enum) -> impl FnOnce() { - || { - //~^ ERROR: closure may outlive the current function, but it borrows `x.0` - match x { - Enum::A(a, b) => { - drop((a, b)); - } - _ => unreachable!(), - } - } -} - -pub fn test_enum2(x: Enum) -> impl FnOnce() { - || { - //~^ ERROR: closure may outlive the current function, but it borrows `x.0` - match x { - Enum::A(a, b) => { - drop((a, b)); - } - } - } -} - -// The behavior for single-variant enums matches what happens for a struct -pub fn test_struct(x: Struct) -> impl FnOnce() { - || { - //~^ ERROR: closure may outlive the current function, but it borrows `x.0` - match x { - Struct(a, b) => { - drop((a, b)); - } - } - } -} - -// If we have two variants, the entire enum gets moved into the closure -pub fn test_two_variants(x: TwoVariants) -> impl FnOnce() { - || { - match x { - TwoVariants::A(a, b) => { - drop((a, b)); - } - _ => unreachable!(), - } - } -} - -// ...and single-variant, non-exhaustive enums behave as if they had multiple variants -pub fn test_non_exhaustive1(x: NonExhaustive) -> impl FnOnce() { - || { - match x { - NonExhaustive::A(a, b) => { - drop((a, b)); - } - _ => unreachable!(), - } - } -} - -// (again, wildcard branch or not) -pub fn test_non_exhaustive2(x: NonExhaustive) -> impl FnOnce() { - || { - match x { - NonExhaustive::A(a, b) => { - drop((a, b)); - } - } - } -} - -// ...regardless of whether the enum is defined in the current, or in another crate -pub fn test_ext(x: ExtNonExhaustive) -> impl FnOnce() { - || { - match x { - ExtNonExhaustive::A(a, b) => { - drop((a, b)); - } - _ => unreachable!(), - } - } -} - -fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/match/partial-move.stderr b/tests/ui/closures/2229_closure_analysis/match/partial-move.stderr deleted file mode 100644 index 09f9adf95d5b..000000000000 --- a/tests/ui/closures/2229_closure_analysis/match/partial-move.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `x.0`, which is owned by the current function - --> $DIR/partial-move.rs:35:5 - | -LL | || { - | ^^ may outlive borrowed value `x.0` -LL | -LL | match x { - | - `x.0` is borrowed here - | -note: closure is returned here - --> $DIR/partial-move.rs:35:5 - | -LL | / || { -LL | | -LL | | match x { -LL | | Enum::A(a, b) => { -... | -LL | | } - | |_____^ -help: to force the closure to take ownership of `x.0` (and any other referenced variables), use the `move` keyword - | -LL | move || { - | ++++ - -error[E0373]: closure may outlive the current function, but it borrows `x.0`, which is owned by the current function - --> $DIR/partial-move.rs:47:5 - | -LL | || { - | ^^ may outlive borrowed value `x.0` -LL | -LL | match x { - | - `x.0` is borrowed here - | -note: closure is returned here - --> $DIR/partial-move.rs:47:5 - | -LL | / || { -LL | | -LL | | match x { -LL | | Enum::A(a, b) => { -... | -LL | | } - | |_____^ -help: to force the closure to take ownership of `x.0` (and any other referenced variables), use the `move` keyword - | -LL | move || { - | ++++ - -error[E0373]: closure may outlive the current function, but it borrows `x.0`, which is owned by the current function - --> $DIR/partial-move.rs:59:5 - | -LL | || { - | ^^ may outlive borrowed value `x.0` -LL | -LL | match x { - | - `x.0` is borrowed here - | -note: closure is returned here - --> $DIR/partial-move.rs:59:5 - | -LL | / || { -LL | | -LL | | match x { -LL | | Struct(a, b) => { -... | -LL | | } - | |_____^ -help: to force the closure to take ownership of `x.0` (and any other referenced variables), use the `move` keyword - | -LL | move || { - | ++++ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0373`. diff --git a/tests/ui/closures/binder/implicit-stuff.rs b/tests/ui/closures/binder/implicit-stuff.rs index 09e4c747afee..c976c200b0c8 100644 --- a/tests/ui/closures/binder/implicit-stuff.rs +++ b/tests/ui/closures/binder/implicit-stuff.rs @@ -24,4 +24,5 @@ fn main() { //~| ERROR `'_` cannot be used here let _ = for<'a> |x: &()| -> &'a () { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here let _ = for<'a> |x: &'a ()| -> &() { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here + //~^ ERROR: lifetime may not live long enough } diff --git a/tests/ui/closures/binder/implicit-stuff.stderr b/tests/ui/closures/binder/implicit-stuff.stderr index cec2a60ba28c..330a05a79bae 100644 --- a/tests/ui/closures/binder/implicit-stuff.stderr +++ b/tests/ui/closures/binder/implicit-stuff.stderr @@ -102,6 +102,15 @@ LL | let _ = for<'a> |x: &'a _, y, z: _| -> &'a _ { | | | `for<...>` is here -error: aborting due to 15 previous errors +error: lifetime may not live long enough + --> $DIR/implicit-stuff.rs:26:42 + | +LL | let _ = for<'a> |x: &'a ()| -> &() { x }; + | -- - ^ returning this value requires that `'a` must outlive `'1` + | | | + | | let's call the lifetime of this reference `'1` + | lifetime `'a` defined here + +error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/closures/closure-arg-borrow-ice-issue-152331.rs b/tests/ui/closures/closure-arg-borrow-ice-issue-152331.rs deleted file mode 100644 index 261f8fedc38f..000000000000 --- a/tests/ui/closures/closure-arg-borrow-ice-issue-152331.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn main() { - h2(|_: (), _: (), _: (), x: &_| {}); - //~^ ERROR type mismatch in closure arguments -} - -fn h2(_: F) -where - F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())), -{ -} diff --git a/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr b/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr deleted file mode 100644 index 7cfc9f0576ec..000000000000 --- a/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-borrow-ice-issue-152331.rs:2:5 - | -LL | h2(|_: (), _: (), _: (), x: &_| {}); - | ^^^----------------------------^^^^ - | | | - | | found signature defined here - | expected due to this - | - = note: expected closure signature `for<'a, 't0> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _` - found closure signature `fn((), (), (), &_) -> _` -note: required by a bound in `h2` - --> $DIR/closure-arg-borrow-ice-issue-152331.rs:8:8 - | -LL | fn h2(_: F) - | -- required by a bound in this function -LL | where -LL | F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2` -help: consider adjusting the signature so it borrows its arguments - | -LL | h2(|_: &(), _: (), _: &(), x: &_| {}); - | + + -help: consider adjusting the signature so it does not borrow its argument - | -LL - h2(|_: (), _: (), _: (), x: &_| {}); -LL + h2(|_: (), _: (), _: (), x: _| {}); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/closures/closure-move-use-after-move-diagnostic.rs b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs index 863bcedd01e6..3326af7486c5 100644 --- a/tests/ui/closures/closure-move-use-after-move-diagnostic.rs +++ b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs @@ -1,16 +1,16 @@ //! regression test for -struct NoCopy; //~ NOTE: if `NoCopy` implemented `Clone`, you could clone the value -//~^ NOTE: consider implementing `Clone` for this type +struct NoCopy; //~ NOTE if `NoCopy` implemented `Clone`, you could clone the value +//~^ NOTE consider implementing `Clone` for this type fn main() { let x = NoCopy; - //~^ NOTE: move occurs because `x` has type `NoCopy` + //~^ NOTE move occurs because `x` has type `NoCopy` let f = move || { - //~^ NOTE: value moved into closure here + //~^ NOTE value moved into closure here let y = x; - //~^ NOTE: variable moved due to use in closure - //~| NOTE: you could clone this value + //~^ NOTE variable moved due to use in closure + //~| NOTE you could clone this value }; let z = x; - //~^ ERROR: use of moved value: `x` - //~| NOTE: value used here after move + //~^ ERROR use of moved value: `x` + //~| NOTE value used here after move } diff --git a/tests/ui/closures/issue-111932.stderr b/tests/ui/closures/issue-111932.stderr index 2d10a2657aa0..fc3b7b0c6e66 100644 --- a/tests/ui/closures/issue-111932.stderr +++ b/tests/ui/closures/issue-111932.stderr @@ -17,6 +17,7 @@ LL | println!("{:?}", foo); | required by this formatting parameter | = help: the trait `Sized` is not implemented for `dyn Foo` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/closures/local-enums-in-closure-2074.rs b/tests/ui/closures/local-enums-in-closure-2074.rs deleted file mode 100644 index 29cd6f13e3bb..000000000000 --- a/tests/ui/closures/local-enums-in-closure-2074.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2074 - -//@ run-pass - -#![allow(non_camel_case_types)] - -pub fn main() { - let one = || { - enum r { - a, - } - r::a as usize - }; - let two = || { - enum r { - a, - } - r::a as usize - }; - one(); - two(); -} diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs index 55160f7a0f00..4565d89f0dc8 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs @@ -13,9 +13,6 @@ use minicore::*; #[repr(C)] pub struct ReprCU64(u64); -#[repr(Rust)] -pub struct ReprRustU64(u64); - #[repr(C)] pub struct ReprCBytes(u8, u8, u8, u8, u8); @@ -28,11 +25,10 @@ pub struct ReprCAlign16(u16); #[no_mangle] pub fn test( f1: extern "cmse-nonsecure-call" fn() -> ReprCU64, //~ ERROR [E0798] - f2: extern "cmse-nonsecure-call" fn() -> ReprRustU64, //~ ERROR [E0798] - f3: extern "cmse-nonsecure-call" fn() -> ReprCBytes, //~ ERROR [E0798] - f4: extern "cmse-nonsecure-call" fn() -> U64Compound, //~ ERROR [E0798] - f5: extern "cmse-nonsecure-call" fn() -> ReprCAlign16, //~ ERROR [E0798] - f6: extern "cmse-nonsecure-call" fn() -> [u8; 5], //~ ERROR [E0798] + f2: extern "cmse-nonsecure-call" fn() -> ReprCBytes, //~ ERROR [E0798] + f3: extern "cmse-nonsecure-call" fn() -> U64Compound, //~ ERROR [E0798] + f4: extern "cmse-nonsecure-call" fn() -> ReprCAlign16, //~ ERROR [E0798] + f5: extern "cmse-nonsecure-call" fn() -> [u8; 5], //~ ERROR [E0798] ) { } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr index 6b7446abc8eb..4351444225b5 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr @@ -1,5 +1,5 @@ error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:41:48 + --> $DIR/return-via-stack.rs:37:48 | LL | u128: extern "cmse-nonsecure-call" fn() -> u128, | ^^^^ this type doesn't fit in the available registers @@ -8,7 +8,7 @@ LL | u128: extern "cmse-nonsecure-call" fn() -> u128, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:42:48 + --> $DIR/return-via-stack.rs:38:48 | LL | i128: extern "cmse-nonsecure-call" fn() -> i128, | ^^^^ this type doesn't fit in the available registers @@ -17,7 +17,7 @@ LL | i128: extern "cmse-nonsecure-call" fn() -> i128, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:30:46 + --> $DIR/return-via-stack.rs:27:46 | LL | f1: extern "cmse-nonsecure-call" fn() -> ReprCU64, | ^^^^^^^^ this type doesn't fit in the available registers @@ -26,52 +26,43 @@ LL | f1: extern "cmse-nonsecure-call" fn() -> ReprCU64, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:31:46 + --> $DIR/return-via-stack.rs:28:46 | -LL | f2: extern "cmse-nonsecure-call" fn() -> ReprRustU64, - | ^^^^^^^^^^^ this type doesn't fit in the available registers - | - = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers - = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size - -error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:32:46 - | -LL | f3: extern "cmse-nonsecure-call" fn() -> ReprCBytes, +LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCBytes, | ^^^^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:33:46 + --> $DIR/return-via-stack.rs:29:46 | -LL | f4: extern "cmse-nonsecure-call" fn() -> U64Compound, +LL | f3: extern "cmse-nonsecure-call" fn() -> U64Compound, | ^^^^^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:34:46 + --> $DIR/return-via-stack.rs:30:46 | -LL | f5: extern "cmse-nonsecure-call" fn() -> ReprCAlign16, +LL | f4: extern "cmse-nonsecure-call" fn() -> ReprCAlign16, | ^^^^^^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:35:46 + --> $DIR/return-via-stack.rs:31:46 | -LL | f6: extern "cmse-nonsecure-call" fn() -> [u8; 5], +LL | f5: extern "cmse-nonsecure-call" fn() -> [u8; 5], | ^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:57:46 + --> $DIR/return-via-stack.rs:53:46 | LL | f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64, | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -80,7 +71,7 @@ LL | f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:58:46 + --> $DIR/return-via-stack.rs:54:46 | LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64, | ^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -88,6 +79,6 @@ LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64, = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error: aborting due to 10 previous errors +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0798`. diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs index 2e73ef8c32f5..53e98d2eb1bc 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs @@ -24,24 +24,3 @@ pub extern "cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} //~ ERROR [ #[no_mangle] #[allow(improper_ctypes_definitions)] pub extern "cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} //~ ERROR [E0798] - -struct Four { - a: u32, - b: u32, - c: u32, - d: u32, -} - -struct Five { - a: u32, - b: u32, - c: u32, - d: u32, - e: u32, -} - -#[no_mangle] -pub extern "cmse-nonsecure-entry" fn four(_: Four) {} - -#[no_mangle] -pub extern "cmse-nonsecure-entry" fn five(_: Five) {} //~ ERROR [E0798] diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr index c17cf50a6139..af8277d314ba 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr @@ -40,14 +40,6 @@ LL | pub extern "cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} | = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit argument registers -error[E0798]: arguments for `"cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:47:46 - | -LL | pub extern "cmse-nonsecure-entry" fn five(_: Five) {} - | ^^^^ does not fit in the available registers - | - = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit argument registers - -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0798`. diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs index 756cc6816acd..0a6565e37fc7 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs @@ -40,15 +40,9 @@ pub extern "cmse-nonsecure-entry" fn inputs5(_: f64, _: f32, _: f32) {} #[no_mangle] pub extern "cmse-nonsecure-entry" fn inputs6(_: ReprTransparentStruct, _: U32Compound) {} #[no_mangle] -#[expect(improper_ctypes_definitions)] +#[allow(improper_ctypes_definitions)] pub extern "cmse-nonsecure-entry" fn inputs7(_: [u32; 4]) {} -// With zero-sized types we can actually have more than 4 arguments. -#[expect(improper_ctypes_definitions)] -pub extern "cmse-nonsecure-entry" fn inputs8(_: (), _: (), _: (), _: (), _: ()) {} -#[expect(improper_ctypes_definitions)] -pub extern "cmse-nonsecure-entry" fn inputs9(_: (), _: (), _: (), _: (), _: ()) {} - #[no_mangle] pub extern "cmse-nonsecure-entry" fn outputs1() -> u32 { 0 @@ -75,8 +69,8 @@ pub extern "cmse-nonsecure-entry" fn outputs6() -> ReprTransparentStruct { ReprTransparentStruct { _marker1: (), _marker2: (), field: 0xAA, _marker3: () } } #[no_mangle] -pub extern "cmse-nonsecure-entry" fn outputs7() -> ReprTransparentStruct> -{ +pub extern "cmse-nonsecure-entry" fn outputs7( +) -> ReprTransparentStruct> { ReprTransparentStruct { _marker1: (), _marker2: (), diff --git a/tests/ui/codemap_tests/bad-format-args.stderr b/tests/ui/codemap_tests/bad-format-args.stderr index ef0fa5f481e5..8f79beaa9e1b 100644 --- a/tests/ui/codemap_tests/bad-format-args.stderr +++ b/tests/ui/codemap_tests/bad-format-args.stderr @@ -3,6 +3,8 @@ error: requires at least a format string argument | LL | format!(); | ^^^^^^^^^ + | + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `,`, found `1` --> $DIR/bad-format-args.rs:3:16 diff --git a/tests/ui/codemap_tests/tab_3.stderr b/tests/ui/codemap_tests/tab_3.stderr index 2a0a9e2d48f3..7ae21a57052f 100644 --- a/tests/ui/codemap_tests/tab_3.stderr +++ b/tests/ui/codemap_tests/tab_3.stderr @@ -11,6 +11,7 @@ LL | println!("{:?}", some_vec); | note: `into_iter` takes ownership of the receiver `self`, which moves `some_vec` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | some_vec.clone().into_iter(); diff --git a/tests/ui/coercion/closure-in-array.rs b/tests/ui/coercion/closure-in-array.rs deleted file mode 100644 index ca5c021c77a7..000000000000 --- a/tests/ui/coercion/closure-in-array.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Weakened closure sig inference by #140283. -fn foo usize, const N: usize>(x: [F; N]) {} - -fn main() { - foo([|s| s.len()]) - //~^ ERROR: type annotations needed -} diff --git a/tests/ui/coercion/closure-in-array.stderr b/tests/ui/coercion/closure-in-array.stderr deleted file mode 100644 index 90cf590c09e7..000000000000 --- a/tests/ui/coercion/closure-in-array.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/closure-in-array.rs:5:11 - | -LL | foo([|s| s.len()]) - | ^ - type must be known at this point - | -help: consider giving this closure parameter an explicit type - | -LL | foo([|s: /* Type */| s.len()]) - | ++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/coercion/coerce-many-with-ty-var.rs b/tests/ui/coercion/coerce-many-with-ty-var.rs deleted file mode 100644 index cbd16f58ea5b..000000000000 --- a/tests/ui/coercion/coerce-many-with-ty-var.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ run-pass -// Check that least upper bound coercions don't resolve type variable merely based on the first -// coercion. Check issue #136420. - -fn foo() {} -fn bar() {} - -fn infer(_: T) {} - -fn infer_array_element(_: [T; 2]) {} - -fn main() { - // Previously the element type's ty var will be unified with `foo`. - let _: [_; 2] = [foo, bar]; - infer_array_element([foo, bar]); - - let _ = if false { - foo - } else { - bar - }; - infer(if false { - foo - } else { - bar - }); - - let _ = match false { - true => foo, - false => bar, - }; - infer(match false { - true => foo, - false => bar, - }); -} diff --git a/tests/ui/coercion/vec-macro-coercions.rs b/tests/ui/coercion/vec-macro-coercions.rs deleted file mode 100644 index f7dfd4324796..000000000000 --- a/tests/ui/coercion/vec-macro-coercions.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass - -fn main() { - let functions = &vec![ - |x: i32| -> i32 { x + 3 }, - |x: i32| -> i32 { x + 3 }, - ]; - - let string = String::new(); - let a = vec![&string, "abc"]; - let b = vec!["abc", &string]; -} diff --git a/tests/ui/coherence/conflicting-impl-with-err.rs b/tests/ui/coherence/conflicting-impl-with-err.rs index 49219b4c4a35..3e0234b874d7 100644 --- a/tests/ui/coherence/conflicting-impl-with-err.rs +++ b/tests/ui/coherence/conflicting-impl-with-err.rs @@ -1,8 +1,8 @@ struct ErrorKind; struct Error(ErrorKind); -impl From for Error { //~ ERROR cannot find - fn from(_: nope::Thing) -> Self { //~ ERROR cannot find +impl From for Error { //~ ERROR failed to resolve + fn from(_: nope::Thing) -> Self { //~ ERROR failed to resolve unimplemented!() } } diff --git a/tests/ui/coherence/conflicting-impl-with-err.stderr b/tests/ui/coherence/conflicting-impl-with-err.stderr index 706798bb0000..75a201797b55 100644 --- a/tests/ui/coherence/conflicting-impl-with-err.stderr +++ b/tests/ui/coherence/conflicting-impl-with-err.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `nope` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From for Error { @@ -6,7 +6,7 @@ LL | impl From for Error { | = help: you might be missing a crate named `nope` -error[E0433]: cannot find module or crate `nope` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:5:16 | LL | fn from(_: nope::Thing) -> Self { diff --git a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs index b754b1cb5472..c50bbcec5215 100644 --- a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs +++ b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs @@ -3,7 +3,7 @@ use std::cmp::Ordering; use std::marker::PhantomData; #[derive(PartialEq, Default)] -//~^ ERROR conflicting implementations of trait `PartialEq` for type `Interval<_>` +//~^ ERROR conflicting implementations of trait `PartialEq>` for type `Interval<_>` pub(crate) struct Interval(PhantomData); // This impl overlaps with the `derive` unless we reject the nested diff --git a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr index 620694aacf83..a9a99fb28d84 100644 --- a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr +++ b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `PartialEq` for type `Interval<_>` +error[E0119]: conflicting implementations of trait `PartialEq>` for type `Interval<_>` --> $DIR/warn-when-cycle-is-error-in-coherence.rs:5:10 | LL | #[derive(PartialEq, Default)] diff --git a/tests/ui/compile-flags/invalid/remap-path-scope.foo.stderr b/tests/ui/compile-flags/invalid/remap-path-scope.foo.stderr deleted file mode 100644 index dc72089e0d57..000000000000 --- a/tests/ui/compile-flags/invalid/remap-path-scope.foo.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all` - diff --git a/tests/ui/compile-flags/invalid/remap-path-scope.rs b/tests/ui/compile-flags/invalid/remap-path-scope.rs deleted file mode 100644 index 545c8c86cec7..000000000000 --- a/tests/ui/compile-flags/invalid/remap-path-scope.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Error on invalid --remap-path-scope arguments - -//@ revisions: foo underscore -//@ [foo]compile-flags: --remap-path-scope=foo -//@ [underscore]compile-flags: --remap-path-scope=macro_object - -//~? ERROR argument for `--remap-path-scope - -fn main() {} diff --git a/tests/ui/compile-flags/invalid/remap-path-scope.underscore.stderr b/tests/ui/compile-flags/invalid/remap-path-scope.underscore.stderr deleted file mode 100644 index dc72089e0d57..000000000000 --- a/tests/ui/compile-flags/invalid/remap-path-scope.underscore.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all` - diff --git a/tests/ui/compiletest-self-test/auxiliary/no_prefer_dynamic_lib.rs b/tests/ui/compiletest-self-test/auxiliary/no_prefer_dynamic_lib.rs deleted file mode 100644 index 6688dadbab24..000000000000 --- a/tests/ui/compiletest-self-test/auxiliary/no_prefer_dynamic_lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ no-prefer-dynamic - -//! Since this is `no-prefer-dynamic` we expect compiletest to _not_ look for -//! this create as `libno_prefer_dynamic_lib.so`. - -#![crate_type = "rlib"] - -pub fn return_42() -> i32 { - 42 -} diff --git a/tests/ui/compiletest-self-test/no-prefer-dynamic-means-no-so.rs b/tests/ui/compiletest-self-test/no-prefer-dynamic-means-no-so.rs deleted file mode 100644 index b7e8fae506c3..000000000000 --- a/tests/ui/compiletest-self-test/no-prefer-dynamic-means-no-so.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! Since we and our `aux-crate` is `no-prefer-dynamic`, we expect compiletest -//! to _not_ look for `libno_prefer_dynamic_lib.so`. - -//@ check-pass -//@ no-prefer-dynamic -//@ aux-crate: no_prefer_dynamic_lib=no_prefer_dynamic_lib.rs - -fn main() { - no_prefer_dynamic_lib::return_42(); -} diff --git a/tests/ui/compiletest-self-test/ui-testing-optout.rs b/tests/ui/compiletest-self-test/ui-testing-optout.rs index 2f2bc54676a8..62920a86c3b3 100644 --- a/tests/ui/compiletest-self-test/ui-testing-optout.rs +++ b/tests/ui/compiletest-self-test/ui-testing-optout.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z ui-testing=no --diagnostic-width=80 +//@ compile-flags: -Z ui-testing=no // Line number < 10 type A = B; //~ ERROR diff --git a/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.rs b/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.rs index d49fb49d253c..703e63ae047f 100644 --- a/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.rs +++ b/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.rs @@ -8,13 +8,11 @@ struct ConstBytes //~^ ERROR rustc_dump_predicates //~| NOTE Binder { value: ConstArgHasType(T/#0, &'static [*mut u8; 3_usize]), bound_vars: [] } -//~| NOTE Binder { value: TraitPredicate( as std::marker::Sized>, polarity:Positive), bound_vars: [] } - +//~| NOTE Binder { value: TraitPredicate( as std::marker::Sized>, polarity:Positive), bound_vars: [] } where ConstBytes: Sized; //~^ ERROR mismatched types //~| NOTE expected `&[*mut u8; 3]`, found `&[u8; 3]` //~| NOTE expected reference `&'static [*mut u8; 3]` -//~| NOTE found reference `&'static [u8; 3]` fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.stderr b/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.stderr index 1273a74102a2..f5f8a420a703 100644 --- a/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.stderr +++ b/tests/ui/const-generics/adt_const_params/byte-string-u8-validation.stderr @@ -1,12 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/byte-string-u8-validation.rs:14:16 - | -LL | ConstBytes: Sized; - | ^^^^^^ expected `&[*mut u8; 3]`, found `&[u8; 3]` - | - = note: expected reference `&'static [*mut u8; 3]` - found reference `&'static [u8; 3]` - error: rustc_dump_predicates --> $DIR/byte-string-u8-validation.rs:8:1 | @@ -14,7 +5,16 @@ LL | struct ConstBytes | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: Binder { value: ConstArgHasType(T/#0, &'static [*mut u8; 3_usize]), bound_vars: [] } - = note: Binder { value: TraitPredicate( as std::marker::Sized>, polarity:Positive), bound_vars: [] } + = note: Binder { value: TraitPredicate( as std::marker::Sized>, polarity:Positive), bound_vars: [] } + +error[E0308]: mismatched types + --> $DIR/byte-string-u8-validation.rs:13:16 + | +LL | ConstBytes: Sized; + | ^^^^^^ expected `&[*mut u8; 3]`, found `&[u8; 3]` + | + = note: expected reference `&'static [*mut u8; 3]` + found reference `&'static [u8; 3]` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs index 1900931b3f35..0614ea97b1ad 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs @@ -8,10 +8,10 @@ struct NotParam; struct CantParam(NotParam); impl std::marker::ConstParamTy_ for CantParam {} -//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type +//~^ error: the trait `ConstParamTy_` cannot be implemented for this type #[derive(std::marker::ConstParamTy, Eq, PartialEq)] +//~^ error: the trait `ConstParamTy_` cannot be implemented for this type struct CantParamDerive(NotParam); -//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr index 084c64d27335..fd1836802c4a 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr @@ -8,12 +8,13 @@ LL | impl std::marker::ConstParamTy_ for CantParam {} | ^^^^^^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/const_param_ty_impl_bad_field.rs:14:8 + --> $DIR/const_param_ty_impl_bad_field.rs:13:10 | LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)] - | ------------------------- in this derive macro expansion + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | LL | struct CantParamDerive(NotParam); - | ^^^^^^^^^^^^^^^ -------- this field does not implement `ConstParamTy_` + | -------- this field does not implement `ConstParamTy_` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs index a8f190609c04..a1c8eccfb095 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs @@ -8,13 +8,13 @@ impl std::marker::ConstParamTy_ for ImplementsConstParamTy {} struct CantParam(ImplementsConstParamTy); impl std::marker::ConstParamTy_ for CantParam {} -//~^ ERROR: the type `CantParam` does not `#[derive(PartialEq)]` -//~| ERROR: the trait bound `CantParam: Eq` is not satisfied +//~^ error: the type `CantParam` does not `#[derive(PartialEq)]` +//~| ERROR the trait bound `CantParam: Eq` is not satisfied #[derive(std::marker::ConstParamTy)] +//~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]` +//~| ERROR the trait bound `CantParamDerive: Eq` is not satisfied struct CantParamDerive(ImplementsConstParamTy); -//~^ ERROR: the type `CantParamDerive` does not `#[derive(PartialEq)]` -//~| ERROR: the trait bound `CantParamDerive: Eq` is not satisfied fn check() {} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr index 1219d5f04380..ca2a693d48ce 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr @@ -27,12 +27,10 @@ note: required by a bound in `ConstParamTy_` --> $SRC_DIR/core/src/marker.rs:LL:COL error[E0277]: the trait bound `CantParamDerive: Eq` is not satisfied - --> $DIR/const_param_ty_impl_no_structural_eq.rs:15:8 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 | LL | #[derive(std::marker::ConstParamTy)] - | ------------------------- in this derive macro expansion -LL | struct CantParamDerive(ImplementsConstParamTy); - | ^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive` | note: required by a bound in `ConstParamTy_` --> $SRC_DIR/core/src/marker.rs:LL:COL @@ -43,15 +41,13 @@ LL | struct CantParamDerive(ImplementsConstParamTy); | error[E0277]: the type `CantParamDerive` does not `#[derive(PartialEq)]` - --> $DIR/const_param_ty_impl_no_structural_eq.rs:15:8 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 | LL | #[derive(std::marker::ConstParamTy)] - | ------------------------- in this derive macro expansion -LL | struct CantParamDerive(ImplementsConstParamTy); - | ^^^^^^^^^^^^^^^ unsatisfied trait bound + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | help: the nightly-only, unstable trait `StructuralPartialEq` is not implemented for `CantParamDerive` - --> $DIR/const_param_ty_impl_no_structural_eq.rs:15:1 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:17:1 | LL | struct CantParamDerive(ImplementsConstParamTy); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/adt_const_params/mismatch-raw-ptr-in-adt.stderr b/tests/ui/const-generics/adt_const_params/mismatch-raw-ptr-in-adt.stderr index d7eec45bae0f..717e680ee536 100644 --- a/tests/ui/const-generics/adt_const_params/mismatch-raw-ptr-in-adt.stderr +++ b/tests/ui/const-generics/adt_const_params/mismatch-raw-ptr-in-adt.stderr @@ -7,15 +7,6 @@ LL | struct ConstBytes; = note: `*mut u8` must implement `ConstParamTy_`, but it does not = note: `[*mut u8; 3]` must implement `ConstParamTy_`, but it does not -error[E0308]: mismatched types - --> $DIR/mismatch-raw-ptr-in-adt.rs:9:23 - | -LL | let _: ConstBytes = ConstBytes::; - | ^^^^^^ expected `&[*mut u8; 3]`, found `&[u8; 3]` - | - = note: expected reference `&'static [*mut u8; 3]` - found reference `&'static [u8; 3]` - error[E0308]: mismatched types --> $DIR/mismatch-raw-ptr-in-adt.rs:9:46 | @@ -25,6 +16,15 @@ LL | let _: ConstBytes = ConstBytes::; = note: expected reference `&'static [*mut u8; 3]` found reference `&'static [u8; 3]` +error[E0308]: mismatched types + --> $DIR/mismatch-raw-ptr-in-adt.rs:9:23 + | +LL | let _: ConstBytes = ConstBytes::; + | ^^^^^^ expected `&[*mut u8; 3]`, found `&[u8; 3]` + | + = note: expected reference `&'static [*mut u8; 3]` + found reference `&'static [u8; 3]` + error: aborting due to 3 previous errors Some errors have detailed explanations: E0308, E0741. diff --git a/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs index e8a16be2197b..d42ef90e1b18 100644 --- a/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs +++ b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs @@ -4,15 +4,15 @@ use std::marker::ConstParamTy; #[derive(ConstParamTy)] +//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty struct Foo([*const u8; 1]); -//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty #[derive(ConstParamTy)] +//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty struct Foo2([*mut u8; 1]); -//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty #[derive(ConstParamTy)] -struct Foo3([fn(); 1]); //~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty +struct Foo3([fn(); 1]); fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr index 6c8a506d1f40..442ec6b96cef 100644 --- a/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr +++ b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr @@ -1,41 +1,44 @@ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/nested_bad_const_param_ty.rs:7:8 + --> $DIR/nested_bad_const_param_ty.rs:6:10 | LL | #[derive(ConstParamTy)] - | ------------ in this derive macro expansion + | ^^^^^^^^^^^^ +LL | LL | struct Foo([*const u8; 1]); - | ^^^ -------------- this field does not implement `ConstParamTy_` + | -------------- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy_` - --> $DIR/nested_bad_const_param_ty.rs:7:12 + --> $DIR/nested_bad_const_param_ty.rs:8:12 | LL | struct Foo([*const u8; 1]); | ^^^^^^^^^^^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/nested_bad_const_param_ty.rs:11:8 + --> $DIR/nested_bad_const_param_ty.rs:10:10 | LL | #[derive(ConstParamTy)] - | ------------ in this derive macro expansion + | ^^^^^^^^^^^^ +LL | LL | struct Foo2([*mut u8; 1]); - | ^^^^ ------------ this field does not implement `ConstParamTy_` + | ------------ this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy_` - --> $DIR/nested_bad_const_param_ty.rs:11:13 + --> $DIR/nested_bad_const_param_ty.rs:12:13 | LL | struct Foo2([*mut u8; 1]); | ^^^^^^^^^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/nested_bad_const_param_ty.rs:15:8 + --> $DIR/nested_bad_const_param_ty.rs:14:10 | LL | #[derive(ConstParamTy)] - | ------------ in this derive macro expansion + | ^^^^^^^^^^^^ +LL | LL | struct Foo3([fn(); 1]); - | ^^^^ --------- this field does not implement `ConstParamTy_` + | --------- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `[fn(); 1]` requires that `fn(): ConstParamTy_` - --> $DIR/nested_bad_const_param_ty.rs:15:13 + --> $DIR/nested_bad_const_param_ty.rs:16:13 | LL | struct Foo3([fn(); 1]); | ^^^^^^^^^ diff --git a/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.rs b/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.rs index e364368b8a4c..6b87ad86d4bc 100644 --- a/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.rs +++ b/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.rs @@ -1,4 +1,4 @@ -#![feature(adt_const_params, generic_const_exprs, unsized_const_params)] +#![feature(generic_const_exprs, unsized_const_params)] #![allow(incomplete_features)] // Regression test for 128232 diff --git a/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.stderr b/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.stderr index b13f76eabadb..72dfda50ea5c 100644 --- a/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.stderr +++ b/tests/ui/const-generics/adt_const_params/non_valtreeable_const_arg-2.stderr @@ -9,11 +9,13 @@ help: you might be missing a const parameter LL | impl Wrapper<{ bar() }> { | +++++++++++++++++++++++ -error[E0741]: using function pointers as const generic parameters is forbidden +error: using function pointers as const generic parameters is forbidden --> $DIR/non_valtreeable_const_arg-2.rs:8:25 | LL | struct Wrapper; | ^^^^ + | + = note: the only supported types are integers, `bool`, and `char` error[E0599]: the function or associated item `call` exists for struct `Wrapper`, but its trait bounds were not satisfied --> $DIR/non_valtreeable_const_arg-2.rs:17:26 @@ -35,5 +37,5 @@ note: the trait `Fn` must be implemented error: aborting due to 3 previous errors -Some errors have detailed explanations: E0425, E0599, E0741. +Some errors have detailed explanations: E0425, E0599. For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-1.rs b/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-1.rs deleted file mode 100644 index 17910d52d3d7..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-1.rs +++ /dev/null @@ -1,22 +0,0 @@ -// regression test for issue #137582, where constant evaluating an unsized AnonConst would ICE - -#![feature(adt_const_params)] - -mod lib { - pub type Matrix = [&'static u32]; - - const EMPTY_MATRIX: Matrix = [[0; 4]; 4]; - //~^ ERROR the size for values of type `[&'static u32]` cannot be known at compilation time - //~| ERROR mismatched types - //~| ERROR mismatched types - - pub struct Walk { - //~^ ERROR use of unstable library feature `unsized_const_params` - _p: (), - } - - impl Walk {} - //~^ ERROR the size for values of type `[&'static u32]` cannot be known at compilation time -} - -fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-1.stderr b/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-1.stderr deleted file mode 100644 index daea55efbbc7..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-1.stderr +++ /dev/null @@ -1,44 +0,0 @@ -error[E0277]: the size for values of type `[&'static u32]` cannot be known at compilation time - --> $DIR/unsized-anon-const-err-1.rs:8:25 - | -LL | const EMPTY_MATRIX: Matrix = [[0; 4]; 4]; - | ^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[&'static u32]` - = note: statics and constants must have a statically known size - -error[E0658]: use of unstable library feature `unsized_const_params` - --> $DIR/unsized-anon-const-err-1.rs:13:43 - | -LL | pub struct Walk { - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(unsized_const_params)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required for `[&'static u32]` to implement `ConstParamTy_` - -error[E0277]: the size for values of type `[&'static u32]` cannot be known at compilation time - --> $DIR/unsized-anon-const-err-1.rs:18:46 - | -LL | impl Walk {} - | ^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[&'static u32]` - = note: statics and constants must have a statically known size - -error[E0308]: mismatched types - --> $DIR/unsized-anon-const-err-1.rs:8:35 - | -LL | const EMPTY_MATRIX: Matrix = [[0; 4]; 4]; - | ^^^^^^ expected `&u32`, found `[{integer}; 4]` - -error[E0308]: mismatched types - --> $DIR/unsized-anon-const-err-1.rs:8:34 - | -LL | const EMPTY_MATRIX: Matrix = [[0; 4]; 4]; - | ^^^^^^^^^^^ expected `[&u32]`, found `[&u32; 4]` - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0277, E0308, E0658. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.rs b/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.rs deleted file mode 100644 index 81b1ec6a7719..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// regression test for issue #151591, where constant evaluating an unsized AnonConst would ICE - -#![feature(adt_const_params)] -#![feature(unsized_const_params)] -//~^ WARN the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes - -#[derive(Clone)] -struct S; - -const A: [u8]; -//~^ ERROR free constant item without body -//~| ERROR the size for values of type `[u8]` cannot be known at compilation time - -impl Copy for S {} -//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time -//~| ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates -impl Copy for S {} -//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time -//~| ERROR the const parameter `M` is not constrained by the impl trait, self type, or predicates - -fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.stderr b/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.stderr deleted file mode 100644 index d538bb0af09a..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error: free constant item without body - --> $DIR/unsized-anon-const-err-2.rs:10:1 - | -LL | const A: [u8]; - | ^^^^^^^^^^^^^- - | | - | help: provide a definition for the constant: `= ;` - -warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-anon-const-err-2.rs:4:12 - | -LL | #![feature(unsized_const_params)] - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #95174 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-anon-const-err-2.rs:10:10 - | -LL | const A: [u8]; - | ^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: statics and constants must have a statically known size - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-anon-const-err-2.rs:14:31 - | -LL | impl Copy for S {} - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: statics and constants must have a statically known size - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-anon-const-err-2.rs:17:33 - | -LL | impl Copy for S {} - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: statics and constants must have a statically known size - -error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/unsized-anon-const-err-2.rs:14:6 - | -LL | impl Copy for S {} - | ^^^^^^^^^^^^ unconstrained const parameter - | - = note: expressions using a const parameter must map each value to a distinct output value - = note: proving the result of expressions other than the parameter are unique is not supported - -error[E0207]: the const parameter `M` is not constrained by the impl trait, self type, or predicates - --> $DIR/unsized-anon-const-err-2.rs:17:6 - | -LL | impl Copy for S {} - | ^^^^^^^^^^^^^^ unconstrained const parameter - | - = note: expressions using a const parameter must map each value to a distinct output value - = note: proving the result of expressions other than the parameter are unique is not supported - -error: aborting due to 6 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0207, E0277. -For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-func-err.rs b/tests/ui/const-generics/adt_const_params/unsized-anon-const-func-err.rs deleted file mode 100644 index a299cc29fcc5..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-func-err.rs +++ /dev/null @@ -1,16 +0,0 @@ -// manually reduced reproduction of issue #137582, where constant evaluating an unsized AnonConst -// would ICE - -#![feature(adt_const_params)] - -fn func() {} -//~^ ERROR use of unstable library feature `unsized_const_params` - -const VALUE: [u32] = [0; 4]; -//~^ ERROR mismatched types -//~| ERROR the size for values of type `[u32]` cannot be known at compilation time - -fn main() { - func::(); - //~^ ERROR the size for values of type `[u32]` cannot be known at compilation time -} diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-func-err.stderr b/tests/ui/const-generics/adt_const_params/unsized-anon-const-func-err.stderr deleted file mode 100644 index 14a41e87e4aa..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-func-err.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0658]: use of unstable library feature `unsized_const_params` - --> $DIR/unsized-anon-const-func-err.rs:6:9 - | -LL | fn func() {} - | ^^^^^^^^^^^^^^ - | - = help: add `#![feature(unsized_const_params)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required for `[u32]` to implement `ConstParamTy_` - -error[E0277]: the size for values of type `[u32]` cannot be known at compilation time - --> $DIR/unsized-anon-const-func-err.rs:9:14 - | -LL | const VALUE: [u32] = [0; 4]; - | ^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u32]` - = note: statics and constants must have a statically known size - -error[E0308]: mismatched types - --> $DIR/unsized-anon-const-func-err.rs:9:22 - | -LL | const VALUE: [u32] = [0; 4]; - | ^^^^^^ expected `[u32]`, found `[u32; 4]` - -error[E0277]: the size for values of type `[u32]` cannot be known at compilation time - --> $DIR/unsized-anon-const-func-err.rs:14:12 - | -LL | func::(); - | ^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u32]` - = note: statics and constants must have a statically known size - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0308, E0658. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-struct-err.rs b/tests/ui/const-generics/adt_const_params/unsized-anon-const-struct-err.rs deleted file mode 100644 index 35407d02f6ef..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-struct-err.rs +++ /dev/null @@ -1,16 +0,0 @@ -// manually reduced reproduction of issue #137582, where constant evaluating an unsized AnonConst -// would ICE - -#![feature(adt_const_params)] - -const VALUE: [u32] = [0; 4]; -//~^ ERROR the size for values of type `[u32]` cannot be known at compilation time -//~| ERROR mismatched types - -struct SomeStruct {} -//~^ ERROR use of unstable library feature `unsized_const_params` - -impl SomeStruct {} -//~^ ERROR the size for values of type `[u32]` cannot be known at compilation time - -fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/unsized-anon-const-struct-err.stderr b/tests/ui/const-generics/adt_const_params/unsized-anon-const-struct-err.stderr deleted file mode 100644 index d9a13976d68a..000000000000 --- a/tests/ui/const-generics/adt_const_params/unsized-anon-const-struct-err.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0277]: the size for values of type `[u32]` cannot be known at compilation time - --> $DIR/unsized-anon-const-struct-err.rs:6:14 - | -LL | const VALUE: [u32] = [0; 4]; - | ^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u32]` - = note: statics and constants must have a statically known size - -error[E0658]: use of unstable library feature `unsized_const_params` - --> $DIR/unsized-anon-const-struct-err.rs:10:19 - | -LL | struct SomeStruct {} - | ^^^^^^^^^^^^^^ - | - = help: add `#![feature(unsized_const_params)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required for `[u32]` to implement `ConstParamTy_` - -error[E0277]: the size for values of type `[u32]` cannot be known at compilation time - --> $DIR/unsized-anon-const-struct-err.rs:13:17 - | -LL | impl SomeStruct {} - | ^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u32]` - = note: statics and constants must have a statically known size - -error[E0308]: mismatched types - --> $DIR/unsized-anon-const-struct-err.rs:6:22 - | -LL | const VALUE: [u32] = [0; 4]; - | ^^^^^^ expected `[u32]`, found `[u32; 4]` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0308, E0658. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/unsized_field-1.rs b/tests/ui/const-generics/adt_const_params/unsized_field-1.rs index f2d972612dc6..5db031cb900f 100644 --- a/tests/ui/const-generics/adt_const_params/unsized_field-1.rs +++ b/tests/ui/const-generics/adt_const_params/unsized_field-1.rs @@ -6,18 +6,18 @@ extern crate unsized_const_param; use std::marker::ConstParamTy; #[derive(ConstParamTy, Eq, PartialEq)] -struct A([u8]); //~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type +struct A([u8]); #[derive(ConstParamTy, Eq, PartialEq)] -struct B(&'static [u8]); //~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type +struct B(&'static [u8]); #[derive(ConstParamTy, Eq, PartialEq)] struct C(unsized_const_param::Foo); #[derive(std::marker::ConstParamTy, Eq, PartialEq)] -struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>); //~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type +struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>); fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr b/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr index 2538b811618b..134dbba0d63a 100644 --- a/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr +++ b/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr @@ -1,41 +1,44 @@ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsized_field-1.rs:9:8 + --> $DIR/unsized_field-1.rs:8:10 | LL | #[derive(ConstParamTy, Eq, PartialEq)] - | ------------ in this derive macro expansion + | ^^^^^^^^^^^^ +LL | LL | struct A([u8]); - | ^ ---- this field does not implement `ConstParamTy_` + | ---- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `[u8]` requires that `feature(unsized_const_params) is enabled` - --> $DIR/unsized_field-1.rs:9:10 + --> $DIR/unsized_field-1.rs:10:10 | LL | struct A([u8]); | ^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsized_field-1.rs:13:8 + --> $DIR/unsized_field-1.rs:12:10 | LL | #[derive(ConstParamTy, Eq, PartialEq)] - | ------------ in this derive macro expansion + | ^^^^^^^^^^^^ +LL | LL | struct B(&'static [u8]); - | ^ ------------- this field does not implement `ConstParamTy_` + | ------------- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `&'static [u8]` requires that `feature(unsized_const_params) is enabled` - --> $DIR/unsized_field-1.rs:13:10 + --> $DIR/unsized_field-1.rs:14:10 | LL | struct B(&'static [u8]); | ^^^^^^^^^^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsized_field-1.rs:20:8 + --> $DIR/unsized_field-1.rs:19:10 | LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)] - | ------------------------- in this derive macro expansion + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>); - | ^ ---------------------------------------------------------- this field does not implement `ConstParamTy_` + | ---------------------------------------------------------- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `GenericNotUnsizedParam<&'static [u8]>` requires that `feature(unsized_const_params) is enabled` - --> $DIR/unsized_field-1.rs:20:10 + --> $DIR/unsized_field-1.rs:21:10 | LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.rs b/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.rs index 71ac662cf580..500e8e22b0e3 100644 --- a/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.rs +++ b/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.rs @@ -6,8 +6,8 @@ use std::marker::ConstParamTy; #[derive(Debug, PartialEq, Eq, ConstParamTy)] -struct Foo { //~^ ERROR the trait `ConstParamTy_` +struct Foo { nested: &'static Bar, //~^ ERROR the size for values //~| ERROR the size for values diff --git a/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.stderr b/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.stderr index f520413927c3..af29eaa35cb6 100644 --- a/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.stderr +++ b/tests/ui/const-generics/adt_const_params/unsizing-wfcheck-issue-126272.stderr @@ -19,13 +19,11 @@ LL | struct Bar(T); | this could be changed to `T: ?Sized`... error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsizing-wfcheck-issue-126272.rs:9:8 + --> $DIR/unsizing-wfcheck-issue-126272.rs:8:32 | LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)] - | ------------ in this derive macro expansion -LL | struct Foo { - | ^^^ -LL | + | ^^^^^^^^^^^^ +... LL | nested: &'static Bar, | ----------------------------------------- this field does not implement `ConstParamTy_` | @@ -61,13 +59,12 @@ help: the trait `Debug` is implemented for `Bar` LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)] | ^^^^^ note: required for `Bar<(dyn Debug + 'static)>` to implement `Debug` - --> $DIR/unsizing-wfcheck-issue-126272.rs:20:8 + --> $DIR/unsizing-wfcheck-issue-126272.rs:19:10 | LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)] - | ----- in this derive macro expansion + | ^^^^^ LL | struct Bar(T); - | ^^^ - unsatisfied trait bound - = help: consider manually implementing `Debug` to avoid undesired bounds + | - unsatisfied trait bound introduced in this `derive` macro = note: 2 redundant requirements hidden = note: required for `&&'static Bar<(dyn Debug + 'static)>` to implement `Debug` = note: required for the cast from `&&&'static Bar<(dyn Debug + 'static)>` to `&dyn Debug` @@ -96,16 +93,13 @@ help: the trait `Eq` is implemented for `Bar` LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)] | ^^ note: required for `Bar` to implement `Eq` - --> $DIR/unsizing-wfcheck-issue-126272.rs:20:8 + --> $DIR/unsizing-wfcheck-issue-126272.rs:19:28 | LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)] - | -- in this derive macro expansion -LL | struct Bar(T); - | ^^^ - type parameter would need to implement `Eq` - = help: consider manually implementing `Eq` to avoid undesired bounds + | ^^ unsatisfied trait bound introduced in this `derive` macro = note: 1 redundant requirement hidden = note: required for `&'static Bar` to implement `Eq` -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time diff --git a/tests/ui/const-generics/associated-const-bindings/ambiguity.rs b/tests/ui/const-generics/associated-const-bindings/ambiguity.rs index 6871a028de5f..6bc2a6d5d153 100644 --- a/tests/ui/const-generics/associated-const-bindings/ambiguity.rs +++ b/tests/ui/const-generics/associated-const-bindings/ambiguity.rs @@ -1,12 +1,13 @@ // We used to say "ambiguous associated type" on ambiguous associated consts. // Ensure that we now use the correct label. -#![feature(adt_const_params, min_generic_const_args, unsized_const_params)] +#![feature(min_generic_const_args, unsized_const_params)] #![allow(incomplete_features)] trait Trait0: Parent0 + Parent0 {} trait Parent0 { - type const K: (); + #[type_const] + const K: (); } fn take0(_: impl Trait0) {} @@ -14,10 +15,12 @@ fn take0(_: impl Trait0) {} trait Trait1: Parent1 + Parent2 {} trait Parent1 { - type const C: i32; + #[type_const] + const C: i32; } trait Parent2 { - type const C: &'static str; + #[type_const] + const C: &'static str; } fn take1(_: impl Trait1) {} diff --git a/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr b/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr index 9dcb30d6b737..806708f18d65 100644 --- a/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr +++ b/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr @@ -1,8 +1,8 @@ error[E0222]: ambiguous associated constant `K` in bounds of `Trait0` - --> $DIR/ambiguity.rs:12:25 + --> $DIR/ambiguity.rs:13:25 | -LL | type const K: (); - | ---------------- +LL | const K: (); + | ----------- | | | ambiguous `K` from `Parent0` | ambiguous `K` from `Parent0` @@ -17,13 +17,13 @@ LL | fn take0(_: impl Trait0) {} T: Parent0::K = const { } error[E0222]: ambiguous associated constant `C` in bounds of `Trait1` - --> $DIR/ambiguity.rs:23:25 + --> $DIR/ambiguity.rs:26:25 | -LL | type const C: i32; - | ----------------- ambiguous `C` from `Parent1` +LL | const C: i32; + | ------------ ambiguous `C` from `Parent1` ... -LL | type const C: &'static str; - | -------------------------- ambiguous `C` from `Parent2` +LL | const C: &'static str; + | --------------------- ambiguous `C` from `Parent2` ... LL | fn take1(_: impl Trait1) {} | ^^^^^^^ ambiguous associated constant `C` diff --git a/tests/ui/const-generics/associated-const-bindings/assoc-const.rs b/tests/ui/const-generics/associated-const-bindings/assoc-const.rs index 3f8353b6914d..ac9f7e53b3cb 100644 --- a/tests/ui/const-generics/associated-const-bindings/assoc-const.rs +++ b/tests/ui/const-generics/associated-const-bindings/assoc-const.rs @@ -3,13 +3,15 @@ #![allow(unused, incomplete_features)] pub trait Foo { - type const N: usize; + #[type_const] + const N: usize; } pub struct Bar; impl Foo for Bar { - type const N: usize = 3; + #[type_const] + const N: usize = 3; } const TEST: usize = 3; diff --git a/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.rs b/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.rs index 53f65319db9d..803cc59cc93d 100644 --- a/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.rs +++ b/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.rs @@ -11,7 +11,8 @@ use std::marker::ConstParamTy_; trait Trait { - type const K: T; + #[type_const] + const K: T; } fn take( diff --git a/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.stderr b/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.stderr index f2f69aad4ee6..a4f97525b515 100644 --- a/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.stderr +++ b/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty-not-wf.stderr @@ -1,11 +1,11 @@ error: higher-ranked subtype error - --> $DIR/bound-var-in-ty-not-wf.rs:20:13 + --> $DIR/bound-var-in-ty-not-wf.rs:21:13 | LL | K = const { () } | ^^^^^^^^^^^^ error: higher-ranked subtype error - --> $DIR/bound-var-in-ty-not-wf.rs:20:13 + --> $DIR/bound-var-in-ty-not-wf.rs:21:13 | LL | K = const { () } | ^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty.rs b/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty.rs index a509fe0d52e3..e6fd5bdad002 100644 --- a/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty.rs +++ b/tests/ui/const-generics/associated-const-bindings/bound-var-in-ty.rs @@ -14,7 +14,8 @@ use std::marker::ConstParamTy_; trait Trait { - type const K: T; + #[type_const] + const K: T; } fn take( diff --git a/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs b/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs index 149755bad4ca..004215986711 100644 --- a/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs +++ b/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs @@ -5,18 +5,20 @@ //@ check-pass -#![feature(adt_const_params, min_generic_const_args, unsized_const_params)] +#![feature(min_generic_const_args, unsized_const_params)] #![allow(incomplete_features)] trait Trait: SuperTrait { type N; type Q; - type const N: usize; + #[type_const] + const N: usize; } trait SuperTrait { - type const Q: &'static str; + #[type_const] + const Q: &'static str; } fn take0(_: impl Trait) {} diff --git a/tests/ui/const-generics/associated-const-bindings/coherence.rs b/tests/ui/const-generics/associated-const-bindings/coherence.rs index e9296f3a8df0..f4081fae6144 100644 --- a/tests/ui/const-generics/associated-const-bindings/coherence.rs +++ b/tests/ui/const-generics/associated-const-bindings/coherence.rs @@ -2,10 +2,12 @@ #![expect(incomplete_features)] pub trait IsVoid { - type const IS_VOID: bool; + #[type_const] + const IS_VOID: bool; } impl IsVoid for () { - type const IS_VOID: bool = true; + #[type_const] + const IS_VOID: bool = true; } pub trait Maybe {} diff --git a/tests/ui/const-generics/associated-const-bindings/coherence.stderr b/tests/ui/const-generics/associated-const-bindings/coherence.stderr index df6781f2f9a2..23d6495a16a4 100644 --- a/tests/ui/const-generics/associated-const-bindings/coherence.stderr +++ b/tests/ui/const-generics/associated-const-bindings/coherence.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Maybe` for type `()` - --> $DIR/coherence.rs:13:1 + --> $DIR/coherence.rs:15:1 | LL | impl Maybe for () {} | ----------------- first implementation here diff --git a/tests/ui/const-generics/associated-const-bindings/const-projection-err.rs b/tests/ui/const-generics/associated-const-bindings/const-projection-err.rs index 8e871ddf90ce..d485316ce371 100644 --- a/tests/ui/const-generics/associated-const-bindings/const-projection-err.rs +++ b/tests/ui/const-generics/associated-const-bindings/const-projection-err.rs @@ -2,7 +2,8 @@ #![allow(incomplete_features)] trait TraitWAssocConst { - type const A: usize; + #[type_const] + const A: usize; } fn foo>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/const-projection-err.stderr b/tests/ui/const-generics/associated-const-bindings/const-projection-err.stderr index c533a7d65b90..552b1579e618 100644 --- a/tests/ui/const-generics/associated-const-bindings/const-projection-err.stderr +++ b/tests/ui/const-generics/associated-const-bindings/const-projection-err.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `::A == 1` - --> $DIR/const-projection-err.rs:11:11 + --> $DIR/const-projection-err.rs:12:11 | LL | foo::(); | ^ expected `1`, found `0` @@ -7,7 +7,7 @@ LL | foo::(); = note: expected constant `1` found constant `0` note: required by a bound in `foo` - --> $DIR/const-projection-err.rs:8:28 + --> $DIR/const-projection-err.rs:9:28 | LL | fn foo>() {} | ^^^^^ required by this bound in `foo` diff --git a/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs b/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs index 578904ea1891..161eef63d36f 100644 --- a/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs +++ b/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs @@ -8,7 +8,8 @@ #![allow(incomplete_features)] pub trait TraitA { - type const K: u8 = 0; + #[type_const] + const K: u8 = 0; } pub trait TraitB {} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-assoc-const-ty-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-assoc-const-ty-mentions-self.rs deleted file mode 100644 index 771f48cba068..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-assoc-const-ty-mentions-self.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Ensure that we consider traits dyn *in*compatible if the type of any (type) assoc const -// mentions `Self` (barring "`Self` projections") - -//@ dont-require-annotations: NOTE - -#![feature(adt_const_params)] -#![feature(generic_const_items)] -#![feature(generic_const_parameter_types)] -#![feature(min_generic_const_args)] -#![feature(unsized_const_params)] -#![expect(incomplete_features)] - -trait Trait { - // NOTE: The `ConstParamTy_` bound is intentionally on the assoc const and not on the trait as - // doing the latter would already render the trait dyn incompatible due to it being - // bounded by `PartialEq` and supertrait bounds cannot mention `Self` like this. - type const K: Self where Self: std::marker::ConstParamTy_; - //~^ NOTE it contains associated const `K` whose type references the `Self` type - - // This is not a "`Self` projection" in our sense (which would be allowed) - // since the trait is not the principal trait or a supertrait thereof. - type const Q: ::Output; - //~^ NOTE it contains associated const `Q` whose type references the `Self` type -} - -trait SomeOtherTrait { - type Output: std::marker::ConstParamTy_; -} - -// You could imagine this impl being more interesting and mention `T` somewhere in `Output`... -impl SomeOtherTrait for T { - type Output = (); -} - -fn main() { - let _: dyn Trait; //~ ERROR the trait `Trait` is not dyn compatible -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-assoc-const-ty-mentions-self.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-assoc-const-ty-mentions-self.stderr deleted file mode 100644 index 19cd8bf5af99..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-assoc-const-ty-mentions-self.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/dyn-compat-assoc-const-ty-mentions-self.rs:36:16 - | -LL | let _: dyn Trait; - | ^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compat-assoc-const-ty-mentions-self.rs:17:16 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -... -LL | type const K: Self where Self: std::marker::ConstParamTy_; - | ^ ...because it contains associated const `K` whose type references the `Self` type -... -LL | type const Q: ::Output; - | ^ ...because it contains associated const `Q` whose type references the `Self` type - = help: consider moving `K` to another trait - = help: consider moving `Q` to another trait - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs deleted file mode 100644 index 8de8cb1a60db..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Traits with type associated consts are dyn compatible. -// Check that we allow the corresp. trait object types if all assoc consts are specified. - -//@ check-pass - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait: SuperTrait { - type const K: usize; -} - -trait SuperTrait { - type const Q: usize; - type const C: usize; -} - -trait Bound { - type const N: usize; -} - -impl Bound for () { - type const N: usize = 10; -} - -fn main() { - let _: dyn Trait; - - let obj: &dyn Bound = &(); - _ = identity(obj); - - fn identity(x: &(impl ?Sized + Bound)) -> &(impl ?Sized + Bound) { x } -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs deleted file mode 100644 index ad5c4b679117..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Ensure that we actually enforce equality constraints found in trait object types. - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { - type const N: usize; -} - -impl Trait for () { - type const N: usize = 1; -} - -fn main() { - let _: &dyn Trait = &(); //~ ERROR type mismatch resolving `<() as Trait>::N == 0` -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr deleted file mode 100644 index 282504e3bc35..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0271]: type mismatch resolving `<() as Trait>::N == 0` - --> $DIR/dyn-compat-const-mismatch.rs:15:32 - | -LL | let _: &dyn Trait = &(); - | ^^^ expected `0`, found `1` - | - = note: expected constant `0` - found constant `1` - = note: required for the cast from `&()` to `&dyn Trait` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs deleted file mode 100644 index 8130960195d9..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Test that we force users to explicitly specify const arguments for const parameters that -// have defaults if the default mentions the `Self` type parameter. - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait X::N }> {} - -trait Y { - type const N: usize; -} - -impl Y for T { - type const N: usize = 1; -} - -fn main() { - let _: dyn X; //~ ERROR the const parameter `N` must be explicitly specified -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr deleted file mode 100644 index a22545fcd8d2..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0393]: the const parameter `N` must be explicitly specified - --> $DIR/dyn-compat-const-param-default-mentions-self.rs:18:16 - | -LL | trait X::N }> {} - | -------------------------------------------- const parameter `N` must be specified for this -... -LL | let _: dyn X; - | ^ - | - = note: because the parameter default references `Self`, the parameter must be specified on the trait object type -help: explicitly specify the const parameter - | -LL | let _: dyn X; - | +++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0393`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs deleted file mode 100644 index 9564903dce5b..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Check that we reject const projections behind trait aliases that mention `Self`. -// The code below is pretty artifical and contains a type mismatch anyway but we still need to -// reject it & lower the `Self` ty param to a `{type error}` to avoid ICEs down the line. -// -// The author of the trait object type can't fix this unlike the supertrait bound -// equivalent where they just need to explicitly specify the assoc const. - -#![feature(min_generic_const_args, trait_alias)] -#![expect(incomplete_features)] - -trait Trait { - type const Y: i32; -} - -struct Hold(T); - -trait Bound = Trait }>; -//~^ ERROR the constant `Hold::` is not of type `i32` - -fn main() { - let _: dyn Bound; //~ ERROR associated constant binding in trait object type mentions `Self` -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.stderr deleted file mode 100644 index 699b9192cf93..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: the constant `Hold::` is not of type `i32` - --> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:17:21 - | -LL | trait Bound = Trait }>; - | ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct constructor - | -note: required by a const generic parameter in `Bound` - --> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:17:21 - | -LL | trait Bound = Trait }>; - | ^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `Bound` - -error: associated constant binding in trait object type mentions `Self` - --> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:21:12 - | -LL | trait Bound = Trait }>; - | -------------------- this binding mentions `Self` -... -LL | let _: dyn Bound; - | ^^^^^^^^^ contains a mention of `Self` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs deleted file mode 100644 index 560a1b7f3f7a..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Test that we force users to explicitly specify associated constants (via bindings) -// which reference the `Self` type parameter. - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait X: Y { - type const Q: usize; -} - -trait Y { - type const K: usize; -} - -fn main() { - let _: dyn X; - //~^ ERROR the value of the associated constant `K` in `Y` must be specified -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.stderr deleted file mode 100644 index dae9e3d8c22b..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0191]: the value of the associated constant `K` in `Y` must be specified - --> $DIR/dyn-compat-const-projection-from-supertrait-mentions-self.rs:16:16 - | -LL | type const K: usize; - | ------------------- `K` defined here -... -LL | let _: dyn X; - | ^^^^^^^^^ help: specify the associated constant: `X` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-generic-assoc-const.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-generic-assoc-const.rs deleted file mode 100644 index 05e8aeea5ed5..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-generic-assoc-const.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Ensure that traits with generic associated consts (GACs) are dyn *in*compatible. -// It would be very hard to make dyn Trait with GACs sound just like with GATs. - -//@ dont-require-annotations: NOTE - -#![feature(min_generic_const_args, generic_const_items)] -#![expect(incomplete_features)] - -trait Trait { - const POLY: T; - //~^ NOTE it contains generic associated const `POLY` -} - -fn main() { - let _: dyn Trait; //~ ERROR the trait `Trait` is not dyn compatible -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-generic-assoc-const.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-generic-assoc-const.stderr deleted file mode 100644 index ed187e0287e9..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-generic-assoc-const.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/dyn-compat-generic-assoc-const.rs:15:16 - | -LL | let _: dyn Trait; - | ^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compat-generic-assoc-const.rs:10:11 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | const POLY: T; - | ^^^^ ...because it contains generic associated const `POLY` - = help: consider moving `POLY` to another trait - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-non-type-assoc-const.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-non-type-assoc-const.rs deleted file mode 100644 index 38d593984724..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-non-type-assoc-const.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Ensure that traits with non-type associated consts are dyn *in*compatible. - -//@ dont-require-annotations: NOTE - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { - const K: usize; - //~^ NOTE it contains associated const `K` that's not defined as `type const` -} - -fn main() { - let _: dyn Trait; //~ ERROR the trait `Trait` is not dyn compatible - - // Check that specifying the non-type assoc const doesn't "magically make it work". - let _: dyn Trait; - //~^ ERROR the trait `Trait` is not dyn compatible - //~| ERROR use of trait associated const not defined as `type const` -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-non-type-assoc-const.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-non-type-assoc-const.stderr deleted file mode 100644 index 5bc072e98c0f..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-non-type-assoc-const.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/dyn-compat-non-type-assoc-const.rs:14:16 - | -LL | let _: dyn Trait; - | ^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compat-non-type-assoc-const.rs:9:11 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | const K: usize; - | ^ ...because it contains associated const `K` that's not defined as `type const` - = help: consider moving `K` to another trait - -error: use of trait associated const not defined as `type const` - --> $DIR/dyn-compat-non-type-assoc-const.rs:17:22 - | -LL | let _: dyn Trait; - | ^^^^^ - | - = note: the declaration in the trait must begin with `type const` not just `const` alone - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/dyn-compat-non-type-assoc-const.rs:17:16 - | -LL | let _: dyn Trait; - | ^^^^^^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compat-non-type-assoc-const.rs:9:11 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | const K: usize; - | ^ ...because it contains associated const `K` that's not defined as `type const` - = help: consider moving `K` to another trait - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs deleted file mode 100644 index 03f1a526b73a..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Ensure that the where-clause of assoc consts in dyn-compatible traits are allowed to freely -// reference the `Self` type parameter (contrary to methods) and that such where clauses are -// actually enforced. - -#![feature(min_generic_const_args, generic_const_items)] -#![expect(incomplete_features)] - -trait Trait { - type const N: i32 where Self: Bound; -} - -impl Trait for () { - type const N: i32 = 0; -} - -trait Bound {} - -fn main() { - let _: dyn Trait; // OK - - let _: &dyn Trait = &(); //~ ERROR the trait bound `(): Bound` is not satisfied -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr deleted file mode 100644 index 21e407f8a861..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0277]: the trait bound `(): Bound` is not satisfied - --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:21:32 - | -LL | let _: &dyn Trait = &(); - | ^^^ the trait `Bound` is not implemented for `()` - | -help: this trait has no implementations, consider adding one - --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:16:1 - | -LL | trait Bound {} - | ^^^^^^^^^^^ -note: required by a bound in `Trait::N` - --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:9:35 - | -LL | type const N: i32 where Self: Bound; - | ^^^^^ required by this bound in `Trait::N` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs deleted file mode 100644 index 623769f5d12f..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs +++ /dev/null @@ -1,35 +0,0 @@ -// FIXME(mgca): Ideally this would compile -- at least if the user annotated the instantiated type -// of the assoc const (but we don't have the syntax for this (yet)). In any case, we -// should not leak `trait_object_dummy_self` (defined as `FreshTy(0)` under the hood) -// to the rest of the compiler and by extension the user via diagnostics. -//@ known-bug: unknown - -#![feature( - adt_const_params, - min_generic_const_args, - unsized_const_params, - generic_const_parameter_types -)] -#![expect(incomplete_features)] - -trait A { - type Ty: std::marker::ConstParamTy_; - type const CT: Self::Ty; -} - -impl A for () { - type Ty = i32; - type const CT: i32 = 0; -} - -fn main() { - // NOTE: As alluded to above, if we can't get the examples below to compile as written, - // we might want to allow the user to manually specify the instantiated type somehow. - // The hypothetical syntax for that *might* look sth. like - // * `dyn A i32 { 0 }>` - // * `dyn A` - - let _: dyn A; - - let _: &dyn A = &(); -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr deleted file mode 100644 index cc08c25906b6..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0277]: the trait bound `FreshTy(0): A` is not satisfied - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:32:33 - | -LL | let _: dyn A; - | ^ the trait `A` is not implemented for `FreshTy(0)` - | -help: the trait `A` is implemented for `()` - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:20:1 - | -LL | impl A for () { - | ^^^^^^^^^^^^^ - -error[E0277]: the trait bound `FreshTy(0): A` is not satisfied - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:34:34 - | -LL | let _: &dyn A = &(); - | ^ the trait `A` is not implemented for `FreshTy(0)` - | -help: the trait `A` is implemented for `()` - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:20:1 - | -LL | impl A for () { - | ^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs deleted file mode 100644 index 9886213743c8..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs +++ /dev/null @@ -1,53 +0,0 @@ -// While mentioning `Self` in the method signature of dyn compatible traits is generally forbidden -// due to type erasure, we can make an exception for const projections from `Self` where the trait -// is the principal trait or a supertrait thereof. That's sound because we force users to specify -// all associated consts in the trait object type, so the projections are all normalizable. -// -// Check that we can define & use dyn compatible traits that reference `Self` const projections. - -// This is a run-pass test to ensure that codegen can actually deal with such method instances -// (e.g., const projections normalize flawlessly to something concrete, symbols get mangled -// properly, the vtable is fine) and simply to ensure that the generated code "received" the -// correct values from the type assoc consts). -//@ run-pass - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { - type const N: usize; - - fn process(&self, _: [u8; Self::N]) -> [u8; Self::N]; -} - -impl Trait for u8 { - type const N: usize = 2; - - fn process(&self, [x, y]: [u8; Self::N]) -> [u8; Self::N] { - [self * x, self + y] - } -} - -impl Trait for [u8; N] { - type const N: usize = N; - - fn process(&self, other: [u8; Self::N]) -> [u8; Self::N] { - let mut result = [0; _]; - for i in 0..Self::N { - result[i] = self[i] + other[i]; - } - result - } -} - -fn main() { - let ops: [Box>; _] = [Box::new(3), Box::new([1, 1])]; - - let mut data = [16, 32]; - - for op in ops { - data = op.process(data); - } - - assert_eq!(data, [49, 36]); -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs deleted file mode 100644 index f2ae98accda5..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Ensure that we reject the `Self` type parameter in supertrait bounds of dyn-compatible traits -// even if they're part of a "`Self` projection" (contrary to method signatures and the type of -// assoc consts). - -//@ dont-require-annotations: NOTE - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait: SuperTrait<{ Self::N }> { -//~^ NOTE it uses `Self` as a type parameter - type const N: usize; -} - -trait SuperTrait {} - -fn main() { - let _: dyn Trait; //~ ERROR the trait `Trait` is not dyn compatible -} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.stderr deleted file mode 100644 index 38c928fd58d7..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/dyn-compat-self-const-projections-in-supertrait-bounds.rs:18:16 - | -LL | let _: dyn Trait; - | ^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compat-self-const-projections-in-supertrait-bounds.rs:10:14 - | -LL | trait Trait: SuperTrait<{ Self::N }> { - | ----- ^^^^^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter - | | - | this trait is not dyn compatible... - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs deleted file mode 100644 index 52ecd42b191d..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Ensure that we can successfully mangle & demangle trait object types w/ assoc const bindings. - -// FIXME(mgca): Legacy mangling still crashes: -// "finding type for [impl], encountered [crate root] with no parent" - -//@ build-fail -//@ revisions: v0 -//\@[legacy] compile-flags: -C symbol-mangling-version=legacy -Z unstable-options -//@ [v0] compile-flags: -C symbol-mangling-version=v0 -//\@[legacy] normalize-stderr: "h[[:xdigit:]]{16}" -> "h[HASH]" -//@ [v0] normalize-stderr: "sym\[.*?\]" -> "sym[HASH]" - -#![feature(min_generic_const_args, rustc_attrs)] -#![expect(incomplete_features)] -#![crate_name = "sym"] - -trait Trait { - type const N: usize; -} - -#[rustc_symbol_name] -//~^ ERROR symbol-name(_RMCs -//~| ERROR demangling(>) -impl dyn Trait {} - -fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr deleted file mode 100644 index 8ca0f73494d3..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: symbol-name(_RMCsCRATE_HASH_3symDNtB_5Traitp1NKj0_EL_) - --> $DIR/dyn-compat-symbol-mangling.rs:21:1 - | -LL | #[rustc_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/dyn-compat-symbol-mangling.rs:21:1 - | -LL | #[rustc_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/dyn-compat-symbol-mangling.rs:21:1 - | -LL | #[rustc_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-unspecified-assoc-consts.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-unspecified-assoc-consts.rs deleted file mode 100644 index 5bd8aa609420..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-unspecified-assoc-consts.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Traits with type associated consts are dyn compatible. However, all associated consts must -// be specified in the corresp. trait object type (barring exceptions) similiar to associated -// types. Check that we reject code that doesn't provide the necessary bindings. - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { - type const K: usize; -} - -// fn ctxt / body -fn main() { - let _: dyn Trait; - //~^ ERROR the value of the associated constant `K` in `Trait` must be specified -} - -// item ctxt / signature / non-body -struct Store(dyn Trait); -//~^ ERROR the value of the associated constant `K` in `Trait` must be specified - -// item ctxt & no wfcking (eager ty alias) -type DynTrait = dyn Trait; -//~^ ERROR the value of the associated constant `K` in `Trait` must be specified diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-unspecified-assoc-consts.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-unspecified-assoc-consts.stderr deleted file mode 100644 index 35fdd7f2751e..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-unspecified-assoc-consts.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0191]: the value of the associated constant `K` in `Trait` must be specified - --> $DIR/dyn-compat-unspecified-assoc-consts.rs:19:18 - | -LL | type const K: usize; - | ------------------- `K` defined here -... -LL | struct Store(dyn Trait); - | ^^^^^ help: specify the associated constant: `Trait` - -error[E0191]: the value of the associated constant `K` in `Trait` must be specified - --> $DIR/dyn-compat-unspecified-assoc-consts.rs:23:21 - | -LL | type const K: usize; - | ------------------- `K` defined here -... -LL | type DynTrait = dyn Trait; - | ^^^^^ help: specify the associated constant: `Trait` - -error[E0191]: the value of the associated constant `K` in `Trait` must be specified - --> $DIR/dyn-compat-unspecified-assoc-consts.rs:14:16 - | -LL | type const K: usize; - | ------------------- `K` defined here -... -LL | let _: dyn Trait; - | ^^^^^ help: specify the associated constant: `Trait` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-const-projection-escaping-bound-vars.rs b/tests/ui/const-generics/associated-const-bindings/dyn-const-projection-escaping-bound-vars.rs deleted file mode 100644 index c2ae86232a02..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/dyn-const-projection-escaping-bound-vars.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Check associated const binding with escaping bound vars doesn't cause ICE -//! (#151642) -//@ check-pass - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait2<'a> { type const ASSOC: i32; } -fn g(_: for<'a> fn(Box>)) {} - -fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs b/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs index f42589f91d15..614ed8c803d4 100644 --- a/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs +++ b/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs @@ -5,34 +5,42 @@ #![deny(dead_code)] trait Tr { - type const I: i32; + #[type_const] + const I: i32; } impl Tr for () { - type const I: i32 = 1; + #[type_const] + const I: i32 = 1; } fn foo() -> impl Tr {} trait Tr2 { - type const J: i32; - type const K: i32; + #[type_const] + const J: i32; + #[type_const] + const K: i32; } impl Tr2 for () { - type const J: i32 = 1; - type const K: i32 = 1; + #[type_const] + const J: i32 = 1; + #[type_const] + const K: i32 = 1; } fn foo2() -> impl Tr2 {} mod t { pub trait Tr3 { - type const L: i32; + #[type_const] + const L: i32; } impl Tr3 for () { - type const L: i32 = 1; + #[type_const] + const L: i32 = 1; } } diff --git a/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs b/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs index e50c13b5d3b5..b7ed8ee39f87 100644 --- a/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs +++ b/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs @@ -7,11 +7,13 @@ // though it contained inference variables, which would cause ICEs. trait Foo { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } impl Foo for () { - type const ASSOC: u32 = N; + #[type_const] + const ASSOC: u32 = N; } fn bar = 10>>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/esc-bound-var-in-ty.rs b/tests/ui/const-generics/associated-const-bindings/esc-bound-var-in-ty.rs index de888c5a7939..d32737fcb62f 100644 --- a/tests/ui/const-generics/associated-const-bindings/esc-bound-var-in-ty.rs +++ b/tests/ui/const-generics/associated-const-bindings/esc-bound-var-in-ty.rs @@ -1,7 +1,6 @@ // Detect and reject escaping late-bound generic params in // the type of assoc consts used in an equality bound. #![feature( - adt_const_params, min_generic_const_args, unsized_const_params, generic_const_parameter_types, @@ -9,7 +8,8 @@ #![allow(incomplete_features)] trait Trait<'a> { - type const K: &'a (); + #[type_const] + const K: &'a (); } fn take(_: impl for<'r> Trait<'r, K = const { &() }>) {} diff --git a/tests/ui/const-generics/associated-const-bindings/issue-102335-const.rs b/tests/ui/const-generics/associated-const-bindings/issue-102335-const.rs index 1663cad13c7c..a88a3abf0a12 100644 --- a/tests/ui/const-generics/associated-const-bindings/issue-102335-const.rs +++ b/tests/ui/const-generics/associated-const-bindings/issue-102335-const.rs @@ -8,7 +8,8 @@ trait T { } trait S { - type const C: i32; + #[type_const] + const C: i32; } fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs index 1c6e873b98c3..77f0f06f8040 100644 --- a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs +++ b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs @@ -2,11 +2,13 @@ #![expect(incomplete_features)] trait Foo { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } impl Foo for () { - type const ASSOC: u32 = N; + #[type_const] + const ASSOC: u32 = N; } fn bar = { N }>>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr index b447cd08a214..c2fb7faa3a3a 100644 --- a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr +++ b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr @@ -1,26 +1,26 @@ error: the constant `N` is not of type `u32` - --> $DIR/mismatched-types-with-generic-in-ace.rs:12:29 + --> $DIR/mismatched-types-with-generic-in-ace.rs:14:29 | LL | fn bar = { N }>>() {} | ^^^^^^^^^^^^^^^^ expected `u32`, found `u64` | note: required by a const generic parameter in `Foo::ASSOC` - --> $DIR/mismatched-types-with-generic-in-ace.rs:5:22 + --> $DIR/mismatched-types-with-generic-in-ace.rs:6:17 | -LL | type const ASSOC: u32; - | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` +LL | const ASSOC: u32; + | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` error: the constant `10` is not of type `u32` - --> $DIR/mismatched-types-with-generic-in-ace.rs:16:5 + --> $DIR/mismatched-types-with-generic-in-ace.rs:18:5 | LL | bar::<10_u64, ()>(); | ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64` | note: required by a const generic parameter in `Foo::ASSOC` - --> $DIR/mismatched-types-with-generic-in-ace.rs:5:22 + --> $DIR/mismatched-types-with-generic-in-ace.rs:6:17 | -LL | type const ASSOC: u32; - | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` +LL | const ASSOC: u32; + | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs b/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs index a1efa74090bb..c7bb5bccedb3 100644 --- a/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs +++ b/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs @@ -6,7 +6,8 @@ // with associated const equality bounds. trait Trait { - type const C: usize; + #[type_const] + const C: usize; } fn f>() { diff --git a/tests/ui/const-generics/associated-const-bindings/param-in-ty.rs b/tests/ui/const-generics/associated-const-bindings/param-in-ty.rs index 4d67186f71f9..44e7e3f19ef2 100644 --- a/tests/ui/const-generics/associated-const-bindings/param-in-ty.rs +++ b/tests/ui/const-generics/associated-const-bindings/param-in-ty.rs @@ -11,7 +11,8 @@ use std::marker::ConstParamTy_; trait Trait<'a, T: 'a + ConstParamTy_, const N: usize> { - type const K: &'a [T; N]; + #[type_const] + const K: &'a [T; N]; } fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>( @@ -31,7 +32,8 @@ fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>( ) {} trait Project: ConstParamTy_ { - type const SELF: Self; + #[type_const] + const SELF: Self; } fn take1(_: impl Project) {} diff --git a/tests/ui/const-generics/associated-const-bindings/param-in-ty.stderr b/tests/ui/const-generics/associated-const-bindings/param-in-ty.stderr index 2ef3fab7e5ff..719dad816a6f 100644 --- a/tests/ui/const-generics/associated-const-bindings/param-in-ty.stderr +++ b/tests/ui/const-generics/associated-const-bindings/param-in-ty.stderr @@ -1,5 +1,5 @@ error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:21:29 + --> $DIR/param-in-ty.rs:22:29 | LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>( | -- the lifetime parameter `'r` is defined here @@ -10,7 +10,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }> = note: `K` has type `&'r [A; Q]` error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:21:29 + --> $DIR/param-in-ty.rs:22:29 | LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>( | - the type parameter `A` is defined here @@ -21,7 +21,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }> = note: `K` has type `&'r [A; Q]` error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:21:29 + --> $DIR/param-in-ty.rs:22:29 | LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>( | - the const parameter `Q` is defined here @@ -32,7 +32,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }> = note: `K` has type `&'r [A; Q]` error: the type of the associated constant `SELF` must not depend on `impl Trait` - --> $DIR/param-in-ty.rs:37:26 + --> $DIR/param-in-ty.rs:39:26 | LL | fn take1(_: impl Project) {} | -------------^^^^------------ @@ -41,7 +41,7 @@ LL | fn take1(_: impl Project) {} | the `impl Trait` is specified here error: the type of the associated constant `SELF` must not depend on generic parameters - --> $DIR/param-in-ty.rs:42:21 + --> $DIR/param-in-ty.rs:44:21 | LL | fn take2>(_: P) {} | - ^^^^ its type must not depend on the type parameter `P` @@ -51,7 +51,7 @@ LL | fn take2>(_: P) {} = note: `SELF` has type `P` error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:51:52 + --> $DIR/param-in-ty.rs:53:52 | LL | trait Iface<'r>: ConstParamTy_ { | -- the lifetime parameter `'r` is defined here @@ -62,7 +62,7 @@ LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> = note: `K` has type `&'r [Self; Q]` error: the type of the associated constant `K` must not depend on `Self` - --> $DIR/param-in-ty.rs:51:52 + --> $DIR/param-in-ty.rs:53:52 | LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> | ^ its type must not depend on `Self` @@ -70,7 +70,7 @@ LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> = note: `K` has type `&'r [Self; Q]` error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:51:52 + --> $DIR/param-in-ty.rs:53:52 | LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> | - ^ its type must not depend on the const parameter `Q` @@ -80,7 +80,7 @@ LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> = note: `K` has type `&'r [Self; Q]` error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:51:52 + --> $DIR/param-in-ty.rs:53:52 | LL | trait Iface<'r>: ConstParamTy_ { | -- the lifetime parameter `'r` is defined here @@ -92,7 +92,7 @@ LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: the type of the associated constant `K` must not depend on `Self` - --> $DIR/param-in-ty.rs:51:52 + --> $DIR/param-in-ty.rs:53:52 | LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> | ^ its type must not depend on `Self` @@ -101,7 +101,7 @@ LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: the type of the associated constant `K` must not depend on generic parameters - --> $DIR/param-in-ty.rs:51:52 + --> $DIR/param-in-ty.rs:53:52 | LL | type Assoc: Trait<'r, Self, Q, K = const { loop {} }> | - ^ its type must not depend on the const parameter `Q` diff --git a/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.rs b/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.rs index dbfbba9b7cbd..8a78b26dbc5d 100644 --- a/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.rs +++ b/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.rs @@ -4,7 +4,8 @@ // Issue 110549 pub trait TraitWAssocConst { - type const A: usize; + #[type_const] + const A: usize; } fn foo>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.stderr b/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.stderr index 11490a044091..232b15b7e981 100644 --- a/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.stderr +++ b/tests/ui/const-generics/associated-const-bindings/projection-unspecified-but-bounded.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `::A == 32` - --> $DIR/projection-unspecified-but-bounded.rs:13:11 + --> $DIR/projection-unspecified-but-bounded.rs:14:11 | LL | foo::(); | ^ expected `32`, found `::A` @@ -7,7 +7,7 @@ LL | foo::(); = note: expected constant `32` found constant `::A` note: required by a bound in `foo` - --> $DIR/projection-unspecified-but-bounded.rs:10:28 + --> $DIR/projection-unspecified-but-bounded.rs:11:28 | LL | fn foo>() {} | ^^^^^^ required by this bound in `foo` diff --git a/tests/ui/const-generics/associated-const-bindings/supertraits.rs b/tests/ui/const-generics/associated-const-bindings/supertraits.rs index cdceb682a854..a5f8859c92bd 100644 --- a/tests/ui/const-generics/associated-const-bindings/supertraits.rs +++ b/tests/ui/const-generics/associated-const-bindings/supertraits.rs @@ -16,7 +16,8 @@ use std::marker::ConstParamTy_; trait Trait: SuperTrait {} trait SuperTrait: SuperSuperTrait {} trait SuperSuperTrait { - type const K: T; + #[type_const] + const K: T; } fn take(_: impl Trait) {} diff --git a/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.rs b/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.rs index 95f81323acf4..5c494031d4fa 100644 --- a/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.rs +++ b/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.rs @@ -4,7 +4,8 @@ #![feature(min_generic_const_args)] trait Trait { - type const F: fn(); + #[type_const] + const F: fn(); //~^ ERROR using function pointers as const generic parameters is forbidden } diff --git a/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.stderr b/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.stderr index 333dd1b89e9b..09d1063081fe 100644 --- a/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.stderr +++ b/tests/ui/const-generics/associated-const-bindings/using-fnptr-as-type_const.stderr @@ -1,8 +1,8 @@ error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/using-fnptr-as-type_const.rs:7:19 + --> $DIR/using-fnptr-as-type_const.rs:8:14 | -LL | type const F: fn(); - | ^^^^ +LL | const F: fn(); + | ^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-1.rs b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-1.rs deleted file mode 100644 index 1beeb07e995a..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-1.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Check that we correctly handle associated const bindings -//! in `impl Trait` where the RHS is a const param (#151642). - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { type const CT: bool; } - -fn f(_: impl Trait) {} -//~^ ERROR the constant `N` is not of type `bool` -fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-1.stderr b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-1.stderr deleted file mode 100644 index 56e01e640078..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-1.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: the constant `N` is not of type `bool` - --> $DIR/wf-mismatch-1.rs:9:34 - | -LL | fn f(_: impl Trait) {} - | ^^^^^^^^^^ expected `bool`, found `i32` - | -note: required by a const generic parameter in `f` - --> $DIR/wf-mismatch-1.rs:9:34 - | -LL | fn f(_: impl Trait) {} - | ^^^^^^^^^^ required by this const generic parameter in `f` - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-2.rs b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-2.rs deleted file mode 100644 index 7a75b6da78c5..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-2.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! Check that we correctly handle associated const bindings -//! in `dyn Trait` where the RHS is a const param (#151642). - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { type const CT: bool; } - -fn f() { - let _: dyn Trait; - //~^ ERROR the constant `N` is not of type `bool` -} -fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-2.stderr b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-2.stderr deleted file mode 100644 index 8169cc07fc5f..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-2.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: the constant `N` is not of type `bool` - --> $DIR/wf-mismatch-2.rs:10:12 - | -LL | let _: dyn Trait; - | ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `i32` - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs deleted file mode 100644 index 3eeb7703aa2b..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Check that we correctly handle associated const bindings -//! where the RHS is a normalizable const projection (#151642). - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { type const CT: bool; } - -trait Bound { type const N: u32; } -impl Bound for () { type const N: u32 = 0; } - -fn f() { let _: dyn Trait::N }>; } -//~^ ERROR the constant `0` is not of type `bool` -fn g(_: impl Trait::N }>) {} -//~^ ERROR the constant `0` is not of type `bool` - -fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr deleted file mode 100644 index ac21527e04ed..000000000000 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: the constant `0` is not of type `bool` - --> $DIR/wf-mismatch-3.rs:14:20 - | -LL | fn g(_: impl Trait::N }>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32` - | -note: required by a const generic parameter in `g` - --> $DIR/wf-mismatch-3.rs:14:20 - | -LL | fn g(_: impl Trait::N }>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `g` - -error: the constant `0` is not of type `bool` - --> $DIR/wf-mismatch-3.rs:12:17 - | -LL | fn f() { let _: dyn Trait::N }>; } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/const-generics/fn-item-as-const-arg-137084.rs b/tests/ui/const-generics/fn-item-as-const-arg-137084.rs deleted file mode 100644 index 8b75a3c8c96d..000000000000 --- a/tests/ui/const-generics/fn-item-as-const-arg-137084.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Regression test for https://github.com/rust-lang/rust/issues/137084 -// Previously caused ICE when using function item as const generic argument - -#![feature(min_generic_const_args)] -#![allow(incomplete_features)] - -fn a() {} -fn d(e: &String) { - a:: - //~^ ERROR mismatched types - //~| ERROR the constant `d` is not of type `i32` -} - -fn main() {} diff --git a/tests/ui/const-generics/fn-item-as-const-arg-137084.stderr b/tests/ui/const-generics/fn-item-as-const-arg-137084.stderr deleted file mode 100644 index 58b74c655cd2..000000000000 --- a/tests/ui/const-generics/fn-item-as-const-arg-137084.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/fn-item-as-const-arg-137084.rs:9:5 - | -LL | fn a() {} - | -------------------- function `a` defined here -LL | fn d(e: &String) { -LL | a:: - | ^^^^^^ expected `()`, found fn item - | - = note: expected unit type `()` - found fn item `fn() {a::}` -help: try adding a return type - | -LL | fn d(e: &String) -> fn() { - | +++++++ -help: use parentheses to call this function - | -LL | a::() - | ++ - -error: the constant `d` is not of type `i32` - --> $DIR/fn-item-as-const-arg-137084.rs:9:9 - | -LL | a:: - | ^ expected `i32`, found fn item - | -note: required by a const generic parameter in `a` - --> $DIR/fn-item-as-const-arg-137084.rs:7:6 - | -LL | fn a() {} - | ^^^^^^^^^^^^ required by this const generic parameter in `a` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs deleted file mode 100644 index 8cd46783d4fd..000000000000 --- a/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(min_generic_const_args)] -#![allow(incomplete_features)] - -pub type const NON_LOCAL_CONST: char = 'a'; diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.rs index 79e9834b54ed..298cfb512e41 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.rs @@ -18,4 +18,5 @@ fn use_dyn(v: &dyn Foo) where [u8; N + 1]: Sized { fn main() { use_dyn(&()); //~^ ERROR type annotations needed + //~| ERROR type annotations needed } diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr index f9904c9d2e48..a124fbc60920 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr @@ -14,6 +14,27 @@ help: consider specifying the generic argument LL | use_dyn::(&()); | +++++ -error: aborting due to 1 previous error +error[E0284]: type annotations needed + --> $DIR/dyn-compatibility-ok-infer-err.rs:19:5 + | +LL | use_dyn(&()); + | ^^^^^^^ --- type must be known at this point + | | + | cannot infer the value of the const parameter `N` declared on the function `use_dyn` + | +note: required for `()` to implement `Foo<_>` + --> $DIR/dyn-compatibility-ok-infer-err.rs:8:22 + | +LL | impl Foo for () { + | -------------- ^^^^^^ ^^ + | | + | unsatisfied trait bound introduced here + = note: required for the cast from `&()` to `&dyn Foo<_>` +help: consider specifying the generic argument + | +LL | use_dyn::(&()); + | +++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs index c08d36f4d9ff..9f20cf085794 100644 --- a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs +++ b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs @@ -11,7 +11,7 @@ where //~^ ERROR only lifetime parameters can be used in this context //~| ERROR defaults for generic parameters are not allowed in `for<...>` binders //~| ERROR defaults for generic parameters are not allowed in `for<...>` binders - //~| ERROR cannot find + //~| ERROR failed to resolve: use of undeclared type `COT` //~| ERROR the name `N` is already used for a generic parameter in this item's generic parameters { } diff --git a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr index de81c021b829..8e9b5b03d14e 100644 --- a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr +++ b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr @@ -43,7 +43,7 @@ error: defaults for generic parameters are not allowed in `for<...>` binders LL | for [(); COT::BYTES]:, | ^^^^^^^ -error[E0433]: cannot find type `COT` in this scope +error[E0433]: failed to resolve: use of undeclared type `COT` --> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:43 | LL | for [(); COT::BYTES]:, diff --git a/tests/ui/const-generics/generic_const_exprs/issue-105257.rs b/tests/ui/const-generics/generic_const_exprs/issue-105257.rs index 947410cbe0dc..85a28f2b3303 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-105257.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-105257.rs @@ -2,9 +2,9 @@ #![expect(incomplete_features)] trait Trait { - fn fnc(&self) {} //~ ERROR defaults for generic parameters are not allowed here - //~^ ERROR mismatched types - fn foo() }>(&self) {} //~ ERROR defaults for generic parameters are not allowed here + fn fnc(&self) {} //~ERROR defaults for generic parameters are not allowed here + //~^ ERROR: mismatched types + fn foo() }>(&self) {} //~ERROR defaults for generic parameters are not allowed here } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.rs b/tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.rs new file mode 100644 index 000000000000..1ed0965e1bde --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.rs @@ -0,0 +1,22 @@ +//! ICE regression test for #114317 and #126182 +//! Type mismatches of literals cause errors int typeck, +//! but those errors cannot be propagated to the various +//! `lit_to_const` call sites. Now `lit_to_const` just delays +//! a bug and produces an error constant on its own. + +#![feature(adt_const_params)] +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct A(C); +//~^ ERROR: generic parameters with a default must be trailing +//~| ERROR: mismatched types + +struct Cond; + +struct Thing>(T); +//~^ ERROR: mismatched types + +impl Thing {} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.stderr b/tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.stderr new file mode 100644 index 000000000000..e4613e498b27 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.stderr @@ -0,0 +1,21 @@ +error: generic parameters with a default must be trailing + --> $DIR/lit_type_mismatch.rs:11:16 + | +LL | struct A(C); + | ^ + +error[E0308]: mismatched types + --> $DIR/lit_type_mismatch.rs:11:24 + | +LL | struct A(C); + | ^ expected `()`, found integer + +error[E0308]: mismatched types + --> $DIR/lit_type_mismatch.rs:17:23 + | +LL | struct Thing>(T); + | ^ expected `bool`, found integer + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/generic_const_exprs/non-local-const.rs b/tests/ui/const-generics/generic_const_exprs/non-local-const.rs index d0efdb2c2017..0a30cc385ac4 100644 --- a/tests/ui/const-generics/generic_const_exprs/non-local-const.rs +++ b/tests/ui/const-generics/generic_const_exprs/non-local-const.rs @@ -1,12 +1,10 @@ // regression test for #133808. -//@ aux-build:non_local_type_const.rs #![feature(generic_const_exprs)] #![feature(min_generic_const_args)] #![allow(incomplete_features)] #![crate_type = "lib"] -extern crate non_local_type_const; pub trait Foo {} -impl Foo for [u8; non_local_type_const::NON_LOCAL_CONST] {} -//~^ ERROR the constant `'a'` is not of type `usize` +impl Foo for [u8; std::path::MAIN_SEPARATOR] {} +//~^ ERROR the constant `MAIN_SEPARATOR` is not of type `usize` diff --git a/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr b/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr index 3d1ec60eb908..d8df3269a19e 100644 --- a/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr +++ b/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr @@ -1,10 +1,10 @@ -error: the constant `'a'` is not of type `usize` - --> $DIR/non-local-const.rs:11:14 +error: the constant `MAIN_SEPARATOR` is not of type `usize` + --> $DIR/non-local-const.rs:9:14 | -LL | impl Foo for [u8; non_local_type_const::NON_LOCAL_CONST] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `char` +LL | impl Foo for [u8; std::path::MAIN_SEPARATOR] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `char` | - = note: the length of array `[u8; 'a']` must be type `usize` + = note: the length of array `[u8; MAIN_SEPARATOR]` must be type `usize` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs b/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs deleted file mode 100644 index 7710fc68d795..000000000000 --- a/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Regression test for https://github.com/rust-lang/rust/issues/151186 - -#![feature(min_generic_const_args)] -#![allow(incomplete_features)] - -trait Maybe {} - -trait MyTrait ()> {} -//~^ ERROR using function pointers as const generic parameters is forbidden - -fn foo<'a>(x: &'a ()) -> &'a () { x } - -impl Maybe for T where T: MyTrait<{ foo }> {} -//~^ ERROR the constant `foo` is not of type `fn()` - -fn main() {} diff --git a/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.stderr b/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.stderr deleted file mode 100644 index 7c9d7ee7dde5..000000000000 --- a/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: using function pointers as const generic parameters is forbidden - --> $DIR/ice-151186-fn-ptr-in-where-clause.rs:8:24 - | -LL | trait MyTrait ()> {} - | ^^^^^^^^^^ - | - = note: the only supported types are integers, `bool`, and `char` - -error: the constant `foo` is not of type `fn()` - --> $DIR/ice-151186-fn-ptr-in-where-clause.rs:13:33 - | -LL | impl Maybe for T where T: MyTrait<{ foo }> {} - | ^^^^^^^^^^^^^^^^ expected fn pointer, found fn item - | -note: required by a const generic parameter in `MyTrait` - --> $DIR/ice-151186-fn-ptr-in-where-clause.rs:8:15 - | -LL | trait MyTrait ()> {} - | ^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `MyTrait` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/const-generics/infer/issue-77092.rs b/tests/ui/const-generics/infer/issue-77092.rs index 77d1fe187795..47c594e5b11e 100644 --- a/tests/ui/const-generics/infer/issue-77092.rs +++ b/tests/ui/const-generics/infer/issue-77092.rs @@ -10,5 +10,6 @@ fn main() { for i in 1..4 { println!("{:?}", take_array_from_mut(&mut arr, i)); //~^ ERROR type annotations needed + //~| ERROR type annotations needed } } diff --git a/tests/ui/const-generics/infer/issue-77092.stderr b/tests/ui/const-generics/infer/issue-77092.stderr index 96f6496eca53..3763cd738a86 100644 --- a/tests/ui/const-generics/infer/issue-77092.stderr +++ b/tests/ui/const-generics/infer/issue-77092.stderr @@ -14,6 +14,24 @@ help: consider specifying the generic arguments LL | println!("{:?}", take_array_from_mut::(&mut arr, i)); | ++++++++++ -error: aborting due to 1 previous error +error[E0284]: type annotations needed + --> $DIR/issue-77092.rs:11:26 + | +LL | println!("{:?}", take_array_from_mut(&mut arr, i)); + | ---- ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut` + | | + | required by this formatting parameter + | + = note: required for `[i32; _]` to implement `Debug` + = note: 1 redundant requirement hidden + = note: required for `&mut [i32; _]` to implement `Debug` +note: required by a bound in `core::fmt::rt::Argument::<'_>::new_debug` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL +help: consider specifying the generic arguments + | +LL | println!("{:?}", take_array_from_mut::(&mut arr, i)); + | ++++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr index 87ec5973fa28..7d563e3b6054 100644 --- a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr +++ b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr @@ -11,7 +11,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait X { | - this trait is not dyn compatible... LL | type Y; - | ^ ...because it contains generic associated type `Y` + | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-82956.rs b/tests/ui/const-generics/issues/issue-82956.rs index 8586c39a717a..983717170c34 100644 --- a/tests/ui/const-generics/issues/issue-82956.rs +++ b/tests/ui/const-generics/issues/issue-82956.rs @@ -24,7 +24,7 @@ where fn pop(self) -> (Self::Newlen, Self::Output) { let mut iter = IntoIter::new(self); - //~^ ERROR: cannot find + //~^ ERROR: failed to resolve: use of undeclared type `IntoIter` let end = iter.next_back().unwrap(); let new = [(); N - 1].map(move |()| iter.next().unwrap()); (new, end) diff --git a/tests/ui/const-generics/issues/issue-82956.stderr b/tests/ui/const-generics/issues/issue-82956.stderr index a3d5572d5474..beb801496115 100644 --- a/tests/ui/const-generics/issues/issue-82956.stderr +++ b/tests/ui/const-generics/issues/issue-82956.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `IntoIter` in this scope +error[E0433]: failed to resolve: use of undeclared type `IntoIter` --> $DIR/issue-82956.rs:26:24 | LL | let mut iter = IntoIter::new(self); diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs index 8470b933cadd..16479ba3f64f 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs @@ -10,9 +10,9 @@ use Option::Some; fn foo>() {} - trait Trait { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } fn bar() { diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr b/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr index f1d5e5c67475..8b9c228c1ee5 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr @@ -9,8 +9,6 @@ error: generic parameters may not be used in const operations | LL | foo::<{ Some:: { 0: const { N + 1 } } }>(); | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs b/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs index 68f999fb76fa..5f0d6c924bd1 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs +++ b/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs @@ -1,9 +1,9 @@ #![feature(min_generic_const_args, adt_const_params, unsized_const_params)] #![expect(incomplete_features)] - trait Trait { - type const ASSOC: usize; + #[type_const] + const ASSOC: usize; } fn takes_tuple() {} diff --git a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs index 5def3cbb829b..d3c9b655a9e5 100644 --- a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs +++ b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs @@ -16,7 +16,8 @@ struct Foo { field: T, } -type const WRAP: Foo = { Foo:: { +#[type_const] +const WRAP: Foo = { Foo:: { field: N, } }; diff --git a/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs b/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs index 7401181962bb..47ecbfa6b7e1 100644 --- a/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs +++ b/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs @@ -6,7 +6,8 @@ fn takes_array() {} trait Trait { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } fn generic_caller() { diff --git a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs deleted file mode 100644 index 13b2e031b118..000000000000 --- a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! regression test for -//@ run-pass -#![expect(incomplete_features)] -#![feature(min_generic_const_args)] -#![allow(dead_code)] - -trait Abc {} - -trait A { - type const VALUE: usize; -} - -impl A for T { - type const VALUE: usize = 0; -} - -trait S {} - -trait Handler -where - (): S<{ ::VALUE }>, -{ -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs b/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs index ca7299e7690b..a11314c11aae 100644 --- a/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs +++ b/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs @@ -6,9 +6,9 @@ pub trait Tr { } fn mk_array(_x: T) -> [(); T::SIZE] { - //~^ ERROR: use of `const` in the type system not defined as `type const` + //~^ ERROR type_const [(); T::SIZE] - //~^ ERROR: use of `const` in the type system not defined as `type const` + //~^ ERROR type_const } fn main() {} diff --git a/tests/ui/const-generics/mgca/assoc-const-without-type_const.stderr b/tests/ui/const-generics/mgca/assoc-const-without-type_const.stderr index 759a40cc0675..7872e0967626 100644 --- a/tests/ui/const-generics/mgca/assoc-const-without-type_const.stderr +++ b/tests/ui/const-generics/mgca/assoc-const-without-type_const.stderr @@ -1,20 +1,18 @@ -error: use of `const` in the type system not defined as `type const` +error: use of trait associated const without `#[type_const]` --> $DIR/assoc-const-without-type_const.rs:8:35 | -LL | const SIZE: usize; - | - help: add `type` before `const` for `Tr::SIZE`: `type` -... LL | fn mk_array(_x: T) -> [(); T::SIZE] { | ^^^^^^^ + | + = note: the declaration in the trait must be marked with `#[type_const]` -error: use of `const` in the type system not defined as `type const` +error: use of trait associated const without `#[type_const]` --> $DIR/assoc-const-without-type_const.rs:10:10 | -LL | const SIZE: usize; - | - help: add `type` before `const` for `Tr::SIZE`: `type` -... LL | [(); T::SIZE] | ^^^^^^^ + | + = note: the declaration in the trait must be marked with `#[type_const]` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/assoc-const.rs b/tests/ui/const-generics/mgca/assoc-const.rs index c49b84edba10..fb5b4308a7f8 100644 --- a/tests/ui/const-generics/mgca/assoc-const.rs +++ b/tests/ui/const-generics/mgca/assoc-const.rs @@ -4,7 +4,8 @@ #![allow(incomplete_features)] pub trait Tr { - type const SIZE: usize; + #[type_const] + const SIZE: usize; } fn mk_array>(_x: T) -> [(); >::SIZE] { diff --git a/tests/ui/const-generics/mgca/auxiliary/non_local_const.rs b/tests/ui/const-generics/mgca/auxiliary/non_local_const.rs deleted file mode 100644 index 19091e4780fe..000000000000 --- a/tests/ui/const-generics/mgca/auxiliary/non_local_const.rs +++ /dev/null @@ -1 +0,0 @@ -pub const N: usize = 2; diff --git a/tests/ui/const-generics/mgca/bad-type_const-syntax.rs b/tests/ui/const-generics/mgca/bad-type_const-syntax.rs index 81be1ca4eb88..bb5bdb8d7c4c 100644 --- a/tests/ui/const-generics/mgca/bad-type_const-syntax.rs +++ b/tests/ui/const-generics/mgca/bad-type_const-syntax.rs @@ -1,16 +1,16 @@ trait Tr { - type const N: usize; - //~^ ERROR: `type const` syntax is experimental [E0658] - //~| ERROR: associated `type const` are unstable [E0658] + #[type_const()] + //~^ ERROR malformed + //~| ERROR experimental + const N: usize; } struct S; impl Tr for S { - - type const N: usize = 0; - //~^ ERROR: `type const` syntax is experimental [E0658] - //~| ERROR: associated `type const` are unstable [E0658] + #[type_const] + //~^ ERROR experimental + const N: usize = 0; } fn main() {} diff --git a/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr b/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr index 7bb2adf27199..df442c22241b 100644 --- a/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr +++ b/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr @@ -1,43 +1,33 @@ -error[E0658]: `type const` syntax is experimental +error[E0658]: the `#[type_const]` attribute is an experimental feature --> $DIR/bad-type_const-syntax.rs:2:5 | -LL | type const N: usize; - | ^^^^^^^^^^ +LL | #[type_const()] + | ^^^^^^^^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `type const` syntax is experimental +error[E0658]: the `#[type_const]` attribute is an experimental feature --> $DIR/bad-type_const-syntax.rs:11:5 | -LL | type const N: usize = 0; - | ^^^^^^^^^^ +LL | #[type_const] + | ^^^^^^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: associated `type const` are unstable +error[E0565]: malformed `type_const` attribute input --> $DIR/bad-type_const-syntax.rs:2:5 | -LL | type const N: usize; - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #132980 for more information - = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +LL | #[type_const()] + | ^^^^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[type_const]` -error[E0658]: associated `type const` are unstable - --> $DIR/bad-type_const-syntax.rs:11:5 - | -LL | type const N: usize = 0; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #132980 for more information - = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +error: aborting due to 3 previous errors -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0565, E0658. +For more information about an error, try `rustc --explain E0565`. diff --git a/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs b/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs index 69d16993a7e0..37f9c31feaa5 100644 --- a/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs +++ b/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs @@ -4,17 +4,23 @@ #![feature(min_generic_const_args, generic_const_items)] pub trait Tr { - type const N1: usize; - type const N2: usize; - type const N3: usize; + #[type_const] + const N1: usize; + #[type_const] + const N2: usize; + #[type_const] + const N3: usize; } pub struct S; impl Tr for S { - type const N1: usize = 0; - type const N2: usize = 1; - type const N3: usize = 2; + #[type_const] + const N1: usize = 0; + #[type_const] + const N2: usize = 1; + #[type_const] + const N3: usize = 2; } fn main() {} diff --git a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs index 9d475f8224fa..68aa30bd65bb 100644 --- a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs +++ b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs @@ -3,8 +3,7 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] - -type const C: usize = 0; +const C: usize = 0; pub struct A {} impl A { fn fun1() {} diff --git a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr index 6b2b871ba4b9..3d74d1db206e 100644 --- a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr +++ b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr @@ -1,11 +1,11 @@ error[E0107]: missing generics for struct `A` - --> $DIR/const-arg-coherence-conflicting-methods.rs:13:6 + --> $DIR/const-arg-coherence-conflicting-methods.rs:12:6 | LL | impl A { | ^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `M` - --> $DIR/const-arg-coherence-conflicting-methods.rs:8:12 + --> $DIR/const-arg-coherence-conflicting-methods.rs:7:12 | LL | pub struct A {} | ^ -------------- @@ -15,7 +15,7 @@ LL | impl A { | +++ error[E0592]: duplicate definitions with name `fun1` - --> $DIR/const-arg-coherence-conflicting-methods.rs:10:5 + --> $DIR/const-arg-coherence-conflicting-methods.rs:9:5 | LL | fn fun1() {} | ^^^^^^^^^ duplicate definitions for `fun1` diff --git a/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs b/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs deleted file mode 100644 index a7e46ad877e7..000000000000 --- a/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ needs-rustc-debug-assertions - -#![feature(min_generic_const_args)] -#![feature(generic_const_exprs)] -#![expect(incomplete_features)] - -type const A: u8 = A; -//~^ ERROR overflow normalizing the unevaluated constant `A` - -fn main() {} diff --git a/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr b/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr deleted file mode 100644 index 47653dd1896f..000000000000 --- a/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0275]: overflow normalizing the unevaluated constant `A` - --> $DIR/cyclic-type-const-151251.rs:7:1 - | -LL | type const A: u8 = A; - | ^^^^^^^^^^^^^^^^ - | - = note: in case this is a recursive type alias, consider using a struct, enum, or union instead - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/const-generics/mgca/early-bound-param-lt-bad.stderr b/tests/ui/const-generics/mgca/early-bound-param-lt-bad.stderr index e0804158952d..461a26e33a3c 100644 --- a/tests/ui/const-generics/mgca/early-bound-param-lt-bad.stderr +++ b/tests/ui/const-generics/mgca/early-bound-param-lt-bad.stderr @@ -3,8 +3,6 @@ error: generic parameters may not be used in const operations | LL | T: Trait | ^^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.rs b/tests/ui/const-generics/mgca/explicit_anon_consts.rs deleted file mode 100644 index 2b9909b43dfb..000000000000 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.rs +++ /dev/null @@ -1,73 +0,0 @@ -#![feature(generic_const_items, min_generic_const_args)] -#![expect(incomplete_features)] -// library crates exercise weirder code paths around -// DefIds which were created for const args. -#![crate_type = "lib"] - -struct Foo; - -type Adt1 = Foo; -type Adt2 = Foo<{ N }>; -type Adt3 = Foo; -//~^ ERROR: generic parameters may not be used in const operations -type Adt4 = Foo<{ 1 + 1 }>; -//~^ ERROR: complex const arguments must be placed inside of a `const` block -type Adt5 = Foo; - -type Arr = [(); N]; -type Arr2 = [(); { N }]; -type Arr3 = [(); const { N }]; -//~^ ERROR: generic parameters may not be used in const operations -type Arr4 = [(); 1 + 1]; -//~^ ERROR: complex const arguments must be placed inside of a `const` block -type Arr5 = [(); const { 1 + 1 }]; - -fn repeats() -> [(); N] { - let _1 = [(); N]; - let _2 = [(); { N }]; - let _3 = [(); const { N }]; - //~^ ERROR: generic parameters may not be used in const operations - let _4 = [(); 1 + 1]; - //~^ ERROR: complex const arguments must be placed inside of a `const` block - let _5 = [(); const { 1 + 1 }]; - let _6: [(); const { N }] = todo!(); - //~^ ERROR: generic parameters may not be used in const operations -} - - -type const ITEM1: usize = N; - -type const ITEM2: usize = { N }; - -type const ITEM3: usize = const { N }; -//~^ ERROR: generic parameters may not be used in const operations - -type const ITEM4: usize = { 1 + 1 }; -//~^ ERROR: complex const arguments must be placed inside of a `const` block - -type const ITEM5: usize = const { 1 + 1}; - -trait Trait { - - type const ASSOC: usize; -} - -fn ace_bounds< - const N: usize, - // We skip the T1 case because it doesn't resolve - // T1: Trait, - T2: Trait, - T3: Trait, - //~^ ERROR: generic parameters may not be used in const operations - T4: Trait, - //~^ ERROR: complex const arguments must be placed inside of a `const` block - T5: Trait, ->() {} - -struct Default1; -struct Default2; -struct Default3; -//~^ ERROR: generic parameters may not be used in const operations -struct Default4; -//~^ ERROR: complex const arguments must be placed inside of a `const` block -struct Default5; diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr deleted file mode 100644 index 714d7a804d11..000000000000 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr +++ /dev/null @@ -1,94 +0,0 @@ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:13:33 - | -LL | type Adt4 = Foo<{ 1 + 1 }>; - | ^^^^^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:21:34 - | -LL | type Arr4 = [(); 1 + 1]; - | ^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:30:19 - | -LL | let _4 = [(); 1 + 1]; - | ^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:45:43 - | -LL | type const ITEM4: usize = { 1 + 1 }; - | ^^^^^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:62:23 - | -LL | T4: Trait, - | ^^^^^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:71:50 - | -LL | struct Default4; - | ^^^^^^^^^ - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:42:51 - | -LL | type const ITEM3: usize = const { N }; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:60:31 - | -LL | T3: Trait, - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:69:58 - | -LL | struct Default3; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:28:27 - | -LL | let _3 = [(); const { N }]; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:33:26 - | -LL | let _6: [(); const { N }] = todo!(); - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:11:41 - | -LL | type Adt3 = Foo; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:19:42 - | -LL | type Arr3 = [(); const { N }]; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: aborting due to 13 previous errors - diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs b/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs index be853bb87a37..8131a5b72343 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs +++ b/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs @@ -4,7 +4,8 @@ #![expect(incomplete_features)] trait Trait { - type const ASSOC: isize; + #[type_const] + const ASSOC: isize; } fn ace>() {} diff --git a/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs b/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs deleted file mode 100644 index 948b8ce72148..000000000000 --- a/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! Regression test for -#![expect(incomplete_features)] -#![feature( - adt_const_params, - generic_const_items, - generic_const_parameter_types, - min_generic_const_args, - unsized_const_params -)] -use std::marker::ConstParamTy_; - -struct Foo { - field: T, -} - -type const WRAP : T = Foo::{field : 1}; -//~^ ERROR: type annotations needed for the literal - -fn main() {} diff --git a/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr b/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr deleted file mode 100644 index fdb0995bff5d..000000000000 --- a/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: type annotations needed for the literal - --> $DIR/generic_const_type_mismatch.rs:16:59 - | -LL | type const WRAP : T = Foo::{field : 1}; - | ^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs b/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs index bbe624269672..31f54abf31ef 100644 --- a/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs +++ b/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs @@ -6,7 +6,8 @@ struct Foo; trait Trait { - type const ASSOC: usize; + #[type_const] + const ASSOC: usize; } type Arr = [(); {{{ N }}}]; diff --git a/tests/ui/const-generics/mgca/negated-literal.rs b/tests/ui/const-generics/mgca/negated-literal.rs deleted file mode 100644 index a7651822b0a8..000000000000 --- a/tests/ui/const-generics/mgca/negated-literal.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ check-pass - -#![feature(adt_const_params, min_generic_const_args)] -#![allow(incomplete_features)] - -use std::marker::ConstParamTy; - -#[derive(Eq, PartialEq, ConstParamTy)] -struct Foo { - field: isize -} - -fn foo() {} - -fn main() { - foo::<{ Foo { field: -1 } }>(); -} diff --git a/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs b/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs deleted file mode 100644 index 6f1235269dfc..000000000000 --- a/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Just a test of the error message (it's different for non-local consts) -//@ aux-build:non_local_const.rs -#![feature(min_generic_const_args)] -#![allow(incomplete_features)] -extern crate non_local_const; -fn main() { - let x = [(); non_local_const::N]; - //~^ ERROR: use of `const` in the type system not defined as `type const` -} diff --git a/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr b/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr deleted file mode 100644 index 3c10b78eb3e1..000000000000 --- a/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: use of `const` in the type system not defined as `type const` - --> $DIR/non-local-const-without-type_const.rs:7:18 - | -LL | let x = [(); non_local_const::N]; - | ^^^^^^^^^^^^^^^^^^ - | - = note: only consts marked defined as `type const` may be used in types - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs b/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs deleted file mode 100644 index cd68a2c0d430..000000000000 --- a/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![feature(adt_const_params, min_generic_const_args)] -#![expect(incomplete_features)] - -use std::marker::ConstParamTy; - -#[derive(Eq, PartialEq, ConstParamTy)] -struct Foo { - field: isize -} - -fn foo() {} - -fn main() { - foo::<{ Foo { field: -1_usize } }>(); - //~^ ERROR: type annotations needed for the literal - foo::<{ Foo { field: { -1_usize } } }>(); - //~^ ERROR: complex const arguments must be placed inside of a `const` block - foo::<{ Foo { field: -true } }>(); - //~^ ERROR: the constant `true` is not of type `isize` - foo::<{ Foo { field: { -true } } }>(); - //~^ ERROR: complex const arguments must be placed inside of a `const` block - foo::<{ Foo { field: -"<3" } }>(); - //~^ ERROR: the constant `"<3"` is not of type `isize` - foo::<{ Foo { field: { -"<3" } } }>(); - //~^ ERROR: complex const arguments must be placed inside of a `const` block -} diff --git a/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr b/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr deleted file mode 100644 index 43ed4b71e33e..000000000000 --- a/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/nonsensical-negated-literal.rs:16:26 - | -LL | foo::<{ Foo { field: { -1_usize } } }>(); - | ^^^^^^^^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/nonsensical-negated-literal.rs:20:26 - | -LL | foo::<{ Foo { field: { -true } } }>(); - | ^^^^^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/nonsensical-negated-literal.rs:24:26 - | -LL | foo::<{ Foo { field: { -"<3" } } }>(); - | ^^^^^^^^^ - -error: type annotations needed for the literal - --> $DIR/nonsensical-negated-literal.rs:14:26 - | -LL | foo::<{ Foo { field: -1_usize } }>(); - | ^^^^^^^^ - -error: the constant `true` is not of type `isize` - --> $DIR/nonsensical-negated-literal.rs:18:13 - | -LL | foo::<{ Foo { field: -true } }>(); - | ^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `bool` - -error: the constant `"<3"` is not of type `isize` - --> $DIR/nonsensical-negated-literal.rs:22:13 - | -LL | foo::<{ Foo { field: -"<3" } }>(); - | ^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `&'static str` - -error: aborting due to 6 previous errors - diff --git a/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs index 16ed24a7b287..819323d9cbec 100644 --- a/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs +++ b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs @@ -8,8 +8,8 @@ struct Foo; trait Trait { - - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } fn foo() {} diff --git a/tests/ui/const-generics/mgca/projection-error.rs b/tests/ui/const-generics/mgca/projection-error.rs index d3bd520297e1..edb6db098084 100644 --- a/tests/ui/const-generics/mgca/projection-error.rs +++ b/tests/ui/const-generics/mgca/projection-error.rs @@ -5,8 +5,10 @@ // containing erroneous types normalizes to a const error instead of // a type error. + pub trait Tr { - type const SIZE: usize; + #[type_const] + const SIZE: usize; } fn mk_array(_x: T) -> [(); >::SIZE] {} diff --git a/tests/ui/const-generics/mgca/projection-error.stderr b/tests/ui/const-generics/mgca/projection-error.stderr index 94e6bbcdd87f..9357600a5e11 100644 --- a/tests/ui/const-generics/mgca/projection-error.stderr +++ b/tests/ui/const-generics/mgca/projection-error.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find type `T` in this scope - --> $DIR/projection-error.rs:12:17 + --> $DIR/projection-error.rs:14:17 | LL | pub trait Tr { | --------------- similarly named trait `Tr` defined here @@ -17,7 +17,7 @@ LL | fn mk_array(_x: T) -> [(); >::SIZE] {} | +++ error[E0425]: cannot find type `T` in this scope - --> $DIR/projection-error.rs:12:29 + --> $DIR/projection-error.rs:14:29 | LL | pub trait Tr { | --------------- similarly named trait `Tr` defined here diff --git a/tests/ui/const-generics/mgca/selftyalias-containing-param.rs b/tests/ui/const-generics/mgca/selftyalias-containing-param.rs deleted file mode 100644 index 5ab39799078f..000000000000 --- a/tests/ui/const-generics/mgca/selftyalias-containing-param.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -struct S([(); N]); - -impl S { - fn foo() -> [(); const { let _: Self = loop {}; 1 }] { - //~^ ERROR generic `Self` - todo!() - } -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/selftyalias-containing-param.stderr b/tests/ui/const-generics/mgca/selftyalias-containing-param.stderr deleted file mode 100644 index 1c841e39e673..000000000000 --- a/tests/ui/const-generics/mgca/selftyalias-containing-param.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/selftyalias-containing-param.rs:7:37 - | -LL | fn foo() -> [(); const { let _: Self = loop {}; 1 }] { - | ^^^^ - | -note: not a concrete type - --> $DIR/selftyalias-containing-param.rs:6:22 - | -LL | impl S { - | ^^^^ - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/selftyparam.rs b/tests/ui/const-generics/mgca/selftyparam.rs deleted file mode 100644 index 58433405b8ca..000000000000 --- a/tests/ui/const-generics/mgca/selftyparam.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Tr { - fn foo() -> [(); const { let _: Self; 1 }]; - //~^ ERROR generic parameters -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/selftyparam.stderr b/tests/ui/const-generics/mgca/selftyparam.stderr deleted file mode 100644 index c3e0770fb978..000000000000 --- a/tests/ui/const-generics/mgca/selftyparam.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: generic parameters may not be used in const operations - --> $DIR/selftyparam.rs:5:37 - | -LL | fn foo() -> [(); const { let _: Self; 1 }]; - | ^^^^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs deleted file mode 100644 index d06ea7a10c74..000000000000 --- a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! regression test for -#![expect(incomplete_features)] -#![feature(min_generic_const_args)] - -fn foo() { - [0; size_of::<*mut T>()]; - //~^ ERROR: complex const arguments must be placed inside of a `const` block - [0; const { size_of::<*mut T>() }]; - //~^ ERROR: generic parameters may not be used in const operations - [0; const { size_of::<*mut i32>() }]; -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr deleted file mode 100644 index 61e934380c36..000000000000 --- a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/size-of-generic-ptr-in-array-len.rs:6:9 - | -LL | [0; size_of::<*mut T>()]; - | ^^^^^^^^^^^^^^^^^^^ - -error: generic parameters may not be used in const operations - --> $DIR/size-of-generic-ptr-in-array-len.rs:8:32 - | -LL | [0; const { size_of::<*mut T>() }]; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items - -error: aborting due to 2 previous errors - diff --git a/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs b/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs deleted file mode 100644 index 715caef38a9a..000000000000 --- a/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Regression test for https://github.com/rust-lang/rust/issues/141738 -// -// Using a struct constructor as an array repeat count with -// `min_generic_const_args` used to ICE with "unexpected `DefKind` -// for const alias to resolve to: Ctor(Struct, Const)". -// It should now produce a proper type error. - -#![feature(min_generic_const_args)] -//~^ WARN the feature `min_generic_const_args` is incomplete - -struct S; - -fn main() { - let _b = [0; S]; - //~^ ERROR the constant `S` is not of type `usize` -} diff --git a/tests/ui/const-generics/mgca/struct-ctor-in-array-len.stderr b/tests/ui/const-generics/mgca/struct-ctor-in-array-len.stderr deleted file mode 100644 index baf587a856bc..000000000000 --- a/tests/ui/const-generics/mgca/struct-ctor-in-array-len.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/struct-ctor-in-array-len.rs:8:12 - | -LL | #![feature(min_generic_const_args)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #132980 for more information - = note: `#[warn(incomplete_features)]` on by default - -error: the constant `S` is not of type `usize` - --> $DIR/struct-ctor-in-array-len.rs:14:14 - | -LL | let _b = [0; S]; - | ^^^^^^ expected `usize`, found `S` - | - = note: the length of array `[{integer}; S]` must be type `usize` - -error: aborting due to 1 previous error; 1 warning emitted - diff --git a/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs b/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs index e946441453d8..a5b3d3d0d5b6 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs @@ -15,7 +15,8 @@ enum MyEnum { } trait Trait { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } fn with_point() -> Point { diff --git a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr index 2961c714d141..e0ea3fd5560c 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr +++ b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr @@ -9,8 +9,6 @@ error: generic parameters may not be used in const operations | LL | with_point::<{ Point(const { N + 1 }, N) }>(); | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs index 43d0d21fb736..84ded05fdd0e 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs @@ -12,8 +12,7 @@ enum MyEnum { Unit, } - -type const CONST_ITEM: u32 = 42; +const CONST_ITEM: u32 = 42; fn accepts_point() {} fn accepts_enum>() {} @@ -32,7 +31,7 @@ fn test_errors() { //~| ERROR tuple constructor with invalid base path accepts_point::<{ non_ctor(N, N) }>(); - //~^ ERROR complex const arguments must be placed inside of a `const` block + //~^ ERROR tuple constructor with invalid base path accepts_point::<{ CONST_ITEM(N, N) }>(); //~^ ERROR tuple constructor with invalid base path diff --git a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr index ce210b2b3e39..cc6144b9c88a 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr +++ b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find function, tuple struct or tuple variant `UnresolvedIdent` in this scope - --> $DIR/tuple_ctor_erroneous.rs:30:23 + --> $DIR/tuple_ctor_erroneous.rs:29:23 | LL | accepts_point::<{ UnresolvedIdent(N, N) }>(); | ^^^^^^^^^^^^^^^ not found in this scope @@ -10,55 +10,55 @@ LL | fn test_errors() { | +++++++++++++++++++++++++++++++++++ error: tuple constructor has 2 arguments but 1 were provided - --> $DIR/tuple_ctor_erroneous.rs:24:23 + --> $DIR/tuple_ctor_erroneous.rs:23:23 | LL | accepts_point::<{ Point(N) }>(); | ^^^^^^^^ error: tuple constructor has 2 arguments but 3 were provided - --> $DIR/tuple_ctor_erroneous.rs:27:23 + --> $DIR/tuple_ctor_erroneous.rs:26:23 | LL | accepts_point::<{ Point(N, N, N) }>(); | ^^^^^^^^^^^^^^ error: tuple constructor with invalid base path - --> $DIR/tuple_ctor_erroneous.rs:30:23 + --> $DIR/tuple_ctor_erroneous.rs:29:23 | LL | accepts_point::<{ UnresolvedIdent(N, N) }>(); | ^^^^^^^^^^^^^^^^^^^^^ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_ctor_erroneous.rs:34:23 +error: tuple constructor with invalid base path + --> $DIR/tuple_ctor_erroneous.rs:33:23 | LL | accepts_point::<{ non_ctor(N, N) }>(); | ^^^^^^^^^^^^^^ error: tuple constructor with invalid base path - --> $DIR/tuple_ctor_erroneous.rs:37:23 + --> $DIR/tuple_ctor_erroneous.rs:36:23 | LL | accepts_point::<{ CONST_ITEM(N, N) }>(); | ^^^^^^^^^^^^^^^^ error: the constant `Point` is not of type `Point` - --> $DIR/tuple_ctor_erroneous.rs:40:23 + --> $DIR/tuple_ctor_erroneous.rs:39:23 | LL | accepts_point::<{ Point }>(); | ^^^^^ expected `Point`, found struct constructor | note: required by a const generic parameter in `accepts_point` - --> $DIR/tuple_ctor_erroneous.rs:18:18 + --> $DIR/tuple_ctor_erroneous.rs:17:18 | LL | fn accepts_point() {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `accepts_point` error: the constant `MyEnum::::Variant` is not of type `MyEnum` - --> $DIR/tuple_ctor_erroneous.rs:43:22 + --> $DIR/tuple_ctor_erroneous.rs:42:22 | LL | accepts_enum::<{ MyEnum::Variant:: }>(); | ^^^^^^^^^^^^^^^^^^^^^^ expected `MyEnum`, found enum constructor | note: required by a const generic parameter in `accepts_enum` - --> $DIR/tuple_ctor_erroneous.rs:19:17 + --> $DIR/tuple_ctor_erroneous.rs:18:17 | LL | fn accepts_enum>() {} | ^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `accepts_enum` diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs index 5a40c1b14c2d..e47052523fa3 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs @@ -2,8 +2,8 @@ #![expect(incomplete_features)] trait Trait { - - type const ASSOC: usize; + #[type_const] + const ASSOC: usize; } fn takes_tuple() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr index b4853d3c2e38..b294e1032ce8 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr @@ -21,8 +21,6 @@ error: generic parameters may not be used in const operations | LL | takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>(); | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs index 4c040bcaa945..3fde431e27e2 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs @@ -4,7 +4,8 @@ #![expect(incomplete_features)] trait Trait { - type const ASSOC: u32; + #[type_const] + const ASSOC: u32; } fn takes_tuple() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs b/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs deleted file mode 100644 index 4bf62b3a3070..000000000000 --- a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Regression test for -#![expect(incomplete_features)] -#![feature( - adt_const_params, - min_generic_const_args, - unsized_const_params -)] -fn foo() {} -fn bar() {} -fn qux() {} - -fn main() { - foo::<{ (1, true) }>(); - //~^ ERROR: type annotations needed for the literal - bar::<{ (1_u32, [1, 2]) }>(); - //~^ ERROR: expected `i32`, found const array - qux::<{ (1i32, 'a') }>(); - //~^ ERROR: the constant `1` is not of type `char` - //~| ERROR: the constant `'a'` is not of type `i32 -} diff --git a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr b/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr deleted file mode 100644 index 4136c7337cd4..000000000000 --- a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: type annotations needed for the literal - --> $DIR/tuple_expr_type_mismatch.rs:13:14 - | -LL | foo::<{ (1, true) }>(); - | ^ - -error: expected `i32`, found const array - --> $DIR/tuple_expr_type_mismatch.rs:15:21 - | -LL | bar::<{ (1_u32, [1, 2]) }>(); - | ^^^^^^ - -error: the constant `1` is not of type `char` - --> $DIR/tuple_expr_type_mismatch.rs:17:13 - | -LL | qux::<{ (1i32, 'a') }>(); - | ^^^^^^^^^^^ expected `char`, found `i32` - -error: the constant `'a'` is not of type `i32` - --> $DIR/tuple_expr_type_mismatch.rs:17:13 - | -LL | qux::<{ (1i32, 'a') }>(); - | ^^^^^^^^^^^ expected `i32`, found `char` - -error: aborting due to 4 previous errors - diff --git a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs b/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs deleted file mode 100644 index e98b1ad4fe37..000000000000 --- a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ needs-rustc-debug-assertions - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Tr { - type const SIZE: usize; -} - -struct T; - -impl Tr for T { - type const SIZE: usize; - //~^ ERROR associated constant in `impl` without body -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr b/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr deleted file mode 100644 index ba01456ee040..000000000000 --- a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: associated constant in `impl` without body - --> $DIR/type-const-assoc-const-without-body.rs:13:5 - | -LL | type const SIZE: usize; - | ^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: provide a definition for the constant: `= ;` - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/type-const-ctor-148953.rs b/tests/ui/const-generics/mgca/type-const-ctor-148953.rs deleted file mode 100644 index bdd3dcf8618f..000000000000 --- a/tests/ui/const-generics/mgca/type-const-ctor-148953.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Regression test for -//! -//! Unit struct constructors used as the RHS of a `type const` associated -//! const used to ICE during normalization because they were lowered as -//! `Const::new_unevaluated` with a Ctor def_id. Fixed by adding proper const -//! constructor support that produces a concrete ValTree value instead. - -//@ check-pass - -#![feature(min_generic_const_args, adt_const_params)] -#![expect(incomplete_features)] - -use std::marker::ConstParamTy; - -#[derive(ConstParamTy, PartialEq, Eq)] -struct S; - -impl S { - type const N: S = S; -} - -#[derive(ConstParamTy, PartialEq, Eq)] -enum E { - V, -} - -impl E { - type const M: E = { E::V }; -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-inherent-assoc-const-without-body.rs b/tests/ui/const-generics/mgca/type-const-inherent-assoc-const-without-body.rs deleted file mode 100644 index 9fa417637295..000000000000 --- a/tests/ui/const-generics/mgca/type-const-inherent-assoc-const-without-body.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ needs-rustc-debug-assertions - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -impl S { //~ ERROR cannot find type `S` in this scope - type const SIZE: usize; - //~^ ERROR associated constant in `impl` without body -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-inherent-assoc-const-without-body.stderr b/tests/ui/const-generics/mgca/type-const-inherent-assoc-const-without-body.stderr deleted file mode 100644 index b1e1edfa70d6..000000000000 --- a/tests/ui/const-generics/mgca/type-const-inherent-assoc-const-without-body.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: associated constant in `impl` without body - --> $DIR/type-const-inherent-assoc-const-without-body.rs:7:5 - | -LL | type const SIZE: usize; - | ^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: provide a definition for the constant: `= ;` - -error[E0425]: cannot find type `S` in this scope - --> $DIR/type-const-inherent-assoc-const-without-body.rs:6:6 - | -LL | impl S { - | ^ not found in this scope - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/const-generics/mgca/type-const-used-in-trait.rs b/tests/ui/const-generics/mgca/type-const-used-in-trait.rs deleted file mode 100644 index 1efc65bd7018..000000000000 --- a/tests/ui/const-generics/mgca/type-const-used-in-trait.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -type const N: usize = 2; - -trait CollectArray { - fn inner_array(&mut self) -> [A; N]; -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-array-return.rs b/tests/ui/const-generics/mgca/type_const-array-return.rs deleted file mode 100644 index 43db35966a45..000000000000 --- a/tests/ui/const-generics/mgca/type_const-array-return.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ check-pass -// This test should compile without an ICE. -#![expect(incomplete_features)] -#![feature(min_generic_const_args)] - -pub struct A; - -pub trait Array { - type const LEN: usize; - fn arr() -> [u8; Self::LEN]; -} - -impl Array for A { - type const LEN: usize = 4; - - #[allow(unused_braces)] - fn arr() -> [u8; const { Self::LEN }] { - return [0u8; const { Self::LEN }]; - } -} - -fn main() { - let _ = A::arr(); -} diff --git a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.gate.stderr b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.gate.stderr index 095f42355c77..8a64af285da5 100644 --- a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.gate.stderr +++ b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.gate.stderr @@ -1,38 +1,38 @@ error: anonymous constants referencing generics are not yet supported - --> $DIR/type_const-generic-param-in-type.rs:8:58 + --> $DIR/type_const-generic-param-in-type.rs:9:53 | -LL | type const FOO: [T; 0] = const { [] }; - | ^^^^^^^^^^^^ +LL | const FOO: [T; 0] = const { [] }; + | ^^^^^^^^^^^^ error: anonymous constants referencing generics are not yet supported - --> $DIR/type_const-generic-param-in-type.rs:12:43 + --> $DIR/type_const-generic-param-in-type.rs:14:38 | -LL | type const BAR: [(); N] = const { [] }; - | ^^^^^^^^^^^^ +LL | const BAR: [(); N] = const { [] }; + | ^^^^^^^^^^^^ error: anonymous constants with lifetimes in their type are not yet supported - --> $DIR/type_const-generic-param-in-type.rs:16:35 + --> $DIR/type_const-generic-param-in-type.rs:19:30 | -LL | type const BAZ<'a>: [&'a (); 0] = const { [] }; - | ^^^^^^^^^^^^ +LL | const BAZ<'a>: [&'a (); 0] = const { [] }; + | ^^^^^^^^^^^^ error: anonymous constants referencing generics are not yet supported - --> $DIR/type_const-generic-param-in-type.rs:32:64 + --> $DIR/type_const-generic-param-in-type.rs:39:59 | -LL | type const ASSOC: [T; 0] = const { [] }; - | ^^^^^^^^^^^^ +LL | const ASSOC: [T; 0] = const { [] }; + | ^^^^^^^^^^^^ error: anonymous constants referencing generics are not yet supported - --> $DIR/type_const-generic-param-in-type.rs:36:55 + --> $DIR/type_const-generic-param-in-type.rs:44:50 | -LL | type const ASSOC_CONST: [(); N] = const { [] }; - | ^^^^^^^^^^^^ +LL | const ASSOC_CONST: [(); N] = const { [] }; + | ^^^^^^^^^^^^ error: anonymous constants with lifetimes in their type are not yet supported - --> $DIR/type_const-generic-param-in-type.rs:40:44 + --> $DIR/type_const-generic-param-in-type.rs:49:39 | -LL | type const ASSOC_LT<'a>: [&'a (); 0] = const { [] }; - | ^^^^^^^^^^^^ +LL | const ASSOC_LT<'a>: [&'a (); 0] = const { [] }; + | ^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr index b18bd678973a..14ae276324ad 100644 --- a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr +++ b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr @@ -1,56 +1,56 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:8:50 + --> $DIR/type_const-generic-param-in-type.rs:9:45 | -LL | type const FOO: [T; 0] = const { [] }; - | ^ the type must not depend on the parameter `T` +LL | const FOO: [T; 0] = const { [] }; + | ^ the type must not depend on the parameter `T` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:12:38 + --> $DIR/type_const-generic-param-in-type.rs:14:33 | -LL | type const BAR: [(); N] = const { [] }; - | ^ the type must not depend on the parameter `N` +LL | const BAR: [(); N] = const { [] }; + | ^ the type must not depend on the parameter `N` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:16:23 + --> $DIR/type_const-generic-param-in-type.rs:19:18 | -LL | type const BAZ<'a>: [&'a (); 0] = const { [] }; - | ^^ the type must not depend on the parameter `'a` +LL | const BAZ<'a>: [&'a (); 0] = const { [] }; + | ^^ the type must not depend on the parameter `'a` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:21:56 + --> $DIR/type_const-generic-param-in-type.rs:25:51 | -LL | type const ASSOC: [T; 0]; - | ^ the type must not depend on the parameter `T` +LL | const ASSOC: [T; 0]; + | ^ the type must not depend on the parameter `T` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:24:50 + --> $DIR/type_const-generic-param-in-type.rs:29:45 | -LL | type const ASSOC_CONST: [(); N]; - | ^ the type must not depend on the parameter `N` +LL | const ASSOC_CONST: [(); N]; + | ^ the type must not depend on the parameter `N` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:27:32 + --> $DIR/type_const-generic-param-in-type.rs:33:27 | -LL | type const ASSOC_LT<'a>: [&'a (); 0]; - | ^^ the type must not depend on the parameter `'a` +LL | const ASSOC_LT<'a>: [&'a (); 0]; + | ^^ the type must not depend on the parameter `'a` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:32:56 + --> $DIR/type_const-generic-param-in-type.rs:39:51 | -LL | type const ASSOC: [T; 0] = const { [] }; - | ^ the type must not depend on the parameter `T` +LL | const ASSOC: [T; 0] = const { [] }; + | ^ the type must not depend on the parameter `T` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:36:50 + --> $DIR/type_const-generic-param-in-type.rs:44:45 | -LL | type const ASSOC_CONST: [(); N] = const { [] }; - | ^ the type must not depend on the parameter `N` +LL | const ASSOC_CONST: [(); N] = const { [] }; + | ^ the type must not depend on the parameter `N` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:40:32 + --> $DIR/type_const-generic-param-in-type.rs:49:27 | -LL | type const ASSOC_LT<'a>: [&'a (); 0] = const { [] }; - | ^^ the type must not depend on the parameter `'a` +LL | const ASSOC_LT<'a>: [&'a (); 0] = const { [] }; + | ^^ the type must not depend on the parameter `'a` error: aborting due to 9 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs index 72ae464822e4..f1a4aba9bcee 100644 --- a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs +++ b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs @@ -5,39 +5,48 @@ #![feature(adt_const_params, unsized_const_params, min_generic_const_args, generic_const_items)] #![cfg_attr(gate, feature(generic_const_parameter_types))] -type const FOO: [T; 0] = const { [] }; +#[type_const] +const FOO: [T; 0] = const { [] }; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters //[gate]~^^ ERROR anonymous constants referencing generics are not yet supported -type const BAR: [(); N] = const { [] }; +#[type_const] +const BAR: [(); N] = const { [] }; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters //[gate]~^^ ERROR anonymous constants referencing generics are not yet supported -type const BAZ<'a>: [&'a (); 0] = const { [] }; +#[type_const] +const BAZ<'a>: [&'a (); 0] = const { [] }; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters //[gate]~^^ ERROR anonymous constants with lifetimes in their type are not yet supported trait Tr { - type const ASSOC: [T; 0]; + #[type_const] + const ASSOC: [T; 0]; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters - type const ASSOC_CONST: [(); N]; + #[type_const] + const ASSOC_CONST: [(); N]; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters - type const ASSOC_LT<'a>: [&'a (); 0]; + #[type_const] + const ASSOC_LT<'a>: [&'a (); 0]; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters } impl Tr for () { - type const ASSOC: [T; 0] = const { [] }; + #[type_const] + const ASSOC: [T; 0] = const { [] }; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters //[gate]~^^ ERROR anonymous constants referencing generics are not yet supported - type const ASSOC_CONST: [(); N] = const { [] }; + #[type_const] + const ASSOC_CONST: [(); N] = const { [] }; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters //[gate]~^^ ERROR anonymous constants referencing generics are not yet supported - type const ASSOC_LT<'a>: [&'a (); 0] = const { [] }; + #[type_const] + const ASSOC_LT<'a>: [&'a (); 0] = const { [] }; //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters //[gate]~^^ ERROR anonymous constants with lifetimes in their type are not yet supported } diff --git a/tests/ui/const-generics/mgca/type_const-incemental-compile.rs b/tests/ui/const-generics/mgca/type_const-incemental-compile.rs deleted file mode 100644 index 7094d89d5062..000000000000 --- a/tests/ui/const-generics/mgca/type_const-incemental-compile.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass -//@compile-flags: -Clink-dead-code=true -// link-dead-code tries to eagerly monomorphize and collect items -// This lead to collector.rs to try and evaluate a type_const -// which will fail since they do not have bodies. -#![expect(incomplete_features)] -#![feature(min_generic_const_args)] - -type const TYPE_CONST: usize = 0; -fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs index 3262e79478bd..b2c734098009 100644 --- a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs +++ b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs @@ -4,7 +4,8 @@ struct A; impl A { - type const B = 4; + #[type_const] + const B = 4; //~^ ERROR: missing type for `const` item } diff --git a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr index 77e54ab2f2e9..b44e47cd7e61 100644 --- a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr +++ b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr @@ -1,13 +1,13 @@ error: missing type for `const` item - --> $DIR/type_const-inherent-const-omitted-type.rs:7:17 + --> $DIR/type_const-inherent-const-omitted-type.rs:8:12 | -LL | type const B = 4; - | ^ +LL | const B = 4; + | ^ | help: provide a type for the item | -LL | type const B: = 4; - | ++++++++ +LL | const B: = 4; + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/type_const-mismatched-types.rs b/tests/ui/const-generics/mgca/type_const-mismatched-types.rs index c73785f9a3e3..8d2eae71d330 100644 --- a/tests/ui/const-generics/mgca/type_const-mismatched-types.rs +++ b/tests/ui/const-generics/mgca/type_const-mismatched-types.rs @@ -1,19 +1,22 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -type const FREE: u32 = 5_usize; -//~^ ERROR the constant `5` is not of type `u32` -//~| ERROR mismatched types +#[type_const] +const FREE: u32 = 5_usize; +//~^ ERROR mismatched types -type const FREE2: isize = FREE; +#[type_const] +const FREE2: isize = FREE; //~^ ERROR the constant `5` is not of type `isize` trait Tr { - type const N: usize; + #[type_const] + const N: usize; } impl Tr for () { - type const N: usize = false; + #[type_const] + const N: usize = false; //~^ ERROR mismatched types } diff --git a/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr b/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr index f7f64c535f60..4029bb7b6bff 100644 --- a/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr +++ b/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr @@ -1,33 +1,27 @@ -error: the constant `5` is not of type `u32` - --> $DIR/type_const-mismatched-types.rs:4:1 - | -LL | type const FREE: u32 = 5_usize; - | ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize` - error: the constant `5` is not of type `isize` - --> $DIR/type_const-mismatched-types.rs:8:1 + --> $DIR/type_const-mismatched-types.rs:9:1 | -LL | type const FREE2: isize = FREE; - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `usize` +LL | const FREE2: isize = FREE; + | ^^^^^^^^^^^^^^^^^^ expected `isize`, found `u32` error[E0308]: mismatched types - --> $DIR/type_const-mismatched-types.rs:16:27 + --> $DIR/type_const-mismatched-types.rs:5:19 | -LL | type const N: usize = false; - | ^^^^^ expected `usize`, found `bool` - -error[E0308]: mismatched types - --> $DIR/type_const-mismatched-types.rs:4:24 - | -LL | type const FREE: u32 = 5_usize; - | ^^^^^^^ expected `u32`, found `usize` +LL | const FREE: u32 = 5_usize; + | ^^^^^^^ expected `u32`, found `usize` | help: change the type of the numeric literal from `usize` to `u32` | -LL - type const FREE: u32 = 5_usize; -LL + type const FREE: u32 = 5_u32; +LL - const FREE: u32 = 5_usize; +LL + const FREE: u32 = 5_u32; | -error: aborting due to 4 previous errors +error[E0308]: mismatched types + --> $DIR/type_const-mismatched-types.rs:19:22 + | +LL | const N: usize = false; + | ^^^^^ expected `usize`, found `bool` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/mgca/type_const-not-constparamty.rs b/tests/ui/const-generics/mgca/type_const-not-constparamty.rs index b78bb4ca599d..11db82187b84 100644 --- a/tests/ui/const-generics/mgca/type_const-not-constparamty.rs +++ b/tests/ui/const-generics/mgca/type_const-not-constparamty.rs @@ -5,18 +5,21 @@ struct S; // FIXME(mgca): need support for ctors without anon const // (we use a const-block to trigger an anon const here) -type const FREE: S = const { S }; +#[type_const] +const FREE: S = const { S }; //~^ ERROR `S` must implement `ConstParamTy` to be used as the type of a const generic parameter trait Tr { - type const N: S; + #[type_const] + const N: S; //~^ ERROR `S` must implement `ConstParamTy` to be used as the type of a const generic parameter } impl Tr for S { // FIXME(mgca): need support for ctors without anon const // (we use a const-block to trigger an anon const here) - type const N: S = const { S }; + #[type_const] + const N: S = const { S }; //~^ ERROR `S` must implement `ConstParamTy` to be used as the type of a const generic parameter } diff --git a/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr b/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr index 2cbb644f2c71..d07bbde1e62e 100644 --- a/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr +++ b/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr @@ -1,8 +1,8 @@ error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter - --> $DIR/type_const-not-constparamty.rs:8:18 + --> $DIR/type_const-not-constparamty.rs:9:13 | -LL | type const FREE: S = const { S }; - | ^ +LL | const FREE: S = const { S }; + | ^ | help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct | @@ -11,10 +11,10 @@ LL | struct S; | error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter - --> $DIR/type_const-not-constparamty.rs:19:19 + --> $DIR/type_const-not-constparamty.rs:22:14 | -LL | type const N: S = const { S }; - | ^ +LL | const N: S = const { S }; + | ^ | help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct | @@ -23,10 +23,10 @@ LL | struct S; | error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter - --> $DIR/type_const-not-constparamty.rs:12:19 + --> $DIR/type_const-not-constparamty.rs:14:14 | -LL | type const N: S; - | ^ +LL | const N: S; + | ^ | help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct | diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs index f4cf3a4c5ce9..ac4c4fb59419 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs @@ -1,11 +1,11 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args, generic_const_items)] - -type const FREE1: usize = const { std::mem::size_of::() }; +#[type_const] +const FREE1: usize = const { std::mem::size_of::() }; //~^ ERROR generic parameters may not be used in const operations - -type const FREE2: usize = const { I + 1 }; +#[type_const] +const FREE2: usize = const { I + 1 }; //~^ ERROR generic parameters may not be used in const operations fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr index 475d2cf312d6..f339e82beeed 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr @@ -1,18 +1,14 @@ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:5:58 + --> $DIR/type_const-on-generic-expr.rs:5:53 | -LL | type const FREE1: usize = const { std::mem::size_of::() }; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items +LL | const FREE1: usize = const { std::mem::size_of::() }; + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:8:51 + --> $DIR/type_const-on-generic-expr.rs:8:46 | -LL | type const FREE2: usize = const { I + 1 }; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items +LL | const FREE2: usize = const { I + 1 }; + | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs index 2a26138d373f..37de4d4a4abb 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs +++ b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs @@ -2,19 +2,25 @@ #![feature(min_generic_const_args, generic_const_items)] pub trait Tr { - type const N1: usize; - type const N2: usize; - type const N3: usize; + #[type_const] + const N1: usize; + #[type_const] + const N2: usize; + #[type_const] + const N3: usize; } pub struct S; impl Tr for S { - type const N1: usize = const { std::mem::size_of::() }; + #[type_const] + const N1: usize = const { std::mem::size_of::() }; //~^ ERROR generic parameters may not be used in const operations - type const N2: usize = const { I + 1 }; + #[type_const] + const N2: usize = const { I + 1 }; //~^ ERROR generic parameters may not be used in const operations - type const N3: usize = const { 2 & X }; + #[type_const] + const N3: usize = const { 2 & X }; //~^ ERROR generic parameters may not be used in const operations } diff --git a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr index e13d6fbcdd82..9d4e99ca0aaf 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr +++ b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr @@ -1,26 +1,20 @@ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic_expr-2.rs:13:59 + --> $DIR/type_const-on-generic_expr-2.rs:17:54 | -LL | type const N1: usize = const { std::mem::size_of::() }; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items +LL | const N1: usize = const { std::mem::size_of::() }; + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic_expr-2.rs:15:52 + --> $DIR/type_const-on-generic_expr-2.rs:20:47 | -LL | type const N2: usize = const { I + 1 }; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items +LL | const N2: usize = const { I + 1 }; + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic_expr-2.rs:17:40 + --> $DIR/type_const-on-generic_expr-2.rs:23:35 | -LL | type const N3: usize = const { 2 & X }; - | ^ - | - = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items +LL | const N3: usize = const { 2 & X }; + | ^ error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs index a7ff9f0ce03f..ab613859aa5c 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs @@ -8,13 +8,14 @@ trait BadTr { struct GoodS; impl BadTr for GoodS { - type const NUM: = 84; + #[type_const] + const NUM: = 84; //~^ ERROR: missing type for `const` item } fn accept_bad_tr>(_x: &T) {} -//~^ ERROR use of trait associated const not defined as `type const` +//~^ ERROR use of trait associated const without `#[type_const]` fn main() { accept_bad_tr::<84, _>(&GoodS); diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr index 11a60246f6a6..16f312454ed2 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr @@ -1,16 +1,16 @@ error: missing type for `const` item - --> $DIR/type_const-only-in-impl-omitted-type.rs:11:20 + --> $DIR/type_const-only-in-impl-omitted-type.rs:12:15 | -LL | type const NUM: = 84; - | ^ help: provide a type for the associated constant: `usize` +LL | const NUM: = 84; + | ^ help: provide a type for the associated constant: `usize` -error: use of trait associated const not defined as `type const` - --> $DIR/type_const-only-in-impl-omitted-type.rs:16:43 +error: use of trait associated const without `#[type_const]` + --> $DIR/type_const-only-in-impl-omitted-type.rs:17:43 | LL | fn accept_bad_tr>(_x: &T) {} | ^^^^^^^^^^^ | - = note: the declaration in the trait must begin with `type const` not just `const` alone + = note: the declaration in the trait must be marked with `#[type_const]` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl.rs b/tests/ui/const-generics/mgca/type_const-only-in-impl.rs index e016908b3cc3..1887f511bd62 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl.rs +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl.rs @@ -8,11 +8,12 @@ trait BadTr { struct GoodS; impl BadTr for GoodS { - type const NUM: usize = 84; + #[type_const] + const NUM: usize = 84; } fn accept_bad_tr>(_x: &T) {} -//~^ ERROR use of trait associated const not defined as `type const` +//~^ ERROR use of trait associated const without `#[type_const]` fn main() { accept_bad_tr::<84, _>(&GoodS); diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr b/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr index 55d5cca6ba69..44632e46fb07 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr @@ -1,10 +1,10 @@ -error: use of trait associated const not defined as `type const` - --> $DIR/type_const-only-in-impl.rs:14:43 +error: use of trait associated const without `#[type_const]` + --> $DIR/type_const-only-in-impl.rs:15:43 | LL | fn accept_bad_tr>(_x: &T) {} | ^^^^^^^^^^^ | - = note: the declaration in the trait must begin with `type const` not just `const` alone + = note: the declaration in the trait must be marked with `#[type_const]` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/type_const-only-in-trait.rs b/tests/ui/const-generics/mgca/type_const-only-in-trait.rs index 1def66a1ba68..2ff38648206a 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-trait.rs +++ b/tests/ui/const-generics/mgca/type_const-only-in-trait.rs @@ -2,14 +2,15 @@ #![feature(min_generic_const_args)] trait GoodTr { - type const NUM: usize; + #[type_const] + const NUM: usize; } struct BadS; impl GoodTr for BadS { const NUM: usize = 42; - //~^ ERROR implementation of a `type const` must also be marked as `type const` + //~^ ERROR implementation of `#[type_const]` const must be marked with `#[type_const]` } fn accept_good_tr>(_x: &T) {} diff --git a/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr b/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr index f98b4d9cbbfd..29f1b724960a 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr +++ b/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr @@ -1,14 +1,16 @@ -error: implementation of a `type const` must also be marked as `type const` - --> $DIR/type_const-only-in-trait.rs:11:5 +error: implementation of `#[type_const]` const must be marked with `#[type_const]` + --> $DIR/type_const-only-in-trait.rs:12:5 | LL | const NUM: usize = 42; | ^^^^^^^^^^^^^^^^ | -note: trait declaration of const is marked as `type const` +note: trait declaration of const is marked with `#[type_const]` --> $DIR/type_const-only-in-trait.rs:5:5 | -LL | type const NUM: usize; - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[type_const] + | ^^^^^^^^^^^^^ +LL | const NUM: usize; + | ^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/type_const-pub.rs b/tests/ui/const-generics/mgca/type_const-pub.rs index 70fab75901b9..fc5b1ce36a14 100644 --- a/tests/ui/const-generics/mgca/type_const-pub.rs +++ b/tests/ui/const-generics/mgca/type_const-pub.rs @@ -5,7 +5,6 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -pub type const TYPE_CONST : usize = 1; -fn main() { - print!("{}", TYPE_CONST) -} +#[type_const] +pub const TYPE_CONST : usize = 1; +fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-recursive.rs b/tests/ui/const-generics/mgca/type_const-recursive.rs index ebaab51bbc3b..15e49f747ed6 100644 --- a/tests/ui/const-generics/mgca/type_const-recursive.rs +++ b/tests/ui/const-generics/mgca/type_const-recursive.rs @@ -1,8 +1,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] - -type const A: u8 = A; +#[type_const] +const A: u8 = A; //~^ ERROR: overflow normalizing the unevaluated constant `A` [E0275] fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-recursive.stderr b/tests/ui/const-generics/mgca/type_const-recursive.stderr index d21ccb22bc90..947319ec7eda 100644 --- a/tests/ui/const-generics/mgca/type_const-recursive.stderr +++ b/tests/ui/const-generics/mgca/type_const-recursive.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow normalizing the unevaluated constant `A` --> $DIR/type_const-recursive.rs:5:1 | -LL | type const A: u8 = A; - | ^^^^^^^^^^^^^^^^ +LL | const A: u8 = A; + | ^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/const-generics/mgca/type_const-use.rs b/tests/ui/const-generics/mgca/type_const-use.rs index f295bf465e30..04362cd28538 100644 --- a/tests/ui/const-generics/mgca/type_const-use.rs +++ b/tests/ui/const-generics/mgca/type_const-use.rs @@ -3,7 +3,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -type const CONST: usize = 1; +#[type_const] +const CONST: usize = 1; fn uses_const() { CONST; diff --git a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs index cf75b45b9ff0..588fa2f913b6 100644 --- a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs +++ b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs @@ -32,10 +32,10 @@ fn generic() { const NON_TYPE_CONST: usize = const { 1 }; - -type const TYPE_CONST: usize = const { 1 }; -//~^ ERROR: `type const` syntax is experimental [E0658] -//~| ERROR: top-level `type const` are unstable [E0658] +#[type_const] +//~^ ERROR: the `#[type_const]` attribute is an experimental feature +const TYPE_CONST: usize = const { 1 }; +//~^ ERROR: unbraced const blocks as const args are experimental static STATIC: usize = const { 1 }; diff --git a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr index dbcb8c56ac5b..00db630c27e9 100644 --- a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr +++ b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr @@ -48,21 +48,21 @@ LL | generic::(); = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `type const` syntax is experimental - --> $DIR/unbraced_const_block_const_arg_gated.rs:36:1 +error[E0658]: unbraced const blocks as const args are experimental + --> $DIR/unbraced_const_block_const_arg_gated.rs:37:27 | -LL | type const TYPE_CONST: usize = const { 1 }; - | ^^^^^^^^^^ +LL | const TYPE_CONST: usize = const { 1 }; + | ^^^^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: top-level `type const` are unstable - --> $DIR/unbraced_const_block_const_arg_gated.rs:36:1 +error[E0658]: the `#[type_const]` attribute is an experimental feature + --> $DIR/unbraced_const_block_const_arg_gated.rs:35:1 | -LL | type const TYPE_CONST: usize = const { 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[type_const] + | ^^^^^^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable diff --git a/tests/ui/const-generics/mgca/unmarked-free-const.rs b/tests/ui/const-generics/mgca/unmarked-free-const.rs deleted file mode 100644 index d6d9b936d95b..000000000000 --- a/tests/ui/const-generics/mgca/unmarked-free-const.rs +++ /dev/null @@ -1,11 +0,0 @@ -// regression test, used to ICE - -#![feature(min_generic_const_args)] -#![allow(incomplete_features)] - -const N: usize = 4; - -fn main() { - let x = [(); N]; - //~^ ERROR use of `const` in the type system not defined as `type const` -} diff --git a/tests/ui/const-generics/mgca/unmarked-free-const.stderr b/tests/ui/const-generics/mgca/unmarked-free-const.stderr deleted file mode 100644 index 76875d8db0ef..000000000000 --- a/tests/ui/const-generics/mgca/unmarked-free-const.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: use of `const` in the type system not defined as `type const` - --> $DIR/unmarked-free-const.rs:9:18 - | -LL | const N: usize = 4; - | - help: add `type` before `const` for `N`: `type` -... -LL | let x = [(); N]; - | ^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs deleted file mode 100644 index 8a2117096a4a..000000000000 --- a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs +++ /dev/null @@ -1,13 +0,0 @@ -// This test causes ERROR: mismatched types [E0308] -// and makes rustc to print array from const arguments -#![feature(min_generic_const_args, adt_const_params)] -#![allow(incomplete_features)] - -struct TakesArr; - -fn foo() { - let _: TakesArr<{ [N] }> = TakesArr::<{ [1] }>; - //~^ ERROR: mismatched types [E0308] -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.stderr b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.stderr deleted file mode 100644 index a2e212b28ec6..000000000000 --- a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/wrong_type_const_arr_diag.rs:9:32 - | -LL | let _: TakesArr<{ [N] }> = TakesArr::<{ [1] }>; - | ----------------- ^^^^^^^^^^^^^^^^^^^ expected `[N]`, found `*b"\x01"` - | | - | expected due to this - | - = note: expected struct `TakesArr<[N]>` - found struct `TakesArr<*b"\x01">` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs deleted file mode 100644 index 909189ae4875..000000000000 --- a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This test causes ERROR: mismatched types [E0308] -// and makes rustc to print array from const arguments -#![feature(min_generic_const_args, adt_const_params, trivial_bounds)] -#![allow(incomplete_features)] - -trait Trait { - - type const ASSOC: u8; -} - -struct TakesArr; - -fn foo() -where - u8: Trait -{ - let _: TakesArr<{ [::ASSOC] }> = TakesArr::<{ [1] }>; - //~^ ERROR: mismatched types [E0308] -} - -fn main() {} diff --git a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.stderr b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.stderr deleted file mode 100644 index 66de4a4d6a86..000000000000 --- a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/wrong_type_const_arr_diag_trait.rs:17:51 - | -LL | let _: TakesArr<{ [::ASSOC] }> = TakesArr::<{ [1] }>; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^ expected `[::ASSOC]`, found `*b"\x01"` - | | - | expected due to this - | - = note: expected struct `TakesArr<[::ASSOC]>` - found struct `TakesArr<*b"\x01">` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr index df7c2a0a8629..cc6a813b747d 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr @@ -1,27 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:31:21 - | -LL | get_flag::(); - | ^^^^ expected `char`, found `u8` - -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:14 - | -LL | get_flag::<7, 'c'>(); - | ^ expected `bool`, found integer - -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:35:14 - | -LL | get_flag::<42, 0x5ad>(); - | ^^ expected `bool`, found integer - -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:35:18 - | -LL | get_flag::<42, 0x5ad>(); - | ^^^^^ expected `char`, found `u8` - error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | @@ -64,6 +40,30 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character ff __ __ __ │ .░░░ } +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:31:21 + | +LL | get_flag::(); + | ^^^^ expected `char`, found `u8` + +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:33:14 + | +LL | get_flag::<7, 'c'>(); + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:35:14 + | +LL | get_flag::<42, 0x5ad>(); + | ^^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:35:18 + | +LL | get_flag::<42, 0x5ad>(); + | ^^^^^ expected `char`, found `u8` + error: aborting due to 8 previous errors Some errors have detailed explanations: E0080, E0308. diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr index df7c2a0a8629..cc6a813b747d 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr @@ -1,27 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:31:21 - | -LL | get_flag::(); - | ^^^^ expected `char`, found `u8` - -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:14 - | -LL | get_flag::<7, 'c'>(); - | ^ expected `bool`, found integer - -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:35:14 - | -LL | get_flag::<42, 0x5ad>(); - | ^^ expected `bool`, found integer - -error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:35:18 - | -LL | get_flag::<42, 0x5ad>(); - | ^^^^^ expected `char`, found `u8` - error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | @@ -64,6 +40,30 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character ff __ __ __ │ .░░░ } +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:31:21 + | +LL | get_flag::(); + | ^^^^ expected `char`, found `u8` + +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:33:14 + | +LL | get_flag::<7, 'c'>(); + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:35:14 + | +LL | get_flag::<42, 0x5ad>(); + | ^^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/invalid-patterns.rs:35:18 + | +LL | get_flag::<42, 0x5ad>(); + | ^^^^^ expected `char`, found `u8` + error: aborting due to 8 previous errors Some errors have detailed explanations: E0080, E0308. diff --git a/tests/ui/const-generics/ogca/basic-fail.rs b/tests/ui/const-generics/ogca/basic-fail.rs deleted file mode 100644 index e3db3dea3735..000000000000 --- a/tests/ui/const-generics/ogca/basic-fail.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(generic_const_items)] -#![feature(min_generic_const_args)] -#![feature(opaque_generic_const_args)] -#![expect(incomplete_features)] - -type const ADD1: usize = const { N + 1 }; - -type const INC: usize = const { N + 1 }; - -type const ONE: usize = ADD1::<0>; - -type const OTHER_ONE: usize = INC::<0>; - -// Not definitionally equal. -const ARR: [(); ADD1::<0>] = [(); INC::<0>]; -//~^ ERROR mismatched types - -fn main() {} diff --git a/tests/ui/const-generics/ogca/basic-fail.stderr b/tests/ui/const-generics/ogca/basic-fail.stderr deleted file mode 100644 index ce4e8eb1471c..000000000000 --- a/tests/ui/const-generics/ogca/basic-fail.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/basic-fail.rs:15:30 - | -LL | const ARR: [(); ADD1::<0>] = [(); INC::<0>]; - | ^^^^^^^^^^^^^^ expected an array with a size of const { N + 1 }, found one with a size of const { N + 1 } - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/ogca/basic.rs b/tests/ui/const-generics/ogca/basic.rs deleted file mode 100644 index e736484b5c3c..000000000000 --- a/tests/ui/const-generics/ogca/basic.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ check-pass - -#![feature(generic_const_items)] -#![feature(min_generic_const_args)] -#![feature(opaque_generic_const_args)] -#![expect(incomplete_features)] - -type const ADD1: usize = const { N + 1 }; - -type const INC: usize = ADD1::; - -type const ONE: usize = ADD1::<0>; - -type const OTHER_ONE: usize = INC::<0>; - -const ARR: [(); ADD1::<0>] = [(); INC::<0>]; - -fn main() {} diff --git a/tests/ui/const-generics/ogca/coherence-ambiguous.rs b/tests/ui/const-generics/ogca/coherence-ambiguous.rs deleted file mode 100644 index 21efe4cfe981..000000000000 --- a/tests/ui/const-generics/ogca/coherence-ambiguous.rs +++ /dev/null @@ -1,19 +0,0 @@ -// FIXME(ogca): this should ERROR not pass!! -//@ check-pass - -#![feature(generic_const_items, min_generic_const_args, opaque_generic_const_args)] -#![expect(incomplete_features)] - -type const FOO: usize = const { N + 1 }; - -type const BAR: usize = const { N + 1 }; - -trait Trait {} - -impl Trait for [(); FOO::<1>] {} -impl Trait for [(); BAR::<1>] {} -// FIXME(ogca): this should ERROR! -impl Trait for [(); BAR::<2>] {} -// FIXME(ogca): this should ERROR! - -fn main() {} diff --git a/tests/ui/const-generics/ogca/rhs-but-not-root.rs b/tests/ui/const-generics/ogca/rhs-but-not-root.rs deleted file mode 100644 index 2897b16d493f..000000000000 --- a/tests/ui/const-generics/ogca/rhs-but-not-root.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(generic_const_items)] -#![feature(min_generic_const_args)] -#![feature(opaque_generic_const_args)] -#![expect(incomplete_features)] - -// Anon consts must be the root of the RHS to be OGCA. -type const FOO: usize = ID::; -//~^ ERROR generic parameters may not be used in const operations - -type const ID: usize = N; - -fn main() {} diff --git a/tests/ui/const-generics/ogca/rhs-but-not-root.stderr b/tests/ui/const-generics/ogca/rhs-but-not-root.stderr deleted file mode 100644 index c720b58b9bde..000000000000 --- a/tests/ui/const-generics/ogca/rhs-but-not-root.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: generic parameters may not be used in const operations - --> $DIR/rhs-but-not-root.rs:7:54 - | -LL | type const FOO: usize = ID::; - | ^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs index 808d960da68b..49c88856bc96 100644 --- a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs @@ -4,6 +4,8 @@ use std::convert::TryFrom; pub fn test_usage(p: ()) { SmallCString::try_from(p).map(|cstr| cstr); //~^ ERROR: type annotations needed + //~| ERROR: type annotations needed + //~| ERROR: type annotations needed } pub struct SmallCString {} diff --git a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr index c80efd6df8a8..1557b83b00ec 100644 --- a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr @@ -7,7 +7,7 @@ LL | SmallCString::try_from(p).map(|cstr| cstr); | type must be known at this point | note: required by a const generic parameter in `SmallCString` - --> $DIR/try-from-with-const-genericsrs-98299.rs:9:25 + --> $DIR/try-from-with-const-genericsrs-98299.rs:11:25 | LL | pub struct SmallCString {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString` @@ -16,6 +16,46 @@ help: consider giving this closure parameter an explicit type, where the value o LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); | +++++++++++++++++ -error: aborting due to 1 previous error +error[E0284]: type annotations needed for `SmallCString<_>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 + | +LL | SmallCString::try_from(p).map(|cstr| cstr); + | ------------ ^^^^ + | | + | type must be known at this point + | +note: required for `SmallCString<_>` to implement `TryFrom<()>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:13:22 + | +LL | impl TryFrom<()> for SmallCString { + | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified + | +LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); + | +++++++++++++++++ + +error[E0284]: type annotations needed for `SmallCString<_>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 + | +LL | SmallCString::try_from(p).map(|cstr| cstr); + | ------------------------- ^^^^ + | | + | type must be known at this point + | +note: required for `SmallCString<_>` to implement `TryFrom<()>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:13:22 + | +LL | impl TryFrom<()> for SmallCString { + | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified + | +LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); + | +++++++++++++++++ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/const-generics/type-dependent/type-mismatch.full.stderr b/tests/ui/const-generics/type-dependent/type-mismatch.full.stderr index 9de140dab9eb..95d20de1b432 100644 --- a/tests/ui/const-generics/type-dependent/type-mismatch.full.stderr +++ b/tests/ui/const-generics/type-dependent/type-mismatch.full.stderr @@ -1,15 +1,3 @@ -error: the constant `1` is not of type `u8` - --> $DIR/type-mismatch.rs:8:27 - | -LL | assert_eq!(R.method::<1u16>(), 1); - | ^^^^ expected `u8`, found `u16` - | -note: required by a const generic parameter in `R::method` - --> $DIR/type-mismatch.rs:5:15 - | -LL | fn method(&self) -> u8 { N } - | ^^^^^^^^^^^ required by this const generic parameter in `R::method` - error[E0308]: mismatched types --> $DIR/type-mismatch.rs:8:27 | @@ -22,6 +10,6 @@ LL - assert_eq!(R.method::<1u16>(), 1); LL + assert_eq!(R.method::<1u8>(), 1); | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/type-dependent/type-mismatch.min.stderr b/tests/ui/const-generics/type-dependent/type-mismatch.min.stderr index 9de140dab9eb..95d20de1b432 100644 --- a/tests/ui/const-generics/type-dependent/type-mismatch.min.stderr +++ b/tests/ui/const-generics/type-dependent/type-mismatch.min.stderr @@ -1,15 +1,3 @@ -error: the constant `1` is not of type `u8` - --> $DIR/type-mismatch.rs:8:27 - | -LL | assert_eq!(R.method::<1u16>(), 1); - | ^^^^ expected `u8`, found `u16` - | -note: required by a const generic parameter in `R::method` - --> $DIR/type-mismatch.rs:5:15 - | -LL | fn method(&self) -> u8 { N } - | ^^^^^^^^^^^ required by this const generic parameter in `R::method` - error[E0308]: mismatched types --> $DIR/type-mismatch.rs:8:27 | @@ -22,6 +10,6 @@ LL - assert_eq!(R.method::<1u16>(), 1); LL + assert_eq!(R.method::<1u8>(), 1); | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/type-dependent/type-mismatch.rs b/tests/ui/const-generics/type-dependent/type-mismatch.rs index fc7ae994184b..6ed5fdca30ae 100644 --- a/tests/ui/const-generics/type-dependent/type-mismatch.rs +++ b/tests/ui/const-generics/type-dependent/type-mismatch.rs @@ -6,6 +6,5 @@ impl R { } fn main() { assert_eq!(R.method::<1u16>(), 1); - //~^ ERROR the constant `1` is not of type `u8` - //~| ERROR mismatched types + //~^ ERROR mismatched types } diff --git a/tests/ui/const-generics/type-relative-path-144547.rs b/tests/ui/const-generics/type-relative-path-144547.rs index e3532fe635c2..b268055e1f7d 100644 --- a/tests/ui/const-generics/type-relative-path-144547.rs +++ b/tests/ui/const-generics/type-relative-path-144547.rs @@ -2,21 +2,20 @@ //@ revisions: min mgca //@[mgca] check-pass -#![allow(incomplete_features)] -#![feature(mgca_type_const_syntax)] + #![cfg_attr(mgca, feature(min_generic_const_args))] -// FIXME(mgca) syntax is it's own feature flag before -// expansion and is also an incomplete feature. -//#![cfg_attr(mgca, expect(incomplete_features))] +#![cfg_attr(mgca, expect(incomplete_features))] trait UnderlyingImpl { type InfoType: LevelInfo; type SupportedArray; } +// FIXME: cfg_attr(..., type_const) is broken (search for sym::type_const in compiler/) trait LevelInfo { #[cfg(mgca)] - type const SUPPORTED_SLOTS: usize; + #[type_const] + const SUPPORTED_SLOTS: usize; #[cfg(not(mgca))] const SUPPORTED_SLOTS: usize; @@ -26,7 +25,8 @@ struct Info; impl LevelInfo for Info { #[cfg(mgca)] - type const SUPPORTED_SLOTS: usize = 1; + #[type_const] + const SUPPORTED_SLOTS: usize = 1; #[cfg(not(mgca))] const SUPPORTED_SLOTS: usize = 1; diff --git a/tests/ui/const-generics/vec-macro-in-static-array.stderr b/tests/ui/const-generics/vec-macro-in-static-array.stderr index 63d7b0c89fa1..de21f2274f3a 100644 --- a/tests/ui/const-generics/vec-macro-in-static-array.stderr +++ b/tests/ui/const-generics/vec-macro-in-static-array.stderr @@ -6,6 +6,7 @@ LL | static VEC: [u32; 256] = vec![]; | = note: expected array `[u32; 256]` found struct `Vec<_>` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-item-with-block-body/macro-codegen.rs b/tests/ui/consts/const-block-item-macro-codegen.rs similarity index 100% rename from tests/ui/consts/const-item-with-block-body/macro-codegen.rs rename to tests/ui/consts/const-block-item-macro-codegen.rs diff --git a/tests/ui/consts/const-item-with-block-body/static.rs b/tests/ui/consts/const-block-item.rs similarity index 100% rename from tests/ui/consts/const-item-with-block-body/static.rs rename to tests/ui/consts/const-block-item.rs diff --git a/tests/ui/consts/const-item-with-block-body/static.stderr b/tests/ui/consts/const-block-item.stderr similarity index 84% rename from tests/ui/consts/const-item-with-block-body/static.stderr rename to tests/ui/consts/const-block-item.stderr index feaabb92803f..b325976a60b6 100644 --- a/tests/ui/consts/const-item-with-block-body/static.stderr +++ b/tests/ui/consts/const-block-item.stderr @@ -1,5 +1,5 @@ warning: trait `Value` is never used - --> $DIR/static.rs:5:15 + --> $DIR/const-block-item.rs:5:15 | LL | pub trait Value { | ^^^^^ diff --git a/tests/ui/consts/const-block-items/assert-fail.rs b/tests/ui/consts/const-block-items/assert-fail.rs deleted file mode 100644 index a7e3478666ef..000000000000 --- a/tests/ui/consts/const-block-items/assert-fail.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-fail - -#![feature(const_block_items)] - -const { assert!(false) } -//~^ ERROR: evaluation panicked: assertion failed: false [E0080] -const { assert!(2 + 2 == 5) } -//~^ ERROR: evaluation panicked: assertion failed: 2 + 2 == 5 [E0080] - -fn main() {} diff --git a/tests/ui/consts/const-block-items/assert-fail.stderr b/tests/ui/consts/const-block-items/assert-fail.stderr deleted file mode 100644 index b1444dc5e0d0..000000000000 --- a/tests/ui/consts/const-block-items/assert-fail.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0080]: evaluation panicked: assertion failed: false - --> $DIR/assert-fail.rs:5:9 - | -LL | const { assert!(false) } - | ^^^^^^^^^^^^^^ evaluation of `_` failed here - -error[E0080]: evaluation panicked: assertion failed: 2 + 2 == 5 - --> $DIR/assert-fail.rs:7:9 - | -LL | const { assert!(2 + 2 == 5) } - | ^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-block-items/assert-pass.rs b/tests/ui/consts/const-block-items/assert-pass.rs deleted file mode 100644 index c409cc5b91f7..000000000000 --- a/tests/ui/consts/const-block-items/assert-pass.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ check-pass -#![feature(const_block_items)] - -const { assert!(true) } -const { assert!(2 + 2 == 4) } - -fn main() {} diff --git a/tests/ui/consts/const-block-items/hir.rs b/tests/ui/consts/const-block-items/hir.rs deleted file mode 100644 index 1d9c5e91b57e..000000000000 --- a/tests/ui/consts/const-block-items/hir.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ build-pass -//@ compile-flags: -Zunpretty=hir - -#![feature(const_block_items)] - -const { - // foo -} - -fn main() { } diff --git a/tests/ui/consts/const-block-items/hir.stdout b/tests/ui/consts/const-block-items/hir.stdout deleted file mode 100644 index 2b7f0818556f..000000000000 --- a/tests/ui/consts/const-block-items/hir.stdout +++ /dev/null @@ -1,14 +0,0 @@ -//@ build-pass -//@ compile-flags: -Zunpretty=hir - -#![feature(const_block_items)] -extern crate std; -#[attr = PreludeImport] -use ::std::prelude::rust_2015::*; - -const _: () = - { - // foo - }; - -fn main() { } diff --git a/tests/ui/consts/const-block-items/typecheck.rs b/tests/ui/consts/const-block-items/typecheck.rs deleted file mode 100644 index 2e521cbfda05..000000000000 --- a/tests/ui/consts/const-block-items/typecheck.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ check-fail - -#![feature(const_block_items)] - -const { - assert!(true); - 2 + 2 //~ ERROR: mismatched types [E0308] -} - - -const fn id(t: T) -> T { - t -} - -const { id(2) } -//~^ ERROR: mismatched types [E0308] -const { id(()) } - - -fn main() {} diff --git a/tests/ui/consts/const-block-items/typecheck.stderr b/tests/ui/consts/const-block-items/typecheck.stderr deleted file mode 100644 index 93d1eb1bc9e4..000000000000 --- a/tests/ui/consts/const-block-items/typecheck.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/typecheck.rs:7:5 - | -LL | 2 + 2 - | ^^^^^ expected `()`, found integer - -error[E0308]: mismatched types - --> $DIR/typecheck.rs:15:12 - | -LL | const { id(2) } - | -- ^ expected `()`, found integer - | | - | arguments to this function are incorrect - | -help: the return type of this call is `{integer}` due to the type of the argument passed - --> $DIR/typecheck.rs:15:9 - | -LL | const { id(2) } - | ^^^-^ - | | - | this argument influences the return type of `id` -note: function defined here - --> $DIR/typecheck.rs:11:10 - | -LL | const fn id(t: T) -> T { - | ^^ ---- - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/const-blocks/trait-error.stderr b/tests/ui/consts/const-blocks/trait-error.stderr index 308d71f0f4bd..601d067e3d84 100644 --- a/tests/ui/consts/const-blocks/trait-error.stderr +++ b/tests/ui/consts/const-blocks/trait-error.stderr @@ -5,12 +5,10 @@ LL | [Foo(String::new()); 4]; | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | note: required for `Foo` to implement `Copy` - --> $DIR/trait-error.rs:2:8 + --> $DIR/trait-error.rs:1:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion -LL | struct Foo(T); - | ^^^ - type parameter would need to implement `Copy` + | ^^^^ unsatisfied trait bound introduced in this `derive` macro = note: the `Copy` trait is required because this value will be copied for each element of the array help: create an inline `const` block | diff --git a/tests/ui/consts/const-eval/array-len-mismatch-type.rs b/tests/ui/consts/const-eval/array-len-mismatch-type.rs deleted file mode 100644 index 463572c13e10..000000000000 --- a/tests/ui/consts/const-eval/array-len-mismatch-type.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! Regression test for -pub struct Data([[&'static str]; 5_i32]); -//~^ ERROR the constant `5` is not of type `usize` -//~| ERROR the size for values of type `[&'static str]` cannot be known at compilation time -//~| ERROR mismatched types -const _: &'static Data = unsafe { &*(&[] as *const Data) }; -//~^ ERROR the type `[[&str]; 5]` has an unknown layout -fn main() {} diff --git a/tests/ui/consts/const-eval/array-len-mismatch-type.stderr b/tests/ui/consts/const-eval/array-len-mismatch-type.stderr deleted file mode 100644 index 0f03006f0032..000000000000 --- a/tests/ui/consts/const-eval/array-len-mismatch-type.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error: the constant `5` is not of type `usize` - --> $DIR/array-len-mismatch-type.rs:2:17 - | -LL | pub struct Data([[&'static str]; 5_i32]); - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i32` - | - = note: the length of array `[[&'static str]; 5]` must be type `usize` - -error[E0277]: the size for values of type `[&'static str]` cannot be known at compilation time - --> $DIR/array-len-mismatch-type.rs:2:17 - | -LL | pub struct Data([[&'static str]; 5_i32]); - | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[&'static str]` - = note: slice and array elements must have `Sized` type - -error[E0080]: the type `[[&str]; 5]` has an unknown layout - --> $DIR/array-len-mismatch-type.rs:6:39 - | -LL | const _: &'static Data = unsafe { &*(&[] as *const Data) }; - | ^^ evaluation of `_` failed here - -error[E0308]: mismatched types - --> $DIR/array-len-mismatch-type.rs:2:34 - | -LL | pub struct Data([[&'static str]; 5_i32]); - | ^^^^^ expected `usize`, found `i32` - | -help: change the type of the numeric literal from `i32` to `usize` - | -LL - pub struct Data([[&'static str]; 5_i32]); -LL + pub struct Data([[&'static str]; 5_usize]); - | - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0080, E0277, E0308. -For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/c-variadic-fail.rs b/tests/ui/consts/const-eval/c-variadic-fail.rs deleted file mode 100644 index b5a400a8bf25..000000000000 --- a/tests/ui/consts/const-eval/c-variadic-fail.rs +++ /dev/null @@ -1,147 +0,0 @@ -//@ build-fail - -#![feature(c_variadic)] -#![feature(const_c_variadic)] -#![feature(const_trait_impl)] -#![feature(const_destruct)] -#![feature(const_clone)] - -use std::ffi::VaList; -use std::mem::MaybeUninit; - -const unsafe extern "C" fn read_n(mut ap: ...) { - let mut i = N; - while i > 0 { - i -= 1; - let _ = ap.arg::(); - } -} - -unsafe fn read_too_many() { - // None passed, none read. - const { read_n::<0>() } - - // One passed, none read. Ignoring arguments is fine. - const { read_n::<0>(1) } - - // None passed, one read. - const { read_n::<1>() } - //~^ ERROR more C-variadic arguments read than were passed - - // One passed, two read. - const { read_n::<2>(1) } - //~^ ERROR more C-variadic arguments read than were passed -} - -const unsafe extern "C" fn read_as(mut ap: ...) -> T { - ap.arg::() -} - -unsafe fn read_cast() { - const { read_as::(1i32) }; - const { read_as::(1u32) }; - - const { read_as::(1i32, 2u64, 3.0f64) }; - const { read_as::(1u32, 2u64, 3.0f64) }; - - const { read_as::(1i64) }; - const { read_as::(1u64) }; - - const { read_as::(1i32) }; - //~^ ERROR va_arg type mismatch: requested `u32`, but next argument is `i32` - - const { read_as::(1u32) }; - //~^ ERROR va_arg type mismatch: requested `i32`, but next argument is `u32` - - const { read_as::(1u64) }; - //~^ ERROR va_arg type mismatch: requested `i32`, but next argument is `u64` - - const { read_as::(1i32) }; - //~^ ERROR va_arg type mismatch: requested `f64`, but next argument is `i32` - - const { read_as::<*const u8>(1i32) }; - //~^ ERROR va_arg type mismatch: requested `*const u8`, but next argument is `i32` -} - -fn use_after_free() { - const unsafe extern "C" fn helper(ap: ...) -> [u8; size_of::()] { - unsafe { std::mem::transmute(ap) } - } - - const { - unsafe { - let ap = helper(1, 2, 3); - let mut ap = std::mem::transmute::<_, VaList>(ap); - ap.arg::(); - //~^ ERROR memory access failed: ALLOC0 has been freed, so this pointer is dangling [E0080] - } - }; -} - -fn manual_copy_drop() { - const unsafe extern "C" fn helper(ap: ...) { - // A copy created using Clone is valid, and can be used to read arguments. - let mut copy = ap.clone(); - assert!(copy.arg::() == 1i32); - - let mut copy: VaList = unsafe { std::mem::transmute_copy(&ap) }; - - // Using the copy is actually fine. - let _ = copy.arg::(); - drop(copy); - - // But then using the original is UB. - drop(ap); - } - - const { unsafe { helper(1, 2, 3) } }; - //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080] -} - -fn manual_copy_forget() { - const unsafe extern "C" fn helper(ap: ...) { - let mut copy: VaList = unsafe { std::mem::transmute_copy(&ap) }; - - // Using the copy is actually fine. - let _ = copy.arg::(); - std::mem::forget(copy); - - // The read (via `copy`) deallocated the original allocation. - drop(ap); - } - - const { unsafe { helper(1, 2, 3) } }; - //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080] -} - -fn manual_copy_read() { - const unsafe extern "C" fn helper(mut ap: ...) { - let mut copy: VaList = unsafe { std::mem::transmute_copy(&ap) }; - - // Reading from `ap` after reading from `copy` is UB. - let _ = copy.arg::(); - let _ = ap.arg::(); - } - - const { unsafe { helper(1, 2, 3) } }; - //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080] -} - -fn drop_of_invalid() { - const { - let mut invalid: MaybeUninit = MaybeUninit::zeroed(); - let ap = unsafe { invalid.assume_init() }; - } - //~^ ERROR pointer not dereferenceable: pointer must point to some allocation, but got null pointer [E0080] -} - -fn main() { - unsafe { - read_too_many(); - read_cast(); - manual_copy_read(); - manual_copy_drop(); - manual_copy_forget(); - drop_of_invalid(); - } -} diff --git a/tests/ui/consts/const-eval/c-variadic-fail.stderr b/tests/ui/consts/const-eval/c-variadic-fail.stderr deleted file mode 100644 index 14da5500cb1b..000000000000 --- a/tests/ui/consts/const-eval/c-variadic-fail.stderr +++ /dev/null @@ -1,355 +0,0 @@ -error[E0080]: more C-variadic arguments read than were passed - --> $DIR/c-variadic-fail.rs:28:13 - | -LL | const { read_n::<1>() } - | ^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#2}` failed inside this call - | -note: inside `read_n::<1>` - --> $DIR/c-variadic-fail.rs:16:17 - | -LL | let _ = ap.arg::(); - | ^^^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:28:5 - | -LL | const { read_n::<1>() } - | ^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:28:5 - | -LL | const { read_n::<1>() } - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: more C-variadic arguments read than were passed - --> $DIR/c-variadic-fail.rs:32:13 - | -LL | const { read_n::<2>(1) } - | ^^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#3}` failed inside this call - | -note: inside `read_n::<2>` - --> $DIR/c-variadic-fail.rs:16:17 - | -LL | let _ = ap.arg::(); - | ^^^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:32:5 - | -LL | const { read_n::<2>(1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:32:5 - | -LL | const { read_n::<2>(1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: va_arg type mismatch: requested `u32`, but next argument is `i32` - --> $DIR/c-variadic-fail.rs:50:13 - | -LL | const { read_as::(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast::{constant#6}` failed inside this call - | -note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 - | -LL | ap.arg::() - | ^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:50:5 - | -LL | const { read_as::(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:50:5 - | -LL | const { read_as::(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: va_arg type mismatch: requested `i32`, but next argument is `u32` - --> $DIR/c-variadic-fail.rs:53:13 - | -LL | const { read_as::(1u32) }; - | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast::{constant#7}` failed inside this call - | -note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 - | -LL | ap.arg::() - | ^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:53:5 - | -LL | const { read_as::(1u32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:53:5 - | -LL | const { read_as::(1u32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: va_arg type mismatch: requested `i32`, but next argument is `u64` - --> $DIR/c-variadic-fail.rs:56:13 - | -LL | const { read_as::(1u64) }; - | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast::{constant#8}` failed inside this call - | -note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 - | -LL | ap.arg::() - | ^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:56:5 - | -LL | const { read_as::(1u64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:56:5 - | -LL | const { read_as::(1u64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: va_arg type mismatch: requested `f64`, but next argument is `i32` - --> $DIR/c-variadic-fail.rs:59:13 - | -LL | const { read_as::(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast::{constant#9}` failed inside this call - | -note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 - | -LL | ap.arg::() - | ^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:59:5 - | -LL | const { read_as::(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:59:5 - | -LL | const { read_as::(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: va_arg type mismatch: requested `*const u8`, but next argument is `i32` - --> $DIR/c-variadic-fail.rs:62:13 - | -LL | const { read_as::<*const u8>(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast::{constant#10}` failed inside this call - | -note: inside `read_as::<*const u8>` - --> $DIR/c-variadic-fail.rs:37:5 - | -LL | ap.arg::() - | ^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::<*const u8>` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:62:5 - | -LL | const { read_as::<*const u8>(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:62:5 - | -LL | const { read_as::<*const u8>(1i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling - --> $DIR/c-variadic-fail.rs:75:13 - | -LL | ap.arg::(); - | ^^^^^^^^^^^^^^^ evaluation of `use_after_free::{constant#0}` failed inside this call - | -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:71:5 - | -LL | / const { -LL | | unsafe { -LL | | let ap = helper(1, 2, 3); -LL | | let mut ap = std::mem::transmute::<_, VaList>(ap); -... | -LL | | }; - | |_____^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:71:5 - | -LL | / const { -LL | | unsafe { -LL | | let ap = helper(1, 2, 3); -LL | | let mut ap = std::mem::transmute::<_, VaList>(ap); -... | -LL | | }; - | |_____^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: using ALLOC1 as variable argument list pointer but it does not point to a variable argument list - --> $DIR/c-variadic-fail.rs:97:22 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_drop::{constant#0}` failed inside this call - | -note: inside `manual_copy_drop::helper` - --> $DIR/c-variadic-fail.rs:94:9 - | -LL | drop(ap); - | ^^^^^^^^ -note: inside `std::mem::drop::>` - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `drop_in_place::> - shim(Some(VaList<'_>))` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside ` as Drop>::drop` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:97:5 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:97:5 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: using ALLOC2 as variable argument list pointer but it does not point to a variable argument list - --> $DIR/c-variadic-fail.rs:113:22 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_forget::{constant#0}` failed inside this call - | -note: inside `manual_copy_forget::helper` - --> $DIR/c-variadic-fail.rs:110:9 - | -LL | drop(ap); - | ^^^^^^^^ -note: inside `std::mem::drop::>` - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `drop_in_place::> - shim(Some(VaList<'_>))` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside ` as Drop>::drop` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:113:5 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:113:5 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: using ALLOC3 as variable argument list pointer but it does not point to a variable argument list - --> $DIR/c-variadic-fail.rs:126:22 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_read::{constant#0}` failed inside this call - | -note: inside `manual_copy_read::helper` - --> $DIR/c-variadic-fail.rs:123:17 - | -LL | let _ = ap.arg::(); - | ^^^^^^^^^^^^^^^ -note: inside `VaList::<'_>::arg::` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:126:5 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:126:5 - | -LL | const { unsafe { helper(1, 2, 3) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got null pointer - --> $DIR/c-variadic-fail.rs:134:5 - | -LL | } - | ^ evaluation of `drop_of_invalid::{constant#0}` failed inside this call - | -note: inside `drop_in_place::> - shim(Some(VaList<'_>))` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside ` as Drop>::drop` - --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:131:5 - | -LL | / const { -LL | | let mut invalid: MaybeUninit = MaybeUninit::zeroed(); -LL | | let ap = unsafe { invalid.assume_init() }; -LL | | } - | |_____^ - -note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:131:5 - | -LL | / const { -LL | | let mut invalid: MaybeUninit = MaybeUninit::zeroed(); -LL | | let ap = unsafe { invalid.assume_init() }; -LL | | } - | |_____^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/c-variadic.rs b/tests/ui/consts/const-eval/c-variadic.rs deleted file mode 100644 index 2f8d043fb5db..000000000000 --- a/tests/ui/consts/const-eval/c-variadic.rs +++ /dev/null @@ -1,155 +0,0 @@ -//@ edition: 2021 -//@ run-pass -//@ ignore-backends: gcc - -#![feature(c_variadic)] -#![feature(const_c_variadic)] -#![feature(const_destruct)] -#![feature(const_cmp)] -#![feature(const_trait_impl)] - -use std::ffi::*; - -fn ignores_arguments() { - const unsafe extern "C" fn variadic(_: ...) {} - - const { - unsafe { variadic() }; - unsafe { variadic(1, 2, 3) }; - } -} - -fn echo() { - const unsafe extern "C" fn variadic(mut ap: ...) -> i32 { - ap.arg() - } - - assert_eq!(unsafe { variadic(1) }, 1); - assert_eq!(unsafe { variadic(3, 2, 1) }, 3); - - const { - assert!(unsafe { variadic(1) } == 1); - assert!(unsafe { variadic(3, 2, 1) } == 3); - } -} - -fn forward_by_val() { - const unsafe fn helper(mut ap: VaList) -> i32 { - ap.arg() - } - - const unsafe extern "C" fn variadic(ap: ...) -> i32 { - helper(ap) - } - - assert_eq!(unsafe { variadic(1) }, 1); - assert_eq!(unsafe { variadic(3, 2, 1) }, 3); - - const { - assert!(unsafe { variadic(1) } == 1); - assert!(unsafe { variadic(3, 2, 1) } == 3); - } -} - -fn forward_by_ref() { - const unsafe fn helper(ap: &mut VaList) -> i32 { - ap.arg() - } - - const unsafe extern "C" fn variadic(mut ap: ...) -> i32 { - helper(&mut ap) - } - - assert_eq!(unsafe { variadic(1) }, 1); - assert_eq!(unsafe { variadic(3, 2, 1) }, 3); - - const { - assert!(unsafe { variadic(1) } == 1); - assert!(unsafe { variadic(3, 2, 1) } == 3); - } -} - -#[allow(improper_ctypes_definitions)] -fn nested() { - const unsafe fn helper(mut ap1: VaList, mut ap2: VaList) -> (i32, i32) { - (ap1.arg(), ap2.arg()) - } - - const unsafe extern "C" fn variadic2(ap1: VaList, ap2: ...) -> (i32, i32) { - helper(ap1, ap2) - } - - const unsafe extern "C" fn variadic1(ap1: ...) -> (i32, i32) { - variadic2(ap1, 2, 2) - } - - assert_eq!(unsafe { variadic1(1) }, (1, 2)); - - const { - let (a, b) = unsafe { variadic1(1, 1) }; - - assert!(a != 2); - assert!(a == 1); - assert!(b != 1); - assert!(b == 2); - } -} - -fn various_types() { - const unsafe extern "C" fn check_list_2(mut ap: ...) { - macro_rules! continue_if { - ($cond:expr) => { - if !($cond) { - panic!(); - } - }; - } - - const unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool { - match CStr::from_ptr(ptr).to_str() { - Ok(cstr) => cstr == val, - Err(_) => panic!(), - } - } - - continue_if!(ap.arg::().floor() == 3.14f64.floor()); - continue_if!(ap.arg::() == 12); - continue_if!(ap.arg::() == 'a' as c_int); - continue_if!(ap.arg::().floor() == 6.18f64.floor()); - continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello")); - continue_if!(ap.arg::() == 42); - continue_if!(compare_c_str(ap.arg::<*const c_char>(), "World")); - } - - unsafe { - check_list_2( - 3.14 as c_double, - 12 as c_long, - b'a' as c_int, - 6.28 as c_double, - c"Hello".as_ptr(), - 42 as c_int, - c"World".as_ptr(), - ); - const { - check_list_2( - 3.14 as c_double, - 12 as c_long, - b'a' as c_int, - 6.28 as c_double, - c"Hello".as_ptr(), - 42 as c_int, - c"World".as_ptr(), - ) - }; - } -} - -fn main() { - ignores_arguments(); - echo(); - forward_by_val(); - forward_by_ref(); - nested(); - various_types(); -} diff --git a/tests/ui/consts/const-eval/const_panic.stderr b/tests/ui/consts/const-eval/const_panic.stderr index 8e0384b2f2af..a2036e834b0b 100644 --- a/tests/ui/consts/const-eval/const_panic.stderr +++ b/tests/ui/consts/const-eval/const_panic.stderr @@ -21,6 +21,8 @@ error[E0080]: evaluation panicked: not implemented | LL | const X: () = std::unimplemented!(); | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `X` failed here + | + = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:19:15 @@ -57,6 +59,8 @@ error[E0080]: evaluation panicked: not implemented | LL | const X_CORE: () = core::unimplemented!(); | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `X_CORE` failed here + | + = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:37:20 diff --git a/tests/ui/consts/const-eval/const_panic_2021.stderr b/tests/ui/consts/const-eval/const_panic_2021.stderr index a0181ccca391..ba771a35d036 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.stderr +++ b/tests/ui/consts/const-eval/const_panic_2021.stderr @@ -21,6 +21,8 @@ error[E0080]: evaluation panicked: not implemented | LL | const D: () = std::unimplemented!(); | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `D` failed here + | + = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:18:15 @@ -51,6 +53,8 @@ error[E0080]: evaluation panicked: not implemented | LL | const D_CORE: () = core::unimplemented!(); | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `D_CORE` failed here + | + = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:33:20 diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr index a9dc43caf76a..e07b172d426c 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -15,6 +15,8 @@ error[E0080]: evaluation panicked: not implemented | LL | const X: () = unimplemented!(); | ^^^^^^^^^^^^^^^^ evaluation of `X` failed here + | + = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr b/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr index 735409b77953..9d62bbc2187f 100644 --- a/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr +++ b/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr @@ -5,7 +5,7 @@ LL | [(); loop {}].field; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/field-access-after-const-eval-fail-in-ty.rs:4:10 | diff --git a/tests/ui/consts/const-eval/format.rs b/tests/ui/consts/const-eval/format.rs index f25c7018f826..a8085a786e18 100644 --- a/tests/ui/consts/const-eval/format.rs +++ b/tests/ui/consts/const-eval/format.rs @@ -6,7 +6,7 @@ const fn failure() { const fn print() { println!("{:?}", 0); //~^ ERROR cannot call non-const formatting macro in constant functions - //~| ERROR cannot call non-const function `std::io::_print` in constant functions + //~| ERROR cannot call non-const function `_print` in constant functions } const fn format_args() { diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index 67bef0ce6c35..ea191eb5c098 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -13,8 +13,9 @@ LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::io::_print` in constant functions +error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/format.rs:7:5 | LL | println!("{:?}", 0); @@ -23,6 +24,7 @@ LL | println!("{:?}", 0); note: function `_print` is not const --> $SRC_DIR/std/src/io/stdio.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions --> $DIR/format.rs:13:5 diff --git a/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr b/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr index a11915d47861..f326da8e26af 100644 --- a/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr +++ b/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr @@ -8,7 +8,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/infinite_loop.rs:13:18 | diff --git a/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr b/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr index a11915d47861..f326da8e26af 100644 --- a/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr +++ b/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr @@ -8,7 +8,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/infinite_loop.rs:13:18 | diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 7625664f9ed6..fd0b9ae1e17d 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -23,6 +23,8 @@ note: erroneous constant encountered | LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered --> $DIR/issue-44578.rs:26:20 @@ -31,6 +33,7 @@ LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/issue-52475.stderr b/tests/ui/consts/const-eval/issue-52475.stderr index 5ba0f8732d80..daaee03787f4 100644 --- a/tests/ui/consts/const-eval/issue-52475.stderr +++ b/tests/ui/consts/const-eval/issue-52475.stderr @@ -9,7 +9,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/issue-52475.rs:2:18 | diff --git a/tests/ui/consts/const-eval/issue-70723.stderr b/tests/ui/consts/const-eval/issue-70723.stderr index 50faa3353e91..7cece4ed5d6c 100644 --- a/tests/ui/consts/const-eval/issue-70723.stderr +++ b/tests/ui/consts/const-eval/issue-70723.stderr @@ -5,7 +5,7 @@ LL | static _X: () = loop {}; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/issue-70723.rs:1:1 | diff --git a/tests/ui/consts/const-eval/ptr_fragments.rs b/tests/ui/consts/const-eval/ptr_fragments.rs index f4d92127e189..d27804084d73 100644 --- a/tests/ui/consts/const-eval/ptr_fragments.rs +++ b/tests/ui/consts/const-eval/ptr_fragments.rs @@ -70,7 +70,6 @@ const _PARTIAL_OVERWRITE: () = { #[allow(dead_code)] #[cfg(not(target_arch = "s390x"))] // u128 is less aligned on s390x, removing the padding fn fragment_in_dst_padding_gets_overwritten() { - // We can't use `repr(align)` here as that would make this not a `ScalarPair` any more. #[repr(C)] struct Pair { x: u128, diff --git a/tests/ui/consts/const-eval/ptr_fragments_in_final.rs b/tests/ui/consts/const-eval/ptr_fragments_in_final.rs index 76f292c3f8b5..4037a2d23722 100644 --- a/tests/ui/consts/const-eval/ptr_fragments_in_final.rs +++ b/tests/ui/consts/const-eval/ptr_fragments_in_final.rs @@ -37,40 +37,4 @@ const MIXED_PTR: MaybeUninit<*const u8> = { //~ERROR: partial pointer in final v } }; -/// This has pointer bytes in the padding of the memory that the final value is read from. -/// To ensure consistent behavior, we want to *always* copy that padding, even if the value -/// could be represented as a more efficient ScalarPair. Hence this must fail to compile. -fn fragment_in_padding() -> impl Copy { - // We can't use `repr(align)` here as that would make this not a `ScalarPair` any more. - #[repr(C)] - #[derive(Clone, Copy)] - struct Thing { - x: u128, - y: usize, - // at least one pointer worth of padding - } - // Ensure there is indeed padding. - const _: () = assert!(mem::size_of::() > 16 + mem::size_of::()); - - #[derive(Clone, Copy)] - union PreservePad { - thing: Thing, - bytes: [u8; mem::size_of::()], - } - - const A: Thing = unsafe { //~ERROR: partial pointer in final value - let mut buffer = [PreservePad { bytes: [0u8; mem::size_of::()] }; 2]; - // The offset half a pointer from the end, so that copying a `Thing` copies exactly - // half the pointer. - let offset = mem::size_of::() - mem::size_of::()/2; - // Ensure this is inside the padding. - assert!(offset >= std::mem::offset_of!(Thing, y) + mem::size_of::()); - - (&raw mut buffer).cast::<&i32>().byte_add(offset).write_unaligned(&1); - buffer[0].thing - }; - - A -} - fn main() {} diff --git a/tests/ui/consts/const-eval/ptr_fragments_in_final.stderr b/tests/ui/consts/const-eval/ptr_fragments_in_final.stderr index de0cd4db7e15..41a822416581 100644 --- a/tests/ui/consts/const-eval/ptr_fragments_in_final.stderr +++ b/tests/ui/consts/const-eval/ptr_fragments_in_final.stderr @@ -14,13 +14,5 @@ LL | const MIXED_PTR: MaybeUninit<*const u8> = { | = note: while pointers can be broken apart into individual bytes during const-evaluation, only complete pointers (with all their bytes in the right order) are supported in the final value -error: encountered partial pointer in final value of constant - --> $DIR/ptr_fragments_in_final.rs:61:5 - | -LL | const A: Thing = unsafe { - | ^^^^^^^^^^^^^^ - | - = note: while pointers can be broken apart into individual bytes during const-evaluation, only complete pointers (with all their bytes in the right order) are supported in the final value - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index be3b539b269a..2861f82ec53b 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -64,7 +64,7 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; @@ -75,7 +75,7 @@ LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; 00 │ . } -error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 9950ac726ca7..8e6dc66a40ee 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -64,7 +64,7 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; @@ -75,7 +75,7 @@ LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; 00 │ . } -error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr index 47e26c3ed935..f087c9960c28 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr @@ -5,7 +5,7 @@ LL | foo(); | ^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/ctfe-fn-call.rs:32:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr index 95e280398050..ecb48fc62a3d 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr @@ -11,7 +11,7 @@ LL | | } | |_____^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/ctfe-labelled-loop.rs:16:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr index 25928b766bda..a05d792c95ca 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr @@ -5,7 +5,7 @@ LL | recurse(n - 1) | ^^^^^^^^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/ctfe-recursion.rs:13:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr index 44abf8be6bdf..2bb9a8a98ec4 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr @@ -7,7 +7,7 @@ LL | | } | |_____^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/ctfe-simple-loop.rs:19:1 | @@ -28,7 +28,7 @@ LL | | } | |_____^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/ctfe-simple-loop.rs:20:1 | diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index be5c6f77a087..e4486e3c500b 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -15,7 +15,7 @@ error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer LL | let out_of_bounds_ptr = &ptr[255]; | ^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here -error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:26:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; @@ -26,7 +26,7 @@ LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; HEX_DUMP } -error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:28:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; diff --git a/tests/ui/consts/const-fn.rs b/tests/ui/consts/const-fn.rs index 34aaeac6462d..aa9c478ea633 100644 --- a/tests/ui/consts/const-fn.rs +++ b/tests/ui/consts/const-fn.rs @@ -1,6 +1,10 @@ //@ run-pass +#![allow(stable_features)] + // A very basic test of const fn functionality. +#![feature(const_indexing)] + const fn add(x: u32, y: u32) -> u32 { x + y } diff --git a/tests/ui/consts/const-mut-refs/issue-76510.stderr b/tests/ui/consts/const-mut-refs/issue-76510.stderr index 82c9d523e738..3a6c95141e52 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.stderr +++ b/tests/ui/consts/const-mut-refs/issue-76510.stderr @@ -4,9 +4,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 8f54b4eda227..da6f2a28d5a8 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -4,9 +4,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const B: *mut i32 = &mut 4; | ^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/mut_ref_in_final.rs:21:35 @@ -14,9 +14,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const B3: Option<&mut i32> = Some(&mut 42); | ^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0716]: temporary value dropped while borrowed --> $DIR/mut_ref_in_final.rs:24:42 @@ -86,9 +86,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | static RAW_MUT_CAST_S: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/mut_ref_in_final.rs:73:54 @@ -96,9 +96,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | static RAW_MUT_COERCE_S: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/mut_ref_in_final.rs:75:52 @@ -106,9 +106,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const RAW_MUT_CAST_C: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/mut_ref_in_final.rs:77:53 @@ -116,9 +116,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const RAW_MUT_COERCE_C: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0080]: constructing invalid value at ..0: encountered a dangling reference (0x2a[noalloc] has no provenance) --> $DIR/mut_ref_in_final.rs:86:5 diff --git a/tests/ui/consts/const-promoted-opaque.atomic.stderr b/tests/ui/consts/const-promoted-opaque.atomic.stderr index ac31992d0631..64cc7b3a3292 100644 --- a/tests/ui/consts/const-promoted-opaque.atomic.stderr +++ b/tests/ui/consts/const-promoted-opaque.atomic.stderr @@ -13,9 +13,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | const BAZ: &Foo = &FOO; | ^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0716]: temporary value dropped while borrowed --> $DIR/const-promoted-opaque.rs:40:26 diff --git a/tests/ui/consts/const-try-feature-gate.stderr b/tests/ui/consts/const-try-feature-gate.stderr index eb5728aaaa78..62a4a5fba4ff 100644 --- a/tests/ui/consts/const-try-feature-gate.stderr +++ b/tests/ui/consts/const-try-feature-gate.stderr @@ -30,7 +30,6 @@ LL | Some(())?; = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `FromResidual` is not yet stable as a const trait --> $DIR/const-try-feature-gate.rs:4:5 diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.rs b/tests/ui/consts/const_refs_to_static-ice-121413.rs index 27d5d8600b4b..cc368d971c05 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.rs +++ b/tests/ui/consts/const_refs_to_static-ice-121413.rs @@ -7,7 +7,7 @@ const REF_INTERIOR_MUT: &usize = { //~^ HELP consider importing this struct static FOO: Sync = AtomicUsize::new(0); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of undeclared type `AtomicUsize` //~| WARN trait objects without an explicit `dyn` are deprecated //~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 150b8cb079e7..89429d83b205 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `AtomicUsize` in this scope +error[E0433]: failed to resolve: use of undeclared type `AtomicUsize` --> $DIR/const_refs_to_static-ice-121413.rs:9:24 | LL | static FOO: Sync = AtomicUsize::new(0); diff --git a/tests/ui/consts/control-flow/issue-50577.rs b/tests/ui/consts/control-flow/issue-50577.rs index 1cecbadbbe63..beb9a44fca52 100644 --- a/tests/ui/consts/control-flow/issue-50577.rs +++ b/tests/ui/consts/control-flow/issue-50577.rs @@ -1,6 +1,6 @@ fn main() { enum Foo { Drop = assert_eq!(1, 1), - //~^ ERROR mismatched types [E0308] + //~^ ERROR `if` may be missing an `else` clause } } diff --git a/tests/ui/consts/control-flow/issue-50577.stderr b/tests/ui/consts/control-flow/issue-50577.stderr index 6f62510c8801..1556c6f9c558 100644 --- a/tests/ui/consts/control-flow/issue-50577.stderr +++ b/tests/ui/consts/control-flow/issue-50577.stderr @@ -1,9 +1,13 @@ -error[E0308]: mismatched types +error[E0317]: `if` may be missing an `else` clause --> $DIR/issue-50577.rs:3:16 | LL | Drop = assert_eq!(1, 1), | ^^^^^^^^^^^^^^^^ expected `isize`, found `()` + | + = note: `if` expressions without `else` evaluate to `()` + = help: consider adding an `else` block that evaluates to the expected type + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0317`. diff --git a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr index c28f37bc1670..32a18469ab9e 100644 --- a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr +++ b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr @@ -5,7 +5,7 @@ LL | [(); loop {}]; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:10:14 | diff --git a/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr index ebf659814e73..02b8904fbded 100644 --- a/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr +++ b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr @@ -5,7 +5,7 @@ LL | let array = [(); { loop {} }]; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/do-not-ice-on-field-access-of-err-type.rs:5:22 | diff --git a/tests/ui/consts/issue-102117.stderr b/tests/ui/consts/issue-102117.stderr index 4440680bd7f1..cea355d01d7b 100644 --- a/tests/ui/consts/issue-102117.stderr +++ b/tests/ui/consts/issue-102117.stderr @@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/issue-102117.rs:17:26 | LL | type_id: TypeId::of::(), - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ | | | the parameter type `T` must be valid for the static lifetime... | ...so that the type `T` will meet its required lifetime bounds @@ -16,7 +16,7 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/issue-102117.rs:17:26 | LL | type_id: TypeId::of::(), - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ | | | the parameter type `T` must be valid for the static lifetime... | ...so that the type `T` will meet its required lifetime bounds diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index eebfa5d6ea40..11e11adcb5ae 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -4,9 +4,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const C1: &'static mut [usize] = &mut []; | ^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-17718-const-borrow.stderr b/tests/ui/consts/issue-17718-const-borrow.stderr index b801498c2028..420a2c378a25 100644 --- a/tests/ui/consts/issue-17718-const-borrow.stderr +++ b/tests/ui/consts/issue-17718-const-borrow.stderr @@ -4,9 +4,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | const B: &'static UnsafeCell = &A; | ^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-17718-const-borrow.rs:9:39 @@ -14,9 +14,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | const E: &'static UnsafeCell = &D.a; | ^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-17718-const-borrow.rs:11:23 @@ -24,9 +24,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | const F: &'static C = &D; | ^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/issue-29914.rs b/tests/ui/consts/issue-29914.rs index 36a82f5b9501..7897733c7238 100644 --- a/tests/ui/consts/issue-29914.rs +++ b/tests/ui/consts/issue-29914.rs @@ -1,4 +1,8 @@ //@ run-pass +#![allow(stable_features)] + +#![feature(const_indexing)] + const ARR: [usize; 5] = [5, 4, 3, 2, 1]; fn main() { diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs index 0553b676bc3e..f2ddc928d122 100644 --- a/tests/ui/consts/issue-94675.rs +++ b/tests/ui/consts/issue-94675.rs @@ -10,6 +10,7 @@ impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec) { self.bar[0] = baz.len(); //~^ ERROR: `Vec: [const] Index<_>` is not satisfied + //~| ERROR: `Vec: [const] Index` is not satisfied //~| ERROR: `Vec: [const] IndexMut` is not satisfied } } diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr index ab7a76a90e02..771f2a14c305 100644 --- a/tests/ui/consts/issue-94675.stderr +++ b/tests/ui/consts/issue-94675.stderr @@ -16,6 +16,17 @@ LL | self.bar[0] = baz.len(); note: trait `IndexMut` is implemented but not `const` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -error: aborting due to 2 previous errors +error[E0277]: the trait bound `Vec: [const] Index` is not satisfied + --> $DIR/issue-94675.rs:11:9 + | +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ + | +note: trait `Index` is implemented but not `const` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL +note: required by a bound in `std::ops::IndexMut::index_mut` + --> $SRC_DIR/core/src/ops/index.rs:LL:COL + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs index 74e0a36560b0..6a6b0e666e1c 100644 --- a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs +++ b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs @@ -1,7 +1,7 @@ const fn foo(a: i32) -> Vec { vec![1, 2, 3] - //~^ ERROR cannot call non-const - //~| ERROR cannot call non-const + //~^ ERROR allocations are not allowed + //~| ERROR cannot call non-const method } fn main() {} diff --git a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr index a7e8fdf37ae2..8e52a7aa35e1 100644 --- a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr +++ b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr @@ -1,21 +1,21 @@ -error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new_uninit` in constant functions +error[E0010]: allocations are not allowed in constant functions --> $DIR/bad_const_fn_body_ice.rs:2:5 | LL | vec![1, 2, 3] - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ allocation not allowed in constant functions | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in constant functions +error[E0015]: cannot call non-const method `slice::::into_vec::` in constant functions --> $DIR/bad_const_fn_body_ice.rs:2:5 | LL | vec![1, 2, 3] | ^^^^^^^^^^^^^ | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0010, E0015. +For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index b679493eb08e..09a11c75fd7b 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -1,6 +1,6 @@ //! Check what happens when the error occurs inside a std function that we can't print the span of. //@ ignore-backends: gcc -//@ compile-flags: -Z ui-testing=no --diagnostic-width=80 +//@ compile-flags: -Z ui-testing=no use std::{ mem::{self, MaybeUninit}, diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index b86911e7057b..55dde6358286 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,12 +1,12 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/missing_span_in_backtrace.rs:16:9 | -16 | / ... ptr::swap_nonoverlapping( -17 | | ... &mut x1 as *mut _ as *mut MaybeUninit, -18 | | ... &mut x2 as *mut _ as *mut MaybeUninit, -19 | | ... 10, -20 | | ... ); - | |_______^ evaluation of `X` failed inside this call +16 | / ptr::swap_nonoverlapping( +17 | | &mut x1 as *mut _ as *mut MaybeUninit, +18 | | &mut x2 as *mut _ as *mut MaybeUninit, +19 | | 10, +20 | | ); + | |_________^ evaluation of `X` failed inside this call | note: inside `swap_nonoverlapping::compiletime::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/partial_qualif.stderr b/tests/ui/consts/partial_qualif.stderr index f69fa1c46c01..b7632eb868ac 100644 --- a/tests/ui/consts/partial_qualif.stderr +++ b/tests/ui/consts/partial_qualif.stderr @@ -4,9 +4,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | &{a} | ^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/precise-drop-allow-const-fn-unstable.rs b/tests/ui/consts/precise-drop-allow-const-fn-unstable.rs index 4bd5f746f502..56155e519dca 100644 --- a/tests/ui/consts/precise-drop-allow-const-fn-unstable.rs +++ b/tests/ui/consts/precise-drop-allow-const-fn-unstable.rs @@ -2,7 +2,7 @@ //@ compile-flags: --crate-type=lib -Cinstrument-coverage -Zno-profiler-runtime //@[allow] check-pass -#![feature(staged_api, rustc_attrs)] +#![feature(staged_api, rustc_allow_const_fn_unstable)] #![stable(feature = "rust_test", since = "1.0.0")] #[stable(feature = "rust_test", since = "1.0.0")] diff --git a/tests/ui/consts/qualif_overwrite.stderr b/tests/ui/consts/qualif_overwrite.stderr index 1dc2bf7f1231..4aaaa4b2ca90 100644 --- a/tests/ui/consts/qualif_overwrite.stderr +++ b/tests/ui/consts/qualif_overwrite.stderr @@ -4,9 +4,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | &{a} | ^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/qualif_overwrite_2.stderr b/tests/ui/consts/qualif_overwrite_2.stderr index fb8ac601c67a..bc1681418765 100644 --- a/tests/ui/consts/qualif_overwrite_2.stderr +++ b/tests/ui/consts/qualif_overwrite_2.stderr @@ -4,9 +4,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | &{a.0} | ^^^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/recursive-const-in-impl.stderr b/tests/ui/consts/recursive-const-in-impl.stderr index c53ce701566e..ec5ad52fadd4 100644 --- a/tests/ui/consts/recursive-const-in-impl.stderr +++ b/tests/ui/consts/recursive-const-in-impl.stderr @@ -6,6 +6,7 @@ LL | println!("{}", Thing::::X); | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "14"]` attribute to your crate (`recursive_const_in_impl`) = note: query depth increased by 9 when simplifying constant for the type system `main::promoted[0]` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/consts/refs-to-cell-in-final.stderr b/tests/ui/consts/refs-to-cell-in-final.stderr index e30b5aa24e76..ac866dbe7210 100644 --- a/tests/ui/consts/refs-to-cell-in-final.stderr +++ b/tests/ui/consts/refs-to-cell-in-final.stderr @@ -4,9 +4,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | static RAW_SYNC_S: SyncPtr> = SyncPtr { x: &Cell::new(42) }; | ^^^^^^^^^^^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/refs-to-cell-in-final.rs:15:53 @@ -14,9 +14,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | const RAW_SYNC_C: SyncPtr> = SyncPtr { x: &Cell::new(42) }; | ^^^^^^^^^^^^^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/refs-to-cell-in-final.rs:41:57 @@ -31,9 +31,9 @@ LL | | x LL | | }; | |_^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/static-default-lifetime/elided-lifetime.rs b/tests/ui/consts/static-default-lifetime/elided-lifetime.rs index 989de389180a..d60fe7d409af 100644 --- a/tests/ui/consts/static-default-lifetime/elided-lifetime.rs +++ b/tests/ui/consts/static-default-lifetime/elided-lifetime.rs @@ -16,7 +16,7 @@ impl Bar for Foo<'_> { const STATIC: &str = ""; //~^ ERROR `&` without an explicit lifetime name cannot be used here //~| WARN this was previously accepted by the compiler but is being phased out - //~| ERROR lifetime parameters or bounds on associated constant `STATIC` do not match the trait declaration + //~| ERROR lifetime parameters or bounds on associated const `STATIC` do not match the trait declaration } fn main() {} diff --git a/tests/ui/consts/static-default-lifetime/elided-lifetime.stderr b/tests/ui/consts/static-default-lifetime/elided-lifetime.stderr index ae4a48e4e932..bb8365b0ae56 100644 --- a/tests/ui/consts/static-default-lifetime/elided-lifetime.stderr +++ b/tests/ui/consts/static-default-lifetime/elided-lifetime.stderr @@ -39,14 +39,14 @@ help: use the `'static` lifetime LL | const STATIC: &'static str = ""; | +++++++ -error[E0195]: lifetime parameters or bounds on associated constant `STATIC` do not match the trait declaration +error[E0195]: lifetime parameters or bounds on associated const `STATIC` do not match the trait declaration --> $DIR/elided-lifetime.rs:16:17 | LL | const STATIC: &str; - | - lifetimes in impl do not match this associated constant in trait + | - lifetimes in impl do not match this associated const in trait ... LL | const STATIC: &str = ""; - | ^ lifetimes do not match associated constant in trait + | ^ lifetimes do not match associated const in trait error: aborting due to 3 previous errors diff --git a/tests/ui/consts/static-default-lifetime/static-trait-impl.rs b/tests/ui/consts/static-default-lifetime/static-trait-impl.rs index ecc163aecbf1..85746df146fc 100644 --- a/tests/ui/consts/static-default-lifetime/static-trait-impl.rs +++ b/tests/ui/consts/static-default-lifetime/static-trait-impl.rs @@ -9,7 +9,7 @@ impl Bar<'_> for A { const STATIC: &str = ""; //~^ ERROR `&` without an explicit lifetime name cannot be used here //~| WARN this was previously accepted by the compiler but is being phased out - //~| ERROR lifetime parameters or bounds on associated constant `STATIC` do not match the trait declaration + //~| ERROR lifetime parameters or bounds on associated const `STATIC` do not match the trait declaration } struct B; diff --git a/tests/ui/consts/static-default-lifetime/static-trait-impl.stderr b/tests/ui/consts/static-default-lifetime/static-trait-impl.stderr index 2bc271dccad9..38d24db1317f 100644 --- a/tests/ui/consts/static-default-lifetime/static-trait-impl.stderr +++ b/tests/ui/consts/static-default-lifetime/static-trait-impl.stderr @@ -21,14 +21,14 @@ help: use the `'static` lifetime LL | const STATIC: &'static str = ""; | +++++++ -error[E0195]: lifetime parameters or bounds on associated constant `STATIC` do not match the trait declaration +error[E0195]: lifetime parameters or bounds on associated const `STATIC` do not match the trait declaration --> $DIR/static-trait-impl.rs:9:17 | LL | const STATIC: &'a str; - | - lifetimes in impl do not match this associated constant in trait + | - lifetimes in impl do not match this associated const in trait ... LL | const STATIC: &str = ""; - | ^ lifetimes do not match associated constant in trait + | ^ lifetimes do not match associated const in trait error: aborting due to 2 previous errors diff --git a/tests/ui/consts/timeout.stderr b/tests/ui/consts/timeout.stderr index e96e5875058a..6afb317c3aff 100644 --- a/tests/ui/consts/timeout.stderr +++ b/tests/ui/consts/timeout.stderr @@ -7,7 +7,7 @@ error: constant evaluation is taking a long time = note: in this macro invocation | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/timeout.rs:7:1 | diff --git a/tests/ui/consts/write_to_static_via_mut_ref.stderr b/tests/ui/consts/write_to_static_via_mut_ref.stderr index be1f7178998a..ce44047f1550 100644 --- a/tests/ui/consts/write_to_static_via_mut_ref.stderr +++ b/tests/ui/consts/write_to_static_via_mut_ref.stderr @@ -4,9 +4,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | static OH_NO: &mut i32 = &mut 42; | ^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0594]: cannot assign to `*OH_NO`, as `OH_NO` is an immutable static item --> $DIR/write_to_static_via_mut_ref.rs:4:5 diff --git a/tests/ui/contracts/contract-captures-via-closure-noncopy.rs b/tests/ui/contracts/contract-captures-via-closure-noncopy.rs index 5153a7b48dcd..c7aa72d2b0f6 100644 --- a/tests/ui/contracts/contract-captures-via-closure-noncopy.rs +++ b/tests/ui/contracts/contract-captures-via-closure-noncopy.rs @@ -13,7 +13,7 @@ struct Baz { #[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz*2 })] // Relevant thing is this: ^^^^^^^^^^^ // because we are capturing state that is non-Copy. -//~^^^ ERROR trait bound `Baz: Copy` is not satisfied +//~^^^ ERROR trait bound `Baz: std::marker::Copy` is not satisfied fn doubler(x: Baz) -> Baz { Baz { baz: x.baz + 10 } } diff --git a/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr b/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr index 20c220e98bcc..5f55faed80c8 100644 --- a/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr +++ b/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `Baz: Copy` is not satisfied in `{closure@$DIR/contract-captures-via-closure-noncopy.rs:13:42: 13:57}` +error[E0277]: the trait bound `Baz: std::marker::Copy` is not satisfied in `{closure@$DIR/contract-captures-via-closure-noncopy.rs:13:42: 13:57}` --> $DIR/contract-captures-via-closure-noncopy.rs:13:1 | LL | #[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz*2 })] @@ -9,7 +9,7 @@ LL | #[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz | unsatisfied trait bound | required by a bound introduced by this call | - = help: within `{closure@$DIR/contract-captures-via-closure-noncopy.rs:13:42: 13:57}`, the trait `Copy` is not implemented for `Baz` + = help: within `{closure@$DIR/contract-captures-via-closure-noncopy.rs:13:42: 13:57}`, the trait `std::marker::Copy` is not implemented for `Baz` note: required because it's used within this closure --> $DIR/contract-captures-via-closure-noncopy.rs:13:42 | diff --git a/tests/ui/coroutine/gen_fn.none.stderr b/tests/ui/coroutine/gen_fn.none.stderr index 8a5f86541316..590210641aed 100644 --- a/tests/ui/coroutine/gen_fn.none.stderr +++ b/tests/ui/coroutine/gen_fn.none.stderr @@ -1,8 +1,8 @@ -error: expected one of `#`, `async`, `const`, `default`, `extern`, `final`, `fn`, `pub`, `safe`, `unsafe`, or `use`, found `gen` +error: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `safe`, `unsafe`, or `use`, found `gen` --> $DIR/gen_fn.rs:4:1 | LL | gen fn foo() {} - | ^^^ expected one of 11 possible tokens + | ^^^ expected one of 10 possible tokens error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/gen_fn.rs b/tests/ui/coroutine/gen_fn.rs index 78301cd2832c..2f50d5db9acf 100644 --- a/tests/ui/coroutine/gen_fn.rs +++ b/tests/ui/coroutine/gen_fn.rs @@ -2,7 +2,7 @@ //@[e2024] edition: 2024 gen fn foo() {} -//[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `final`, `fn`, `pub`, `safe`, `unsafe`, or `use`, found `gen` +//[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `safe`, `unsafe`, or `use`, found `gen` //[e2024]~^^ ERROR: gen blocks are experimental fn main() {} diff --git a/tests/ui/coroutine/issue-105084.rs b/tests/ui/coroutine/issue-105084.rs index 9dd3df5ce341..cddee4990175 100644 --- a/tests/ui/coroutine/issue-105084.rs +++ b/tests/ui/coroutine/issue-105084.rs @@ -15,11 +15,11 @@ fn main() { let mut g = #[coroutine] || { // This is desuraged as 4 stages: - // - `vec!` macro - // - `write_via_move` + // - allocate a `*mut u8` with `exchange_malloc`; + // - create a Box that is ignored for trait computations; // - compute fields (and yields); // - assign to `t`. - let t = vec![(5, yield)]; + let t = std::boxed::box_new((5, yield)); drop(t); }; @@ -30,12 +30,13 @@ fn main() { // As it is not taken into account for trait computation, // the coroutine is `Copy`. let mut h = copy(g); - //~^ ERROR the trait bound `Box>: Copy` is not satisfied in + //~^ ERROR the trait bound `Box<(i32, ())>: Copy` is not satisfied in // We now have 2 boxes with the same backing allocation: // one inside `g` and one inside `h`. // Proceed and drop `t` in `g`. Pin::new(&mut g).resume(()); + //~^ ERROR borrow of moved value: `g` // Proceed and drop `t` in `h` -> double free! Pin::new(&mut h).resume(()); diff --git a/tests/ui/coroutine/issue-105084.stderr b/tests/ui/coroutine/issue-105084.stderr index 208636bfa6a8..23c1fdc54592 100644 --- a/tests/ui/coroutine/issue-105084.stderr +++ b/tests/ui/coroutine/issue-105084.stderr @@ -1,26 +1,51 @@ -error[E0277]: the trait bound `Box>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}` +error[E0382]: borrow of moved value: `g` + --> $DIR/issue-105084.rs:38:14 + | +LL | let mut g = #[coroutine] + | ----- move occurs because `g` has type `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`, which does not implement the `Copy` trait +... +LL | let mut h = copy(g); + | - value moved here +... +LL | Pin::new(&mut g).resume(()); + | ^^^^^^ value borrowed here after move + | +note: consider changing this parameter type in function `copy` to borrow instead if owning the value isn't necessary + --> $DIR/issue-105084.rs:10:21 + | +LL | fn copy(x: T) -> T { + | ---- ^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut h = copy(g.clone()); + | ++++++++ + +error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}` --> $DIR/issue-105084.rs:32:17 | LL | || { | -- within this `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}` ... LL | let mut h = copy(g); - | ^^^^^^^ within `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`, the trait `Copy` is not implemented for `Box>` + | ^^^^^^^ within `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`, the trait `Copy` is not implemented for `Box<(i32, ())>` | note: coroutine does not implement `Copy` as this value is used across a yield - --> $DIR/issue-105084.rs:22:26 + --> $DIR/issue-105084.rs:22:41 | -LL | let t = vec![(5, yield)]; - | ---------^^^^^-- - | | | - | | yield occurs here, with the value maybe used later - | has type `Box>` which does not implement `Copy` +LL | let t = std::boxed::box_new((5, yield)); + | ------------------------^^^^^-- + | | | + | | yield occurs here, with `std::boxed::box_new((5, yield))` maybe used later + | has type `Box<(i32, ())>` which does not implement `Copy` note: required by a bound in `copy` --> $DIR/issue-105084.rs:10:12 | LL | fn copy(x: T) -> T { | ^^^^ required by this bound in `copy` -error: aborting due to 1 previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0382. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/coroutine/stalled-coroutine-obligations.rs b/tests/ui/coroutine/stalled-coroutine-obligations.rs deleted file mode 100644 index 89af3c9a583c..000000000000 --- a/tests/ui/coroutine/stalled-coroutine-obligations.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ edition: 2021 - -// Regression tests for #137916 and #138274 -// We now check stalled coroutine obligations eagerly at the start of `mir_borrowck`. -// So these unsatisfied bounds are caught before causing ICEs. -use std::ptr::null; - -async fn a() -> Box { - Box::new(async { - //~^ ERROR: future cannot be sent between threads safely - let non_send = null::<()>(); - &non_send; - async {}.await - }) -} - - -trait Trait {} -fn foo() -> Box { todo!() } - -fn fetch() { - async { - let fut = async { - let _x = foo(); - async {}.await; - }; - let _: Box = Box::new(fut); - //~^ ERROR: future cannot be sent between threads safely - }; -} - -fn main() {} diff --git a/tests/ui/coroutine/stalled-coroutine-obligations.stderr b/tests/ui/coroutine/stalled-coroutine-obligations.stderr deleted file mode 100644 index cbf395dd6cfb..000000000000 --- a/tests/ui/coroutine/stalled-coroutine-obligations.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/stalled-coroutine-obligations.rs:9:5 - | -LL | / Box::new(async { -LL | | -LL | | let non_send = null::<()>(); -LL | | &non_send; -LL | | async {}.await -LL | | }) - | |______^ future created by async block is not `Send` - | - = help: within `{async block@$DIR/stalled-coroutine-obligations.rs:9:14: 9:19}`, the trait `Send` is not implemented for `*const ()` -note: future is not `Send` as this value is used across an await - --> $DIR/stalled-coroutine-obligations.rs:13:18 - | -LL | let non_send = null::<()>(); - | -------- has type `*const ()` which is not `Send` -LL | &non_send; -LL | async {}.await - | ^^^^^ await occurs here, with `non_send` maybe used later - = note: required for the cast from `Box<{async block@$DIR/stalled-coroutine-obligations.rs:9:14: 9:19}>` to `Box` - -error: future cannot be sent between threads safely - --> $DIR/stalled-coroutine-obligations.rs:27:32 - | -LL | let _: Box = Box::new(fut); - | ^^^^^^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Send` is not implemented for `dyn Trait` -note: future is not `Send` as this value is used across an await - --> $DIR/stalled-coroutine-obligations.rs:25:22 - | -LL | let _x = foo(); - | -- has type `Box` which is not `Send` -LL | async {}.await; - | ^^^^^ await occurs here, with `_x` maybe used later - = note: required for the cast from `Box<{async block@$DIR/stalled-coroutine-obligations.rs:23:19: 23:24}>` to `Box` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/coroutine/uninhabited-field.rs b/tests/ui/coroutine/uninhabited-field.rs index 6debd89ef4a9..d6ada07ce0cb 100644 --- a/tests/ui/coroutine/uninhabited-field.rs +++ b/tests/ui/coroutine/uninhabited-field.rs @@ -1,10 +1,11 @@ // Test that uninhabited saved local doesn't make the entire variant uninhabited. //@ run-pass #![allow(unused)] +#![feature(assert_matches)] #![feature(coroutine_trait)] #![feature(coroutines, stmt_expr_attributes)] #![feature(never_type)] -use std::assert_matches; +use std::assert_matches::assert_matches; use std::ops::Coroutine; use std::ops::CoroutineState; use std::pin::Pin; diff --git a/tests/ui/coroutine/yield-while-ref-reborrowed.stderr b/tests/ui/coroutine/yield-while-ref-reborrowed.stderr index 836360b87303..0b2cc92f4b4a 100644 --- a/tests/ui/coroutine/yield-while-ref-reborrowed.stderr +++ b/tests/ui/coroutine/yield-while-ref-reborrowed.stderr @@ -10,6 +10,8 @@ LL | println!("{}", x); | ^ second borrow occurs here LL | Pin::new(&mut b).resume(()); | ------ first borrow later used here + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/delegation/bad-resolve.rs b/tests/ui/delegation/bad-resolve.rs index 79acaec021a6..861f2b15da20 100644 --- a/tests/ui/delegation/bad-resolve.rs +++ b/tests/ui/delegation/bad-resolve.rs @@ -40,7 +40,7 @@ impl Trait for S { } mod prefix {} -reuse unresolved_prefix::{a, b, c}; //~ ERROR cannot find module or crate `unresolved_prefix` +reuse unresolved_prefix::{a, b, c}; //~ ERROR use of unresolved module or unlinked crate reuse prefix::{self, super, crate}; //~ ERROR `crate` in paths can only be used in start position fn main() {} diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index 6fde0bb13877..4c015c226b18 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -91,7 +91,7 @@ LL | type Type; LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ missing `Type` in implementation -error[E0433]: cannot find module or crate `unresolved_prefix` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unresolved_prefix` --> $DIR/bad-resolve.rs:43:7 | LL | reuse unresolved_prefix::{a, b, c}; @@ -99,11 +99,11 @@ LL | reuse unresolved_prefix::{a, b, c}; | = help: you might be missing a crate named `unresolved_prefix` -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/bad-resolve.rs:44:29 | LL | reuse prefix::{self, super, crate}; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position error: aborting due to 12 previous errors diff --git a/tests/ui/delegation/glob-bad-path.rs b/tests/ui/delegation/glob-bad-path.rs index 067cb651777e..4ac9d68e8dd1 100644 --- a/tests/ui/delegation/glob-bad-path.rs +++ b/tests/ui/delegation/glob-bad-path.rs @@ -5,7 +5,7 @@ trait Trait {} struct S; impl Trait for u8 { - reuse unresolved::*; //~ ERROR cannot find module or crate `unresolved` + reuse unresolved::*; //~ ERROR failed to resolve: use of unresolved module or unlinked crate `unresolved` reuse S::*; //~ ERROR expected trait, found struct `S` } diff --git a/tests/ui/delegation/glob-bad-path.stderr b/tests/ui/delegation/glob-bad-path.stderr index 7e92bc045bbd..15d9ca412033 100644 --- a/tests/ui/delegation/glob-bad-path.stderr +++ b/tests/ui/delegation/glob-bad-path.stderr @@ -4,7 +4,7 @@ error: expected trait, found struct `S` LL | reuse S::*; | ^ not a trait -error[E0433]: cannot find module or crate `unresolved` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unresolved` --> $DIR/glob-bad-path.rs:8:11 | LL | reuse unresolved::*; diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.rs b/tests/ui/delegation/ice-line-bounds-issue-148732.rs index 699e7d86f258..e44c78476021 100644 --- a/tests/ui/delegation/ice-line-bounds-issue-148732.rs +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.rs @@ -3,6 +3,7 @@ reuse a as b { //~| ERROR functions delegation is not yet fully implemented dbg!(b); //~^ ERROR missing lifetime specifier + //~| ERROR `fn() {b}` doesn't implement `Debug` } fn main() {} diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr index c4f261181b10..f332bc6a7a21 100644 --- a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr @@ -3,6 +3,8 @@ error[E0106]: missing lifetime specifier | LL | dbg!(b); | ^^^^^^^ expected named lifetime parameter + | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `a` in this scope --> $DIR/ice-line-bounds-issue-148732.rs:1:7 @@ -17,7 +19,7 @@ LL | / reuse a as b { LL | | LL | | LL | | dbg!(b); -LL | | +... | LL | | } | |_^ | @@ -25,7 +27,19 @@ LL | | } = help: add `#![feature(fn_delegation)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error[E0277]: `fn() {b}` doesn't implement `Debug` + --> $DIR/ice-line-bounds-issue-148732.rs:4:5 + | +LL | reuse a as b { + | - consider calling this function +... +LL | dbg!(b); + | ^^^^^^^ the trait `Debug` is not implemented for fn item `fn() {b}` + | + = help: use parentheses to call this function: `b()` + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) -Some errors have detailed explanations: E0106, E0425, E0658. +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0106, E0277, E0425, E0658. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/delegation/impl-reuse-bad-path.rs b/tests/ui/delegation/impl-reuse-bad-path.rs index 656be5d79d9b..19eb51153468 100644 --- a/tests/ui/delegation/impl-reuse-bad-path.rs +++ b/tests/ui/delegation/impl-reuse-bad-path.rs @@ -4,7 +4,7 @@ mod unresolved { struct S; reuse impl unresolved for S { self.0 } - //~^ ERROR cannot find module or crate `unresolved` in this scope + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `unresolved` //~| ERROR cannot find trait `unresolved` in this scope trait T {} diff --git a/tests/ui/delegation/impl-reuse-bad-path.stderr b/tests/ui/delegation/impl-reuse-bad-path.stderr index bf486260c669..5fadd719ae4d 100644 --- a/tests/ui/delegation/impl-reuse-bad-path.stderr +++ b/tests/ui/delegation/impl-reuse-bad-path.stderr @@ -16,7 +16,7 @@ error: expected trait, found module `TraitModule` LL | reuse impl TraitModule for S { self.0 } | ^^^^^^^^^^^ not a trait -error[E0433]: cannot find module or crate `unresolved` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unresolved` --> $DIR/impl-reuse-bad-path.rs:6:16 | LL | reuse impl unresolved for S { self.0 } diff --git a/tests/ui/delegation/unresolved-delegation-ice-151356.rs b/tests/ui/delegation/unresolved-delegation-ice-151356.rs deleted file mode 100644 index b61e08551183..000000000000 --- a/tests/ui/delegation/unresolved-delegation-ice-151356.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![allow(incomplete_features)] -#![feature(fn_delegation)] - -extern "C" { - fn a() { - //~^ ERROR incorrect function inside `extern` block - reuse foo {} - } -} - -pub fn main() {} diff --git a/tests/ui/delegation/unresolved-delegation-ice-151356.stderr b/tests/ui/delegation/unresolved-delegation-ice-151356.stderr deleted file mode 100644 index 407d22e477c4..000000000000 --- a/tests/ui/delegation/unresolved-delegation-ice-151356.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: incorrect function inside `extern` block - --> $DIR/unresolved-delegation-ice-151356.rs:5:8 - | -LL | extern "C" { - | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body -LL | fn a() { - | ________^___- - | | | - | | cannot have a body -LL | | -LL | | reuse foo {} -LL | | } - | |_____- help: remove the invalid body: `;` - | - = help: you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block - = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html - -error: aborting due to 1 previous error - diff --git a/tests/ui/delegation/unsupported.current.stderr b/tests/ui/delegation/unsupported.current.stderr index 9bc2eec068fe..2bb0633621f2 100644 --- a/tests/ui/delegation/unsupported.current.stderr +++ b/tests/ui/delegation/unsupported.current.stderr @@ -29,7 +29,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when checking effective visibilities +note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:33:24 + | +LL | reuse ToReuse::opaque_ret; + | ^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0283]: type annotations needed diff --git a/tests/ui/delegation/unsupported.next.stderr b/tests/ui/delegation/unsupported.next.stderr index 08bc49513bad..1665d1f39d6d 100644 --- a/tests/ui/delegation/unsupported.next.stderr +++ b/tests/ui/delegation/unsupported.next.stderr @@ -25,7 +25,7 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when checking effective visibilities + = note: cycle used when computing implied outlives bounds for `::opaque_ret::{anon_assoc#0}` (hack disabled = false) = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0283]: type annotations needed diff --git a/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr index b0372051f026..f26b43aa3ec7 100644 --- a/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr +++ b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr @@ -1,8 +1,8 @@ error: OK - --> $DIR/dep-graph-assoc-type-codegen.rs:29:34 + --> $DIR/dep-graph-assoc-type-codegen.rs:29:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/dep-graph/dep-graph-caller-callee.stderr b/tests/ui/dep-graph/dep-graph-caller-callee.stderr index 33fe91b3500a..4d06dc7f3ed3 100644 --- a/tests/ui/dep-graph/dep-graph-caller-callee.stderr +++ b/tests/ui/dep-graph/dep-graph-caller-callee.stderr @@ -1,14 +1,14 @@ error: OK - --> $DIR/dep-graph-caller-callee.rs:21:34 + --> $DIR/dep-graph-caller-callee.rs:21:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `x` to `typeck` - --> $DIR/dep-graph-caller-callee.rs:32:34 + --> $DIR/dep-graph-caller-callee.rs:32:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/dep-graph/dep-graph-check-attr.rs b/tests/ui/dep-graph/dep-graph-check-attr.rs index c0697a5316f7..a45bf24f8c1f 100644 --- a/tests/ui/dep-graph/dep-graph-check-attr.rs +++ b/tests/ui/dep-graph/dep-graph-check-attr.rs @@ -5,15 +5,15 @@ #![allow(dead_code)] #![allow(unused_variables)] -#[rustc_clean(cfg = "foo")] //~ ERROR attribute requires -Z query-dep-graph +#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph fn main() {} -#[rustc_if_this_changed] //~ ERROR attribute requires -Z query-dep-graph +#[rustc_if_this_changed(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph struct Foo { f: T, } -#[rustc_clean(cfg = "foo")] //~ ERROR attribute requires -Z query-dep-graph +#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph type TypeAlias = Foo; #[rustc_then_this_would_need(variances_of)] //~ ERROR attribute requires -Z query-dep-graph diff --git a/tests/ui/dep-graph/dep-graph-check-attr.stderr b/tests/ui/dep-graph/dep-graph-check-attr.stderr index 4b651c47ac83..46f4e4358cf6 100644 --- a/tests/ui/dep-graph/dep-graph-check-attr.stderr +++ b/tests/ui/dep-graph/dep-graph-check-attr.stderr @@ -1,20 +1,20 @@ error: attribute requires -Z query-dep-graph to be enabled --> $DIR/dep-graph-check-attr.rs:8:1 | -LL | #[rustc_clean(cfg = "foo")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_clean(hir_owner)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: attribute requires -Z query-dep-graph to be enabled --> $DIR/dep-graph-check-attr.rs:11:1 | -LL | #[rustc_if_this_changed] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_if_this_changed(hir_owner)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: attribute requires -Z query-dep-graph to be enabled --> $DIR/dep-graph-check-attr.rs:16:1 | -LL | #[rustc_clean(cfg = "foo")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_clean(hir_owner)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: attribute requires -Z query-dep-graph to be enabled --> $DIR/dep-graph-check-attr.rs:19:1 diff --git a/tests/ui/dep-graph/dep-graph-struct-signature.stderr b/tests/ui/dep-graph/dep-graph-struct-signature.stderr index 98efedc7244c..cfe1e62d9318 100644 --- a/tests/ui/dep-graph/dep-graph-struct-signature.stderr +++ b/tests/ui/dep-graph/dep-graph-struct-signature.stderr @@ -1,134 +1,134 @@ error: no path from `WillChange` to `type_of` - --> $DIR/dep-graph-struct-signature.rs:28:34 + --> $DIR/dep-graph-struct-signature.rs:28:5 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `associated_item` - --> $DIR/dep-graph-struct-signature.rs:29:34 + --> $DIR/dep-graph-struct-signature.rs:29:5 | LL | #[rustc_then_this_would_need(associated_item)] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `trait_def` - --> $DIR/dep-graph-struct-signature.rs:30:34 + --> $DIR/dep-graph-struct-signature.rs:30:5 | LL | #[rustc_then_this_would_need(trait_def)] - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:36:34 + --> $DIR/dep-graph-struct-signature.rs:36:5 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:37:34 + --> $DIR/dep-graph-struct-signature.rs:37:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:40:34 + --> $DIR/dep-graph-struct-signature.rs:40:5 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:41:34 + --> $DIR/dep-graph-struct-signature.rs:41:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:46:34 + --> $DIR/dep-graph-struct-signature.rs:46:5 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:53:34 + --> $DIR/dep-graph-struct-signature.rs:53:5 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:61:38 + --> $DIR/dep-graph-struct-signature.rs:61:9 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:63:38 + --> $DIR/dep-graph-struct-signature.rs:63:9 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `type_of` - --> $DIR/dep-graph-struct-signature.rs:68:34 + --> $DIR/dep-graph-struct-signature.rs:68:5 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `type_of` - --> $DIR/dep-graph-struct-signature.rs:75:34 + --> $DIR/dep-graph-struct-signature.rs:75:5 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `fn_sig` - --> $DIR/dep-graph-struct-signature.rs:81:34 + --> $DIR/dep-graph-struct-signature.rs:81:5 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `fn_sig` - --> $DIR/dep-graph-struct-signature.rs:84:34 + --> $DIR/dep-graph-struct-signature.rs:84:5 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `typeck` - --> $DIR/dep-graph-struct-signature.rs:85:34 + --> $DIR/dep-graph-struct-signature.rs:85:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:32:38 + --> $DIR/dep-graph-struct-signature.rs:32:9 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `fn_sig` - --> $DIR/dep-graph-struct-signature.rs:77:38 + --> $DIR/dep-graph-struct-signature.rs:77:9 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:48:38 + --> $DIR/dep-graph-struct-signature.rs:48:9 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:49:38 + --> $DIR/dep-graph-struct-signature.rs:49:9 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:55:38 + --> $DIR/dep-graph-struct-signature.rs:55:9 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-struct-signature.rs:56:38 + --> $DIR/dep-graph-struct-signature.rs:56:9 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 22 previous errors diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr index 293f918a3187..6f56cbc8dd7a 100644 --- a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr +++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr @@ -1,14 +1,14 @@ error: OK - --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:33:34 + --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:33:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `x::` to `typeck` - --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:42:34 + --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:42:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr index 46cb0e9ea86f..08f382cc024c 100644 --- a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr +++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr @@ -1,14 +1,14 @@ error: no path from `x::` to `typeck` - --> $DIR/dep-graph-trait-impl-two-traits.rs:32:34 + --> $DIR/dep-graph-trait-impl-two-traits.rs:32:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `x::` to `typeck` - --> $DIR/dep-graph-trait-impl-two-traits.rs:41:34 + --> $DIR/dep-graph-trait-impl-two-traits.rs:41:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/dep-graph/dep-graph-trait-impl.stderr b/tests/ui/dep-graph/dep-graph-trait-impl.stderr index a5fce64c3a1c..bfee6d5c87b3 100644 --- a/tests/ui/dep-graph/dep-graph-trait-impl.stderr +++ b/tests/ui/dep-graph/dep-graph-trait-impl.stderr @@ -1,32 +1,32 @@ error: OK - --> $DIR/dep-graph-trait-impl.rs:28:34 + --> $DIR/dep-graph-trait-impl.rs:28:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-trait-impl.rs:33:34 + --> $DIR/dep-graph-trait-impl.rs:33:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-trait-impl.rs:38:34 + --> $DIR/dep-graph-trait-impl.rs:38:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-trait-impl.rs:43:34 + --> $DIR/dep-graph-trait-impl.rs:43:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `x::` to `typeck` - --> $DIR/dep-graph-trait-impl.rs:56:34 + --> $DIR/dep-graph-trait-impl.rs:56:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/dep-graph/dep-graph-type-alias.stderr b/tests/ui/dep-graph/dep-graph-type-alias.stderr index 9f24c1113b98..42ac803b22ec 100644 --- a/tests/ui/dep-graph/dep-graph-type-alias.stderr +++ b/tests/ui/dep-graph/dep-graph-type-alias.stderr @@ -1,74 +1,74 @@ error: no path from `TypeAlias` to `type_of` - --> $DIR/dep-graph-type-alias.rs:18:30 + --> $DIR/dep-graph-type-alias.rs:18:1 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:20:34 + --> $DIR/dep-graph-type-alias.rs:20:5 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `TypeAlias` to `type_of` - --> $DIR/dep-graph-type-alias.rs:25:30 + --> $DIR/dep-graph-type-alias.rs:25:1 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:28:38 + --> $DIR/dep-graph-type-alias.rs:28:9 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `TypeAlias` to `type_of` - --> $DIR/dep-graph-type-alias.rs:34:30 + --> $DIR/dep-graph-type-alias.rs:34:1 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `TypeAlias` to `type_of` - --> $DIR/dep-graph-type-alias.rs:42:30 + --> $DIR/dep-graph-type-alias.rs:42:1 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:49:30 + --> $DIR/dep-graph-type-alias.rs:49:1 | LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:52:30 + --> $DIR/dep-graph-type-alias.rs:52:1 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:53:30 + --> $DIR/dep-graph-type-alias.rs:53:1 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:36:34 + --> $DIR/dep-graph-type-alias.rs:36:5 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:44:34 + --> $DIR/dep-graph-type-alias.rs:44:5 | LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK - --> $DIR/dep-graph-type-alias.rs:45:34 + --> $DIR/dep-graph-type-alias.rs:45:5 | LL | #[rustc_then_this_would_need(typeck)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/dep-graph/dep-graph-variance-alias.stderr b/tests/ui/dep-graph/dep-graph-variance-alias.stderr index 83ef573aad48..e11de2452899 100644 --- a/tests/ui/dep-graph/dep-graph-variance-alias.stderr +++ b/tests/ui/dep-graph/dep-graph-variance-alias.stderr @@ -1,8 +1,8 @@ error: OK - --> $DIR/dep-graph-variance-alias.rs:19:30 + --> $DIR/dep-graph-variance-alias.rs:19:1 | LL | #[rustc_then_this_would_need(variances_of)] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/deprecation/deprecated-expr-precedence.stderr b/tests/ui/deprecation/deprecated-expr-precedence.stderr index bd575e6b6276..c3124cf86ef4 100644 --- a/tests/ui/deprecation/deprecated-expr-precedence.stderr +++ b/tests/ui/deprecation/deprecated-expr-precedence.stderr @@ -5,7 +5,7 @@ LL | #[deprecated] 0 | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements = note: requested on the command line with `-W unused-attributes` error[E0308]: mismatched types diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index 427d14d89c19..a4dc9f23d3d2 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -83,7 +83,7 @@ LL | #[deprecated = "hello"] | ^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 10 previous errors diff --git a/tests/ui/derived-errors/issue-31997-1.stderr b/tests/ui/derived-errors/issue-31997-1.stderr index 2fb830ac41fc..40485027a660 100644 --- a/tests/ui/derived-errors/issue-31997-1.stderr +++ b/tests/ui/derived-errors/issue-31997-1.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `HashMap` in this scope +error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/issue-31997-1.rs:20:19 | LL | let mut map = HashMap::new(); diff --git a/tests/ui/derives/copy-drop-mutually-exclusive.rs b/tests/ui/derives/copy-drop-mutually-exclusive.rs index 64cd5bf594b0..5147605910d7 100644 --- a/tests/ui/derives/copy-drop-mutually-exclusive.rs +++ b/tests/ui/derives/copy-drop-mutually-exclusive.rs @@ -1,14 +1,14 @@ //! Regression test for issue #20126: Copy and Drop traits are mutually exclusive -#[derive(Copy, Clone)] -struct Foo; //~ ERROR the trait `Copy` cannot be implemented +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented +struct Foo; impl Drop for Foo { fn drop(&mut self) {} } -#[derive(Copy, Clone)] -struct Bar(::std::marker::PhantomData); //~ ERROR the trait `Copy` cannot be implemented +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented +struct Bar(::std::marker::PhantomData); impl Drop for Bar { fn drop(&mut self) {} diff --git a/tests/ui/derives/copy-drop-mutually-exclusive.stderr b/tests/ui/derives/copy-drop-mutually-exclusive.stderr index ab2d086c7f5f..771bbc925695 100644 --- a/tests/ui/derives/copy-drop-mutually-exclusive.stderr +++ b/tests/ui/derives/copy-drop-mutually-exclusive.stderr @@ -1,30 +1,14 @@ error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor - --> $DIR/copy-drop-mutually-exclusive.rs:4:8 + --> $DIR/copy-drop-mutually-exclusive.rs:3:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion -LL | struct Foo; - | ^^^ `Copy` not allowed on types with destructors - | -note: destructor declared here - --> $DIR/copy-drop-mutually-exclusive.rs:7:5 - | -LL | fn drop(&mut self) {} - | ^^^^^^^^^^^^^^^^^^ + | ^^^^ `Copy` not allowed on types with destructors error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor - --> $DIR/copy-drop-mutually-exclusive.rs:11:8 + --> $DIR/copy-drop-mutually-exclusive.rs:10:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion -LL | struct Bar(::std::marker::PhantomData); - | ^^^ `Copy` not allowed on types with destructors - | -note: destructor declared here - --> $DIR/copy-drop-mutually-exclusive.rs:14:5 - | -LL | fn drop(&mut self) {} - | ^^^^^^^^^^^^^^^^^^ + | ^^^^ `Copy` not allowed on types with destructors error: aborting due to 2 previous errors diff --git a/tests/ui/derives/derive-assoc-type-not-impl.stderr b/tests/ui/derives/derive-assoc-type-not-impl.stderr index ca968910fde4..13ba80243a5e 100644 --- a/tests/ui/derives/derive-assoc-type-not-impl.stderr +++ b/tests/ui/derives/derive-assoc-type-not-impl.stderr @@ -11,13 +11,10 @@ LL | Bar:: { x: 1 }.clone(); | ^^^^^ method cannot be called on `Bar` due to unsatisfied trait bounds | note: trait bound `NotClone: Clone` was not satisfied - --> $DIR/derive-assoc-type-not-impl.rs:7:12 + --> $DIR/derive-assoc-type-not-impl.rs:6:10 | LL | #[derive(Clone)] - | ----- in this derive macro expansion -LL | struct Bar { - | ^ type parameter would need to implement `Clone` - = help: consider manually implementing the trait to avoid undesired bounds + | ^^^^^ unsatisfied trait bound introduced in this `derive` macro help: consider annotating `NotClone` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr index 42dc8d46b575..e0cb3c1b43da 100644 --- a/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr @@ -7,7 +7,7 @@ LL | #[derive(Eq,PartialEq)] LL | x: Error | ^^^^^^^^ the trait `Eq` is not implemented for `Error` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL help: consider annotating `Error` with `#[derive(Eq)]` | diff --git a/tests/ui/derives/derives-span-Eq-enum.stderr b/tests/ui/derives/derives-span-Eq-enum.stderr index ef1d9e3242ad..2f09b9ea385f 100644 --- a/tests/ui/derives/derives-span-Eq-enum.stderr +++ b/tests/ui/derives/derives-span-Eq-enum.stderr @@ -7,7 +7,7 @@ LL | #[derive(Eq,PartialEq)] LL | Error | ^^^^^ the trait `Eq` is not implemented for `Error` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL help: consider annotating `Error` with `#[derive(Eq)]` | diff --git a/tests/ui/derives/derives-span-Eq-struct.stderr b/tests/ui/derives/derives-span-Eq-struct.stderr index bae7bb0361df..c16d9118e10f 100644 --- a/tests/ui/derives/derives-span-Eq-struct.stderr +++ b/tests/ui/derives/derives-span-Eq-struct.stderr @@ -7,7 +7,7 @@ LL | struct Struct { LL | x: Error | ^^^^^^^^ the trait `Eq` is not implemented for `Error` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL help: consider annotating `Error` with `#[derive(Eq)]` | diff --git a/tests/ui/derives/derives-span-Eq-tuple-struct.stderr b/tests/ui/derives/derives-span-Eq-tuple-struct.stderr index 13396cb27246..dac295eed919 100644 --- a/tests/ui/derives/derives-span-Eq-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Eq-tuple-struct.stderr @@ -7,7 +7,7 @@ LL | struct Struct( LL | Error | ^^^^^ the trait `Eq` is not implemented for `Error` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL help: consider annotating `Error` with `#[derive(Eq)]` | diff --git a/tests/ui/derives/deriving-copyclone.stderr b/tests/ui/derives/deriving-copyclone.stderr index 20a73ffdcfbf..befff8802804 100644 --- a/tests/ui/derives/deriving-copyclone.stderr +++ b/tests/ui/derives/deriving-copyclone.stderr @@ -7,12 +7,10 @@ LL | is_copy(B { a: 1, b: C }); | required by a bound introduced by this call | note: required for `B` to implement `Copy` - --> $DIR/deriving-copyclone.rs:10:8 + --> $DIR/deriving-copyclone.rs:9:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion -LL | struct B { - | ^ - type parameter would need to implement `Copy` + | ^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `is_copy` --> $DIR/deriving-copyclone.rs:18:15 | @@ -32,13 +30,10 @@ LL | is_clone(B { a: 1, b: C }); | required by a bound introduced by this call | note: required for `B` to implement `Clone` - --> $DIR/deriving-copyclone.rs:10:8 + --> $DIR/deriving-copyclone.rs:9:16 | LL | #[derive(Copy, Clone)] - | ----- in this derive macro expansion -LL | struct B { - | ^ - type parameter would need to implement `Clone` - = help: consider manually implementing `Clone` to avoid undesired bounds + | ^^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `is_clone` --> $DIR/deriving-copyclone.rs:19:16 | @@ -58,12 +53,10 @@ LL | is_copy(B { a: 1, b: D }); | required by a bound introduced by this call | note: required for `B` to implement `Copy` - --> $DIR/deriving-copyclone.rs:10:8 + --> $DIR/deriving-copyclone.rs:9:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion -LL | struct B { - | ^ - type parameter would need to implement `Copy` + | ^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `is_copy` --> $DIR/deriving-copyclone.rs:18:15 | diff --git a/tests/ui/derives/deriving-with-repr-packed-2.stderr b/tests/ui/derives/deriving-with-repr-packed-2.stderr index 6bd3fff39790..b62c67d9a9da 100644 --- a/tests/ui/derives/deriving-with-repr-packed-2.stderr +++ b/tests/ui/derives/deriving-with-repr-packed-2.stderr @@ -21,14 +21,10 @@ LL | let x: Foo = Foo(NonCopy, NonCopy, NonCopy); note: the following trait bounds were not satisfied: `NonCopy: Clone` `NonCopy: Copy` - --> $DIR/deriving-with-repr-packed-2.rs:7:16 + --> $DIR/deriving-with-repr-packed-2.rs:5:16 | LL | #[derive(Copy, Clone, Default, PartialEq, Eq)] - | ----- in this derive macro expansion -LL | #[repr(packed)] -LL | pub struct Foo(T, T, T); - | ^ type parameter would need to implement `Clone` - = help: consider manually implementing the trait to avoid undesired bounds + | ^^^^^ unsatisfied trait bound introduced in this `derive` macro help: consider annotating `NonCopy` with `#[derive(Clone, Copy)]` | LL + #[derive(Clone, Copy)] diff --git a/tests/ui/derives/issue-97343.stderr b/tests/ui/derives/issue-97343.stderr index c033a3d227c1..27691f571884 100644 --- a/tests/ui/derives/issue-97343.stderr +++ b/tests/ui/derives/issue-97343.stderr @@ -2,11 +2,12 @@ error[E0109]: type arguments are not allowed on type parameter `Irrelevant` --> $DIR/issue-97343.rs:4:23 | LL | #[derive(Debug)] - | ----- in this derive macro expansion + | ----- + | | + | not allowed on type parameter `Irrelevant` + | in this derive macro expansion LL | pub struct Irrelevant { - | ---------- ^^^^^^^^^^ type argument not allowed - | | - | not allowed on type parameter `Irrelevant` + | ^^^^^^^^^^ type argument not allowed | note: type parameter `Irrelevant` defined here --> $DIR/issue-97343.rs:4:23 diff --git a/tests/ui/derives/nonsense-input-to-debug.stderr b/tests/ui/derives/nonsense-input-to-debug.stderr index 207d7b1969de..7c97ca93cfc9 100644 --- a/tests/ui/derives/nonsense-input-to-debug.stderr +++ b/tests/ui/derives/nonsense-input-to-debug.stderr @@ -13,6 +13,8 @@ LL | should_be_vec_t: vec![T], | expected type | in this macro invocation | this macro call doesn't expand to a type + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0392]: type parameter `T` is never used --> $DIR/nonsense-input-to-debug.rs:5:17 diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index 2a05d77f8f6d..b778eab60596 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -51,7 +51,7 @@ impl ::core::default::Default for Empty { #[automatically_derived] impl ::core::hash::Hash for Empty { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {} + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } #[automatically_derived] impl ::core::marker::StructuralPartialEq for Empty { } @@ -65,7 +65,7 @@ impl ::core::cmp::Eq for Empty { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) {} + fn assert_receiver_is_total_eq(&self) -> () {} } #[automatically_derived] impl ::core::cmp::PartialOrd for Empty { @@ -123,7 +123,7 @@ impl ::core::default::Default for Point { #[automatically_derived] impl ::core::hash::Hash for Point { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.x, state); ::core::hash::Hash::hash(&self.y, state) } @@ -142,7 +142,7 @@ impl ::core::cmp::Eq for Point { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; } } @@ -211,7 +211,7 @@ impl ::core::default::Default for PackedPoint { #[automatically_derived] impl ::core::hash::Hash for PackedPoint { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&{ self.x }, state); ::core::hash::Hash::hash(&{ self.y }, state) } @@ -230,7 +230,7 @@ impl ::core::cmp::Eq for PackedPoint { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; } } @@ -297,7 +297,7 @@ impl ::core::convert::From for TupleSingleField { #[automatically_derived] impl ::core::hash::Hash for TupleSingleField { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.0, state) } } @@ -313,7 +313,7 @@ impl ::core::cmp::Eq for TupleSingleField { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; } } @@ -372,7 +372,7 @@ impl ::core::convert::From for SingleField { #[automatically_derived] impl ::core::hash::Hash for SingleField { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.foo, state) } } @@ -388,7 +388,7 @@ impl ::core::cmp::Eq for SingleField { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; } } @@ -465,7 +465,7 @@ impl ::core::default::Default for Big { #[automatically_derived] impl ::core::hash::Hash for Big { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.b1, state); ::core::hash::Hash::hash(&self.b2, state); ::core::hash::Hash::hash(&self.b3, state); @@ -493,7 +493,7 @@ impl ::core::cmp::Eq for Big { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; } } @@ -741,7 +741,7 @@ impl ::core::convert::From<[u32]> for Unsized { #[automatically_derived] impl ::core::hash::Hash for Unsized { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.0, state) } } @@ -757,7 +757,7 @@ impl ::core::cmp::Eq for Unsized { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq<[u32]>; } } @@ -829,7 +829,7 @@ impl impl ::core::hash::Hash for Generic where T::A: ::core::hash::Hash { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.t, state); ::core::hash::Hash::hash(&self.ta, state); ::core::hash::Hash::hash(&self.u, state) @@ -852,7 +852,7 @@ impl ::core::cmp::Eq for #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq; @@ -946,7 +946,7 @@ impl where T::A: ::core::hash::Hash + ::core::marker::Copy { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&{ self.0 }, state); ::core::hash::Hash::hash(&{ self.1 }, state); ::core::hash::Hash::hash(&{ self.2 }, state) @@ -974,7 +974,7 @@ impl () { let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq; @@ -1043,7 +1043,7 @@ impl ::core::fmt::Debug for Enum0 { #[automatically_derived] impl ::core::hash::Hash for Enum0 { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { match *self {} } } @@ -1059,7 +1059,7 @@ impl ::core::cmp::Eq for Enum0 { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) {} + fn assert_receiver_is_total_eq(&self) -> () {} } #[automatically_derived] impl ::core::cmp::PartialOrd for Enum0 { @@ -1105,7 +1105,7 @@ impl ::core::fmt::Debug for Enum1 { #[automatically_derived] impl ::core::hash::Hash for Enum1 { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { match self { Enum1::Single { x: __self_0 } => ::core::hash::Hash::hash(__self_0, state), @@ -1129,7 +1129,7 @@ impl ::core::cmp::Eq for Enum1 { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; } } @@ -1181,7 +1181,7 @@ impl ::core::default::Default for Fieldless1 { #[automatically_derived] impl ::core::hash::Hash for Fieldless1 { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {} + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } #[automatically_derived] impl ::core::marker::StructuralPartialEq for Fieldless1 { } @@ -1195,7 +1195,7 @@ impl ::core::cmp::Eq for Fieldless1 { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) {} + fn assert_receiver_is_total_eq(&self) -> () {} } #[automatically_derived] impl ::core::cmp::PartialOrd for Fieldless1 { @@ -1251,7 +1251,7 @@ impl ::core::default::Default for Fieldless { #[automatically_derived] impl ::core::hash::Hash for Fieldless { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_discr = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_discr, state) } @@ -1272,7 +1272,7 @@ impl ::core::cmp::Eq for Fieldless { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) {} + fn assert_receiver_is_total_eq(&self) -> () {} } #[automatically_derived] impl ::core::cmp::PartialOrd for Fieldless { @@ -1345,7 +1345,7 @@ impl ::core::default::Default for Mixed { #[automatically_derived] impl ::core::hash::Hash for Mixed { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_discr = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_discr, state); match self { @@ -1382,7 +1382,7 @@ impl ::core::cmp::Eq for Mixed { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq>; let _: ::core::cmp::AssertParamIsEq>; @@ -1545,7 +1545,7 @@ impl ::core::fmt::Debug for Fielded { #[automatically_derived] impl ::core::hash::Hash for Fielded { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_discr = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_discr, state); match self { @@ -1580,7 +1580,7 @@ impl ::core::cmp::Eq for Fielded { #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq>; @@ -1666,7 +1666,7 @@ impl ::core::fmt::Debug for impl ::core::hash::Hash for EnumGeneric { #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_discr = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_discr, state); match self { @@ -1702,7 +1702,7 @@ impl ::core::cmp::Eq for #[inline] #[doc(hidden)] #[coverage(off)] - fn assert_receiver_is_total_eq(&self) { + fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq; let _: ::core::cmp::AssertParamIsEq; } diff --git a/tests/ui/deriving/issue-103157.stderr b/tests/ui/deriving/issue-103157.stderr index 0e4a3f75db3f..51d4d0a89745 100644 --- a/tests/ui/deriving/issue-103157.stderr +++ b/tests/ui/deriving/issue-103157.stderr @@ -18,7 +18,7 @@ LL | Float(Option), u16 and 4 others = note: required for `Option` to implement `Eq` -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr index 075e4bf0384d..43205bd395fc 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr @@ -1,8 +1,8 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments --> $DIR/does_not_acccept_args.rs:12:1 | -LL | #[diagnostic::do_not_recommend(if, crate, do yeet, false, dyn, abstract, gen, not_accepted)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diagnostic::do_not_recommend(not_accepted)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr index 075e4bf0384d..43205bd395fc 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr @@ -1,8 +1,8 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments --> $DIR/does_not_acccept_args.rs:12:1 | -LL | #[diagnostic::do_not_recommend(if, crate, do yeet, false, dyn, abstract, gen, not_accepted)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diagnostic::do_not_recommend(not_accepted)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.rs b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.rs index 943b5a37f938..918bf5a0113e 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.rs @@ -9,7 +9,7 @@ trait Bar {} trait Baz {} trait Boo {} -#[diagnostic::do_not_recommend(if, crate, do yeet, false, dyn, abstract, gen, not_accepted)] +#[diagnostic::do_not_recommend(not_accepted)] //~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments impl Foo for T where T: Send {} diff --git a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs index f7babae3aa7c..c0af549e2d01 100644 --- a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs +++ b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs @@ -6,7 +6,7 @@ pub struct Foo; #[diagnostic::on_const(message = "tadaa", note = "boing")] -//~^ ERROR: `#[diagnostic::on_const]` can only be applied to non-const trait impls +//~^ ERROR: `#[diagnostic::on_const]` can only be applied to trait impls impl const PartialEq for Foo { fn eq(&self, _other: &Foo) -> bool { true diff --git a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr index f92ea501696e..baa0b11f798b 100644 --- a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr +++ b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr @@ -13,14 +13,14 @@ note: the lint level is defined here LL | #![deny(misplaced_diagnostic_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[diagnostic::on_const]` can only be applied to non-const trait impls +error: `#[diagnostic::on_const]` can only be applied to trait impls --> $DIR/misplaced_attr.rs:8:1 | LL | #[diagnostic::on_const(message = "tadaa", note = "boing")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | impl const PartialEq for Foo { - | ---------------------------- this is a const trait impl + | ---------------------------- not a trait impl error: `#[diagnostic::on_const]` can only be applied to trait impls --> $DIR/misplaced_attr.rs:16:1 diff --git a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs index b007425bd375..bbab6f877487 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs @@ -2,18 +2,12 @@ mod a {} macro_rules! m { () => { - use a::$crate; //~ ERROR: unresolved import `a::$crate` - //~^ NOTE: no `$crate` in `a` - use a::$crate::b; //~ ERROR: `$crate` in paths can only be used in start position - //~^ NOTE: can only be used in path start position - type A = a::$crate; //~ ERROR: `$crate` in paths can only be used in start position - //~^ NOTE: can only be used in path start position + use a::$crate; //~ ERROR unresolved import `a::$crate` + use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position + type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position } } m!(); -//~^ NOTE: in this expansion -//~| NOTE: in this expansion -//~| NOTE: in this expansion fn main() {} diff --git a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr index fc49e4c3dc3d..d46029710d6f 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr @@ -1,8 +1,8 @@ -error[E0433]: `$crate` in paths can only be used in start position - --> $DIR/dollar-crate-is-keyword-2.rs:7:16 +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/dollar-crate-is-keyword-2.rs:6:16 | LL | use a::$crate::b; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | m!(); | ---- in this macro invocation @@ -20,11 +20,11 @@ LL | m!(); | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `$crate` in paths can only be used in start position - --> $DIR/dollar-crate-is-keyword-2.rs:9:21 +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/dollar-crate-is-keyword-2.rs:7:21 | LL | type A = a::$crate; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | m!(); | ---- in this macro invocation diff --git a/tests/ui/dropck/cleanup-arm-conditional.rs b/tests/ui/dropck/cleanup-arm-conditional.rs index 7afbf9595da5..31331f24d6f6 100644 --- a/tests/ui/dropck/cleanup-arm-conditional.rs +++ b/tests/ui/dropck/cleanup-arm-conditional.rs @@ -1,9 +1,13 @@ //@ run-pass +#![allow(stable_features)] #![allow(unused_imports)] // Test that cleanup scope for temporaries created in a match // arm is confined to the match arm itself. + +#![feature(os)] + use std::os; struct Test { x: isize } diff --git a/tests/ui/dst/dst-index-fail.rs b/tests/ui/dst/dst-index.rs similarity index 100% rename from tests/ui/dst/dst-index-fail.rs rename to tests/ui/dst/dst-index.rs diff --git a/tests/ui/dst/dst-index-fail.stderr b/tests/ui/dst/dst-index.stderr similarity index 85% rename from tests/ui/dst/dst-index-fail.stderr rename to tests/ui/dst/dst-index.stderr index a5481e9ad673..d38af3f89c21 100644 --- a/tests/ui/dst/dst-index-fail.stderr +++ b/tests/ui/dst/dst-index.stderr @@ -1,23 +1,23 @@ error[E0161]: cannot move a value of type `str` - --> $DIR/dst-index-fail.rs:31:5 + --> $DIR/dst-index.rs:31:5 | LL | S[0]; | ^^^^ the size of `str` cannot be statically determined error[E0161]: cannot move a value of type `dyn Debug` - --> $DIR/dst-index-fail.rs:34:5 + --> $DIR/dst-index.rs:34:5 | LL | T[0]; | ^^^^ the size of `dyn Debug` cannot be statically determined error[E0507]: cannot move out of index of `S` - --> $DIR/dst-index-fail.rs:31:5 + --> $DIR/dst-index.rs:31:5 | LL | S[0]; | ^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait error[E0507]: cannot move out of index of `T` - --> $DIR/dst-index-fail.rs:34:5 + --> $DIR/dst-index.rs:34:5 | LL | T[0]; | ^^^^ move occurs because value has type `dyn Debug`, which does not implement the `Copy` trait diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs index f4193f18352d..8e5cd4248f14 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs @@ -3,12 +3,12 @@ struct NonGeneric {} #[derive(Default)] -//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied -//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied +//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied +//~^^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied +//~^^^ ERROR struct takes 0 generic arguments but 1 generic argument was supplied +//~^^^^ ERROR struct takes 0 generic arguments but 1 generic argument was supplied struct NonGeneric<'a, const N: usize> {} -//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied -//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied -//~| ERROR: lifetime parameter `'a` is never used -//~| ERROR: the name `NonGeneric` is defined multiple times +//~^ ERROR lifetime parameter `'a` is never used +//~^^ ERROR the name `NonGeneric` is defined multiple times pub fn main() {} diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr index 0d6aaaf5186d..cf9c0d0ad3be 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `NonGeneric` is defined multiple times - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:1 + --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:10:1 | LL | struct NonGeneric {} | ----------------- previous definition of the type `NonGeneric` here @@ -37,7 +37,7 @@ LL | struct NonGeneric {} | ^^^^^^^^^^ error[E0392]: lifetime parameter `'a` is never used - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:19 + --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:10:19 | LL | struct NonGeneric<'a, const N: usize> {} | ^^ unused lifetime parameter @@ -45,26 +45,29 @@ LL | struct NonGeneric<'a, const N: usize> {} = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8 + --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10 | +LL | #[derive(Default)] + | ^^^^^^^ expected 0 lifetime arguments +... LL | struct NonGeneric<'a, const N: usize> {} - | ^^^^^^^^^^ -- help: remove the lifetime argument - | | - | expected 0 lifetime arguments + | -- help: remove the lifetime argument | note: struct defined here, with 0 lifetime parameters --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8 | LL | struct NonGeneric {} | ^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8 + --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10 | +LL | #[derive(Default)] + | ^^^^^^^ expected 0 generic arguments +... LL | struct NonGeneric<'a, const N: usize> {} - | ^^^^^^^^^^ - help: remove the unnecessary generic argument - | | - | expected 0 generic arguments + | - help: remove the unnecessary generic argument | note: struct defined here, with 0 generic parameters --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8 diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs index e946c0c5350e..f3bf299aa65f 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs @@ -8,12 +8,12 @@ struct NotSM; #[derive(PartialEq, Eq)] -//~^ ERROR: struct takes 0 generic arguments +//~^ ERROR struct takes 0 generic arguments +//~| ERROR struct takes 0 generic arguments +//~| ERROR struct takes 0 generic arguments +//~| ERROR struct takes 0 generic arguments struct NotSM(T); -//~^ ERROR: struct takes 0 generic arguments -//~| ERROR: struct takes 0 generic arguments -//~| ERROR: struct takes 0 generic arguments -//~| ERROR: the name `NotSM` is defined multiple times -//~| ERROR: no field `0` +//~^ ERROR the name `NotSM` is defined multiple times +//~| ERROR no field `0` fn main() {} diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr index e80cf35d81e1..32c3cf440316 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `NotSM` is defined multiple times - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:1 + --> $DIR/multiple-types-with-same-name-and-derive.rs:15:1 | LL | struct NotSM; | ------------- previous definition of the type `NotSM` here @@ -10,10 +10,10 @@ LL | struct NotSM(T); = note: `NotSM` must be defined only once in the type namespace of this module error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8 + --> $DIR/multiple-types-with-same-name-and-derive.rs:10:10 | -LL | struct NotSM(T); - | ^^^^^ expected 0 generic arguments +LL | #[derive(PartialEq, Eq)] + | ^^^^^^^^^ expected 0 generic arguments | note: struct defined here, with 0 generic parameters --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 @@ -32,25 +32,25 @@ note: struct defined here, with 0 generic parameters | LL | struct NotSM; | ^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8 + --> $DIR/multiple-types-with-same-name-and-derive.rs:10:21 | -LL | struct NotSM(T); - | ^^^^^ expected 0 generic arguments +LL | #[derive(PartialEq, Eq)] + | ^^ expected 0 generic arguments | note: struct defined here, with 0 generic parameters --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 | LL | struct NotSM; | ^^^^^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8 + --> $DIR/multiple-types-with-same-name-and-derive.rs:10:10 | -LL | struct NotSM(T); - | ^^^^^ expected 0 generic arguments +LL | #[derive(PartialEq, Eq)] + | ^^^^^^^^^ expected 0 generic arguments | note: struct defined here, with 0 generic parameters --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 @@ -60,7 +60,7 @@ LL | struct NotSM; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0609]: no field `0` on type `&NotSM` - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:17 + --> $DIR/multiple-types-with-same-name-and-derive.rs:15:17 | LL | struct NotSM(T); | ^ unknown field diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds.stderr index 717d8949e2d8..21ba90301173 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds.stderr @@ -5,7 +5,7 @@ LL | type Bar | -------- `Bar` defined here ... LL | fn foo(_: &dyn Foo<()>) {} - | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = /* Type */>` + | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds.rs:11:16 @@ -14,7 +14,7 @@ LL | type Bar | -------- `Bar` defined here ... LL | fn bar(_: &dyn Foo) {} - | ^^^^^^^^ help: specify the associated type: `Foo` + | ^^^^^^^^ help: specify the associated type: `Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds2.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds2.stderr index 9ddded9addfa..5c4163b19693 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds2.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds2.stderr @@ -5,7 +5,7 @@ LL | type Bar | -------- `Bar` defined here ... LL | fn foo(_: &dyn Foo<()>) {} - | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = /* Type */>` + | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds2.rs:11:16 @@ -14,7 +14,7 @@ LL | type Bar | -------- `Bar` defined here ... LL | fn bar(_: &dyn Foo) {} - | ^^^^^^^^ help: specify the associated type: `Foo` + | ^^^^^^^^ help: specify the associated type: `Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_others.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_others.stderr index 8f75f19f571a..5438faaaf054 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_others.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_others.stderr @@ -5,7 +5,7 @@ LL | type Bop; | -------- `Bop` defined here ... LL | fn foo(_: &dyn Foo) {} - | ^^^ help: specify the associated type: `Foo` + | ^^^ help: specify the associated type: `Foo` error[E0191]: the value of the associated type `Bop` in `Bar` must be specified --> $DIR/assoc_type_bounds_sized_others.rs:22:16 @@ -14,7 +14,7 @@ LL | type Bop; | -------- `Bop` defined here ... LL | fn bar(_: &dyn Bar) {} - | ^^^ help: specify the associated type: `Bar` + | ^^^ help: specify the associated type: `Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/dyn-compatibility/associated-consts.stderr b/tests/ui/dyn-compatibility/associated-consts.stderr index a92557ea7b8b..dc64c93a577e 100644 --- a/tests/ui/dyn-compatibility/associated-consts.stderr +++ b/tests/ui/dyn-compatibility/associated-consts.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/associated-consts.rs:8:35 + --> $DIR/associated-consts.rs:8:31 | LL | fn make_bar(t: &T) -> &dyn Bar { - | ^^^ `Bar` is not dyn compatible + | ^^^^^^^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit @@ -11,7 +11,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait Bar { | --- this trait is not dyn compatible... LL | const X: usize; - | ^ ...because it contains associated const `X` + | ^ ...because it contains this associated `const` = help: consider moving `X` to another trait error: aborting due to 1 previous error diff --git a/tests/ui/dyn-compatibility/default-param-self-projection.stderr b/tests/ui/dyn-compatibility/default-param-self-projection.stderr index 86f85f4da8e6..ea252a99b048 100644 --- a/tests/ui/dyn-compatibility/default-param-self-projection.stderr +++ b/tests/ui/dyn-compatibility/default-param-self-projection.stderr @@ -7,11 +7,11 @@ LL | trait A::E> {} LL | let B: &dyn A = &(); | ^ | - = note: because the parameter default references `Self`, the parameter must be specified on the trait object type -help: explicitly specify the type parameter + = note: because the parameter default references `Self`, the parameter must be specified on the object type +help: set the type parameter to the desired type | -LL | let B: &dyn A = &(); - | +++++++++ +LL | let B: &dyn A = &(); + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr b/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr index 1189c8dc2a6a..cfebd5d69470 100644 --- a/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr +++ b/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr @@ -11,7 +11,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait Super { | ----- this trait is not dyn compatible... LL | type Assoc<'a>; - | ^^^^^ ...because it contains generic associated type `Assoc` + | ^^^^^ ...because it contains the generic associated type `Assoc` = help: consider moving `Assoc` to another trait error: aborting due to 1 previous error diff --git a/tests/ui/dyn-compatibility/metasized.rs b/tests/ui/dyn-compatibility/metasized.rs deleted file mode 100644 index ff233c5ca764..000000000000 --- a/tests/ui/dyn-compatibility/metasized.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass -//! This test and `sized-*.rs` and `pointeesized.rs` test that dyn-compatibility correctly -//! handles sizedness traits, which are special in several parts of the compiler. -#![feature(sized_hierarchy)] -use std::marker::MetaSized; - -trait Foo: std::fmt::Debug + MetaSized {} - -impl Foo for T {} - -fn unsize_sized(x: Box) -> Box { - x -} - -fn unsize_subtrait(x: Box) -> Box { - x -} - -fn main() { - let _bx = unsize_sized(Box::new(vec![1, 2, 3])); - - let bx: Box = Box::new(vec![1, 2, 3]); - let _ = format!("{bx:?}"); - let _bx = unsize_subtrait(bx); -} diff --git a/tests/ui/dyn-compatibility/missing-assoc-type.stderr b/tests/ui/dyn-compatibility/missing-assoc-type.stderr index 5a5dc20590d0..5a7560682f2e 100644 --- a/tests/ui/dyn-compatibility/missing-assoc-type.stderr +++ b/tests/ui/dyn-compatibility/missing-assoc-type.stderr @@ -11,7 +11,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait Foo { | --- this trait is not dyn compatible... LL | type Bar; - | ^^^ ...because it contains generic associated type `Bar` + | ^^^ ...because it contains the generic associated type `Bar` = help: consider moving `Bar` to another trait error: aborting due to 1 previous error diff --git a/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr b/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr index bef580bcedb5..94037387c3e1 100644 --- a/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr +++ b/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr @@ -11,7 +11,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait Tr { | -- this trait is not dyn compatible... LL | const N: usize; - | ^ ...because it contains associated const `N` + | ^ ...because it contains this associated `const` = help: consider moving `N` to another trait = help: only type `u8` implements `Tr`; consider using it directly instead. diff --git a/tests/ui/dyn-compatibility/pointeesized.rs b/tests/ui/dyn-compatibility/pointeesized.rs deleted file mode 100644 index 863abd704ead..000000000000 --- a/tests/ui/dyn-compatibility/pointeesized.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -//! This test and `sized-*.rs` and `metasized.rs` test that dyn-compatibility correctly -//! handles sizedness traits, which are special in several parts of the compiler. -#![feature(sized_hierarchy)] -// PointeeSized is effectively removed before reaching the trait solver, -// so it's as though it wasn't even mentioned in the trait list. -use std::marker::PointeeSized; - -fn main() { - let dyn_ref: &(dyn PointeeSized + Send) = &42; - let dyn_ref: &dyn Send = dyn_ref; - let _dyn_ref: &(dyn PointeeSized + Send) = dyn_ref; - assert_eq!( - std::any::TypeId::of::(), - std::any::TypeId::of::(), - ); -} diff --git a/tests/ui/dyn-compatibility/require-assoc-for-all-super-substs.stderr b/tests/ui/dyn-compatibility/require-assoc-for-all-super-substs.stderr index f39be936f417..3d89b52d522d 100644 --- a/tests/ui/dyn-compatibility/require-assoc-for-all-super-substs.stderr +++ b/tests/ui/dyn-compatibility/require-assoc-for-all-super-substs.stderr @@ -5,7 +5,7 @@ LL | type Assoc: Default; | ------------------- `Assoc` defined here ... LL | let q: as Sup>::Assoc = Default::default(); - | ^^^^^^^^^^^^^ help: specify the associated type: `Dyn` + | ^^^^^^^^^^^^^ help: specify the associated type: `Dyn` error: aborting due to 1 previous error diff --git a/tests/ui/dyn-compatibility/sized-3.rs b/tests/ui/dyn-compatibility/sized-3.rs deleted file mode 100644 index 84ee391445e7..000000000000 --- a/tests/ui/dyn-compatibility/sized-3.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This test and `metasized.rs` and `pointeesized.rs` test that dyn-compatibility correctly -//! handles the different sizedness traits, which are special in several parts of the compiler. - -trait Foo: std::fmt::Debug + Sized {} - -impl Foo for T {} - -fn unsize_sized(x: Box) -> Box { - //~^ ERROR the trait `Sized` is not dyn compatible - x -} - -fn unsize_subtrait(x: Box) -> Box { - //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Sized` is not dyn compatible - x -} - -fn main() { - let _bx = unsize_sized(Box::new(vec![1, 2, 3])); - //~^ ERROR the trait `Sized` is not dyn compatible - - let bx: Box = Box::new(vec![1, 2, 3]); - //~^ ERROR the trait `Foo` is not dyn compatible - let _ = format!("{bx:?}"); - let _bx = unsize_subtrait(bx); - //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Sized` is not dyn compatible -} diff --git a/tests/ui/dyn-compatibility/sized-3.stderr b/tests/ui/dyn-compatibility/sized-3.stderr deleted file mode 100644 index 88d3bb5810fe..000000000000 --- a/tests/ui/dyn-compatibility/sized-3.stderr +++ /dev/null @@ -1,88 +0,0 @@ -error[E0038]: the trait `Sized` is not dyn compatible - --> $DIR/sized-3.rs:8:47 - | -LL | fn unsize_sized(x: Box) -> Box { - | ^^^^^^^^^ `Sized` is not dyn compatible - | - = note: the trait is not dyn compatible because it requires `Self: Sized` - = note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/sized-3.rs:13:27 - | -LL | fn unsize_subtrait(x: Box) -> Box { - | ^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/sized-3.rs:4:30 - | -LL | trait Foo: std::fmt::Debug + Sized {} - | --- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - -error[E0038]: the trait `Sized` is not dyn compatible - --> $DIR/sized-3.rs:13:44 - | -LL | fn unsize_subtrait(x: Box) -> Box { - | ^^^^^^^^^ `Sized` is not dyn compatible - | - = note: the trait is not dyn compatible because it requires `Self: Sized` - = note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - -error[E0038]: the trait `Sized` is not dyn compatible - --> $DIR/sized-3.rs:20:15 - | -LL | let _bx = unsize_sized(Box::new(vec![1, 2, 3])); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Sized` is not dyn compatible - | - = note: the trait is not dyn compatible because it requires `Self: Sized` - = note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/sized-3.rs:23:21 - | -LL | let bx: Box = Box::new(vec![1, 2, 3]); - | ^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/sized-3.rs:4:30 - | -LL | trait Foo: std::fmt::Debug + Sized {} - | --- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/sized-3.rs:26:31 - | -LL | let _bx = unsize_subtrait(bx); - | ^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/sized-3.rs:4:30 - | -LL | trait Foo: std::fmt::Debug + Sized {} - | --- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - -error[E0038]: the trait `Sized` is not dyn compatible - --> $DIR/sized-3.rs:26:15 - | -LL | let _bx = unsize_subtrait(bx); - | ^^^^^^^^^^^^^^^^^^^ `Sized` is not dyn compatible - | - = note: the trait is not dyn compatible because it requires `Self: Sized` - = note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr index a8c2f512a9ad..ba4ce4753995 100644 --- a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr +++ b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr @@ -18,7 +18,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable --> $DIR/supertrait-mentions-GAT.rs:4:10 | LL | type Gat<'a> - | ^^^ ...because it contains generic associated type `Gat` + | ^^^ ...because it contains the generic associated type `Gat` ... LL | trait SuperTrait: for<'a> GatTrait = T> { | ---------- this trait is not dyn compatible... diff --git a/tests/ui/dyn-compatibility/trait-alias-self-projection.rs b/tests/ui/dyn-compatibility/trait-alias-self-projection.rs new file mode 100644 index 000000000000..0badb738809e --- /dev/null +++ b/tests/ui/dyn-compatibility/trait-alias-self-projection.rs @@ -0,0 +1,12 @@ +#![feature(trait_alias)] +trait B = Fn() -> Self; +type D = &'static dyn B; +//~^ ERROR E0411 + +fn a() -> D { + unreachable!(); +} + +fn main() { + _ = a(); +} diff --git a/tests/ui/dyn-compatibility/trait-alias-self-projection.stderr b/tests/ui/dyn-compatibility/trait-alias-self-projection.stderr new file mode 100644 index 000000000000..dccee02e9cd1 --- /dev/null +++ b/tests/ui/dyn-compatibility/trait-alias-self-projection.stderr @@ -0,0 +1,9 @@ +error[E0411]: `Self` is not allowed in type aliases + --> $DIR/trait-alias-self-projection.rs:3:19 + | +LL | type D = &'static dyn B; + | ^^^^^ `Self` is only available in impls, traits, and concrete type definitions + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0411`. diff --git a/tests/ui/dyn-compatibility/type-projection-behind-trait-alias-mentions-self.rs b/tests/ui/dyn-compatibility/type-projection-behind-trait-alias-mentions-self.rs deleted file mode 100644 index 9122ddaaff7b..000000000000 --- a/tests/ui/dyn-compatibility/type-projection-behind-trait-alias-mentions-self.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Check that we reject type projections behind trait aliases that mention `Self`. -// -// The author of the trait object type can't fix this unlike the supertrait bound -// equivalent where they just need to explicitly specify the assoc type. - -// issue: - -#![feature(trait_alias)] - -trait F = Fn() -> Self; - -trait G = H; -trait H { type T: ?Sized; } - -fn main() { - let _: dyn F; //~ ERROR associated type binding in trait object type mentions `Self` - let _: dyn G; //~ ERROR associated type binding in trait object type mentions `Self` -} diff --git a/tests/ui/dyn-compatibility/type-projection-behind-trait-alias-mentions-self.stderr b/tests/ui/dyn-compatibility/type-projection-behind-trait-alias-mentions-self.stderr deleted file mode 100644 index 0b7fb55a908c..000000000000 --- a/tests/ui/dyn-compatibility/type-projection-behind-trait-alias-mentions-self.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: associated type binding in trait object type mentions `Self` - --> $DIR/type-projection-behind-trait-alias-mentions-self.rs:16:12 - | -LL | trait F = Fn() -> Self; - | ---- this binding mentions `Self` -... -LL | let _: dyn F; - | ^^^^^ contains a mention of `Self` - -error: associated type binding in trait object type mentions `Self` - --> $DIR/type-projection-behind-trait-alias-mentions-self.rs:17:12 - | -LL | trait G = H; - | -------- this binding mentions `Self` -... -LL | let _: dyn G; - | ^^^^^ contains a mention of `Self` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/dst/dst-coerce-custom.rs b/tests/ui/dynamically-sized-types/dst-coerce-custom.rs similarity index 100% rename from tests/ui/dst/dst-coerce-custom.rs rename to tests/ui/dynamically-sized-types/dst-coerce-custom.rs diff --git a/tests/ui/dst/dst-coerce-rc.rs b/tests/ui/dynamically-sized-types/dst-coerce-rc.rs similarity index 93% rename from tests/ui/dst/dst-coerce-rc.rs rename to tests/ui/dynamically-sized-types/dst-coerce-rc.rs index 490cfaca7de9..5ec7853a8e82 100644 --- a/tests/ui/dst/dst-coerce-rc.rs +++ b/tests/ui/dynamically-sized-types/dst-coerce-rc.rs @@ -1,7 +1,10 @@ //@ run-pass #![allow(unused_variables)] +#![allow(stable_features)] // Test a very simple custom DST coercion. +#![feature(core, rc_weak)] + use std::cell::RefCell; use std::rc::{Rc, Weak}; diff --git a/tests/ui/dst/dst-coercions.rs b/tests/ui/dynamically-sized-types/dst-coercions.rs similarity index 100% rename from tests/ui/dst/dst-coercions.rs rename to tests/ui/dynamically-sized-types/dst-coercions.rs diff --git a/tests/ui/dst/dst-coercions.stderr b/tests/ui/dynamically-sized-types/dst-coercions.stderr similarity index 100% rename from tests/ui/dst/dst-coercions.stderr rename to tests/ui/dynamically-sized-types/dst-coercions.stderr diff --git a/tests/ui/dst/dst-deref-mut.rs b/tests/ui/dynamically-sized-types/dst-deref-mut.rs similarity index 100% rename from tests/ui/dst/dst-deref-mut.rs rename to tests/ui/dynamically-sized-types/dst-deref-mut.rs diff --git a/tests/ui/dst/dst-deref.rs b/tests/ui/dynamically-sized-types/dst-deref.rs similarity index 100% rename from tests/ui/dst/dst-deref.rs rename to tests/ui/dynamically-sized-types/dst-deref.rs diff --git a/tests/ui/dst/dst-field-align.rs b/tests/ui/dynamically-sized-types/dst-field-align.rs similarity index 100% rename from tests/ui/dst/dst-field-align.rs rename to tests/ui/dynamically-sized-types/dst-field-align.rs diff --git a/tests/ui/dst/dst-index-success.rs b/tests/ui/dynamically-sized-types/dst-index.rs similarity index 100% rename from tests/ui/dst/dst-index-success.rs rename to tests/ui/dynamically-sized-types/dst-index.rs diff --git a/tests/ui/dst/dst-irrefutable-bind.rs b/tests/ui/dynamically-sized-types/dst-irrefutable-bind.rs similarity index 100% rename from tests/ui/dst/dst-irrefutable-bind.rs rename to tests/ui/dynamically-sized-types/dst-irrefutable-bind.rs diff --git a/tests/ui/dst/dst-raw.rs b/tests/ui/dynamically-sized-types/dst-raw.rs similarity index 100% rename from tests/ui/dst/dst-raw.rs rename to tests/ui/dynamically-sized-types/dst-raw.rs diff --git a/tests/ui/dst/dst-struct-sole.rs b/tests/ui/dynamically-sized-types/dst-struct-sole.rs similarity index 100% rename from tests/ui/dst/dst-struct-sole.rs rename to tests/ui/dynamically-sized-types/dst-struct-sole.rs diff --git a/tests/ui/dst/dst-struct.rs b/tests/ui/dynamically-sized-types/dst-struct.rs similarity index 100% rename from tests/ui/dst/dst-struct.rs rename to tests/ui/dynamically-sized-types/dst-struct.rs diff --git a/tests/ui/dst/dst-trait.rs b/tests/ui/dynamically-sized-types/dst-trait.rs similarity index 100% rename from tests/ui/dst/dst-trait.rs rename to tests/ui/dynamically-sized-types/dst-trait.rs diff --git a/tests/ui/eii/privacy2.rs b/tests/ui/eii/privacy2.rs index c11061f311ed..e3f1f8c863da 100644 --- a/tests/ui/eii/privacy2.rs +++ b/tests/ui/eii/privacy2.rs @@ -13,7 +13,7 @@ fn eii1_impl(x: u64) { println!("{x:?}") } -#[codegen::eii3] //~ ERROR cannot find `eii3` in `codegen` +#[codegen::eii3] //~ ERROR failed to resolve: could not find `eii3` in `codegen` fn eii3_impl(x: u64) { println!("{x:?}") } diff --git a/tests/ui/eii/privacy2.stderr b/tests/ui/eii/privacy2.stderr index f0a04bf63561..9f4fd6a071c9 100644 --- a/tests/ui/eii/privacy2.stderr +++ b/tests/ui/eii/privacy2.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `eii3` in `codegen` +error[E0433]: failed to resolve: could not find `eii3` in `codegen` --> $DIR/privacy2.rs:16:12 | LL | #[codegen::eii3] diff --git a/tests/ui/enum-discriminant/discriminant_value.rs b/tests/ui/enum-discriminant/discriminant_value.rs index dc3d9cb83cca..0d6b9166c26a 100644 --- a/tests/ui/enum-discriminant/discriminant_value.rs +++ b/tests/ui/enum-discriminant/discriminant_value.rs @@ -1,5 +1,6 @@ //@ run-pass -#![feature(core_intrinsics)] +#![allow(stable_features)] +#![feature(core, core_intrinsics)] extern crate core; use core::intrinsics::discriminant_value; diff --git a/tests/ui/enum/assoc-fn-call-on-variant.rs b/tests/ui/enum/assoc-fn-call-on-variant.rs index c85d00eb0de8..0886e7dcd8d8 100644 --- a/tests/ui/enum/assoc-fn-call-on-variant.rs +++ b/tests/ui/enum/assoc-fn-call-on-variant.rs @@ -12,6 +12,5 @@ impl E { } fn main() { - E::A::f(); //~ ERROR cannot find module `A` in `E` - //~^ NOTE: `A` is a variant, not a module + E::A::f(); //~ ERROR failed to resolve: `A` is a variant, not a module } diff --git a/tests/ui/enum/assoc-fn-call-on-variant.stderr b/tests/ui/enum/assoc-fn-call-on-variant.stderr index ab7049e22f4b..ee75870ad394 100644 --- a/tests/ui/enum/assoc-fn-call-on-variant.stderr +++ b/tests/ui/enum/assoc-fn-call-on-variant.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module `A` in `E` +error[E0433]: failed to resolve: `A` is a variant, not a module --> $DIR/assoc-fn-call-on-variant.rs:15:8 | LL | E::A::f(); diff --git a/tests/ui/error-codes/E0010-teach.rs b/tests/ui/error-codes/E0010-teach.rs new file mode 100644 index 000000000000..0eef24783873 --- /dev/null +++ b/tests/ui/error-codes/E0010-teach.rs @@ -0,0 +1,7 @@ +//@ compile-flags: -Z teach + +#![allow(warnings)] + +const CON: Vec = vec![1, 2, 3]; //~ ERROR E0010 +//~| ERROR cannot call non-const method +fn main() {} diff --git a/tests/ui/error-codes/E0010-teach.stderr b/tests/ui/error-codes/E0010-teach.stderr new file mode 100644 index 000000000000..82bbe01aef79 --- /dev/null +++ b/tests/ui/error-codes/E0010-teach.stderr @@ -0,0 +1,22 @@ +error[E0010]: allocations are not allowed in constants + --> $DIR/E0010-teach.rs:5:23 + | +LL | const CON: Vec = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ allocation not allowed in constants + | + = note: The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created. + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const method `slice::::into_vec::` in constants + --> $DIR/E0010-teach.rs:5:23 + | +LL | const CON: Vec = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0010, E0015. +For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/error-codes/E0010.rs b/tests/ui/error-codes/E0010.rs new file mode 100644 index 000000000000..edb96714dd32 --- /dev/null +++ b/tests/ui/error-codes/E0010.rs @@ -0,0 +1,5 @@ +#![allow(warnings)] + +const CON: Vec = vec![1, 2, 3]; //~ ERROR E0010 +//~| ERROR cannot call non-const method +fn main() {} diff --git a/tests/ui/error-codes/E0010.stderr b/tests/ui/error-codes/E0010.stderr new file mode 100644 index 000000000000..87b722b5f656 --- /dev/null +++ b/tests/ui/error-codes/E0010.stderr @@ -0,0 +1,21 @@ +error[E0010]: allocations are not allowed in constants + --> $DIR/E0010.rs:3:23 + | +LL | const CON: Vec = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ allocation not allowed in constants + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const method `slice::::into_vec::` in constants + --> $DIR/E0010.rs:3:23 + | +LL | const CON: Vec = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0010, E0015. +For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/error-codes/E0017.stderr b/tests/ui/error-codes/E0017.stderr index 70186165d862..fcc57b9e5c3c 100644 --- a/tests/ui/error-codes/E0017.stderr +++ b/tests/ui/error-codes/E0017.stderr @@ -19,9 +19,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0596]: cannot borrow immutable static item `X` as mutable --> $DIR/E0017.rs:11:39 @@ -52,9 +52,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 3 previous errors; 2 warnings emitted diff --git a/tests/ui/error-codes/E0030-teach.stderr b/tests/ui/error-codes/E0030-teach.stderr index 81c9236b0037..50c7d1eee1f4 100644 --- a/tests/ui/error-codes/E0030-teach.stderr +++ b/tests/ui/error-codes/E0030-teach.stderr @@ -4,7 +4,7 @@ error[E0030]: lower bound for range pattern must be less than or equal to upper LL | 1000 ..= 5 => {} | ^^^^^^^^^^ lower bound larger than upper bound | - = note: when matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range + = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0116.stderr b/tests/ui/error-codes/E0116.stderr index 20e3b196226a..1ea5a57f46db 100644 --- a/tests/ui/error-codes/E0116.stderr +++ b/tests/ui/error-codes/E0116.stderr @@ -4,8 +4,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl Vec {} | ^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0184.rs b/tests/ui/error-codes/E0184.rs index 64cc1f0d1538..0c448e4ad8bc 100644 --- a/tests/ui/error-codes/E0184.rs +++ b/tests/ui/error-codes/E0184.rs @@ -1,5 +1,5 @@ -#[derive(Copy)] -struct Foo; //~ ERROR E0184 +#[derive(Copy)] //~ ERROR E0184 +struct Foo; impl Drop for Foo { fn drop(&mut self) { diff --git a/tests/ui/error-codes/E0184.stderr b/tests/ui/error-codes/E0184.stderr index 13294959bc3c..1a7df9ac095a 100644 --- a/tests/ui/error-codes/E0184.stderr +++ b/tests/ui/error-codes/E0184.stderr @@ -1,16 +1,8 @@ error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor - --> $DIR/E0184.rs:2:8 + --> $DIR/E0184.rs:1:10 | LL | #[derive(Copy)] - | ---- in this derive macro expansion -LL | struct Foo; - | ^^^ `Copy` not allowed on types with destructors - | -note: destructor declared here - --> $DIR/E0184.rs:5:5 - | -LL | fn drop(&mut self) { - | ^^^^^^^^^^^^^^^^^^ + | ^^^^ `Copy` not allowed on types with destructors error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0191.stderr b/tests/ui/error-codes/E0191.stderr index 6fbb20839777..63974fd6cbbb 100644 --- a/tests/ui/error-codes/E0191.stderr +++ b/tests/ui/error-codes/E0191.stderr @@ -5,7 +5,7 @@ LL | type Bar; | -------- `Bar` defined here ... LL | type Foo = dyn Trait; - | ^^^^^ help: specify the associated type: `Trait` + | ^^^^^ help: specify the associated type: `Trait` error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0220.stderr b/tests/ui/error-codes/E0220.stderr index 48197c9a8ccf..0e0b5c7084cc 100644 --- a/tests/ui/error-codes/E0220.stderr +++ b/tests/ui/error-codes/E0220.stderr @@ -11,7 +11,7 @@ LL | type Bar; | -------- `Bar` defined here ... LL | type Foo = dyn Trait; - | ^^^^^^^^^^^^ help: specify the associated type: `Trait` + | ^^^^^^^^^^^^ help: specify the associated type: `Trait` error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0264.rs b/tests/ui/error-codes/E0264.rs index 855644796ed4..6adaf01fb524 100644 --- a/tests/ui/error-codes/E0264.rs +++ b/tests/ui/error-codes/E0264.rs @@ -1,8 +1,8 @@ #![feature(lang_items)] extern "C" { - #[lang = "copy"] - fn copy(); //~ ERROR E0264 + #[lang = "cake"] + fn cake(); //~ ERROR E0264 } fn main() {} diff --git a/tests/ui/error-codes/E0264.stderr b/tests/ui/error-codes/E0264.stderr index 6442f42e689d..3503fb229e4f 100644 --- a/tests/ui/error-codes/E0264.stderr +++ b/tests/ui/error-codes/E0264.stderr @@ -1,7 +1,7 @@ -error[E0264]: unknown external lang item: `copy` +error[E0264]: unknown external lang item: `cake` --> $DIR/E0264.rs:5:5 | -LL | fn copy(); +LL | fn cake(); | ^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0393.stderr b/tests/ui/error-codes/E0393.stderr index a6991aa355fa..4847aa2508da 100644 --- a/tests/ui/error-codes/E0393.stderr +++ b/tests/ui/error-codes/E0393.stderr @@ -7,11 +7,11 @@ LL | LL | fn together_we_will_rule_the_galaxy(son: &dyn A) {} | ^ | - = note: because the parameter default references `Self`, the parameter must be specified on the trait object type -help: explicitly specify the type parameter + = note: because the parameter default references `Self`, the parameter must be specified on the object type +help: set the type parameter to the desired type | -LL | fn together_we_will_rule_the_galaxy(son: &dyn A) {} - | +++++++++ +LL | fn together_we_will_rule_the_galaxy(son: &dyn A) {} + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0433.stderr b/tests/ui/error-codes/E0433.stderr index e1e09045e0dc..1ac8c3ebc4d4 100644 --- a/tests/ui/error-codes/E0433.stderr +++ b/tests/ui/error-codes/E0433.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `NonExistingMap` in this scope +error[E0433]: failed to resolve: use of undeclared type `NonExistingMap` --> $DIR/E0433.rs:2:15 | LL | let map = NonExistingMap::new(); diff --git a/tests/ui/error-codes/E0492.stderr b/tests/ui/error-codes/E0492.stderr index a5057e8baedb..43a3a872e4e7 100644 --- a/tests/ui/error-codes/E0492.stderr +++ b/tests/ui/error-codes/E0492.stderr @@ -4,9 +4,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | const B: &'static AtomicUsize = &A; | ^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/E0492.rs:5:34 @@ -14,9 +14,9 @@ error[E0492]: interior mutable shared borrows of temporaries that have their lif LL | static C: &'static AtomicUsize = &A; | ^^ this borrow of an interior mutable value refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 2 previous errors diff --git a/tests/ui/error-emitter/multiline-removal-suggestion.svg b/tests/ui/error-emitter/multiline-removal-suggestion.svg index 39631e0e306d..1e8621388510 100644 --- a/tests/ui/error-emitter/multiline-removal-suggestion.svg +++ b/tests/ui/error-emitter/multiline-removal-suggestion.svg @@ -1,4 +1,4 @@ - +

{ impl

Trait

for () { const A: () = (); - //~^ ERROR constant `A` has 1 type parameter but its trait declaration has 0 type parameters + //~^ ERROR const `A` has 1 type parameter but its trait declaration has 0 type parameters const B: u64 = 0; - //~^ ERROR constant `B` has 1 const parameter but its trait declaration has 2 const parameters + //~^ ERROR const `B` has 1 const parameter but its trait declaration has 2 const parameters const C<'a>: &'a str = ""; - //~^ ERROR constant `C` has 0 type parameters but its trait declaration has 1 type parameter + //~^ ERROR const `C` has 0 type parameters but its trait declaration has 1 type parameter const D: u16 = N; - //~^ ERROR constant `D` has an incompatible generic parameter for trait `Trait` + //~^ ERROR const `D` has an incompatible generic parameter for trait `Trait` const E: &'static () = &(); - //~^ ERROR lifetime parameters or bounds on associated constant `E` do not match the trait declaration + //~^ ERROR lifetime parameters or bounds on associated const `E` do not match the trait declaration const F: usize = 1024 where diff --git a/tests/ui/generic-const-items/compare-impl-item.stderr b/tests/ui/generic-const-items/compare-impl-item.stderr index ffe65f9fc088..f7e3ff6501b1 100644 --- a/tests/ui/generic-const-items/compare-impl-item.stderr +++ b/tests/ui/generic-const-items/compare-impl-item.stderr @@ -1,4 +1,4 @@ -error[E0049]: associated constant `A` has 1 type parameter but its trait declaration has 0 type parameters +error[E0049]: associated const `A` has 1 type parameter but its trait declaration has 0 type parameters --> $DIR/compare-impl-item.rs:16:13 | LL | const A: (); @@ -7,7 +7,7 @@ LL | const A: (); LL | const A: () = (); | ^ found 1 type parameter -error[E0049]: associated constant `B` has 1 const parameter but its trait declaration has 2 const parameters +error[E0049]: associated const `B` has 1 const parameter but its trait declaration has 2 const parameters --> $DIR/compare-impl-item.rs:18:13 | LL | const B: u64; @@ -18,7 +18,7 @@ LL | const B: u64; LL | const B: u64 = 0; | ^^^^^^^^^^^^ found 1 const parameter -error[E0049]: associated constant `C` has 0 type parameters but its trait declaration has 1 type parameter +error[E0049]: associated const `C` has 0 type parameters but its trait declaration has 1 type parameter --> $DIR/compare-impl-item.rs:20:13 | LL | const C: T; @@ -27,7 +27,7 @@ LL | const C: T; LL | const C<'a>: &'a str = ""; | ^^ found 0 type parameters -error[E0053]: associated constant `D` has an incompatible generic parameter for trait `Trait` +error[E0053]: associated const `D` has an incompatible generic parameter for trait `Trait` --> $DIR/compare-impl-item.rs:22:13 | LL | trait Trait

{ @@ -42,14 +42,14 @@ LL | impl

Trait

: Supertrait {} -//~^ ERROR missing generics for trait `Supertrait` -//~| ERROR missing generics for trait `Supertrait` -//~| ERROR missing generics for trait `Supertrait` - -impl

Trait

for () {} - -const fn upcast

(x: &dyn Trait

) -> &dyn Trait

{ - x -} - -const fn foo() -> &'static dyn Supertrait<()> { - upcast::<()>(&()) -} - -const _: &'static dyn Supertrait<()> = foo(); - -fn main() {} diff --git a/tests/ui/traits/vtable/missing-generics-issue-151330.stderr b/tests/ui/traits/vtable/missing-generics-issue-151330.stderr deleted file mode 100644 index 65ef08cad32a..000000000000 --- a/tests/ui/traits/vtable/missing-generics-issue-151330.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0107]: missing generics for trait `Supertrait` - --> $DIR/missing-generics-issue-151330.rs:6:17 - | -LL | trait Trait

: Supertrait {} - | ^^^^^^^^^^ expected 1 generic argument - | -note: trait defined here, with 1 generic parameter: `T` - --> $DIR/missing-generics-issue-151330.rs:4:7 - | -LL | trait Supertrait {} - | ^^^^^^^^^^ - -help: add missing generic argument - | -LL | trait Trait

: Supertrait {} - | +++ - -error[E0107]: missing generics for trait `Supertrait` - --> $DIR/missing-generics-issue-151330.rs:6:17 - | -LL | trait Trait

: Supertrait {} - | ^^^^^^^^^^ expected 1 generic argument - | -note: trait defined here, with 1 generic parameter: `T` - --> $DIR/missing-generics-issue-151330.rs:4:7 - | -LL | trait Supertrait {} - | ^^^^^^^^^^ - - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing generic argument - | -LL | trait Trait

: Supertrait {} - | +++ - -error[E0107]: missing generics for trait `Supertrait` - --> $DIR/missing-generics-issue-151330.rs:6:17 - | -LL | trait Trait

: Supertrait {} - | ^^^^^^^^^^ expected 1 generic argument - | -note: trait defined here, with 1 generic parameter: `T` - --> $DIR/missing-generics-issue-151330.rs:4:7 - | -LL | trait Supertrait {} - | ^^^^^^^^^^ - - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing generic argument - | -LL | trait Trait

: Supertrait {} - | +++ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.rs b/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.rs index 35465183001a..ec6bb7bbcc59 100644 --- a/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.rs +++ b/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.rs @@ -5,8 +5,8 @@ // Issue #148892. //@ aux-crate:crate1=crate1.rs -struct MyStruct; //~ HELP the trait `crate1::Trait` is not implemented for `MyStruct` +struct MyStruct; //~ HELP the trait `Trait` is not implemented for `MyStruct` fn main() { - crate1::foo(MyStruct); //~ ERROR the trait bound `MyStruct: crate1::Trait` is not satisfied + crate1::foo(MyStruct); //~ ERROR the trait bound `MyStruct: Trait` is not satisfied } diff --git a/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.stderr b/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.stderr index 5bcda9f2a95b..7fec237f54d4 100644 --- a/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.stderr +++ b/tests/ui/traits/wrong-multiple-different-versions-of-a-crate.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `MyStruct: crate1::Trait` is not satisfied +error[E0277]: the trait bound `MyStruct: Trait` is not satisfied --> $DIR/wrong-multiple-different-versions-of-a-crate.rs:11:17 | LL | crate1::foo(MyStruct); @@ -6,7 +6,7 @@ LL | crate1::foo(MyStruct); | | | required by a bound introduced by this call | -help: the trait `crate1::Trait` is not implemented for `MyStruct` +help: the trait `Trait` is not implemented for `MyStruct` --> $DIR/wrong-multiple-different-versions-of-a-crate.rs:8:1 | LL | struct MyStruct; diff --git a/tests/ui/transmutability/transmute-with-type-params.rs b/tests/ui/transmutability/transmute-with-type-params.rs deleted file mode 100644 index f1630449a41b..000000000000 --- a/tests/ui/transmutability/transmute-with-type-params.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@ [next] compile-flags: -Znext-solver -//@ check-pass - -// A regression test for https://github.com/rust-lang/rust/issues/151300 - -#![feature(transmutability)] -use std::mem::TransmuteFrom; - -pub fn is_maybe_transmutable() -where - Dst: TransmuteFrom, -{ -} - -fn function_with_generic() { - is_maybe_transmutable::<(), ()>(); -} - -fn main() {} diff --git a/tests/ui/treat-err-as-bug/err.stderr b/tests/ui/treat-err-as-bug/err.stderr index 8ff267deacef..2a9935c5d22b 100644 --- a/tests/ui/treat-err-as-bug/err.stderr +++ b/tests/ui/treat-err-as-bug/err.stderr @@ -5,7 +5,7 @@ LL | pub static C: u32 = 0 - 1; | ^^^^^ evaluation of `C` failed here -error: the compiler unexpectedly panicked. This is a bug +error: the compiler unexpectedly panicked. this is a bug. query stack during panic: #0 [eval_static_initializer] evaluating initializer of static `C` diff --git a/tests/ui/treat-err-as-bug/span_delayed_bug.stderr b/tests/ui/treat-err-as-bug/span_delayed_bug.stderr index ae1bad55960e..88983e95cee7 100644 --- a/tests/ui/treat-err-as-bug/span_delayed_bug.stderr +++ b/tests/ui/treat-err-as-bug/span_delayed_bug.stderr @@ -5,7 +5,7 @@ LL | fn main() {} | ^^^^^^^^^ -error: the compiler unexpectedly panicked. This is a bug +error: the compiler unexpectedly panicked. this is a bug. query stack during panic: #0 [trigger_delayed_bug] triggering a delayed bug for testing incremental diff --git a/tests/ui/trimmed-paths/auxiliary/doc_hidden_helper.rs b/tests/ui/trimmed-paths/auxiliary/doc_hidden_helper.rs deleted file mode 100644 index 2e5e1591606e..000000000000 --- a/tests/ui/trimmed-paths/auxiliary/doc_hidden_helper.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ edition: 2024 - -pub struct ActuallyPub {} -#[doc(hidden)] -pub struct DocHidden {} - -pub mod pub_mod { - pub struct ActuallyPubInPubMod {} - #[doc(hidden)] - pub struct DocHiddenInPubMod {} -} - -#[doc(hidden)] -pub mod hidden_mod { - pub struct ActuallyPubInHiddenMod {} - #[doc(hidden)] - pub struct DocHiddenInHiddenMod {} -} diff --git a/tests/ui/trimmed-paths/core-unicode.rs b/tests/ui/trimmed-paths/core-unicode.rs deleted file mode 100644 index 4a3eeca62970..000000000000 --- a/tests/ui/trimmed-paths/core-unicode.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ edition: 2024 - -// Test that the `#[doc(hidden)]` module `core::unicode` module does not -// disqualify another item named `unicode` from path trimming in diagnostics. - -use core::marker::PhantomData; - -mod inner { - #[expect(non_camel_case_types)] - pub(crate) enum unicode {} -} - -fn main() { - let PhantomData::<(inner::unicode, u32)> = PhantomData::<(u32, inner::unicode)>; - //~^ ERROR mismatched types [E0308] - //~| NOTE expected `PhantomData<(u32, unicode)>`, found `PhantomData<(unicode, u32)>` - //~| NOTE this expression has type `PhantomData<(u32, unicode)>` - //~| NOTE expected struct `PhantomData<(u32, unicode)>` -} diff --git a/tests/ui/trimmed-paths/core-unicode.stderr b/tests/ui/trimmed-paths/core-unicode.stderr deleted file mode 100644 index 7351896b0b54..000000000000 --- a/tests/ui/trimmed-paths/core-unicode.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/core-unicode.rs:14:9 - | -LL | let PhantomData::<(inner::unicode, u32)> = PhantomData::<(u32, inner::unicode)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------------------------ this expression has type `PhantomData<(u32, unicode)>` - | | - | expected `PhantomData<(u32, unicode)>`, found `PhantomData<(unicode, u32)>` - | - = note: expected struct `PhantomData<(u32, unicode)>` - found struct `PhantomData<(unicode, u32)>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/trimmed-paths/doc-hidden.rs b/tests/ui/trimmed-paths/doc-hidden.rs deleted file mode 100644 index c3125385c7e4..000000000000 --- a/tests/ui/trimmed-paths/doc-hidden.rs +++ /dev/null @@ -1,68 +0,0 @@ -//@ edition: 2024 -//@ aux-crate: helper=doc_hidden_helper.rs - -// Test that `#[doc(hidden)]` items in other crates do not disqualify another -// item with the same name from path trimming in diagnostics. - -// Declare several modules and types whose short names match those in the aux crate. -// -// Of these, only `ActuallyPub` and `ActuallyPubInPubMod` should be disqualified -// from path trimming, because the other names only collide with `#[doc(hidden)]` -// names. -mod local { - pub(crate) struct ActuallyPub {} - pub(crate) struct DocHidden {} - - pub(crate) mod pub_mod { - pub(crate) struct ActuallyPubInPubMod {} - pub(crate) struct DocHiddenInPubMod {} - } - - pub(crate) mod hidden_mod { - pub(crate) struct ActuallyPubInHiddenMod {} - pub(crate) struct DocHiddenInHiddenMod {} - } -} - -fn main() { - uses_local(); - uses_helper(); -} - -fn uses_local() { - use local::{ActuallyPub, DocHidden}; - use local::pub_mod::{ActuallyPubInPubMod, DocHiddenInPubMod}; - use local::hidden_mod::{ActuallyPubInHiddenMod, DocHiddenInHiddenMod}; - - let _: ( - //~^ NOTE expected due to this - ActuallyPub, - DocHidden, - ActuallyPubInPubMod, - DocHiddenInPubMod, - ActuallyPubInHiddenMod, - DocHiddenInHiddenMod, - ) = 3u32; - //~^ ERROR mismatched types [E0308] - //~| NOTE expected `(ActuallyPub, ..., ..., ..., ..., ...)`, found `u32` - //~| NOTE expected tuple `(local::ActuallyPub, DocHidden, local::pub_mod::ActuallyPubInPubMod, DocHiddenInPubMod, ActuallyPubInHiddenMod, DocHiddenInHiddenMod)` -} - -fn uses_helper() { - use helper::{ActuallyPub, DocHidden}; - use helper::pub_mod::{ActuallyPubInPubMod, DocHiddenInPubMod}; - use helper::hidden_mod::{ActuallyPubInHiddenMod, DocHiddenInHiddenMod}; - - let _: ( - //~^ NOTE expected due to this - ActuallyPub, - DocHidden, - ActuallyPubInPubMod, - DocHiddenInPubMod, - ActuallyPubInHiddenMod, - DocHiddenInHiddenMod, - ) = 3u32; - //~^ ERROR mismatched types [E0308] - //~| NOTE expected `(ActuallyPub, ..., ..., ..., ..., ...)`, found `u32` - //~| NOTE expected tuple `(doc_hidden_helper::ActuallyPub, doc_hidden_helper::DocHidden, doc_hidden_helper::pub_mod::ActuallyPubInPubMod, doc_hidden_helper::pub_mod::DocHiddenInPubMod, doc_hidden_helper::hidden_mod::ActuallyPubInHiddenMod, doc_hidden_helper::hidden_mod::DocHiddenInHiddenMod)` -} diff --git a/tests/ui/trimmed-paths/doc-hidden.stderr b/tests/ui/trimmed-paths/doc-hidden.stderr deleted file mode 100644 index 167c92c50a35..000000000000 --- a/tests/ui/trimmed-paths/doc-hidden.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/doc-hidden.rs:45:9 - | -LL | let _: ( - | ____________- -LL | | -LL | | ActuallyPub, -LL | | DocHidden, -... | -LL | | DocHiddenInHiddenMod, -LL | | ) = 3u32; - | | - ^^^^ expected `(ActuallyPub, ..., ..., ..., ..., ...)`, found `u32` - | |_____| - | expected due to this - | - = note: expected tuple `(local::ActuallyPub, DocHidden, local::pub_mod::ActuallyPubInPubMod, DocHiddenInPubMod, ActuallyPubInHiddenMod, DocHiddenInHiddenMod)` - found type `u32` - -error[E0308]: mismatched types - --> $DIR/doc-hidden.rs:64:9 - | -LL | let _: ( - | ____________- -LL | | -LL | | ActuallyPub, -LL | | DocHidden, -... | -LL | | DocHiddenInHiddenMod, -LL | | ) = 3u32; - | | - ^^^^ expected `(ActuallyPub, ..., ..., ..., ..., ...)`, found `u32` - | |_____| - | expected due to this - | - = note: expected tuple `(doc_hidden_helper::ActuallyPub, doc_hidden_helper::DocHidden, doc_hidden_helper::pub_mod::ActuallyPubInPubMod, doc_hidden_helper::pub_mod::DocHiddenInPubMod, doc_hidden_helper::hidden_mod::ActuallyPubInHiddenMod, doc_hidden_helper::hidden_mod::DocHiddenInHiddenMod)` - found type `u32` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/try-block/try-block-homogeneous-pre-expansion.rs b/tests/ui/try-block/try-block-homogeneous-pre-expansion.rs deleted file mode 100644 index 980f97ca0672..000000000000 --- a/tests/ui/try-block/try-block-homogeneous-pre-expansion.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass -//@ edition: 2018 - -// For historical reasons this is only a warning, not an error. -// See - -fn main() { - #[cfg(false)] - try {} - //~^ warn `try` blocks are unstable - //~| warn unstable syntax can change at any point -} diff --git a/tests/ui/try-block/try-block-homogeneous-pre-expansion.stderr b/tests/ui/try-block/try-block-homogeneous-pre-expansion.stderr deleted file mode 100644 index dc92d7e64aff..000000000000 --- a/tests/ui/try-block/try-block-homogeneous-pre-expansion.stderr +++ /dev/null @@ -1,14 +0,0 @@ -warning: `try` blocks are unstable - --> $DIR/try-block-homogeneous-pre-expansion.rs:9:5 - | -LL | try {} - | ^^^^^^ - | - = note: see issue #31436 for more information - = help: add `#![feature(try_blocks)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = warning: unstable syntax can change at any point in the future, causing a hard error! - = note: for more information, see issue #65860 - -warning: 1 warning emitted - diff --git a/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr b/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr index 7fe151021976..71c7e460c399 100644 --- a/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr +++ b/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr @@ -22,6 +22,7 @@ LL | }; LL | println!("{}", x); | ^ value borrowed here after move | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | ::std::mem::drop(x.clone()); diff --git a/tests/ui/try-block/try-block-opt-init.stderr b/tests/ui/try-block/try-block-opt-init.stderr index b838af5d53b9..1679fc2ac18c 100644 --- a/tests/ui/try-block/try-block-opt-init.stderr +++ b/tests/ui/try-block/try-block-opt-init.stderr @@ -9,6 +9,8 @@ LL | cfg_res = 5; ... LL | assert_eq!(cfg_res, 5); | ^^^^^^^^^^^^^^^^^^^^^^ `cfg_res` used here but it is possibly-uninitialized + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index a566800da53e..f8c0deba99ba 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -22,7 +22,7 @@ help: the following other types implement trait `From` ::: $SRC_DIR/core/src/ascii/ascii_char.rs:LL:COL | = note: in this macro invocation - = note: this error originates in the macro `impl_from_bool` which comes from the expansion of the macro `into_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `impl_from` which comes from the expansion of the macro `into_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` --> $DIR/bad-interconversion.rs:9:12 diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr index bbc0b91cd503..7311f5882f75 100644 --- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr @@ -28,7 +28,7 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/implied_lifetime_wf_check3.rs:55:5 | LL | test_type_param::assert_static::() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | the parameter type `A` must be valid for the static lifetime... | ...so that the type `A` will meet its required lifetime bounds diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr index 710e4a5ce9e8..3cec4bbb0993 100644 --- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr @@ -21,7 +21,7 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/implied_lifetime_wf_check4_static.rs:15:5 | LL | assert_static::() - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | | | the parameter type `A` must be valid for the static lifetime... | ...so that the type `A` will meet its required lifetime bounds diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr index da2099c1ed27..a7135e8f05f4 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr @@ -35,6 +35,7 @@ note: this call may capture more lifetimes than intended, because Rust 2024 has | LL | let mut thing = test(&mut z); | ^^^^^^^^^^^^ + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { @@ -56,6 +57,7 @@ note: this call may capture more lifetimes than intended, because Rust 2024 has | LL | let mut thing = test(&mut z); | ^^^^^^^^^^^^ + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { @@ -77,6 +79,7 @@ note: this call may capture more lifetimes than intended, because Rust 2024 has | LL | let mut thing = test(&mut z); | ^^^^^^^^^^^^ + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { diff --git a/tests/ui/type-alias-impl-trait/issue-60662.stdout b/tests/ui/type-alias-impl-trait/issue-60662.stdout index dff748b43119..d1f337819f8b 100644 --- a/tests/ui/type-alias-impl-trait/issue-60662.stdout +++ b/tests/ui/type-alias-impl-trait/issue-60662.stdout @@ -4,7 +4,7 @@ #![feature(type_alias_impl_trait)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; trait Animal { } diff --git a/tests/ui/type-alias-impl-trait/nested.stderr b/tests/ui/type-alias-impl-trait/nested.stderr index 9ac0fe5302be..f72830b864d1 100644 --- a/tests/ui/type-alias-impl-trait/nested.stderr +++ b/tests/ui/type-alias-impl-trait/nested.stderr @@ -20,6 +20,7 @@ LL | println!("{:?}", bar()); | required by this formatting parameter | = help: the trait `Debug` is not implemented for `Bar` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs b/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs deleted file mode 100644 index 684f2498d584..000000000000 --- a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Znext-solver=globally -#![feature(type_alias_impl_trait)] - -type Foo = Vec; - -#[define_opaque(Foo)] -fn make_foo() -> Foo {} -//~^ ERROR type mismatch resolving - -fn main() {} diff --git a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr b/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr deleted file mode 100644 index dd73ed1a247c..000000000000 --- a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0271]: type mismatch resolving `Foo == ()` - --> $DIR/opaque-alias-relate-issue-151331.rs:7:18 - | -LL | fn make_foo() -> Foo {} - | ^^^ types differ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/type-alias/issue-62263-self-in-atb.rs b/tests/ui/type-alias/issue-62263-self-in-atb.rs index 0f8d88310bcd..91522d8912f7 100644 --- a/tests/ui/type-alias/issue-62263-self-in-atb.rs +++ b/tests/ui/type-alias/issue-62263-self-in-atb.rs @@ -3,6 +3,6 @@ pub trait Trait { } pub type Alias = dyn Trait; -//~^ ERROR cannot find `Self` +//~^ ERROR failed to resolve: `Self` fn main() {} diff --git a/tests/ui/type-alias/issue-62263-self-in-atb.stderr b/tests/ui/type-alias/issue-62263-self-in-atb.stderr index aa9e37ce71c7..18c8bc1a1b36 100644 --- a/tests/ui/type-alias/issue-62263-self-in-atb.stderr +++ b/tests/ui/type-alias/issue-62263-self-in-atb.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/issue-62263-self-in-atb.rs:5:32 | LL | pub type Alias = dyn Trait; diff --git a/tests/ui/type-alias/issue-62305-self-assoc-ty.rs b/tests/ui/type-alias/issue-62305-self-assoc-ty.rs index 47a6838c9100..a4d9a285485e 100644 --- a/tests/ui/type-alias/issue-62305-self-assoc-ty.rs +++ b/tests/ui/type-alias/issue-62305-self-assoc-ty.rs @@ -1,4 +1,4 @@ type Alias = Self::Target; -//~^ ERROR cannot find `Self` +//~^ ERROR failed to resolve: `Self` fn main() {} diff --git a/tests/ui/type-alias/issue-62305-self-assoc-ty.stderr b/tests/ui/type-alias/issue-62305-self-assoc-ty.stderr index 5bec48f007ca..a35e644d3aa8 100644 --- a/tests/ui/type-alias/issue-62305-self-assoc-ty.stderr +++ b/tests/ui/type-alias/issue-62305-self-assoc-ty.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/issue-62305-self-assoc-ty.rs:1:14 | LL | type Alias = Self::Target; diff --git a/tests/ui/type-alias/missing-associated-type-in-trait-object-22434.stderr b/tests/ui/type-alias/missing-associated-type-in-trait-object-22434.stderr index c198b83e9688..73afefa5a1fd 100644 --- a/tests/ui/type-alias/missing-associated-type-in-trait-object-22434.stderr +++ b/tests/ui/type-alias/missing-associated-type-in-trait-object-22434.stderr @@ -5,7 +5,7 @@ LL | type A; | ------ `A` defined here ... LL | type I<'a> = &'a (dyn Foo + 'a); - | ^^^ help: specify the associated type: `Foo` + | ^^^ help: specify the associated type: `Foo` error: aborting due to 1 previous error diff --git a/tests/ui/type/binding-assigned-block-without-tail-expression.stderr b/tests/ui/type/binding-assigned-block-without-tail-expression.stderr index ed7ff22e501c..ff34facf3892 100644 --- a/tests/ui/type/binding-assigned-block-without-tail-expression.stderr +++ b/tests/ui/type/binding-assigned-block-without-tail-expression.stderr @@ -11,6 +11,7 @@ LL | println!("{}", x); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/binding-assigned-block-without-tail-expression.rs:15:20 @@ -25,6 +26,7 @@ LL | println!("{}", y); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/binding-assigned-block-without-tail-expression.rs:16:20 @@ -39,6 +41,7 @@ LL | println!("{}", z); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/binding-assigned-block-without-tail-expression.rs:17:20 @@ -56,6 +59,7 @@ LL | println!("{}", s); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/binding-assigned-block-without-tail-expression.rs:18:18 diff --git a/tests/ui/type/pattern_types/derives_fail.stderr b/tests/ui/type/pattern_types/derives_fail.stderr index 45c9bae1f280..6b2e27494f0e 100644 --- a/tests/ui/type/pattern_types/derives_fail.stderr +++ b/tests/ui/type/pattern_types/derives_fail.stderr @@ -16,7 +16,7 @@ LL | #[repr(transparent)] LL | struct Nanoseconds(NanoI32); | ^^^^^^^ the trait `Eq` is not implemented for `(i32) is 0..=999999999` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL error[E0277]: `(i32) is 0..=999999999` doesn't implement `Debug` diff --git a/tests/ui/type/recover-from-semicolon-trailing-undefined.rs b/tests/ui/type/recover-from-semicolon-trailing-undefined.rs deleted file mode 100644 index 3e2860eb1343..000000000000 --- a/tests/ui/type/recover-from-semicolon-trailing-undefined.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ compile-flags: -Znext-solver=globally - -// Regression test for https://github.com/rust-lang/rust/issues/151610 - -fn main() { - let x_str = { - x!("{}", x); - //~^ ERROR cannot find macro `x` in this scope - }; - println!("{}", x_str); - //~^ ERROR `()` doesn't implement `std::fmt::Display` -} diff --git a/tests/ui/type/recover-from-semicolon-trailing-undefined.stderr b/tests/ui/type/recover-from-semicolon-trailing-undefined.stderr deleted file mode 100644 index 6a8295d49338..000000000000 --- a/tests/ui/type/recover-from-semicolon-trailing-undefined.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: cannot find macro `x` in this scope - --> $DIR/recover-from-semicolon-trailing-undefined.rs:7:9 - | -LL | x!("{}", x); - | ^ - -error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/recover-from-semicolon-trailing-undefined.rs:10:20 - | -LL | let x_str = { - | _________________- -LL | | x!("{}", x); -LL | | -LL | | }; - | |_____- this block is missing a tail expression -LL | println!("{}", x_str); - | -- ^^^^^ `()` cannot be formatted with the default formatter - | | - | required by this formatting parameter - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self.stderr b/tests/ui/type/type-parameter-defaults-referencing-Self.stderr index 300ad1998e42..23f10c9262c7 100644 --- a/tests/ui/type/type-parameter-defaults-referencing-Self.stderr +++ b/tests/ui/type/type-parameter-defaults-referencing-Self.stderr @@ -7,11 +7,11 @@ LL | trait Foo { LL | fn foo(x: &dyn Foo) { } | ^^^ | - = note: because the parameter default references `Self`, the parameter must be specified on the trait object type -help: explicitly specify the type parameter + = note: because the parameter default references `Self`, the parameter must be specified on the object type +help: set the type parameter to the desired type | -LL | fn foo(x: &dyn Foo) { } - | +++++++++ +LL | fn foo(x: &dyn Foo) { } + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/type/type-path-err-node-types.rs b/tests/ui/type/type-path-err-node-types.rs index a4ff4f497b47..b3795772e6fe 100644 --- a/tests/ui/type/type-path-err-node-types.rs +++ b/tests/ui/type/type-path-err-node-types.rs @@ -12,7 +12,7 @@ fn ufcs_trait() { } fn ufcs_item() { - NonExistent::Assoc::; //~ ERROR cannot find type `NonExistent` + NonExistent::Assoc::; //~ ERROR undeclared type `NonExistent` } fn method() { diff --git a/tests/ui/type/type-path-err-node-types.stderr b/tests/ui/type/type-path-err-node-types.stderr index d03d5d0b55c9..a9e999f80b3a 100644 --- a/tests/ui/type/type-path-err-node-types.stderr +++ b/tests/ui/type/type-path-err-node-types.stderr @@ -16,7 +16,7 @@ error[E0425]: cannot find value `nonexistent` in this scope LL | nonexistent.nonexistent::(); | ^^^^^^^^^^^ not found in this scope -error[E0433]: cannot find type `NonExistent` in this scope +error[E0433]: failed to resolve: use of undeclared type `NonExistent` --> $DIR/type-path-err-node-types.rs:15:5 | LL | NonExistent::Assoc::; diff --git a/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr b/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr index b4bf0e00cfe2..31acc5bb10ec 100644 --- a/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr +++ b/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr @@ -14,6 +14,8 @@ error[E0308]: mismatched types | LL | b"abc".iter().for_each(|x| dbg!(x)); | ^^^^^^^ expected `()`, found `&u8` + | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/closure-ty-mismatch-issue-128561.rs:8:9 diff --git a/tests/ui/typeck/issue-110017-format-into-help-deletes-macro.stderr b/tests/ui/typeck/issue-110017-format-into-help-deletes-macro.stderr index efd8d6e2686c..bc722cdd57a5 100644 --- a/tests/ui/typeck/issue-110017-format-into-help-deletes-macro.stderr +++ b/tests/ui/typeck/issue-110017-format-into-help-deletes-macro.stderr @@ -6,6 +6,7 @@ LL | Err(format!("error: {x}")) | = note: expected struct `Box` found struct `String` + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) help: call `Into::into` on this expression to convert `String` into `Box` | LL | Err(format!("error: {x}").into()) diff --git a/tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr b/tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr index cc5a4af88064..30d51420b7cb 100644 --- a/tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr +++ b/tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr @@ -12,6 +12,7 @@ LL | | } | = note: expected unit type `()` found enum `Result<(), std::fmt::Error>` + = note: this error originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider using a semicolon here | LL | }; diff --git a/tests/ui/typeck/issue-120856.rs b/tests/ui/typeck/issue-120856.rs index bd92adf529f8..51dd63a6f89d 100644 --- a/tests/ui/typeck/issue-120856.rs +++ b/tests/ui/typeck/issue-120856.rs @@ -1,7 +1,5 @@ pub type Archived = ::Archived; -//~^ ERROR: cannot find module or crate `m` in this scope -//~| ERROR: cannot find module or crate `n` in this scope -//~| NOTE: use of unresolved module or unlinked crate `m` -//~| NOTE: use of unresolved module or unlinked crate `n` +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `m` +//~| ERROR failed to resolve: use of unresolved module or unlinked crate `n` fn main() {} diff --git a/tests/ui/typeck/issue-120856.stderr b/tests/ui/typeck/issue-120856.stderr index 026c38da2959..4ff9f345c48b 100644 --- a/tests/ui/typeck/issue-120856.stderr +++ b/tests/ui/typeck/issue-120856.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `n` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `n` --> $DIR/issue-120856.rs:1:37 | LL | pub type Archived = ::Archived; @@ -10,7 +10,7 @@ help: a trait with a similar name exists LL | pub type Archived = ::Archived; | + -error[E0433]: cannot find module or crate `m` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `m` --> $DIR/issue-120856.rs:1:25 | LL | pub type Archived = ::Archived; diff --git a/tests/ui/typeck/issue-13853.rs b/tests/ui/typeck/issue-13853.rs index ac9886d2e724..ed44d5062614 100644 --- a/tests/ui/typeck/issue-13853.rs +++ b/tests/ui/typeck/issue-13853.rs @@ -25,7 +25,7 @@ impl Node for Stuff { fn iterate>(graph: &G) { for node in graph.iter() { //~ ERROR no method named `iter` found - node.zomg(); + node.zomg(); //~ ERROR type annotations needed } } diff --git a/tests/ui/typeck/issue-13853.stderr b/tests/ui/typeck/issue-13853.stderr index 45363c87d29d..4a39b404770d 100644 --- a/tests/ui/typeck/issue-13853.stderr +++ b/tests/ui/typeck/issue-13853.stderr @@ -17,6 +17,12 @@ error[E0599]: no method named `iter` found for reference `&G` in the current sco LL | for node in graph.iter() { | ^^^^ method not found in `&G` +error[E0282]: type annotations needed + --> $DIR/issue-13853.rs:28:9 + | +LL | node.zomg(); + | ^^^^ cannot infer type + error[E0308]: mismatched types --> $DIR/issue-13853.rs:37:13 | @@ -37,7 +43,7 @@ help: consider borrowing here LL | iterate(&graph); | + -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0308, E0599. -For more information about an error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0282, E0308, E0599. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.cargo-invoked.stderr b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.cargo-invoked.stderr index 8ff61b21ad1f..8a3b87b0d11a 100644 --- a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.cargo-invoked.stderr +++ b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.cargo-invoked.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `page_size` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `page_size` --> $DIR/path-to-method-sugg-unresolved-expr.rs:5:21 | LL | let page_size = page_size::get(); diff --git a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.only-rustc.stderr b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.only-rustc.stderr index 0cf3394cfedd..34ed5c44d931 100644 --- a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.only-rustc.stderr +++ b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.only-rustc.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `page_size` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `page_size` --> $DIR/path-to-method-sugg-unresolved-expr.rs:5:21 | LL | let page_size = page_size::get(); diff --git a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.rs b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.rs index 035e7afb30d9..e095850879cd 100644 --- a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.rs +++ b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.rs @@ -3,7 +3,7 @@ //@[cargo-invoked] rustc-env:CARGO_CRATE_NAME=foo fn main() { let page_size = page_size::get(); - //~^ ERROR cannot find module or crate `page_size` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `page_size` //~| NOTE use of unresolved module or unlinked crate `page_size` //[cargo-invoked]~^^^ HELP if you wanted to use a crate named `page_size`, use `cargo add //[only-rustc]~^^^^ HELP you might be missing a crate named `page_size` diff --git a/tests/ui/typeck/question-mark-operator-suggestion-span.stderr b/tests/ui/typeck/question-mark-operator-suggestion-span.stderr index f567e553d8b7..089b3bcd1988 100644 --- a/tests/ui/typeck/question-mark-operator-suggestion-span.stderr +++ b/tests/ui/typeck/question-mark-operator-suggestion-span.stderr @@ -12,6 +12,7 @@ LL | | } | = note: expected unit type `()` found enum `Result<(), std::fmt::Error>` + = note: this error originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider using a semicolon here | LL | }; diff --git a/tests/ui/typeck/sugg-swap-equality-in-macro-issue-139050.stderr b/tests/ui/typeck/sugg-swap-equality-in-macro-issue-139050.stderr index c217672b0050..d74372c665a4 100644 --- a/tests/ui/typeck/sugg-swap-equality-in-macro-issue-139050.stderr +++ b/tests/ui/typeck/sugg-swap-equality-in-macro-issue-139050.stderr @@ -2,12 +2,7 @@ error[E0425]: cannot find type `Item` in this scope --> $DIR/sugg-swap-equality-in-macro-issue-139050.rs:29:5 | LL | Item: Eq + Debug, - | ^^^^ - | -help: you might have meant to use an associated type of the same name - | -LL | I::Item: Eq + Debug, - | +++ + | ^^^^ not found in this scope error[E0308]: mismatched types --> $DIR/sugg-swap-equality-in-macro-issue-139050.rs:31:5 diff --git a/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.stderr b/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.stderr index 6785d48eca60..59e56f672374 100644 --- a/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.stderr +++ b/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.stderr @@ -26,6 +26,7 @@ error[E0308]: mismatched types LL | let c: S = dbg!(field); | ^^^^^^^^^^^ expected `S`, found `&S` | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider using clone here | LL | let c: S = dbg!(field).clone(); @@ -37,6 +38,7 @@ error[E0308]: mismatched types LL | let c: S = dbg!(dbg!(field)); | ^^^^^^^^^^^^^^^^^ expected `S`, found `&S` | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider using clone here | LL | let c: S = dbg!(dbg!(field)).clone(); diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 2772d55f953a..0b70ac97fd43 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -684,6 +684,13 @@ error[E0015]: cannot call non-const method ` as Iterator>:: LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^ | +note: method `filter` is not const because trait `Iterator` is not const + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this method is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::` in constants @@ -692,6 +699,13 @@ error[E0015]: cannot call non-const method `, {closu LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^ | +note: method `map` is not const because trait `Iterator` is not const + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this method is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 83 previous errors diff --git a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr index 6860b0b2f7ee..739182e120b4 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr @@ -7,7 +7,7 @@ LL | let mut closure0 = None; LL | return c(); | - type must be known at this point | -help: consider giving `closure0` an explicit type, where the type for type parameter `T` is specified +help: consider giving `closure0` an explicit type, where the placeholders `_` are specified | LL | let mut closure0: Option = None; | +++++++++++ diff --git a/tests/ui/imports/underscore-imports/auxiliary/duplicate.rs b/tests/ui/underscore-imports/auxiliary/duplicate.rs similarity index 100% rename from tests/ui/imports/underscore-imports/auxiliary/duplicate.rs rename to tests/ui/underscore-imports/auxiliary/duplicate.rs diff --git a/tests/ui/imports/underscore-imports/auxiliary/underscore-imports.rs b/tests/ui/underscore-imports/auxiliary/underscore-imports.rs similarity index 100% rename from tests/ui/imports/underscore-imports/auxiliary/underscore-imports.rs rename to tests/ui/underscore-imports/auxiliary/underscore-imports.rs diff --git a/tests/ui/imports/underscore-imports/basic.rs b/tests/ui/underscore-imports/basic.rs similarity index 100% rename from tests/ui/imports/underscore-imports/basic.rs rename to tests/ui/underscore-imports/basic.rs diff --git a/tests/ui/imports/underscore-imports/basic.stderr b/tests/ui/underscore-imports/basic.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/basic.stderr rename to tests/ui/underscore-imports/basic.stderr diff --git a/tests/ui/imports/underscore-imports/cycle.rs b/tests/ui/underscore-imports/cycle.rs similarity index 100% rename from tests/ui/imports/underscore-imports/cycle.rs rename to tests/ui/underscore-imports/cycle.rs diff --git a/tests/ui/imports/underscore-imports/duplicate.rs b/tests/ui/underscore-imports/duplicate.rs similarity index 100% rename from tests/ui/imports/underscore-imports/duplicate.rs rename to tests/ui/underscore-imports/duplicate.rs diff --git a/tests/ui/imports/underscore-imports/hygiene-2.rs b/tests/ui/underscore-imports/hygiene-2.rs similarity index 100% rename from tests/ui/imports/underscore-imports/hygiene-2.rs rename to tests/ui/underscore-imports/hygiene-2.rs diff --git a/tests/ui/imports/underscore-imports/hygiene.rs b/tests/ui/underscore-imports/hygiene.rs similarity index 100% rename from tests/ui/imports/underscore-imports/hygiene.rs rename to tests/ui/underscore-imports/hygiene.rs diff --git a/tests/ui/imports/underscore-imports/intercrate.rs b/tests/ui/underscore-imports/intercrate.rs similarity index 100% rename from tests/ui/imports/underscore-imports/intercrate.rs rename to tests/ui/underscore-imports/intercrate.rs diff --git a/tests/ui/imports/underscore-imports/invalid-path-110164.ed2015.stderr b/tests/ui/underscore-imports/issue-110164.ed2015.stderr similarity index 79% rename from tests/ui/imports/underscore-imports/invalid-path-110164.ed2015.stderr rename to tests/ui/underscore-imports/issue-110164.ed2015.stderr index e023ec58d1ad..f34b5ab5dde7 100644 --- a/tests/ui/imports/underscore-imports/invalid-path-110164.ed2015.stderr +++ b/tests/ui/underscore-imports/issue-110164.ed2015.stderr @@ -1,35 +1,35 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:8:5 + --> $DIR/issue-110164.rs:8:5 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:10:5 + --> $DIR/issue-110164.rs:10:5 | LL | use _::*; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:14:9 + --> $DIR/issue-110164.rs:14:9 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:16:9 + --> $DIR/issue-110164.rs:16:9 | LL | use _::*; | ^ expected identifier, found reserved identifier error[E0432]: unresolved import `self::*` - --> $DIR/invalid-path-110164.rs:4:5 + --> $DIR/issue-110164.rs:4:5 | LL | use self::*; | ^^^^^^^ cannot glob-import a module into itself error[E0432]: unresolved import `crate::*` - --> $DIR/invalid-path-110164.rs:6:5 + --> $DIR/issue-110164.rs:6:5 | LL | use crate::*; | ^^^^^^^^ cannot glob-import a module into itself diff --git a/tests/ui/imports/underscore-imports/invalid-path-110164.ed2021.stderr b/tests/ui/underscore-imports/issue-110164.ed2021.stderr similarity index 79% rename from tests/ui/imports/underscore-imports/invalid-path-110164.ed2021.stderr rename to tests/ui/underscore-imports/issue-110164.ed2021.stderr index e023ec58d1ad..f34b5ab5dde7 100644 --- a/tests/ui/imports/underscore-imports/invalid-path-110164.ed2021.stderr +++ b/tests/ui/underscore-imports/issue-110164.ed2021.stderr @@ -1,35 +1,35 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:8:5 + --> $DIR/issue-110164.rs:8:5 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:10:5 + --> $DIR/issue-110164.rs:10:5 | LL | use _::*; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:14:9 + --> $DIR/issue-110164.rs:14:9 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/invalid-path-110164.rs:16:9 + --> $DIR/issue-110164.rs:16:9 | LL | use _::*; | ^ expected identifier, found reserved identifier error[E0432]: unresolved import `self::*` - --> $DIR/invalid-path-110164.rs:4:5 + --> $DIR/issue-110164.rs:4:5 | LL | use self::*; | ^^^^^^^ cannot glob-import a module into itself error[E0432]: unresolved import `crate::*` - --> $DIR/invalid-path-110164.rs:6:5 + --> $DIR/issue-110164.rs:6:5 | LL | use crate::*; | ^^^^^^^^ cannot glob-import a module into itself diff --git a/tests/ui/imports/underscore-imports/invalid-path-110164.rs b/tests/ui/underscore-imports/issue-110164.rs similarity index 100% rename from tests/ui/imports/underscore-imports/invalid-path-110164.rs rename to tests/ui/underscore-imports/issue-110164.rs diff --git a/tests/ui/imports/underscore-imports/macro-expanded.rs b/tests/ui/underscore-imports/macro-expanded.rs similarity index 100% rename from tests/ui/imports/underscore-imports/macro-expanded.rs rename to tests/ui/underscore-imports/macro-expanded.rs diff --git a/tests/ui/imports/underscore-imports/multiple-uses.ed2015.stderr b/tests/ui/underscore-imports/multiple-uses.ed2015.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/multiple-uses.ed2015.stderr rename to tests/ui/underscore-imports/multiple-uses.ed2015.stderr diff --git a/tests/ui/imports/underscore-imports/multiple-uses.ed2021.stderr b/tests/ui/underscore-imports/multiple-uses.ed2021.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/multiple-uses.ed2021.stderr rename to tests/ui/underscore-imports/multiple-uses.ed2021.stderr diff --git a/tests/ui/imports/underscore-imports/multiple-uses.rs b/tests/ui/underscore-imports/multiple-uses.rs similarity index 100% rename from tests/ui/imports/underscore-imports/multiple-uses.rs rename to tests/ui/underscore-imports/multiple-uses.rs diff --git a/tests/ui/imports/underscore-imports/shadow.rs b/tests/ui/underscore-imports/shadow.rs similarity index 100% rename from tests/ui/imports/underscore-imports/shadow.rs rename to tests/ui/underscore-imports/shadow.rs diff --git a/tests/ui/imports/underscore-imports/shadow.stderr b/tests/ui/underscore-imports/shadow.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/shadow.stderr rename to tests/ui/underscore-imports/shadow.stderr diff --git a/tests/ui/imports/underscore-imports/unused-2018.rs b/tests/ui/underscore-imports/unused-2018.rs similarity index 100% rename from tests/ui/imports/underscore-imports/unused-2018.rs rename to tests/ui/underscore-imports/unused-2018.rs diff --git a/tests/ui/imports/underscore-imports/unused-2018.stderr b/tests/ui/underscore-imports/unused-2018.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/unused-2018.stderr rename to tests/ui/underscore-imports/unused-2018.stderr diff --git a/tests/ui/uninhabited/void-branch.stderr b/tests/ui/uninhabited/void-branch.stderr index 15693fc85f4b..ee5efb94ed21 100644 --- a/tests/ui/uninhabited/void-branch.stderr +++ b/tests/ui/uninhabited/void-branch.stderr @@ -16,6 +16,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable expression --> $DIR/void-branch.rs:25:9 @@ -30,6 +31,7 @@ note: this expression has type `Infallible`, which is uninhabited | LL | infallible(); | ^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/union/union-derive-clone.stderr b/tests/ui/union/union-derive-clone.stderr index 62ef35b76192..679ab6a38e49 100644 --- a/tests/ui/union/union-derive-clone.stderr +++ b/tests/ui/union/union-derive-clone.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `U1: Copy` is not satisfied LL | #[derive(Clone)] | ^^^^^ the trait `Copy` is not implemented for `U1` | -note: required by a bound in `std::clone::AssertParamIsCopy` +note: required by a bound in `AssertParamIsCopy` --> $SRC_DIR/core/src/clone.rs:LL:COL help: consider annotating `U1` with `#[derive(Copy)]` | @@ -25,13 +25,10 @@ LL | let w = u.clone(); | ^^^^^ method cannot be called on `U5` due to unsatisfied trait bounds | note: trait bound `CloneNoCopy: Copy` was not satisfied - --> $DIR/union-derive-clone.rs:26:10 + --> $DIR/union-derive-clone.rs:25:10 | LL | #[derive(Clone, Copy)] - | ----- in this derive macro expansion -LL | union U5 { - | ^ type parameter would need to implement `Clone` - = help: consider manually implementing the trait to avoid undesired bounds + | ^^^^^ unsatisfied trait bound introduced in this `derive` macro help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]` | LL + #[derive(Clone, Copy)] diff --git a/tests/ui/union/union-derive-eq.current.stderr b/tests/ui/union/union-derive-eq.current.stderr index df8e6db887bc..a0339687dad4 100644 --- a/tests/ui/union/union-derive-eq.current.stderr +++ b/tests/ui/union/union-derive-eq.current.stderr @@ -7,7 +7,7 @@ LL | union U2 { LL | a: PartialEqNotEq, | ^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `PartialEqNotEq` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` | diff --git a/tests/ui/union/union-derive-eq.next.stderr b/tests/ui/union/union-derive-eq.next.stderr index df8e6db887bc..a0339687dad4 100644 --- a/tests/ui/union/union-derive-eq.next.stderr +++ b/tests/ui/union/union-derive-eq.next.stderr @@ -7,7 +7,7 @@ LL | union U2 { LL | a: PartialEqNotEq, | ^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `PartialEqNotEq` | -note: required by a bound in `std::cmp::AssertParamIsEq` +note: required by a bound in `AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` | diff --git a/tests/ui/unpretty/bad-literal.stdout b/tests/ui/unpretty/bad-literal.stdout index 711f3a9bdf87..267d59a868e4 100644 --- a/tests/ui/unpretty/bad-literal.stdout +++ b/tests/ui/unpretty/bad-literal.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ check-fail diff --git a/tests/ui/unpretty/box.rs b/tests/ui/unpretty/box.rs new file mode 100644 index 000000000000..83fdeff7a179 --- /dev/null +++ b/tests/ui/unpretty/box.rs @@ -0,0 +1,8 @@ +//@ compile-flags: -Zunpretty=thir-tree +//@ check-pass + +#![feature(liballoc_internals)] + +fn main() { + let _ = std::boxed::box_new(1); +} diff --git a/tests/ui/unpretty/box.stdout b/tests/ui/unpretty/box.stdout new file mode 100644 index 000000000000..2576a2aa125d --- /dev/null +++ b/tests/ui/unpretty/box.stdout @@ -0,0 +1,90 @@ +DefId(0:3 ~ box[efb9]::main): +params: [ +] +body: + Expr { + ty: () + temp_scope_id: 11 + span: $DIR/box.rs:6:11: 8:2 (#0) + kind: + Scope { + region_scope: Node(11) + hir_id: HirId(DefId(0:3 ~ box[efb9]::main).11) + value: + Expr { + ty: () + temp_scope_id: 11 + span: $DIR/box.rs:6:11: 8:2 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/box.rs:6:11: 8:2 (#0) + region_scope: Node(1) + safety_mode: Safe + stmts: [ + Stmt { + kind: Let { + remainder_scope: Remainder { block: 1, first_statement_index: 0} + init_scope: Node(2) + pattern: + Pat { + ty: std::boxed::Box + span: $DIR/box.rs:7:9: 7:10 (#0) + kind: PatKind { + Wild + } + } + , + initializer: Some( + Expr { + ty: std::boxed::Box + temp_scope_id: 3 + span: $DIR/box.rs:7:13: 7:35 (#0) + kind: + Scope { + region_scope: Node(3) + hir_id: HirId(DefId(0:3 ~ box[efb9]::main).3) + value: + Expr { + ty: std::boxed::Box + temp_scope_id: 3 + span: $DIR/box.rs:7:13: 7:35 (#0) + kind: + Box { + Expr { + ty: i32 + temp_scope_id: 8 + span: $DIR/box.rs:7:33: 7:34 (#0) + kind: + Scope { + region_scope: Node(8) + hir_id: HirId(DefId(0:3 ~ box[efb9]::main).8) + value: + Expr { + ty: i32 + temp_scope_id: 8 + span: $DIR/box.rs:7:33: 7:34 (#0) + kind: + Literal( lit: Spanned { node: Int(Pu128(1), Unsuffixed), span: $DIR/box.rs:7:33: 7:34 (#0) }, neg: false) + + } + } + } + } + } + } + } + ) + else_block: None + hir_id: HirId(DefId(0:3 ~ box[efb9]::main).9) + span: $DIR/box.rs:7:5: 7:35 (#0) + } + } + ] + expr: [] + } + } + } + } + + diff --git a/tests/ui/unpretty/debug-fmt-hir.stdout b/tests/ui/unpretty/debug-fmt-hir.stdout index 1f0a6e2e334f..342dc144909c 100644 --- a/tests/ui/unpretty/debug-fmt-hir.stdout +++ b/tests/ui/unpretty/debug-fmt-hir.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ check-pass diff --git a/tests/ui/unpretty/deprecated-attr.stdout b/tests/ui/unpretty/deprecated-attr.stdout index 32d5cf06a3d6..32aac13586d5 100644 --- a/tests/ui/unpretty/deprecated-attr.stdout +++ b/tests/ui/unpretty/deprecated-attr.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ check-pass diff --git a/tests/ui/unpretty/diagnostic-attr.stdout b/tests/ui/unpretty/diagnostic-attr.stdout index 0b4b5f919343..25349681b02a 100644 --- a/tests/ui/unpretty/diagnostic-attr.stdout +++ b/tests/ui/unpretty/diagnostic-attr.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ check-pass diff --git a/tests/ui/unpretty/exhaustive-asm.hir.stdout b/tests/ui/unpretty/exhaustive-asm.hir.stdout index c44db0865396..ed98191e1dd5 100644 --- a/tests/ui/unpretty/exhaustive-asm.hir.stdout +++ b/tests/ui/unpretty/exhaustive-asm.hir.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use std::prelude::rust_2024::*; //@ revisions: expanded hir //@[expanded]compile-flags: -Zunpretty=expanded diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 7ee848491d6e..f309aa0b5fb6 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -31,7 +31,7 @@ #![feature(yeet_expr)] #![allow(incomplete_features)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use std::prelude::rust_2024::*; mod prelude { @@ -46,7 +46,7 @@ mod prelude { } } -#[attr = PreludeImport] +#[prelude_import] use self::prelude::*; /// inner single-line doc comment diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout index 008d69c9b9ef..156dcd68a674 100644 --- a/tests/ui/unpretty/flattened-format-args.stdout +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir -Zflatten-format-args=yes //@ check-pass diff --git a/tests/ui/unpretty/let-else-hir.stdout b/tests/ui/unpretty/let-else-hir.stdout index 73d627ef997a..cc19f392c3a4 100644 --- a/tests/ui/unpretty/let-else-hir.stdout +++ b/tests/ui/unpretty/let-else-hir.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ check-pass diff --git a/tests/ui/unpretty/self-hir.stdout b/tests/ui/unpretty/self-hir.stdout index b14c583f4f38..c973e143275c 100644 --- a/tests/ui/unpretty/self-hir.stdout +++ b/tests/ui/unpretty/self-hir.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ check-pass diff --git a/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout b/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout index c990837d2138..8b6ca4f672dc 100644 --- a/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout +++ b/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout @@ -5,7 +5,7 @@ #![expect(incomplete_features)] #![allow(dead_code)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; use std::marker::ConstParamTy; diff --git a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout index 19bfe92e3b27..41d62d11aaa6 100644 --- a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout @@ -9,7 +9,7 @@ //@ edition: 2015 #![allow(dead_code)] extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; fn main() ({ } as ()) diff --git a/tests/ui/unresolved/unresolved-candidates.stderr b/tests/ui/unresolved/unresolved-candidates.stderr index 7d8e894a5582..55b9d8ec6e8f 100644 --- a/tests/ui/unresolved/unresolved-candidates.stderr +++ b/tests/ui/unresolved/unresolved-candidates.stderr @@ -4,10 +4,8 @@ error[E0432]: unresolved import `Trait` LL | use Trait; | ^^^^^ no `Trait` in the root | -help: consider importing one of these items instead +help: consider importing this trait instead | -LL | use std::mem::type_info::Trait; - | +++++++++++++++++++++ LL | use a::Trait; | +++ diff --git a/tests/ui/unsized/issue-71659.current.stderr b/tests/ui/unsized/issue-71659.current.stderr index 22e43e07dbda..f7de668ba3a5 100644 --- a/tests/ui/unsized/issue-71659.current.stderr +++ b/tests/ui/unsized/issue-71659.current.stderr @@ -1,22 +1,18 @@ -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/issue-71659.rs:33:17 +error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied + --> $DIR/issue-71659.rs:34:15 | -LL | let x: &dyn Foo = &[]; - | ^^^ `Foo` is not dyn compatible +LL | let x = x.cast::<[i32]>(); + | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required by a bound in `Cast::cast` + --> $DIR/issue-71659.rs:23:15 | - = note: ...because it opted out of dyn-compatibility - | - ::: $DIR/issue-71659.rs:29:11 - | -LL | pub trait Foo: CastTo<[i32]> {} - | --- this trait is not dyn compatible... - = help: only type `[i32; 0]` implements `Foo` within this crate; consider using it directly instead. - = note: `Foo` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type +LL | fn cast(&self) -> &T + | ---- required by a bound in this associated function +LL | where +LL | Self: CastTo, + | ^^^^^^^^^ required by this bound in `Cast::cast` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-71659.next.stderr b/tests/ui/unsized/issue-71659.next.stderr index 22e43e07dbda..f7de668ba3a5 100644 --- a/tests/ui/unsized/issue-71659.next.stderr +++ b/tests/ui/unsized/issue-71659.next.stderr @@ -1,22 +1,18 @@ -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/issue-71659.rs:33:17 +error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied + --> $DIR/issue-71659.rs:34:15 | -LL | let x: &dyn Foo = &[]; - | ^^^ `Foo` is not dyn compatible +LL | let x = x.cast::<[i32]>(); + | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required by a bound in `Cast::cast` + --> $DIR/issue-71659.rs:23:15 | - = note: ...because it opted out of dyn-compatibility - | - ::: $DIR/issue-71659.rs:29:11 - | -LL | pub trait Foo: CastTo<[i32]> {} - | --- this trait is not dyn compatible... - = help: only type `[i32; 0]` implements `Foo` within this crate; consider using it directly instead. - = note: `Foo` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type +LL | fn cast(&self) -> &T + | ---- required by a bound in this associated function +LL | where +LL | Self: CastTo, + | ^^^^^^^^^ required by this bound in `Cast::cast` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-71659.rs b/tests/ui/unsized/issue-71659.rs index 9e1387fa8443..c463ed125bb6 100644 --- a/tests/ui/unsized/issue-71659.rs +++ b/tests/ui/unsized/issue-71659.rs @@ -31,6 +31,6 @@ impl Foo for [i32; 0] {} fn main() { let x: &dyn Foo = &[]; - //~^ ERROR: the trait `Foo` is not dyn compatible let x = x.cast::<[i32]>(); + //~^ ERROR: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied } diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr b/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr index e144b981f3cd..9f07e63e4544 100644 --- a/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr @@ -4,7 +4,7 @@ error: item annotated with `#[unstable_feature_bound]` should not be stable LL | fn bar() {} | ^^^^^^^^^^^ | - = help: if this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]` + = help: If this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]` error: aborting due to 1 previous error diff --git a/tests/ui/unstable-feature-bound/unstable_impl_coherence.disabled.stderr b/tests/ui/unstable-feature-bound/unstable_impl_coherence.disabled.stderr index 60bb2117df24..afef024e1b9c 100644 --- a/tests/ui/unstable-feature-bound/unstable_impl_coherence.disabled.stderr +++ b/tests/ui/unstable-feature-bound/unstable_impl_coherence.disabled.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `aux::Trait` for type `LocalTy` +error[E0119]: conflicting implementations of trait `Trait` for type `LocalTy` --> $DIR/unstable_impl_coherence.rs:14:1 | LL | impl aux::Trait for LocalTy {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `unstable_impl_coherence_aux`: - - impl aux::Trait for T + - impl Trait for T where feature(foo) is enabled; error: aborting due to 1 previous error diff --git a/tests/ui/unstable-feature-bound/unstable_impl_coherence.enabled.stderr b/tests/ui/unstable-feature-bound/unstable_impl_coherence.enabled.stderr index 60bb2117df24..afef024e1b9c 100644 --- a/tests/ui/unstable-feature-bound/unstable_impl_coherence.enabled.stderr +++ b/tests/ui/unstable-feature-bound/unstable_impl_coherence.enabled.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `aux::Trait` for type `LocalTy` +error[E0119]: conflicting implementations of trait `Trait` for type `LocalTy` --> $DIR/unstable_impl_coherence.rs:14:1 | LL | impl aux::Trait for LocalTy {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `unstable_impl_coherence_aux`: - - impl aux::Trait for T + - impl Trait for T where feature(foo) is enabled; error: aborting due to 1 previous error diff --git a/tests/ui/unstable-feature-bound/unstable_impl_coherence.rs b/tests/ui/unstable-feature-bound/unstable_impl_coherence.rs index c36316dc5fa1..22100f85f715 100644 --- a/tests/ui/unstable-feature-bound/unstable_impl_coherence.rs +++ b/tests/ui/unstable-feature-bound/unstable_impl_coherence.rs @@ -12,6 +12,6 @@ use aux::Trait; struct LocalTy; impl aux::Trait for LocalTy {} -//~^ ERROR: conflicting implementations of trait `aux::Trait` for type `LocalTy` +//~^ ERROR: conflicting implementations of trait `Trait` for type `LocalTy` fn main(){} diff --git a/tests/ui/unstable-feature-bound/unstable_impl_method_selection.stderr b/tests/ui/unstable-feature-bound/unstable_impl_method_selection.stderr index b2e4eb730d84..840af730154d 100644 --- a/tests/ui/unstable-feature-bound/unstable_impl_method_selection.stderr +++ b/tests/ui/unstable-feature-bound/unstable_impl_method_selection.stderr @@ -4,9 +4,9 @@ error[E0283]: type annotations needed LL | vec![].foo(); | ^^^ cannot infer type for struct `Vec<_>` | - = note: multiple `impl`s satisfying `Vec<_>: aux::Trait` found in the `unstable_impl_method_selection_aux` crate: - - impl aux::Trait for Vec; - - impl aux::Trait for Vec + = note: multiple `impl`s satisfying `Vec<_>: Trait` found in the `unstable_impl_method_selection_aux` crate: + - impl Trait for Vec; + - impl Trait for Vec where feature(bar) is enabled; error: aborting due to 1 previous error diff --git a/tests/ui/use/issue-18986.stderr b/tests/ui/use/issue-18986.stderr index 084fa80c3b6d..350cb18f9527 100644 --- a/tests/ui/use/issue-18986.stderr +++ b/tests/ui/use/issue-18986.stderr @@ -3,11 +3,6 @@ error[E0574]: expected struct, variant or union type, found trait `Trait` | LL | Trait { x: 42 } => () | ^^^^^ not a struct, variant or union type - | -help: consider importing this struct instead - | -LL + use std::mem::type_info::Trait; - | error: aborting due to 1 previous error diff --git a/tests/ui/use/use-after-move-based-on-type.stderr b/tests/ui/use/use-after-move-based-on-type.stderr index 1e72b3a1e95a..02a6ed599a92 100644 --- a/tests/ui/use/use-after-move-based-on-type.stderr +++ b/tests/ui/use/use-after-move-based-on-type.stderr @@ -8,6 +8,7 @@ LL | let _y = x; LL | println!("{}", x); | ^ value borrowed here after move | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | let _y = x.clone(); diff --git a/tests/ui/use/use-path-segment-kw.rs b/tests/ui/use/use-path-segment-kw.rs index fffc027ac6fd..680ecd3d03d4 100644 --- a/tests/ui/use/use-path-segment-kw.rs +++ b/tests/ui/use/use-path-segment-kw.rs @@ -9,43 +9,43 @@ macro_rules! macro_dollar_crate { use $crate; //~ ERROR `$crate` may not be imported pub use $crate as _dollar_crate; //~ ERROR `$crate` may not be imported - type A2 = ::$crate; //~ ERROR global paths cannot start with `$crate` + type A2 = ::$crate; //~ ERROR failed to resolve: global paths cannot start with `$crate` use ::$crate; //~ ERROR unresolved import `$crate` use ::$crate as _dollar_crate2; //~ ERROR unresolved import `$crate` use ::{$crate}; //~ ERROR unresolved import `$crate` use ::{$crate as _nested_dollar_crate2}; //~ ERROR unresolved import `$crate` - type A3 = foobar::$crate; //~ ERROR `$crate` in paths can only be used in start position + type A3 = foobar::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position use foobar::$crate; //~ ERROR unresolved import `foobar::$crate` use foobar::$crate as _dollar_crate3; //~ ERROR unresolved import `foobar::$crate` use foobar::{$crate}; //~ ERROR unresolved import `foobar::$crate` use foobar::{$crate as _nested_dollar_crate3}; //~ ERROR unresolved import `foobar::$crate` - type A4 = crate::$crate; //~ ERROR `$crate` in paths can only be used in start position + type A4 = crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position use crate::$crate; //~ ERROR unresolved import `crate::$crate` use crate::$crate as _dollar_crate4; //~ ERROR unresolved import `crate::$crate` use crate::{$crate}; //~ ERROR unresolved import `crate::$crate` use crate::{$crate as _nested_dollar_crate4}; //~ ERROR unresolved import `crate::$crate` - type A5 = super::$crate; //~ ERROR `$crate` in paths can only be used in start position + type A5 = super::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position use super::$crate; //~ ERROR unresolved import `super::$crate` use super::$crate as _dollar_crate5; //~ ERROR unresolved import `super::$crate` use super::{$crate}; //~ ERROR unresolved import `super::$crate` use super::{$crate as _nested_dollar_crate5}; //~ ERROR unresolved import `super::$crate` - type A6 = self::$crate; //~ ERROR `$crate` in paths can only be used in start position + type A6 = self::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position use self::$crate; use self::$crate as _dollar_crate6; use self::{$crate}; use self::{$crate as _nested_dollar_crate6}; - type A7 = $crate::$crate; //~ ERROR `$crate` in paths can only be used in start position + type A7 = $crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position use $crate::$crate; //~ ERROR unresolved import `$crate::$crate` use $crate::$crate as _dollar_crate7; //~ ERROR unresolved import `$crate::$crate` use $crate::{$crate}; //~ ERROR unresolved import `$crate::$crate` use $crate::{$crate as _nested_dollar_crate7}; //~ ERROR unresolved import `$crate::$crate` - type A8 = $crate::crate; //~ ERROR `crate` in paths can only be used in start position + type A8 = $crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position use $crate::crate; //~ ERROR unresolved import `$crate::crate` //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use $crate::crate as _m_crate8; //~ ERROR unresolved import `$crate::crate` @@ -53,13 +53,13 @@ macro_rules! macro_dollar_crate { //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use $crate::{crate as _m_nested_crate8}; //~ ERROR unresolved import `$crate::crate` - type A9 = $crate::super; //~ ERROR `super` in paths can only be used in start position + type A9 = $crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position use $crate::super; //~ ERROR unresolved import `$crate::super` use $crate::super as _m_super8; //~ ERROR unresolved import `$crate::super` use $crate::{super}; //~ ERROR unresolved import `$crate::super` use $crate::{super as _m_nested_super8}; //~ ERROR unresolved import `$crate::super` - type A10 = $crate::self; //~ ERROR `self` in paths can only be used in start position + type A10 = $crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position use $crate::self; //~ ERROR `$crate` may not be imported //~^ ERROR `self` imports are only allowed within a { } list //~^^ ERROR the name `` is defined multiple times @@ -98,7 +98,7 @@ mod foo { use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` pub use crate as _crate; // Good - type B2 = ::crate; //~ ERROR `crate` + type B2 = ::crate; //~ ERROR failed to resolve: global paths cannot start with `crate` use ::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` //~^ ERROR unresolved import `crate` use ::crate as _crate2; //~ ERROR unresolved import `crate` @@ -106,7 +106,7 @@ mod foo { //~^ ERROR unresolved import `crate` use ::{crate as _nested_crate2}; //~ ERROR unresolved import `crate` - type B3 = foobar::crate; //~ ERROR `crate` in paths can only be used in start position + type B3 = foobar::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position use foobar::crate; //~ ERROR unresolved import `foobar::crate` //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use foobar::crate as _crate3; //~ ERROR unresolved import `foobar::crate` @@ -114,7 +114,7 @@ mod foo { //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use foobar::{crate as _nested_crate3}; //~ ERROR unresolved import `foobar::crate` - type B4 = crate::crate; //~ ERROR `crate` in paths can only be used in start position + type B4 = crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position use crate::crate; //~ ERROR unresolved import `crate::crate` //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use crate::crate as _crate4; //~ ERROR unresolved import `crate::crate` @@ -122,7 +122,7 @@ mod foo { //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use crate::{crate as _nested_crate4}; //~ ERROR unresolved import `crate::crate` - type B5 = super::crate; //~ ERROR `crate` in paths can only be used in start position + type B5 = super::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position use super::crate; //~ ERROR unresolved import `super::crate` //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use super::crate as _crate5; //~ ERROR unresolved import `super::crate` @@ -130,7 +130,7 @@ mod foo { //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` use super::{crate as _nested_crate5}; //~ ERROR unresolved import `super::crate` - type B6 = self::crate; //~ ERROR `crate` in paths can only be used in start position + type B6 = self::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position use self::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` //~^ ERROR the name `crate` is defined multiple times use self::crate as _crate6; @@ -146,19 +146,19 @@ mod foo { use super; //~ ERROR unresolved import `super` pub use super as _super; //~ ERROR unresolved import `super` - type C2 = ::super; //~ ERROR global paths cannot start with `super` + type C2 = ::super; //~ ERROR failed to resolve: global paths cannot start with `super` use ::super; //~ ERROR unresolved import `super` use ::super as _super2; //~ ERROR unresolved import `super` use ::{super}; //~ ERROR unresolved import `super` use ::{super as _nested_super2}; //~ ERROR unresolved import `super` - type C3 = foobar::super; //~ ERROR `super` in paths can only be used in start position + type C3 = foobar::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position use foobar::super; //~ ERROR unresolved import `foobar::super` use foobar::super as _super3; //~ ERROR unresolved import `foobar::super` use foobar::{super}; //~ ERROR unresolved import `foobar::super` use foobar::{super as _nested_super3}; //~ ERROR unresolved import `foobar::super` - type C4 = crate::super; //~ ERROR `super` in paths can only be used in start position + type C4 = crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position use crate::super; //~ ERROR unresolved import `crate::super` use crate::super as _super4; //~ ERROR unresolved import `crate::super` use crate::{super}; //~ ERROR unresolved import `crate::super` @@ -184,7 +184,7 @@ mod foo { use self; //~ ERROR `self` imports are only allowed within a { } list pub use self as _self; //~ ERROR `self` imports are only allowed within a { } list - type D2 = ::self; //~ ERROR global paths cannot start with `self` + type D2 = ::self; //~ ERROR failed to resolve: global paths cannot start with `self` use ::self; //~ ERROR `self` imports are only allowed within a { } list //~^ ERROR unresolved import `{{root}}` use ::self as _self2; //~ ERROR `self` imports are only allowed within a { } list @@ -192,13 +192,13 @@ mod foo { use ::{self}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix use ::{self as _nested_self2}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix - type D3 = foobar::self; //~ ERROR `self` in paths can only be used in start position + type D3 = foobar::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position pub use foobar::qux::self; //~ ERROR `self` imports are only allowed within a { } list pub use foobar::self as _self3; //~ ERROR `self` imports are only allowed within a { } list pub use foobar::baz::{self}; // Good pub use foobar::{self as _nested_self3}; // Good - type D4 = crate::self; //~ ERROR `self` in paths can only be used in start position + type D4 = crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position use crate::self; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` //~^ ERROR `self` imports are only allowed within a { } list //~^^ ERROR the name `crate` is defined multiple times @@ -207,7 +207,7 @@ mod foo { //~^ ERROR the name `crate` is defined multiple times pub use crate::{self as _nested_self4}; // Good - type D5 = super::self; //~ ERROR `self` in paths can only be used in start position + type D5 = super::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position use super::self; //~ ERROR unresolved import `super` //~^ ERROR `self` imports are only allowed within a { } list pub use super::self as _self5; //~ ERROR `self` imports are only allowed within a { } list @@ -215,7 +215,7 @@ mod foo { use super::{self}; //~ ERROR unresolved import `super` pub use super::{self as _nested_self5}; //~ ERROR unresolved import `super` - type D6 = self::self; //~ ERROR `self` in paths can only be used in start position + type D6 = self::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position use self::self; //~ ERROR `self` imports are only allowed within a { } list pub use self::self as _self6; //~ ERROR `self` imports are only allowed within a { } list use self::{self}; //~ ERROR unresolved import `self` diff --git a/tests/ui/use/use-path-segment-kw.stderr b/tests/ui/use/use-path-segment-kw.stderr index a5cfa47df3b2..407e99059b2a 100644 --- a/tests/ui/use/use-path-segment-kw.stderr +++ b/tests/ui/use/use-path-segment-kw.stderr @@ -1062,182 +1062,182 @@ error[E0573]: expected type, found module `self` LL | type D1 = self; | ^^^^ not a type -error[E0433]: global paths cannot start with `$crate` +error[E0433]: failed to resolve: global paths cannot start with `$crate` --> $DIR/use-path-segment-kw.rs:12:21 | LL | type A2 = ::$crate; - | ^^^^^^ cannot start with this + | ^^^^^^ global paths cannot start with `$crate` ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:18:27 | LL | type A3 = foobar::$crate; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:24:26 | LL | type A4 = crate::$crate; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:30:26 | LL | type A5 = super::$crate; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:36:25 | LL | type A6 = self::$crate; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:42:27 | LL | type A7 = $crate::$crate; - | ^^^^^^ can only be used in path start position + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:48:27 | LL | type A8 = $crate::crate; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `super` in paths can only be used in start position +error[E0433]: failed to resolve: `super` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:56:27 | LL | type A9 = $crate::super; - | ^^^^^ can only be used in path start position + | ^^^^^ `super` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: `self` in paths can only be used in start position +error[E0433]: failed to resolve: `self` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:62:28 | LL | type A10 = $crate::self; - | ^^^^ can only be used in path start position + | ^^^^ `self` in paths can only be used in start position ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: global paths cannot start with `crate` +error[E0433]: failed to resolve: global paths cannot start with `crate` --> $DIR/use-path-segment-kw.rs:101:21 | LL | type B2 = ::crate; - | ^^^^^ cannot start with this + | ^^^^^ global paths cannot start with `crate` -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:109:27 | LL | type B3 = foobar::crate; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:117:26 | LL | type B4 = crate::crate; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:125:26 | LL | type B5 = super::crate; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:133:25 | LL | type B6 = self::crate; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position -error[E0433]: global paths cannot start with `super` +error[E0433]: failed to resolve: global paths cannot start with `super` --> $DIR/use-path-segment-kw.rs:149:21 | LL | type C2 = ::super; - | ^^^^^ cannot start with this + | ^^^^^ global paths cannot start with `super` -error[E0433]: `super` in paths can only be used in start position +error[E0433]: failed to resolve: `super` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:155:27 | LL | type C3 = foobar::super; - | ^^^^^ can only be used in path start position + | ^^^^^ `super` in paths can only be used in start position -error[E0433]: `super` in paths can only be used in start position +error[E0433]: failed to resolve: `super` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:161:26 | LL | type C4 = crate::super; - | ^^^^^ can only be used in path start position + | ^^^^^ `super` in paths can only be used in start position -error[E0433]: global paths cannot start with `self` +error[E0433]: failed to resolve: global paths cannot start with `self` --> $DIR/use-path-segment-kw.rs:187:21 | LL | type D2 = ::self; - | ^^^^ cannot start with this + | ^^^^ global paths cannot start with `self` -error[E0433]: `self` in paths can only be used in start position +error[E0433]: failed to resolve: `self` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:195:27 | LL | type D3 = foobar::self; - | ^^^^ can only be used in path start position + | ^^^^ `self` in paths can only be used in start position -error[E0433]: `self` in paths can only be used in start position +error[E0433]: failed to resolve: `self` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:201:26 | LL | type D4 = crate::self; - | ^^^^ can only be used in path start position + | ^^^^ `self` in paths can only be used in start position -error[E0433]: `self` in paths can only be used in start position +error[E0433]: failed to resolve: `self` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:210:26 | LL | type D5 = super::self; - | ^^^^ can only be used in path start position + | ^^^^ `self` in paths can only be used in start position -error[E0433]: `self` in paths can only be used in start position +error[E0433]: failed to resolve: `self` in paths can only be used in start position --> $DIR/use-path-segment-kw.rs:218:25 | LL | type D6 = self::self; - | ^^^^ can only be used in path start position + | ^^^^ `self` in paths can only be used in start position error: aborting due to 141 previous errors diff --git a/tests/ui/use/use-self-type.rs b/tests/ui/use/use-self-type.rs index 4453049acff0..3b4ce4297019 100644 --- a/tests/ui/use/use-self-type.rs +++ b/tests/ui/use/use-self-type.rs @@ -4,7 +4,7 @@ impl S { fn f() {} fn g() { use Self::f; //~ ERROR unresolved import - pub(in Self::f) struct Z; //~ ERROR cannot find `Self` + pub(in Self::f) struct Z; //~ ERROR failed to resolve: `Self` } } diff --git a/tests/ui/use/use-self-type.stderr b/tests/ui/use/use-self-type.stderr index 086b7a4d8222..498df34fe325 100644 --- a/tests/ui/use/use-self-type.stderr +++ b/tests/ui/use/use-self-type.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` cannot be used in imports --> $DIR/use-self-type.rs:7:16 | LL | pub(in Self::f) struct Z; diff --git a/tests/ui/use/use-super-global-path.rs b/tests/ui/use/use-super-global-path.rs index d00c6964dea1..64bfd14b7e7d 100644 --- a/tests/ui/use/use-super-global-path.rs +++ b/tests/ui/use/use-super-global-path.rs @@ -4,12 +4,11 @@ struct S; struct Z; mod foo { - use ::super::{S, Z}; - //~^ ERROR: global paths cannot start with `super` - //~| ERROR: global paths cannot start with `super` + use ::super::{S, Z}; //~ ERROR global paths cannot start with `super` + //~| ERROR global paths cannot start with `super` pub fn g() { - use ::super::main; //~ ERROR: global paths cannot start with `super` + use ::super::main; //~ ERROR global paths cannot start with `super` main(); } } diff --git a/tests/ui/use/use-super-global-path.stderr b/tests/ui/use/use-super-global-path.stderr index dd853aab4830..00d172f4799a 100644 --- a/tests/ui/use/use-super-global-path.stderr +++ b/tests/ui/use/use-super-global-path.stderr @@ -1,22 +1,22 @@ -error[E0433]: global paths cannot start with `super` +error[E0433]: failed to resolve: global paths cannot start with `super` --> $DIR/use-super-global-path.rs:7:11 | LL | use ::super::{S, Z}; - | ^^^^^ cannot start with this + | ^^^^^ global paths cannot start with `super` -error[E0433]: global paths cannot start with `super` +error[E0433]: failed to resolve: global paths cannot start with `super` --> $DIR/use-super-global-path.rs:7:11 | LL | use ::super::{S, Z}; - | ^^^^^ cannot start with this + | ^^^^^ global paths cannot start with `super` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0433]: global paths cannot start with `super` - --> $DIR/use-super-global-path.rs:12:15 +error[E0433]: failed to resolve: global paths cannot start with `super` + --> $DIR/use-super-global-path.rs:11:15 | LL | use ::super::main; - | ^^^^^ cannot start with this + | ^^^^^ global paths cannot start with `super` error: aborting due to 3 previous errors diff --git a/tests/ui/use/use.rs b/tests/ui/use/use.rs index c6b6724ef7c1..25b8e529c432 100644 --- a/tests/ui/use/use.rs +++ b/tests/ui/use/use.rs @@ -1,7 +1,9 @@ //@ run-pass +#![allow(stable_features)] + #![allow(unused_imports)] -#![feature(no_core)] +#![feature(no_core, core)] #![no_core] extern crate std; diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs index 13d7a800c51f..f2b9f037ea5f 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs @@ -4,13 +4,11 @@ trait Foo> { //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| ERROR cycle detected when computing type of `Foo::N` - //~| ERROR `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter fn func() {} } trait Bar> {} //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! -//~| ERROR `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index f9a855d3b93b..4024f57af4ff 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -13,7 +13,7 @@ LL | trait Foo> { | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:20 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:10:20 | LL | trait Bar> {} | ^^^^^^ @@ -32,7 +32,7 @@ LL | trait Foo> { | ^^^^^^^^^^^^^^^ | note: ...which requires computing type of `Bar::M`... - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:11 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:10:11 | LL | trait Bar> {} | ^^^^^^^^^^^^^^^ @@ -44,22 +44,6 @@ LL | trait Foo> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:3:20 - | -LL | trait Foo> { - | ^^^^^^ - | - = note: the only supported types are integers, `bool`, and `char` - -error: `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:20 - | -LL | trait Bar> {} - | ^^^^^^ - | - = note: the only supported types are integers, `bool`, and `char` - -error: aborting due to 3 previous errors; 2 warnings emitted +error: aborting due to 1 previous error; 2 warnings emitted For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/wf/issue-87495.stderr b/tests/ui/wf/issue-87495.stderr index 49651e8d6c05..bf79535df116 100644 --- a/tests/ui/wf/issue-87495.stderr +++ b/tests/ui/wf/issue-87495.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `T` is not dyn compatible - --> $DIR/issue-87495.rs:4:29 + --> $DIR/issue-87495.rs:4:25 | LL | const CONST: (bool, dyn T); - | ^ `T` is not dyn compatible + | ^^^^^ `T` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit @@ -11,8 +11,13 @@ note: for a trait to be dyn compatible it needs to allow building a vtable LL | trait T { | - this trait is not dyn compatible... LL | const CONST: (bool, dyn T); - | ^^^^^ ...because it contains associated const `CONST` + | ^^^^^ ...because it contains this associated `const` = help: consider moving `CONST` to another trait +help: you might have meant to use `Self` to refer to the implementing type + | +LL - const CONST: (bool, dyn T); +LL + const CONST: (bool, Self); + | error: aborting due to 1 previous error diff --git a/tests/ui/where-clauses/unsupported_attribute.stderr b/tests/ui/where-clauses/unsupported_attribute.stderr index e69eff976c3f..9ebc14c40a14 100644 --- a/tests/ui/where-clauses/unsupported_attribute.stderr +++ b/tests/ui/where-clauses/unsupported_attribute.stderr @@ -64,7 +64,7 @@ error: `#[deprecated]` attribute cannot be used on where predicates LL | #[deprecated] T: Trait, | ^^^^^^^^^^^^^ | - = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements error: `#[deprecated]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:25:5 @@ -72,7 +72,7 @@ error: `#[deprecated]` attribute cannot be used on where predicates LL | #[deprecated] 'a: 'static, | ^^^^^^^^^^^^^ | - = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements error: `#[automatically_derived]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:26:5 diff --git a/triagebot.toml b/triagebot.toml index 6c6daac9cf3b..e51622f1e5a9 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -76,9 +76,9 @@ add-labels = ["beta-nominated"] [ping.windows] message = """\ -Hey Windows Group! This issue has been identified as a good "Windows candidate". +Hey Windows Group! This bug has been identified as a good "Windows candidate". In case it's useful, here are some [instructions] for tackling these sorts of -issues. Maybe take a look? +bugs. Maybe take a look? Thanks! <3 [instructions]: https://rustc-dev-guide.rust-lang.org/notification-groups/windows.html @@ -87,9 +87,9 @@ label = "O-windows" [ping.arm] message = """\ -Hey ARM Group! This issue has been identified as a good "ARM candidate". +Hey ARM Group! This bug has been identified as a good "ARM candidate". In case it's useful, here are some [instructions] for tackling these sorts of -issues. Maybe take a look? +bugs. Maybe take a look? Thanks! <3 [instructions]: https://rustc-dev-guide.rust-lang.org/notification-groups/arm.html @@ -98,9 +98,9 @@ label = "O-ARM" [ping.loongarch] message = """\ -Hey LoongArch Group! This issue has been identified as a good "LoongArch candidate". +Hey LoongArch Group! This bug has been identified as a good "LoongArch candidate". In case it's useful, here are some [instructions] for tackling these sorts of -issues. Maybe take a look? +bugs. Maybe take a look? Thanks! <3 [instructions]: https://rustc-dev-guide.rust-lang.org/notification-groups/loongarch.html @@ -109,9 +109,9 @@ label = "O-loongarch" [ping.risc-v] message = """\ -Hey RISC-V Group! This issue has been identified as a good "RISC-V candidate". +Hey RISC-V Group! This bug has been identified as a good "RISC-V candidate". In case it's useful, here are some [instructions] for tackling these sorts of -issues. Maybe take a look? +bugs. Maybe take a look? Thanks! <3 [instructions]: https://rustc-dev-guide.rust-lang.org/notification-groups/risc-v.html @@ -499,7 +499,6 @@ trigger_files = [ "bootstrap.example.toml", "src/bootstrap", "src/build_helper", - "src/tools/build-manifest", "src/tools/rust-installer", "src/tools/x", "src/stage0", @@ -540,6 +539,7 @@ trigger_files = [ [autolabel."A-query-system"] trigger_files = [ + "compiler/rustc_query_system", "compiler/rustc_query_impl", "compiler/rustc_macros/src/query.rs" ] @@ -794,8 +794,7 @@ zulip_stream = 474880 # #t-compiler/backports topic = "#{number}: stable-nominated" message_on_add = [ """\ -PR #{number} "{title}" fixes a regression and has been nominated for backport. -{recipients}, what do you think about it? +@**channel** PR #{number} "{title}" has been nominated for stable backport. """, """\ /poll Approve stable backport of #{number}? @@ -1182,11 +1181,11 @@ cc = ["@Muscraft"] [mentions."compiler/rustc_errors/src/translation.rs"] message = "`rustc_errors::translation` was changed" -cc = ["@davidtwco", "@TaKO8Ki", "@JonathanBrouwer"] +cc = ["@davidtwco", "@TaKO8Ki"] [mentions."compiler/rustc_macros/src/diagnostics"] message = "`rustc_macros::diagnostics` was changed" -cc = ["@davidtwco", "@TaKO8Ki", "@JonathanBrouwer"] +cc = ["@davidtwco", "@TaKO8Ki"] [mentions."compiler/rustc_public"] message = "This PR changes rustc_public" @@ -1448,6 +1447,27 @@ compiler_leads = [ "@davidtwco", "@wesleywiser", ] +compiler = [ + "@BoxyUwU", + "@chenyukang", + "@davidtwco", + "@eholk", + "@fee1-dead", + "@fmease", + "@jackh726", + "@jieyouxu", + "@jdonszelmann", + "@JonathanBrouwer", + "@madsmtm", + "@mati865", + "@Nadrieril", + "@nnethercote", + "@oli-obk", + "@petrochenkov", + "@SparrowLii", + "@WaffleLapkin", + "@wesleywiser", +] libs = [ "@Mark-Simulacrum", "@workingjubilee", @@ -1464,6 +1484,11 @@ infra-ci = [ "@jdno", "@jieyouxu", ] +rustdoc = [ + "@GuillaumeGomez", + "@notriddle", + "@fmease", +] docs = [ "@ehuss", "@GuillaumeGomez", @@ -1485,7 +1510,6 @@ diagnostics = [ "@davidtwco", "@oli-obk", "@chenyukang", - "@TaKO8Ki" ] parser = [ "@davidtwco", @@ -1512,6 +1536,13 @@ mir-opt = [ "@wesleywiser", "@saethlin", ] +types = [ + "@jackh726", + "@lcnr", + "@oli-obk", + "@spastorino", + "@BoxyUwU", +] borrowck = [ "@davidtwco", "@matthewjasper" @@ -1531,6 +1562,21 @@ style-team = [ "@joshtriplett", "@traviscross", ] +project-const-traits = [ + "@fee1-dead", + "@fmease", + "@oli-obk", +] +project-stable-mir = [ + "@celinval", + "@oli-obk", + "@scottmcm", + "@makai410", +] +project-exploit-mitigations = [ + "@cuviper", + "@rcvalle", +] compiletest = [ "@jieyouxu", ] @@ -1555,11 +1601,8 @@ dep-bumps = [ "/compiler/rustc_llvm" = ["@cuviper"] "/compiler/rustc_codegen_llvm/src/debuginfo" = ["compiler", "debuginfo"] "/compiler/rustc_codegen_ssa" = ["compiler", "codegen"] -"/compiler/rustc_middle/src/dep_graph" = ["compiler", "incremental", "query-system"] -"/compiler/rustc_middle/src/ich" = ["compiler", "incremental", "query-system"] "/compiler/rustc_middle/src/mir" = ["compiler", "mir"] "/compiler/rustc_middle/src/traits" = ["compiler", "types"] -"/compiler/rustc_middle/src/query" = ["compiler", "query-system"] "/compiler/rustc_middle/src/ty" = ["compiler", "types"] "/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] "/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"] @@ -1568,6 +1611,9 @@ dep-bumps = [ "/compiler/rustc_parse" = ["compiler", "parser"] "/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"] "/compiler/rustc_query_impl" = ["compiler", "query-system"] +"/compiler/rustc_query_system" = ["compiler", "query-system"] +"/compiler/rustc_query_system/src/dep_graph" = ["compiler", "incremental", "query-system"] +"/compiler/rustc_query_system/src/ich" = ["compiler", "incremental", "query-system"] "/compiler/rustc_trait_selection" = ["compiler", "types"] "/compiler/rustc_traits" = ["compiler", "types"] "/compiler/rustc_type_ir" = ["compiler", "types"] @@ -1609,7 +1655,6 @@ dep-bumps = [ "/tests/rustdoc-json" = ["@aDotInTheVoid"] "/tests/rustdoc-ui" = ["rustdoc"] "/tests/ui" = ["compiler"] -"/src/tools/build-manifest" = ["bootstrap"] "/src/tools/cargo" = ["@ehuss"] "/src/tools/compiletest" = ["bootstrap", "@wesleywiser", "@oli-obk", "@jieyouxu"] "/src/tools/linkchecker" = ["@ehuss"] diff --git a/typos.toml b/typos.toml index 3c95a45d572d..b9d9c6c3522c 100644 --- a/typos.toml +++ b/typos.toml @@ -1,6 +1,3 @@ -# Config for the `typos` crate, used by `./x test tidy --extra-checks=spellcheck`. -# See also: https://github.com/crate-ci/typos/blob/v1.28.2/docs/reference.md - [files] extend-exclude = [ # exclude git (sub)modules and generated content @@ -16,67 +13,56 @@ extend-exclude = [ ] [default.extend-words] -# Allowlist for words that look like typos but are not, or aren't worth fixing -# right now. Entries should look like `mipsel = "mipsel"`. +# Add exclusions here, lines should be like `x = "x"`, where `x` is excluded word. # -# tidy-alphabetical-start -arange = "arange" # short for A-range +# Also see docs: https://github.com/crate-ci/typos/blob/v1.28.2/docs/reference.md +arange = "arange" childs = "childs" clonable = "clonable" -filetimes = "filetimes" # short for "file times", not a typo for "lifetimes" +Datas = "Datas" +filetimes = "filetimes" leafs = "leafs" -makro = "makro" # deliberate misspelling to avoid `macro` keyword +makro = "makro" misformed = "misformed" moreso = "moreso" -numer = "numer" # short for numerator, not a typo for "number" -optin = "optin" # short for opt-in +optin = "optin" publically = "publically" -rplace = "rplace" # short for R-place +rplace = "rplace" +smove = "smove" splitted = "splitted" -taits = "taits" # lowercase for TAITs (type alias impl trait) +taits = "taits" targetting = "targetting" unparseable = "unparseable" unstability = "unstability" -unstalled = "unstalled" # short for un-stalled -# tidy-alphabetical-end +unstalled = "unstalled" -# Denylist to forbid misspelled words that aren't detected by the built-in -# dictionary. Entries should look like `mipsel = ""` or `mipsel = "misspell"`; -# the non-empty form can be automatically fixed by `--bless`. -# -# tidy-alphabetical-start -definitinon = "definition" -dependy = "" -similarlty = "similarity" -# tidy-alphabetical-end +# this can be valid word, depends on dictionary edition +#matcheable = "matcheable" [default.extend-identifiers] -# Allowlist for specific identifiers that should be permitted even though they -# appear to contain typos that would be forbidden in other identifiers. +# An entry goes here if the typo is part of some existing ident +# where you want to keep it, but don't want to allow +# such typos everywhere. # -# For example, you might want to allow a specific constant like -# `DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME`, but still want to forbid -# the typo `INVAILD` in other places. -# -# tidy-alphabetical-start +# I.e. you don't want (or can't) fix some constant name, like +# `DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME` but actually +# want to see `INVAILD` typo fixed in other places. +debug_aranges = "debug_aranges" DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME = "DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME" +EnzymeTypeTreeShiftIndiciesEq = "EnzymeTypeTreeShiftIndiciesEq" +EnzymeTypeTreeShiftIndiciesEqFn = "EnzymeTypeTreeShiftIndiciesEqFn" +shift_indicies_eq = "shift_indicies_eq" ERRNO_ACCES = "ERRNO_ACCES" ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS = "ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS" ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC = "ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC" ERROR_FILENAME_EXCED_RANGE = "ERROR_FILENAME_EXCED_RANGE" ERROR_MCA_OCCURED = "ERROR_MCA_OCCURED" ERROR_REQ_NOT_ACCEP = "ERROR_REQ_NOT_ACCEP" -EnzymeTypeTreeShiftIndiciesEq = "EnzymeTypeTreeShiftIndiciesEq" -EnzymeTypeTreeShiftIndiciesEqFn = "EnzymeTypeTreeShiftIndiciesEqFn" -Oppen = "Oppen" # Derek C. Oppen, author of "Pretty Printing" (1979) +Oppen = "Oppen" # typos treats this as two different camelcase words (`SETTIN` and `Gs`) # Tracked in: https://github.com/crate-ci/typos/issues/745 SETTINGs = "SETTINGs" -debug_aranges = "debug_aranges" # debug A-ranges -key_smove = "key_smove" # shifted move key, used by terminfo -shift_indicies_eq = "shift_indicies_eq" -tolen = "tolen" # length of "to" buffer, used by `sendto` in Windows sockets -# tidy-alphabetical-end +tolen = "tolen" [default] extend-ignore-words-re = [ diff --git a/x b/x index a8acbd4d5ac6..4fce0be219e7 100755 --- a/x +++ b/x @@ -29,19 +29,16 @@ xpy=$(dirname "$(realpath "$0")")/x.py # On MacOS, `py` tries to install "Developer command line tools". Try `python3` first. # NOTE: running `bash -c ./x` from Windows doesn't set OSTYPE. case ${OSTYPE:-} in - cygwin*|msys*) SEARCH="py python3 python python2 uv";; - *) SEARCH="python3 python py python2 uv";; + cygwin*|msys*) SEARCH="py python3 python python2";; + *) SEARCH="python3 python py python2";; esac for SEARCH_PYTHON in $SEARCH; do if python=$(command -v $SEARCH_PYTHON) && [ -x "$python" ]; then - case $SEARCH_PYTHON in - py) - extra_arg="-3";; - uv) - extra_arg="run";; - *) - extra_arg="";; - esac + if [ $SEARCH_PYTHON = py ]; then + extra_arg="-3" + else + extra_arg="" + fi exec "$python" $extra_arg "$xpy" "$@" fi done

for () { LL | const D: u16 = N; | ^^^^^^^^^^^^ found const parameter of type `u16` -error[E0195]: lifetime parameters or bounds on associated constant `E` do not match the trait declaration +error[E0195]: lifetime parameters or bounds on associated const `E` do not match the trait declaration --> $DIR/compare-impl-item.rs:24:12 | LL | const E<'a>: &'a (); - | ---- lifetimes in impl do not match this associated constant in trait + | ---- lifetimes in impl do not match this associated const in trait ... LL | const E: &'static () = &(); - | ^ lifetimes do not match associated constant in trait + | ^ lifetimes do not match associated const in trait error[E0276]: impl has stricter requirements than trait --> $DIR/compare-impl-item.rs:29:12 diff --git a/tests/ui/generic-const-items/type-const-nested-assoc-const.rs b/tests/ui/generic-const-items/type-const-nested-assoc-const.rs deleted file mode 100644 index 72a3098b76cf..000000000000 --- a/tests/ui/generic-const-items/type-const-nested-assoc-const.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ check-pass - -#![feature(generic_const_items, min_generic_const_args)] -#![allow(incomplete_features)] - -type const CT: usize = { ::N }; - -trait Trait { - type const N: usize; -} - -impl Trait for T { - type const N:usize = 0; -} - -fn f(_x: [(); CT::<()>]) {} - -fn main() {} diff --git a/tests/ui/generics/generic-trait-method-params-2311.rs b/tests/ui/generics/generic-trait-method-params-2311.rs deleted file mode 100644 index f63036e47f6f..000000000000 --- a/tests/ui/generics/generic-trait-method-params-2311.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2311 - -//@ check-pass -#![allow(non_camel_case_types)] - -trait clam { - fn get(self) -> A; -} -trait foo { - fn bar>(&self, c: C) -> B; -} - -pub fn main() {} diff --git a/tests/ui/generics/resolve-generic-method-param-2312.rs b/tests/ui/generics/resolve-generic-method-param-2312.rs deleted file mode 100644 index 7473b73f5bfa..000000000000 --- a/tests/ui/generics/resolve-generic-method-param-2312.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2312 - -//@ check-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -// Testing that the B's are resolved - -trait clam { - fn get(self) -> A; -} - -struct foo(isize); - -impl foo { - pub fn bar>(&self, _c: C) -> B { - panic!(); - } -} - -pub fn main() {} diff --git a/tests/ui/generics/wrong-number-of-args.rs b/tests/ui/generics/wrong-number-of-args.rs index 9af16567cd75..8bc384a3d817 100644 --- a/tests/ui/generics/wrong-number-of-args.rs +++ b/tests/ui/generics/wrong-number-of-args.rs @@ -127,7 +127,7 @@ mod r#trait { //~| HELP remove type D = Box; - //~^ ERROR missing generics for trait `r#trait::GenericType` + //~^ ERROR missing generics for trait `GenericType` //~| HELP add missing type E = Box>; diff --git a/tests/ui/generics/wrong-number-of-args.stderr b/tests/ui/generics/wrong-number-of-args.stderr index 554d017d67e3..bedeeb812fc9 100644 --- a/tests/ui/generics/wrong-number-of-args.stderr +++ b/tests/ui/generics/wrong-number-of-args.stderr @@ -469,7 +469,7 @@ note: trait defined here, with 1 lifetime parameter: `'a` LL | trait GenericLifetime<'a> { | ^^^^^^^^^^^^^^^ -- -error[E0107]: missing generics for trait `r#trait::GenericType` +error[E0107]: missing generics for trait `GenericType` --> $DIR/wrong-number-of-args.rs:129:22 | LL | type D = Box; diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs index df1b9e164c76..a89b22925128 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs @@ -1,11 +1,9 @@ //@ run-pass -//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f128) // Test half-open range patterns against their expression equivalents // via `.contains(...)` and make sure the dynamic semantics match. #![allow(unreachable_patterns)] -#![feature(cfg_target_has_reliable_f16_f128)] #![feature(f128)] #![feature(f16)] @@ -44,7 +42,8 @@ fn range_to_inclusive() { assert!(!yes!('b', ..='a')); // f16; `..=X` - #[cfg(target_has_reliable_f16)] + // FIXME(f16_f128): remove gate when ABI issues are resolved + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { assert!(yes!(f16::NEG_INFINITY, ..=f16::NEG_INFINITY)); assert!(yes!(f16::NEG_INFINITY, ..=1.0f16)); @@ -65,7 +64,8 @@ fn range_to_inclusive() { assert!(!yes!(1.6f64, ..=-1.5f64)); // f128; `..=X` - #[cfg(target_has_reliable_f128)] + // FIXME(f16_f128): remove gate when ABI issues are resolved + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { assert!(yes!(f128::NEG_INFINITY, ..=f128::NEG_INFINITY)); assert!(yes!(f128::NEG_INFINITY, ..=1.0f128)); @@ -106,7 +106,8 @@ fn range_to() { assert!(!yes!('b', ..'a')); // f16; `..X` - #[cfg(target_has_reliable_f16)] + // FIXME(f16_f128): remove gate when ABI issues are resolved + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { assert!(yes!(f16::NEG_INFINITY, ..1.0f16)); assert!(!yes!(1.5f16, ..1.5f16)); @@ -130,7 +131,8 @@ fn range_to() { assert!(!yes!(1.6f64, ..1.5f64)); // f128; `..X` - #[cfg(target_has_reliable_f128)] + // FIXME(f16_f128): remove gate when ABI issues are resolved + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { assert!(yes!(f128::NEG_INFINITY, ..1.0f128)); assert!(!yes!(1.5f128, ..1.5f128)); @@ -172,7 +174,8 @@ fn range_from() { assert!(yes!(core::char::MAX, core::char::MAX..)); // f16; `X..` - #[cfg(target_has_reliable_f16)] + // FIXME(f16_f128): remove gate when ABI issues are resolved + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { assert!(yes!(f16::NEG_INFINITY, f16::NEG_INFINITY..)); assert!(yes!(f16::INFINITY, f16::NEG_INFINITY..)); @@ -205,7 +208,8 @@ fn range_from() { assert!(yes!(f64::INFINITY, f64::INFINITY..)); // f128; `X..` - #[cfg(target_has_reliable_f128)] + // FIXME(f16_f128): remove gate when ABI issues are resolved + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { assert!(yes!(f128::NEG_INFINITY, f128::NEG_INFINITY..)); assert!(yes!(f128::INFINITY, f128::NEG_INFINITY..)); diff --git a/tests/ui/collections/hashmap/hashmap-capacity-overflow.rs b/tests/ui/hashmap/hashmap-capacity-overflow.rs similarity index 100% rename from tests/ui/collections/hashmap/hashmap-capacity-overflow.rs rename to tests/ui/hashmap/hashmap-capacity-overflow.rs diff --git a/tests/ui/collections/hashmap/hashmap-index-mut.rs b/tests/ui/hashmap/hashmap-index-mut.rs similarity index 100% rename from tests/ui/collections/hashmap/hashmap-index-mut.rs rename to tests/ui/hashmap/hashmap-index-mut.rs diff --git a/tests/ui/collections/hashmap/hashmap-index-mut.stderr b/tests/ui/hashmap/hashmap-index-mut.stderr similarity index 100% rename from tests/ui/collections/hashmap/hashmap-index-mut.stderr rename to tests/ui/hashmap/hashmap-index-mut.stderr diff --git a/tests/ui/collections/hashmap/hashmap-iter-value-lifetime.rs b/tests/ui/hashmap/hashmap-iter-value-lifetime.rs similarity index 100% rename from tests/ui/collections/hashmap/hashmap-iter-value-lifetime.rs rename to tests/ui/hashmap/hashmap-iter-value-lifetime.rs diff --git a/tests/ui/collections/hashmap/hashmap-iter-value-lifetime.stderr b/tests/ui/hashmap/hashmap-iter-value-lifetime.stderr similarity index 100% rename from tests/ui/collections/hashmap/hashmap-iter-value-lifetime.stderr rename to tests/ui/hashmap/hashmap-iter-value-lifetime.stderr diff --git a/tests/ui/collections/hashmap/hashmap-lifetimes.rs b/tests/ui/hashmap/hashmap-lifetimes.rs similarity index 100% rename from tests/ui/collections/hashmap/hashmap-lifetimes.rs rename to tests/ui/hashmap/hashmap-lifetimes.rs diff --git a/tests/ui/collections/hashmap/hashmap-lifetimes.stderr b/tests/ui/hashmap/hashmap-lifetimes.stderr similarity index 100% rename from tests/ui/collections/hashmap/hashmap-lifetimes.stderr rename to tests/ui/hashmap/hashmap-lifetimes.stderr diff --git a/tests/ui/collections/hashmap/hashmap-memory.rs b/tests/ui/hashmap/hashmap-memory.rs similarity index 100% rename from tests/ui/collections/hashmap/hashmap-memory.rs rename to tests/ui/hashmap/hashmap-memory.rs diff --git a/tests/ui/collections/hashmap/hashmap-path-key.rs b/tests/ui/hashmap/hashmap-path-key.rs similarity index 100% rename from tests/ui/collections/hashmap/hashmap-path-key.rs rename to tests/ui/hashmap/hashmap-path-key.rs diff --git a/tests/ui/collections/hashmap/hashset-enum-variant.rs b/tests/ui/hashmap/hashset-enum-variant.rs similarity index 100% rename from tests/ui/collections/hashmap/hashset-enum-variant.rs rename to tests/ui/hashmap/hashset-enum-variant.rs diff --git a/tests/ui/collections/hashmap/hashset_generics.rs b/tests/ui/hashmap/hashset_generics.rs similarity index 100% rename from tests/ui/collections/hashmap/hashset_generics.rs rename to tests/ui/hashmap/hashset_generics.rs diff --git a/tests/ui/collections/hashmap/hashset_generics.stderr b/tests/ui/hashmap/hashset_generics.stderr similarity index 100% rename from tests/ui/collections/hashmap/hashset_generics.stderr rename to tests/ui/hashmap/hashset_generics.stderr diff --git a/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.rs b/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.rs similarity index 81% rename from tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.rs rename to tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.rs index d0d09f11a574..d1a4e09243ec 100644 --- a/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.rs +++ b/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.rs @@ -1,4 +1,6 @@ -// Regression test for https://github.com/rust-lang/rust/issues/60218 +// https://github.com/rust-lang/rust/issues/60218 +// Regression test for #60218 +// // This was reported to cause ICEs. use std::iter::Map; diff --git a/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr b/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.stderr similarity index 85% rename from tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr rename to tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.stderr index b02179f14125..4c403bcbd601 100644 --- a/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr +++ b/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `&u32: Foo` is not satisfied - --> $DIR/higher-trait-bounds-ice-60218.rs:17:19 + --> $DIR/higher-trait-bounds-ice-60218.rs:19:19 | LL | trigger_error(vec![], |x: &u32| x) | ------------- ^^^^^^ the trait `Foo` is not implemented for `&u32` @@ -7,12 +7,12 @@ LL | trigger_error(vec![], |x: &u32| x) | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/higher-trait-bounds-ice-60218.rs:6:1 + --> $DIR/higher-trait-bounds-ice-60218.rs:8:1 | LL | pub trait Foo {} | ^^^^^^^^^^^^^ note: required by a bound in `trigger_error` - --> $DIR/higher-trait-bounds-ice-60218.rs:12:72 + --> $DIR/higher-trait-bounds-ice-60218.rs:14:72 | LL | pub fn trigger_error(iterable: I, functor: F) | ------------- required by a bound in this function diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr index 90d9eb3922e0..395dd068e237 100644 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr +++ b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr @@ -2,10 +2,15 @@ error[E0308]: mismatched types --> $DIR/candidate-from-env-universe-err-project.rs:38:5 | LL | projection_bound::(); - | ^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | = note: expected associated type `>::Assoc` found associated type `>::Assoc` +note: the lifetime requirement is introduced here + --> $DIR/candidate-from-env-universe-err-project.rs:19:42 + | +LL | fn projection_bound Trait<'a, Assoc = usize>>() {} + | ^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/candidate-from-env-universe-err-project.rs:52:30 diff --git a/tests/ui/higher-ranked/trait-bounds/issue-88446.rs b/tests/ui/higher-ranked/trait-bounds/issue-88446.rs index 8e42465b929a..0ca8387776a4 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-88446.rs +++ b/tests/ui/higher-ranked/trait-bounds/issue-88446.rs @@ -1,7 +1,4 @@ //@ check-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver trait Yokeable<'a> { type Output: 'a; diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs index 226bd48f0e4e..d85c6999e26f 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs @@ -1,7 +1,4 @@ //@ check-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver #![allow(unused)] diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs index 0dcef54ed69c..b3feda4a531f 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs @@ -1,7 +1,4 @@ //@check-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver trait Yokeable<'a>: 'static { type Output: 'a; diff --git a/tests/ui/hygiene/cross-crate-name-hiding-2.stderr b/tests/ui/hygiene/cross-crate-name-hiding-2.stderr index 90dd40534ed1..336d35099c80 100644 --- a/tests/ui/hygiene/cross-crate-name-hiding-2.stderr +++ b/tests/ui/hygiene/cross-crate-name-hiding-2.stderr @@ -1,11 +1,13 @@ error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope --> $DIR/cross-crate-name-hiding-2.rs:13:13 | -LL | my_struct!(define); - | ------------------ you might have meant to refer to this struct -... LL | let x = MyStruct {}; | ^^^^^^^^ not found in this scope + | + ::: $DIR/auxiliary/use_by_macro.rs:7:24 + | +LL | pub struct MyStruct; + | -------- you might have meant to refer to this struct error: aborting due to 1 previous error diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs index 60355c22bb30..71c33674b37f 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs @@ -10,7 +10,7 @@ macro a() { mod u { // Late resolution. fn f() { my_core::mem::drop(0); } - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `my_core` } } @@ -23,7 +23,7 @@ mod v { mod u { // Late resolution. fn f() { my_core::mem::drop(0); } - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `my_core` } fn main() {} diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr index db1a56d7d816..87ef07c27f5b 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr @@ -15,7 +15,7 @@ LL | a!(); | = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: cannot find module or crate `my_core` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `my_core` --> $DIR/extern-prelude-from-opaque-fail-2018.rs:12:18 | LL | fn f() { my_core::mem::drop(0); } @@ -29,7 +29,7 @@ LL | a!(); std::mem = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: cannot find module or crate `my_core` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `my_core` --> $DIR/extern-prelude-from-opaque-fail-2018.rs:25:14 | LL | fn f() { my_core::mem::drop(0); } diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs b/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs index 8f75ba1434a1..8265b73cc565 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs @@ -10,7 +10,7 @@ macro a() { mod u { // Late resolution. fn f() { my_core::mem::drop(0); } - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `my_core` } } @@ -23,7 +23,7 @@ mod v { mod u { // Late resolution. fn f() { my_core::mem::drop(0); } - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `my_core` } fn main() {} diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr b/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr index f3a43fa0127c..d36bc9130953 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr @@ -15,7 +15,7 @@ LL | a!(); | = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: cannot find module or crate `my_core` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `my_core` --> $DIR/extern-prelude-from-opaque-fail.rs:12:18 | LL | fn f() { my_core::mem::drop(0); } @@ -29,7 +29,7 @@ LL | a!(); my_core::mem = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: cannot find module or crate `my_core` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `my_core` --> $DIR/extern-prelude-from-opaque-fail.rs:25:14 | LL | fn f() { my_core::mem::drop(0); } diff --git a/tests/ui/hygiene/no_implicit_prelude.rs b/tests/ui/hygiene/no_implicit_prelude.rs index bfe7a6a44614..8145212fe309 100644 --- a/tests/ui/hygiene/no_implicit_prelude.rs +++ b/tests/ui/hygiene/no_implicit_prelude.rs @@ -9,7 +9,7 @@ mod foo { #[no_implicit_prelude] mod bar { pub macro m() { - Vec::new(); //~ ERROR cannot find + Vec::new(); //~ ERROR failed to resolve ().clone() //~ ERROR no method named `clone` found } fn f() { diff --git a/tests/ui/hygiene/no_implicit_prelude.stderr b/tests/ui/hygiene/no_implicit_prelude.stderr index 5461ee527b88..0606fe501386 100644 --- a/tests/ui/hygiene/no_implicit_prelude.stderr +++ b/tests/ui/hygiene/no_implicit_prelude.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `Vec` in this scope +error[E0433]: failed to resolve: use of undeclared type `Vec` --> $DIR/no_implicit_prelude.rs:12:9 | LL | fn f() { ::bar::m!(); } diff --git a/tests/ui/hygiene/unpretty-debug-lifetimes.rs b/tests/ui/hygiene/unpretty-debug-lifetimes.rs deleted file mode 100644 index ee8be21b60d0..000000000000 --- a/tests/ui/hygiene/unpretty-debug-lifetimes.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ check-pass -//@ compile-flags: -Zunpretty=expanded,hygiene - -// Regression test for lifetime hygiene annotations in -Zunpretty=expanded,hygiene -// Previously, lifetimes were missing the #N syntax context suffix. - -// Don't break whenever Symbol numbering changes -//@ normalize-stdout: "\d+#" -> "0#" - -#![feature(decl_macro)] -#![feature(no_core)] -#![no_core] - -macro lifetime_hygiene($f:ident<$a:lifetime>) { - fn $f<$a, 'a>() {} -} - -lifetime_hygiene!(f<'a>); diff --git a/tests/ui/hygiene/unpretty-debug-lifetimes.stdout b/tests/ui/hygiene/unpretty-debug-lifetimes.stdout deleted file mode 100644 index 28a5c70a02d7..000000000000 --- a/tests/ui/hygiene/unpretty-debug-lifetimes.stdout +++ /dev/null @@ -1,31 +0,0 @@ -//@ check-pass -//@ compile-flags: -Zunpretty=expanded,hygiene - -// Regression test for lifetime hygiene annotations in -Zunpretty=expanded,hygiene -// Previously, lifetimes were missing the #N syntax context suffix. - -// Don't break whenever Symbol numbering changes -//@ normalize-stdout: "\d+#" -> "0#" - -#![feature /* 0#0 */(decl_macro)] -#![feature /* 0#0 */(no_core)] -#![no_core /* 0#0 */] - -macro lifetime_hygiene - /* - 0#0 - */ { - ($f:ident<$a:lifetime>) => { fn $f<$a, 'a>() {} } -} -fn f /* 0#0 */<'a /* 0#0 */, 'a /* 0#1 */>() {} - - -/* -Expansions: -crate0::{{expn0}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Root -crate0::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "lifetime_hygiene") - -SyntaxContexts: -#0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque) -#1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque) -*/ diff --git a/tests/ui/impl-trait/associated-type-cycle.stderr b/tests/ui/impl-trait/associated-type-cycle.stderr index 438a5a92ffc2..7eef8d1e3389 100644 --- a/tests/ui/impl-trait/associated-type-cycle.stderr +++ b/tests/ui/impl-trait/associated-type-cycle.stderr @@ -5,7 +5,7 @@ LL | type Bar; | -------- `Bar` defined here ... LL | impl Foo for Box { - | ^^^ help: specify the associated type: `Foo` + | ^^^ help: specify the associated type: `Foo` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/issues/issue-72911.rs b/tests/ui/impl-trait/issues/issue-72911.rs index b105860ba651..63f4898f4306 100644 --- a/tests/ui/impl-trait/issues/issue-72911.rs +++ b/tests/ui/impl-trait/issues/issue-72911.rs @@ -9,12 +9,12 @@ pub fn gather_all() -> impl Iterator { } fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator { - //~^ ERROR: cannot find + //~^ ERROR: failed to resolve unimplemented!() } fn lint_files() -> impl Iterator { - //~^ ERROR: cannot find + //~^ ERROR: failed to resolve unimplemented!() } diff --git a/tests/ui/impl-trait/issues/issue-72911.stderr b/tests/ui/impl-trait/issues/issue-72911.stderr index 1333f608ead1..063b7f68dc02 100644 --- a/tests/ui/impl-trait/issues/issue-72911.stderr +++ b/tests/ui/impl-trait/issues/issue-72911.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `foo` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo` --> $DIR/issue-72911.rs:11:33 | LL | fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator { @@ -6,7 +6,7 @@ LL | fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator $DIR/issue-72911.rs:16:41 | LL | fn lint_files() -> impl Iterator { diff --git a/tests/ui/impl-trait/precise-capturing/migration-note.stderr b/tests/ui/impl-trait/precise-capturing/migration-note.stderr index fef0a85bf1ae..880e7878477a 100644 --- a/tests/ui/impl-trait/precise-capturing/migration-note.stderr +++ b/tests/ui/impl-trait/precise-capturing/migration-note.stderr @@ -282,6 +282,7 @@ note: this call may capture more lifetimes than intended, because Rust 2024 has | LL | let x = { let x = display_len(&mut vec![0]); x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn display_len(x: &Vec) -> impl Display + use { diff --git a/tests/ui/impl-trait/stashed-diag-issue-121504.rs b/tests/ui/impl-trait/stashed-diag-issue-121504.rs index ee2cd1ee816f..84686ba4f7d3 100644 --- a/tests/ui/impl-trait/stashed-diag-issue-121504.rs +++ b/tests/ui/impl-trait/stashed-diag-issue-121504.rs @@ -4,7 +4,7 @@ trait MyTrait { async fn foo(self) -> (Self, i32); } -impl MyTrait for xyz::T { //~ ERROR cannot find module or crate `xyz` +impl MyTrait for xyz::T { //~ ERROR failed to resolve: use of unresolved module or unlinked crate `xyz` async fn foo(self, key: i32) -> (u32, i32) { (self, key) } diff --git a/tests/ui/impl-trait/stashed-diag-issue-121504.stderr b/tests/ui/impl-trait/stashed-diag-issue-121504.stderr index f973e6c9dc42..41c6cc425558 100644 --- a/tests/ui/impl-trait/stashed-diag-issue-121504.stderr +++ b/tests/ui/impl-trait/stashed-diag-issue-121504.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `xyz` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `xyz` --> $DIR/stashed-diag-issue-121504.rs:7:18 | LL | impl MyTrait for xyz::T { diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index 2d97215de3bb..1a8d6509e137 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -390,6 +390,14 @@ LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { pani - impl Fn for Exclusive where F: Sync, F: Fn, Args: std::marker::Tuple; +error[E0118]: no nominal type found for inherent implementation + --> $DIR/where-allowed.rs:241:1 + | +LL | impl T {} + | ^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type + | + = note: either implement a trait on it or create a newtype to wrap it instead + error: unconstrained opaque type --> $DIR/where-allowed.rs:122:16 | @@ -406,14 +414,6 @@ LL | type InTypeAlias = impl Debug; | = note: `InTypeAlias` must be used in combination with a concrete type within the same crate -error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:241:1 - | -LL | impl T {} - | ^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type - | - = note: either implement a trait on it or create a newtype to wrap it instead - error: aborting due to 48 previous errors Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0658, E0666. diff --git a/tests/ui/imports/absolute-paths-in-nested-use-groups.rs b/tests/ui/imports/absolute-paths-in-nested-use-groups.rs index 9a8c9aab7282..96b5131674c7 100644 --- a/tests/ui/imports/absolute-paths-in-nested-use-groups.rs +++ b/tests/ui/imports/absolute-paths-in-nested-use-groups.rs @@ -3,12 +3,9 @@ mod foo {} use foo::{ - ::bar, - //~^ ERROR: crate root in paths can only be used in start position - super::bar, - //~^ ERROR: `super` in paths can only be used in start position - self::bar, - //~^ ERROR: `self` in paths can only be used in start position + ::bar, //~ ERROR crate root in paths can only be used in start position + super::bar, //~ ERROR `super` in paths can only be used in start position + self::bar, //~ ERROR `self` in paths can only be used in start position }; fn main() {} diff --git a/tests/ui/imports/absolute-paths-in-nested-use-groups.stderr b/tests/ui/imports/absolute-paths-in-nested-use-groups.stderr index ff951ad7489c..e41590ac45ee 100644 --- a/tests/ui/imports/absolute-paths-in-nested-use-groups.stderr +++ b/tests/ui/imports/absolute-paths-in-nested-use-groups.stderr @@ -1,20 +1,20 @@ -error[E0433]: the crate root in paths can only be used in start position +error[E0433]: failed to resolve: crate root in paths can only be used in start position --> $DIR/absolute-paths-in-nested-use-groups.rs:6:5 | LL | ::bar, - | ^ can only be used in path start position + | ^ crate root in paths can only be used in start position -error[E0433]: `super` in paths can only be used in start position - --> $DIR/absolute-paths-in-nested-use-groups.rs:8:5 +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/absolute-paths-in-nested-use-groups.rs:7:5 | LL | super::bar, - | ^^^^^ can only be used in path start position + | ^^^^^ `super` in paths can only be used in start position -error[E0433]: `self` in paths can only be used in start position - --> $DIR/absolute-paths-in-nested-use-groups.rs:10:5 +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/absolute-paths-in-nested-use-groups.rs:8:5 | LL | self::bar, - | ^^^^ can only be used in path start position + | ^^^^ `self` in paths can only be used in start position error: aborting due to 3 previous errors diff --git a/tests/ui/imports/ambiguous-import-visibility-macro.rs b/tests/ui/imports/ambiguous-import-visibility-macro.rs deleted file mode 100644 index e1861cc5d4e0..000000000000 --- a/tests/ui/imports/ambiguous-import-visibility-macro.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ check-pass -//@ edition:2018 -//@ proc-macro: same-res-ambigious-extern-macro.rs - -macro_rules! globbing{ - () => { - pub use same_res_ambigious_extern_macro::*; - } -} - -#[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility -extern crate same_res_ambigious_extern_macro; -globbing! {} // this imports the same `RustEmbed` macro with `pub` visibility - -pub trait RustEmbed {} - -pub use RustEmbed as Embed; //~ WARN ambiguous import visibility - //~| WARN this was previously accepted -fn main() {} diff --git a/tests/ui/imports/ambiguous-import-visibility-macro.stderr b/tests/ui/imports/ambiguous-import-visibility-macro.stderr deleted file mode 100644 index ed6eb6f893af..000000000000 --- a/tests/ui/imports/ambiguous-import-visibility-macro.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: ambiguous import visibility: pub(crate) or pub - --> $DIR/ambiguous-import-visibility-macro.rs:17:9 - | -LL | pub use RustEmbed as Embed; - | ^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #149145 - = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution -note: `RustEmbed` could refer to the derive macro imported here - --> $DIR/ambiguous-import-visibility-macro.rs:7:17 - | -LL | pub use same_res_ambigious_extern_macro::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | globbing! {} // this imports the same `RustEmbed` macro with `pub` visibility - | ------------ in this macro invocation - = help: consider adding an explicit import of `RustEmbed` to disambiguate - = help: or use `crate::RustEmbed` to refer to this derive macro unambiguously -note: `RustEmbed` could also refer to the derive macro imported here - --> $DIR/ambiguous-import-visibility-macro.rs:11:1 - | -LL | #[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility - | ^^^^^^^^^^^^ - = note: `#[warn(ambiguous_import_visibilities)]` (part of `#[warn(future_incompatible)]`) on by default - = note: this warning originates in the macro `globbing` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: 1 warning emitted - diff --git a/tests/ui/imports/ambiguous-import-visibility-module.rs b/tests/ui/imports/ambiguous-import-visibility-module.rs deleted file mode 100644 index 35c6da8b21a4..000000000000 --- a/tests/ui/imports/ambiguous-import-visibility-module.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ check-pass -//@ edition:2018.. - -mod reexport { - mod m { - pub struct S {} - } - - macro_rules! mac { - () => { - use m::S; - }; - } - - pub use m::*; - mac!(); - - pub use S as Z; //~ WARN ambiguous import visibility - //~| WARN this was previously accepted -} - -fn main() { - reexport::Z {}; -} diff --git a/tests/ui/imports/ambiguous-import-visibility-module.stderr b/tests/ui/imports/ambiguous-import-visibility-module.stderr deleted file mode 100644 index a97070c20a62..000000000000 --- a/tests/ui/imports/ambiguous-import-visibility-module.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: ambiguous import visibility: pub or pub(in crate::reexport) - --> $DIR/ambiguous-import-visibility-module.rs:18:13 - | -LL | pub use S as Z; - | ^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #149145 - = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution -note: `S` could refer to the struct imported here - --> $DIR/ambiguous-import-visibility-module.rs:11:17 - | -LL | use m::S; - | ^^^^ -... -LL | mac!(); - | ------ in this macro invocation - = help: use `self::S` to refer to this struct unambiguously -note: `S` could also refer to the struct imported here - --> $DIR/ambiguous-import-visibility-module.rs:15:13 - | -LL | pub use m::*; - | ^^^^ - = help: use `self::S` to refer to this struct unambiguously - = note: `#[warn(ambiguous_import_visibilities)]` (part of `#[warn(future_incompatible)]`) on by default - = note: this warning originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: 1 warning emitted - diff --git a/tests/ui/imports/ambiguous-import-visibility.rs b/tests/ui/imports/ambiguous-import-visibility.rs deleted file mode 100644 index 4cb8b763fbc9..000000000000 --- a/tests/ui/imports/ambiguous-import-visibility.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass -//@ edition:2018 -//@ proc-macro: same-res-ambigious-extern-macro.rs - -#[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility -extern crate same_res_ambigious_extern_macro; -// this imports the same `RustEmbed` macro with `pub` visibility -pub use same_res_ambigious_extern_macro::*; - -pub trait RustEmbed {} - -pub use RustEmbed as Embed; //~ WARN ambiguous import visibility - //~| WARN this was previously accepted -fn main() {} diff --git a/tests/ui/imports/ambiguous-import-visibility.stderr b/tests/ui/imports/ambiguous-import-visibility.stderr deleted file mode 100644 index 30cddca4697d..000000000000 --- a/tests/ui/imports/ambiguous-import-visibility.stderr +++ /dev/null @@ -1,25 +0,0 @@ -warning: ambiguous import visibility: pub(crate) or pub - --> $DIR/ambiguous-import-visibility.rs:12:9 - | -LL | pub use RustEmbed as Embed; - | ^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #149145 - = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution -note: `RustEmbed` could refer to the derive macro imported here - --> $DIR/ambiguous-import-visibility.rs:8:9 - | -LL | pub use same_res_ambigious_extern_macro::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `RustEmbed` to disambiguate - = help: or use `crate::RustEmbed` to refer to this derive macro unambiguously -note: `RustEmbed` could also refer to the derive macro imported here - --> $DIR/ambiguous-import-visibility.rs:5:1 - | -LL | #[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility - | ^^^^^^^^^^^^ - = note: `#[warn(ambiguous_import_visibilities)]` (part of `#[warn(future_incompatible)]`) on by default - -warning: 1 warning emitted - diff --git a/tests/ui/imports/ambiguous-reachable.rs b/tests/ui/imports/ambiguous-reachable.rs deleted file mode 100644 index fc92315622aa..000000000000 --- a/tests/ui/imports/ambiguous-reachable.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ build-pass -//@ aux-crate: ambiguous_reachable_extern=ambiguous-reachable-extern.rs - -#![allow(ambiguous_glob_imports)] - -fn main() { - ambiguous_reachable_extern::generic::(); -} diff --git a/tests/ui/imports/ambiguous-reachable.stderr b/tests/ui/imports/ambiguous-reachable.stderr deleted file mode 100644 index 78a0d76d68b5..000000000000 --- a/tests/ui/imports/ambiguous-reachable.stderr +++ /dev/null @@ -1,23 +0,0 @@ -Future incompatibility report: Future breakage diagnostic: -warning: `generic` is ambiguous - --> $DIR/ambiguous-reachable.rs:7:33 - | -LL | ambiguous_reachable_extern::generic::(); - | ^^^^^^^ ambiguous name - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: ambiguous because of multiple glob imports of a name in the same module -note: `generic` could refer to the function defined here - --> $DIR/auxiliary/ambiguous-reachable-extern.rs:13:9 - | -LL | pub use m1::*; - | ^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `generic` could also refer to the function defined here - --> $DIR/auxiliary/ambiguous-reachable-extern.rs:14:9 - | -LL | pub use m2::*; - | ^^ - diff --git a/tests/ui/imports/ambiguous-trait-in-scope.rs b/tests/ui/imports/ambiguous-trait-in-scope.rs deleted file mode 100644 index d12276297396..000000000000 --- a/tests/ui/imports/ambiguous-trait-in-scope.rs +++ /dev/null @@ -1,84 +0,0 @@ -//@ edition:2018 -//@ aux-crate:external=ambiguous-trait-reexport.rs - -mod m1 { - pub trait Trait { - fn method1(&self) {} - } - impl Trait for u8 {} -} -mod m2 { - pub trait Trait { - fn method2(&self) {} - } - impl Trait for u8 {} -} -mod m1_reexport { - pub use crate::m1::Trait; -} -mod m2_reexport { - pub use crate::m2::Trait; -} - -mod ambig_reexport { - pub use crate::m1::*; - pub use crate::m2::*; -} - -fn test1() { - // Create an ambiguous import for `Trait` in one order - use m1::*; - use m2::*; - 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope -} - -fn test2() { - // Create an ambiguous import for `Trait` in another order - use m2::*; - use m1::*; - 0u8.method1(); //~ ERROR: no method named `method1` found for type `u8` in the current scope - 0u8.method2(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -} - -fn test_indirect_reexport() { - use m1_reexport::*; - use m2_reexport::*; - 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope -} - -fn test_ambig_reexport() { - use ambig_reexport::*; - 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope -} - -fn test_external() { - use external::m1::*; - use external::m2::*; - 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope -} - -fn test_external_indirect_reexport() { - use external::m1_reexport::*; - use external::m2_reexport::*; - 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope -} - -fn test_external_ambig_reexport() { - use external::ambig_reexport::*; - 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope -} - -fn main() {} diff --git a/tests/ui/imports/ambiguous-trait-in-scope.stderr b/tests/ui/imports/ambiguous-trait-in-scope.stderr deleted file mode 100644 index cac1f4bb73fb..000000000000 --- a/tests/ui/imports/ambiguous-trait-in-scope.stderr +++ /dev/null @@ -1,191 +0,0 @@ -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:32:9 - | -LL | use m1::*; - | -- `Trait` imported ambiguously here -LL | use m2::*; -LL | 0u8.method1(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - = note: `#[warn(ambiguous_glob_imported_traits)]` (part of `#[warn(future_incompatible)]`) on by default - -error[E0599]: no method named `method2` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:34:9 - | -LL | 0u8.method2(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m2::Trait; - | -LL + use crate::m2::Trait; - | - -error[E0599]: no method named `method1` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:41:9 - | -LL | 0u8.method1(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method1` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m1::Trait; - | -LL + use crate::m1::Trait; - | - -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:42:9 - | -LL | use m2::*; - | -- `Trait` imported ambiguously here -... -LL | 0u8.method2(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:49:9 - | -LL | use m1_reexport::*; - | ----------- `Trait` imported ambiguously here -LL | use m2_reexport::*; -LL | 0u8.method1(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - -error[E0599]: no method named `method2` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:51:9 - | -LL | 0u8.method2(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m2::Trait; - | -LL + use crate::m2::Trait; - | - -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:56:9 - | -LL | use ambig_reexport::*; - | -------------- `Trait` imported ambiguously here -LL | 0u8.method1(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - -error[E0599]: no method named `method2` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:58:9 - | -LL | 0u8.method2(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m2::Trait; - | -LL + use crate::m2::Trait; - | - -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:64:9 - | -LL | use external::m1::*; - | ------------ `Trait` imported ambiguously here -LL | use external::m2::*; -LL | 0u8.method1(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - -error[E0599]: no method named `method2` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:66:9 - | -LL | 0u8.method2(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m2::Trait; - | -LL + use crate::m2::Trait; - | - -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:72:9 - | -LL | use external::m1_reexport::*; - | --------------------- `Trait` imported ambiguously here -LL | use external::m2_reexport::*; -LL | 0u8.method1(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - -error[E0599]: no method named `method2` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:74:9 - | -LL | 0u8.method2(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m2::Trait; - | -LL + use crate::m2::Trait; - | - -warning: Use of ambiguously glob imported trait `Trait` - --> $DIR/ambiguous-trait-in-scope.rs:79:9 - | -LL | use external::ambig_reexport::*; - | ------------------------ `Trait` imported ambiguously here -LL | 0u8.method1(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #147992 - = help: Import `Trait` explicitly - -error[E0599]: no method named `method2` found for type `u8` in the current scope - --> $DIR/ambiguous-trait-in-scope.rs:81:9 - | -LL | 0u8.method2(); - | ^^^^^^^ method not found in `u8` - | - = help: items from traits can only be used if the trait is in scope -help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them - | -LL + use ambiguous_trait_reexport::m2::Trait; - | -LL + use crate::m2::Trait; - | - -error: aborting due to 7 previous errors; 7 warnings emitted - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/imports/auxiliary/ambiguous-reachable-extern.rs b/tests/ui/imports/auxiliary/ambiguous-reachable-extern.rs deleted file mode 100644 index af81812560e3..000000000000 --- a/tests/ui/imports/auxiliary/ambiguous-reachable-extern.rs +++ /dev/null @@ -1,14 +0,0 @@ -mod m1 { - pub fn generic() { - let x = 10; - let y = 11; - println!("hello {x} world {:?}", y); - } -} - -mod m2 { - pub fn generic() {} -} - -pub use m1::*; -pub use m2::*; diff --git a/tests/ui/imports/auxiliary/ambiguous-trait-reexport.rs b/tests/ui/imports/auxiliary/ambiguous-trait-reexport.rs deleted file mode 100644 index 77fb0c7d3934..000000000000 --- a/tests/ui/imports/auxiliary/ambiguous-trait-reexport.rs +++ /dev/null @@ -1,23 +0,0 @@ -pub mod m1 { - pub trait Trait { - fn method1(&self) {} - } - impl Trait for u8 {} -} -pub mod m2 { - pub trait Trait { - fn method2(&self) {} - } - impl Trait for u8 {} -} -pub mod m1_reexport { - pub use crate::m1::Trait; -} -pub mod m2_reexport { - pub use crate::m2::Trait; -} - -pub mod ambig_reexport { - pub use crate::m1::*; - pub use crate::m2::*; -} diff --git a/tests/ui/imports/extern-prelude-extern-crate-fail.rs b/tests/ui/imports/extern-prelude-extern-crate-fail.rs index 7412706dcf39..84751ecc02b6 100644 --- a/tests/ui/imports/extern-prelude-extern-crate-fail.rs +++ b/tests/ui/imports/extern-prelude-extern-crate-fail.rs @@ -7,7 +7,7 @@ mod n { mod m { fn check() { - two_macros::m!(); //~ ERROR cannot find + two_macros::m!(); //~ ERROR failed to resolve: use of unresolved module or unlinked crate `two_macros` } } diff --git a/tests/ui/imports/extern-prelude-extern-crate-fail.stderr b/tests/ui/imports/extern-prelude-extern-crate-fail.stderr index 42735ff90c90..ec53730afa02 100644 --- a/tests/ui/imports/extern-prelude-extern-crate-fail.stderr +++ b/tests/ui/imports/extern-prelude-extern-crate-fail.stderr @@ -9,7 +9,7 @@ LL | define_std_as_non_existent!(); | = note: this error originates in the macro `define_std_as_non_existent` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0433]: cannot find module or crate `two_macros` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `two_macros` --> $DIR/extern-prelude-extern-crate-fail.rs:10:9 | LL | two_macros::m!(); diff --git a/tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2015.stderr b/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2015.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2015.stderr rename to tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2015.stderr diff --git a/tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2021.stderr b/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr similarity index 100% rename from tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2021.stderr rename to tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr diff --git a/tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.rs b/tests/ui/imports/multiple-extern-by-macro-for-underscore.rs similarity index 100% rename from tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.rs rename to tests/ui/imports/multiple-extern-by-macro-for-underscore.rs diff --git a/tests/ui/imports/nested-import-root-symbol-150103.rs b/tests/ui/imports/nested-import-root-symbol-150103.rs index 7e126d8188c7..066ed37d8bbb 100644 --- a/tests/ui/imports/nested-import-root-symbol-150103.rs +++ b/tests/ui/imports/nested-import-root-symbol-150103.rs @@ -3,11 +3,11 @@ // caused by `{{root}}` appearing in diagnostic suggestions mod A { - use Iuse::{ ::Fish }; //~ ERROR cannot find module or crate `Iuse` in the crate root + use Iuse::{ ::Fish }; //~ ERROR failed to resolve: use of unresolved module or unlinked crate } mod B { - use A::{::Fish}; //~ ERROR the crate root in paths can only be used in start position + use A::{::Fish}; //~ ERROR failed to resolve: crate root in paths can only be used in start position } fn main() {} diff --git a/tests/ui/imports/nested-import-root-symbol-150103.stderr b/tests/ui/imports/nested-import-root-symbol-150103.stderr index e5240ceef268..be8b8c12d218 100644 --- a/tests/ui/imports/nested-import-root-symbol-150103.stderr +++ b/tests/ui/imports/nested-import-root-symbol-150103.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `Iuse` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `Iuse` --> $DIR/nested-import-root-symbol-150103.rs:6:9 | LL | use Iuse::{ ::Fish }; @@ -9,11 +9,11 @@ help: you might be missing a crate named `Iuse`, add it to your project and impo LL + extern crate Iuse; | -error[E0433]: the crate root in paths can only be used in start position +error[E0433]: failed to resolve: crate root in paths can only be used in start position --> $DIR/nested-import-root-symbol-150103.rs:10:13 | LL | use A::{::Fish}; - | ^ can only be used in path start position + | ^ crate root in paths can only be used in start position error: aborting due to 2 previous errors diff --git a/tests/ui/imports/no-ambiguous-trait-lint-on-redundant-import.rs b/tests/ui/imports/no-ambiguous-trait-lint-on-redundant-import.rs deleted file mode 100644 index ee08fd8ea800..000000000000 --- a/tests/ui/imports/no-ambiguous-trait-lint-on-redundant-import.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ check-pass -// The AMBIGUOUS_GLOB_IMPORTED_TRAITS lint is reported on uses of traits that are -// ambiguously glob imported. This test checks that we don't report this lint -// when the same trait is glob imported multiple times. - -mod t { - pub trait Trait { - fn method(&self) {} - } - - impl Trait for i8 {} -} - -mod m1 { - pub use t::Trait; -} - -mod m2 { - pub use t::Trait; -} - -use m1::*; -use m2::*; - -fn main() { - 0i8.method(); -} diff --git a/tests/ui/imports/overwrite-different-vis-3.rs b/tests/ui/imports/overwrite-different-vis-3.rs deleted file mode 100644 index f45c5cdfb3ab..000000000000 --- a/tests/ui/imports/overwrite-different-vis-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Regression test for issue #152606. - -//@ check-pass - -mod outer { - mod inner { - use super::*; // should go before the ambiguous glob imports - } - - use crate::*; - pub use crate::*; -} - -fn main() {} diff --git a/tests/ui/imports/suggest-import-issue-120074.edition2015.stderr b/tests/ui/imports/suggest-import-issue-120074.edition2015.stderr index b079471e809c..91fad1fb3099 100644 --- a/tests/ui/imports/suggest-import-issue-120074.edition2015.stderr +++ b/tests/ui/imports/suggest-import-issue-120074.edition2015.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `bar` in `crate` +error[E0433]: failed to resolve: unresolved import --> $DIR/suggest-import-issue-120074.rs:14:35 | LL | println!("Hello, {}!", crate::bar::do_the_thing); diff --git a/tests/ui/imports/suggest-import-issue-120074.edition2021.stderr b/tests/ui/imports/suggest-import-issue-120074.edition2021.stderr new file mode 100644 index 000000000000..91fad1fb3099 --- /dev/null +++ b/tests/ui/imports/suggest-import-issue-120074.edition2021.stderr @@ -0,0 +1,23 @@ +error[E0433]: failed to resolve: unresolved import + --> $DIR/suggest-import-issue-120074.rs:14:35 + | +LL | println!("Hello, {}!", crate::bar::do_the_thing); + | ^^^ unresolved import + | +help: a similar path exists + | +LL | println!("Hello, {}!", crate::foo::bar::do_the_thing); + | +++++ +help: consider importing this module + | +LL + use foo::bar; + | +help: if you import `bar`, refer to it directly + | +LL - println!("Hello, {}!", crate::bar::do_the_thing); +LL + println!("Hello, {}!", bar::do_the_thing); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/imports/suggest-import-issue-120074.post2015.stderr b/tests/ui/imports/suggest-import-issue-120074.post2015.stderr index 045a7df3feea..f334fb31a3dc 100644 --- a/tests/ui/imports/suggest-import-issue-120074.post2015.stderr +++ b/tests/ui/imports/suggest-import-issue-120074.post2015.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `bar` in `crate` +error[E0433]: failed to resolve: unresolved import --> $DIR/suggest-import-issue-120074.rs:14:35 | LL | println!("Hello, {}!", crate::bar::do_the_thing); diff --git a/tests/ui/imports/suggest-import-issue-120074.rs b/tests/ui/imports/suggest-import-issue-120074.rs index 27027405f4de..4ca0d52b1f3e 100644 --- a/tests/ui/imports/suggest-import-issue-120074.rs +++ b/tests/ui/imports/suggest-import-issue-120074.rs @@ -11,5 +11,5 @@ pub mod foo { } fn main() { - println!("Hello, {}!", crate::bar::do_the_thing); //~ ERROR cannot find `bar` in `crate` + println!("Hello, {}!", crate::bar::do_the_thing); //~ ERROR failed to resolve: unresolved import } diff --git a/tests/ui/imports/tool-mod-child.rs b/tests/ui/imports/tool-mod-child.rs index 6f67d200c2d7..c0978046719a 100644 --- a/tests/ui/imports/tool-mod-child.rs +++ b/tests/ui/imports/tool-mod-child.rs @@ -1,8 +1,8 @@ //@ edition:2015 use clippy::a; //~ ERROR unresolved import `clippy` -use clippy::a::b; //~ ERROR cannot find +use clippy::a::b; //~ ERROR failed to resolve: use of unresolved module or unlinked crate `clippy` use rustdoc::a; //~ ERROR unresolved import `rustdoc` -use rustdoc::a::b; //~ ERROR cannot find +use rustdoc::a::b; //~ ERROR failed to resolve: use of unresolved module or unlinked crate `rustdoc` fn main() {} diff --git a/tests/ui/imports/tool-mod-child.stderr b/tests/ui/imports/tool-mod-child.stderr index babb5e21cbf7..3e216c492d34 100644 --- a/tests/ui/imports/tool-mod-child.stderr +++ b/tests/ui/imports/tool-mod-child.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `clippy` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `clippy` --> $DIR/tool-mod-child.rs:3:5 | LL | use clippy::a::b; @@ -20,7 +20,7 @@ help: you might be missing a crate named `clippy`, add it to your project and im LL + extern crate clippy; | -error[E0433]: cannot find module or crate `rustdoc` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rustdoc` --> $DIR/tool-mod-child.rs:6:5 | LL | use rustdoc::a::b; diff --git a/tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.rs b/tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.rs deleted file mode 100644 index b13b6f418d42..000000000000 --- a/tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::rc::Rc; -pub struct Foo; - -pub type Function = Rc; - -impl Function {} -//~^ ERROR cannot define inherent `impl` for a type outside of the crate where the type is defined [E0116] -fn main(){} diff --git a/tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.stderr b/tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.stderr deleted file mode 100644 index a62f7f82ba9d..000000000000 --- a/tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined - --> $DIR/insufficient-suggestion-issue-141679.rs:6:1 - | -LL | impl Function {} - | ^^^^^^^^^^^^^ impl for type defined outside of crate - | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see -note: `Function` does not define a new type, only an alias of `Rc` defined here - --> $DIR/insufficient-suggestion-issue-141679.rs:4:1 - | -LL | pub type Function = Rc; - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0116`. diff --git a/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr b/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr index de61c3900d46..f8491697910c 100644 --- a/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr +++ b/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr @@ -4,8 +4,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl extern_crate::StructWithAttr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined --> $DIR/no-attr-empty-impl.rs:7:1 @@ -13,8 +12,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl extern_crate::StructNoAttr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined --> $DIR/no-attr-empty-impl.rs:10:1 @@ -22,8 +20,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl extern_crate::EnumWithAttr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined --> $DIR/no-attr-empty-impl.rs:13:1 @@ -31,8 +28,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl extern_crate::EnumNoAttr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error[E0390]: cannot define inherent `impl` for primitive types --> $DIR/no-attr-empty-impl.rs:16:1 diff --git a/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr b/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr index f01817e29443..2a33262f8389 100644 --- a/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr +++ b/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr @@ -4,8 +4,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl Vec {} | ^^^^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error: aborting due to 1 previous error diff --git a/tests/ui/indexing/indexing-requires-a-uint.stderr b/tests/ui/indexing/indexing-requires-a-uint.stderr index e5f9f7854f7b..7bfb678df5fc 100644 --- a/tests/ui/indexing/indexing-requires-a-uint.stderr +++ b/tests/ui/indexing/indexing-requires-a-uint.stderr @@ -13,6 +13,8 @@ help: the following other types implement trait `SliceIndex` | = note: `usize` implements `SliceIndex` = note: required for `[{integer}]` to implement `Index` + = note: 1 redundant requirement hidden + = note: required for `[{integer}; 1]` to implement `Index` error[E0308]: mismatched types --> $DIR/indexing-requires-a-uint.rs:12:18 diff --git a/tests/ui/indexing/point-at-index-for-obligation-failure.rs b/tests/ui/indexing/point-at-index-for-obligation-failure.rs index 4ff9069936fe..e9c429b53ced 100644 --- a/tests/ui/indexing/point-at-index-for-obligation-failure.rs +++ b/tests/ui/indexing/point-at-index-for-obligation-failure.rs @@ -1,7 +1,7 @@ fn main() { let a = std::collections::HashMap::::new(); let s = "hello"; - let _b = a[ //~ ERROR E0277 - &s + let _b = a[ + &s //~ ERROR E0277 ]; } diff --git a/tests/ui/indexing/point-at-index-for-obligation-failure.stderr b/tests/ui/indexing/point-at-index-for-obligation-failure.stderr index 22f48d61985f..a221e4337891 100644 --- a/tests/ui/indexing/point-at-index-for-obligation-failure.stderr +++ b/tests/ui/indexing/point-at-index-for-obligation-failure.stderr @@ -1,11 +1,8 @@ error[E0277]: the trait bound `String: Borrow<&str>` is not satisfied - --> $DIR/point-at-index-for-obligation-failure.rs:4:14 + --> $DIR/point-at-index-for-obligation-failure.rs:5:9 | -LL | let _b = a[ - | ______________^ -LL | | &s -LL | | ]; - | |_____^ the trait `Borrow<&str>` is not implemented for `String` +LL | &s + | ^^ the trait `Borrow<&str>` is not implemented for `String` | help: the trait `Borrow<&_>` is not implemented for `String` but trait `Borrow<_>` is implemented for it diff --git a/tests/ui/inference/issue-72616.stderr b/tests/ui/inference/issue-72616.stderr index 8eba3216a846..6b47d5688113 100644 --- a/tests/ui/inference/issue-72616.stderr +++ b/tests/ui/inference/issue-72616.stderr @@ -8,11 +8,8 @@ LL | if String::from("a") == "a".try_into().unwrap() {} | = note: multiple `impl`s satisfying `String: PartialEq<_>` found in the following crates: `alloc`, `std`: - impl PartialEq for String; - - impl PartialEq for String; - - impl PartialEq for String; - impl PartialEq for String; - impl PartialEq for String; - - impl PartialEq for String; help: try using a fully qualified path to specify the expected types | LL - if String::from("a") == "a".try_into().unwrap() {} diff --git a/tests/ui/inference/iterator-sum-array-15673.rs b/tests/ui/inference/iterator-sum-array-15673.rs index b8d9fd994218..c3d94415affd 100644 --- a/tests/ui/inference/iterator-sum-array-15673.rs +++ b/tests/ui/inference/iterator-sum-array-15673.rs @@ -1,6 +1,9 @@ //! Regression test for https://github.com/rust-lang/rust/issues/15673 //@ run-pass +#![allow(stable_features)] + +#![feature(iter_arith)] fn main() { let x: [u64; 3] = [1, 2, 3]; diff --git a/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr b/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr index ff668f88d4d1..3de317d2af6d 100644 --- a/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr +++ b/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr @@ -3,6 +3,8 @@ error[E0282]: type annotations needed | LL | println!("{:?}", []); | ^^ cannot infer type + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/inline-const/dont-eval-const-block-during-promotion.fail.stderr b/tests/ui/inline-const/dont-eval-const-block-during-promotion.fail.stderr deleted file mode 100644 index a4d133cbc011..000000000000 --- a/tests/ui/inline-const/dont-eval-const-block-during-promotion.fail.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont-eval-const-block-during-promotion.rs:48:14 - | -LL | x = &([0][const { 0 }] & 0); - | ^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | (x, y, z); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont-eval-const-block-during-promotion.rs:50:14 - | -LL | y = &(1 / const { 1 }); - | ^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | (x, y, z); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont-eval-const-block-during-promotion.rs:52:14 - | -LL | z = &(const { 1 } / -1); - | ^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -LL | -LL | (x, y, z); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/inline-const/dont-eval-const-block-during-promotion.rs b/tests/ui/inline-const/dont-eval-const-block-during-promotion.rs deleted file mode 100644 index 3ecf7acf8edc..000000000000 --- a/tests/ui/inline-const/dont-eval-const-block-during-promotion.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! Test for #150464: as of #138499, trying to evaluate const blocks during constant promotion will -//! result in a query cycle, so we shouldn't do it. Evaluation can happen when trying to promote -//! integer division and array indexing, where it's necessary for the operation to succeed to be -//! able to use it in a promoted constant. -//@ revisions: pass fail -//@[pass] check-pass - -use std::mem::offset_of; - -struct Thing(i32); - -fn main() { - // For a temporary involving array indexing to be promoted, we evaluate the index to make sure - // it's in-bounds. As of #150557 we treat inline constants as maybe-out-of-bounds to avoid the - // query cycle from evaluating them. That allows this to compile: - let x = &([0][const { 0 }] & 0); - // Likewise, integer divisors must be nonzero. Avoiding the query cycle allows this to compile: - let y = &(1 / const { 1 }); - // Likewise, signed integer dividends can't be the integer minimum when the divisor is -1. - let z = &(const { 1 } / -1); - // These temporaries are all lifetime-extended, so they don't need to be promoted for references - // to them to be live later in the block. Generally, code with const blocks in these positions - // should compile as long as being promoted isn't necessary for borrow-checking to succeed. - (x, y, z); - - // A reduced example from real code (#150464): this can't be promoted since the array is a local - // variable, but it still resulted in a query cycle because the index was evaluated for the - // bounds-check before checking that. By not evaluating the const block, we avoid the cycle. - // Since this doesn't rely on promotion, it should borrow-check successfully. - let temp = [0u8]; - let _ = &(temp[const { 0usize }] & 0u8); - // #150464 was reported because `offset_of!` started desugaring to a const block in #148151. - let _ = &(temp[offset_of!(Thing, 0)] & 0u8); - - // Similarly, at the time #150464 was reported, the index here was evaluated before checking - // that the indexed expression is an array. As above, this can't be promoted, but still resulted - // in a query cycle. By not evaluating the const block, we avoid the cycle. Since this doesn't - // rely on promotion, it should borrow-check successfully. - let temp: &[u8] = &[0u8]; - let _ = &(temp[const { 0usize }] & 0u8); - - // By no longer promoting these temporaries, they're dropped at the ends of their respective - // statements, so we can't refer to them thereafter. This code no longer query-cycles, but it - // fails to borrow-check instead. - #[cfg(fail)] - { - let (x, y, z); - x = &([0][const { 0 }] & 0); - //[fail]~^ ERROR: temporary value dropped while borrowed - y = &(1 / const { 1 }); - //[fail]~^ ERROR: temporary value dropped while borrowed - z = &(const { 1 } / -1); - //[fail]~^ ERROR: temporary value dropped while borrowed - (x, y, z); - } - - // Sanity check: those temporaries do promote if the const blocks are removed. - // If constant promotion is changed so that these are no longer implicitly promoted, the - // comments on this test file should be reworded to reflect that. - let (x, y, z); - x = &([0][0] & 0); - y = &(1 / 1); - z = &(1 / -1); - (x, y, z); -} diff --git a/tests/ui/inline-const/in-pat-recovery.rs b/tests/ui/inline-const/in-pat-recovery.rs index 037c58d3bf98..d519217fad3b 100644 --- a/tests/ui/inline-const/in-pat-recovery.rs +++ b/tests/ui/inline-const/in-pat-recovery.rs @@ -4,63 +4,63 @@ fn main() { match 1 { const { 1 + 7 } => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns 2 => {} _ => {} } match 5 { const { 1 } ..= 10 => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { 1 ..= const { 10 } => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { const { 1 } ..= const { 10 } => {} - //~^ ERROR const blocks cannot be used as patterns - //~| ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns + //~| ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { const { 1 } .. 10 => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { 1 .. const { 10 } => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { const { 1 + 2 } ..= 10 => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { 1 ..= const { 5 + 5 } => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { const { 3 } .. => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } match 5 { ..= const { 7 } => {} - //~^ ERROR const blocks cannot be used as patterns + //~^ ERROR arbitrary expressions aren't allowed in patterns _ => {} } } diff --git a/tests/ui/inline-const/in-pat-recovery.stderr b/tests/ui/inline-const/in-pat-recovery.stderr index 55adb5c49a6d..376c43aaecca 100644 --- a/tests/ui/inline-const/in-pat-recovery.stderr +++ b/tests/ui/inline-const/in-pat-recovery.stderr @@ -1,88 +1,88 @@ -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:6:15 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:6:9 | LL | const { 1 + 7 } => {} - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:13:15 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:13:9 | LL | const { 1 } ..= 10 => {} - | ^^^^^ + | ^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:19:21 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:19:15 | LL | 1 ..= const { 10 } => {} - | ^^^^^^ + | ^^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:25:15 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:25:9 | LL | const { 1 } ..= const { 10 } => {} - | ^^^^^ + | ^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:25:31 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:25:25 | LL | const { 1 } ..= const { 10 } => {} - | ^^^^^^ + | ^^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:32:15 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:32:9 | LL | const { 1 } .. 10 => {} - | ^^^^^ + | ^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:38:20 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:38:14 | LL | 1 .. const { 10 } => {} - | ^^^^^^ + | ^^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:44:15 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:44:9 | LL | const { 1 + 2 } ..= 10 => {} - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:50:21 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:50:15 | LL | 1 ..= const { 5 + 5 } => {} - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:56:15 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:56:9 | LL | const { 3 } .. => {} - | ^^^^^ + | ^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error: const blocks cannot be used as patterns - --> $DIR/in-pat-recovery.rs:62:19 +error: arbitrary expressions aren't allowed in patterns + --> $DIR/in-pat-recovery.rs:62:13 | LL | ..= const { 7 } => {} - | ^^^^^ + | ^^^^^^^^^^^ | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead diff --git a/tests/ui/inline-const/reject-const-block-pat-pre-expansion.rs b/tests/ui/inline-const/reject-const-block-pat-pre-expansion.rs deleted file mode 100644 index 9af4925c0432..000000000000 --- a/tests/ui/inline-const/reject-const-block-pat-pre-expansion.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Regression test for : reject inline const -//! patterns pre-expansion when possible. - -macro_rules! analyze { ($p:pat) => {}; } -analyze!(const { 0 }); -//~^ ERROR: const blocks cannot be used as patterns - -#[cfg(false)] -fn scope() { let const { 0 }; } -//~^ ERROR: const blocks cannot be used as patterns - -fn main() {} diff --git a/tests/ui/inline-const/reject-const-block-pat-pre-expansion.stderr b/tests/ui/inline-const/reject-const-block-pat-pre-expansion.stderr deleted file mode 100644 index 034b97699396..000000000000 --- a/tests/ui/inline-const/reject-const-block-pat-pre-expansion.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: const blocks cannot be used as patterns - --> $DIR/reject-const-block-pat-pre-expansion.rs:9:24 - | -LL | fn scope() { let const { 0 }; } - | ^^^^^ - | - = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead - -error: const blocks cannot be used as patterns - --> $DIR/reject-const-block-pat-pre-expansion.rs:5:16 - | -LL | analyze!(const { 0 }); - | ^^^^^ - | - = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead - -error: aborting due to 2 previous errors - diff --git a/tests/ui/instrument-coverage/coverage-options.rs b/tests/ui/instrument-coverage/coverage-options.rs index 091ccdf38a08..ead2e3221d8c 100644 --- a/tests/ui/instrument-coverage/coverage-options.rs +++ b/tests/ui/instrument-coverage/coverage-options.rs @@ -1,5 +1,5 @@ //@ revisions: block branch condition bad -//@ compile-flags: -Cinstrument-coverage -Zno-profiler-runtime +//@ compile-flags -Cinstrument-coverage -Zno-profiler-runtime //@ [block] check-pass //@ [block] compile-flags: -Zcoverage-options=block diff --git a/tests/ui/internal-lints/diagnostics_incorrect.rs b/tests/ui/internal-lints/diagnostics_incorrect.rs new file mode 100644 index 000000000000..787acdad3884 --- /dev/null +++ b/tests/ui/internal-lints/diagnostics_incorrect.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Z unstable-options + +#![feature(rustc_attrs)] + +#[rustc_lint_diagnostics] +//~^ ERROR `#[rustc_lint_diagnostics]` attribute cannot be used on structs +struct Foo; + +impl Foo { + #[rustc_lint_diagnostics(a)] + //~^ ERROR malformed `rustc_lint_diagnostics` + fn bar() {} +} + +fn main() {} diff --git a/tests/ui/internal-lints/diagnostics_incorrect.stderr b/tests/ui/internal-lints/diagnostics_incorrect.stderr new file mode 100644 index 000000000000..4d509acec790 --- /dev/null +++ b/tests/ui/internal-lints/diagnostics_incorrect.stderr @@ -0,0 +1,20 @@ +error: `#[rustc_lint_diagnostics]` attribute cannot be used on structs + --> $DIR/diagnostics_incorrect.rs:5:1 + | +LL | #[rustc_lint_diagnostics] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_lint_diagnostics]` can only be applied to functions + +error[E0565]: malformed `rustc_lint_diagnostics` attribute input + --> $DIR/diagnostics_incorrect.rs:10:5 + | +LL | #[rustc_lint_diagnostics(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_lint_diagnostics]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0565`. diff --git a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr index aee60c94f106..397eeaf600ad 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr @@ -1,4 +1,4 @@ thread 'main' ($TID) panicked at $DIR/const-eval-select-backtrace-std.rs:6:8: -start byte index 1 is out of bounds of `` +byte index 1 is out of bounds of `` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/invalid/invalid-crate-type.rs b/tests/ui/invalid/invalid-crate-type.rs index c233e7d5e3db..6c44c3b4f2b1 100644 --- a/tests/ui/invalid/invalid-crate-type.rs +++ b/tests/ui/invalid/invalid-crate-type.rs @@ -26,7 +26,7 @@ #![crate_type="dlib"] //~^ ERROR invalid `crate_type` value //~| HELP did you mean -//~| SUGGESTION lib +//~| SUGGESTION rlib #![crate_type="lob"] //~^ ERROR invalid `crate_type` value diff --git a/tests/ui/invalid/invalid-crate-type.stderr b/tests/ui/invalid/invalid-crate-type.stderr index 3eae04678b4a..59d5d7bc9bbf 100644 --- a/tests/ui/invalid/invalid-crate-type.stderr +++ b/tests/ui/invalid/invalid-crate-type.stderr @@ -34,7 +34,7 @@ error: invalid `crate_type` value --> $DIR/invalid-crate-type.rs:26:15 | LL | #![crate_type="dlib"] - | ^^^^^^ help: did you mean: `"lib"` + | ^^^^^^ help: did you mean: `"rlib"` error: invalid `crate_type` value --> $DIR/invalid-crate-type.rs:31:15 diff --git a/tests/ui/issues/auxiliary/issue-11529.rs b/tests/ui/issues/auxiliary/issue-11529.rs new file mode 100644 index 000000000000..dd3ef4387057 --- /dev/null +++ b/tests/ui/issues/auxiliary/issue-11529.rs @@ -0,0 +1 @@ +pub struct A<'a>(pub &'a isize); diff --git a/tests/ui/privacy/auxiliary/imported-enum-is-private.rs b/tests/ui/issues/auxiliary/issue-11680.rs similarity index 53% rename from tests/ui/privacy/auxiliary/imported-enum-is-private.rs rename to tests/ui/issues/auxiliary/issue-11680.rs index ea847d9aff13..74abbf0bf8cd 100644 --- a/tests/ui/privacy/auxiliary/imported-enum-is-private.rs +++ b/tests/ui/issues/auxiliary/issue-11680.rs @@ -1,5 +1,3 @@ -//! auxiliary crate for - enum Foo { Bar(isize) } diff --git a/tests/ui/issues/issue-11529.rs b/tests/ui/issues/issue-11529.rs new file mode 100644 index 000000000000..73940c22be4c --- /dev/null +++ b/tests/ui/issues/issue-11529.rs @@ -0,0 +1,10 @@ +//@ run-pass +//@ aux-build:issue-11529.rs + + +extern crate issue_11529 as a; + +fn main() { + let one = 1; + let _a = a::A(&one); +} diff --git a/tests/ui/privacy/imported-enum-is-private.rs b/tests/ui/issues/issue-11680.rs similarity index 50% rename from tests/ui/privacy/imported-enum-is-private.rs rename to tests/ui/issues/issue-11680.rs index b628676a25c6..9f3dfebcc812 100644 --- a/tests/ui/privacy/imported-enum-is-private.rs +++ b/tests/ui/issues/issue-11680.rs @@ -1,7 +1,6 @@ -//! regression test for -//@ aux-build:imported-enum-is-private.rs +//@ aux-build:issue-11680.rs -extern crate imported_enum_is_private as other; +extern crate issue_11680 as other; fn main() { let _b = other::Foo::Bar(1); diff --git a/tests/ui/privacy/imported-enum-is-private.stderr b/tests/ui/issues/issue-11680.stderr similarity index 79% rename from tests/ui/privacy/imported-enum-is-private.stderr rename to tests/ui/issues/issue-11680.stderr index cae1ebb0e29e..5bcf93de811f 100644 --- a/tests/ui/privacy/imported-enum-is-private.stderr +++ b/tests/ui/issues/issue-11680.stderr @@ -1,5 +1,5 @@ error[E0603]: enum `Foo` is private - --> $DIR/imported-enum-is-private.rs:7:21 + --> $DIR/issue-11680.rs:6:21 | LL | let _b = other::Foo::Bar(1); | ^^^ --- tuple variant `Bar` is not publicly re-exported @@ -7,13 +7,13 @@ LL | let _b = other::Foo::Bar(1); | private enum | note: the enum `Foo` is defined here - --> $DIR/auxiliary/imported-enum-is-private.rs:3:1 + --> $DIR/auxiliary/issue-11680.rs:1:1 | LL | enum Foo { | ^^^^^^^^ error[E0603]: enum `Foo` is private - --> $DIR/imported-enum-is-private.rs:10:27 + --> $DIR/issue-11680.rs:9:27 | LL | let _b = other::test::Foo::Bar(1); | ^^^ --- tuple variant `Bar` is not publicly re-exported @@ -21,7 +21,7 @@ LL | let _b = other::test::Foo::Bar(1); | private enum | note: the enum `Foo` is defined here - --> $DIR/auxiliary/imported-enum-is-private.rs:8:5 + --> $DIR/auxiliary/issue-11680.rs:6:5 | LL | enum Foo { | ^^^^^^^^ diff --git a/tests/ui/lifetimes/unit-struct-as-rvalue.rs b/tests/ui/issues/issue-11681.rs similarity index 84% rename from tests/ui/lifetimes/unit-struct-as-rvalue.rs rename to tests/ui/issues/issue-11681.rs index 10c1d2517064..6d8810d80520 100644 --- a/tests/ui/lifetimes/unit-struct-as-rvalue.rs +++ b/tests/ui/issues/issue-11681.rs @@ -1,4 +1,3 @@ -//! regression test for // This tests verifies that unary structs and enum variants // are treated as rvalues and their lifetime is not bounded to // the static scope. diff --git a/tests/ui/lifetimes/unit-struct-as-rvalue.stderr b/tests/ui/issues/issue-11681.stderr similarity index 89% rename from tests/ui/lifetimes/unit-struct-as-rvalue.stderr rename to tests/ui/issues/issue-11681.stderr index afb80331f356..4f23ba86eecc 100644 --- a/tests/ui/lifetimes/unit-struct-as-rvalue.stderr +++ b/tests/ui/issues/issue-11681.stderr @@ -1,5 +1,5 @@ error[E0515]: cannot return value referencing temporary value - --> $DIR/unit-struct-as-rvalue.rs:14:10 + --> $DIR/issue-11681.rs:13:10 | LL | let testValue = &Test; | ---- temporary value created here diff --git a/tests/ui/match/match-tuple-slice.rs b/tests/ui/issues/issue-16648.rs similarity index 75% rename from tests/ui/match/match-tuple-slice.rs rename to tests/ui/issues/issue-16648.rs index aaebf4401d09..7f3d3217bee0 100644 --- a/tests/ui/match/match-tuple-slice.rs +++ b/tests/ui/issues/issue-16648.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass fn main() { let x: (isize, &[isize]) = (2, &[1, 2]); diff --git a/tests/ui/pattern/match-constant-and-byte-literal.rs b/tests/ui/issues/issue-16745.rs similarity index 71% rename from tests/ui/pattern/match-constant-and-byte-literal.rs rename to tests/ui/issues/issue-16745.rs index 7a793478016d..99c85bcffcf8 100644 --- a/tests/ui/pattern/match-constant-and-byte-literal.rs +++ b/tests/ui/issues/issue-16745.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass fn main() { const X: u8 = 0; diff --git a/tests/ui/cfg/struct-field-empty.rs b/tests/ui/issues/issue-16819.rs similarity index 70% rename from tests/ui/cfg/struct-field-empty.rs rename to tests/ui/issues/issue-16819.rs index eed69a0c03f0..2805c82acfb2 100644 --- a/tests/ui/cfg/struct-field-empty.rs +++ b/tests/ui/issues/issue-16819.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass #![allow(unused_variables)] // `#[cfg]` on struct field permits empty unusable struct diff --git a/tests/ui/type-inference/panic-with-unspecified-type.rs b/tests/ui/issues/issue-16966.rs similarity index 62% rename from tests/ui/type-inference/panic-with-unspecified-type.rs rename to tests/ui/issues/issue-16966.rs index 0f96759e8144..66a3fadac8d9 100644 --- a/tests/ui/type-inference/panic-with-unspecified-type.rs +++ b/tests/ui/issues/issue-16966.rs @@ -1,4 +1,3 @@ -//! regression test for //@ edition:2015..2021 fn main() { panic!(std::default::Default::default()); diff --git a/tests/ui/type-inference/panic-with-unspecified-type.stderr b/tests/ui/issues/issue-16966.stderr similarity index 81% rename from tests/ui/type-inference/panic-with-unspecified-type.stderr rename to tests/ui/issues/issue-16966.stderr index cd8485f392bc..e294d8830de0 100644 --- a/tests/ui/type-inference/panic-with-unspecified-type.stderr +++ b/tests/ui/issues/issue-16966.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/panic-with-unspecified-type.rs:4:12 + --> $DIR/issue-16966.rs:3:12 | LL | panic!(std::default::Default::default()); | -------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | panic!(std::default::Default::default()); | required by a bound introduced by this call | = note: cannot satisfy `_: Any` -note: required by a bound in `std::rt::begin_panic` +note: required by a bound in `begin_panic` --> $SRC_DIR/std/src/panicking.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/for-loop-region-links.rs b/tests/ui/issues/issue-17068.rs similarity index 77% rename from tests/ui/lifetimes/for-loop-region-links.rs rename to tests/ui/issues/issue-17068.rs index 0c86c211a00b..af565da3366b 100644 --- a/tests/ui/lifetimes/for-loop-region-links.rs +++ b/tests/ui/issues/issue-17068.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass // Test that regionck creates the right region links in the pattern // binding of a for loop diff --git a/tests/ui/lint/unused/unused-trait-fn.rs b/tests/ui/issues/issue-17351.rs similarity index 72% rename from tests/ui/lint/unused/unused-trait-fn.rs rename to tests/ui/issues/issue-17351.rs index 57b39c0de17e..86049377198c 100644 --- a/tests/ui/lint/unused/unused-trait-fn.rs +++ b/tests/ui/issues/issue-17351.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass trait Str { fn foo(&self) {} } //~ WARN method `foo` is never used diff --git a/tests/ui/lint/unused/unused-trait-fn.stderr b/tests/ui/issues/issue-17351.stderr similarity index 87% rename from tests/ui/lint/unused/unused-trait-fn.stderr rename to tests/ui/issues/issue-17351.stderr index f33fed29c94c..043d4ffc7808 100644 --- a/tests/ui/lint/unused/unused-trait-fn.stderr +++ b/tests/ui/issues/issue-17351.stderr @@ -1,5 +1,5 @@ warning: method `foo` is never used - --> $DIR/unused-trait-fn.rs:4:16 + --> $DIR/issue-17351.rs:3:16 | LL | trait Str { fn foo(&self) {} } | --- ^^^ diff --git a/tests/ui/cast/cast-to-unsized-type.rs b/tests/ui/issues/issue-17441.rs similarity index 86% rename from tests/ui/cast/cast-to-unsized-type.rs rename to tests/ui/issues/issue-17441.rs index 4c7ca49fd98d..e5f83c4ebadd 100644 --- a/tests/ui/cast/cast-to-unsized-type.rs +++ b/tests/ui/issues/issue-17441.rs @@ -1,5 +1,3 @@ -//! regression test for - fn main() { let _foo = &[1_usize, 2] as [usize]; //~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]` diff --git a/tests/ui/cast/cast-to-unsized-type.stderr b/tests/ui/issues/issue-17441.stderr similarity index 85% rename from tests/ui/cast/cast-to-unsized-type.stderr rename to tests/ui/issues/issue-17441.stderr index 087cfac77484..96aad879e24d 100644 --- a/tests/ui/cast/cast-to-unsized-type.stderr +++ b/tests/ui/issues/issue-17441.stderr @@ -1,5 +1,5 @@ error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` - --> $DIR/cast-to-unsized-type.rs:4:16 + --> $DIR/issue-17441.rs:2:16 | LL | let _foo = &[1_usize, 2] as [usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | let _foo = &[1_usize, 2] as &[usize]; | + error[E0620]: cast to unsized type: `Box` as `dyn Debug` - --> $DIR/cast-to-unsized-type.rs:7:16 + --> $DIR/issue-17441.rs:5:16 | LL | let _bar = Box::new(1_usize) as dyn std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,25 +21,25 @@ LL | let _bar = Box::new(1_usize) as Box; | ++++ + error[E0620]: cast to unsized type: `usize` as `dyn Debug` - --> $DIR/cast-to-unsized-type.rs:10:16 + --> $DIR/issue-17441.rs:8:16 | LL | let _baz = 1_usize as dyn std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider using a box or reference as appropriate - --> $DIR/cast-to-unsized-type.rs:10:16 + --> $DIR/issue-17441.rs:8:16 | LL | let _baz = 1_usize as dyn std::fmt::Debug; | ^^^^^^^ error[E0620]: cast to unsized type: `[usize; 2]` as `[usize]` - --> $DIR/cast-to-unsized-type.rs:13:17 + --> $DIR/issue-17441.rs:11:17 | LL | let _quux = [1_usize, 2] as [usize]; | ^^^^^^^^^^^^^^^^^^^^^^^ | help: consider using a box or reference as appropriate - --> $DIR/cast-to-unsized-type.rs:13:17 + --> $DIR/issue-17441.rs:11:17 | LL | let _quux = [1_usize, 2] as [usize]; | ^^^^^^^^^^^^ diff --git a/tests/ui/closures/unsized_value_move.rs b/tests/ui/issues/issue-17651.rs similarity index 70% rename from tests/ui/closures/unsized_value_move.rs rename to tests/ui/issues/issue-17651.rs index da39cc0f35f4..7629a5a3be1e 100644 --- a/tests/ui/closures/unsized_value_move.rs +++ b/tests/ui/issues/issue-17651.rs @@ -1,4 +1,3 @@ -//! regression test for // Test that moves of unsized values within closures are caught // and rejected. diff --git a/tests/ui/closures/unsized_value_move.stderr b/tests/ui/issues/issue-17651.stderr similarity index 95% rename from tests/ui/closures/unsized_value_move.stderr rename to tests/ui/issues/issue-17651.stderr index a9a26a42d167..9519507320d8 100644 --- a/tests/ui/closures/unsized_value_move.stderr +++ b/tests/ui/issues/issue-17651.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time - --> $DIR/unsized_value_move.rs:6:18 + --> $DIR/issue-17651.rs:5:18 | LL | (|| Box::new(*(&[0][..])))(); | -------- ^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/match/match-large-array.rs b/tests/ui/issues/issue-17877.rs similarity index 76% rename from tests/ui/match/match-large-array.rs rename to tests/ui/issues/issue-17877.rs index e72777c443c5..7df0fffa41c8 100644 --- a/tests/ui/match/match-large-array.rs +++ b/tests/ui/issues/issue-17877.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass fn main() { diff --git a/tests/ui/unsized/enum-struct-optimization.rs b/tests/ui/issues/issue-18353.rs similarity index 75% rename from tests/ui/unsized/enum-struct-optimization.rs rename to tests/ui/issues/issue-18353.rs index 2e2bc64008a6..378caa9f3697 100644 --- a/tests/ui/unsized/enum-struct-optimization.rs +++ b/tests/ui/issues/issue-18353.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass #![allow(dead_code)] // Test that wrapping an unsized struct in an enum which gets optimised does diff --git a/tests/ui/deref/deref-in-for-loop.rs b/tests/ui/issues/issue-18767.rs similarity index 72% rename from tests/ui/deref/deref-in-for-loop.rs rename to tests/ui/issues/issue-18767.rs index 26921c3f1dda..87762406da60 100644 --- a/tests/ui/deref/deref-in-for-loop.rs +++ b/tests/ui/issues/issue-18767.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass // Test that regionck uses the right memcat for patterns in for loops // and doesn't ICE. diff --git a/tests/ui/issues/issue-19482.stderr b/tests/ui/issues/issue-19482.stderr index 7683e16610e6..903a9f98c758 100644 --- a/tests/ui/issues/issue-19482.stderr +++ b/tests/ui/issues/issue-19482.stderr @@ -5,7 +5,7 @@ LL | type A; | ------ `A` defined here ... LL | fn bar(x: &dyn Foo) {} - | ^^^ help: specify the associated type: `Foo` + | ^^^ help: specify the associated type: `Foo` error: aborting due to 1 previous error diff --git a/tests/ui/methods/method-not-found-on-struct.rs b/tests/ui/issues/issue-19692.rs similarity index 69% rename from tests/ui/methods/method-not-found-on-struct.rs rename to tests/ui/issues/issue-19692.rs index b2a457ed19e5..99eccc8a8175 100644 --- a/tests/ui/methods/method-not-found-on-struct.rs +++ b/tests/ui/issues/issue-19692.rs @@ -1,5 +1,3 @@ -//! regression test for - struct Homura; fn akemi(homura: Homura) { diff --git a/tests/ui/methods/method-not-found-on-struct.stderr b/tests/ui/issues/issue-19692.stderr similarity index 90% rename from tests/ui/methods/method-not-found-on-struct.stderr rename to tests/ui/issues/issue-19692.stderr index 3bf775f30a7a..1e3d7a2e2f51 100644 --- a/tests/ui/methods/method-not-found-on-struct.stderr +++ b/tests/ui/issues/issue-19692.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `kaname` found for struct `Homura` in the current scope - --> $DIR/method-not-found-on-struct.rs:6:40 + --> $DIR/issue-19692.rs:4:40 | LL | struct Homura; | ------------- method `kaname` not found for this struct diff --git a/tests/ui/enum/enum-nonexisting-field.rs b/tests/ui/issues/issue-19922.rs similarity index 69% rename from tests/ui/enum/enum-nonexisting-field.rs rename to tests/ui/issues/issue-19922.rs index 837430340f33..fede86f22afd 100644 --- a/tests/ui/enum/enum-nonexisting-field.rs +++ b/tests/ui/issues/issue-19922.rs @@ -1,5 +1,3 @@ -//! regression test for - enum Homura { Akemi { madoka: () } } diff --git a/tests/ui/enum/enum-nonexisting-field.stderr b/tests/ui/issues/issue-19922.stderr similarity index 89% rename from tests/ui/enum/enum-nonexisting-field.stderr rename to tests/ui/issues/issue-19922.stderr index 22bfa08dadb3..0355d3a89710 100644 --- a/tests/ui/enum/enum-nonexisting-field.stderr +++ b/tests/ui/issues/issue-19922.stderr @@ -1,5 +1,5 @@ error[E0559]: variant `Homura::Akemi` has no field named `kaname` - --> $DIR/enum-nonexisting-field.rs:8:34 + --> $DIR/issue-19922.rs:6:34 | LL | let homura = Homura::Akemi { kaname: () }; | ^^^^^^ `Homura::Akemi` does not have this field diff --git a/tests/ui/issues/issue-20644.rs b/tests/ui/issues/issue-20644.rs index 09a2ee7217c3..5f7e4054f776 100644 --- a/tests/ui/issues/issue-20644.rs +++ b/tests/ui/issues/issue-20644.rs @@ -1,10 +1,14 @@ //@ build-pass #![allow(dead_code)] #![allow(unused_imports)] +#![allow(stable_features)] // A reduced version of the rustbook ice. The problem this encountered // had to do with codegen ignoring binders. + +#![feature(os)] + use std::iter; use std::os; use std::fs::File; diff --git a/tests/ui/issues/issue-2074.rs b/tests/ui/issues/issue-2074.rs new file mode 100644 index 000000000000..b6e3fb1fa23a --- /dev/null +++ b/tests/ui/issues/issue-2074.rs @@ -0,0 +1,15 @@ +//@ run-pass + +#![allow(non_camel_case_types)] + +pub fn main() { + let one = || { + enum r { a } + r::a as usize + }; + let two = || { + enum r { a } + r::a as usize + }; + one(); two(); +} diff --git a/tests/ui/issues/issue-21634.rs b/tests/ui/issues/issue-21634.rs index 475a33eca58e..270a893474ad 100644 --- a/tests/ui/issues/issue-21634.rs +++ b/tests/ui/issues/issue-21634.rs @@ -1,4 +1,7 @@ //@ run-pass +#![allow(stable_features)] + +#![feature(cfg_target_feature)] #[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))] fn main() { diff --git a/tests/ui/threads-sendsync/recursive-thread-spawn.rs b/tests/ui/issues/issue-2190-1.rs similarity index 79% rename from tests/ui/threads-sendsync/recursive-thread-spawn.rs rename to tests/ui/issues/issue-2190-1.rs index 974f3a74f146..e4e4bf9dbbee 100644 --- a/tests/ui/threads-sendsync/recursive-thread-spawn.rs +++ b/tests/ui/issues/issue-2190-1.rs @@ -2,7 +2,7 @@ use std::thread::Builder; -static GENERATIONS: usize = 1024 + 256 + 128 + 49; +static GENERATIONS: usize = 1024+256+128+49; fn spawn(mut f: Box) { Builder::new().stack_size(32 * 1024).spawn(move || f()); @@ -11,7 +11,7 @@ fn spawn(mut f: Box) { fn child_no(x: usize) -> Box { Box::new(move || { if x < GENERATIONS { - spawn(child_no(x + 1)); + spawn(child_no(x+1)); } }) } diff --git a/tests/ui/extern/lgamma-linkage.rs b/tests/ui/issues/issue-2214.rs similarity index 89% rename from tests/ui/extern/lgamma-linkage.rs rename to tests/ui/issues/issue-2214.rs index 0b09677c47f2..453bb58a6221 100644 --- a/tests/ui/extern/lgamma-linkage.rs +++ b/tests/ui/issues/issue-2214.rs @@ -1,5 +1,3 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2214 - //@ run-pass //@ ignore-wasm32 wasi-libc does not have lgamma //@ ignore-sgx no libc @@ -21,7 +19,7 @@ mod m { use std::ffi::{c_double, c_int}; extern "C" { #[cfg(all(unix, not(target_os = "vxworks")))] - #[link_name = "lgamma_r"] + #[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; #[cfg(windows)] #[link_name = "lgamma"] diff --git a/tests/ui/issues/issue-22370.stderr b/tests/ui/issues/issue-22370.stderr index cd1580e844ca..b02d867eb7dd 100644 --- a/tests/ui/issues/issue-22370.stderr +++ b/tests/ui/issues/issue-22370.stderr @@ -7,11 +7,11 @@ LL | LL | fn f(a: &dyn A) {} | ^ | - = note: because the parameter default references `Self`, the parameter must be specified on the trait object type -help: explicitly specify the type parameter + = note: because the parameter default references `Self`, the parameter must be specified on the object type +help: set the type parameter to the desired type | -LL | fn f(a: &dyn A) {} - | +++++++++ +LL | fn f(a: &dyn A) {} + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/lint/unused/unused-var-in-match-arm.rs b/tests/ui/issues/issue-22599.rs similarity index 68% rename from tests/ui/lint/unused/unused-var-in-match-arm.rs rename to tests/ui/issues/issue-22599.rs index 780225f98dbb..05096e5c1853 100644 --- a/tests/ui/lint/unused/unused-var-in-match-arm.rs +++ b/tests/ui/issues/issue-22599.rs @@ -1,4 +1,3 @@ -//! regression test for #![deny(unused_variables)] fn f(_: i32) {} diff --git a/tests/ui/lint/unused/unused-var-in-match-arm.stderr b/tests/ui/issues/issue-22599.stderr similarity index 78% rename from tests/ui/lint/unused/unused-var-in-match-arm.stderr rename to tests/ui/issues/issue-22599.stderr index a1b9849293ef..b599f6febe31 100644 --- a/tests/ui/lint/unused/unused-var-in-match-arm.stderr +++ b/tests/ui/issues/issue-22599.stderr @@ -1,11 +1,11 @@ error: unused variable: `a` - --> $DIR/unused-var-in-match-arm.rs:9:19 + --> $DIR/issue-22599.rs:8:19 | LL | v = match 0 { a => 0 }; | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: the lint level is defined here - --> $DIR/unused-var-in-match-arm.rs:2:9 + --> $DIR/issue-22599.rs:1:9 | LL | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-2288.rs b/tests/ui/issues/issue-2288.rs new file mode 100644 index 000000000000..f424cca79d3c --- /dev/null +++ b/tests/ui/issues/issue-2288.rs @@ -0,0 +1,33 @@ +//@ run-pass +#![allow(non_camel_case_types)] + +trait clam { + fn chowder(&self, y: A); +} + +#[derive(Copy, Clone)] +struct foo { + x: A, +} + +impl clam for foo { + fn chowder(&self, _y: A) { + } +} + +fn foo(b: A) -> foo { + foo { + x: b + } +} + +fn f(x: Box>, a: A) { + x.chowder(a); +} + +pub fn main() { + + let c = foo(42); + let d: Box> = Box::new(c) as Box>; + f(d, c.x); +} diff --git a/tests/ui/generics/generic-impl-method-params-2311.rs b/tests/ui/issues/issue-2311-2.rs similarity index 64% rename from tests/ui/generics/generic-impl-method-params-2311.rs rename to tests/ui/issues/issue-2311-2.rs index cd9f488daed0..5a0b49a501fc 100644 --- a/tests/ui/generics/generic-impl-method-params-2311.rs +++ b/tests/ui/issues/issue-2311-2.rs @@ -2,6 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] + trait clam { fn get(self) -> A; } @@ -11,13 +12,15 @@ struct foo { } impl foo { - pub fn bar>(&self, _c: C) -> B { - panic!(); - } + pub fn bar>(&self, _c: C) -> B { + panic!(); + } } fn foo(b: A) -> foo { - foo { x: b } + foo { + x: b + } } -pub fn main() {} +pub fn main() { } diff --git a/tests/ui/issues/issue-2311.rs b/tests/ui/issues/issue-2311.rs new file mode 100644 index 000000000000..5388e634c096 --- /dev/null +++ b/tests/ui/issues/issue-2311.rs @@ -0,0 +1,10 @@ +//@ check-pass +#![allow(non_camel_case_types)] + + +trait clam { fn get(self) -> A; } +trait foo { + fn bar>(&self, c: C) -> B; +} + +pub fn main() { } diff --git a/tests/ui/issues/issue-2312.rs b/tests/ui/issues/issue-2312.rs new file mode 100644 index 000000000000..ecd296aac7a1 --- /dev/null +++ b/tests/ui/issues/issue-2312.rs @@ -0,0 +1,16 @@ +//@ check-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// Testing that the B's are resolved + + +trait clam { fn get(self) -> A; } + +struct foo(isize); + +impl foo { + pub fn bar>(&self, _c: C) -> B { panic!(); } +} + +pub fn main() { } diff --git a/tests/ui/type-inference/swap-with-unspecified-type.rs b/tests/ui/issues/issue-24013.rs similarity index 70% rename from tests/ui/type-inference/swap-with-unspecified-type.rs rename to tests/ui/issues/issue-24013.rs index db415df19e99..c6d301671272 100644 --- a/tests/ui/type-inference/swap-with-unspecified-type.rs +++ b/tests/ui/issues/issue-24013.rs @@ -1,5 +1,3 @@ -//! regression test for - fn main() { use std::mem::{transmute, swap}; let a = 1; diff --git a/tests/ui/type-inference/swap-with-unspecified-type.stderr b/tests/ui/issues/issue-24013.stderr similarity index 87% rename from tests/ui/type-inference/swap-with-unspecified-type.stderr rename to tests/ui/issues/issue-24013.stderr index eaaed559ebf1..37a86ecc5437 100644 --- a/tests/ui/type-inference/swap-with-unspecified-type.stderr +++ b/tests/ui/issues/issue-24013.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/swap-with-unspecified-type.rs:7:13 + --> $DIR/issue-24013.rs:5:13 | LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))}; | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `swap` diff --git a/tests/ui/issues/issue-2445-b.rs b/tests/ui/issues/issue-2445-b.rs new file mode 100644 index 000000000000..3a54c62a771b --- /dev/null +++ b/tests/ui/issues/issue-2445-b.rs @@ -0,0 +1,30 @@ +//@ run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +struct c1 { + x: T, +} + +impl c1 { + pub fn f1(&self, _x: isize) { + } +} + +fn c1(x: T) -> c1 { + c1 { + x: x + } +} + +impl c1 { + pub fn f2(&self, _x: isize) { + } +} + + +pub fn main() { + c1::(3).f1(4); + c1::(3).f2(4); +} diff --git a/tests/ui/resolve/struct-function-same-name-2445.rs b/tests/ui/issues/issue-2445.rs similarity index 78% rename from tests/ui/resolve/struct-function-same-name-2445.rs rename to tests/ui/issues/issue-2445.rs index 8a0490efa3aa..e6c33a8fd016 100644 --- a/tests/ui/resolve/struct-function-same-name-2445.rs +++ b/tests/ui/issues/issue-2445.rs @@ -1,9 +1,8 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2445 - //@ run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] + struct c1 { x: T, } @@ -13,13 +12,16 @@ impl c1 { } fn c1(x: T) -> c1 { - c1 { x } + c1 { + x: x + } } impl c1 { pub fn f2(&self, _x: T) {} } + pub fn main() { c1::(3).f1(4); c1::(3).f2(4); diff --git a/tests/ui/issues/issue-2463.rs b/tests/ui/issues/issue-2463.rs new file mode 100644 index 000000000000..8fff9763bd9e --- /dev/null +++ b/tests/ui/issues/issue-2463.rs @@ -0,0 +1,24 @@ +//@ run-pass +#![allow(dead_code)] + +struct Pair { f: isize, g: isize } + +pub fn main() { + + let x = Pair { + f: 0, + g: 0, + }; + + let _y = Pair { + f: 1, + g: 1, + .. x + }; + + let _z = Pair { + f: 1, + .. x + }; + +} diff --git a/tests/ui/resolve/struct-function-same-name-2487.rs b/tests/ui/issues/issue-2487-a.rs similarity index 64% rename from tests/ui/resolve/struct-function-same-name-2487.rs rename to tests/ui/issues/issue-2487-a.rs index 5f9a61c3260b..d38616929fae 100644 --- a/tests/ui/resolve/struct-function-same-name-2487.rs +++ b/tests/ui/issues/issue-2487-a.rs @@ -2,8 +2,10 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] + struct socket { sock: isize, + } impl Drop for socket { @@ -11,22 +13,19 @@ impl Drop for socket { } impl socket { - pub fn set_identity(&self) { + pub fn set_identity(&self) { closure(|| setsockopt_bytes(self.sock.clone())) } } fn socket() -> socket { - socket { sock: 1 } + socket { + sock: 1 + } } -fn closure(f: F) -where - F: FnOnce(), -{ - f() -} +fn closure(f: F) where F: FnOnce() { f() } -fn setsockopt_bytes(_sock: isize) {} +fn setsockopt_bytes(_sock: isize) { } pub fn main() {} diff --git a/tests/ui/resolve/struct-function-same-name-2502.rs b/tests/ui/issues/issue-2502.rs similarity index 51% rename from tests/ui/resolve/struct-function-same-name-2502.rs rename to tests/ui/issues/issue-2502.rs index 5305c7d0a96f..98a52a3b5a7d 100644 --- a/tests/ui/resolve/struct-function-same-name-2502.rs +++ b/tests/ui/issues/issue-2502.rs @@ -1,11 +1,11 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2502 - //@ check-pass #![allow(dead_code)] #![allow(non_camel_case_types)] + + struct font<'a> { - fontbuf: &'a Vec, + fontbuf: &'a Vec , } impl<'a> font<'a> { @@ -14,8 +14,10 @@ impl<'a> font<'a> { } } -fn font(fontbuf: &Vec) -> font<'_> { - font { fontbuf } +fn font(fontbuf: &Vec ) -> font<'_> { + font { + fontbuf: fontbuf + } } -pub fn main() {} +pub fn main() { } diff --git a/tests/ui/type-inference/send-with-unspecified-type.rs b/tests/ui/issues/issue-25368.rs similarity index 79% rename from tests/ui/type-inference/send-with-unspecified-type.rs rename to tests/ui/issues/issue-25368.rs index 4c2de025d69c..4be83457f7a8 100644 --- a/tests/ui/type-inference/send-with-unspecified-type.rs +++ b/tests/ui/issues/issue-25368.rs @@ -1,5 +1,3 @@ -//! regression test for - use std::sync::mpsc::channel; use std::thread::spawn; use std::marker::PhantomData; diff --git a/tests/ui/type-inference/send-with-unspecified-type.stderr b/tests/ui/issues/issue-25368.stderr similarity index 91% rename from tests/ui/type-inference/send-with-unspecified-type.stderr rename to tests/ui/issues/issue-25368.stderr index 85692e8ad0cd..23f1441e69dc 100644 --- a/tests/ui/type-inference/send-with-unspecified-type.stderr +++ b/tests/ui/issues/issue-25368.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/send-with-unspecified-type.rs:13:27 + --> $DIR/issue-25368.rs:11:27 | LL | tx.send(Foo{ foo: PhantomData }); | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` diff --git a/tests/ui/resolve/struct-function-same-name-2550.rs b/tests/ui/issues/issue-2550.rs similarity index 59% rename from tests/ui/resolve/struct-function-same-name-2550.rs rename to tests/ui/issues/issue-2550.rs index c96f58374c6d..450db9be627e 100644 --- a/tests/ui/resolve/struct-function-same-name-2550.rs +++ b/tests/ui/issues/issue-2550.rs @@ -1,18 +1,20 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2550 - //@ run-pass #![allow(dead_code)] #![allow(non_snake_case)] + struct C { x: usize, } fn C(x: usize) -> C { - C { x } + C { + x: x + } } -fn f(_x: T) {} +fn f(_x: T) { +} pub fn main() { f(C(1)); diff --git a/tests/ui/privacy/private-struct-field-in-module.rs b/tests/ui/issues/issue-26472.rs similarity index 81% rename from tests/ui/privacy/private-struct-field-in-module.rs rename to tests/ui/issues/issue-26472.rs index 7ed8def1c691..b100c59ad0bd 100644 --- a/tests/ui/privacy/private-struct-field-in-module.rs +++ b/tests/ui/issues/issue-26472.rs @@ -1,5 +1,3 @@ -//! regression test for - mod sub { pub struct S { len: usize } impl S { diff --git a/tests/ui/privacy/private-struct-field-in-module.stderr b/tests/ui/issues/issue-26472.stderr similarity index 81% rename from tests/ui/privacy/private-struct-field-in-module.stderr rename to tests/ui/issues/issue-26472.stderr index 2394686f69ca..d7134bff1761 100644 --- a/tests/ui/privacy/private-struct-field-in-module.stderr +++ b/tests/ui/issues/issue-26472.stderr @@ -1,5 +1,5 @@ error[E0616]: field `len` of struct `S` is private - --> $DIR/private-struct-field-in-module.rs:13:15 + --> $DIR/issue-26472.rs:11:15 | LL | let v = s.len; | ^^^ private field @@ -10,7 +10,7 @@ LL | let v = s.len(); | ++ error[E0616]: field `len` of struct `S` is private - --> $DIR/private-struct-field-in-module.rs:14:7 + --> $DIR/issue-26472.rs:12:7 | LL | s.len = v; | ^^^ private field diff --git a/tests/ui/resolve/struct-function-same-name-2708.rs b/tests/ui/issues/issue-2708.rs similarity index 69% rename from tests/ui/resolve/struct-function-same-name-2708.rs rename to tests/ui/issues/issue-2708.rs index 729a5819ae4e..09d19f87aa64 100644 --- a/tests/ui/resolve/struct-function-same-name-2708.rs +++ b/tests/ui/issues/issue-2708.rs @@ -1,13 +1,15 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2708 - //@ run-pass #![allow(dead_code)] #![allow(non_snake_case)] + + + struct Font { fontbuf: usize, cairo_font: usize, font_dtor: usize, + } impl Drop for Font { @@ -15,7 +17,11 @@ impl Drop for Font { } fn Font() -> Font { - Font { fontbuf: 0, cairo_font: 0, font_dtor: 0 } + Font { + fontbuf: 0, + cairo_font: 0, + font_dtor: 0 + } } pub fn main() { diff --git a/tests/ui/issues/issue-27340.rs b/tests/ui/issues/issue-27340.rs index 9966c24a7441..53ca2bc973ff 100644 --- a/tests/ui/issues/issue-27340.rs +++ b/tests/ui/issues/issue-27340.rs @@ -1,7 +1,7 @@ struct Foo; #[derive(Copy, Clone)] +//~^ ERROR the trait `Copy` cannot be implemented for this type struct Bar(Foo); -//~^ ERROR: the trait `Copy` cannot be implemented for this type -//~| ERROR: `Foo: Clone` is not satisfied +//~^ ERROR `Foo: Clone` is not satisfied fn main() {} diff --git a/tests/ui/issues/issue-27340.stderr b/tests/ui/issues/issue-27340.stderr index 3b4ad58b1f08..d5ff29a618b0 100644 --- a/tests/ui/issues/issue-27340.stderr +++ b/tests/ui/issues/issue-27340.stderr @@ -1,20 +1,22 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/issue-27340.rs:3:8 + --> $DIR/issue-27340.rs:2:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion + | ^^^^ +LL | LL | struct Bar(Foo); - | ^^^ --- this field does not implement `Copy` + | --- this field does not implement `Copy` error[E0277]: the trait bound `Foo: Clone` is not satisfied - --> $DIR/issue-27340.rs:3:12 + --> $DIR/issue-27340.rs:4:12 | LL | #[derive(Copy, Clone)] | ----- in this derive macro expansion +LL | LL | struct Bar(Foo); | ^^^ the trait `Clone` is not implemented for `Foo` | -note: required by a bound in `std::clone::AssertParamIsClone` +note: required by a bound in `AssertParamIsClone` --> $SRC_DIR/core/src/clone.rs:LL:COL help: consider annotating `Foo` with `#[derive(Clone)]` | diff --git a/tests/ui/issues/issue-28344.stderr b/tests/ui/issues/issue-28344.stderr index 9940f005b7f8..c85424e22794 100644 --- a/tests/ui/issues/issue-28344.stderr +++ b/tests/ui/issues/issue-28344.stderr @@ -16,7 +16,7 @@ error[E0191]: the value of the associated type `Output` in `BitXor<_>` must be s --> $DIR/issue-28344.rs:5:17 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - | ^^^^^^ help: specify the associated type: `BitXor::` + | ^^^^^^ help: specify the associated type: `BitXor::` warning: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-28344.rs:10:13 @@ -35,7 +35,7 @@ error[E0191]: the value of the associated type `Output` in `BitXor<_>` must be s --> $DIR/issue-28344.rs:10:13 | LL | let g = BitXor::bitor; - | ^^^^^^ help: specify the associated type: `BitXor::` + | ^^^^^^ help: specify the associated type: `BitXor::` error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/tests/ui/pattern/or-pattern-mismatched-variable-and-variant.rs b/tests/ui/issues/issue-2848.rs similarity index 83% rename from tests/ui/pattern/or-pattern-mismatched-variable-and-variant.rs rename to tests/ui/issues/issue-2848.rs index 0447fd2ad589..8499459cec26 100644 --- a/tests/ui/pattern/or-pattern-mismatched-variable-and-variant.rs +++ b/tests/ui/issues/issue-2848.rs @@ -1,4 +1,3 @@ -//! regression test for #[allow(non_camel_case_types)] mod bar { diff --git a/tests/ui/pattern/or-pattern-mismatched-variable-and-variant.stderr b/tests/ui/issues/issue-2848.stderr similarity index 84% rename from tests/ui/pattern/or-pattern-mismatched-variable-and-variant.stderr rename to tests/ui/issues/issue-2848.stderr index 66c7d7d348c9..1cef27c34635 100644 --- a/tests/ui/pattern/or-pattern-mismatched-variable-and-variant.stderr +++ b/tests/ui/issues/issue-2848.stderr @@ -1,5 +1,5 @@ error[E0408]: variable `beta` is not bound in all patterns - --> $DIR/or-pattern-mismatched-variable-and-variant.rs:15:7 + --> $DIR/issue-2848.rs:14:7 | LL | alpha | beta => {} | ^^^^^ ---- variable not in all patterns @@ -7,7 +7,7 @@ LL | alpha | beta => {} | pattern doesn't bind `beta` error[E0170]: pattern binding `beta` is named the same as one of the variants of the type `bar::foo` - --> $DIR/or-pattern-mismatched-variable-and-variant.rs:15:15 + --> $DIR/issue-2848.rs:14:15 | LL | alpha | beta => {} | ^^^^ help: to match on the variant, qualify the path: `bar::foo::beta` diff --git a/tests/ui/pattern/or-pattern-binding-mismatch.rs b/tests/ui/issues/issue-2849.rs similarity index 70% rename from tests/ui/pattern/or-pattern-binding-mismatch.rs rename to tests/ui/issues/issue-2849.rs index a207c3f81899..787ab0e28960 100644 --- a/tests/ui/pattern/or-pattern-binding-mismatch.rs +++ b/tests/ui/issues/issue-2849.rs @@ -1,4 +1,3 @@ -//! regression test for enum Foo { Alpha, Beta(isize) } fn main() { diff --git a/tests/ui/pattern/or-pattern-binding-mismatch.stderr b/tests/ui/issues/issue-2849.stderr similarity index 87% rename from tests/ui/pattern/or-pattern-binding-mismatch.stderr rename to tests/ui/issues/issue-2849.stderr index 46984fac03ce..ef5cdb42e610 100644 --- a/tests/ui/pattern/or-pattern-binding-mismatch.stderr +++ b/tests/ui/issues/issue-2849.stderr @@ -1,5 +1,5 @@ error[E0408]: variable `i` is not bound in all patterns - --> $DIR/or-pattern-binding-mismatch.rs:6:7 + --> $DIR/issue-2849.rs:5:7 | LL | Foo::Alpha | Foo::Beta(i) => {} | ^^^^^^^^^^ - variable not in all patterns diff --git a/tests/ui/structs/struct-size-with-drop-2895.rs b/tests/ui/issues/issue-2895.rs similarity index 84% rename from tests/ui/structs/struct-size-with-drop-2895.rs rename to tests/ui/issues/issue-2895.rs index 9540d340ff68..6301a8637534 100644 --- a/tests/ui/structs/struct-size-with-drop-2895.rs +++ b/tests/ui/issues/issue-2895.rs @@ -1,12 +1,10 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2895 - //@ run-pass #![allow(dead_code)] use std::mem; struct Cat { - x: isize, + x: isize } struct Kitty { diff --git a/tests/ui/issues/issue-2904.rs b/tests/ui/issues/issue-2904.rs new file mode 100644 index 000000000000..1ae3a8ad656e --- /dev/null +++ b/tests/ui/issues/issue-2904.rs @@ -0,0 +1,79 @@ +//@ build-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(non_camel_case_types)] + +// Map representation + +use std::fmt; +use std::io::prelude::*; +use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty}; + +enum square { + bot, + wall, + rock, + lambda, + closed_lift, + open_lift, + earth, + empty +} + +impl fmt::Debug for square { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", match *self { + bot => { "R".to_string() } + wall => { "#".to_string() } + rock => { "*".to_string() } + lambda => { "\\".to_string() } + closed_lift => { "L".to_string() } + open_lift => { "O".to_string() } + earth => { ".".to_string() } + empty => { " ".to_string() } + }) + } +} + +fn square_from_char(c: char) -> square { + match c { + 'R' => { bot } + '#' => { wall } + '*' => { rock } + '\\' => { lambda } + 'L' => { closed_lift } + 'O' => { open_lift } + '.' => { earth } + ' ' => { empty } + _ => { + println!("invalid square: {}", c); + panic!() + } + } +} + +fn read_board_grid(mut input: rdr) + -> Vec> { + let mut input: &mut dyn Read = &mut input; + let mut grid = Vec::new(); + let mut line = [0; 10]; + input.read(&mut line); + let mut row = Vec::new(); + for c in &line { + row.push(square_from_char(*c as char)) + } + grid.push(row); + let width = grid[0].len(); + for row in &grid { assert_eq!(row.len(), width) } + grid +} + +mod test { + #[test] + pub fn trivial_to_string() { + assert_eq!(lambda.to_string(), "\\") + } +} + +pub fn main() {} diff --git a/tests/ui/traits/trait-object-method-call-2935.rs b/tests/ui/issues/issue-2935.rs similarity index 60% rename from tests/ui/traits/trait-object-method-call-2935.rs rename to tests/ui/issues/issue-2935.rs index ea24aae89462..bcc25f6187b5 100644 --- a/tests/ui/traits/trait-object-method-call-2935.rs +++ b/tests/ui/issues/issue-2935.rs @@ -1,5 +1,3 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2935 - //@ run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] @@ -13,14 +11,14 @@ trait it { } impl it for t { - fn f(&self) {} + fn f(&self) { } } pub fn main() { - // let x = ({a: 4} as it); - // let y = box ({a: 4}); - // let z = box ({a: 4} as it); - // let z = box ({a: true} as it); + // let x = ({a: 4} as it); + // let y = box ({a: 4}); + // let z = box ({a: 4} as it); + // let z = box ({a: true} as it); let z: Box<_> = Box::new(Box::new(true) as Box); // x.f(); // y.f(); diff --git a/tests/ui/issues/issue-29663.rs b/tests/ui/issues/issue-29663.rs index 9f7de6b72e11..ed512f14f4ce 100644 --- a/tests/ui/issues/issue-29663.rs +++ b/tests/ui/issues/issue-29663.rs @@ -1,6 +1,8 @@ //@ run-pass +#![allow(stable_features)] // write_volatile causes an LLVM assert with composite types +#![feature(volatile)] use std::ptr::{read_volatile, write_volatile}; #[derive(Debug, Eq, PartialEq)] diff --git a/tests/ui/match/large-match-mir-gen.rs b/tests/ui/issues/issue-29740.rs similarity index 98% rename from tests/ui/match/large-match-mir-gen.rs rename to tests/ui/issues/issue-29740.rs index bb084a9ef0d0..e26e2c882dc3 100644 --- a/tests/ui/match/large-match-mir-gen.rs +++ b/tests/ui/issues/issue-29740.rs @@ -1,8 +1,7 @@ -//! regression test for //@ check-pass #![allow(dead_code)] -// Inefficient MIR matching algorithms generated way -// too much code for this sort of case, leading to OOM. +// Regression test for #29740. Inefficient MIR matching algorithms +// generated way too much code for this sort of case, leading to OOM. #![allow(non_snake_case)] pub mod KeyboardEventConstants { diff --git a/tests/ui/cast/non-primitive-isize-ref-cast.rs b/tests/ui/issues/issue-2995.rs similarity index 59% rename from tests/ui/cast/non-primitive-isize-ref-cast.rs rename to tests/ui/issues/issue-2995.rs index 95259456eede..0da7909480d2 100644 --- a/tests/ui/cast/non-primitive-isize-ref-cast.rs +++ b/tests/ui/issues/issue-2995.rs @@ -1,5 +1,3 @@ -//! regression test for - fn bad (p: *const isize) { let _q: &isize = p as &isize; //~ ERROR non-primitive cast } diff --git a/tests/ui/cast/non-primitive-isize-ref-cast.stderr b/tests/ui/issues/issue-2995.stderr similarity index 88% rename from tests/ui/cast/non-primitive-isize-ref-cast.stderr rename to tests/ui/issues/issue-2995.stderr index 3f4c171d3dc7..f4a08e1751fc 100644 --- a/tests/ui/cast/non-primitive-isize-ref-cast.stderr +++ b/tests/ui/issues/issue-2995.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `*const isize` as `&isize` - --> $DIR/non-primitive-isize-ref-cast.rs:4:22 + --> $DIR/issue-2995.rs:2:22 | LL | let _q: &isize = p as &isize; | ^^^^^^^^^^^ invalid cast diff --git a/tests/ui/borrowck/borrow-box-in-map-3026.rs b/tests/ui/issues/issue-3026.rs similarity index 73% rename from tests/ui/borrowck/borrow-box-in-map-3026.rs rename to tests/ui/issues/issue-3026.rs index dd63075eecba..05dc46c3cc09 100644 --- a/tests/ui/borrowck/borrow-box-in-map-3026.rs +++ b/tests/ui/issues/issue-3026.rs @@ -1,5 +1,3 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/3026 - //@ run-pass use std::collections::HashMap; diff --git a/tests/ui/panics/vec-extend-after-panic-3029.rs b/tests/ui/issues/issue-3029.rs similarity index 74% rename from tests/ui/panics/vec-extend-after-panic-3029.rs rename to tests/ui/issues/issue-3029.rs index 3ae708d91e19..22d0906ccf70 100644 --- a/tests/ui/panics/vec-extend-after-panic-3029.rs +++ b/tests/ui/issues/issue-3029.rs @@ -1,5 +1,3 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/3029 - //@ run-fail //@ error-pattern:so long //@ needs-subprocess diff --git a/tests/ui/pattern/multiple-bindings-on-var.rs b/tests/ui/issues/issue-3038.rs similarity index 89% rename from tests/ui/pattern/multiple-bindings-on-var.rs rename to tests/ui/issues/issue-3038.rs index f84276257b67..cf3ba009f00c 100644 --- a/tests/ui/pattern/multiple-bindings-on-var.rs +++ b/tests/ui/issues/issue-3038.rs @@ -1,4 +1,3 @@ -//! regression test for enum F { G(isize, isize) } enum H { I(J, K) } diff --git a/tests/ui/pattern/multiple-bindings-on-var.stderr b/tests/ui/issues/issue-3038.stderr similarity index 82% rename from tests/ui/pattern/multiple-bindings-on-var.stderr rename to tests/ui/issues/issue-3038.stderr index c2ec11c43465..210da2ceff9b 100644 --- a/tests/ui/pattern/multiple-bindings-on-var.stderr +++ b/tests/ui/issues/issue-3038.stderr @@ -1,17 +1,17 @@ error[E0416]: identifier `x` is bound more than once in the same pattern - --> $DIR/multiple-bindings-on-var.rs:13:15 + --> $DIR/issue-3038.rs:12:15 | LL | F::G(x, x) => { println!("{}", x + x); } | ^ used in a pattern more than once error[E0416]: identifier `x` is bound more than once in the same pattern - --> $DIR/multiple-bindings-on-var.rs:18:32 + --> $DIR/issue-3038.rs:17:32 | LL | H::I(J::L(x, _), K::M(_, x)) | ^ used in a pattern more than once error[E0416]: identifier `x` is bound more than once in the same pattern - --> $DIR/multiple-bindings-on-var.rs:24:13 + --> $DIR/issue-3038.rs:23:13 | LL | (x, x) => { x } | ^ used in a pattern more than once diff --git a/tests/ui/traits/trait-object-type-alias-3052.rs b/tests/ui/issues/issue-3052.rs similarity index 69% rename from tests/ui/traits/trait-object-type-alias-3052.rs rename to tests/ui/issues/issue-3052.rs index e601c76713dc..ab3519fe7147 100644 --- a/tests/ui/traits/trait-object-type-alias-3052.rs +++ b/tests/ui/issues/issue-3052.rs @@ -1,5 +1,3 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/3052 - //@ run-pass #![allow(dead_code)] @@ -10,4 +8,5 @@ fn f() -> Option { Some(mock_connection) } -pub fn main() {} +pub fn main() { +} diff --git a/tests/ui/issues/issue-3121.rs b/tests/ui/issues/issue-3121.rs new file mode 100644 index 000000000000..aa150f11cf40 --- /dev/null +++ b/tests/ui/issues/issue-3121.rs @@ -0,0 +1,24 @@ +//@ run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#[derive(Copy, Clone)] +enum side { mayo, catsup, vinegar } +#[derive(Copy, Clone)] +enum order { hamburger, fries(side), shake } +#[derive(Copy, Clone)] +enum meal { to_go(order), for_here(order) } + +fn foo(m: Box, cond: bool) { + match *m { + meal::to_go(_) => { } + meal::for_here(_) if cond => {} + meal::for_here(order::hamburger) => {} + meal::for_here(order::fries(_s)) => {} + meal::for_here(order::shake) => {} + } +} + +pub fn main() { + foo(Box::new(meal::for_here(order::hamburger)), true) +} diff --git a/tests/ui/associated-consts/associated-const-access.rs b/tests/ui/issues/issue-31267.rs similarity index 67% rename from tests/ui/associated-consts/associated-const-access.rs rename to tests/ui/issues/issue-31267.rs index d6508d4922ae..d6081bb87439 100644 --- a/tests/ui/associated-consts/associated-const-access.rs +++ b/tests/ui/issues/issue-31267.rs @@ -1,5 +1,5 @@ -//! regression test for //@ run-pass +// Regression test for issue #31267 struct Foo; diff --git a/tests/ui/pattern/constructor-type-mismatch.rs b/tests/ui/issues/issue-32004.rs similarity index 82% rename from tests/ui/pattern/constructor-type-mismatch.rs rename to tests/ui/issues/issue-32004.rs index 77b8e5312dca..b3493508c5a9 100644 --- a/tests/ui/pattern/constructor-type-mismatch.rs +++ b/tests/ui/issues/issue-32004.rs @@ -1,4 +1,3 @@ -//! regression test for enum Foo { Bar(i32), Baz diff --git a/tests/ui/pattern/constructor-type-mismatch.stderr b/tests/ui/issues/issue-32004.stderr similarity index 90% rename from tests/ui/pattern/constructor-type-mismatch.stderr rename to tests/ui/issues/issue-32004.stderr index 6610e12cdc75..fcbec97661b4 100644 --- a/tests/ui/pattern/constructor-type-mismatch.stderr +++ b/tests/ui/issues/issue-32004.stderr @@ -1,5 +1,5 @@ error[E0532]: expected unit struct, unit variant or constant, found tuple variant `Foo::Bar` - --> $DIR/constructor-type-mismatch.rs:11:9 + --> $DIR/issue-32004.rs:10:9 | LL | Bar(i32), | -------- `Foo::Bar` defined here @@ -20,7 +20,7 @@ LL + Foo::Baz => {} | error[E0532]: expected tuple struct or tuple variant, found unit struct `S` - --> $DIR/constructor-type-mismatch.rs:17:9 + --> $DIR/issue-32004.rs:16:9 | LL | struct S; | --------- `S` defined here diff --git a/tests/ui/pattern/enum-variant-not-found.rs b/tests/ui/issues/issue-34209.rs similarity index 66% rename from tests/ui/pattern/enum-variant-not-found.rs rename to tests/ui/issues/issue-34209.rs index e78e28abeb6e..632ddb91b36f 100644 --- a/tests/ui/pattern/enum-variant-not-found.rs +++ b/tests/ui/issues/issue-34209.rs @@ -1,5 +1,3 @@ -//! regression test for - enum S { A, } diff --git a/tests/ui/pattern/enum-variant-not-found.stderr b/tests/ui/issues/issue-34209.stderr similarity index 90% rename from tests/ui/pattern/enum-variant-not-found.stderr rename to tests/ui/issues/issue-34209.stderr index 6db4cf79d6b3..83b40d0c0816 100644 --- a/tests/ui/pattern/enum-variant-not-found.stderr +++ b/tests/ui/issues/issue-34209.stderr @@ -1,5 +1,5 @@ error[E0599]: no variant named `B` found for enum `S` - --> $DIR/enum-variant-not-found.rs:9:12 + --> $DIR/issue-34209.rs:7:12 | LL | enum S { | ------ variant `B` not found here diff --git a/tests/ui/issues/issue-34373.rs b/tests/ui/issues/issue-34373.rs index 765bfc20a451..5b05811a4eb3 100644 --- a/tests/ui/issues/issue-34373.rs +++ b/tests/ui/issues/issue-34373.rs @@ -4,9 +4,8 @@ trait Trait { fn foo(_: T) {} } -pub struct Foo>>; -//~^ ERROR cycle detected when computing type of `Foo::T` -//~| ERROR type parameter `T` is never used +pub struct Foo>>; //~ ERROR cycle detected +//~^ ERROR `T` is never used type DefaultFoo = Foo; fn main() { diff --git a/tests/ui/issues/issue-34373.stderr b/tests/ui/issues/issue-34373.stderr index 6d68de8fb3b8..03d771931341 100644 --- a/tests/ui/issues/issue-34373.stderr +++ b/tests/ui/issues/issue-34373.stderr @@ -5,7 +5,7 @@ LL | pub struct Foo>>; | ^^^^^^^^^^ | note: ...which requires expanding type alias `DefaultFoo`... - --> $DIR/issue-34373.rs:10:19 + --> $DIR/issue-34373.rs:9:19 | LL | type DefaultFoo = Foo; | ^^^ diff --git a/tests/ui/match/closure-in-match-guard.rs b/tests/ui/issues/issue-34569.rs similarity index 86% rename from tests/ui/match/closure-in-match-guard.rs rename to tests/ui/issues/issue-34569.rs index c3f16dad4bfb..25b2e7fbe160 100644 --- a/tests/ui/match/closure-in-match-guard.rs +++ b/tests/ui/issues/issue-34569.rs @@ -1,4 +1,3 @@ -//! regression test for //@ run-pass //@ compile-flags:-g diff --git a/tests/ui/issues/issue-34780.rs b/tests/ui/issues/issue-34780.rs index 4470e3af682b..ee5cc0750dce 100644 --- a/tests/ui/issues/issue-34780.rs +++ b/tests/ui/issues/issue-34780.rs @@ -1,4 +1,6 @@ //@ check-pass +#![allow(stable_features)] +#![feature(associated_consts)] use std::marker::PhantomData; diff --git a/tests/ui/type/struct-constructor-as-value.rs b/tests/ui/issues/issue-35241.rs similarity index 53% rename from tests/ui/type/struct-constructor-as-value.rs rename to tests/ui/issues/issue-35241.rs index 9cac1caf86ec..2fa762475da9 100644 --- a/tests/ui/type/struct-constructor-as-value.rs +++ b/tests/ui/issues/issue-35241.rs @@ -1,5 +1,3 @@ -//! regression test for - struct Foo(u32); fn test() -> Foo { Foo } //~ ERROR mismatched types diff --git a/tests/ui/type/struct-constructor-as-value.stderr b/tests/ui/issues/issue-35241.stderr similarity index 93% rename from tests/ui/type/struct-constructor-as-value.stderr rename to tests/ui/issues/issue-35241.stderr index 5915f971b324..6f6602793fdb 100644 --- a/tests/ui/type/struct-constructor-as-value.stderr +++ b/tests/ui/issues/issue-35241.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/struct-constructor-as-value.rs:5:20 + --> $DIR/issue-35241.rs:3:20 | LL | struct Foo(u32); | ---------- `Foo` defines a struct constructor here, which should be called diff --git a/tests/ui/issues/issue-38857.rs b/tests/ui/issues/issue-38857.rs index 63a0af759a3d..81d881c100bb 100644 --- a/tests/ui/issues/issue-38857.rs +++ b/tests/ui/issues/issue-38857.rs @@ -1,5 +1,5 @@ fn main() { let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() }; - //~^ ERROR: cannot find `imp` in `sys` [E0433] - //~| ERROR: module `sys` is private [E0603] + //~^ ERROR failed to resolve: could not find `imp` in `sys` [E0433] + //~^^ ERROR module `sys` is private [E0603] } diff --git a/tests/ui/issues/issue-38857.stderr b/tests/ui/issues/issue-38857.stderr index 85a0c266ac65..4d505784b865 100644 --- a/tests/ui/issues/issue-38857.stderr +++ b/tests/ui/issues/issue-38857.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `imp` in `sys` +error[E0433]: failed to resolve: could not find `imp` in `sys` --> $DIR/issue-38857.rs:2:23 | LL | let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() }; diff --git a/tests/ui/associated-types/associated-type-as-value.rs b/tests/ui/issues/issue-38919.rs similarity index 57% rename from tests/ui/associated-types/associated-type-as-value.rs rename to tests/ui/issues/issue-38919.rs index ddc808236658..3d28f1936b47 100644 --- a/tests/ui/associated-types/associated-type-as-value.rs +++ b/tests/ui/issues/issue-38919.rs @@ -1,5 +1,3 @@ -//! regression test for - fn foo() { T::Item; //~ ERROR no associated item named `Item` found } diff --git a/tests/ui/associated-types/associated-type-as-value.stderr b/tests/ui/issues/issue-38919.stderr similarity index 89% rename from tests/ui/associated-types/associated-type-as-value.stderr rename to tests/ui/issues/issue-38919.stderr index c553582b3907..4a4bd2ee43d8 100644 --- a/tests/ui/associated-types/associated-type-as-value.stderr +++ b/tests/ui/issues/issue-38919.stderr @@ -1,5 +1,5 @@ error[E0599]: no associated item named `Item` found for type parameter `T` in the current scope - --> $DIR/associated-type-as-value.rs:4:8 + --> $DIR/issue-38919.rs:2:8 | LL | fn foo() { | - associated item `Item` not found for this type parameter diff --git a/tests/ui/issues/issue-42796.stderr b/tests/ui/issues/issue-42796.stderr index 0e7ce9e98c4d..670b98c77089 100644 --- a/tests/ui/issues/issue-42796.stderr +++ b/tests/ui/issues/issue-42796.stderr @@ -9,6 +9,7 @@ LL | let mut s_copy = s; LL | println!("{}", s); | ^ value borrowed here after move | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | let mut s_copy = s.clone(); diff --git a/tests/ui/issues/issue-42956.rs b/tests/ui/issues/issue-42956.rs index 5d6d4249a7d8..a124ca84f3c3 100644 --- a/tests/ui/issues/issue-42956.rs +++ b/tests/ui/issues/issue-42956.rs @@ -1,5 +1,7 @@ //@ check-pass #![allow(dead_code)] +#![allow(stable_features)] +#![feature(associated_consts)] impl A for i32 { type Foo = u32; diff --git a/tests/ui/issues/issue-46101.rs b/tests/ui/issues/issue-46101.rs index 86b06f7c61d0..ab3d30d401f0 100644 --- a/tests/ui/issues/issue-46101.rs +++ b/tests/ui/issues/issue-46101.rs @@ -1,6 +1,6 @@ trait Foo {} -#[derive(Foo::Anything)] //~ ERROR cannot find - //~| ERROR cannot find +#[derive(Foo::Anything)] //~ ERROR failed to resolve: partially resolved path in a derive macro + //~| ERROR failed to resolve: partially resolved path in a derive macro struct S; fn main() {} diff --git a/tests/ui/issues/issue-46101.stderr b/tests/ui/issues/issue-46101.stderr index 1dada87d72d6..a0cdd5d5f053 100644 --- a/tests/ui/issues/issue-46101.stderr +++ b/tests/ui/issues/issue-46101.stderr @@ -1,14 +1,14 @@ -error[E0433]: cannot find derive macro `Anything` in trait `Foo` +error[E0433]: failed to resolve: partially resolved path in a derive macro --> $DIR/issue-46101.rs:2:10 | LL | #[derive(Foo::Anything)] - | ^^^^^^^^^^^^^ a derive macro can't exist within a trait + | ^^^^^^^^^^^^^ partially resolved path in a derive macro -error[E0433]: cannot find derive macro `Anything` in trait `Foo` +error[E0433]: failed to resolve: partially resolved path in a derive macro --> $DIR/issue-46101.rs:2:10 | LL | #[derive(Foo::Anything)] - | ^^^^^^^^^^^^^ a derive macro can't exist within a trait + | ^^^^^^^^^^^^^ partially resolved path in a derive macro | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/issues/issue-46604.stderr b/tests/ui/issues/issue-46604.stderr index 21abc498de12..abe3ad476c60 100644 --- a/tests/ui/issues/issue-46604.stderr +++ b/tests/ui/issues/issue-46604.stderr @@ -4,9 +4,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; | ^^^^^^^^^^^^^^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item --> $DIR/issue-46604.rs:6:5 diff --git a/tests/ui/impl-trait/impl-trait-in-generic-param.rs b/tests/ui/issues/issue-47715.rs similarity index 87% rename from tests/ui/impl-trait/impl-trait-in-generic-param.rs rename to tests/ui/issues/issue-47715.rs index 4a6a76e4f2d1..bf2b03351b29 100644 --- a/tests/ui/impl-trait/impl-trait-in-generic-param.rs +++ b/tests/ui/issues/issue-47715.rs @@ -1,5 +1,3 @@ -//! regression test for - trait Foo {} trait Bar {} diff --git a/tests/ui/impl-trait/impl-trait-in-generic-param.stderr b/tests/ui/issues/issue-47715.stderr similarity index 85% rename from tests/ui/impl-trait/impl-trait-in-generic-param.stderr rename to tests/ui/issues/issue-47715.stderr index 806a3cb22754..8ed9ff439521 100644 --- a/tests/ui/impl-trait/impl-trait-in-generic-param.stderr +++ b/tests/ui/issues/issue-47715.stderr @@ -1,5 +1,5 @@ error[E0562]: `impl Trait` is not allowed in generics - --> $DIR/impl-trait-in-generic-param.rs:11:37 + --> $DIR/issue-47715.rs:9:37 | LL | struct Container> { | ^^^^^^^^ @@ -7,7 +7,7 @@ LL | struct Container> { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generics - --> $DIR/impl-trait-in-generic-param.rs:16:30 + --> $DIR/issue-47715.rs:14:30 | LL | enum Enum> { | ^^^^^^^^ @@ -15,7 +15,7 @@ LL | enum Enum> { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generics - --> $DIR/impl-trait-in-generic-param.rs:21:32 + --> $DIR/issue-47715.rs:19:32 | LL | union Union + Copy> { | ^^^^^^^^ @@ -23,7 +23,7 @@ LL | union Union + Copy> { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generics - --> $DIR/impl-trait-in-generic-param.rs:26:30 + --> $DIR/issue-47715.rs:24:30 | LL | type Type> = T; | ^^^^^^^^ diff --git a/tests/ui/closures/nested-closure-escape-borrow.rs b/tests/ui/issues/issue-49824.rs similarity index 70% rename from tests/ui/closures/nested-closure-escape-borrow.rs rename to tests/ui/issues/issue-49824.rs index afd440ba4250..bc1cd6856bc9 100644 --- a/tests/ui/closures/nested-closure-escape-borrow.rs +++ b/tests/ui/issues/issue-49824.rs @@ -1,4 +1,3 @@ -//! regression test for fn main() { let mut x = 0; || { diff --git a/tests/ui/closures/nested-closure-escape-borrow.stderr b/tests/ui/issues/issue-49824.stderr similarity index 94% rename from tests/ui/closures/nested-closure-escape-borrow.stderr rename to tests/ui/issues/issue-49824.stderr index 5a77652fa376..1c77090de27b 100644 --- a/tests/ui/closures/nested-closure-escape-borrow.stderr +++ b/tests/ui/issues/issue-49824.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/nested-closure-escape-borrow.rs:5:9 + --> $DIR/issue-49824.rs:4:9 | LL | let mut x = 0; | ----- variable defined here diff --git a/tests/ui/issues/issue-49934-errors.rs b/tests/ui/issues/issue-49934-errors.rs new file mode 100644 index 000000000000..dd14bac5e3a9 --- /dev/null +++ b/tests/ui/issues/issue-49934-errors.rs @@ -0,0 +1,8 @@ +fn foo<#[derive(Debug)] T>() { //~ ERROR expected non-macro attribute, found attribute macro + match 0 { + #[derive(Debug)] //~ ERROR expected non-macro attribute, found attribute macro + _ => (), + } +} + +fn main() {} diff --git a/tests/ui/issues/issue-49934-errors.stderr b/tests/ui/issues/issue-49934-errors.stderr new file mode 100644 index 000000000000..8c4c54170a10 --- /dev/null +++ b/tests/ui/issues/issue-49934-errors.stderr @@ -0,0 +1,14 @@ +error: expected non-macro attribute, found attribute macro `derive` + --> $DIR/issue-49934-errors.rs:1:10 + | +LL | fn foo<#[derive(Debug)] T>() { + | ^^^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `derive` + --> $DIR/issue-49934-errors.rs:3:11 + | +LL | #[derive(Debug)] + | ^^^^^^ not a non-macro attribute + +error: aborting due to 2 previous errors + diff --git a/tests/ui/proc-macro/derive-macro-invalid-placement.rs b/tests/ui/issues/issue-49934.rs similarity index 75% rename from tests/ui/proc-macro/derive-macro-invalid-placement.rs rename to tests/ui/issues/issue-49934.rs index fd24bd7284a9..119d84a06885 100644 --- a/tests/ui/proc-macro/derive-macro-invalid-placement.rs +++ b/tests/ui/issues/issue-49934.rs @@ -1,14 +1,5 @@ -//! regression test for - #![feature(stmt_expr_attributes)] -fn foo<#[derive(Debug)] T>() { //~ ERROR expected non-macro attribute, found attribute macro - match 0 { - #[derive(Debug)] //~ ERROR expected non-macro attribute, found attribute macro - _ => (), - } -} - fn main() { // fold_stmt (Item) #[allow(dead_code)] diff --git a/tests/ui/proc-macro/derive-macro-invalid-placement.stderr b/tests/ui/issues/issue-49934.stderr similarity index 66% rename from tests/ui/proc-macro/derive-macro-invalid-placement.stderr rename to tests/ui/issues/issue-49934.stderr index 48111f4d3a14..f2ff541bb992 100644 --- a/tests/ui/proc-macro/derive-macro-invalid-placement.stderr +++ b/tests/ui/issues/issue-49934.stderr @@ -1,17 +1,5 @@ -error: expected non-macro attribute, found attribute macro `derive` - --> $DIR/derive-macro-invalid-placement.rs:5:10 - | -LL | fn foo<#[derive(Debug)] T>() { - | ^^^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `derive` - --> $DIR/derive-macro-invalid-placement.rs:7:11 - | -LL | #[derive(Debug)] - | ^^^^^^ not a non-macro attribute - error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/derive-macro-invalid-placement.rs:19:5 + --> $DIR/issue-49934.rs:10:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ not applicable here @@ -19,7 +7,7 @@ LL | println!("Hello, world!"); | -------------------------- not a `struct`, `enum` or `union` error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/derive-macro-invalid-placement.rs:23:5 + --> $DIR/issue-49934.rs:14:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ not applicable here @@ -27,7 +15,7 @@ LL | "Hello, world!"; | ---------------- not a `struct`, `enum` or `union` error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/derive-macro-invalid-placement.rs:27:5 + --> $DIR/issue-49934.rs:18:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ not applicable here @@ -35,7 +23,7 @@ LL | let _ = "Hello, world!"; | ------------------------ not a `struct`, `enum` or `union` error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/derive-macro-invalid-placement.rs:31:13 + --> $DIR/issue-49934.rs:22:13 | LL | let _ = #[derive(Debug)] "Hello, world!"; | ^^^^^^^^^^^^^^^^ --------------- not a `struct`, `enum` or `union` @@ -43,13 +31,13 @@ LL | let _ = #[derive(Debug)] "Hello, world!"; | not applicable here error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/derive-macro-invalid-placement.rs:36:9 + --> $DIR/issue-49934.rs:27:9 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ not applicable here LL | "Hello, world!", | --------------- not a `struct`, `enum` or `union` -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0774`. diff --git a/tests/ui/expr/if/expr-stack-overflow.rs b/tests/ui/issues/issue-74564-if-expr-stack-overflow.rs similarity index 99% rename from tests/ui/expr/if/expr-stack-overflow.rs rename to tests/ui/issues/issue-74564-if-expr-stack-overflow.rs index 6fa09345c827..c0ffed27e6fb 100644 --- a/tests/ui/expr/if/expr-stack-overflow.rs +++ b/tests/ui/issues/issue-74564-if-expr-stack-overflow.rs @@ -1,4 +1,3 @@ -//! regression test for //@ build-pass // ignore-tidy-filelength #![crate_type = "rlib"] diff --git a/tests/ui/iterators/into_iter-when-iter-was-intended.fixed b/tests/ui/iterators/into_iter-when-iter-was-intended.fixed deleted file mode 100644 index e841b1605f11..000000000000 --- a/tests/ui/iterators/into_iter-when-iter-was-intended.fixed +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-rustfix -//@ edition:2021 -// Suggest using the right `IntoIterator` method. #68095 -fn main() { - let _a = [0, 1, 2].iter().chain([3, 4, 5].iter()); //~ ERROR E0271 - let _b = [0, 1, 2].into_iter().chain([3, 4, 5].into_iter()); //~ ERROR E0271 - // These don't have appropriate suggestions yet. - // let c = [0, 1, 2].iter().chain([3, 4, 5]); - // let d = [0, 1, 2].iter().chain(vec![3, 4, 5]); -} diff --git a/tests/ui/iterators/into_iter-when-iter-was-intended.rs b/tests/ui/iterators/into_iter-when-iter-was-intended.rs deleted file mode 100644 index 8d4376aa0ae6..000000000000 --- a/tests/ui/iterators/into_iter-when-iter-was-intended.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-rustfix -//@ edition:2021 -// Suggest using the right `IntoIterator` method. #68095 -fn main() { - let _a = [0, 1, 2].iter().chain([3, 4, 5].into_iter()); //~ ERROR E0271 - let _b = [0, 1, 2].into_iter().chain([3, 4, 5].iter()); //~ ERROR E0271 - // These don't have appropriate suggestions yet. - // let c = [0, 1, 2].iter().chain([3, 4, 5]); - // let d = [0, 1, 2].iter().chain(vec![3, 4, 5]); -} diff --git a/tests/ui/iterators/into_iter-when-iter-was-intended.stderr b/tests/ui/iterators/into_iter-when-iter-was-intended.stderr deleted file mode 100644 index f26db9781b13..000000000000 --- a/tests/ui/iterators/into_iter-when-iter-was-intended.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0271]: type mismatch resolving ` as IntoIterator>::Item == &{integer}` - --> $DIR/into_iter-when-iter-was-intended.rs:5:37 - | -LL | let _a = [0, 1, 2].iter().chain([3, 4, 5].into_iter()); - | ----- ^^^^^^^^^^^^^^^^^^^^^ expected `&{integer}`, found integer - | | - | required by a bound introduced by this call - | -note: the method call chain might not have had the expected associated types - --> $DIR/into_iter-when-iter-was-intended.rs:5:47 - | -LL | let _a = [0, 1, 2].iter().chain([3, 4, 5].into_iter()); - | --------- ^^^^^^^^^^^ `IntoIterator::Item` is `{integer}` here - | | - | this expression has type `[{integer}; 3]` -note: required by a bound in `std::iter::Iterator::chain` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -help: consider not consuming the `[{integer}; 3]` to construct the `Iterator` - | -LL - let _a = [0, 1, 2].iter().chain([3, 4, 5].into_iter()); -LL + let _a = [0, 1, 2].iter().chain([3, 4, 5].iter()); - | - -error[E0271]: type mismatch resolving ` as IntoIterator>::Item == {integer}` - --> $DIR/into_iter-when-iter-was-intended.rs:6:42 - | -LL | let _b = [0, 1, 2].into_iter().chain([3, 4, 5].iter()); - | ----- ^^^^^^^^^^^^^^^^ expected integer, found `&{integer}` - | | - | required by a bound introduced by this call - | -note: the method call chain might not have had the expected associated types - --> $DIR/into_iter-when-iter-was-intended.rs:6:52 - | -LL | let _b = [0, 1, 2].into_iter().chain([3, 4, 5].iter()); - | --------- ^^^^^^ `IntoIterator::Item` is `&{integer}` here - | | - | this expression has type `[{integer}; 3]` -note: required by a bound in `std::iter::Iterator::chain` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -help: consider consuming the `&[{integer}]` to construct the `Iterator` - | -LL | let _b = [0, 1, 2].into_iter().chain([3, 4, 5].into_iter()); - | +++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/iterators/iter-cloned-type-inference.rs b/tests/ui/iterators/iter-cloned-type-inference.rs index 3957c99cea32..10f955881188 100644 --- a/tests/ui/iterators/iter-cloned-type-inference.rs +++ b/tests/ui/iterators/iter-cloned-type-inference.rs @@ -1,7 +1,11 @@ //@ run-pass +#![allow(stable_features)] + // Test to see that the element type of .cloned() can be inferred // properly. Previously this would fail to deduce the type of `sum`. +#![feature(iter_arith)] + fn square_sum(v: &[i64]) -> i64 { let sum: i64 = v.iter().cloned().sum(); sum * sum diff --git a/tests/ui/iterators/iter-macro-not-async-closure.stderr b/tests/ui/iterators/iter-macro-not-async-closure.stderr index 906ebd482fb6..2f0343a2d0d6 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.stderr +++ b/tests/ui/iterators/iter-macro-not-async-closure.stderr @@ -35,6 +35,7 @@ note: required by a bound in `call_async_once` | LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied --> $DIR/iter-macro-not-async-closure.rs:25:13 @@ -47,6 +48,7 @@ note: required by a bound in `call_async_once` | LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied --> $DIR/iter-macro-not-async-closure.rs:30:5 diff --git a/tests/ui/iterators/iterator-type-inference-sum-15673.rs b/tests/ui/iterators/iterator-type-inference-sum-15673.rs index 4b75503df10e..aee027927f2f 100644 --- a/tests/ui/iterators/iterator-type-inference-sum-15673.rs +++ b/tests/ui/iterators/iterator-type-inference-sum-15673.rs @@ -1,5 +1,8 @@ // https://github.com/rust-lang/rust/issues/15673 //@ run-pass +#![allow(stable_features)] + +#![feature(iter_arith)] fn main() { let x: [u64; 3] = [1, 2, 3]; diff --git a/tests/ui/keyword/keyword-super-as-identifier.rs b/tests/ui/keyword/keyword-super-as-identifier.rs index 0aeb224e183b..02c1b27b08a9 100644 --- a/tests/ui/keyword/keyword-super-as-identifier.rs +++ b/tests/ui/keyword/keyword-super-as-identifier.rs @@ -1,3 +1,3 @@ fn main() { - let super = 22; //~ ERROR too many leading `super` keywords + let super = 22; //~ ERROR failed to resolve: there are too many leading `super` keywords } diff --git a/tests/ui/keyword/keyword-super-as-identifier.stderr b/tests/ui/keyword/keyword-super-as-identifier.stderr index d8609c6bcbe8..bfb27c143ff7 100644 --- a/tests/ui/keyword/keyword-super-as-identifier.stderr +++ b/tests/ui/keyword/keyword-super-as-identifier.stderr @@ -1,4 +1,4 @@ -error[E0433]: too many leading `super` keywords +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/keyword-super-as-identifier.rs:2:9 | LL | let super = 22; diff --git a/tests/ui/keyword/keyword-super.rs b/tests/ui/keyword/keyword-super.rs index c21149a846fe..c121a6c1050e 100644 --- a/tests/ui/keyword/keyword-super.rs +++ b/tests/ui/keyword/keyword-super.rs @@ -1,3 +1,3 @@ fn main() { - let super: isize; //~ ERROR: too many leading `super` keywords + let super: isize; //~ ERROR failed to resolve: there are too many leading `super` keywords } diff --git a/tests/ui/keyword/keyword-super.stderr b/tests/ui/keyword/keyword-super.stderr index 69af7da09376..bf595442c3b8 100644 --- a/tests/ui/keyword/keyword-super.stderr +++ b/tests/ui/keyword/keyword-super.stderr @@ -1,4 +1,4 @@ -error[E0433]: too many leading `super` keywords +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/keyword-super.rs:2:9 | LL | let super: isize; diff --git a/tests/ui/kindck/kindck-send-object.stderr b/tests/ui/kindck/kindck-send-object.stderr index b71d4029350e..0e2ff1730c8d 100644 --- a/tests/ui/kindck/kindck-send-object.stderr +++ b/tests/ui/kindck/kindck-send-object.stderr @@ -19,7 +19,7 @@ LL | assert_send::>(); | ^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `dyn Dummy` - = note: required for `std::ptr::Unique` to implement `Send` + = note: required for `Unique` to implement `Send` note: required because it appears within the type `Box` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` diff --git a/tests/ui/kindck/kindck-send-object1.stderr b/tests/ui/kindck/kindck-send-object1.stderr index 2184ae704673..e3ff2eb9ff4c 100644 --- a/tests/ui/kindck/kindck-send-object1.stderr +++ b/tests/ui/kindck/kindck-send-object1.stderr @@ -19,7 +19,7 @@ LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `(dyn Dummy + 'a)` - = note: required for `std::ptr::Unique<(dyn Dummy + 'a)>` to implement `Send` + = note: required for `Unique<(dyn Dummy + 'a)>` to implement `Send` note: required because it appears within the type `Box<(dyn Dummy + 'a)>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` diff --git a/tests/ui/kindck/kindck-send-object2.stderr b/tests/ui/kindck/kindck-send-object2.stderr index 52a7055b4229..8898bf5b3fab 100644 --- a/tests/ui/kindck/kindck-send-object2.stderr +++ b/tests/ui/kindck/kindck-send-object2.stderr @@ -19,7 +19,7 @@ LL | assert_send::>(); | ^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `dyn Dummy` - = note: required for `std::ptr::Unique` to implement `Send` + = note: required for `Unique` to implement `Send` note: required because it appears within the type `Box` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` diff --git a/tests/ui/kindck/kindck-send-owned.stderr b/tests/ui/kindck/kindck-send-owned.stderr index c433d80cf140..860a9391bbb0 100644 --- a/tests/ui/kindck/kindck-send-owned.stderr +++ b/tests/ui/kindck/kindck-send-owned.stderr @@ -5,7 +5,7 @@ LL | assert_send::>(); | ^^^^^^^^^^^^ `*mut u8` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `*mut u8` - = note: required for `std::ptr::Unique<*mut u8>` to implement `Send` + = note: required for `Unique<*mut u8>` to implement `Send` note: required because it appears within the type `Box<*mut u8>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` diff --git a/tests/ui/layout/debug.rs b/tests/ui/layout/debug.rs index 60415911d38e..90e3c58dad71 100644 --- a/tests/ui/layout/debug.rs +++ b/tests/ui/layout/debug.rs @@ -68,12 +68,12 @@ union P5 { zst: [u16; 0], byte: u8 } //~ ERROR: layout_of #[rustc_layout(debug)] type X = std::mem::MaybeUninit; //~ ERROR: layout_of -#[rustc_layout(debug)] //~ ERROR: cannot be used on constants -const C: () = (); +#[rustc_layout(debug)] +const C: () = (); //~ ERROR: can only be applied to impl S { - #[rustc_layout(debug)] //~ ERROR: cannot be used on associated consts - const C: () = (); + #[rustc_layout(debug)] + const C: () = (); //~ ERROR: can only be applied to } #[rustc_layout(debug)] diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index c92f876fa5a1..79ce21eb532b 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -4,22 +4,6 @@ error: unions cannot have zero fields LL | union EmptyUnion {} | ^^^^^^^^^^^^^^^^^^^ -error: `#[rustc_layout]` attribute cannot be used on constants - --> $DIR/debug.rs:71:1 - | -LL | #[rustc_layout(debug)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_layout]` can be applied to data types and type aliases - -error: `#[rustc_layout]` attribute cannot be used on associated consts - --> $DIR/debug.rs:75:5 - | -LL | #[rustc_layout(debug)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = help: `#[rustc_layout]` can be applied to data types and type aliases - error: layout_of(E) = Layout { size: Size(12 bytes), align: AbiAlign { @@ -593,6 +577,12 @@ error: layout_of(MaybeUninit) = Layout { LL | type X = std::mem::MaybeUninit; | ^^^^^^ +error: `#[rustc_layout]` can only be applied to `struct`/`enum`/`union` declarations and type aliases + --> $DIR/debug.rs:72:1 + | +LL | const C: () = (); + | ^^^^^^^^^^^ + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/debug.rs:80:19 | @@ -614,6 +604,12 @@ error: the type `T` does not have a fixed layout LL | type TooGeneric = T; | ^^^^^^^^^^^^^^^^^^ +error: `#[rustc_layout]` can only be applied to `struct`/`enum`/`union` declarations and type aliases + --> $DIR/debug.rs:76:5 + | +LL | const C: () = (); + | ^^^^^^^^^^^ + error: aborting due to 20 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/layout/rigid-alias-due-to-broken-impl.rs b/tests/ui/layout/rigid-alias-due-to-broken-impl.rs deleted file mode 100644 index 912c660cb7ca..000000000000 --- a/tests/ui/layout/rigid-alias-due-to-broken-impl.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Make sure we don't ICE if `layout_of` encounters an alias -// which is rigid due to a malformed program. A regression test -// for #152545. -// -// This specific ICE happens in the `KnownPanicsLint` visitor. - -//@ compile-flags: --crate-type=rlib -trait Foo { - type Assoc; -} - -// The trait solver only treats missng associated items -// as rigid if the self-type is known to be unsized. -impl Foo for str {} -//~^ ERROR not all trait items implemented - -fn foo(_: [u32; std::mem::size_of::<::Assoc>()]) {} diff --git a/tests/ui/layout/rigid-alias-due-to-broken-impl.stderr b/tests/ui/layout/rigid-alias-due-to-broken-impl.stderr deleted file mode 100644 index e9ba6df2fdc7..000000000000 --- a/tests/ui/layout/rigid-alias-due-to-broken-impl.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `Assoc` - --> $DIR/rigid-alias-due-to-broken-impl.rs:14:1 - | -LL | type Assoc; - | ---------- `Assoc` from trait -... -LL | impl Foo for str {} - | ^^^^^^^^^^^^^^^^ missing `Assoc` in implementation - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/layout/valid_range_oob.stderr b/tests/ui/layout/valid_range_oob.stderr index fc6ebcf1692f..1a0c38412503 100644 --- a/tests/ui/layout/valid_range_oob.stderr +++ b/tests/ui/layout/valid_range_oob.stderr @@ -1,6 +1,6 @@ 257 > 255 -error: the compiler unexpectedly panicked. This is a bug +error: the compiler unexpectedly panicked. this is a bug. query stack during panic: #0 [layout_of] computing layout of `Foo` diff --git a/tests/ui/let-else/let-else-break-help-issue-142602.rs b/tests/ui/let-else/let-else-break-help-issue-142602.rs deleted file mode 100644 index b57c7f757150..000000000000 --- a/tests/ui/let-else/let-else-break-help-issue-142602.rs +++ /dev/null @@ -1,23 +0,0 @@ -// testcase from https://github.com/rust-lang/rust/issues/142602 - -pub fn main() { - // Case 1: break before let-else - let _a = loop { - if true { - break; - } - let Some(_) = Some(5) else { - break 3; //~ ERROR mismatched types - }; - }; - - // Case 2: two let-else statements - let _b = loop { - let Some(_) = Some(5) else { - break; - }; - let Some(_) = Some(4) else { - break 3; //~ ERROR mismatched types - }; - }; -} diff --git a/tests/ui/let-else/let-else-break-help-issue-142602.stderr b/tests/ui/let-else/let-else-break-help-issue-142602.stderr deleted file mode 100644 index aafbaa158ab1..000000000000 --- a/tests/ui/let-else/let-else-break-help-issue-142602.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/let-else-break-help-issue-142602.rs:10:19 - | -LL | break; - | ----- expected because of this `break` -... -LL | break 3; - | ^ expected `()`, found integer - -error[E0308]: mismatched types - --> $DIR/let-else-break-help-issue-142602.rs:20:19 - | -LL | break; - | ----- expected because of this `break` -... -LL | break 3; - | ^ expected `()`, found integer - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/lifetimes/auxiliary/lifetime-inference-across-mods.rs b/tests/ui/lifetimes/auxiliary/lifetime-inference-across-mods.rs deleted file mode 100644 index efc2798d916a..000000000000 --- a/tests/ui/lifetimes/auxiliary/lifetime-inference-across-mods.rs +++ /dev/null @@ -1,2 +0,0 @@ -//! auxiliary crate for -pub struct A<'a>(pub &'a isize); diff --git a/tests/ui/lifetimes/borrowck-let-suggestion.stderr b/tests/ui/lifetimes/borrowck-let-suggestion.stderr index 6a35f61708d2..4703d7f10dc2 100644 --- a/tests/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/tests/ui/lifetimes/borrowck-let-suggestion.stderr @@ -9,6 +9,7 @@ LL | LL | x.use_mut(); | - borrow later used here | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider consuming the `Vec` when turning it into an `Iterator` | LL | let mut x = vec![1].into_iter(); diff --git a/tests/ui/lifetimes/issue-97194.rs b/tests/ui/lifetimes/issue-97194.rs index 5e7c3683d209..5f3560dbe946 100644 --- a/tests/ui/lifetimes/issue-97194.rs +++ b/tests/ui/lifetimes/issue-97194.rs @@ -1,8 +1,8 @@ extern "C" { fn bget(&self, index: [usize; Self::DIM]) -> bool { - //~^ ERROR: incorrect function inside `extern` block - //~| ERROR: `self` parameter is only allowed in associated functions - //~| ERROR: cannot find `Self` + //~^ ERROR incorrect function inside `extern` block + //~| ERROR `self` parameter is only allowed in associated functions + //~| ERROR failed to resolve: `Self` type T<'a> = &'a str; } } diff --git a/tests/ui/lifetimes/issue-97194.stderr b/tests/ui/lifetimes/issue-97194.stderr index c7e318f7390a..345e21cb2507 100644 --- a/tests/ui/lifetimes/issue-97194.stderr +++ b/tests/ui/lifetimes/issue-97194.stderr @@ -22,7 +22,7 @@ LL | fn bget(&self, index: [usize; Self::DIM]) -> bool { | = note: associated functions are those in `impl` or `trait` definitions -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/issue-97194.rs:2:35 | LL | fn bget(&self, index: [usize; Self::DIM]) -> bool { diff --git a/tests/ui/lifetimes/lifetime-inference-across-mods.rs b/tests/ui/lifetimes/lifetime-inference-across-mods.rs deleted file mode 100644 index 224d2193d08c..000000000000 --- a/tests/ui/lifetimes/lifetime-inference-across-mods.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! regression test for -//@ run-pass -//@ aux-build:lifetime-inference-across-mods.rs - - -extern crate lifetime_inference_across_mods as a; - -fn main() { - let one = 1; - let _a = a::A(&one); -} diff --git a/tests/ui/lifetimes/mut-ref-owned-suggestion.rs b/tests/ui/lifetimes/mut-ref-owned-suggestion.rs deleted file mode 100644 index ae5e8f6658b6..000000000000 --- a/tests/ui/lifetimes/mut-ref-owned-suggestion.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Regression test for -//! Tests that `&mut T` suggests `T`, not `mut T`, `&mut str` suggests `String`, not `str`, -//! when recommending an owned value. -fn with_fn(_f: impl Fn() -> &mut ()) {} -//~^ ERROR: missing lifetime specifier - -fn with_ref_mut_str(_f: impl Fn() -> &mut str) {} -//~^ ERROR: missing lifetime specifier - -fn with_fn_has_return(_f: impl Fn() -> &mut ()) -> i32 { - //~^ ERROR: missing lifetime specifier - 2 -} - -fn with_dyn(_f: Box &mut i32>) {} -//~^ ERROR: missing lifetime specifier - -fn trait_bound &mut i32>(_f: F) {} -//~^ ERROR: missing lifetime specifier - -fn nested_result(_f: impl Fn() -> Result<&mut i32, ()>) {} -//~^ ERROR: missing lifetime specifier - -struct Holder &mut i32> { - //~^ ERROR: missing lifetime specifier - f: F, -} - -fn main() {} diff --git a/tests/ui/lifetimes/mut-ref-owned-suggestion.stderr b/tests/ui/lifetimes/mut-ref-owned-suggestion.stderr deleted file mode 100644 index a3e58331342a..000000000000 --- a/tests/ui/lifetimes/mut-ref-owned-suggestion.stderr +++ /dev/null @@ -1,137 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:4:29 - | -LL | fn with_fn(_f: impl Fn() -> &mut ()) {} - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | fn with_fn(_f: impl Fn() -> &'static mut ()) {} - | +++++++ -help: instead, you are more likely to want to return an owned value - | -LL - fn with_fn(_f: impl Fn() -> &mut ()) {} -LL + fn with_fn(_f: impl Fn() -> ()) {} - | - -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:7:38 - | -LL | fn with_ref_mut_str(_f: impl Fn() -> &mut str) {} - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | fn with_ref_mut_str(_f: impl Fn() -> &'static mut str) {} - | +++++++ -help: instead, you are more likely to want to return an owned value - | -LL - fn with_ref_mut_str(_f: impl Fn() -> &mut str) {} -LL + fn with_ref_mut_str(_f: impl Fn() -> String) {} - | - -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:10:40 - | -LL | fn with_fn_has_return(_f: impl Fn() -> &mut ()) -> i32 { - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | fn with_fn_has_return(_f: impl Fn() -> &'static mut ()) -> i32 { - | +++++++ -help: consider making the bound lifetime-generic with a new `'a` lifetime - | -LL - fn with_fn_has_return(_f: impl Fn() -> &mut ()) -> i32 { -LL + fn with_fn_has_return(_f: impl for<'a> Fn() -> &'a ()) -> i32 { - | -help: consider introducing a named lifetime parameter - | -LL - fn with_fn_has_return(_f: impl Fn() -> &mut ()) -> i32 { -LL + fn with_fn_has_return<'a>(_f: impl Fn() -> &'a ()) -> i32 { - | -help: alternatively, you might want to return an owned value - | -LL - fn with_fn_has_return(_f: impl Fn() -> &mut ()) -> i32 { -LL + fn with_fn_has_return(_f: impl Fn() -> ()) -> i32 { - | - -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:15:33 - | -LL | fn with_dyn(_f: Box &mut i32>) {} - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | fn with_dyn(_f: Box &'static mut i32>) {} - | +++++++ -help: instead, you are more likely to want to return an owned value - | -LL - fn with_dyn(_f: Box &mut i32>) {} -LL + fn with_dyn(_f: Box i32>) {} - | - -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:18:27 - | -LL | fn trait_bound &mut i32>(_f: F) {} - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | fn trait_bound &'static mut i32>(_f: F) {} - | +++++++ -help: instead, you are more likely to want to change the argument to be borrowed... - | -LL | fn trait_bound &mut i32>(_f: &F) {} - | + -help: ...or alternatively, you might want to return an owned value - | -LL - fn trait_bound &mut i32>(_f: F) {} -LL + fn trait_bound i32>(_f: F) {} - | - -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:21:42 - | -LL | fn nested_result(_f: impl Fn() -> Result<&mut i32, ()>) {} - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | fn nested_result(_f: impl Fn() -> Result<&'static mut i32, ()>) {} - | +++++++ -help: instead, you are more likely to want to return an owned value - | -LL - fn nested_result(_f: impl Fn() -> Result<&mut i32, ()>) {} -LL + fn nested_result(_f: impl Fn() -> Result) {} - | - -error[E0106]: missing lifetime specifier - --> $DIR/mut-ref-owned-suggestion.rs:24:26 - | -LL | struct Holder &mut i32> { - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` - | -LL | struct Holder &'static mut i32> { - | +++++++ -help: instead, you are more likely to want to return an owned value - | -LL - struct Holder &mut i32> { -LL + struct Holder i32> { - | - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/lifetimes/recover-infer-ret-ty-issue-135845.rs b/tests/ui/lifetimes/recover-infer-ret-ty-issue-135845.rs deleted file mode 100644 index acce49b1af72..000000000000 --- a/tests/ui/lifetimes/recover-infer-ret-ty-issue-135845.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Regression test for #135845. - -use std::marker::PhantomData; - -fn b<'a>() -> _ { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] - let _: PhantomData<&'a ()> = PhantomData; - 0 -} - -fn main() {} diff --git a/tests/ui/lifetimes/recover-infer-ret-ty-issue-135845.stderr b/tests/ui/lifetimes/recover-infer-ret-ty-issue-135845.stderr deleted file mode 100644 index 9f3695e88f82..000000000000 --- a/tests/ui/lifetimes/recover-infer-ret-ty-issue-135845.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/recover-infer-ret-ty-issue-135845.rs:5:15 - | -LL | fn b<'a>() -> _ { - | ^ not allowed in type signatures - | -help: replace with the correct return type - | -LL - fn b<'a>() -> _ { -LL + fn b<'a>() -> i32 { - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.rs b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.rs deleted file mode 100644 index 4bf92a2c1c18..000000000000 --- a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Regression test for https://github.com/rust-lang/rust/issues/65866. - -mod plain { - struct Foo; - - struct Re<'a> { - _data: &'a u16, - } - - trait Bar { - fn bar(&self, r: &mut Re); - //~^ NOTE expected - //~| NOTE `Re` here is elided as `Re<'_>` - } - - impl Bar for Foo { - fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {} - //~^ ERROR `impl` item signature doesn't match `trait` item signature - //~| NOTE expected signature - //~| NOTE found - //~| HELP the lifetime requirements - //~| HELP verify the lifetime relationships - } -} - -mod with_type_args { - struct Foo; - - struct Re<'a, T> { - _data: (&'a u16, T), - } - - trait Bar { - fn bar(&self, r: &mut Re); - //~^ NOTE expected - //~| NOTE `Re` here is elided as `Re<'_, u8>` - } - - impl Bar for Foo { - fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {} - //~^ ERROR `impl` item signature doesn't match `trait` item signature - //~| NOTE expected signature - //~| NOTE found - //~| HELP the lifetime requirements - //~| HELP verify the lifetime relationships - } -} - -fn main() {} diff --git a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr deleted file mode 100644 index db69b4f3656e..000000000000 --- a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error: `impl` item signature doesn't match `trait` item signature - --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:17:9 - | -LL | fn bar(&self, r: &mut Re); - | -------------------------- expected `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)` -... -LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)` - | - = note: expected signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)` - found signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)` - = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` - = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output -note: `Re` here is elided as `Re<'_>` - --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:11:31 - | -LL | fn bar(&self, r: &mut Re); - | ^^ - -error: `impl` item signature doesn't match `trait` item signature - --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:40:9 - | -LL | fn bar(&self, r: &mut Re); - | ------------------------------ expected `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)` -... -LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)` - | - = note: expected signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)` - found signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)` - = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` - = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output -note: `Re` here is elided as `Re<'_, u8>` - --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:34:31 - | -LL | fn bar(&self, r: &mut Re); - | ^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 82855bd75528..bfea0b5a4482 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -8,11 +8,9 @@ LL | drop::>(None); = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console -error: reached the type-length limit while instantiating `<{closure@...} as FnMut<()>>::call_mut` +error: reached the type-length limit while instantiating `<{closure@rt::lang_start<()>::{closure#0}} as FnMut<()>>::call_mut` | = help: consider adding a `#![type_length_limit="10"]` attribute to your crate - = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' - = note: consider using `--verbose` to print the full type name to the console error: aborting due to 2 previous errors diff --git a/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr b/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr deleted file mode 100644 index a3772e509ed6..000000000000 --- a/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: values of the type `[u8; usize::MAX]` are too big for the target architecture - -error: aborting due to 1 previous error - diff --git a/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr b/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr deleted file mode 100644 index a3772e509ed6..000000000000 --- a/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: values of the type `[u8; usize::MAX]` are too big for the target architecture - -error: aborting due to 1 previous error - diff --git a/tests/ui/limits/vtable-try-as-dyn.rs b/tests/ui/limits/vtable-try-as-dyn.rs deleted file mode 100644 index 4df4f92717f9..000000000000 --- a/tests/ui/limits/vtable-try-as-dyn.rs +++ /dev/null @@ -1,15 +0,0 @@ -// At the time of writing, vtable.rs would ICE only with debuginfo disabled, while this testcase, -// originally reported as #152030, would ICE even with debuginfo enabled. -//@ revisions: no-debuginfo full-debuginfo -//@ compile-flags: --crate-type=lib --emit=mir -//@[no-debuginfo] compile-flags: -C debuginfo=0 -//@[full-debuginfo] compile-flags: -C debuginfo=2 -#![feature(try_as_dyn)] - -trait Trait {} -impl Trait for T {} - -//~? ERROR: values of the type `[u8; usize::MAX]` are too big for the target architecture -pub fn foo(x: &[u8; usize::MAX]) { - let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x); -} diff --git a/tests/ui/limits/vtable.rs b/tests/ui/limits/vtable.rs deleted file mode 100644 index 570eaaec491c..000000000000 --- a/tests/ui/limits/vtable.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ compile-flags: --crate-type=lib --emit=mir -C debuginfo=0 -pub trait Trait {} -impl Trait for T {} - -//~? ERROR: values of the type `[u8; usize::MAX]` are too big for the target architecture -pub fn foo(x: &[u8; usize::MAX]) -> &dyn Trait { - x as &dyn Trait -} diff --git a/tests/ui/limits/vtable.stderr b/tests/ui/limits/vtable.stderr deleted file mode 100644 index a3772e509ed6..000000000000 --- a/tests/ui/limits/vtable.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: values of the type `[u8; usize::MAX]` are too big for the target architecture - -error: aborting due to 1 previous error - diff --git a/tests/ui/link-native-libs/link-arg-error2.rs b/tests/ui/link-native-libs/link-arg-error2.rs deleted file mode 100644 index a51dec0614b5..000000000000 --- a/tests/ui/link-native-libs/link-arg-error2.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ compile-flags: -l link-arg:+export-symbols=arg -Z unstable-options - -fn main() {} - -//~? ERROR linking modifier `export-symbols` is only compatible with `static` linking kind diff --git a/tests/ui/link-native-libs/link-arg-error2.stderr b/tests/ui/link-native-libs/link-arg-error2.stderr deleted file mode 100644 index 61bcf7dba282..000000000000 --- a/tests/ui/link-native-libs/link-arg-error2.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: linking modifier `export-symbols` is only compatible with `static` linking kind - diff --git a/tests/ui/link-native-libs/link-arg-from-rs2.rs b/tests/ui/link-native-libs/link-arg-from-rs2.rs deleted file mode 100644 index 3074fec6c1c8..000000000000 --- a/tests/ui/link-native-libs/link-arg-from-rs2.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(link_arg_attribute)] - -#[link(kind = "link-arg", name = "arg", modifiers = "+export-symbols")] -//~^ ERROR linking modifier `export-symbols` is only compatible with `static` linking kind -extern "C" {} - -pub fn main() {} diff --git a/tests/ui/link-native-libs/link-arg-from-rs2.stderr b/tests/ui/link-native-libs/link-arg-from-rs2.stderr deleted file mode 100644 index af3b25253e05..000000000000 --- a/tests/ui/link-native-libs/link-arg-from-rs2.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: linking modifier `export-symbols` is only compatible with `static` linking kind - --> $DIR/link-arg-from-rs2.rs:3:53 - | -LL | #[link(kind = "link-arg", name = "arg", modifiers = "+export-symbols")] - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/link-native-libs/link-attr-validation-late.stderr b/tests/ui/link-native-libs/link-attr-validation-late.stderr index 4a4a19375207..b09431f923aa 100644 --- a/tests/ui/link-native-libs/link-attr-validation-late.stderr +++ b/tests/ui/link-native-libs/link-attr-validation-late.stderr @@ -178,13 +178,13 @@ LL | #[link(name = "...", wasm_import_module())] | = note: for more information, visit -error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols +error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed --> $DIR/link-attr-validation-late.rs:31:34 | LL | #[link(name = "...", modifiers = "")] | ^^ -error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols +error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed --> $DIR/link-attr-validation-late.rs:32:34 | LL | #[link(name = "...", modifiers = "no-plus-minus")] @@ -196,7 +196,7 @@ error[E0539]: malformed `link` attribute input LL | #[link(name = "...", modifiers = "+unknown")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------^^ | | - | valid arguments are "bundle", "export-symbols", "verbatim", "whole-archive" or "as-needed" + | valid arguments are "bundle", "verbatim", "whole-archive" or "as-needed" | = note: for more information, visit diff --git a/tests/ui/link-native-libs/modifiers-bad.blank.stderr b/tests/ui/link-native-libs/modifiers-bad.blank.stderr index 6a1953e008ee..ea36af0b4cfa 100644 --- a/tests/ui/link-native-libs/modifiers-bad.blank.stderr +++ b/tests/ui/link-native-libs/modifiers-bad.blank.stderr @@ -1,2 +1,2 @@ -error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols +error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed diff --git a/tests/ui/link-native-libs/modifiers-bad.no-prefix.stderr b/tests/ui/link-native-libs/modifiers-bad.no-prefix.stderr index 6a1953e008ee..ea36af0b4cfa 100644 --- a/tests/ui/link-native-libs/modifiers-bad.no-prefix.stderr +++ b/tests/ui/link-native-libs/modifiers-bad.no-prefix.stderr @@ -1,2 +1,2 @@ -error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols +error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed diff --git a/tests/ui/link-native-libs/modifiers-bad.prefix-only.stderr b/tests/ui/link-native-libs/modifiers-bad.prefix-only.stderr index 46720cf0b15e..1e701374688f 100644 --- a/tests/ui/link-native-libs/modifiers-bad.prefix-only.stderr +++ b/tests/ui/link-native-libs/modifiers-bad.prefix-only.stderr @@ -1,2 +1,2 @@ -error: unknown linking modifier ``, expected one of: bundle, verbatim, whole-archive, as-needed, export-symbols +error: unknown linking modifier ``, expected one of: bundle, verbatim, whole-archive, as-needed diff --git a/tests/ui/link-native-libs/modifiers-bad.unknown.stderr b/tests/ui/link-native-libs/modifiers-bad.unknown.stderr index d47694a5aeca..75950ad9c64c 100644 --- a/tests/ui/link-native-libs/modifiers-bad.unknown.stderr +++ b/tests/ui/link-native-libs/modifiers-bad.unknown.stderr @@ -1,2 +1,2 @@ -error: unknown linking modifier `ferris`, expected one of: bundle, verbatim, whole-archive, as-needed, export-symbols +error: unknown linking modifier `ferris`, expected one of: bundle, verbatim, whole-archive, as-needed diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed b/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed index 8441d69a309a..17737e5cb8b9 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed @@ -3,6 +3,7 @@ #![allow(deprecated)] #![allow(dead_code)] +#![feature(atomic_try_update)] use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering}; diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.rs b/tests/ui/lint/const-item-interior-mutations-const-atomics.rs index 65973fb378e5..4180b2340df6 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.rs +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.rs @@ -3,6 +3,7 @@ #![allow(deprecated)] #![allow(dead_code)] +#![feature(atomic_try_update)] use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering}; diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr index 908a19682899..17823366d406 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr @@ -1,5 +1,5 @@ warning: mutation of an interior mutable `const` item with call to `store` - --> $DIR/const-item-interior-mutations-const-atomics.rs:12:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:13:14 | LL | let _a = A.store(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `swap` - --> $DIR/const-item-interior-mutations-const-atomics.rs:15:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:16:14 | LL | let _a = A.swap(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `compare_and_swap` - --> $DIR/const-item-interior-mutations-const-atomics.rs:18:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:19:14 | LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `compare_exchange` - --> $DIR/const-item-interior-mutations-const-atomics.rs:21:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:22:14 | LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak` - --> $DIR/const-item-interior-mutations-const-atomics.rs:24:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:25:14 | LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `fetch_and` - --> $DIR/const-item-interior-mutations-const-atomics.rs:27:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:28:14 | LL | let _a = A.fetch_and(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -102,7 +102,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `fetch_nand` - --> $DIR/const-item-interior-mutations-const-atomics.rs:30:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:31:14 | LL | let _a = A.fetch_nand(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `fetch_or` - --> $DIR/const-item-interior-mutations-const-atomics.rs:33:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:34:14 | LL | let _a = A.fetch_or(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `fetch_xor` - --> $DIR/const-item-interior-mutations-const-atomics.rs:36:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:37:14 | LL | let _a = A.fetch_xor(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `fetch_not` - --> $DIR/const-item-interior-mutations-const-atomics.rs:39:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:40:14 | LL | let _a = A.fetch_not(Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -170,7 +170,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `fetch_update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:42:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:43:14 | LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -187,7 +187,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `try_update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:45:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:46:14 | LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -204,7 +204,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:48:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:49:14 | LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -221,7 +221,7 @@ LL + static A: AtomicBool = AtomicBool::new(false); | warning: mutation of an interior mutable `const` item with call to `store` - --> $DIR/const-item-interior-mutations-const-atomics.rs:55:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:56:14 | LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -238,7 +238,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `swap` - --> $DIR/const-item-interior-mutations-const-atomics.rs:58:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:59:14 | LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -255,7 +255,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `compare_and_swap` - --> $DIR/const-item-interior-mutations-const-atomics.rs:61:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:62:14 | LL | let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -272,7 +272,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `compare_exchange` - --> $DIR/const-item-interior-mutations-const-atomics.rs:64:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:65:14 | LL | let _a = A.compare_exchange( | ^ `A` is a interior mutable `const` item of type `AtomicPtr` @@ -296,7 +296,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak` - --> $DIR/const-item-interior-mutations-const-atomics.rs:72:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:73:14 | LL | let _a = A.compare_exchange_weak( | ^ `A` is a interior mutable `const` item of type `AtomicPtr` @@ -320,7 +320,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:80:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:81:14 | LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `try_update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:83:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:84:14 | LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -354,7 +354,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:86:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:87:14 | LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_ptr_add` - --> $DIR/const-item-interior-mutations-const-atomics.rs:89:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:90:14 | LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -388,7 +388,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_ptr_sub` - --> $DIR/const-item-interior-mutations-const-atomics.rs:92:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:93:14 | LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_byte_add` - --> $DIR/const-item-interior-mutations-const-atomics.rs:95:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:96:14 | LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -422,7 +422,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_byte_sub` - --> $DIR/const-item-interior-mutations-const-atomics.rs:98:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:99:14 | LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -439,7 +439,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_and` - --> $DIR/const-item-interior-mutations-const-atomics.rs:101:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:102:14 | LL | let _a = A.fetch_and(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -456,7 +456,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_or` - --> $DIR/const-item-interior-mutations-const-atomics.rs:104:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:105:14 | LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -473,7 +473,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `fetch_xor` - --> $DIR/const-item-interior-mutations-const-atomics.rs:107:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:108:14 | LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -490,7 +490,7 @@ LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); | warning: mutation of an interior mutable `const` item with call to `store` - --> $DIR/const-item-interior-mutations-const-atomics.rs:114:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:115:14 | LL | let _a = A.store(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `swap` - --> $DIR/const-item-interior-mutations-const-atomics.rs:117:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:118:14 | LL | let _a = A.swap(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -524,7 +524,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `compare_and_swap` - --> $DIR/const-item-interior-mutations-const-atomics.rs:120:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:121:14 | LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -541,7 +541,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `compare_exchange` - --> $DIR/const-item-interior-mutations-const-atomics.rs:123:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:124:14 | LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -558,7 +558,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak` - --> $DIR/const-item-interior-mutations-const-atomics.rs:126:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:127:14 | LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -575,7 +575,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_add` - --> $DIR/const-item-interior-mutations-const-atomics.rs:129:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:130:14 | LL | let _a = A.fetch_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -592,7 +592,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_sub` - --> $DIR/const-item-interior-mutations-const-atomics.rs:132:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:133:14 | LL | let _a = A.fetch_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -609,7 +609,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_add` - --> $DIR/const-item-interior-mutations-const-atomics.rs:135:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:136:14 | LL | let _a = A.fetch_add(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -626,7 +626,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_nand` - --> $DIR/const-item-interior-mutations-const-atomics.rs:138:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:139:14 | LL | let _a = A.fetch_nand(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -643,7 +643,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_or` - --> $DIR/const-item-interior-mutations-const-atomics.rs:141:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:142:14 | LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -660,7 +660,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_xor` - --> $DIR/const-item-interior-mutations-const-atomics.rs:144:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:145:14 | LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -677,7 +677,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:147:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:148:14 | LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -694,7 +694,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `try_update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:150:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:151:14 | LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -711,7 +711,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `update` - --> $DIR/const-item-interior-mutations-const-atomics.rs:153:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:154:14 | LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -728,7 +728,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_max` - --> $DIR/const-item-interior-mutations-const-atomics.rs:156:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:157:14 | LL | let _a = A.fetch_max(20, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -745,7 +745,7 @@ LL + static A: AtomicU32 = AtomicU32::new(0); | warning: mutation of an interior mutable `const` item with call to `fetch_min` - --> $DIR/const-item-interior-mutations-const-atomics.rs:159:14 + --> $DIR/const-item-interior-mutations-const-atomics.rs:160:14 | LL | let _a = A.fetch_min(5, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/dead-code/closure-bang.stderr b/tests/ui/lint/dead-code/closure-bang.stderr index c2f83c17179c..a0f5962dfe02 100644 --- a/tests/ui/lint/dead-code/closure-bang.stderr +++ b/tests/ui/lint/dead-code/closure-bang.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/lint/fn-ptr-comparisons-some.stderr b/tests/ui/lint/fn-ptr-comparisons-some.stderr index 8674ce5e4a88..522c4399bce1 100644 --- a/tests/ui/lint/fn-ptr-comparisons-some.stderr +++ b/tests/ui/lint/fn-ptr-comparisons-some.stderr @@ -18,6 +18,7 @@ LL | assert_eq!(Some::(func), Some(func as unsafe extern "C" fn())); = note: the address of the same function can vary between different codegen units = note: furthermore, different functions could have the same address after being merged together = note: for more information visit + = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 2 warnings emitted diff --git a/tests/ui/lint/fn-ptr-comparisons-weird.stderr b/tests/ui/lint/fn-ptr-comparisons-weird.stderr index 3c76e05016f5..2014e519c253 100644 --- a/tests/ui/lint/fn-ptr-comparisons-weird.stderr +++ b/tests/ui/lint/fn-ptr-comparisons-weird.stderr @@ -61,6 +61,7 @@ LL | let _ = assert_eq!(g, g); = note: the address of the same function can vary between different codegen units = note: furthermore, different functions could have the same address after being merged together = note: for more information visit + = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons-weird.rs:35:13 @@ -71,6 +72,7 @@ LL | let _ = assert_ne!(g, g); = note: the address of the same function can vary between different codegen units = note: furthermore, different functions could have the same address after being merged together = note: for more information visit + = note: this warning originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 7 warnings emitted diff --git a/tests/ui/lint/fn_must_use.stderr b/tests/ui/lint/fn_must_use.stderr index bdf4eb6de4a5..0e8da873e7c3 100644 --- a/tests/ui/lint/fn_must_use.stderr +++ b/tests/ui/lint/fn_must_use.stderr @@ -5,7 +5,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, foreign functions, functions, inherent methods, provided trait methods, required trait methods, and traits + = help: `#[must_use]` can be applied to data types, foreign functions, functions, inherent methods, provided trait methods, required trait methods, traits, and unions = note: requested on the command line with `-W unused-attributes` warning: unused return value of `need_to_use_this_value` that must be used diff --git a/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs index d095903ec03a..92cab01fe48c 100644 --- a/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs +++ b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.rs @@ -4,7 +4,7 @@ // Typeck fails for the arg type as // `Self` makes no sense here -fn func(a: Self::ItemsIterator) { //~ ERROR cannot find `Self` +fn func(a: Self::ItemsIterator) { //~ ERROR failed to resolve: `Self` is only available in impls, traits, and type definitions a.into_iter(); } diff --git a/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr index 1a0eaba92375..73ceddae940b 100644 --- a/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr +++ b/tests/ui/lint/ice-array-into-iter-lint-issue-121532.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/ice-array-into-iter-lint-issue-121532.rs:7:12 | LL | fn func(a: Self::ItemsIterator) { diff --git a/tests/ui/lint/invalid_value-polymorphic.rs b/tests/ui/lint/invalid_value-polymorphic.rs index 4ed8950d20fa..6a31ac17d96f 100644 --- a/tests/ui/lint/invalid_value-polymorphic.rs +++ b/tests/ui/lint/invalid_value-polymorphic.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify-before-inline +//@ compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify //@ build-pass #![feature(core_intrinsics)] diff --git a/tests/ui/lint/invalid_value.stderr b/tests/ui/lint/invalid_value.stderr index 3dd2a521ff2e..cc6a2a1c8e53 100644 --- a/tests/ui/lint/invalid_value.stderr +++ b/tests/ui/lint/invalid_value.stderr @@ -333,6 +333,7 @@ LL | let _val: (NonZero, i32) = mem::uninitialized(); | = note: `std::num::NonZero` must be non-null = note: because `core::num::niche_types::NonZeroU32Inner` must be non-null + = note: integers must be initialized error: the type `*const dyn Send` does not permit zero-initialization --> $DIR/invalid_value.rs:97:37 @@ -429,6 +430,7 @@ note: because `std::num::NonZero` must be non-null (in this field of the on LL | Banana(NonZero), | ^^^^^^^^^^^^ = note: because `core::num::niche_types::NonZeroU32Inner` must be non-null + = note: integers must be initialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:111:26 diff --git a/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr index b8e7abf4807c..6e42328a1113 100644 --- a/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr @@ -4,7 +4,7 @@ error: moving 9999 bytes LL | let _ = NotBox::new(data); | ^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/copy_into_box_rc_arc.rs:1:9 | @@ -19,7 +19,7 @@ LL | | data, LL | | } | |_________^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: aborting due to 2 previous errors diff --git a/tests/ui/lint/large_assignments/copy_into_fn.stderr b/tests/ui/lint/large_assignments/copy_into_fn.stderr index a4c4800266af..f05fc33e17e1 100644 --- a/tests/ui/lint/large_assignments/copy_into_fn.stderr +++ b/tests/ui/lint/large_assignments/copy_into_fn.stderr @@ -4,7 +4,7 @@ error: moving 9999 bytes LL | one_arg(Data([0; 9999])); | ^^^^^^^^^^^^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/copy_into_fn.rs:5:9 | @@ -17,7 +17,7 @@ error: moving 9999 bytes LL | many_args(Data([0; 9999]), true, Data([0; 9999])); | ^^^^^^^^^^^^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 9999 bytes --> $DIR/copy_into_fn.rs:17:38 @@ -25,7 +25,7 @@ error: moving 9999 bytes LL | many_args(Data([0; 9999]), true, Data([0; 9999])); | ^^^^^^^^^^^^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: aborting due to 3 previous errors diff --git a/tests/ui/lint/large_assignments/inline_mir.stderr b/tests/ui/lint/large_assignments/inline_mir.stderr index b8170d8977d2..1a5fcb6c8fc1 100644 --- a/tests/ui/lint/large_assignments/inline_mir.stderr +++ b/tests/ui/lint/large_assignments/inline_mir.stderr @@ -4,7 +4,7 @@ error: moving 9999 bytes LL | let cell = std::cell::UnsafeCell::new(data); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/inline_mir.rs:2:9 | @@ -17,7 +17,7 @@ error: moving 9999 bytes LL | std::hint::black_box(cell); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: aborting due to 2 previous errors diff --git a/tests/ui/lint/large_assignments/large_future.attribute.stderr b/tests/ui/lint/large_assignments/large_future.attribute.stderr index 1580c31df3c2..734b7ff7ba22 100644 --- a/tests/ui/lint/large_assignments/large_future.attribute.stderr +++ b/tests/ui/lint/large_assignments/large_future.attribute.stderr @@ -4,7 +4,7 @@ error: moving 10024 bytes LL | let z = (x, 42); | ^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/large_future.rs:1:9 | @@ -17,7 +17,7 @@ error: moving 10024 bytes LL | let a = z.0; | ^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: aborting due to 2 previous errors diff --git a/tests/ui/lint/large_assignments/large_future.option.stderr b/tests/ui/lint/large_assignments/large_future.option.stderr index 1580c31df3c2..734b7ff7ba22 100644 --- a/tests/ui/lint/large_assignments/large_future.option.stderr +++ b/tests/ui/lint/large_assignments/large_future.option.stderr @@ -4,7 +4,7 @@ error: moving 10024 bytes LL | let z = (x, 42); | ^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/large_future.rs:1:9 | @@ -17,7 +17,7 @@ error: moving 10024 bytes LL | let a = z.0; | ^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: aborting due to 2 previous errors diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr index 35f30a79ad99..a386de5e5e8e 100644 --- a/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr @@ -4,7 +4,7 @@ error: moving 9999 bytes LL | data, | ^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/move_into_box_rc_arc.rs:1:9 | diff --git a/tests/ui/lint/large_assignments/move_into_fn.stderr b/tests/ui/lint/large_assignments/move_into_fn.stderr index 4f4c710cacef..19ec6a51d2e7 100644 --- a/tests/ui/lint/large_assignments/move_into_fn.stderr +++ b/tests/ui/lint/large_assignments/move_into_fn.stderr @@ -4,7 +4,7 @@ error: moving 9999 bytes LL | let data = Data([100; 9999]); | ^^^^^^^^^^^^^^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here --> $DIR/move_into_fn.rs:5:9 | @@ -17,7 +17,7 @@ error: moving 9999 bytes LL | take_data(data); | ^^^^ value moved from here | - = note: the current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: aborting due to 2 previous errors diff --git a/tests/ui/lint/lint-forbid-attr.rs b/tests/ui/lint/lint-forbid-attr.rs index cbe7a02a0c17..270a379c2f84 100644 --- a/tests/ui/lint/lint-forbid-attr.rs +++ b/tests/ui/lint/lint-forbid-attr.rs @@ -1,7 +1,6 @@ -#![forbid(deprecated)] //~ NOTE `forbid` level set here +#![forbid(deprecated)] #[allow(deprecated)] -//~^ ERROR allow(deprecated) incompatible with previous forbid [E0453] -//~^^ NOTE overruled by previous forbid +//~^ ERROR allow(deprecated) incompatible fn main() { } diff --git a/tests/ui/lint/lint-forbid-cmdline-1.rs b/tests/ui/lint/lint-forbid-cmdline-1.rs deleted file mode 100644 index 19a8f825f57d..000000000000 --- a/tests/ui/lint/lint-forbid-cmdline-1.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ compile-flags: -F deprecated - -#[allow(deprecated)] //~ ERROR allow(deprecated) incompatible with previous forbid [E0453] -fn main() { -} diff --git a/tests/ui/lint/lint-forbid-cmdline-2.rs b/tests/ui/lint/lint-forbid-cmdline-2.rs deleted file mode 100644 index 3505c11f4201..000000000000 --- a/tests/ui/lint/lint-forbid-cmdline-2.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ compile-flags: -F dead_code - -#[allow(unused)] -//~^ ERROR allow(unused) incompatible with previous forbid [E0453] -//~| NOTE overruled by previous forbid -//~| NOTE `forbid` lint level was set on command line (`-F dead_code`) -fn main() { -} diff --git a/tests/ui/lint/lint-forbid-cmdline-2.stderr b/tests/ui/lint/lint-forbid-cmdline-2.stderr deleted file mode 100644 index 18a60b2f8b7e..000000000000 --- a/tests/ui/lint/lint-forbid-cmdline-2.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0453]: allow(unused) incompatible with previous forbid - --> $DIR/lint-forbid-cmdline-2.rs:3:9 - | -LL | #[allow(unused)] - | ^^^^^^ overruled by previous forbid - | - = note: `forbid` lint level was set on command line (`-F dead_code`) - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui/lint/lint-forbid-cmdline.rs b/tests/ui/lint/lint-forbid-cmdline.rs new file mode 100644 index 000000000000..8a4eb449d3c8 --- /dev/null +++ b/tests/ui/lint/lint-forbid-cmdline.rs @@ -0,0 +1,5 @@ +//@ compile-flags: -F deprecated + +#[allow(deprecated)] //~ ERROR allow(deprecated) incompatible +fn main() { +} diff --git a/tests/ui/lint/lint-forbid-cmdline-1.stderr b/tests/ui/lint/lint-forbid-cmdline.stderr similarity index 70% rename from tests/ui/lint/lint-forbid-cmdline-1.stderr rename to tests/ui/lint/lint-forbid-cmdline.stderr index 7f4893fabd97..3920a7429763 100644 --- a/tests/ui/lint/lint-forbid-cmdline-1.stderr +++ b/tests/ui/lint/lint-forbid-cmdline.stderr @@ -1,10 +1,10 @@ error[E0453]: allow(deprecated) incompatible with previous forbid - --> $DIR/lint-forbid-cmdline-1.rs:3:9 + --> $DIR/lint-forbid-cmdline.rs:3:9 | LL | #[allow(deprecated)] | ^^^^^^^^^^ overruled by previous forbid | - = note: `forbid` lint level was set on command line (`-F deprecated`) + = note: `forbid` lint level was set on command line error: aborting due to 1 previous error diff --git a/tests/ui/lint/lint-invalid-atomic-ordering-update.rs b/tests/ui/lint/lint-invalid-atomic-ordering-update.rs index 0cb87d4eab1b..ac41e7cee0c2 100644 --- a/tests/ui/lint/lint-invalid-atomic-ordering-update.rs +++ b/tests/ui/lint/lint-invalid-atomic-ordering-update.rs @@ -1,4 +1,6 @@ //@ only-x86_64 +#![feature(atomic_try_update)] + use std::sync::atomic::{AtomicIsize, Ordering}; fn main() { diff --git a/tests/ui/lint/lint-invalid-atomic-ordering-update.stderr b/tests/ui/lint/lint-invalid-atomic-ordering-update.stderr index 5a5efbd85b0a..8c266bacf314 100644 --- a/tests/ui/lint/lint-invalid-atomic-ordering-update.stderr +++ b/tests/ui/lint/lint-invalid-atomic-ordering-update.stderr @@ -1,5 +1,5 @@ error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:71:47 + --> $DIR/lint-invalid-atomic-ordering-update.rs:73:47 | LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -8,7 +8,7 @@ LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::AcqRel, |old| Some( = note: `#[deny(invalid_atomic_ordering)]` on by default error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:73:45 + --> $DIR/lint-invalid-atomic-ordering-update.rs:75:45 | LL | let _ = x.try_update(Ordering::Relaxed, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -16,7 +16,7 @@ LL | let _ = x.try_update(Ordering::Relaxed, Ordering::AcqRel, |old| Some(ol = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:75:41 + --> $DIR/lint-invalid-atomic-ordering-update.rs:77:41 | LL | let _ = x.update(Ordering::Relaxed, Ordering::AcqRel, |old| old + 1); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -24,7 +24,7 @@ LL | let _ = x.update(Ordering::Relaxed, Ordering::AcqRel, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:78:47 + --> $DIR/lint-invalid-atomic-ordering-update.rs:80:47 | LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -32,7 +32,7 @@ LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::AcqRel, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:80:45 + --> $DIR/lint-invalid-atomic-ordering-update.rs:82:45 | LL | let _ = x.try_update(Ordering::Acquire, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -40,7 +40,7 @@ LL | let _ = x.try_update(Ordering::Acquire, Ordering::AcqRel, |old| Some(ol = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:82:41 + --> $DIR/lint-invalid-atomic-ordering-update.rs:84:41 | LL | let _ = x.update(Ordering::Acquire, Ordering::AcqRel, |old| old + 1); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -48,7 +48,7 @@ LL | let _ = x.update(Ordering::Acquire, Ordering::AcqRel, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:85:47 + --> $DIR/lint-invalid-atomic-ordering-update.rs:87:47 | LL | let _ = x.fetch_update(Ordering::Release, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -56,7 +56,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::AcqRel, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:87:45 + --> $DIR/lint-invalid-atomic-ordering-update.rs:89:45 | LL | let _ = x.try_update(Ordering::Release, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -64,7 +64,7 @@ LL | let _ = x.try_update(Ordering::Release, Ordering::AcqRel, |old| Some(ol = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:89:41 + --> $DIR/lint-invalid-atomic-ordering-update.rs:91:41 | LL | let _ = x.update(Ordering::Release, Ordering::AcqRel, |old| old + 1); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -72,7 +72,7 @@ LL | let _ = x.update(Ordering::Release, Ordering::AcqRel, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:92:46 + --> $DIR/lint-invalid-atomic-ordering-update.rs:94:46 | LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -80,7 +80,7 @@ LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::AcqRel, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:94:44 + --> $DIR/lint-invalid-atomic-ordering-update.rs:96:44 | LL | let _ = x.try_update(Ordering::AcqRel, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -88,7 +88,7 @@ LL | let _ = x.try_update(Ordering::AcqRel, Ordering::AcqRel, |old| Some(old = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:96:40 + --> $DIR/lint-invalid-atomic-ordering-update.rs:98:40 | LL | let _ = x.update(Ordering::AcqRel, Ordering::AcqRel, |old| old + 1); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -96,7 +96,7 @@ LL | let _ = x.update(Ordering::AcqRel, Ordering::AcqRel, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:99:46 + --> $DIR/lint-invalid-atomic-ordering-update.rs:101:46 | LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -104,7 +104,7 @@ LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::AcqRel, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:101:44 + --> $DIR/lint-invalid-atomic-ordering-update.rs:103:44 | LL | let _ = x.try_update(Ordering::SeqCst, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -112,7 +112,7 @@ LL | let _ = x.try_update(Ordering::SeqCst, Ordering::AcqRel, |old| Some(old = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:103:40 + --> $DIR/lint-invalid-atomic-ordering-update.rs:105:40 | LL | let _ = x.update(Ordering::SeqCst, Ordering::AcqRel, |old| old + 1); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -120,7 +120,7 @@ LL | let _ = x.update(Ordering::SeqCst, Ordering::AcqRel, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:108:47 + --> $DIR/lint-invalid-atomic-ordering-update.rs:110:47 | LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -128,7 +128,7 @@ LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::Release, |old| Some = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:110:45 + --> $DIR/lint-invalid-atomic-ordering-update.rs:112:45 | LL | let _ = x.try_update(Ordering::Relaxed, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -136,7 +136,7 @@ LL | let _ = x.try_update(Ordering::Relaxed, Ordering::Release, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:112:41 + --> $DIR/lint-invalid-atomic-ordering-update.rs:114:41 | LL | let _ = x.update(Ordering::Relaxed, Ordering::Release, |old| old + 1); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -144,7 +144,7 @@ LL | let _ = x.update(Ordering::Relaxed, Ordering::Release, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:115:47 + --> $DIR/lint-invalid-atomic-ordering-update.rs:117:47 | LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -152,7 +152,7 @@ LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::Release, |old| Some = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:117:45 + --> $DIR/lint-invalid-atomic-ordering-update.rs:119:45 | LL | let _ = x.try_update(Ordering::Acquire, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -160,7 +160,7 @@ LL | let _ = x.try_update(Ordering::Acquire, Ordering::Release, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:119:41 + --> $DIR/lint-invalid-atomic-ordering-update.rs:121:41 | LL | let _ = x.update(Ordering::Acquire, Ordering::Release, |old| old + 1); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -168,7 +168,7 @@ LL | let _ = x.update(Ordering::Acquire, Ordering::Release, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:122:47 + --> $DIR/lint-invalid-atomic-ordering-update.rs:124:47 | LL | let _ = x.fetch_update(Ordering::Release, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -176,7 +176,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::Release, |old| Some = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:124:45 + --> $DIR/lint-invalid-atomic-ordering-update.rs:126:45 | LL | let _ = x.try_update(Ordering::Release, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -184,7 +184,7 @@ LL | let _ = x.try_update(Ordering::Release, Ordering::Release, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:126:41 + --> $DIR/lint-invalid-atomic-ordering-update.rs:128:41 | LL | let _ = x.update(Ordering::Release, Ordering::Release, |old| old + 1); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -192,7 +192,7 @@ LL | let _ = x.update(Ordering::Release, Ordering::Release, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:129:46 + --> $DIR/lint-invalid-atomic-ordering-update.rs:131:46 | LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -200,7 +200,7 @@ LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::Release, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:131:44 + --> $DIR/lint-invalid-atomic-ordering-update.rs:133:44 | LL | let _ = x.try_update(Ordering::AcqRel, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -208,7 +208,7 @@ LL | let _ = x.try_update(Ordering::AcqRel, Ordering::Release, |old| Some(ol = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:133:40 + --> $DIR/lint-invalid-atomic-ordering-update.rs:135:40 | LL | let _ = x.update(Ordering::AcqRel, Ordering::Release, |old| old + 1); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -216,7 +216,7 @@ LL | let _ = x.update(Ordering::AcqRel, Ordering::Release, |old| old + 1); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:136:46 + --> $DIR/lint-invalid-atomic-ordering-update.rs:138:46 | LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -224,7 +224,7 @@ LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::Release, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `try_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `try_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:138:44 + --> $DIR/lint-invalid-atomic-ordering-update.rs:140:44 | LL | let _ = x.try_update(Ordering::SeqCst, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -232,7 +232,7 @@ LL | let _ = x.try_update(Ordering::SeqCst, Ordering::Release, |old| Some(ol = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-update.rs:140:40 + --> $DIR/lint-invalid-atomic-ordering-update.rs:142:40 | LL | let _ = x.update(Ordering::SeqCst, Ordering::Release, |old| old + 1); | ^^^^^^^^^^^^^^^^^ invalid failure ordering diff --git a/tests/ui/lint/lint-misplaced-attr.rs b/tests/ui/lint/lint-misplaced-attr.rs index 557dbe294943..d06917ea3f8a 100644 --- a/tests/ui/lint/lint-misplaced-attr.rs +++ b/tests/ui/lint/lint-misplaced-attr.rs @@ -4,7 +4,7 @@ #![deny(unused_attributes)] mod a { - #![crate_type = "bin"] //~ ERROR the `#![crate_type]` attribute can only be used at the crate root + #![crate_type = "bin"] //~ ERROR should be in the root module } #[crate_type = "bin"] fn main() {} //~ ERROR should be an inner diff --git a/tests/ui/lint/lint-misplaced-attr.stderr b/tests/ui/lint/lint-misplaced-attr.stderr index d46bbc44c1b2..bcfda1700800 100644 --- a/tests/ui/lint/lint-misplaced-attr.stderr +++ b/tests/ui/lint/lint-misplaced-attr.stderr @@ -1,4 +1,4 @@ -error: the `#![crate_type]` attribute can only be used at the crate root +error: crate-level attribute should be in the root module --> $DIR/lint-misplaced-attr.rs:7:5 | LL | #![crate_type = "bin"] @@ -10,17 +10,16 @@ note: the lint level is defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_type]` +error: crate-level attribute should be an inner attribute --> $DIR/lint-misplaced-attr.rs:10:1 | LL | #[crate_type = "bin"] fn main() {} | ^^^^^^^^^^^^^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this function - --> $DIR/lint-misplaced-attr.rs:10:23 +help: add a `!` | -LL | #[crate_type = "bin"] fn main() {} - | ^^^^^^^^^^^^ +LL | #![crate_type = "bin"] fn main() {} + | + error: aborting due to 2 previous errors diff --git a/tests/ui/lint/lint-stability-deprecated.stderr b/tests/ui/lint/lint-stability-deprecated.stderr index ce0bc36f6292..bda4ee82d1fc 100644 --- a/tests/ui/lint/lint-stability-deprecated.stderr +++ b/tests/ui/lint/lint-stability-deprecated.stderr @@ -1,8 +1,8 @@ -warning: use of deprecated function `lint_stability::deprecated`: text - --> $DIR/lint-stability-deprecated.rs:24:9 +warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text + --> $DIR/lint-stability-deprecated.rs:97:48 | -LL | deprecated(); - | ^^^^^^^^^^ +LL | struct S2(T::TypeDeprecated); + | ^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/lint-stability-deprecated.rs:6:9 @@ -10,6 +10,12 @@ note: the lint level is defined here LL | #![warn(deprecated)] | ^^^^^^^^^^ +warning: use of deprecated function `lint_stability::deprecated`: text + --> $DIR/lint-stability-deprecated.rs:24:9 + | +LL | deprecated(); + | ^^^^^^^^^^ + warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text --> $DIR/lint-stability-deprecated.rs:29:16 | @@ -316,12 +322,6 @@ warning: use of deprecated function `this_crate::MethodTester::test_method_body: LL | fn_in_body(); | ^^^^^^^^^^ -warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text - --> $DIR/lint-stability-deprecated.rs:97:48 - | -LL | struct S2(T::TypeDeprecated); - | ^^^^^^^^^^^^^^^^^ - warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text --> $DIR/lint-stability-deprecated.rs:101:13 | diff --git a/tests/ui/lint/lint-stability.stderr b/tests/ui/lint/lint-stability.stderr index fd57908a77b5..249f3ccaa542 100644 --- a/tests/ui/lint/lint-stability.stderr +++ b/tests/ui/lint/lint-stability.stderr @@ -1,3 +1,12 @@ +error[E0658]: use of unstable library feature `unstable_test_feature` + --> $DIR/lint-stability.rs:88:48 + | +LL | struct S1(T::TypeUnstable); + | ^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + error[E0658]: use of unstable library feature `unstable_test_feature` --> $DIR/lint-stability.rs:17:5 | @@ -367,15 +376,6 @@ LL | let _ = Unstable::StableVariant; = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `unstable_test_feature` - --> $DIR/lint-stability.rs:88:48 - | -LL | struct S1(T::TypeUnstable); - | ^^^^^^^^^^^^^^^ - | - = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - error[E0658]: use of unstable library feature `unstable_test_feature` --> $DIR/lint-stability.rs:92:13 | diff --git a/tests/ui/lint/lint-type-overflow2.rs b/tests/ui/lint/lint-type-overflow2.rs index d3ff02aeb722..ac7420326c89 100644 --- a/tests/ui/lint/lint-type-overflow2.rs +++ b/tests/ui/lint/lint-type-overflow2.rs @@ -1,19 +1,13 @@ //@ compile-flags: -O -#![feature(f16)] -#![feature(f128)] #![deny(overflowing_literals)] fn main() { let x2: i8 = --128; //~ ERROR literal out of range for `i8` //~| WARN use of a double negation - let x = -65520.0_f16; //~ ERROR literal out of range for `f16` - let x = 65520.0_f16; //~ ERROR literal out of range for `f16` let x = -3.40282357e+38_f32; //~ ERROR literal out of range for `f32` let x = 3.40282357e+38_f32; //~ ERROR literal out of range for `f32` let x = -1.7976931348623159e+308_f64; //~ ERROR literal out of range for `f64` let x = 1.7976931348623159e+308_f64; //~ ERROR literal out of range for `f64` - let x = -1.1897314953572317650857593266280075e+4932_f128; //~ ERROR literal out of range for `f128` - let x = 1.1897314953572317650857593266280075e+4932_f128; //~ ERROR literal out of range for `f128` } diff --git a/tests/ui/lint/lint-type-overflow2.stderr b/tests/ui/lint/lint-type-overflow2.stderr index c045d243753e..2cfb18e9fe92 100644 --- a/tests/ui/lint/lint-type-overflow2.stderr +++ b/tests/ui/lint/lint-type-overflow2.stderr @@ -1,5 +1,5 @@ warning: use of a double negation - --> $DIR/lint-type-overflow2.rs:8:18 + --> $DIR/lint-type-overflow2.rs:6:18 | LL | let x2: i8 = --128; | ^^^^^ @@ -13,7 +13,7 @@ LL | let x2: i8 = -(-128); | + + error: literal out of range for `i8` - --> $DIR/lint-type-overflow2.rs:8:20 + --> $DIR/lint-type-overflow2.rs:6:20 | LL | let x2: i8 = --128; | ^^^ @@ -21,29 +21,13 @@ LL | let x2: i8 = --128; = note: the literal `128` does not fit into the type `i8` whose range is `-128..=127` = help: consider using the type `u8` instead note: the lint level is defined here - --> $DIR/lint-type-overflow2.rs:5:9 + --> $DIR/lint-type-overflow2.rs:3:9 | LL | #![deny(overflowing_literals)] | ^^^^^^^^^^^^^^^^^^^^ -error: literal out of range for `f16` - --> $DIR/lint-type-overflow2.rs:11:14 - | -LL | let x = -65520.0_f16; - | ^^^^^^^^^^^ - | - = note: the literal `65520.0_f16` does not fit into the type `f16` and will be converted to `f16::INFINITY` - -error: literal out of range for `f16` - --> $DIR/lint-type-overflow2.rs:12:14 - | -LL | let x = 65520.0_f16; - | ^^^^^^^^^^^ - | - = note: the literal `65520.0_f16` does not fit into the type `f16` and will be converted to `f16::INFINITY` - error: literal out of range for `f32` - --> $DIR/lint-type-overflow2.rs:13:14 + --> $DIR/lint-type-overflow2.rs:9:14 | LL | let x = -3.40282357e+38_f32; | ^^^^^^^^^^^^^^^^^^ @@ -51,7 +35,7 @@ LL | let x = -3.40282357e+38_f32; = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `f32::INFINITY` error: literal out of range for `f32` - --> $DIR/lint-type-overflow2.rs:14:14 + --> $DIR/lint-type-overflow2.rs:10:14 | LL | let x = 3.40282357e+38_f32; | ^^^^^^^^^^^^^^^^^^ @@ -59,7 +43,7 @@ LL | let x = 3.40282357e+38_f32; = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `f32::INFINITY` error: literal out of range for `f64` - --> $DIR/lint-type-overflow2.rs:15:14 + --> $DIR/lint-type-overflow2.rs:11:14 | LL | let x = -1.7976931348623159e+308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,28 +51,12 @@ LL | let x = -1.7976931348623159e+308_f64; = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `f64::INFINITY` error: literal out of range for `f64` - --> $DIR/lint-type-overflow2.rs:16:14 + --> $DIR/lint-type-overflow2.rs:12:14 | LL | let x = 1.7976931348623159e+308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `f64::INFINITY` -error: literal out of range for `f128` - --> $DIR/lint-type-overflow2.rs:17:14 - | -LL | let x = -1.1897314953572317650857593266280075e+4932_f128; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the literal `1.1897314953572317650857593266280075e+4932_f128` does not fit into the type `f128` and will be converted to `f128::INFINITY` - -error: literal out of range for `f128` - --> $DIR/lint-type-overflow2.rs:18:14 - | -LL | let x = 1.1897314953572317650857593266280075e+4932_f128; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the literal `1.1897314953572317650857593266280075e+4932_f128` does not fit into the type `f128` and will be converted to `f128::INFINITY` - -error: aborting due to 9 previous errors; 1 warning emitted +error: aborting due to 5 previous errors; 1 warning emitted diff --git a/tests/ui/lint/must_not_suspend/other_items.stderr b/tests/ui/lint/must_not_suspend/other_items.stderr index 289230b027ad..999a9d2fb3dc 100644 --- a/tests/ui/lint/must_not_suspend/other_items.stderr +++ b/tests/ui/lint/must_not_suspend/other_items.stderr @@ -4,7 +4,7 @@ error: `#[must_not_suspend]` attribute cannot be used on modules LL | #[must_not_suspend] | ^^^^^^^^^^^^^^^^^^^ | - = help: `#[must_not_suspend]` can be applied to data types and traits + = help: `#[must_not_suspend]` can be applied to data types, traits, and unions error: aborting due to 1 previous error diff --git a/tests/ui/lint/must_not_suspend/return.stderr b/tests/ui/lint/must_not_suspend/return.stderr index b041491128e1..1a81b1a39f0c 100644 --- a/tests/ui/lint/must_not_suspend/return.stderr +++ b/tests/ui/lint/must_not_suspend/return.stderr @@ -4,7 +4,7 @@ error: `#[must_not_suspend]` attribute cannot be used on functions LL | #[must_not_suspend] | ^^^^^^^^^^^^^^^^^^^ | - = help: `#[must_not_suspend]` can be applied to data types and traits + = help: `#[must_not_suspend]` can be applied to data types, traits, and unions error: aborting due to 1 previous error diff --git a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-2.rs b/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-2.rs deleted file mode 100644 index 43ee6bf26a69..000000000000 --- a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Make sure that the copied `#[expect]` attr in the derived code does not trigger an unfulfilled -// expectation as it's linked to the original one which is fulfilled. -// -// See for rational. - -//@ check-pass - -#[expect(non_camel_case_types)] -#[derive(Debug)] -pub struct SCREAMING_CASE { - pub t_ref: i64, -} - -fn main() {} diff --git a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.rs b/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.rs deleted file mode 100644 index 904366e6532e..000000000000 --- a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Make sure we produce the unfulfilled expectation lint if neither the struct or the -// derived code fulfilled it. - -//@ check-pass - -#[expect(unexpected_cfgs)] -//~^ WARN this lint expectation is unfulfilled -//~^^ WARN this lint expectation is unfulfilled -#[derive(Debug)] -pub struct MyStruct { - pub t_ref: i64, -} - -fn main() {} diff --git a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.stderr b/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.stderr deleted file mode 100644 index 6478ec435db0..000000000000 --- a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: this lint expectation is unfulfilled - --> $DIR/derive-expect-issue-150553-3.rs:6:10 - | -LL | #[expect(unexpected_cfgs)] - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(unfulfilled_lint_expectations)]` on by default - -warning: this lint expectation is unfulfilled - --> $DIR/derive-expect-issue-150553-3.rs:6:10 - | -LL | #[expect(unexpected_cfgs)] - | ^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 2 warnings emitted - diff --git a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553.rs b/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553.rs deleted file mode 100644 index 1752835c8bb8..000000000000 --- a/tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Make sure we properly copy the `#[expect]` attr to the derived code and that no -// unfulfilled expectations are trigerred. -// -// See for rational. - -//@ check-pass - -#![deny(redundant_lifetimes)] - -use std::fmt::Debug; - -#[derive(Debug)] -#[expect(redundant_lifetimes)] -pub struct RefWrapper<'a, T> -where - 'a: 'static, - T: Debug, -{ - pub t_ref: &'a T, -} - -fn main() {} diff --git a/tests/ui/lint/unused-parens-labeled-break-issue-143256.rs b/tests/ui/lint/unused-parens-labeled-break-issue-143256.rs deleted file mode 100644 index 8594e646f605..000000000000 --- a/tests/ui/lint/unused-parens-labeled-break-issue-143256.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ check-pass -// testcase for https://github.com/rust-lang/rust/issues/143256 - -#![deny(unused_parens)] -#![allow(unreachable_code, unused_variables, dead_code)] - -fn foo() { - let _x = || 'outer: loop { - let inner = 'inner: loop { - let i = Default::default(); - // the parentheses here are necessary - if (break 'outer i) { - loop { - break 'inner 5i8; - } - } else if true { - break 'inner 6; - } - break 7; - }; - break inner < 8; - }; -} - -fn main() {} diff --git a/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr b/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr index 5928eb6c58c4..b06e65af7bc7 100644 --- a/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr +++ b/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr @@ -17,7 +17,7 @@ error: crate-level attribute should be an inner attribute: add an exclamation ma LL | #[crate_name = concat !()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this macro def +note: This attribute does not have an `!`, which means it is applied to this macro def --> $DIR/concat-in-crate-name-issue-137687.rs:5:1 | LL | / macro_rules! a { diff --git a/tests/ui/lint/unused/diverging-path.rs b/tests/ui/lint/unused/diverging-path.rs deleted file mode 100644 index 7f364518fe97..000000000000 --- a/tests/ui/lint/unused/diverging-path.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! Assignments to a captured variable within a diverging closure should not be considered unused if -//! the divergence is caught. -//! -//! Regression test for https://github.com/rust-lang/rust/issues/152079 -//@ compile-flags: -Wunused -//@ check-pass - -fn main() { - let mut x = 1; - catch(|| { - x = 2; - panic!(); - }); - dbg!(x); -} - -fn catch(f: F) { - if let Ok(true) = std::fs::exists("may_or_may_not_call_f") { - _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)); - } -} diff --git a/tests/ui/lint/unused/lint-unsed-in-macro-issue-151269.rs b/tests/ui/lint/unused/lint-unsed-in-macro-issue-151269.rs deleted file mode 100644 index 65b8a22d383a..000000000000 --- a/tests/ui/lint/unused/lint-unsed-in-macro-issue-151269.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![deny(unused_must_use)] - -fn error() -> Result<(), ()> { - Err(()) -} - -macro_rules! foo { - () => {{ - error(); - }}; -} - -fn main() { - let _ = foo!(); //~ ERROR unused `Result` that must be used -} diff --git a/tests/ui/lint/unused/lint-unsed-in-macro-issue-151269.stderr b/tests/ui/lint/unused/lint-unsed-in-macro-issue-151269.stderr deleted file mode 100644 index 12cedf58974b..000000000000 --- a/tests/ui/lint/unused/lint-unsed-in-macro-issue-151269.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: unused `Result` that must be used - --> $DIR/lint-unsed-in-macro-issue-151269.rs:14:13 - | -LL | let _ = foo!(); - | ^^^^^^ - | - = note: this `Result` may be an `Err` variant, which should be handled -note: the lint level is defined here - --> $DIR/lint-unsed-in-macro-issue-151269.rs:1:9 - | -LL | #![deny(unused_must_use)] - | ^^^^^^^^^^^^^^^ -help: use `let _ = ...` to ignore the resulting value - | -LL | let _ = error(); - | +++++++ - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/unused/mut-used-despite-borrowck-error.rs b/tests/ui/lint/unused/mut-used-despite-borrowck-error.rs deleted file mode 100644 index 7f1a51bc8510..000000000000 --- a/tests/ui/lint/unused/mut-used-despite-borrowck-error.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! Do not fire unused_mut lint when mutation of the bound variable fails due to a borrow-checking -//! error. -//! -//! Regression test for https://github.com/rust-lang/rust/issues/152024 -//@ compile-flags: -W unused_mut - -struct Thing; -impl Drop for Thing { - fn drop(&mut self) {} -} - -fn main() { - let mut t; - let mut b = None; - loop { - t = Thing; //~ ERROR cannot assign to `t` because it is borrowed - b.insert(&t); - } -} diff --git a/tests/ui/lint/unused/mut-used-despite-borrowck-error.stderr b/tests/ui/lint/unused/mut-used-despite-borrowck-error.stderr deleted file mode 100644 index c03cf3f7c609..000000000000 --- a/tests/ui/lint/unused/mut-used-despite-borrowck-error.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0506]: cannot assign to `t` because it is borrowed - --> $DIR/mut-used-despite-borrowck-error.rs:16:9 - | -LL | t = Thing; - | ^ `t` is assigned to here but it was already borrowed -LL | b.insert(&t); - | - -- `t` is borrowed here - | | - | borrow later used here - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/lint/unused/underscore-capture-issue-149889.rs b/tests/ui/lint/unused/underscore-capture-issue-149889.rs deleted file mode 100644 index 3fbaf2588516..000000000000 --- a/tests/ui/lint/unused/underscore-capture-issue-149889.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ check-pass -#![deny(unused_assignments)] - -fn lock() -> impl Drop { - struct Handle; - - impl Drop for Handle { - fn drop(&mut self) {} - } - - Handle -} - -fn bar(_f: impl FnMut(bool)) {} - -pub fn foo() { - let mut _handle = None; - bar(move |l| { - if l { - _handle = Some(lock()); - } else { - _handle = None; - } - }) -} - -fn main() { - foo(); -} diff --git a/tests/ui/lint/unused/unused-allocation-box-ref-issue-151846.rs b/tests/ui/lint/unused/unused-allocation-box-ref-issue-151846.rs deleted file mode 100644 index 57eefc3891fa..000000000000 --- a/tests/ui/lint/unused/unused-allocation-box-ref-issue-151846.rs +++ /dev/null @@ -1,54 +0,0 @@ -//@ check-pass -// Test for issue #151846: unused_allocation warning should ignore -// allocations to pass Box to things taking self: &Box - -#![deny(unused_allocation)] - -struct MyStruct; - -trait TraitTakesBoxRef { - fn trait_takes_box_ref(&self); -} - -impl TraitTakesBoxRef for Box { - fn trait_takes_box_ref(&self) {} -} - -impl MyStruct { - fn inherent_takes_box_ref(self: &Box) {} -} - -fn takes_box_ref(_: &Box) {} - -trait TraitTakesBoxVal { - fn trait_takes_box_val(self); -} - -impl TraitTakesBoxVal for Box { - fn trait_takes_box_val(self) {} -} - -impl MyStruct { - fn inherent_takes_box_val(self: Box) {} -} - -fn takes_box_val(_: Box) {} - -pub fn foo() { - // These should NOT warn - the allocation is necessary because - // the method takes &Box - Box::new(MyStruct).trait_takes_box_ref(); - Box::new(MyStruct).inherent_takes_box_ref(); - takes_box_ref(&Box::new(MyStruct)); - - // These already don't warn - the allocation is necessary - Box::new(MyStruct).trait_takes_box_val(); - Box::new(MyStruct).inherent_takes_box_val(); - takes_box_val(Box::new(MyStruct)); - - // Fully-qualified syntax also does not warn: - as TraitTakesBoxRef>::trait_takes_box_ref(&Box::new(MyStruct)); - MyStruct::inherent_takes_box_ref(&Box::new(MyStruct)); -} - -fn main() {} diff --git a/tests/ui/lint/unused/unused-attr-duplicate.stderr b/tests/ui/lint/unused/unused-attr-duplicate.stderr index 351645f4a783..54ed351d4348 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.stderr +++ b/tests/ui/lint/unused/unused-attr-duplicate.stderr @@ -16,6 +16,18 @@ note: the lint level is defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:34:1 + | +LL | #![no_builtins] + | ^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:33:1 + | +LL | #![no_builtins] + | ^^^^^^^^^^^^^^^ + error: unused attribute --> $DIR/unused-attr-duplicate.rs:37:1 | @@ -304,17 +316,5 @@ LL | #![windows_subsystem = "console"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:34:1 - | -LL | #![no_builtins] - | ^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:33:1 - | -LL | #![no_builtins] - | ^^^^^^^^^^^^^^^ - error: aborting due to 25 previous errors diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.stderr b/tests/ui/lint/unused/unused-attr-macro-rules.stderr index 75e86d3c014f..e251ec65622e 100644 --- a/tests/ui/lint/unused/unused-attr-macro-rules.stderr +++ b/tests/ui/lint/unused/unused-attr-macro-rules.stderr @@ -27,7 +27,7 @@ error: crate-level attribute should be an inner attribute: add an exclamation ma LL | #[recursion_limit="1"] | ^^^^^^^^^^^^^^^^^^^^^^ | -note: this attribute does not have an `!`, which means it is applied to this macro def +note: This attribute does not have an `!`, which means it is applied to this macro def --> $DIR/unused-attr-macro-rules.rs:12:1 | LL | / macro_rules! foo { diff --git a/tests/ui/lint/unused/unused-macros.stderr b/tests/ui/lint/unused/unused-macros.stderr index 50c80b61eb5b..d0baf5becec4 100644 --- a/tests/ui/lint/unused/unused-macros.stderr +++ b/tests/ui/lint/unused/unused-macros.stderr @@ -15,11 +15,6 @@ error: unused macro definition: `m` | LL | macro_rules! m { | ^ -... -LL | create_macro!(); - | --------------- in this macro invocation - | - = note: this error originates in the macro `create_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: unused macro definition: `unused` --> $DIR/unused-macros.rs:26:18 diff --git a/tests/ui/lint/unused/unused_assignments_across_match_guards.rs b/tests/ui/lint/unused/unused_assignments_across_match_guards.rs deleted file mode 100644 index 666a529b8f85..000000000000 --- a/tests/ui/lint/unused/unused_assignments_across_match_guards.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Regression test for -// This test ensures that unused_assignments does not report assignments used in a match. -//@ check-pass - -fn pnk(x: usize) -> &'static str { - let mut k1 = "k1"; - let mut h1 = "h1"; - match x & 3 { - 3 if { k1 = "unused?"; false } => (), - _ if { h1 = k1; true } => (), - _ => (), - } - h1 -} - -#[deny(unused_assignments)] -fn main() { - pnk(3); -} diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr index 3fc340b5188f..3192c0994548 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.stderr +++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr @@ -5,7 +5,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions note: the lint level is defined here --> $DIR/unused_attributes-must_use.rs:4:9 | @@ -19,7 +19,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on modules --> $DIR/unused_attributes-must_use.rs:11:1 @@ -28,7 +28,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on use statements --> $DIR/unused_attributes-must_use.rs:15:1 @@ -37,7 +37,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on constants --> $DIR/unused_attributes-must_use.rs:19:1 @@ -46,7 +46,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on statics --> $DIR/unused_attributes-must_use.rs:22:1 @@ -55,7 +55,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on inherent impl blocks --> $DIR/unused_attributes-must_use.rs:40:1 @@ -64,7 +64,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on foreign modules --> $DIR/unused_attributes-must_use.rs:55:1 @@ -73,7 +73,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on foreign statics --> $DIR/unused_attributes-must_use.rs:59:5 @@ -82,7 +82,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on type aliases --> $DIR/unused_attributes-must_use.rs:73:1 @@ -91,7 +91,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on type parameters --> $DIR/unused_attributes-must_use.rs:77:8 @@ -100,7 +100,7 @@ LL | fn qux<#[must_use] T>(_: T) {} | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on associated consts --> $DIR/unused_attributes-must_use.rs:82:5 @@ -109,7 +109,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on associated types --> $DIR/unused_attributes-must_use.rs:85:5 @@ -118,7 +118,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on trait impl blocks --> $DIR/unused_attributes-must_use.rs:95:1 @@ -127,7 +127,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on trait methods in impl blocks --> $DIR/unused_attributes-must_use.rs:100:5 @@ -136,7 +136,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, foreign functions, functions, inherent methods, provided trait methods, required trait methods, and traits + = help: `#[must_use]` can be applied to data types, foreign functions, functions, inherent methods, provided trait methods, required trait methods, traits, and unions error: `#[must_use]` attribute cannot be used on trait aliases --> $DIR/unused_attributes-must_use.rs:107:1 @@ -145,7 +145,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on macro defs --> $DIR/unused_attributes-must_use.rs:111:1 @@ -154,7 +154,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on statements --> $DIR/unused_attributes-must_use.rs:120:5 @@ -163,7 +163,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on closures --> $DIR/unused_attributes-must_use.rs:125:13 @@ -172,7 +172,7 @@ LL | let x = #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, foreign functions, functions, methods, and traits + = help: `#[must_use]` can be applied to data types, foreign functions, functions, methods, traits, and unions error: `#[must_use]` attribute cannot be used on match arms --> $DIR/unused_attributes-must_use.rs:148:9 @@ -181,7 +181,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on struct fields --> $DIR/unused_attributes-must_use.rs:157:28 @@ -190,7 +190,7 @@ LL | let s = PatternField { #[must_use] foo: 123 }; | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: `#[must_use]` attribute cannot be used on pattern fields --> $DIR/unused_attributes-must_use.rs:159:24 @@ -199,7 +199,7 @@ LL | let PatternField { #[must_use] foo } = s; | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions error: unused `X` that must be used --> $DIR/unused_attributes-must_use.rs:130:5 diff --git a/tests/ui/liveness/liveness-move-in-while.stderr b/tests/ui/liveness/liveness-move-in-while.stderr index 1bb97ad68c7c..dc48c4cc9acf 100644 --- a/tests/ui/liveness/liveness-move-in-while.stderr +++ b/tests/ui/liveness/liveness-move-in-while.stderr @@ -35,6 +35,7 @@ LL | while true { while true { while true { x = y; x.clone(); } } } | | inside of this loop | inside of this loop | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | while true { while true { while true { x = y.clone(); x.clone(); } } } diff --git a/tests/ui/liveness/liveness-use-after-move.stderr b/tests/ui/liveness/liveness-use-after-move.stderr index a94ceae79d56..eab51edca37f 100644 --- a/tests/ui/liveness/liveness-use-after-move.stderr +++ b/tests/ui/liveness/liveness-use-after-move.stderr @@ -9,6 +9,7 @@ LL | LL | println!("{}", *x); | ^^ value borrowed here after move | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | let y = x.clone(); diff --git a/tests/ui/liveness/liveness-use-after-send.stderr b/tests/ui/liveness/liveness-use-after-send.stderr index da682325347c..2323451a7d2d 100644 --- a/tests/ui/liveness/liveness-use-after-send.stderr +++ b/tests/ui/liveness/liveness-use-after-send.stderr @@ -13,6 +13,7 @@ note: consider changing this parameter type in function `send` to borrow instead | LL | fn send(ch: Chan, data: T) { | ---- in this function ^ this parameter takes ownership of the value + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | send(ch, message.clone()); diff --git a/tests/ui/loop-match/invalid-attribute.stderr b/tests/ui/loop-match/invalid-attribute.stderr index c23452b9b844..ddb68aea31b6 100644 --- a/tests/ui/loop-match/invalid-attribute.stderr +++ b/tests/ui/loop-match/invalid-attribute.stderr @@ -94,6 +94,14 @@ LL | #[const_continue] | = help: `#[const_continue]` can be applied to +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:40:9 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | 5 + | - not a break expression + error: `#[loop_match]` should be applied to a loop --> $DIR/invalid-attribute.rs:39:9 | @@ -103,13 +111,5 @@ LL | #[const_continue] LL | 5 | - not a loop -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:40:9 - | -LL | #[const_continue] - | ^^^^^^^^^^^^^^^^^ -LL | 5 - | - not a break expression - error: aborting due to 14 previous errors diff --git a/tests/ui/loops/loop-proper-liveness.stderr b/tests/ui/loops/loop-proper-liveness.stderr index 5432043c7d24..cd4c064bcd19 100644 --- a/tests/ui/loops/loop-proper-liveness.stderr +++ b/tests/ui/loops/loop-proper-liveness.stderr @@ -7,6 +7,7 @@ LL | let x: i32; LL | println!("{:?}", x); | ^ `x` used here but it isn't initialized | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: i32 = 42; diff --git a/tests/ui/lowering/issue-96847.rs b/tests/ui/lowering/issue-96847.rs index a1fd105d9dd4..9408f6b9b4ab 100644 --- a/tests/ui/lowering/issue-96847.rs +++ b/tests/ui/lowering/issue-96847.rs @@ -1,4 +1,4 @@ -//@ check-fail +//@ run-pass // Test that this doesn't abort during AST lowering. In #96847 it did abort // because the attribute was being lowered twice. @@ -9,7 +9,6 @@ fn main() { for _ in [1,2,3] { #![lang="foo"] - //~^ ERROR definition of an unknown lang item: `foo` [E0522] println!("foo"); } } diff --git a/tests/ui/lowering/issue-96847.stderr b/tests/ui/lowering/issue-96847.stderr deleted file mode 100644 index 2cded32f9fb8..000000000000 --- a/tests/ui/lowering/issue-96847.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0522]: definition of an unknown lang item: `foo` - --> $DIR/issue-96847.rs:11:9 - | -LL | #![lang="foo"] - | ^^^^^^^^^^^^^^ definition of unknown lang item `foo` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0522`. diff --git a/tests/ui/macros/assert-matches-macro-msg.rs b/tests/ui/macros/assert-matches-macro-msg.rs index 17900936a299..956bc9cf0f49 100644 --- a/tests/ui/macros/assert-matches-macro-msg.rs +++ b/tests/ui/macros/assert-matches-macro-msg.rs @@ -4,7 +4,9 @@ //@ error-pattern: right: 3 //@ needs-subprocess -use std::assert_matches; +#![feature(assert_matches)] + +use std::assert_matches::assert_matches; fn main() { assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3"); diff --git a/tests/ui/macros/assert.with-generic-asset.stderr b/tests/ui/macros/assert.with-generic-asset.stderr index 523346830662..51d8f28a35c3 100644 --- a/tests/ui/macros/assert.with-generic-asset.stderr +++ b/tests/ui/macros/assert.with-generic-asset.stderr @@ -15,6 +15,8 @@ error: macro requires a boolean expression as an argument | LL | debug_assert!(); | ^^^^^^^^^^^^^^^ boolean expression required + | + = note: this error originates in the macro `debug_assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found keyword `struct` --> $DIR/assert.rs:8:19 diff --git a/tests/ui/macros/assert.without-generic-asset.stderr b/tests/ui/macros/assert.without-generic-asset.stderr index 523346830662..51d8f28a35c3 100644 --- a/tests/ui/macros/assert.without-generic-asset.stderr +++ b/tests/ui/macros/assert.without-generic-asset.stderr @@ -15,6 +15,8 @@ error: macro requires a boolean expression as an argument | LL | debug_assert!(); | ^^^^^^^^^^^^^^^ boolean expression required + | + = note: this error originates in the macro `debug_assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found keyword `struct` --> $DIR/assert.rs:8:19 diff --git a/tests/ui/macros/builtin-prelude-no-accidents.rs b/tests/ui/macros/builtin-prelude-no-accidents.rs index bffe3776b7b4..9bebcb75526f 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.rs +++ b/tests/ui/macros/builtin-prelude-no-accidents.rs @@ -2,7 +2,7 @@ // because macros with the same names are in prelude. fn main() { - env::current_dir; //~ ERROR cannot find module or crate `env` - type A = panic::PanicInfo; //~ ERROR cannot find module or crate `panic` - type B = vec::Vec; //~ ERROR cannot find module or crate `vec` + env::current_dir; //~ ERROR use of unresolved module or unlinked crate `env` + type A = panic::PanicInfo; //~ ERROR use of unresolved module or unlinked crate `panic` + type B = vec::Vec; //~ ERROR use of unresolved module or unlinked crate `vec` } diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index 3cc322373afb..8c7095a6aedf 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `env` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `env` --> $DIR/builtin-prelude-no-accidents.rs:5:5 | LL | env::current_dir; @@ -10,7 +10,7 @@ help: consider importing this module LL + use std::env; | -error[E0433]: cannot find module or crate `panic` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `panic` --> $DIR/builtin-prelude-no-accidents.rs:6:14 | LL | type A = panic::PanicInfo; @@ -22,7 +22,7 @@ help: consider importing this module LL + use std::panic; | -error[E0433]: cannot find module or crate `vec` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `vec` --> $DIR/builtin-prelude-no-accidents.rs:7:14 | LL | type B = vec::Vec; diff --git a/tests/ui/macros/builtin-std-paths-fail.rs b/tests/ui/macros/builtin-std-paths-fail.rs index fd51c42ff37f..c1a4e32a6dcb 100644 --- a/tests/ui/macros/builtin-std-paths-fail.rs +++ b/tests/ui/macros/builtin-std-paths-fail.rs @@ -1,25 +1,25 @@ #[derive( - core::RustcDecodable, //~ ERROR cannot find `RustcDecodable` in `core` - //~| ERROR cannot find `RustcDecodable` in `core` - core::RustcDecodable, //~ ERROR cannot find `RustcDecodable` in `core` - //~| ERROR cannot find `RustcDecodable` in `core` + core::RustcDecodable, //~ ERROR could not find `RustcDecodable` in `core` + //~| ERROR could not find `RustcDecodable` in `core` + core::RustcDecodable, //~ ERROR could not find `RustcDecodable` in `core` + //~| ERROR could not find `RustcDecodable` in `core` )] -#[core::bench] //~ ERROR cannot find `bench` in `core` -#[core::global_allocator] //~ ERROR cannot find `global_allocator` in `core` -#[core::test_case] //~ ERROR cannot find `test_case` in `core` -#[core::test] //~ ERROR cannot find `test` in `core` +#[core::bench] //~ ERROR could not find `bench` in `core` +#[core::global_allocator] //~ ERROR could not find `global_allocator` in `core` +#[core::test_case] //~ ERROR could not find `test_case` in `core` +#[core::test] //~ ERROR could not find `test` in `core` struct Core; #[derive( - std::RustcDecodable, //~ ERROR cannot find `RustcDecodable` in `std` - //~| ERROR cannot find `RustcDecodable` in `std` - std::RustcDecodable, //~ ERROR cannot find `RustcDecodable` in `std` - //~| ERROR cannot find `RustcDecodable` in `std` + std::RustcDecodable, //~ ERROR could not find `RustcDecodable` in `std` + //~| ERROR could not find `RustcDecodable` in `std` + std::RustcDecodable, //~ ERROR could not find `RustcDecodable` in `std` + //~| ERROR could not find `RustcDecodable` in `std` )] -#[std::bench] //~ ERROR cannot find `bench` in `std` -#[std::global_allocator] //~ ERROR cannot find `global_allocator` in `std` -#[std::test_case] //~ ERROR cannot find `test_case` in `std` -#[std::test] //~ ERROR cannot find `test` in `std` +#[std::bench] //~ ERROR could not find `bench` in `std` +#[std::global_allocator] //~ ERROR could not find `global_allocator` in `std` +#[std::test_case] //~ ERROR could not find `test_case` in `std` +#[std::test] //~ ERROR could not find `test` in `std` struct Std; fn main() {} diff --git a/tests/ui/macros/builtin-std-paths-fail.stderr b/tests/ui/macros/builtin-std-paths-fail.stderr index 247e3f172a3c..85d2bd2132f2 100644 --- a/tests/ui/macros/builtin-std-paths-fail.stderr +++ b/tests/ui/macros/builtin-std-paths-fail.stderr @@ -1,16 +1,16 @@ -error[E0433]: cannot find `RustcDecodable` in `core` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` --> $DIR/builtin-std-paths-fail.rs:2:11 | LL | core::RustcDecodable, | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` -error[E0433]: cannot find `RustcDecodable` in `core` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` --> $DIR/builtin-std-paths-fail.rs:4:11 | LL | core::RustcDecodable, | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` -error[E0433]: cannot find `RustcDecodable` in `core` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` --> $DIR/builtin-std-paths-fail.rs:2:11 | LL | core::RustcDecodable, @@ -18,7 +18,7 @@ LL | core::RustcDecodable, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0433]: cannot find `RustcDecodable` in `core` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` --> $DIR/builtin-std-paths-fail.rs:4:11 | LL | core::RustcDecodable, @@ -26,43 +26,43 @@ LL | core::RustcDecodable, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0433]: cannot find `bench` in `core` +error[E0433]: failed to resolve: could not find `bench` in `core` --> $DIR/builtin-std-paths-fail.rs:7:9 | LL | #[core::bench] | ^^^^^ could not find `bench` in `core` -error[E0433]: cannot find `global_allocator` in `core` +error[E0433]: failed to resolve: could not find `global_allocator` in `core` --> $DIR/builtin-std-paths-fail.rs:8:9 | LL | #[core::global_allocator] | ^^^^^^^^^^^^^^^^ could not find `global_allocator` in `core` -error[E0433]: cannot find `test_case` in `core` +error[E0433]: failed to resolve: could not find `test_case` in `core` --> $DIR/builtin-std-paths-fail.rs:9:9 | LL | #[core::test_case] | ^^^^^^^^^ could not find `test_case` in `core` -error[E0433]: cannot find `test` in `core` +error[E0433]: failed to resolve: could not find `test` in `core` --> $DIR/builtin-std-paths-fail.rs:10:9 | LL | #[core::test] | ^^^^ could not find `test` in `core` -error[E0433]: cannot find `RustcDecodable` in `std` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` --> $DIR/builtin-std-paths-fail.rs:14:10 | LL | std::RustcDecodable, | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std` -error[E0433]: cannot find `RustcDecodable` in `std` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` --> $DIR/builtin-std-paths-fail.rs:16:10 | LL | std::RustcDecodable, | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std` -error[E0433]: cannot find `RustcDecodable` in `std` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` --> $DIR/builtin-std-paths-fail.rs:14:10 | LL | std::RustcDecodable, @@ -70,7 +70,7 @@ LL | std::RustcDecodable, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0433]: cannot find `RustcDecodable` in `std` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` --> $DIR/builtin-std-paths-fail.rs:16:10 | LL | std::RustcDecodable, @@ -78,25 +78,25 @@ LL | std::RustcDecodable, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0433]: cannot find `bench` in `std` +error[E0433]: failed to resolve: could not find `bench` in `std` --> $DIR/builtin-std-paths-fail.rs:19:8 | LL | #[std::bench] | ^^^^^ could not find `bench` in `std` -error[E0433]: cannot find `global_allocator` in `std` +error[E0433]: failed to resolve: could not find `global_allocator` in `std` --> $DIR/builtin-std-paths-fail.rs:20:8 | LL | #[std::global_allocator] | ^^^^^^^^^^^^^^^^ could not find `global_allocator` in `std` -error[E0433]: cannot find `test_case` in `std` +error[E0433]: failed to resolve: could not find `test_case` in `std` --> $DIR/builtin-std-paths-fail.rs:21:8 | LL | #[std::test_case] | ^^^^^^^^^ could not find `test_case` in `std` -error[E0433]: cannot find `test` in `std` +error[E0433]: failed to resolve: could not find `test` in `std` --> $DIR/builtin-std-paths-fail.rs:22:8 | LL | #[std::test] diff --git a/tests/ui/macros/cfg_select.rs b/tests/ui/macros/cfg_select.rs index 693e27daad7a..2369158ba82a 100644 --- a/tests/ui/macros/cfg_select.rs +++ b/tests/ui/macros/cfg_select.rs @@ -1,6 +1,5 @@ #![feature(cfg_select)] #![crate_type = "lib"] -#![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests. fn print() { println!(cfg_select! { @@ -24,46 +23,45 @@ fn arm_rhs_expr_1() -> i32 { fn arm_rhs_expr_2() -> i32 { cfg_select! { - false => 2, - true => 1 + true => 1, + false => 2 } } fn arm_rhs_expr_3() -> i32 { cfg_select! { - any(true) => 1, - any(false) => 2, - any(true) => { 42 } - any(true) => { 42 }, - any(false) => -1 as i32, - any(true) => 2 + 2, - any(false) => "", - any(true) => if true { 42 } else { 84 } - any(false) => if true { 42 } else { 84 }, - any(true) => return 42, - any(false) => loop {} - any(true) => (1, 2), - any(false) => (1, 2,), - any(true) => todo!(), - any(false) => println!("hello"), + true => 1, + false => 2, + true => { 42 } + false => -1 as i32, + true => 2 + 2, + false => "", + true => if true { 42 } else { 84 } + false => if true { 42 } else { 84 }, + true => return 42, + false => loop {} + true => (1, 2), + false => (1, 2,), + true => todo!(), + false => println!("hello"), } } fn expand_to_statements() -> i32 { cfg_select! { - false => { - let b = 2; - b + 1 - } true => { let a = 1; a + 1 } + false => { + let b = 2; + b + 1 + } } } type ExpandToType = cfg_select! { - unix => { u32 }, + unix => u32, _ => i32, }; @@ -78,7 +76,7 @@ fn expand_to_pattern(x: Option) -> bool { } cfg_select! { - false => { + true => { fn foo() {} } _ => { @@ -90,7 +88,7 @@ struct S; impl S { cfg_select! { - false => { + true => { fn foo() {} } _ => { @@ -101,7 +99,7 @@ impl S { trait T { cfg_select! { - false => { + true => { fn a(); } _ => { @@ -112,9 +110,9 @@ trait T { impl T for S { cfg_select! { - false => { + true => { fn a() {} - }, + } _ => { fn b() {} } @@ -123,7 +121,7 @@ impl T for S { extern "C" { cfg_select! { - false => { + true => { fn puts(s: *const i8) -> i32; } _ => { @@ -135,28 +133,7 @@ extern "C" { cfg_select! { _ => {} true => {} - //~^ WARN unreachable configuration predicate -} - -cfg_select! { - true => {} - _ => {} - //~^ WARN unreachable configuration predicate -} - -cfg_select! { - unix => {} - not(unix) => {}, - _ => {} - //~^ WARN unreachable configuration predicate -} - -cfg_select! { - test => {} - test => {} - //~^ WARN unreachable configuration predicate - _ => {} - //~^ WARN unreachable configuration predicate + //~^ WARN unreachable predicate } cfg_select! { diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr index 2da0c2169497..ffd8540425ab 100644 --- a/tests/ui/macros/cfg_select.stderr +++ b/tests/ui/macros/cfg_select.stderr @@ -1,5 +1,13 @@ +warning: unreachable predicate + --> $DIR/cfg_select.rs:135:5 + | +LL | _ => {} + | - always matches +LL | true => {} + | ^^^^ this predicate is never reached + error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:162:1 + --> $DIR/cfg_select.rs:139:1 | LL | / cfg_select! { LL | | @@ -8,95 +16,55 @@ LL | | } | |_^ error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:167:1 + --> $DIR/cfg_select.rs:144:1 | LL | cfg_select! {} | ^^^^^^^^^^^^^^ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `=>` - --> $DIR/cfg_select.rs:171:5 + --> $DIR/cfg_select.rs:148:5 | LL | => {} | ^^ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found expression - --> $DIR/cfg_select.rs:176:5 + --> $DIR/cfg_select.rs:153:5 | LL | () => {} | ^^ expressions are not allowed here error[E0539]: malformed `cfg_select` macro input - --> $DIR/cfg_select.rs:181:5 + --> $DIR/cfg_select.rs:158:5 | LL | "str" => {} | ^^^^^ expected a valid identifier here error[E0539]: malformed `cfg_select` macro input - --> $DIR/cfg_select.rs:186:5 + --> $DIR/cfg_select.rs:163:5 | LL | a::b => {} | ^^^^ expected a valid identifier here error[E0537]: invalid predicate `a` - --> $DIR/cfg_select.rs:191:5 + --> $DIR/cfg_select.rs:168:5 | LL | a() => {} | ^^^ error: expected one of `(`, `::`, `=>`, or `=`, found `+` - --> $DIR/cfg_select.rs:196:7 + --> $DIR/cfg_select.rs:173:7 | LL | a + 1 => {} | ^ expected one of `(`, `::`, `=>`, or `=` error: expected one of `(`, `::`, `=>`, or `=`, found `!` - --> $DIR/cfg_select.rs:202:8 + --> $DIR/cfg_select.rs:179:8 | LL | cfg!() => {} | ^ expected one of `(`, `::`, `=>`, or `=` -warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:137:5 - | -LL | _ => {} - | - always matches -LL | true => {} - | ^^^^ this configuration predicate is never reached - | -note: the lint level is defined here - --> $DIR/cfg_select.rs:3:9 - | -LL | #![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:143:5 - | -LL | true => {} - | ---- always matches -LL | _ => {} - | ^ this configuration predicate is never reached - -warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:150:5 - | -LL | _ => {} - | ^ this configuration predicate is never reached - -warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:156:5 - | -LL | test => {} - | ^^^^ this configuration predicate is never reached - -warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:158:5 - | -LL | _ => {} - | ^ this configuration predicate is never reached - warning: unexpected `cfg` condition name: `a` - --> $DIR/cfg_select.rs:196:5 + --> $DIR/cfg_select.rs:173:5 | LL | a + 1 => {} | ^ help: found config with similar value: `target_feature = "a"` @@ -107,7 +75,7 @@ LL | a + 1 => {} = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `cfg` - --> $DIR/cfg_select.rs:202:5 + --> $DIR/cfg_select.rs:179:5 | LL | cfg!() => {} | ^^^ @@ -115,7 +83,7 @@ LL | cfg!() => {} = help: to expect this configuration use `--check-cfg=cfg(cfg)` = note: see for more information about checking conditional configuration -error: aborting due to 9 previous errors; 7 warnings emitted +error: aborting due to 9 previous errors; 3 warnings emitted Some errors have detailed explanations: E0537, E0539. For more information about an error, try `rustc --explain E0537`. diff --git a/tests/ui/macros/compile_error_macro-suppress-errors.rs b/tests/ui/macros/compile_error_macro-suppress-errors.rs deleted file mode 100644 index e1c2248035e9..000000000000 --- a/tests/ui/macros/compile_error_macro-suppress-errors.rs +++ /dev/null @@ -1,40 +0,0 @@ -pub mod some_module { - compile_error!("Error in a module"); //~ ERROR: Error in a module - - fn abc() -> Hello { - let _: self::SomeType = self::Hello::new(); - let _: SomeType = Hello::new(); - } - - mod inner_module { - use super::Hello; - use crate::another_module::NotExist; //~ ERROR: unresolved import `crate::another_module::NotExist` - use crate::some_module::World; - struct Foo { - bar: crate::some_module::Xyz, - error: self::MissingType, //~ ERROR: cannot find type `MissingType` in module `self` - } - } -} - -pub mod another_module { - use crate::some_module::NotExist; - fn error_in_this_function() { - compile_error!("Error in a function"); //~ ERROR: Error in a function - } -} - -fn main() { - // these errors are suppressed because of the compile_error! macro - - let _ = some_module::some_function(); - let _: some_module::SomeType = some_module::Hello::new(); - - // these errors are not suppressed - - let _ = another_module::some_function(); - //~^ ERROR: cannot find function `some_function` in module `another_module` - let _: another_module::SomeType = another_module::Hello::new(); - //~^ ERROR: cannot find type `SomeType` in module `another_module` - //~| ERROR: cannot find `Hello` in `another_module` -} diff --git a/tests/ui/macros/compile_error_macro-suppress-errors.stderr b/tests/ui/macros/compile_error_macro-suppress-errors.stderr deleted file mode 100644 index bda1deb9c413..000000000000 --- a/tests/ui/macros/compile_error_macro-suppress-errors.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error: Error in a module - --> $DIR/compile_error_macro-suppress-errors.rs:2:5 - | -LL | compile_error!("Error in a module"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: Error in a function - --> $DIR/compile_error_macro-suppress-errors.rs:23:9 - | -LL | compile_error!("Error in a function"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0432]: unresolved import `crate::another_module::NotExist` - --> $DIR/compile_error_macro-suppress-errors.rs:11:13 - | -LL | use crate::another_module::NotExist; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `NotExist` in `another_module` - -error[E0433]: cannot find `Hello` in `another_module` - --> $DIR/compile_error_macro-suppress-errors.rs:37:55 - | -LL | let _: another_module::SomeType = another_module::Hello::new(); - | ^^^^^ could not find `Hello` in `another_module` - -error[E0425]: cannot find type `MissingType` in module `self` - --> $DIR/compile_error_macro-suppress-errors.rs:15:26 - | -LL | error: self::MissingType, - | ^^^^^^^^^^^ not found in `self` - -error[E0425]: cannot find function `some_function` in module `another_module` - --> $DIR/compile_error_macro-suppress-errors.rs:35:29 - | -LL | let _ = another_module::some_function(); - | ^^^^^^^^^^^^^ not found in `another_module` - -error[E0425]: cannot find type `SomeType` in module `another_module` - --> $DIR/compile_error_macro-suppress-errors.rs:37:28 - | -LL | let _: another_module::SomeType = another_module::Hello::new(); - | ^^^^^^^^ not found in `another_module` - -error: aborting due to 7 previous errors - -Some errors have detailed explanations: E0425, E0432, E0433. -For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/macros/failed-to-reparse-issue-139445.stderr b/tests/ui/macros/failed-to-reparse-issue-139445.stderr index fc3a2645e25e..6f7d88fb3446 100644 --- a/tests/ui/macros/failed-to-reparse-issue-139445.stderr +++ b/tests/ui/macros/failed-to-reparse-issue-139445.stderr @@ -9,12 +9,16 @@ error: expected `while`, `for`, `loop` or `{` after a label | LL | assert_eq!(3, 'a,) | ^^^^^^^^^^^^^^^^^^ expected `while`, `for`, `loop` or `{` after a label + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `` --> $DIR/failed-to-reparse-issue-139445.rs:2:5 | LL | assert_eq!(3, 'a,) | ^^^^^^^^^^^^^^^^^^ expected expression + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/macros/format-parse-errors.stderr b/tests/ui/macros/format-parse-errors.stderr index baa29170a7d4..f9ea4c63377b 100644 --- a/tests/ui/macros/format-parse-errors.stderr +++ b/tests/ui/macros/format-parse-errors.stderr @@ -3,6 +3,8 @@ error: requires at least a format string argument | LL | format!(); | ^^^^^^^^^ + | + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found keyword `struct` --> $DIR/format-parse-errors.rs:5:13 diff --git a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout index f01807ec0617..6e41432ad7df 100644 --- a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout +++ b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; //@ compile-flags: -Zunpretty=hir //@ edition: 2015 diff --git a/tests/ui/macros/issue-118786.fixed b/tests/ui/macros/issue-118786.fixed deleted file mode 100644 index 5d4006acd6c8..000000000000 --- a/tests/ui/macros/issue-118786.fixed +++ /dev/null @@ -1,20 +0,0 @@ -#![allow(unused_macros)] -//@ compile-flags: --crate-type lib -//@ dont-require-annotations: NOTE -//@ run-rustfix - -// Regression test for issue 118786 - -macro_rules! make_macro { - ($macro_name:tt) => { - macro_rules! $macro_name { - //~^ ERROR macro expansion ignores `{` and any tokens following - //~| ERROR cannot find macro `macro_rules` in this scope - //~| NOTE put a macro name here - () => {} - } - } -} - -make_macro!(meow); -//~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon diff --git a/tests/ui/macros/issue-118786.rs b/tests/ui/macros/issue-118786.rs index b79a2c7eedd7..78fd6ab6eddd 100644 --- a/tests/ui/macros/issue-118786.rs +++ b/tests/ui/macros/issue-118786.rs @@ -1,7 +1,5 @@ -#![allow(unused_macros)] -//@ compile-flags: --crate-type lib +//@ compile-flags: --crate-type lib -O -C debug-assertions=yes //@ dont-require-annotations: NOTE -//@ run-rustfix // Regression test for issue 118786 diff --git a/tests/ui/macros/issue-118786.stderr b/tests/ui/macros/issue-118786.stderr index 02b26e5a1f31..ddec281b8232 100644 --- a/tests/ui/macros/issue-118786.stderr +++ b/tests/ui/macros/issue-118786.stderr @@ -1,17 +1,21 @@ error: macros that expand to items must be delimited with braces or followed by a semicolon - --> $DIR/issue-118786.rs:19:13 + --> $DIR/issue-118786.rs:17:13 | LL | make_macro!((meow)); | ^^^^^^ | -help: to define a macro, remove the parentheses around the macro name +help: change the delimiters to curly braces | LL - make_macro!((meow)); -LL + make_macro!(meow); +LL + make_macro!({meow}); | +help: add a semicolon + | +LL | macro_rules! $macro_name; { + | + error: macro expansion ignores `{` and any tokens following - --> $DIR/issue-118786.rs:10:34 + --> $DIR/issue-118786.rs:8:34 | LL | macro_rules! $macro_name { | ^ @@ -22,7 +26,7 @@ LL | make_macro!((meow)); = note: the usage of `make_macro!` is likely invalid in item context error: cannot find macro `macro_rules` in this scope - --> $DIR/issue-118786.rs:10:9 + --> $DIR/issue-118786.rs:8:9 | LL | macro_rules! $macro_name { | ^^^^^^^^^^^ @@ -31,7 +35,7 @@ LL | make_macro!((meow)); | ------------------- in this macro invocation | note: maybe you have forgotten to define a name for this `macro_rules!` - --> $DIR/issue-118786.rs:10:20 + --> $DIR/issue-118786.rs:8:20 | LL | macro_rules! $macro_name { | ^ put a macro name here diff --git a/tests/ui/macros/macro-expansion-empty-span-147255.stderr b/tests/ui/macros/macro-expansion-empty-span-147255.stderr index cea691679988..99396622b34e 100644 --- a/tests/ui/macros/macro-expansion-empty-span-147255.stderr +++ b/tests/ui/macros/macro-expansion-empty-span-147255.stderr @@ -8,6 +8,7 @@ LL | println!("{}", x_str); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/macros/macro-inner-attributes.rs b/tests/ui/macros/macro-inner-attributes.rs index fc69f2e4cebe..1a832ca9b0c4 100644 --- a/tests/ui/macros/macro-inner-attributes.rs +++ b/tests/ui/macros/macro-inner-attributes.rs @@ -4,8 +4,8 @@ macro_rules! test { ($nm:ident, #[$a:meta], $i:item) => (mod $nm { #![$a] $i }); } -test!(a, //~ NOTE: found an item that was configured out - #[cfg(false)], //~ NOTE: the item is gated here +test!(a, + #[cfg(false)], pub fn bar() { }); test!(b, @@ -14,7 +14,7 @@ test!(b, #[rustc_dummy] fn main() { - a::bar(); //~ ERROR: cannot find module or crate `a` - //~^ NOTE: use of unresolved module or unlinked crate `a` + a::bar(); + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `a` b::bar(); } diff --git a/tests/ui/macros/macro-inner-attributes.stderr b/tests/ui/macros/macro-inner-attributes.stderr index 5523dda33c32..3c043c38abb5 100644 --- a/tests/ui/macros/macro-inner-attributes.stderr +++ b/tests/ui/macros/macro-inner-attributes.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `a` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a` --> $DIR/macro-inner-attributes.rs:17:5 | LL | a::bar(); diff --git a/tests/ui/macros/macro-lifetime-used-with-labels.rs b/tests/ui/macros/macro-lifetime-used-with-labels.rs index 4489ca6b681b..3b51b8050b34 100644 --- a/tests/ui/macros/macro-lifetime-used-with-labels.rs +++ b/tests/ui/macros/macro-lifetime-used-with-labels.rs @@ -1,4 +1,5 @@ //@ run-pass +#![allow(stable_features)] #![allow(unused_labels)] #![allow(unreachable_code)] diff --git a/tests/ui/macros/macro-local-data-key-priv.stderr b/tests/ui/macros/macro-local-data-key-priv.stderr index 2aced92c4152..8df1aec140d0 100644 --- a/tests/ui/macros/macro-local-data-key-priv.stderr +++ b/tests/ui/macros/macro-local-data-key-priv.stderr @@ -9,6 +9,7 @@ note: the constant `baz` is defined here | LL | thread_local!(static baz: f64 = 0.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/macros/macro-path-prelude-fail-1.rs b/tests/ui/macros/macro-path-prelude-fail-1.rs index a077ef0c6632..d93792bdfe38 100644 --- a/tests/ui/macros/macro-path-prelude-fail-1.rs +++ b/tests/ui/macros/macro-path-prelude-fail-1.rs @@ -1,9 +1,7 @@ mod m { fn check() { - Vec::clone!(); //~ ERROR cannot find - //~^ NOTE `Vec` is a struct, not a module - u8::clone!(); //~ ERROR cannot find - //~^ NOTE `u8` is a builtin type, not a module + Vec::clone!(); //~ ERROR failed to resolve: `Vec` is a struct, not a module + u8::clone!(); //~ ERROR failed to resolve: `u8` is a builtin type, not a module } } diff --git a/tests/ui/macros/macro-path-prelude-fail-1.stderr b/tests/ui/macros/macro-path-prelude-fail-1.stderr index 0332b18992eb..f8377ffb3555 100644 --- a/tests/ui/macros/macro-path-prelude-fail-1.stderr +++ b/tests/ui/macros/macro-path-prelude-fail-1.stderr @@ -1,11 +1,11 @@ -error[E0433]: cannot find module `Vec` in this scope +error[E0433]: failed to resolve: `Vec` is a struct, not a module --> $DIR/macro-path-prelude-fail-1.rs:3:9 | LL | Vec::clone!(); | ^^^ `Vec` is a struct, not a module -error[E0433]: cannot find module `u8` in this scope - --> $DIR/macro-path-prelude-fail-1.rs:5:9 +error[E0433]: failed to resolve: `u8` is a builtin type, not a module + --> $DIR/macro-path-prelude-fail-1.rs:4:9 | LL | u8::clone!(); | ^^ `u8` is a builtin type, not a module diff --git a/tests/ui/macros/macro-path-prelude-fail-2.rs b/tests/ui/macros/macro-path-prelude-fail-2.rs index f359f34e4fd1..816a3c4ccc00 100644 --- a/tests/ui/macros/macro-path-prelude-fail-2.rs +++ b/tests/ui/macros/macro-path-prelude-fail-2.rs @@ -1,6 +1,6 @@ mod m { fn check() { - Result::Ok!(); //~ ERROR cannot find + Result::Ok!(); //~ ERROR failed to resolve: partially resolved path in a macro } } diff --git a/tests/ui/macros/macro-path-prelude-fail-2.stderr b/tests/ui/macros/macro-path-prelude-fail-2.stderr index e1ea8cbc60ec..87646031cdb8 100644 --- a/tests/ui/macros/macro-path-prelude-fail-2.stderr +++ b/tests/ui/macros/macro-path-prelude-fail-2.stderr @@ -1,8 +1,8 @@ -error[E0433]: cannot find macro `Ok` in enum `Result` +error[E0433]: failed to resolve: partially resolved path in a macro --> $DIR/macro-path-prelude-fail-2.rs:3:9 | LL | Result::Ok!(); - | ^^^^^^^^^^ a macro can't exist within an enum + | ^^^^^^^^^^ partially resolved path in a macro error: aborting due to 1 previous error diff --git a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs index a556983e204d..a2e1398c61e6 100644 --- a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs +++ b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs @@ -5,4 +5,5 @@ macro_rules! sample { () => {} } #[sample] //~ ERROR cannot find attribute `sample` in this scope #[derive(sample)] //~ ERROR cannot find derive macro `sample` in this scope //~| ERROR cannot find derive macro `sample` in this scope + //~| ERROR cannot find derive macro `sample` in this scope pub struct S {} diff --git a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr index a3c21df43e75..aad4a844ec17 100644 --- a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr +++ b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr @@ -1,3 +1,12 @@ +error: cannot find derive macro `sample` in this scope + --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:6:10 + | +LL | macro_rules! sample { () => {} } + | ------ `sample` exists, but has no `derive` rules +... +LL | #[derive(sample)] + | ^^^^^^ + error: cannot find attribute `sample` in this scope --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:5:3 | @@ -15,6 +24,8 @@ LL | macro_rules! sample { () => {} } ... LL | #[derive(sample)] | ^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: cannot find derive macro `sample` in this scope --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:6:10 @@ -27,5 +38,5 @@ LL | #[derive(sample)] | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/macros/macro_path_as_generic_bound.rs b/tests/ui/macros/macro_path_as_generic_bound.rs index d720752f4ca5..663f85688ec9 100644 --- a/tests/ui/macros/macro_path_as_generic_bound.rs +++ b/tests/ui/macros/macro_path_as_generic_bound.rs @@ -4,6 +4,6 @@ macro_rules! foo(($t:path) => { impl Foo for T {} }); -foo!(m::m2::A); //~ ERROR cannot find +foo!(m::m2::A); //~ ERROR failed to resolve fn main() {} diff --git a/tests/ui/macros/macro_path_as_generic_bound.stderr b/tests/ui/macros/macro_path_as_generic_bound.stderr index c4454ff23e6a..9fe4ad27aa05 100644 --- a/tests/ui/macros/macro_path_as_generic_bound.stderr +++ b/tests/ui/macros/macro_path_as_generic_bound.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `m` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `m` --> $DIR/macro_path_as_generic_bound.rs:7:6 | LL | foo!(m::m2::A); diff --git a/tests/ui/macros/meta-item-absolute-path.rs b/tests/ui/macros/meta-item-absolute-path.rs index 429d259ae2c4..e677016cff82 100644 --- a/tests/ui/macros/meta-item-absolute-path.rs +++ b/tests/ui/macros/meta-item-absolute-path.rs @@ -1,6 +1,6 @@ //@ edition:2015 -#[derive(::Absolute)] //~ ERROR cannot find - //~| ERROR cannot find +#[derive(::Absolute)] //~ ERROR failed to resolve + //~| ERROR failed to resolve struct S; fn main() {} diff --git a/tests/ui/macros/meta-item-absolute-path.stderr b/tests/ui/macros/meta-item-absolute-path.stderr index 9a9d90ca3f44..93c442036ce2 100644 --- a/tests/ui/macros/meta-item-absolute-path.stderr +++ b/tests/ui/macros/meta-item-absolute-path.stderr @@ -1,10 +1,10 @@ -error[E0433]: cannot find module or crate `Absolute` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `Absolute` --> $DIR/meta-item-absolute-path.rs:2:12 | LL | #[derive(::Absolute)] | ^^^^^^^^ use of unresolved module or unlinked crate `Absolute` -error[E0433]: cannot find module or crate `Absolute` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `Absolute` --> $DIR/meta-item-absolute-path.rs:2:12 | LL | #[derive(::Absolute)] diff --git a/tests/ui/macros/metavar-expressions/usage-errors.rs b/tests/ui/macros/metavar-expressions/usage-errors.rs index 966ffadb32af..feff02e2ce47 100644 --- a/tests/ui/macros/metavar-expressions/usage-errors.rs +++ b/tests/ui/macros/metavar-expressions/usage-errors.rs @@ -27,7 +27,6 @@ curly__rhs_dollar__no_round !(a); macro_rules! no_curly__no_rhs_dollar__round { ( $( $i:ident ),* ) => { count(i) }; //~^ ERROR missing `fn` or `struct` for function or struct definition - //~| HELP if you meant to call a macro, try } no_curly__no_rhs_dollar__round !(a, b, c); @@ -35,7 +34,6 @@ no_curly__no_rhs_dollar__round !(a, b, c); macro_rules! no_curly__no_rhs_dollar__no_round { ( $i:ident ) => { count(i) }; //~^ ERROR missing `fn` or `struct` for function or struct definition - //~| HELP if you meant to call a macro, try } no_curly__no_rhs_dollar__no_round !(a); diff --git a/tests/ui/macros/metavar-expressions/usage-errors.stderr b/tests/ui/macros/metavar-expressions/usage-errors.stderr index 3d22e3ac4b30..f66f522e23b9 100644 --- a/tests/ui/macros/metavar-expressions/usage-errors.stderr +++ b/tests/ui/macros/metavar-expressions/usage-errors.stderr @@ -26,7 +26,7 @@ LL | ( $( $i:ident ),* ) => { count!(i) }; | + error: missing `fn` or `struct` for function or struct definition - --> $DIR/usage-errors.rs:36:23 + --> $DIR/usage-errors.rs:35:23 | LL | ( $i:ident ) => { count(i) }; | ^^^^^ @@ -41,13 +41,13 @@ LL | ( $i:ident ) => { count!(i) }; | + error: variable `i` is still repeating at this depth - --> $DIR/usage-errors.rs:44:36 + --> $DIR/usage-errors.rs:42:36 | LL | ( $( $i:ident ),* ) => { count($i) }; | ^^ error[E0425]: cannot find value `a` in this scope - --> $DIR/usage-errors.rs:54:49 + --> $DIR/usage-errors.rs:52:49 | LL | ( $i:ident ) => { count($i) }; | -- due to this macro variable @@ -56,7 +56,7 @@ LL | const _: u32 = no_curly__rhs_dollar__no_round! (a); | ^ not found in this scope error[E0425]: cannot find function `count` in this scope - --> $DIR/usage-errors.rs:51:23 + --> $DIR/usage-errors.rs:49:23 | LL | ( $i:ident ) => { count($i) }; | ^^^^^ not found in this scope diff --git a/tests/ui/macros/parse-complex-macro-invoc-op.rs b/tests/ui/macros/parse-complex-macro-invoc-op.rs index 2c384bdb42ef..27ead36f69d8 100644 --- a/tests/ui/macros/parse-complex-macro-invoc-op.rs +++ b/tests/ui/macros/parse-complex-macro-invoc-op.rs @@ -3,10 +3,14 @@ #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unused_variables)] +#![allow(stable_features)] #![allow(dropping_copy_types)] // Test parsing binary operators after macro invocations. + +#![feature(macro_rules)] + macro_rules! id { ($e: expr) => { $e } } diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 0367b8c2d023..fa06da5cbfbc 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -5,7 +5,6 @@ #![allow(incomplete_features)] #![feature(auto_traits)] #![feature(box_patterns)] -#![feature(const_block_items)] #![feature(const_trait_impl)] #![feature(coroutines)] #![feature(decl_macro)] @@ -370,9 +369,6 @@ fn test_item() { c1!(item, [ pub const S: () = {}; ], "pub const S: () = {};"); c1!(item, [ const S: (); ], "const S: ();"); - // ItemKind::ConstBlock - c1!(item, [ const {} ], "const {}"); - // ItemKind::Fn c1!(item, [ pub default const async unsafe extern "C" fn f() {} ], diff --git a/tests/ui/macros/tokenstream-ice-issue-149954.rs b/tests/ui/macros/tokenstream-ice-issue-149954.rs deleted file mode 100644 index 958a86cbde8b..000000000000 --- a/tests/ui/macros/tokenstream-ice-issue-149954.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Regression test for ICE https://github.com/rust-lang/rust/issues/149954 -//@ edition: 2024 - -enum A { - A - const A: A = { //~ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found keyword `const` - #[derive(Debug)] - struct A - where - A: A<{ struct A> ; enum A } - //~^ ERROR malformed `cfg` attribute input - //~| ERROR malformed `cfg` attribute input - //~| ERROR expected trait, found struct `A` - //~| ERROR expected trait, found type parameter `A` - //~| ERROR expected trait, found struct `A` - //~| ERROR expected trait, found type parameter `A` - //~| ERROR expected one of `<`, `where`, or `{`, found `}` - //~| ERROR expected one of `<`, `where`, or `{`, found `}` - //~| ERROR expected one of `,`, `>`, or `}`, found `` - } - >; -}; //~ ERROR `main` function not found in crate diff --git a/tests/ui/macros/tokenstream-ice-issue-149954.stderr b/tests/ui/macros/tokenstream-ice-issue-149954.stderr deleted file mode 100644 index 750f3efcc612..000000000000 --- a/tests/ui/macros/tokenstream-ice-issue-149954.stderr +++ /dev/null @@ -1,110 +0,0 @@ -error: expected one of `(`, `,`, `=`, `{`, or `}`, found keyword `const` - --> $DIR/tokenstream-ice-issue-149954.rs:6:5 - | -LL | A - | - expected one of `(`, `,`, `=`, `{`, or `}` -LL | const A: A = { - | ^^^^^ unexpected token - | - = help: enum variants can be `Variant`, `Variant = `, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` - -error: expected one of `<`, `where`, or `{`, found `}` - --> $DIR/tokenstream-ice-issue-149954.rs:10:60 - | -LL | A: A<{ struct A> ; enum A } - | - ^ expected one of `<`, `where`, or `{` - | | - | while parsing this enum - -error: expected one of `<`, `where`, or `{`, found `}` - --> $DIR/tokenstream-ice-issue-149954.rs:10:60 - | -LL | A: A<{ struct A> ; enum A } - | - ^ expected one of `<`, `where`, or `{` - | | - | while parsing this enum - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: expected one of `,`, `>`, or `}`, found `` - --> $DIR/tokenstream-ice-issue-149954.rs:10:60 - | -LL | A: A<{ struct A> ; enum A } - | ^ expected one of `,`, `>`, or `}` - | -help: you might have meant to end the type parameters here - | -LL | A: A<{ struct A> ; enum A }> - | + - -error[E0539]: malformed `cfg` attribute input - --> $DIR/tokenstream-ice-issue-149954.rs:10:36 - | -LL | A: A<{ struct A> ; enum A } - | ^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[cfg(predicate)]` - | - = note: for more information, visit - -error[E0539]: malformed `cfg` attribute input - --> $DIR/tokenstream-ice-issue-149954.rs:10:36 - | -LL | A: A<{ struct A> ; enum A } - | ^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[cfg(predicate)]` - | - = note: for more information, visit - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0404]: expected trait, found struct `A` - --> $DIR/tokenstream-ice-issue-149954.rs:10:16 - | -LL | A: A<{ struct A> ; enum A } - | ________________^ -... | -LL | | >; - | |_________^ not a trait - -error[E0404]: expected trait, found type parameter `A` - --> $DIR/tokenstream-ice-issue-149954.rs:10:32 - | -LL | A: A<{ struct A> ; enum A } - | - ^^^^^^^^^^^^^^^^ not a trait - | | - | found this type parameter - -error[E0404]: expected trait, found struct `A` - --> $DIR/tokenstream-ice-issue-149954.rs:10:16 - | -LL | A: A<{ struct A> ; enum A } - | ________________^ -... | -LL | | >; - | |_________^ not a trait - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0404]: expected trait, found type parameter `A` - --> $DIR/tokenstream-ice-issue-149954.rs:10:32 - | -LL | A: A<{ struct A> ; enum A } - | - ^^^^^^^^^^^^^^^^ not a trait - | | - | found this type parameter - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0601]: `main` function not found in crate `tokenstream_ice_issue_149954` - --> $DIR/tokenstream-ice-issue-149954.rs:22:3 - | -LL | }; - | ^ consider adding a `main` function to `$DIR/tokenstream-ice-issue-149954.rs` - -error: aborting due to 11 previous errors - -Some errors have detailed explanations: E0404, E0539, E0601. -For more information about an error, try `rustc --explain E0404`. diff --git a/tests/ui/macros/vec-macro-in-pattern.rs b/tests/ui/macros/vec-macro-in-pattern.rs index 0e9cb087f66a..9b9a1edf54c9 100644 --- a/tests/ui/macros/vec-macro-in-pattern.rs +++ b/tests/ui/macros/vec-macro-in-pattern.rs @@ -6,7 +6,7 @@ fn main() { match Some(vec![42]) { Some(vec![43]) => {} //~ ERROR expected a pattern, found a function call //~| ERROR found associated function - //~| ERROR expected a pattern, found a function call + //~| ERROR usage of qualified paths in this context is experimental _ => {} } } diff --git a/tests/ui/macros/vec-macro-in-pattern.stderr b/tests/ui/macros/vec-macro-in-pattern.stderr index 38e4aebb8f48..71ba0ea5ad4f 100644 --- a/tests/ui/macros/vec-macro-in-pattern.stderr +++ b/tests/ui/macros/vec-macro-in-pattern.stderr @@ -5,24 +5,29 @@ LL | Some(vec![43]) => {} | ^^^^^^^^ not a tuple struct or tuple variant | = note: function calls are not allowed in patterns: + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0532]: expected a pattern, found a function call +error[E0658]: usage of qualified paths in this context is experimental --> $DIR/vec-macro-in-pattern.rs:7:14 | LL | Some(vec![43]) => {} - | ^^^^^^^^ not a tuple struct or tuple variant + | ^^^^^^^^ | - = note: function calls are not allowed in patterns: + = note: see issue #86935 for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0164]: expected tuple struct or tuple variant, found associated function `::alloc::boxed::Box::new_uninit` +error[E0164]: expected tuple struct or tuple variant, found associated function `<[_]>::into_vec` --> $DIR/vec-macro-in-pattern.rs:7:14 | LL | Some(vec![43]) => {} | ^^^^^^^^ `fn` calls are not allowed in patterns | = help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors -Some errors have detailed explanations: E0164, E0532. +Some errors have detailed explanations: E0164, E0532, E0658. For more information about an error, try `rustc --explain E0164`. diff --git a/tests/ui/macros/write-missing-destination.rs b/tests/ui/macros/write-missing-destination.rs deleted file mode 100644 index 02e0e096a907..000000000000 --- a/tests/ui/macros/write-missing-destination.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Check that `write!` without a destination gives a helpful error message. -// See https://github.com/rust-lang/rust/issues/152493 - -fn main() { - write!("S"); - //~^ ERROR requires a destination and format arguments -} diff --git a/tests/ui/macros/write-missing-destination.stderr b/tests/ui/macros/write-missing-destination.stderr deleted file mode 100644 index 3136191ca17a..000000000000 --- a/tests/ui/macros/write-missing-destination.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: requires a destination and format arguments, like `write!(dest, "format string", args...)` - --> $DIR/write-missing-destination.rs:5:5 - | -LL | write!("S"); - | ^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/malformed/malformed-derive-entry.rs b/tests/ui/malformed/malformed-derive-entry.rs index f9dc98d9d270..77fa2f566a8f 100644 --- a/tests/ui/malformed/malformed-derive-entry.rs +++ b/tests/ui/malformed/malformed-derive-entry.rs @@ -1,14 +1,14 @@ #[derive(Copy(Bad))] -//~^ ERROR: traits in `#[derive(...)]` don't accept arguments +//~^ ERROR traits in `#[derive(...)]` don't accept arguments +//~| ERROR the trait bound struct Test1; -//~^ ERROR: the trait bound #[derive(Copy="bad")] -//~^ ERROR: traits in `#[derive(...)]` don't accept values +//~^ ERROR traits in `#[derive(...)]` don't accept values +//~| ERROR the trait bound struct Test2; -//~^ ERROR: the trait bound -#[derive] //~ ERROR: malformed `derive` attribute input +#[derive] //~ ERROR malformed `derive` attribute input struct Test4; fn main() {} diff --git a/tests/ui/malformed/malformed-derive-entry.stderr b/tests/ui/malformed/malformed-derive-entry.stderr index a5d7c3a4f8aa..02036e8d4c90 100644 --- a/tests/ui/malformed/malformed-derive-entry.stderr +++ b/tests/ui/malformed/malformed-derive-entry.stderr @@ -17,13 +17,10 @@ LL | #[derive] | ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]` error[E0277]: the trait bound `Test1: Clone` is not satisfied - --> $DIR/malformed-derive-entry.rs:3:8 + --> $DIR/malformed-derive-entry.rs:1:10 | LL | #[derive(Copy(Bad))] - | ---- in this derive macro expansion -LL | -LL | struct Test1; - | ^^^^^ the trait `Clone` is not implemented for `Test1` + | ^^^^ the trait `Clone` is not implemented for `Test1` | note: required by a bound in `Copy` --> $SRC_DIR/core/src/marker.rs:LL:COL @@ -34,13 +31,10 @@ LL | struct Test1; | error[E0277]: the trait bound `Test2: Clone` is not satisfied - --> $DIR/malformed-derive-entry.rs:8:8 + --> $DIR/malformed-derive-entry.rs:6:10 | LL | #[derive(Copy="bad")] - | ---- in this derive macro expansion -LL | -LL | struct Test2; - | ^^^^^ the trait `Clone` is not implemented for `Test2` + | ^^^^ the trait `Clone` is not implemented for `Test2` | note: required by a bound in `Copy` --> $SRC_DIR/core/src/marker.rs:LL:COL diff --git a/tests/ui/match/borrowck-uninhabited.rs b/tests/ui/match/borrowck-uninhabited.rs deleted file mode 100644 index 34f5e323a91e..000000000000 --- a/tests/ui/match/borrowck-uninhabited.rs +++ /dev/null @@ -1,55 +0,0 @@ -// See: rust-lang/rust#146590 - -enum Never {} - -// baseline -fn both_inhabited(x: &mut Result) { - match x { - &mut Ok(ref mut y) => match x { - //~^ ERROR: cannot use `*x` because it was mutably borrowed - &mut Err(ref mut z) => { - let _y = y; - let _z = z; - } - _ => {} - }, - _ => {} - }; -} - -// this used to be accepted, even though it shouldn't -fn ref_uninhabited(x: &mut Result) { - match x { - &mut Ok(ref mut y) => match x { - //~^ ERROR: cannot use `*x` because it was mutably borrowed - &mut Err(ref mut z) => { - let _y = y; - let _z = z; - } - _ => {} - }, - _ => {} - }; -} - -enum Single { - V(String, String), -} - -// arguably this should be rejected as well, but currently it is still accepted -fn single_variant(x: &mut Single) { - match x { - &mut Single::V(ref mut y, _) => { - match x { - &mut Single::V(_, ref mut z) => { - let _y = y; - let _z = z; - } - _ => {} - } - }, - _ => {} - }; -} - -fn main() {} diff --git a/tests/ui/match/borrowck-uninhabited.stderr b/tests/ui/match/borrowck-uninhabited.stderr deleted file mode 100644 index 4bbe6ecea16b..000000000000 --- a/tests/ui/match/borrowck-uninhabited.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0503]: cannot use `*x` because it was mutably borrowed - --> $DIR/borrowck-uninhabited.rs:8:37 - | -LL | &mut Ok(ref mut y) => match x { - | --------- ^ use of borrowed `x.0` - | | - | `x.0` is borrowed here -... -LL | let _y = y; - | - borrow later used here - -error[E0503]: cannot use `*x` because it was mutably borrowed - --> $DIR/borrowck-uninhabited.rs:23:37 - | -LL | &mut Ok(ref mut y) => match x { - | --------- ^ use of borrowed `x.0` - | | - | `x.0` is borrowed here -... -LL | let _y = y; - | - borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/tests/ui/match/issue-82392.stdout b/tests/ui/match/issue-82392.stdout index 297a6f482790..d44ffbe21671 100644 --- a/tests/ui/match/issue-82392.stdout +++ b/tests/ui/match/issue-82392.stdout @@ -1,5 +1,5 @@ extern crate std; -#[attr = PreludeImport] +#[prelude_import] use ::std::prelude::rust_2015::*; // https://github.com/rust-lang/rust/issues/82329 //@ compile-flags: -Zunpretty=hir,typed diff --git a/tests/ui/match/match-float.rs b/tests/ui/match/match-float.rs index 279bb5927ac4..70283eaeec52 100644 --- a/tests/ui/match/match-float.rs +++ b/tests/ui/match/match-float.rs @@ -1,12 +1,12 @@ //@ run-pass -//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f128) // Makes sure we use `==` (not bitwise) semantics for float comparison. -#![feature(cfg_target_has_reliable_f16_f128)] #![feature(f128)] #![feature(f16)] -#[cfg(target_has_reliable_f16)] +// FIXME(f16_f128): remove gates when ABI issues are resolved + +#[cfg(all(target_arch = "aarch64", target_os = "linux"))] fn check_f16() { const F1: f16 = 0.0; const F2: f16 = -0.0; @@ -34,7 +34,7 @@ fn check_f64() { assert!(matches!(F2, F1)); } -#[cfg(target_has_reliable_f128)] +#[cfg(all(target_arch = "aarch64", target_os = "linux"))] fn check_f128() { const F1: f128 = 0.0; const F2: f128 = -0.0; @@ -45,10 +45,10 @@ fn check_f128() { } fn main() { - #[cfg(target_has_reliable_f16)] + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] check_f16(); check_f32(); check_f64(); - #[cfg(target_has_reliable_f128)] + #[cfg(all(target_arch = "aarch64", target_os = "linux"))] check_f128(); } diff --git a/tests/ui/match/match-nested-enum-box-3121.rs b/tests/ui/match/match-nested-enum-box-3121.rs deleted file mode 100644 index f2ab4bf08075..000000000000 --- a/tests/ui/match/match-nested-enum-box-3121.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/3121 - -//@ run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -#[derive(Copy, Clone)] -enum side { - mayo, - catsup, - vinegar, -} -#[derive(Copy, Clone)] -enum order { - hamburger, - fries(side), - shake, -} -#[derive(Copy, Clone)] -enum meal { - to_go(order), - for_here(order), -} - -fn foo(m: Box, cond: bool) { - match *m { - meal::to_go(_) => {} - meal::for_here(_) if cond => {} - meal::for_here(order::hamburger) => {} - meal::for_here(order::fries(_s)) => {} - meal::for_here(order::shake) => {} - } -} - -pub fn main() { - foo(Box::new(meal::for_here(order::hamburger)), true) -} diff --git a/tests/ui/match/uninhabited-granular-moves.rs b/tests/ui/match/uninhabited-granular-moves.rs deleted file mode 100644 index f836aedbebc7..000000000000 --- a/tests/ui/match/uninhabited-granular-moves.rs +++ /dev/null @@ -1,46 +0,0 @@ -// See rust-lang/rust#146590, as well as Zulip discussion: -// -// https://rust-lang.zulipchat.com/#narrow/channel/513289-t-patterns/topic/Question.20about.20patterns.20and.20moves/with/558638455 -// -// Whether pattern matching performs a discriminant read shouldn't depend on whether -// you explicitly write down an uninhabited branch, or leave it implicit. - -enum Emp { } - -enum Foo { - Bar(A), - Qux(Emp), -} - -fn test1(thefoo: Foo<(Box, Box)>) { - match thefoo { - Foo::Bar((a, _)) => { } - } - - match thefoo { //~ ERROR: use of partially moved value: `thefoo` - Foo::Bar((_, a)) => { } - } -} - -fn test2(thefoo: Foo<(Box, Box)>) { - match thefoo { - Foo::Bar((a, _)) => { } - Foo::Qux(_) => { } - } - match thefoo { //~ ERROR: use of partially moved value: `thefoo` - Foo::Bar((_, a)) => { } - Foo::Qux(_) => { } - } -} - -fn test3(thefoo: Foo<(Box, Box)>) { - match thefoo { - Foo::Bar((a, _)) => { } - Foo::Qux(_) => { } - } - match thefoo { //~ ERROR: use of partially moved value: `thefoo` - Foo::Bar((_, a)) => { } - } -} - -fn main() {} diff --git a/tests/ui/match/uninhabited-granular-moves.stderr b/tests/ui/match/uninhabited-granular-moves.stderr deleted file mode 100644 index e3a66db526d4..000000000000 --- a/tests/ui/match/uninhabited-granular-moves.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0382]: use of partially moved value: `thefoo` - --> $DIR/uninhabited-granular-moves.rs:20:11 - | -LL | Foo::Bar((a, _)) => { } - | - value partially moved here -... -LL | match thefoo { - | ^^^^^^ value used here after partial move - | - = note: partial move occurs because value has type `Box`, which does not implement the `Copy` trait -help: borrow this binding in the pattern to avoid moving the value - | -LL | Foo::Bar((ref a, _)) => { } - | +++ - -error[E0382]: use of partially moved value: `thefoo` - --> $DIR/uninhabited-granular-moves.rs:30:11 - | -LL | Foo::Bar((a, _)) => { } - | - value partially moved here -... -LL | match thefoo { - | ^^^^^^ value used here after partial move - | - = note: partial move occurs because value has type `Box`, which does not implement the `Copy` trait -help: borrow this binding in the pattern to avoid moving the value - | -LL | Foo::Bar((ref a, _)) => { } - | +++ - -error[E0382]: use of partially moved value: `thefoo` - --> $DIR/uninhabited-granular-moves.rs:41:11 - | -LL | Foo::Bar((a, _)) => { } - | - value partially moved here -... -LL | match thefoo { - | ^^^^^^ value used here after partial move - | - = note: partial move occurs because value has type `Box`, which does not implement the `Copy` trait -help: borrow this binding in the pattern to avoid moving the value - | -LL | Foo::Bar((ref a, _)) => { } - | +++ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/compiletest-self-test/auxiliary/env.rs b/tests/ui/meta/auxiliary/env.rs similarity index 100% rename from tests/ui/compiletest-self-test/auxiliary/env.rs rename to tests/ui/meta/auxiliary/env.rs diff --git a/tests/ui/compiletest-self-test/dir.with.dots/test.rs b/tests/ui/meta/dir.with.dots/test.rs similarity index 100% rename from tests/ui/compiletest-self-test/dir.with.dots/test.rs rename to tests/ui/meta/dir.with.dots/test.rs diff --git a/tests/ui/compiletest-self-test/expected-error-correct-rev.a.stderr b/tests/ui/meta/expected-error-correct-rev.a.stderr similarity index 100% rename from tests/ui/compiletest-self-test/expected-error-correct-rev.a.stderr rename to tests/ui/meta/expected-error-correct-rev.a.stderr diff --git a/tests/ui/compiletest-self-test/expected-error-correct-rev.rs b/tests/ui/meta/expected-error-correct-rev.rs similarity index 100% rename from tests/ui/compiletest-self-test/expected-error-correct-rev.rs rename to tests/ui/meta/expected-error-correct-rev.rs diff --git a/tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.a.stderr b/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr similarity index 100% rename from tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.a.stderr rename to tests/ui/meta/meta-expected-error-wrong-rev.a.stderr diff --git a/tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.rs b/tests/ui/meta/meta-expected-error-wrong-rev.rs similarity index 100% rename from tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.rs rename to tests/ui/meta/meta-expected-error-wrong-rev.rs diff --git a/tests/ui/bootstrap/no_std-extern-libc.rs b/tests/ui/meta/no_std-extern-libc.rs similarity index 100% rename from tests/ui/bootstrap/no_std-extern-libc.rs rename to tests/ui/meta/no_std-extern-libc.rs diff --git a/tests/ui/compiletest-self-test/revision-bad.rs b/tests/ui/meta/revision-bad.rs similarity index 100% rename from tests/ui/compiletest-self-test/revision-bad.rs rename to tests/ui/meta/revision-bad.rs diff --git a/tests/ui/compiletest-self-test/revision-ok.rs b/tests/ui/meta/revision-ok.rs similarity index 100% rename from tests/ui/compiletest-self-test/revision-ok.rs rename to tests/ui/meta/revision-ok.rs diff --git a/tests/ui/compiletest-self-test/rustc-env.rs b/tests/ui/meta/rustc-env.rs similarity index 100% rename from tests/ui/compiletest-self-test/rustc-env.rs rename to tests/ui/meta/rustc-env.rs diff --git a/tests/ui/methods/call_method_unknown_pointee.rs b/tests/ui/methods/call_method_unknown_pointee.rs index 8927576239a8..a144e855ae3c 100644 --- a/tests/ui/methods/call_method_unknown_pointee.rs +++ b/tests/ui/methods/call_method_unknown_pointee.rs @@ -3,39 +3,26 @@ // tests that the pointee type of a raw pointer must be known to call methods on it // see also: `tests/ui/editions/edition-raw-pointer-method-2018.rs` -fn a() { - let ptr = &1u32 as *const u32; +fn main() { + let val = 1_u32; + let ptr = &val as *const u32; unsafe { let _a: i32 = (ptr as *const _).read(); //~^ ERROR type annotations needed - } -} - -fn b() { - let ptr = &1u32 as *const u32; - unsafe { let b = ptr as *const _; //~^ ERROR type annotations needed let _b: u8 = b.read(); + let _c = (ptr as *const u8).read(); // we know the type here } -} - -fn c() { - let ptr = &mut 2u32 as *mut u32; + let mut val = 2_u32; + let ptr = &mut val as *mut u32; unsafe { - let _c: i32 = (ptr as *mut _).read(); + let _a: i32 = (ptr as *mut _).read(); //~^ ERROR type annotations needed + let b = ptr as *mut _; + //~^ ERROR type annotations needed + b.write(10); + (ptr as *mut i32).write(1000); // we know the type here } } - -fn d() { - let ptr = &mut 2u32 as *mut u32; - unsafe { - let d = ptr as *mut _; - //~^ ERROR type annotations needed - let _d: u8 = d.read(); - } -} - -fn main() {} diff --git a/tests/ui/methods/call_method_unknown_pointee.stderr b/tests/ui/methods/call_method_unknown_pointee.stderr index c123533b51bc..e20c6f8e8a17 100644 --- a/tests/ui/methods/call_method_unknown_pointee.stderr +++ b/tests/ui/methods/call_method_unknown_pointee.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/call_method_unknown_pointee.rs:9:23 + --> $DIR/call_method_unknown_pointee.rs:10:23 | LL | let _a: i32 = (ptr as *const _).read(); | ^^^^^^^^^^^^^^^^^ ---- cannot call a method on a raw pointer with an unknown pointee type @@ -7,7 +7,7 @@ LL | let _a: i32 = (ptr as *const _).read(); | cannot infer type error[E0282]: type annotations needed for `*const _` - --> $DIR/call_method_unknown_pointee.rs:17:13 + --> $DIR/call_method_unknown_pointee.rs:12:13 | LL | let b = ptr as *const _; | ^ @@ -21,25 +21,25 @@ LL | let b: *const _ = ptr as *const _; | ++++++++++ error[E0282]: type annotations needed - --> $DIR/call_method_unknown_pointee.rs:27:23 + --> $DIR/call_method_unknown_pointee.rs:21:23 | -LL | let _c: i32 = (ptr as *mut _).read(); +LL | let _a: i32 = (ptr as *mut _).read(); | ^^^^^^^^^^^^^^^ ---- cannot call a method on a raw pointer with an unknown pointee type | | | cannot infer type error[E0282]: type annotations needed for `*mut _` - --> $DIR/call_method_unknown_pointee.rs:35:13 + --> $DIR/call_method_unknown_pointee.rs:23:13 | -LL | let d = ptr as *mut _; +LL | let b = ptr as *mut _; | ^ LL | -LL | let _d: u8 = d.read(); - | ---- cannot call a method on a raw pointer with an unknown pointee type +LL | b.write(10); + | ----- cannot call a method on a raw pointer with an unknown pointee type | -help: consider giving `d` an explicit type, where the placeholders `_` are specified +help: consider giving `b` an explicit type, where the placeholders `_` are specified | -LL | let d: *mut _ = ptr as *mut _; +LL | let b: *mut _ = ptr as *mut _; | ++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/methods/call_method_unknown_referent.rs b/tests/ui/methods/call_method_unknown_referent.rs index 54b8653a2109..b26ecc74175b 100644 --- a/tests/ui/methods/call_method_unknown_referent.rs +++ b/tests/ui/methods/call_method_unknown_referent.rs @@ -14,22 +14,20 @@ impl SmartPtr { fn foo(&self) {} } -fn a() { - let ptr = &1u32; +fn main() { + let val = 1_u32; + let ptr = &val; let _a: i32 = (ptr as &_).read(); //~^ ERROR type annotations needed -} -fn b() { // Same again, but with a smart pointer type - let rc = std::rc::Rc::new(1u32); + let val2 = 1_u32; + let rc = std::rc::Rc::new(val2); let _b = (rc as std::rc::Rc<_>).read(); //~^ ERROR type annotations needed -} -fn c() { // Same again, but with a smart pointer type - let ptr = SmartPtr(1u32); + let ptr = SmartPtr(val); // We can call unambiguous outer-type methods on this (ptr as SmartPtr<_>).foo(); @@ -48,5 +46,3 @@ fn c() { let _c = (ptr as SmartPtr<_>).read(); //~^ ERROR no method named `read` found for struct `SmartPtr` } - -fn main() {} diff --git a/tests/ui/methods/call_method_unknown_referent.stderr b/tests/ui/methods/call_method_unknown_referent.stderr index 92fb32b987df..35c7d9caf3ef 100644 --- a/tests/ui/methods/call_method_unknown_referent.stderr +++ b/tests/ui/methods/call_method_unknown_referent.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/call_method_unknown_referent.rs:19:19 + --> $DIR/call_method_unknown_referent.rs:20:19 | LL | let _a: i32 = (ptr as &_).read(); | ^^^^^^^^^^^ cannot infer type @@ -11,7 +11,7 @@ LL | let _b = (rc as std::rc::Rc<_>).read(); | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error[E0599]: no method named `read` found for struct `SmartPtr` in the current scope - --> $DIR/call_method_unknown_referent.rs:48:35 + --> $DIR/call_method_unknown_referent.rs:46:35 | LL | struct SmartPtr(T); | ------------------ method `read` not found for this struct diff --git a/tests/ui/methods/method-normalize-bounds-issue-20604.rs b/tests/ui/methods/method-normalize-bounds-issue-20604.rs index 9f20f99b97fc..ea18fe14d157 100644 --- a/tests/ui/methods/method-normalize-bounds-issue-20604.rs +++ b/tests/ui/methods/method-normalize-bounds-issue-20604.rs @@ -1,6 +1,7 @@ //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(stable_features)] // Test that we handle projection types which wind up important for // resolving methods. This test was reduced from a larger example; the @@ -9,6 +10,8 @@ // type projection. +#![feature(associated_types)] + trait Hasher { type Output; fn finish(&self) -> Self::Output; diff --git a/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr b/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr deleted file mode 100644 index 89229ebabe84..000000000000 --- a/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr +++ /dev/null @@ -1,8 +0,0 @@ -warning: MIR pass `SimplifyCfg` is unknown and will be ignored - -warning: MIR pass `SimplifyCfg` is unknown and will be ignored - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 2 warnings emitted - diff --git a/tests/ui/mir/enable_passes_validation.rs b/tests/ui/mir/enable_passes_validation.rs index d3d22b49ac7f..99b1ba528b0c 100644 --- a/tests/ui/mir/enable_passes_validation.rs +++ b/tests/ui/mir/enable_passes_validation.rs @@ -1,5 +1,4 @@ //@ revisions: empty unprefixed all_unknown all_known mixed -//@ revisions: enum_not_in_pass_names enum_in_pass_names //@[empty] compile-flags: -Zmir-enable-passes= @@ -14,12 +13,6 @@ //@[mixed] check-pass //@[mixed] compile-flags: -Zmir-enable-passes=+ThisPassDoesNotExist,+CheckAlignment -//@[enum_not_in_pass_names] check-pass -//@[enum_not_in_pass_names] compile-flags: -Zmir-enable-passes=+SimplifyCfg - -//@[enum_in_pass_names] check-pass -//@[enum_in_pass_names] compile-flags: -Zmir-enable-passes=+AddCallGuards - fn main() {} //[empty]~? ERROR incorrect value `` for unstable option `mir-enable-passes` @@ -30,5 +23,3 @@ fn main() {} //[all_unknown]~? WARN MIR pass `DoesNotExist` is unknown and will be ignored //[all_unknown]~? WARN MIR pass `ThisPass` is unknown and will be ignored //[all_unknown]~? WARN MIR pass `DoesNotExist` is unknown and will be ignored -//[enum_not_in_pass_names]~? WARN MIR pass `SimplifyCfg` is unknown and will be ignored -//[enum_not_in_pass_names]~? WARN MIR pass `SimplifyCfg` is unknown and will be ignored diff --git a/tests/ui/mir/gvn-opt-138225.rs b/tests/ui/mir/gvn-opt-138225.rs deleted file mode 100644 index 46359e044e2e..000000000000 --- a/tests/ui/mir/gvn-opt-138225.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! Regression test for - -pub struct A { - name: NestedOption>, - //~^ ERROR cannot find type `NestedOption` in this scope -} - -impl A { - pub async fn func1() -> &'static A { - //~^ ERROR `async fn` is not permitted in Rust 2015 - static RES: A = A { name: None }; - &RES - } -} - -fn main() {} diff --git a/tests/ui/mir/gvn-opt-138225.stderr b/tests/ui/mir/gvn-opt-138225.stderr deleted file mode 100644 index b2e3d4476bf8..000000000000 --- a/tests/ui/mir/gvn-opt-138225.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/gvn-opt-138225.rs:9:9 - | -LL | pub async fn func1() -> &'static A { - | ^^^^^ to use `async fn`, switch to Rust 2018 or later - | - = help: pass `--edition 2024` to `rustc` - = note: for more on editions, read https://doc.rust-lang.org/edition-guide - -error[E0425]: cannot find type `NestedOption` in this scope - --> $DIR/gvn-opt-138225.rs:4:11 - | -LL | name: NestedOption>, - | ^^^^^^^^^^^^ not found in this scope - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0425, E0670. -For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/mir/issue-121103.rs b/tests/ui/mir/issue-121103.rs index 4a3d3f5590f3..247c644c5bb1 100644 --- a/tests/ui/mir/issue-121103.rs +++ b/tests/ui/mir/issue-121103.rs @@ -1,5 +1,3 @@ fn main(_: as lib2::TypeFn>::Output) {} -//~^ ERROR: cannot find -//~| ERROR: cannot find -//~| NOTE: use of unresolved module or unlinked crate `lib2` -//~| NOTE: use of unresolved module or unlinked crate `lib2` +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `lib2` +//~| ERROR failed to resolve: use of unresolved module or unlinked crate `lib2` diff --git a/tests/ui/mir/issue-121103.stderr b/tests/ui/mir/issue-121103.stderr index 236a3cbc5806..3565f6f0cdef 100644 --- a/tests/ui/mir/issue-121103.stderr +++ b/tests/ui/mir/issue-121103.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `lib2` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `lib2` --> $DIR/issue-121103.rs:1:38 | LL | fn main(_: as lib2::TypeFn>::Output) {} @@ -6,7 +6,7 @@ LL | fn main(_: as lib2::TypeFn>::Output) {} | = help: you might be missing a crate named `lib2` -error[E0433]: cannot find module or crate `lib2` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `lib2` --> $DIR/issue-121103.rs:1:13 | LL | fn main(_: as lib2::TypeFn>::Output) {} diff --git a/tests/ui/mir/lint/storage-live.stderr b/tests/ui/mir/lint/storage-live.stderr index c8d07314f075..ef0d253b15a8 100644 --- a/tests/ui/mir/lint/storage-live.stderr +++ b/tests/ui/mir/lint/storage-live.stderr @@ -13,7 +13,7 @@ LL | StorageLive(a); aborting due to `-Z treat-err-as-bug=1` -error: the compiler unexpectedly panicked. This is a bug +error: the compiler unexpectedly panicked. this is a bug. query stack during panic: end of query stack diff --git a/tests/ui/mir/mir_fat_ptr_drop.rs b/tests/ui/mir/mir_fat_ptr_drop.rs index b832d5a4ce9f..ff6a0d70881f 100644 --- a/tests/ui/mir/mir_fat_ptr_drop.rs +++ b/tests/ui/mir/mir_fat_ptr_drop.rs @@ -1,7 +1,10 @@ //@ run-pass #![allow(unused_variables)] +#![allow(stable_features)] // test that ordinary fat pointer operations work. + +#![feature(braced_empty_structs)] #![feature(rustc_attrs)] use std::sync::atomic; diff --git a/tests/ui/mismatched_types/mismatched-types-issue-126222.stderr b/tests/ui/mismatched_types/mismatched-types-issue-126222.stderr index 09ba15253dc5..2a8f9867abb8 100644 --- a/tests/ui/mismatched_types/mismatched-types-issue-126222.stderr +++ b/tests/ui/mismatched_types/mismatched-types-issue-126222.stderr @@ -4,6 +4,7 @@ error[E0308]: mismatched types LL | x => dbg!(x), | ^^^^^^^ expected `()`, found integer | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might have meant to return this value | LL | x => return dbg!(x), @@ -15,6 +16,7 @@ error[E0308]: mismatched types LL | dbg!(x) | ^^^^^^^ expected `()`, found integer | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might have meant to return this value | LL | return dbg!(x) @@ -26,6 +28,7 @@ error[E0308]: mismatched types LL | _ => dbg!(1) | ^^^^^^^ expected `()`, found integer | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might have meant to return this value | LL | _ => return dbg!(1) @@ -37,6 +40,7 @@ error[E0308]: mismatched types LL | _ => {dbg!(1)} | ^^^^^^^ expected `()`, found integer | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might have meant to return this value | LL | _ => {return dbg!(1)} diff --git a/tests/ui/missing-trait-bounds/issue-69725.stderr b/tests/ui/missing-trait-bounds/issue-69725.stderr index 20d2213f4f5f..f483ea849b0e 100644 --- a/tests/ui/missing-trait-bounds/issue-69725.stderr +++ b/tests/ui/missing-trait-bounds/issue-69725.stderr @@ -1,17 +1,17 @@ -error[E0599]: the method `clone` exists for struct `issue_69725::Struct`, but its trait bounds were not satisfied +error[E0599]: the method `clone` exists for struct `Struct`, but its trait bounds were not satisfied --> $DIR/issue-69725.rs:9:32 | LL | let _ = Struct::::new().clone(); - | ^^^^^ method cannot be called on `issue_69725::Struct` due to unsatisfied trait bounds + | ^^^^^ method cannot be called on `Struct` due to unsatisfied trait bounds | ::: $DIR/auxiliary/issue-69725.rs:2:1 | LL | pub struct Struct(A); - | -------------------- doesn't satisfy `issue_69725::Struct: Clone` + | -------------------- doesn't satisfy `Struct: Clone` | = note: the following trait bounds were not satisfied: `A: Clone` - which is required by `issue_69725::Struct: Clone` + which is required by `Struct: Clone` help: consider restricting the type parameter to satisfy the trait bound | LL | fn crash() where A: Clone { diff --git a/tests/ui/missing/missing-let.rs b/tests/ui/missing/missing-let.rs deleted file mode 100644 index 595de640470b..000000000000 --- a/tests/ui/missing/missing-let.rs +++ /dev/null @@ -1,18 +0,0 @@ -fn main() { - let x = Some(42); - let y = Some(42); - let z = Some(42); - if let Some(_) = x - && Some(x) = x //~^ ERROR expected expression, found `let` statement - //~| NOTE: only supported directly in conditions of `if` and `while` expressions - {} - - if Some(_) = y && - //~^ NOTE expected `let` expression, found assignment - //~| ERROR let-chain with missing `let` - let Some(_) = z - //~^ ERROR: expected expression, found `let` statement - //~| NOTE: let expression later in the condition - //~| NOTE: only supported directly in conditions of `if` and `while` expressions - {} -} diff --git a/tests/ui/missing/missing-let.stderr b/tests/ui/missing/missing-let.stderr deleted file mode 100644 index 0a6e76b154f7..000000000000 --- a/tests/ui/missing/missing-let.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/missing-let.rs:5:8 - | -LL | if let Some(_) = x - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -help: you might have meant to continue the let-chain - | -LL | && let Some(x) = x - | +++ -help: you might have meant to compare for equality - | -LL | && Some(x) == x - | + - -error: expected expression, found `let` statement - --> $DIR/missing-let.rs:13:9 - | -LL | let Some(_) = z - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: let-chain with missing `let` - --> $DIR/missing-let.rs:10:8 - | -LL | if Some(_) = y && - | ^^^^^^^---- - | | - | expected `let` expression, found assignment -... -LL | let Some(_) = z - | --------------- let expression later in the condition - | -help: add `let` before the expression - | -LL | if let Some(_) = y && - | +++ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/modules/issue-107649.rs b/tests/ui/modules/issue-107649.rs index 731c2c0592a1..f93fb07e17af 100644 --- a/tests/ui/modules/issue-107649.rs +++ b/tests/ui/modules/issue-107649.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z ui-testing=no --diagnostic-width=80 +//@ compile-flags: -Z ui-testing=no #[path = "auxiliary/dummy_lib.rs"] mod lib; diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr index 40dda93ad015..49d7cb4e0aad 100644 --- a/tests/ui/modules/issue-107649.stderr +++ b/tests/ui/modules/issue-107649.stderr @@ -5,6 +5,7 @@ error[E0277]: `Dummy` doesn't implement `Debug` | ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Dummy` | = note: add `#[derive(Debug)]` to `Dummy` or manually `impl Debug for Dummy` + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Dummy` with `#[derive(Debug)]` --> $DIR/auxiliary/dummy_lib.rs:2:1 | diff --git a/tests/ui/modules/super-at-crate-root.rs b/tests/ui/modules/super-at-crate-root.rs index 0aac3a087570..d605dc0cccb3 100644 --- a/tests/ui/modules/super-at-crate-root.rs +++ b/tests/ui/modules/super-at-crate-root.rs @@ -1,6 +1,6 @@ //! Check that `super` keyword used at the crate root (top-level) results in a compilation error //! as there is no parent module to resolve. -use super::f; //~ ERROR too many leading `super` keywords +use super::f; //~ ERROR there are too many leading `super` keywords fn main() {} diff --git a/tests/ui/modules/super-at-crate-root.stderr b/tests/ui/modules/super-at-crate-root.stderr index cb3855cc033d..027987088646 100644 --- a/tests/ui/modules/super-at-crate-root.stderr +++ b/tests/ui/modules/super-at-crate-root.stderr @@ -1,4 +1,4 @@ -error[E0433]: too many leading `super` keywords +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/super-at-crate-root.rs:4:5 | LL | use super::f; diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.stderr b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.stderr index 5de99cc6ca6a..301f3c3a458d 100644 --- a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.stderr +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.stderr @@ -13,8 +13,7 @@ note: `HashSet` does not implement `Clone`, so `&HashSet` was cloned i | LL | let mut x: HashSet = v.clone(); | ^ -help: `Clone` is not implemented because a trait bound is not satisfied - --> $SRC_DIR/std/src/collections/hash/set.rs:LL:COL + = help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied help: consider annotating `Day` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr index 5de99cc6ca6a..301f3c3a458d 100644 --- a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr @@ -13,8 +13,7 @@ note: `HashSet` does not implement `Clone`, so `&HashSet` was cloned i | LL | let mut x: HashSet = v.clone(); | ^ -help: `Clone` is not implemented because a trait bound is not satisfied - --> $SRC_DIR/std/src/collections/hash/set.rs:LL:COL + = help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied help: consider annotating `Day` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/moves/issue-72649-uninit-in-loop.rs b/tests/ui/moves/issue-72649-uninit-in-loop.rs index f115656d7c0d..8f2e01bdf1ab 100644 --- a/tests/ui/moves/issue-72649-uninit-in-loop.rs +++ b/tests/ui/moves/issue-72649-uninit-in-loop.rs @@ -70,7 +70,6 @@ fn moved_loop_2() { fn uninit_1() { loop { let value: NonCopy; //~ NOTE declared here - //~^ HELP consider assigning a value let _used = value; //~ ERROR binding `value` isn't initialized //~^ NOTE `value` used here but it isn't initialized } @@ -78,7 +77,6 @@ fn uninit_1() { fn uninit_2() { let mut value: NonCopy; //~ NOTE declared here - //~^ HELP consider assigning a value loop { let _used = value; //~ ERROR binding `value` isn't initialized //~^ NOTE `value` used here but it isn't initialized diff --git a/tests/ui/moves/issue-72649-uninit-in-loop.stderr b/tests/ui/moves/issue-72649-uninit-in-loop.stderr index 8bde3b5c042d..3a93769ac454 100644 --- a/tests/ui/moves/issue-72649-uninit-in-loop.stderr +++ b/tests/ui/moves/issue-72649-uninit-in-loop.stderr @@ -83,11 +83,10 @@ LL | let _used2 = value; | ----- you could clone this value error[E0381]: used binding `value` isn't initialized - --> $DIR/issue-72649-uninit-in-loop.rs:74:21 + --> $DIR/issue-72649-uninit-in-loop.rs:73:21 | LL | let value: NonCopy; | ----- binding declared here but left uninitialized -LL | LL | let _used = value; | ^^^^^ `value` used here but it isn't initialized | @@ -97,11 +96,11 @@ LL | let value: NonCopy = /* value */; | +++++++++++++ error[E0381]: used binding `value` isn't initialized - --> $DIR/issue-72649-uninit-in-loop.rs:83:21 + --> $DIR/issue-72649-uninit-in-loop.rs:81:21 | LL | let mut value: NonCopy; | --------- binding declared here but left uninitialized -... +LL | loop { LL | let _used = value; | ^^^^^ `value` used here but it isn't initialized | diff --git a/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr index ba729493c9b7..17049fe67318 100644 --- a/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr @@ -11,6 +11,7 @@ LL | }); LL | println!("{}", x); | ^ value borrowed here after move | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value before moving it into the closure | LL ~ let value = x.clone(); diff --git a/tests/ui/new-range/disabled.rs b/tests/ui/new-range/disabled.rs index ab6fbd3276b3..6ba29f5ca9a2 100644 --- a/tests/ui/new-range/disabled.rs +++ b/tests/ui/new-range/disabled.rs @@ -4,12 +4,11 @@ fn main() { // Unchanged - let a: core::ops::RangeFull = ..; - let b: core::ops::RangeTo = ..2; + let a: core::range::RangeFull = ..; + let b: core::range::RangeTo = ..2; - // FIXME(#125687): re-exports temporarily removed - // let _: core::range::RangeFull = a; - // let _: core::range::RangeTo = b; + let _: core::ops::RangeFull = a; + let _: core::ops::RangeTo = b; // Changed let a: core::range::legacy::RangeFrom = 1..; diff --git a/tests/ui/new-range/enabled.rs b/tests/ui/new-range/enabled.rs index b49681eaacde..140e3b648709 100644 --- a/tests/ui/new-range/enabled.rs +++ b/tests/ui/new-range/enabled.rs @@ -5,12 +5,11 @@ fn main() { // Unchanged - let a: core::ops::RangeFull = ..; - let b: core::ops::RangeTo = ..2; + let a: core::range::RangeFull = ..; + let b: core::range::RangeTo = ..2; - // FIXME(#125687): re-exports temporarily removed - // let _: core::range::RangeFull = a; - // let _: core::range::RangeTo = b; + let _: core::ops::RangeFull = a; + let _: core::ops::RangeTo = b; // Changed let a: core::range::RangeFrom = 1..; diff --git a/tests/ui/nll/borrowck-annotate-static-lifetime.rs b/tests/ui/nll/borrowck-annotate-static-lifetime.rs new file mode 100644 index 000000000000..9d849db9b4f3 --- /dev/null +++ b/tests/ui/nll/borrowck-annotate-static-lifetime.rs @@ -0,0 +1,5 @@ +//! regression test for issue +fn main() { + let _vec: Vec<&'static String> = vec![&String::new()]; + //~^ ERROR temporary value dropped while borrowed [E0716] +} diff --git a/tests/ui/nll/borrowck-annotate-static-lifetime.stderr b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr new file mode 100644 index 000000000000..9cb9007d9131 --- /dev/null +++ b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr @@ -0,0 +1,12 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/borrowck-annotate-static-lifetime.rs:3:44 + | +LL | let _vec: Vec<&'static String> = vec![&String::new()]; + | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary value which is freed while still in use + | type annotation requires that borrow lasts for `'static` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/nll/issue-112604-closure-output-normalize.rs b/tests/ui/nll/issue-112604-closure-output-normalize.rs index c99900759917..117e1d91e341 100644 --- a/tests/ui/nll/issue-112604-closure-output-normalize.rs +++ b/tests/ui/nll/issue-112604-closure-output-normalize.rs @@ -1,7 +1,4 @@ //@check-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver use higher_kinded_types::*; mod higher_kinded_types { diff --git a/tests/ui/nll/issue-98693.stderr b/tests/ui/nll/issue-98693.stderr index cf69fbd5aeed..b5e281538f9c 100644 --- a/tests/ui/nll/issue-98693.stderr +++ b/tests/ui/nll/issue-98693.stderr @@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/issue-98693.rs:16:9 | LL | assert_static::(); - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | | | the parameter type `T` must be valid for the static lifetime... | ...so that the type `T` will meet its required lifetime bounds diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr index 0ab90faabcf0..dc38b8c127e5 100644 --- a/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr @@ -35,21 +35,8 @@ LL | | } LL | | } | |_____- returning this value requires that `*map` is borrowed for `'r` -error[E0499]: cannot borrow `*map` as mutable more than once at a time - --> $DIR/nll-problem-case-3-issue-21906.rs:45:41 - | -LL | fn get_priority_mut_entry<'a, K, V>( - | -- lifetime `'a` defined here -... -LL | match map.entry(key1) { - | --- first mutable borrow occurs here -LL | Entry::Occupied(occupied) => Some(occupied.into_mut()), - | ------------------------- returning this value requires that `*map` is borrowed for `'a` -LL | Entry::Vacant(_vacant) => match map.entry(key2) { - | ^^^ second mutable borrow occurs here - error[E0499]: cannot borrow `*self` as mutable more than once at a time - --> $DIR/nll-problem-case-3-issue-21906.rs:64:21 + --> $DIR/nll-problem-case-3-issue-21906.rs:44:21 | LL | fn two(&mut self) -> &i32 { | - let's call the lifetime of this reference `'1` @@ -61,7 +48,7 @@ LL | return k; | - returning this value requires that `*self` is borrowed for `'1` error[E0502]: cannot borrow `x.data` as immutable because it is also borrowed as mutable - --> $DIR/nll-problem-case-3-issue-21906.rs:82:22 + --> $DIR/nll-problem-case-3-issue-21906.rs:62:22 | LL | fn foo(x: &mut Foo) -> Option<&mut i32> { | - let's call the lifetime of this reference `'1` @@ -72,9 +59,11 @@ LL | return Some(y); ... LL | println!("{:?}", x.data); | ^^^^^^ immutable borrow occurs here + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0499]: cannot borrow `*vec` as mutable more than once at a time - --> $DIR/nll-problem-case-3-issue-21906.rs:97:9 + --> $DIR/nll-problem-case-3-issue-21906.rs:77:9 | LL | fn f(vec: &mut Vec) -> &u8 { | - let's call the lifetime of this reference `'1` @@ -88,7 +77,7 @@ LL | vec.push(10); | ^^^ second mutable borrow occurs here error[E0502]: cannot borrow `*vec` as immutable because it is also borrowed as mutable - --> $DIR/nll-problem-case-3-issue-21906.rs:98:9 + --> $DIR/nll-problem-case-3-issue-21906.rs:78:9 | LL | fn f(vec: &mut Vec) -> &u8 { | - let's call the lifetime of this reference `'1` @@ -101,7 +90,7 @@ LL | n LL | vec.last().unwrap() | ^^^ immutable borrow occurs here -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0499, E0502. For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs index 45b56e32522f..b025ea78f8b4 100644 --- a/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs @@ -29,26 +29,6 @@ fn from_the_rfc<'r, K: Hash + Eq + Copy, V: Default>( } } -// A variant that's similar to the RFC example above, but using the entry API, and requested in -// https://internals.rust-lang.org/t/get-mut-map-back-from-entry-api/24003 -fn get_priority_mut_entry<'a, K, V>( - map: &'a mut HashMap, - key1: K, - key2: K, -) -> Option<&'a mut V> -where - K: Eq + Hash, -{ - use std::collections::hash_map::Entry; - match map.entry(key1) { - Entry::Occupied(occupied) => Some(occupied.into_mut()), - Entry::Vacant(_vacant) => match map.entry(key2) { - Entry::Occupied(occupied2) => Some(occupied2.into_mut()), - Entry::Vacant(_) => None, - }, - } -} - // MCVE 1 from issue #21906 struct A { a: i32, diff --git a/tests/ui/nll/type-test-universe.stderr b/tests/ui/nll/type-test-universe.stderr index c9dcb69f08f5..54b48c1597bd 100644 --- a/tests/ui/nll/type-test-universe.stderr +++ b/tests/ui/nll/type-test-universe.stderr @@ -2,7 +2,7 @@ error: `S` does not live long enough --> $DIR/type-test-universe.rs:11:5 | LL | outlives_forall::(); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error: lifetime may not live long enough --> $DIR/type-test-universe.rs:17:5 diff --git a/tests/ui/nll/user-annotations/patterns.rs b/tests/ui/nll/user-annotations/patterns.rs index 07f78430f67c..1f635d7f50cd 100644 --- a/tests/ui/nll/user-annotations/patterns.rs +++ b/tests/ui/nll/user-annotations/patterns.rs @@ -70,11 +70,6 @@ fn underscore_with_initializer() { //~^ ERROR temporary value dropped while borrowed [E0716] } -fn issue_47184() { - let _vec: Vec<&'static String> = vec![&String::new()]; - //~^ ERROR temporary value dropped while borrowed [E0716] -} - fn pair_underscores_with_initializer() { let x = 22; let (_, _): (&'static u32, u32) = (&x, 44); //~ ERROR diff --git a/tests/ui/nll/user-annotations/patterns.stderr b/tests/ui/nll/user-annotations/patterns.stderr index 325af6a52a0e..8bb714f1d0cd 100644 --- a/tests/ui/nll/user-annotations/patterns.stderr +++ b/tests/ui/nll/user-annotations/patterns.stderr @@ -111,17 +111,8 @@ LL | let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44); | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` -error[E0716]: temporary value dropped while borrowed - --> $DIR/patterns.rs:74:44 - | -LL | let _vec: Vec<&'static String> = vec![&String::new()]; - | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement - | | | - | | creates a temporary value which is freed while still in use - | type annotation requires that borrow lasts for `'static` - error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:80:40 + --> $DIR/patterns.rs:75:40 | LL | let x = 22; | - binding `x` declared here @@ -133,7 +124,7 @@ LL | } | - `x` dropped here while still borrowed error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:85:40 + --> $DIR/patterns.rs:80:40 | LL | let x = 22; | - binding `x` declared here @@ -145,7 +136,7 @@ LL | } | - `x` dropped here while still borrowed error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:90:69 + --> $DIR/patterns.rs:85:69 | LL | let x = 22; | - binding `x` declared here @@ -157,7 +148,7 @@ LL | } | - `x` dropped here while still borrowed error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:95:69 + --> $DIR/patterns.rs:90:69 | LL | let x = 22; | - binding `x` declared here @@ -169,7 +160,7 @@ LL | } | - `x` dropped here while still borrowed error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:103:17 + --> $DIR/patterns.rs:98:17 | LL | let x = 22; | - binding `x` declared here @@ -182,7 +173,7 @@ LL | } | - `x` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/patterns.rs:116:5 + --> $DIR/patterns.rs:111:5 | LL | fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here @@ -191,7 +182,7 @@ LL | y | ^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/patterns.rs:128:5 + --> $DIR/patterns.rs:123:5 | LL | fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here @@ -200,7 +191,7 @@ LL | y | ^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/patterns.rs:133:5 + --> $DIR/patterns.rs:128:5 | LL | fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here @@ -209,14 +200,14 @@ LL | y | ^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/patterns.rs:137:18 + --> $DIR/patterns.rs:132:18 | LL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | let (y, _z): (&'static u32, u32) = (x, 44); | ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` -error: aborting due to 20 previous errors +error: aborting due to 19 previous errors Some errors have detailed explanations: E0597, E0716. For more information about an error, try `rustc --explain E0597`. diff --git a/tests/ui/no_std/no-core-with-explicit-std-core.rs b/tests/ui/no_std/no-core-with-explicit-std-core.rs index 6e8e41adca07..3940bcb3aa4f 100644 --- a/tests/ui/no_std/no-core-with-explicit-std-core.rs +++ b/tests/ui/no_std/no-core-with-explicit-std-core.rs @@ -6,7 +6,8 @@ //@ run-pass -#![feature(no_core)] +#![allow(stable_features)] +#![feature(no_core, core)] #![no_core] extern crate core; diff --git a/tests/ui/object-lifetime/object-lifetime-default-ambiguous.rs b/tests/ui/object-lifetime/object-lifetime-default-ambiguous.rs index 0a0f44073740..5dae92fee5f9 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-ambiguous.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-ambiguous.rs @@ -21,11 +21,11 @@ struct Ref2<'a,'b:'a,T:'a+'b+?Sized> { } fn a<'a,'b>(t: Ref2<'a,'b, dyn Test>) { - //~^ ERROR cannot deduce the lifetime bound for this trait object type + //~^ ERROR lifetime bound for this object type cannot be deduced from context } fn b(t: Ref2) { - //~^ ERROR cannot deduce the lifetime bound for this trait object type + //~^ ERROR lifetime bound for this object type cannot be deduced from context } fn c(t: Ref2<&dyn Test>) { @@ -41,7 +41,7 @@ fn e(t: Ref2>) { } fn f(t: &Ref2) { - //~^ ERROR cannot deduce the lifetime bound for this trait object type + //~^ ERROR lifetime bound for this object type cannot be deduced from context } fn main() { diff --git a/tests/ui/object-lifetime/object-lifetime-default-ambiguous.stderr b/tests/ui/object-lifetime/object-lifetime-default-ambiguous.stderr index 6aa3da66fda0..bd50a27fd5e5 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-ambiguous.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-ambiguous.stderr @@ -1,35 +1,20 @@ -error[E0228]: cannot deduce the lifetime bound for this trait object type from context +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:23:28 | LL | fn a<'a,'b>(t: Ref2<'a,'b, dyn Test>) { | ^^^^^^^^ - | -help: please supply an explicit bound - | -LL | fn a<'a,'b>(t: Ref2<'a,'b, dyn Test + /* 'a */>) { - | ++++++++++ -error[E0228]: cannot deduce the lifetime bound for this trait object type from context +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:27:14 | LL | fn b(t: Ref2) { | ^^^^^^^^ - | -help: please supply an explicit bound - | -LL | fn b(t: Ref2) { - | ++++++++++ -error[E0228]: cannot deduce the lifetime bound for this trait object type from context +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:43:15 | LL | fn f(t: &Ref2) { | ^^^^^^^^ - | -help: please supply an explicit bound - | -LL | fn f(t: &Ref2) { - | ++++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.rs b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.rs index 7a7bba02879e..7337383e2978 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.rs @@ -18,7 +18,7 @@ fn is_static(_: T) where T: 'static { } // Here, we should default to `dyn Bar + 'static`, but the current // code forces us into a conservative, hacky path. fn bar<'a>(x: &'a str) -> &'a dyn Foo<'a, Item = dyn Bar> { &() } -//~^ ERROR cannot deduce the lifetime bound for this trait object type +//~^ ERROR please supply an explicit bound fn main() { let s = format!("foo"); diff --git a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.stderr b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.stderr index 5744d0dd162c..8d44b4de55a4 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic1.stderr @@ -1,13 +1,8 @@ -error[E0228]: cannot deduce the lifetime bound for this trait object type from context +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-dyn-binding-nonstatic1.rs:20:50 | LL | fn bar<'a>(x: &'a str) -> &'a dyn Foo<'a, Item = dyn Bar> { &() } | ^^^^^^^ - | -help: please supply an explicit bound - | -LL | fn bar<'a>(x: &'a str) -> &'a dyn Foo<'a, Item = dyn Bar + /* 'a */> { &() } - | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.rs b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.rs index 9ddf792eaada..2a7415174f8a 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.rs @@ -18,7 +18,7 @@ fn is_static(_: T) where T: 'static { } // Here, we default to `dyn Bar + 'a`. Or, we *should*, but the // current code forces us into a conservative, hacky path. fn bar<'a>(x: &'a str) -> &'a dyn Foo<'a, Item = dyn Bar> { &() } -//~^ ERROR cannot deduce the lifetime bound for this trait object type +//~^ ERROR please supply an explicit bound fn main() { let s = format!("foo"); diff --git a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.stderr b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.stderr index ca8612f57934..0846dd60723a 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic2.stderr @@ -1,13 +1,8 @@ -error[E0228]: cannot deduce the lifetime bound for this trait object type from context +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-dyn-binding-nonstatic2.rs:20:50 | LL | fn bar<'a>(x: &'a str) -> &'a dyn Foo<'a, Item = dyn Bar> { &() } | ^^^^^^^ - | -help: please supply an explicit bound - | -LL | fn bar<'a>(x: &'a str) -> &'a dyn Foo<'a, Item = dyn Bar + /* 'a */> { &() } - | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.rs b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.rs index 48ac5623f898..51be999a6329 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.rs @@ -14,7 +14,7 @@ fn is_static(_: T) where T: 'static { } // Here, we should default to `dyn Bar + 'static`, but the current // code forces us into a conservative, hacky path. fn bar(x: &str) -> &dyn Foo { &() } -//~^ ERROR cannot deduce the lifetime bound for this trait object type +//~^ ERROR please supply an explicit bound fn main() { let s = format!("foo"); diff --git a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.stderr b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.stderr index 05620d3878f7..688f8af0822b 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-dyn-binding-nonstatic3.stderr @@ -1,13 +1,8 @@ -error[E0228]: cannot deduce the lifetime bound for this trait object type from context +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-dyn-binding-nonstatic3.rs:16:36 | LL | fn bar(x: &str) -> &dyn Foo { &() } | ^^^^^^^ - | -help: please supply an explicit bound - | -LL | fn bar(x: &str) -> &dyn Foo { &() } - | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/object-lifetime/undeclared-object-lifetime.rs b/tests/ui/object-lifetime/undeclared-object-lifetime.rs deleted file mode 100644 index 7c0e1100fe7b..000000000000 --- a/tests/ui/object-lifetime/undeclared-object-lifetime.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! E0228 (lifetime bound for trait object cannot be deduced from context) should not be emitted -//! when an undeclared lifetime bound has been specified. -//! -//! Regression test for https://github.com/rust-lang/rust/issues/152014 - -fn f(_: std::cell::Ref<'undefined, dyn std::fmt::Debug>) {} //~ ERROR use of undeclared lifetime name `'undefined` -fn main() {} diff --git a/tests/ui/object-lifetime/undeclared-object-lifetime.stderr b/tests/ui/object-lifetime/undeclared-object-lifetime.stderr deleted file mode 100644 index b6646a05420b..000000000000 --- a/tests/ui/object-lifetime/undeclared-object-lifetime.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0261]: use of undeclared lifetime name `'undefined` - --> $DIR/undeclared-object-lifetime.rs:6:24 - | -LL | fn f(_: std::cell::Ref<'undefined, dyn std::fmt::Debug>) {} - | ^^^^^^^^^^ undeclared lifetime - | -help: consider introducing lifetime `'undefined` here - | -LL | fn f<'undefined>(_: std::cell::Ref<'undefined, dyn std::fmt::Debug>) {} - | ++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/on-unimplemented/no-debug.stderr b/tests/ui/on-unimplemented/no-debug.stderr index 3c3b8d2e2054..1e6fa7d52fa0 100644 --- a/tests/ui/on-unimplemented/no-debug.stderr +++ b/tests/ui/on-unimplemented/no-debug.stderr @@ -8,6 +8,7 @@ LL | println!("{:?} {:?}", Foo, Bar); | = help: the trait `Debug` is not implemented for `Foo` = note: add `#[derive(Debug)]` to `Foo` or manually `impl Debug for Foo` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Foo` with `#[derive(Debug)]` | LL + #[derive(Debug)] @@ -23,6 +24,7 @@ LL | println!("{:?} {:?}", Foo, Bar); | required by this formatting parameter | = help: the trait `Debug` is not implemented for `Bar` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Foo` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:23 @@ -38,6 +40,7 @@ help: the trait `std::fmt::Display` is not implemented for `Foo` LL | struct Foo; | ^^^^^^^^^^ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Bar` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:28 @@ -49,6 +52,7 @@ LL | println!("{} {}", Foo, Bar); | = help: the trait `std::fmt::Display` is not implemented for `Bar` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/overloaded/overloaded-autoderef.rs b/tests/ui/overloaded/overloaded-autoderef.rs index c1a715dd2e9f..a7a07449ca89 100644 --- a/tests/ui/overloaded/overloaded-autoderef.rs +++ b/tests/ui/overloaded/overloaded-autoderef.rs @@ -1,5 +1,6 @@ //@ run-pass #![allow(unused_variables)] +#![allow(stable_features)] use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/ui/overloaded/overloaded-index-autoderef.rs b/tests/ui/overloaded/overloaded-index-autoderef.rs index 3709bb0b5cd5..ab49826e9dfc 100644 --- a/tests/ui/overloaded/overloaded-index-autoderef.rs +++ b/tests/ui/overloaded/overloaded-index-autoderef.rs @@ -1,4 +1,6 @@ //@ run-pass +#![allow(stable_features)] + // Test overloaded indexing combined with autoderef. use std::ops::{Index, IndexMut}; diff --git a/tests/ui/panics/default-backtrace-ice.stderr b/tests/ui/panics/default-backtrace-ice.stderr index 4e48e769d9d5..a7d99e325d9b 100644 --- a/tests/ui/panics/default-backtrace-ice.stderr +++ b/tests/ui/panics/default-backtrace-ice.stderr @@ -13,7 +13,7 @@ stack backtrace: (end_short_backtrace) (begin_short_backtrace) -error: the compiler unexpectedly panicked. This is a bug +error: the compiler unexpectedly panicked. this is a bug. diff --git a/tests/ui/panics/panic-handler-chain-update-hook.rs b/tests/ui/panics/panic-handler-chain-update-hook.rs index b75c21c8b3b2..2ae79ad236ef 100644 --- a/tests/ui/panics/panic-handler-chain-update-hook.rs +++ b/tests/ui/panics/panic-handler-chain-update-hook.rs @@ -1,8 +1,11 @@ //@ run-pass //@ needs-unwind +#![allow(stable_features)] + //@ needs-threads //@ ignore-backends: gcc +#![feature(std_panic)] #![feature(panic_update_hook)] use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/panics/panic-handler-chain.rs b/tests/ui/panics/panic-handler-chain.rs index 49b76834ffe9..cc591c1d9992 100644 --- a/tests/ui/panics/panic-handler-chain.rs +++ b/tests/ui/panics/panic-handler-chain.rs @@ -2,6 +2,9 @@ //@ needs-unwind //@ needs-threads //@ ignore-backends: gcc +#![allow(stable_features)] + +#![feature(std_panic)] use std::sync::atomic::{AtomicUsize, Ordering}; use std::panic; diff --git a/tests/ui/panics/panic-handler-flail-wildly.rs b/tests/ui/panics/panic-handler-flail-wildly.rs index b44a388caad3..d5f5195d3812 100644 --- a/tests/ui/panics/panic-handler-flail-wildly.rs +++ b/tests/ui/panics/panic-handler-flail-wildly.rs @@ -1,11 +1,14 @@ //@ run-pass //@ needs-unwind +#![allow(stable_features)] #![allow(unused_must_use)] //@ needs-threads //@ ignore-backends: gcc +#![feature(std_panic)] + use std::panic; use std::thread; diff --git a/tests/ui/panics/panic-handler-set-twice.rs b/tests/ui/panics/panic-handler-set-twice.rs index aa40187f08ca..ca4ed65f5683 100644 --- a/tests/ui/panics/panic-handler-set-twice.rs +++ b/tests/ui/panics/panic-handler-set-twice.rs @@ -1,6 +1,9 @@ //@ run-pass //@ needs-unwind #![allow(unused_variables)] +#![allow(stable_features)] + +#![feature(std_panic)] //@ needs-threads //@ ignore-backends: gcc diff --git a/tests/ui/parser/bare-struct-body.stderr b/tests/ui/parser/bare-struct-body.stderr index 1b817e2b9ee2..7d17ea59647e 100644 --- a/tests/ui/parser/bare-struct-body.stderr +++ b/tests/ui/parser/bare-struct-body.stderr @@ -21,12 +21,14 @@ LL | let x = { | _____________^ LL | | val: (), LL | | }; - | |_____^ struct name missing for struct literal + | |_____^ | -help: add the correct type +help: you might have forgotten to add the struct literal inside the block + | +LL ~ let x = { SomeStruct { +LL | val: (), +LL ~ } }; | -LL | let x = /* Type */ { - | ++++++++++ error[E0308]: mismatched types --> $DIR/bare-struct-body.rs:11:14 diff --git a/tests/ui/parser/const-block-items/attrs.rs b/tests/ui/parser/const-block-items/attrs.rs deleted file mode 100644 index eb7a0554ea9c..000000000000 --- a/tests/ui/parser/const-block-items/attrs.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass - -#![feature(const_block_items)] - -#[cfg(false)] -const { assert!(false) } - -#[expect(unused)] -const { - let a = 1; - assert!(true); -} - -fn main() {} diff --git a/tests/ui/parser/const-block-items/inner-attr.rs b/tests/ui/parser/const-block-items/inner-attr.rs deleted file mode 100644 index 5da3191760d2..000000000000 --- a/tests/ui/parser/const-block-items/inner-attr.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(const_block_items)] - -// ATTENTION: if we ever start accepting inner attributes here, make sure `rustfmt` can handle them. -// see: https://github.com/rust-lang/rustfmt/issues/6158 - -const { - #![expect(unused)] //~ ERROR: an inner attribute is not permitted in this context - let a = 1; - assert!(true); -} - -fn main() {} diff --git a/tests/ui/parser/const-block-items/inner-attr.stderr b/tests/ui/parser/const-block-items/inner-attr.stderr deleted file mode 100644 index e0a70566332c..000000000000 --- a/tests/ui/parser/const-block-items/inner-attr.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: an inner attribute is not permitted in this context - --> $DIR/inner-attr.rs:7:5 - | -LL | #![expect(unused)] - | ^^^^^^^^^^^^^^^^^^ -... -LL | fn main() {} - | ------------ the inner attribute doesn't annotate this function - | - = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files - -error: aborting due to 1 previous error - diff --git a/tests/ui/parser/const-block-items/macro-item.rs b/tests/ui/parser/const-block-items/macro-item.rs deleted file mode 100644 index 0c07bfc203d2..000000000000 --- a/tests/ui/parser/const-block-items/macro-item.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass -#![feature(const_block_items)] - -macro_rules! foo { - ($item:item) => { - $item - }; -} - -foo!(const {}); - -fn main() {} diff --git a/tests/ui/parser/const-block-items/macro-stmt.rs b/tests/ui/parser/const-block-items/macro-stmt.rs deleted file mode 100644 index 38632d2eec33..000000000000 --- a/tests/ui/parser/const-block-items/macro-stmt.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-fail - -#![feature(const_block_items)] - -macro_rules! foo { - ($item:item) => { - $item - //~^ ERROR: expected expression, found `` - }; -} - -fn main() { - foo!(const {}); -} diff --git a/tests/ui/parser/const-block-items/macro-stmt.stderr b/tests/ui/parser/const-block-items/macro-stmt.stderr deleted file mode 100644 index dce90e5daa4c..000000000000 --- a/tests/ui/parser/const-block-items/macro-stmt.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: expected expression, found `` - --> $DIR/macro-stmt.rs:7:9 - | -LL | $item - | ^^^^^ expected expression -... -LL | foo!(const {}); - | -------------- in this macro invocation - | - = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 1 previous error - diff --git a/tests/ui/parser/const-block-items/mod-in-fn.rs b/tests/ui/parser/const-block-items/mod-in-fn.rs deleted file mode 100644 index ec98f95a8448..000000000000 --- a/tests/ui/parser/const-block-items/mod-in-fn.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ check-pass - -#![feature(const_block_items)] - -fn main() { - mod foo { - const { assert!(true) } - } -} diff --git a/tests/ui/parser/const-block-items/pub.rs b/tests/ui/parser/const-block-items/pub.rs deleted file mode 100644 index b76d30d9bda1..000000000000 --- a/tests/ui/parser/const-block-items/pub.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(const_block_items)] - -//@ check-pass - -// FIXME(const_block_items): `pub`` is useless here -pub const { - assert!(true); -} - -fn main() { } diff --git a/tests/ui/parser/const-block-items/unsafe.rs b/tests/ui/parser/const-block-items/unsafe.rs deleted file mode 100644 index f53dfab7a0a2..000000000000 --- a/tests/ui/parser/const-block-items/unsafe.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(const_block_items)] - -const unsafe fn foo() -> bool { - true -} - -const unsafe { assert!(foo()) } -//~^ ERROR: expected one of `extern` or `fn`, found `{` - -fn main() { } diff --git a/tests/ui/parser/const-block-items/unsafe.stderr b/tests/ui/parser/const-block-items/unsafe.stderr deleted file mode 100644 index 0d38af838b3e..000000000000 --- a/tests/ui/parser/const-block-items/unsafe.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected one of `extern` or `fn`, found `{` - --> $DIR/unsafe.rs:7:14 - | -LL | const unsafe { assert!(foo()) } - | ^ expected one of `extern` or `fn` - -error: aborting due to 1 previous error - diff --git a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.rs b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.rs index 764c1c2a3210..3876fb41d23f 100644 --- a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.rs +++ b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.rs @@ -11,5 +11,5 @@ fn banana(a: >::BAR) {} fn chaenomeles() { path::path::Struct::() //~^ ERROR unexpected `const` parameter declaration - //~| ERROR cannot find module or crate `path` + //~| ERROR failed to resolve: use of unresolved module or unlinked crate `path` } diff --git a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr index 7aba69a0cf5a..db7c76dc1aa9 100644 --- a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr +++ b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr @@ -22,7 +22,7 @@ error: unexpected `const` parameter declaration LL | path::path::Struct::() | ^^^^^^^^^^^^^^ expected a `const` expression, not a parameter declaration -error[E0433]: cannot find module or crate `path` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `path` --> $DIR/const-param-decl-on-type-instead-of-impl.rs:12:5 | LL | path::path::Struct::() diff --git a/tests/ui/parser/diff-markers/long-conflict-markers.rs b/tests/ui/parser/diff-markers/long-conflict-markers.rs deleted file mode 100644 index f92615fb75b4..000000000000 --- a/tests/ui/parser/diff-markers/long-conflict-markers.rs +++ /dev/null @@ -1,11 +0,0 @@ -enum E { - Foo { -<<<<<<<<< HEAD //~ ERROR encountered diff marker - x: u8, -||||||| - z: (), -========= - y: i8, ->>>>>>>>> branch - } -} diff --git a/tests/ui/parser/diff-markers/long-conflict-markers.stderr b/tests/ui/parser/diff-markers/long-conflict-markers.stderr deleted file mode 100644 index c83aaf16b741..000000000000 --- a/tests/ui/parser/diff-markers/long-conflict-markers.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: encountered diff marker - --> $DIR/long-conflict-markers.rs:3:1 - | -LL | <<<<<<<<< HEAD - | ^^^^^^^^^ between this marker and `=======` is the code that you are merging into -... -LL | ========= - | --------- between this marker and `>>>>>>>` is the incoming code -LL | y: i8, -LL | >>>>>>>>> branch - | ^^^^^^^^^ this marker concludes the conflict region - | - = note: conflict markers indicate that a merge was started but could not be completed due to merge conflicts - to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers - = help: if you are in a merge, the top section is the code you already had checked out and the bottom section is the new code - if you are in a rebase, the top section is the code being rebased onto and the bottom section is the code you had checked out which is being rebased - = note: for an explanation on these markers from the `git` documentation, visit - -error: aborting due to 1 previous error - diff --git a/tests/ui/parser/duplicate-visibility.rs b/tests/ui/parser/duplicate-visibility.rs index d35624981c74..f0ee60873da0 100644 --- a/tests/ui/parser/duplicate-visibility.rs +++ b/tests/ui/parser/duplicate-visibility.rs @@ -2,8 +2,8 @@ fn main() {} extern "C" { //~ NOTE while parsing this item list starting here pub pub fn foo(); - //~^ ERROR expected one of `(`, `async`, `const`, `default`, `extern`, `final`, `fn`, `safe`, `unsafe`, or `use`, found keyword `pub` - //~| NOTE expected one of 10 possible tokens + //~^ ERROR expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `safe`, `unsafe`, or `use`, found keyword `pub` + //~| NOTE expected one of 9 possible tokens //~| HELP there is already a visibility modifier, remove one //~| NOTE explicit visibility first seen here } //~ NOTE the item list ends here diff --git a/tests/ui/parser/duplicate-visibility.stderr b/tests/ui/parser/duplicate-visibility.stderr index e00ebe6a8cf6..0d1421ee7f4e 100644 --- a/tests/ui/parser/duplicate-visibility.stderr +++ b/tests/ui/parser/duplicate-visibility.stderr @@ -1,4 +1,4 @@ -error: expected one of `(`, `async`, `const`, `default`, `extern`, `final`, `fn`, `safe`, `unsafe`, or `use`, found keyword `pub` +error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `safe`, `unsafe`, or `use`, found keyword `pub` --> $DIR/duplicate-visibility.rs:4:9 | LL | extern "C" { @@ -6,7 +6,7 @@ LL | extern "C" { LL | pub pub fn foo(); | ^^^ | | - | expected one of 10 possible tokens + | expected one of 9 possible tokens | help: there is already a visibility modifier, remove one ... LL | } diff --git a/tests/ui/parser/dyn-trait-compatibility.rs b/tests/ui/parser/dyn-trait-compatibility.rs index dd01b6e19d05..c6e84284fbec 100644 --- a/tests/ui/parser/dyn-trait-compatibility.rs +++ b/tests/ui/parser/dyn-trait-compatibility.rs @@ -3,7 +3,7 @@ type A0 = dyn; //~^ ERROR cannot find type `dyn` in this scope type A1 = dyn::dyn; -//~^ ERROR cannot find module or crate `dyn` in this scope +//~^ ERROR use of unresolved module or unlinked crate `dyn` type A2 = dyn; //~^ ERROR cannot find type `dyn` in this scope //~| ERROR cannot find type `dyn` in this scope diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 233b22123d31..d15bf3c97f65 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -40,7 +40,7 @@ error[E0425]: cannot find type `dyn` in this scope LL | type A3 = dyn<::dyn>; | ^^^ not found in this scope -error[E0433]: cannot find module or crate `dyn` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `dyn` --> $DIR/dyn-trait-compatibility.rs:5:11 | LL | type A1 = dyn::dyn; diff --git a/tests/ui/parser/issue-12187-1.stderr b/tests/ui/parser/issue-12187-1.stderr index ee5d1c0b2f16..704854fe5858 100644 --- a/tests/ui/parser/issue-12187-1.stderr +++ b/tests/ui/parser/issue-12187-1.stderr @@ -6,7 +6,7 @@ LL | let &v = new(); | help: consider giving this pattern a type, where the type for type parameter `T` is specified | -LL | let &v: &_ = new(); +LL | let &v: &T = new(); | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/parser/issue-12187-2.stderr b/tests/ui/parser/issue-12187-2.stderr index 67d18cf137be..eeef63a1d0bd 100644 --- a/tests/ui/parser/issue-12187-2.stderr +++ b/tests/ui/parser/issue-12187-2.stderr @@ -6,7 +6,7 @@ LL | let &v = new(); | help: consider giving this pattern a type, where the type for type parameter `T` is specified | -LL | let &v: &_ = new(); +LL | let &v: &T = new(); | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/parser/macro-rules-paren-name-issue-150899.rs b/tests/ui/parser/macro-rules-paren-name-issue-150899.rs deleted file mode 100644 index 174a6e7e7de8..000000000000 --- a/tests/ui/parser/macro-rules-paren-name-issue-150899.rs +++ /dev/null @@ -1,7 +0,0 @@ -macro_rules!(i_think_the_name_should_go_here) { - //~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon - //~| ERROR expected item, found `{` - () => {} -} - -fn main() {} diff --git a/tests/ui/parser/macro-rules-paren-name-issue-150899.stderr b/tests/ui/parser/macro-rules-paren-name-issue-150899.stderr deleted file mode 100644 index f5b6ff40f27e..000000000000 --- a/tests/ui/parser/macro-rules-paren-name-issue-150899.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: macros that expand to items must be delimited with braces or followed by a semicolon - --> $DIR/macro-rules-paren-name-issue-150899.rs:1:13 - | -LL | macro_rules!(i_think_the_name_should_go_here) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: to define a macro, remove the parentheses around the macro name - | -LL - macro_rules!(i_think_the_name_should_go_here) { -LL + macro_rules! i_think_the_name_should_go_here { - | - -error: expected item, found `{` - --> $DIR/macro-rules-paren-name-issue-150899.rs:1:47 - | -LL | macro_rules!(i_think_the_name_should_go_here) { - | ^ expected item - | - = note: for a full list of items that can appear in modules, see - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/missing-closing-generics-bracket.fixed b/tests/ui/parser/missing-closing-generics-bracket.fixed deleted file mode 100644 index 3166887fa8c3..000000000000 --- a/tests/ui/parser/missing-closing-generics-bracket.fixed +++ /dev/null @@ -1,10 +0,0 @@ -// Issue #141436 -//@ run-rustfix -#![allow(dead_code)] - -trait Trait<'a> {} - -fn foo>() {} -//~^ ERROR expected one of - -fn main() {} diff --git a/tests/ui/parser/missing-closing-generics-bracket.rs b/tests/ui/parser/missing-closing-generics-bracket.rs deleted file mode 100644 index 9424e3467246..000000000000 --- a/tests/ui/parser/missing-closing-generics-bracket.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Issue #141436 -//@ run-rustfix -#![allow(dead_code)] - -trait Trait<'a> {} - -fn foo() {} -//~^ ERROR expected one of - -fn main() {} diff --git a/tests/ui/parser/missing-closing-generics-bracket.stderr b/tests/ui/parser/missing-closing-generics-bracket.stderr deleted file mode 100644 index c4287301c595..000000000000 --- a/tests/ui/parser/missing-closing-generics-bracket.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: expected one of `+`, `,`, `::`, `=`, or `>`, found `(` - --> $DIR/missing-closing-generics-bracket.rs:7:25 - | -LL | fn foo() {} - | ^ expected one of `+`, `,`, `::`, `=`, or `>` - | -help: you might have meant to end the type parameters here - | -LL | fn foo>() {} - | + - -error: aborting due to 1 previous error - diff --git a/tests/ui/parser/misspelled-keywords/pub-fn.stderr b/tests/ui/parser/misspelled-keywords/pub-fn.stderr index 9b895f32c91e..1123c652c0ee 100644 --- a/tests/ui/parser/misspelled-keywords/pub-fn.stderr +++ b/tests/ui/parser/misspelled-keywords/pub-fn.stderr @@ -1,8 +1,8 @@ -error: expected one of `#`, `async`, `auto`, `const`, `default`, `enum`, `extern`, `final`, `fn`, `gen`, `impl`, `macro_rules`, `macro`, `mod`, `pub`, `safe`, `static`, `struct`, `trait`, `type`, `unsafe`, or `use`, found `puB` +error: expected one of `#`, `async`, `auto`, `const`, `default`, `enum`, `extern`, `fn`, `gen`, `impl`, `macro_rules`, `macro`, `mod`, `pub`, `safe`, `static`, `struct`, `trait`, `type`, `unsafe`, or `use`, found `puB` --> $DIR/pub-fn.rs:1:1 | LL | puB fn code() {} - | ^^^ expected one of 22 possible tokens + | ^^^ expected one of 21 possible tokens | help: write keyword `pub` in lowercase | diff --git a/tests/ui/parser/mod_file_not_exist.rs b/tests/ui/parser/mod_file_not_exist.rs index ba89a8c2c1fb..49ce44982ab9 100644 --- a/tests/ui/parser/mod_file_not_exist.rs +++ b/tests/ui/parser/mod_file_not_exist.rs @@ -1,9 +1,8 @@ -mod not_a_real_file; -//~^ ERROR: file not found for module `not_a_real_file` -//~| HELP: to create the module `not_a_real_file`, create file +mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` +//~^ HELP to create the module `not_a_real_file`, create file fn main() { assert_eq!(mod_file_aux::bar(), 10); - //~^ ERROR: cannot find module or crate `mod_file_aux` - //~| HELP: you might be missing a crate named `mod_file_aux` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `mod_file_aux` + //~| HELP you might be missing a crate named `mod_file_aux` } diff --git a/tests/ui/parser/mod_file_not_exist.stderr b/tests/ui/parser/mod_file_not_exist.stderr index 83fff7161cae..d9e4e8f31f5f 100644 --- a/tests/ui/parser/mod_file_not_exist.stderr +++ b/tests/ui/parser/mod_file_not_exist.stderr @@ -7,8 +7,8 @@ LL | mod not_a_real_file; = help: to create the module `not_a_real_file`, create file "$DIR/not_a_real_file.rs" or "$DIR/not_a_real_file/mod.rs" = note: if there is a `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::...` instead -error[E0433]: cannot find module or crate `mod_file_aux` in this scope - --> $DIR/mod_file_not_exist.rs:6:16 +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `mod_file_aux` + --> $DIR/mod_file_not_exist.rs:5:16 | LL | assert_eq!(mod_file_aux::bar(), 10); | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `mod_file_aux` diff --git a/tests/ui/parser/mod_file_not_exist_windows.rs b/tests/ui/parser/mod_file_not_exist_windows.rs index b0b65ae8c759..bb74684d9944 100644 --- a/tests/ui/parser/mod_file_not_exist_windows.rs +++ b/tests/ui/parser/mod_file_not_exist_windows.rs @@ -5,6 +5,6 @@ mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` fn main() { assert_eq!(mod_file_aux::bar(), 10); - //~^ ERROR cannot find module or crate `mod_file_aux` in this scope + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `mod_file_aux` //~| HELP you might be missing a crate named `mod_file_aux` } diff --git a/tests/ui/parser/mod_file_not_exist_windows.stderr b/tests/ui/parser/mod_file_not_exist_windows.stderr index 95c6c1c92e64..03c762d0ef2d 100644 --- a/tests/ui/parser/mod_file_not_exist_windows.stderr +++ b/tests/ui/parser/mod_file_not_exist_windows.stderr @@ -7,7 +7,7 @@ LL | mod not_a_real_file; = help: to create the module `not_a_real_file`, create file "$DIR/not_a_real_file.rs" or "$DIR/not_a_real_file/mod.rs" = note: if there is a `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::...` instead -error[E0433]: cannot find module or crate `mod_file_aux` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `mod_file_aux` --> $DIR/mod_file_not_exist_windows.rs:7:16 | LL | assert_eq!(mod_file_aux::bar(), 10); diff --git a/tests/ui/parser/struct-lit-placeholder-or-empty-path.rs b/tests/ui/parser/struct-lit-placeholder-or-empty-path.rs deleted file mode 100644 index 8f91eb68b2eb..000000000000 --- a/tests/ui/parser/struct-lit-placeholder-or-empty-path.rs +++ /dev/null @@ -1,14 +0,0 @@ -fn main() { - let _ = {foo: (), bar: {} }; //~ ERROR struct literal body without path - //~| NOTE struct name missing for struct literal - //~| HELP add the correct type - let _ = _ {foo: (), bar: {} }; //~ ERROR placeholder `_` is not allowed for the path in struct literals - //~| NOTE not allowed in struct literals - //~| HELP replace it with the correct type - let _ = {foo: ()}; //~ ERROR struct literal body without path - //~| NOTE struct name missing for struct literal - //~| HELP add the correct type - let _ = _ {foo: ()}; //~ ERROR placeholder `_` is not allowed for the path in struct literals - //~| NOTE not allowed in struct literals - //~| HELP replace it with the correct type -} diff --git a/tests/ui/parser/struct-lit-placeholder-or-empty-path.stderr b/tests/ui/parser/struct-lit-placeholder-or-empty-path.stderr deleted file mode 100644 index 62a417aefc1e..000000000000 --- a/tests/ui/parser/struct-lit-placeholder-or-empty-path.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error: struct literal body without path - --> $DIR/struct-lit-placeholder-or-empty-path.rs:2:13 - | -LL | let _ = {foo: (), bar: {} }; - | ^^^^^^^^^^^^^^^^^^^ struct name missing for struct literal - | -help: add the correct type - | -LL | let _ = /* Type */ {foo: (), bar: {} }; - | ++++++++++ - -error: placeholder `_` is not allowed for the path in struct literals - --> $DIR/struct-lit-placeholder-or-empty-path.rs:5:13 - | -LL | let _ = _ {foo: (), bar: {} }; - | ^ not allowed in struct literals - | -help: replace it with the correct type - | -LL - let _ = _ {foo: (), bar: {} }; -LL + let _ = /* Type */ {foo: (), bar: {} }; - | - -error: struct literal body without path - --> $DIR/struct-lit-placeholder-or-empty-path.rs:8:13 - | -LL | let _ = {foo: ()}; - | ^^^^^^^^^ struct name missing for struct literal - | -help: add the correct type - | -LL | let _ = /* Type */ {foo: ()}; - | ++++++++++ - -error: placeholder `_` is not allowed for the path in struct literals - --> $DIR/struct-lit-placeholder-or-empty-path.rs:11:13 - | -LL | let _ = _ {foo: ()}; - | ^ not allowed in struct literals - | -help: replace it with the correct type - | -LL - let _ = _ {foo: ()}; -LL + let _ = /* Type */ {foo: ()}; - | - -error: aborting due to 4 previous errors - diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs index 4e038875d78f..6f61425a8bd6 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -31,18 +31,18 @@ extern "C" fn f3_3(_: ..., x: isize) {} //~^ ERROR `...` must be the last argument of a C-variadic function const unsafe extern "C" fn f4_1(x: isize, _: ...) {} -//~^ ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time -//~| ERROR c-variadic const function definitions are unstable +//~^ ERROR functions cannot be both `const` and C-variadic +//~| ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time const extern "C" fn f4_2(x: isize, _: ...) {} -//~^ ERROR functions with a C variable argument list must be unsafe +//~^ ERROR functions cannot be both `const` and C-variadic +//~| ERROR functions with a C variable argument list must be unsafe //~| ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time -//~| ERROR c-variadic const function definitions are unstable const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} -//~^ ERROR functions with a C variable argument list must be unsafe +//~^ ERROR functions cannot be both `const` and C-variadic +//~| ERROR functions with a C variable argument list must be unsafe //~| ERROR `...` must be the last argument of a C-variadic function -//~| ERROR c-variadic const function definitions are unstable extern "C" { fn e_f2(..., x: isize); @@ -64,8 +64,8 @@ impl X { //~| ERROR `...` must be the last argument of a C-variadic function const fn i_f5(x: isize, _: ...) {} //~^ ERROR `...` is not supported for non-extern functions + //~| ERROR functions cannot be both `const` and C-variadic //~| ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time - //~| ERROR c-variadic const function definitions are unstable } trait T { diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr index ea9f9baa58ba..318015737fa1 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -80,25 +80,17 @@ error: `...` must be the last argument of a C-variadic function LL | extern "C" fn f3_3(_: ..., x: isize) {} | ^^^^^^ -error[E0658]: c-variadic const function definitions are unstable +error: functions cannot be both `const` and C-variadic --> $DIR/variadic-ffi-semantic-restrictions.rs:33:1 | LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #151787 for more information - = help: add `#![feature(const_c_variadic)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + | ^^^^^ `const` because of this ^^^^^^ C-variadic because of this -error[E0658]: c-variadic const function definitions are unstable +error: functions cannot be both `const` and C-variadic --> $DIR/variadic-ffi-semantic-restrictions.rs:37:1 | LL | const extern "C" fn f4_2(x: isize, _: ...) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #151787 for more information - = help: add `#![feature(const_c_variadic)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + | ^^^^^ `const` because of this ^^^^^^ C-variadic because of this error: functions with a C variable argument list must be unsafe --> $DIR/variadic-ffi-semantic-restrictions.rs:37:36 @@ -117,15 +109,11 @@ error: `...` must be the last argument of a C-variadic function LL | const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} | ^^^^^^ -error[E0658]: c-variadic const function definitions are unstable +error: functions cannot be both `const` and C-variadic --> $DIR/variadic-ffi-semantic-restrictions.rs:42:1 | LL | const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #151787 for more information - = help: add `#![feature(const_c_variadic)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + | ^^^^^ `const` because of this ^^^^^^ C-variadic because of this error: functions with a C variable argument list must be unsafe --> $DIR/variadic-ffi-semantic-restrictions.rs:42:44 @@ -188,15 +176,13 @@ LL | fn i_f4(_: ..., x: isize, _: ...) {} | = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list -error[E0658]: c-variadic const function definitions are unstable +error: functions cannot be both `const` and C-variadic --> $DIR/variadic-ffi-semantic-restrictions.rs:65:5 | LL | const fn i_f5(x: isize, _: ...) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #151787 for more information - = help: add `#![feature(const_c_variadic)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + | ^^^^^ ^^^^^^ C-variadic because of this + | | + | `const` because of this error: `...` is not supported for non-extern functions --> $DIR/variadic-ffi-semantic-restrictions.rs:65:29 @@ -257,10 +243,6 @@ LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} | ^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions - | - = note: see issue #133214 for more information - = help: add `#![feature(const_destruct)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time --> $DIR/variadic-ffi-semantic-restrictions.rs:37:36 @@ -269,10 +251,6 @@ LL | const extern "C" fn f4_2(x: isize, _: ...) {} | ^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions - | - = note: see issue #133214 for more information - = help: add `#![feature(const_destruct)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time --> $DIR/variadic-ffi-semantic-restrictions.rs:65:29 @@ -281,12 +259,7 @@ LL | const fn i_f5(x: isize, _: ...) {} | ^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions - | - = note: see issue #133214 for more information - = help: add `#![feature(const_destruct)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 33 previous errors -Some errors have detailed explanations: E0493, E0658. -For more information about an error, try `rustc --explain E0493`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/patchable-function-entry/patchable-function-entry-attribute.rs b/tests/ui/patchable-function-entry/patchable-function-entry-attribute.rs index 5cbeccf1b0e4..1e376c9ff3c1 100644 --- a/tests/ui/patchable-function-entry/patchable-function-entry-attribute.rs +++ b/tests/ui/patchable-function-entry/patchable-function-entry-attribute.rs @@ -1,26 +1,17 @@ #![feature(patchable_function_entry)] fn main() {} -#[patchable_function_entry(prefix_nops = 256, entry_nops = 0)] -//~^ ERROR malformed +#[patchable_function_entry(prefix_nops = 256, entry_nops = 0)]//~error: integer value out of range pub fn too_high_pnops() {} -#[patchable_function_entry(prefix_nops = "stringvalue", entry_nops = 0)] -//~^ ERROR malformed +#[patchable_function_entry(prefix_nops = "stringvalue", entry_nops = 0)]//~error: invalid literal value pub fn non_int_nop() {} -#[patchable_function_entry] -//~^ ERROR malformed `patchable_function_entry` attribute input +#[patchable_function_entry]//~error: malformed `patchable_function_entry` attribute input pub fn malformed_attribute() {} -#[patchable_function_entry(prefix_nops = 10, something = 0)] -//~^ ERROR malformed +#[patchable_function_entry(prefix_nops = 10, something = 0)]//~error: unexpected parameter name pub fn unexpected_parameter_name() {} -#[patchable_function_entry()] -//~^ ERROR malformed +#[patchable_function_entry()]//~error: must specify at least one parameter pub fn no_parameters_given() {} - -#[patchable_function_entry(prefix_nops = 255, prefix_nops = 255)] -//~^ ERROR malformed -pub fn duplicate_parameter() {} diff --git a/tests/ui/patchable-function-entry/patchable-function-entry-attribute.stderr b/tests/ui/patchable-function-entry/patchable-function-entry-attribute.stderr index 43fc0c0518af..9357a86c4153 100644 --- a/tests/ui/patchable-function-entry/patchable-function-entry-attribute.stderr +++ b/tests/ui/patchable-function-entry/patchable-function-entry-attribute.stderr @@ -1,58 +1,32 @@ -error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/patchable-function-entry-attribute.rs:4:1 - | -LL | #[patchable_function_entry(prefix_nops = 256, entry_nops = 0)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^^^^^^^^^^^^^^^ - | | | - | | expected an integer literal in the range of 0..=255 - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` - -error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/patchable-function-entry-attribute.rs:8:1 - | -LL | #[patchable_function_entry(prefix_nops = "stringvalue", entry_nops = 0)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^^^^^^^^^^^^^^^^ - | | | - | | expected an integer literal here - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` - -error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/patchable-function-entry-attribute.rs:12:1 +error: malformed `patchable_function_entry` attribute input + --> $DIR/patchable-function-entry-attribute.rs:10:1 | LL | #[patchable_function_entry] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` -error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/patchable-function-entry-attribute.rs:16:1 +error: integer value out of range + --> $DIR/patchable-function-entry-attribute.rs:4:42 + | +LL | #[patchable_function_entry(prefix_nops = 256, entry_nops = 0)] + | ^^^ value must be between `0` and `255` + +error: invalid literal value + --> $DIR/patchable-function-entry-attribute.rs:7:42 + | +LL | #[patchable_function_entry(prefix_nops = "stringvalue", entry_nops = 0)] + | ^^^^^^^^^^^^^ value must be an integer between `0` and `255` + +error: unexpected parameter name + --> $DIR/patchable-function-entry-attribute.rs:13:46 | LL | #[patchable_function_entry(prefix_nops = 10, something = 0)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^^^^^ - | | | - | | valid arguments are `prefix_nops` or `entry_nops` - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` + | ^^^^^^^^^^^^^ expected `prefix_nops` or `entry_nops` -error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/patchable-function-entry-attribute.rs:20:1 +error: must specify at least one parameter + --> $DIR/patchable-function-entry-attribute.rs:16:1 | LL | #[patchable_function_entry()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^--^ - | | | - | | expected this to be a list - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0538]: malformed `patchable_function_entry` attribute input - --> $DIR/patchable-function-entry-attribute.rs:24:1 - | -LL | #[patchable_function_entry(prefix_nops = 255, prefix_nops = 255)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^ - | | | - | | found `prefix_nops` used as a key more than once - | help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` +error: aborting due to 5 previous errors -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0538, E0539. -For more information about an error, try `rustc --explain E0538`. diff --git a/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs index fbc742aa8477..fac8684ef094 100644 --- a/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs +++ b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs @@ -4,7 +4,7 @@ fn main() { let vec![const { vec![] }]: Vec = vec![]; //~^ ERROR expected a pattern, found a function call - //~| ERROR expected a pattern, found a function call + //~| ERROR usage of qualified paths in this context is experimental //~| ERROR expected tuple struct or tuple variant //~| ERROR arbitrary expressions aren't allowed in patterns } diff --git a/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr index 48728acbc291..43b0ad18a79b 100644 --- a/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr +++ b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr @@ -5,14 +5,18 @@ LL | let vec![const { vec![] }]: Vec = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant | = note: function calls are not allowed in patterns: + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0532]: expected a pattern, found a function call +error[E0658]: usage of qualified paths in this context is experimental --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:5:9 | LL | let vec![const { vec![] }]: Vec = vec![]; - | ^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant + | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: function calls are not allowed in patterns: + = note: see issue #86935 for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: arbitrary expressions aren't allowed in patterns --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:5:14 @@ -22,15 +26,16 @@ LL | let vec![const { vec![] }]: Vec = vec![]; | = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead -error[E0164]: expected tuple struct or tuple variant, found associated function `::alloc::boxed::Box::new_uninit` +error[E0164]: expected tuple struct or tuple variant, found associated function `<[_]>::into_vec` --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:5:9 | LL | let vec![const { vec![] }]: Vec = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns | = help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors -Some errors have detailed explanations: E0164, E0532. +Some errors have detailed explanations: E0164, E0532, E0658. For more information about an error, try `rustc --explain E0164`. diff --git a/tests/ui/pattern/pattern-error-continue.rs b/tests/ui/pattern/pattern-error-continue.rs index 56c3fa1dda7d..664d4e80ef56 100644 --- a/tests/ui/pattern/pattern-error-continue.rs +++ b/tests/ui/pattern/pattern-error-continue.rs @@ -32,6 +32,6 @@ fn main() { //~| NOTE expected `char`, found `bool` match () { - E::V => {} //~ ERROR cannot find type `E` + E::V => {} //~ ERROR failed to resolve: use of undeclared type `E` } } diff --git a/tests/ui/pattern/pattern-error-continue.stderr b/tests/ui/pattern/pattern-error-continue.stderr index 5068f2800617..de90d99a0ff1 100644 --- a/tests/ui/pattern/pattern-error-continue.stderr +++ b/tests/ui/pattern/pattern-error-continue.stderr @@ -52,7 +52,7 @@ note: function defined here LL | fn f(_c: char) {} | ^ -------- -error[E0433]: cannot find type `E` in this scope +error[E0433]: failed to resolve: use of undeclared type `E` --> $DIR/pattern-error-continue.rs:35:9 | LL | E::V => {} diff --git a/tests/ui/pin-ergonomics/impl-unpin.adt.stderr b/tests/ui/pin-ergonomics/impl-unpin.adt.stderr deleted file mode 100644 index 56fac42d4e32..000000000000 --- a/tests/ui/pin-ergonomics/impl-unpin.adt.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: explicit impls for the `Unpin` trait are not permitted for structurally pinned types - --> $DIR/impl-unpin.rs:14:5 - | -LL | impl Unpin for Foo {} - | ^^^^^^^^^^^^^^^^^^ impl of `Unpin` not allowed - | -help: `Foo` is structurally pinned because it is marked as `#[pin_v2]` - --> $DIR/impl-unpin.rs:7:1 - | -LL | struct Foo; - | ^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/pin-ergonomics/impl-unpin.assoc.stderr b/tests/ui/pin-ergonomics/impl-unpin.assoc.stderr deleted file mode 100644 index 7f0ee1ddd898..000000000000 --- a/tests/ui/pin-ergonomics/impl-unpin.assoc.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `::Assoc` - --> $DIR/impl-unpin.rs:68:5 - | -LL | impl Unpin for ::Assoc {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type - -error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `::Assoc` - --> $DIR/impl-unpin.rs:70:5 - | -LL | impl Unpin for ::Assoc {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0321`. diff --git a/tests/ui/pin-ergonomics/impl-unpin.rs b/tests/ui/pin-ergonomics/impl-unpin.rs deleted file mode 100644 index ded8b4774dd9..000000000000 --- a/tests/ui/pin-ergonomics/impl-unpin.rs +++ /dev/null @@ -1,74 +0,0 @@ -//@ revisions: adt tait ty_alias assoc -#![feature(pin_ergonomics)] -#![cfg_attr(tait, feature(type_alias_impl_trait))] -#![allow(incomplete_features)] - -#[pin_v2] -struct Foo; -struct Bar; - -#[cfg(adt)] -mod adt { - use super::*; - - impl Unpin for Foo {} - //[adt]~^ ERROR explicit impls for the `Unpin` trait are not permitted for structurally pinned types - impl Unpin for Bar {} // ok -} - -#[cfg(ty_alias)] -mod ty_alias { - use super::*; - - type Identity = T; - - impl Unpin for Identity {} - //[ty_alias]~^ ERROR explicit impls for the `Unpin` trait are not permitted for structurally pinned types - impl Unpin for Identity {} // ok -} - -#[cfg(tait)] -mod tait { - use super::*; - - trait Identity {} - - impl Identity for T {} - - type FooAlias = impl Identity; - type BarAlias = impl Identity; - - #[define_opaque(FooAlias)] - fn foo_alias() -> FooAlias { - Foo - } - #[define_opaque(BarAlias)] - fn bar_alias() -> BarAlias { - Bar - } - - impl Unpin for FooAlias {} - //[tait]~^ ERROR only traits defined in the current crate can be implemented for arbitrary types - impl Unpin for BarAlias {} - //[tait]~^ ERROR only traits defined in the current crate can be implemented for arbitrary types -} - -#[cfg(assoc)] -mod assoc { - use super::*; - - trait Identity { - type Assoc; - } - - impl Identity for T { - type Assoc = T; - } - - impl Unpin for ::Assoc {} - //[assoc]~^ ERROR cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `::Assoc` - impl Unpin for ::Assoc {} - //[assoc]~^ ERROR cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `::Assoc` -} - -fn main() {} diff --git a/tests/ui/pin-ergonomics/impl-unpin.tait.stderr b/tests/ui/pin-ergonomics/impl-unpin.tait.stderr deleted file mode 100644 index 5d9392745df3..000000000000 --- a/tests/ui/pin-ergonomics/impl-unpin.tait.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/impl-unpin.rs:50:5 - | -LL | impl Unpin for FooAlias {} - | ^^^^^^^^^^^^^^^-------- - | | - | type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate - | - = note: impl doesn't have any local type before any uncovered type parameters - = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/impl-unpin.rs:52:5 - | -LL | impl Unpin for BarAlias {} - | ^^^^^^^^^^^^^^^-------- - | | - | type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate - | - = note: impl doesn't have any local type before any uncovered type parameters - = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules - = note: define and implement a trait or new type instead - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/pin-ergonomics/impl-unpin.ty_alias.stderr b/tests/ui/pin-ergonomics/impl-unpin.ty_alias.stderr deleted file mode 100644 index 82c1a7d29ddf..000000000000 --- a/tests/ui/pin-ergonomics/impl-unpin.ty_alias.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: explicit impls for the `Unpin` trait are not permitted for structurally pinned types - --> $DIR/impl-unpin.rs:25:5 - | -LL | impl Unpin for Identity {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `Unpin` not allowed - | -help: `Foo` is structurally pinned because it is marked as `#[pin_v2]` - --> $DIR/impl-unpin.rs:7:1 - | -LL | struct Foo; - | ^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/pin-ergonomics/pin_v2-attr.stderr b/tests/ui/pin-ergonomics/pin_v2-attr.stderr index 8f8a9f3b3a19..c297afa87a73 100644 --- a/tests/ui/pin-ergonomics/pin_v2-attr.stderr +++ b/tests/ui/pin-ergonomics/pin_v2-attr.stderr @@ -4,7 +4,7 @@ error: `#[pin_v2]` attribute cannot be used on macro calls LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters --> $DIR/pin_v2-attr.rs:84:12 @@ -18,7 +18,7 @@ error: `#[pin_v2]` attribute cannot be used on crates LL | #![pin_v2] | ^^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on type parameters --> $DIR/pin_v2-attr.rs:27:10 @@ -26,7 +26,7 @@ error: `#[pin_v2]` attribute cannot be used on type parameters LL | enum Foo<#[pin_v2] T, #[pin_v2] U = ()> { | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on type parameters --> $DIR/pin_v2-attr.rs:27:23 @@ -34,7 +34,7 @@ error: `#[pin_v2]` attribute cannot be used on type parameters LL | enum Foo<#[pin_v2] T, #[pin_v2] U = ()> { | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on enum variants --> $DIR/pin_v2-attr.rs:30:5 @@ -42,7 +42,7 @@ error: `#[pin_v2]` attribute cannot be used on enum variants LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on struct fields --> $DIR/pin_v2-attr.rs:32:18 @@ -50,7 +50,7 @@ error: `#[pin_v2]` attribute cannot be used on struct fields LL | TupleVariant(#[pin_v2] T), | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on struct fields --> $DIR/pin_v2-attr.rs:34:9 @@ -58,7 +58,7 @@ error: `#[pin_v2]` attribute cannot be used on struct fields LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on traits --> $DIR/pin_v2-attr.rs:39:1 @@ -66,7 +66,7 @@ error: `#[pin_v2]` attribute cannot be used on traits LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on associated consts --> $DIR/pin_v2-attr.rs:41:5 @@ -74,7 +74,7 @@ error: `#[pin_v2]` attribute cannot be used on associated consts LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on associated types --> $DIR/pin_v2-attr.rs:43:5 @@ -82,7 +82,7 @@ error: `#[pin_v2]` attribute cannot be used on associated types LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on required trait methods --> $DIR/pin_v2-attr.rs:46:5 @@ -90,7 +90,7 @@ error: `#[pin_v2]` attribute cannot be used on required trait methods LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on provided trait methods --> $DIR/pin_v2-attr.rs:48:5 @@ -98,7 +98,7 @@ error: `#[pin_v2]` attribute cannot be used on provided trait methods LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on trait aliases --> $DIR/pin_v2-attr.rs:52:1 @@ -106,7 +106,7 @@ error: `#[pin_v2]` attribute cannot be used on trait aliases LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on inherent impl blocks --> $DIR/pin_v2-attr.rs:55:1 @@ -114,7 +114,7 @@ error: `#[pin_v2]` attribute cannot be used on inherent impl blocks LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on delegations --> $DIR/pin_v2-attr.rs:58:5 @@ -122,7 +122,7 @@ error: `#[pin_v2]` attribute cannot be used on delegations LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on inherent methods --> $DIR/pin_v2-attr.rs:61:5 @@ -130,7 +130,7 @@ error: `#[pin_v2]` attribute cannot be used on inherent methods LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on trait impl blocks --> $DIR/pin_v2-attr.rs:65:1 @@ -138,7 +138,7 @@ error: `#[pin_v2]` attribute cannot be used on trait impl blocks LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on trait methods in impl blocks --> $DIR/pin_v2-attr.rs:67:5 @@ -146,7 +146,7 @@ error: `#[pin_v2]` attribute cannot be used on trait methods in impl blocks LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on extern crates --> $DIR/pin_v2-attr.rs:71:1 @@ -154,7 +154,7 @@ error: `#[pin_v2]` attribute cannot be used on extern crates LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on use statements --> $DIR/pin_v2-attr.rs:74:1 @@ -162,7 +162,7 @@ error: `#[pin_v2]` attribute cannot be used on use statements LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on statics --> $DIR/pin_v2-attr.rs:77:1 @@ -170,7 +170,7 @@ error: `#[pin_v2]` attribute cannot be used on statics LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on constants --> $DIR/pin_v2-attr.rs:80:1 @@ -178,7 +178,7 @@ error: `#[pin_v2]` attribute cannot be used on constants LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on functions --> $DIR/pin_v2-attr.rs:83:1 @@ -186,7 +186,7 @@ error: `#[pin_v2]` attribute cannot be used on functions LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on function params --> $DIR/pin_v2-attr.rs:84:12 @@ -194,7 +194,7 @@ error: `#[pin_v2]` attribute cannot be used on function params LL | fn f(#[pin_v2] param: Foo) | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on closures --> $DIR/pin_v2-attr.rs:92:5 @@ -202,7 +202,7 @@ error: `#[pin_v2]` attribute cannot be used on closures LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on expressions --> $DIR/pin_v2-attr.rs:94:5 @@ -210,7 +210,7 @@ error: `#[pin_v2]` attribute cannot be used on expressions LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on struct fields --> $DIR/pin_v2-attr.rs:98:9 @@ -218,7 +218,7 @@ error: `#[pin_v2]` attribute cannot be used on struct fields LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on statements --> $DIR/pin_v2-attr.rs:96:5 @@ -226,7 +226,7 @@ error: `#[pin_v2]` attribute cannot be used on statements LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on match arms --> $DIR/pin_v2-attr.rs:102:9 @@ -234,7 +234,7 @@ error: `#[pin_v2]` attribute cannot be used on match arms LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on pattern fields --> $DIR/pin_v2-attr.rs:106:13 @@ -242,7 +242,7 @@ error: `#[pin_v2]` attribute cannot be used on pattern fields LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on where predicates --> $DIR/pin_v2-attr.rs:88:5 @@ -250,7 +250,7 @@ error: `#[pin_v2]` attribute cannot be used on where predicates LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on modules --> $DIR/pin_v2-attr.rs:112:1 @@ -258,7 +258,7 @@ error: `#[pin_v2]` attribute cannot be used on modules LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on foreign modules --> $DIR/pin_v2-attr.rs:115:1 @@ -266,7 +266,7 @@ error: `#[pin_v2]` attribute cannot be used on foreign modules LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on foreign types --> $DIR/pin_v2-attr.rs:117:5 @@ -274,7 +274,7 @@ error: `#[pin_v2]` attribute cannot be used on foreign types LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on foreign statics --> $DIR/pin_v2-attr.rs:120:5 @@ -282,7 +282,7 @@ error: `#[pin_v2]` attribute cannot be used on foreign statics LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on foreign functions --> $DIR/pin_v2-attr.rs:123:5 @@ -290,7 +290,7 @@ error: `#[pin_v2]` attribute cannot be used on foreign functions LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on type aliases --> $DIR/pin_v2-attr.rs:127:1 @@ -298,7 +298,7 @@ error: `#[pin_v2]` attribute cannot be used on type aliases LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: `#[pin_v2]` attribute cannot be used on macro defs --> $DIR/pin_v2-attr.rs:130:1 @@ -306,7 +306,7 @@ error: `#[pin_v2]` attribute cannot be used on macro defs LL | #[pin_v2] | ^^^^^^^^^ | - = help: `#[pin_v2]` can only be applied to data types + = help: `#[pin_v2]` can be applied to data types and unions error: aborting due to 39 previous errors diff --git a/tests/ui/pin-ergonomics/user-type-projection.rs b/tests/ui/pin-ergonomics/user-type-projection.rs deleted file mode 100644 index f482586b6ebc..000000000000 --- a/tests/ui/pin-ergonomics/user-type-projection.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![crate_type = "rlib"] -#![feature(pin_ergonomics)] -#![expect(incomplete_features)] -//@ edition: 2024 -//@ check-pass - -// Test that we don't ICE when projecting user-type-annotations through a `&pin` pattern. -// -// Historically, this could occur when the code handling those projections did not know -// about `&pin` patterns, and incorrectly treated them as plain `&`/`&mut` patterns instead. - -struct Data { - x: u32 -} - -pub fn project_user_type_through_pin() -> u32 { - let &pin const Data { x }: &pin const Data = &pin const Data { x: 30 }; - x -} diff --git a/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr b/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr index 347ec0a7743e..4ecc6370d3ca 100644 --- a/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr +++ b/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr @@ -10,6 +10,7 @@ LL | stuff(phantom_pinned) | -------------- borrow later used here | = note: consider using a `let` binding to create a longer lived value + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0716]: temporary value dropped while borrowed --> $DIR/lifetime_errors_on_promotion_misusage.rs:18:30 @@ -23,6 +24,7 @@ LL | }; | - temporary value is freed at the end of this statement | = note: consider using a `let` binding to create a longer lived value + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/print-request/print-calling-conventions.stdout b/tests/ui/print-request/print-calling-conventions.stdout index 8366697d0fb0..b8b939e1c04e 100644 --- a/tests/ui/print-request/print-calling-conventions.stdout +++ b/tests/ui/print-request/print-calling-conventions.stdout @@ -21,7 +21,6 @@ riscv-interrupt-s rust-call rust-cold rust-invalid -rust-preserve-none stdcall stdcall-unwind system diff --git a/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern-2.rs b/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern-2.rs deleted file mode 100644 index 38e3cdded5f2..000000000000 --- a/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern-2.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Doesn't involve `impl Trait` unlike missing-mir-priv-bounds-extern.rs - -pub trait ToPriv { - type AssocPriv; -} - -pub trait PubTr { - #[expect(private_bounds)] - type Assoc: ToPriv; -} - -// Dummy and DummyToPriv are only used in call_handler -struct Dummy; -struct DummyToPriv; -impl PubTr for Dummy { - type Assoc = DummyToPriv; -} -impl ToPriv for DummyToPriv { - type AssocPriv = Priv; -} - -pub trait PubTrHandler { - fn handle(); -} -pub fn call_handler() { - T::handle::(); -} - -struct Priv; - -pub trait GetUnreachable { - type Assoc; -} - -mod m { - pub struct Unreachable; - - impl Unreachable { - #[expect(dead_code)] - pub fn generic() {} - } - - impl crate::GetUnreachable for crate::Priv { - type Assoc = Unreachable; - } -} diff --git a/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern-3.rs b/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern-3.rs deleted file mode 100644 index 807abe2c4ad8..000000000000 --- a/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern-3.rs +++ /dev/null @@ -1,35 +0,0 @@ -struct Priv; - -pub trait Super { - type AssocSuper: GetUnreachable; -} -#[expect(private_bounds)] -pub trait Sub: Super {} - -// This Dummy type is only used in call_handler -struct Dummy; -impl Super for Dummy { - type AssocSuper = Priv; -} -impl Sub for Dummy {} - -pub trait SubHandler { - fn handle(); -} -pub fn call_handler() { - ::handle::(); -} - -pub trait GetUnreachable { - type Assoc; -} -mod m { - pub struct Unreachable; - impl Unreachable { - #[expect(dead_code)] - pub fn generic() {} - } - impl crate::GetUnreachable for crate::Priv { - type Assoc = Unreachable; - } -} diff --git a/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern.rs b/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern.rs deleted file mode 100644 index 4cb7bfcc6a3f..000000000000 --- a/tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern.rs +++ /dev/null @@ -1,40 +0,0 @@ -pub trait ToPriv { - type AssocPriv; -} - -pub trait PubTr { - #[expect(private_bounds)] - type Assoc: ToPriv; -} - -struct Dummy; -struct DummyToPriv; -impl PubTr for Dummy { - type Assoc = DummyToPriv; -} -impl ToPriv for DummyToPriv { - type AssocPriv = Priv; -} - -pub fn get_dummy() -> impl PubTr { - Dummy -} - -struct Priv; - -pub trait GetUnreachable { - type Assoc; -} - -mod m { - pub struct Unreachable; - - impl Unreachable { - #[expect(dead_code)] - pub fn generic() {} - } - - impl crate::GetUnreachable for crate::Priv { - type Assoc = Unreachable; - } -} diff --git a/tests/ui/privacy/issue-79593.rs b/tests/ui/privacy/issue-79593.rs index 663dd67fcdb1..39c222f7c341 100644 --- a/tests/ui/privacy/issue-79593.rs +++ b/tests/ui/privacy/issue-79593.rs @@ -10,7 +10,7 @@ mod foo { Pub {}; //~^ ERROR missing field `private` in initializer of `Pub` Enum::Variant { x: () }; - //~^ ERROR missing field `y` in initializer of `foo::Enum` + //~^ ERROR missing field `y` in initializer of `Enum` } } @@ -21,9 +21,9 @@ fn correct() { fn wrong() { foo::Enum::Variant { x: () }; - //~^ ERROR missing field `y` in initializer of `foo::Enum` + //~^ ERROR missing field `y` in initializer of `Enum` foo::Enum::Variant { }; - //~^ ERROR missing fields `x` and `y` in initializer of `foo::Enum` + //~^ ERROR missing fields `x` and `y` in initializer of `Enum` } fn main() {} diff --git a/tests/ui/privacy/issue-79593.stderr b/tests/ui/privacy/issue-79593.stderr index 74fea1a3ab76..5bb69836f609 100644 --- a/tests/ui/privacy/issue-79593.stderr +++ b/tests/ui/privacy/issue-79593.stderr @@ -4,7 +4,7 @@ error[E0063]: missing field `private` in initializer of `Pub` LL | Pub {}; | ^^^ missing `private` -error[E0063]: missing field `y` in initializer of `foo::Enum` +error[E0063]: missing field `y` in initializer of `Enum` --> $DIR/issue-79593.rs:12:9 | LL | Enum::Variant { x: () }; @@ -18,13 +18,13 @@ LL | foo::Pub {}; | = note: private field `private` that was not provided -error[E0063]: missing field `y` in initializer of `foo::Enum` +error[E0063]: missing field `y` in initializer of `Enum` --> $DIR/issue-79593.rs:23:5 | LL | foo::Enum::Variant { x: () }; | ^^^^^^^^^^^^^^^^^^ missing `y` -error[E0063]: missing fields `x` and `y` in initializer of `foo::Enum` +error[E0063]: missing fields `x` and `y` in initializer of `Enum` --> $DIR/issue-79593.rs:25:5 | LL | foo::Enum::Variant { }; diff --git a/tests/ui/privacy/missing-mir-priv-bounds-2.rs b/tests/ui/privacy/missing-mir-priv-bounds-2.rs deleted file mode 100644 index 7676fdb4af4b..000000000000 --- a/tests/ui/privacy/missing-mir-priv-bounds-2.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Test case from issue #151284. -// A private associated type bound allows to leak another private type and result in missing MIR. - -//@ build-fail -//@ aux-crate:dep=missing-mir-priv-bounds-extern-2.rs - -extern crate dep; -use dep::{GetUnreachable, PubTr, PubTrHandler, ToPriv, call_handler}; - -fn main() { - call_handler::(); -} - -struct Handler; -impl PubTrHandler for Handler { - fn handle() { - ::AccessAssoc::generic::(); - } -} - -trait Access: PubTr { - type AccessAssoc; -} - -impl Access for T { - type AccessAssoc = <::AssocPriv as GetUnreachable>::Assoc; -} - -//~? ERROR missing optimized MIR diff --git a/tests/ui/privacy/missing-mir-priv-bounds-2.stderr b/tests/ui/privacy/missing-mir-priv-bounds-2.stderr deleted file mode 100644 index 29a10eb1223b..000000000000 --- a/tests/ui/privacy/missing-mir-priv-bounds-2.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: missing optimized MIR for `dep::m::Unreachable::generic::` in the crate `missing_mir_priv_bounds_extern_2` - | -note: missing optimized MIR for this item (was the crate `missing_mir_priv_bounds_extern_2` compiled with `--emit=metadata`?) - --> $DIR/auxiliary/missing-mir-priv-bounds-extern-2.rs:40:9 - | -LL | pub fn generic() {} - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/privacy/missing-mir-priv-bounds-3.rs b/tests/ui/privacy/missing-mir-priv-bounds-3.rs deleted file mode 100644 index 1d277265451e..000000000000 --- a/tests/ui/privacy/missing-mir-priv-bounds-3.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Test case from issue #151479. -// A private associated type bound allows to leak another private type and result in missing MIR. - -//@ build-fail -//@ aux-crate:dep=missing-mir-priv-bounds-extern-3.rs - -extern crate dep; -use dep::{GetUnreachable, Sub, SubHandler, Super, call_handler}; - -fn main() { - call_handler::(); -} - -struct Handler; -impl SubHandler for Handler { - fn handle() { - ::AccessAssoc::generic::(); - } -} - -// Without this indirection, Handler::handle notices that -// it's mentioning dep::Priv. -trait Access: Super { - type AccessAssoc; -} -impl Access for T { - type AccessAssoc = <::AssocSuper as GetUnreachable>::Assoc; -} - -//~? ERROR missing optimized MIR diff --git a/tests/ui/privacy/missing-mir-priv-bounds-3.stderr b/tests/ui/privacy/missing-mir-priv-bounds-3.stderr deleted file mode 100644 index ef464de08cb9..000000000000 --- a/tests/ui/privacy/missing-mir-priv-bounds-3.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: missing optimized MIR for `dep::m::Unreachable::generic::` in the crate `missing_mir_priv_bounds_extern_3` - | -note: missing optimized MIR for this item (was the crate `missing_mir_priv_bounds_extern_3` compiled with `--emit=metadata`?) - --> $DIR/auxiliary/missing-mir-priv-bounds-extern-3.rs:30:9 - | -LL | pub fn generic() {} - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/privacy/missing-mir-priv-bounds.rs b/tests/ui/privacy/missing-mir-priv-bounds.rs deleted file mode 100644 index 07783a2ef858..000000000000 --- a/tests/ui/privacy/missing-mir-priv-bounds.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Test case from issue #151284. -// A private associated type bound allows to leak another private type and result in missing MIR. - -//@ build-fail -//@ aux-crate:dep=missing-mir-priv-bounds-extern.rs - -extern crate dep; -use dep::{GetUnreachable, PubTr, ToPriv, get_dummy}; - -fn main() { - wut(get_dummy()); -} - -fn wut(_: T) { - ::AccessAssoc::generic::(); -} - -trait Access: PubTr { - type AccessAssoc; -} - -impl Access for T { - type AccessAssoc = <::AssocPriv as GetUnreachable>::Assoc; -} - -//~? ERROR missing optimized MIR diff --git a/tests/ui/privacy/missing-mir-priv-bounds.stderr b/tests/ui/privacy/missing-mir-priv-bounds.stderr deleted file mode 100644 index 68eca33332cb..000000000000 --- a/tests/ui/privacy/missing-mir-priv-bounds.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: missing optimized MIR for `dep::m::Unreachable::generic::` in the crate `missing_mir_priv_bounds_extern` - | -note: missing optimized MIR for this item (was the crate `missing_mir_priv_bounds_extern` compiled with `--emit=metadata`?) - --> $DIR/auxiliary/missing-mir-priv-bounds-extern.rs:34:9 - | -LL | pub fn generic() {} - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/privacy/no-ice-on-inference-failure.stderr b/tests/ui/privacy/no-ice-on-inference-failure.stderr index 91b99c2890b8..67476e6e2189 100644 --- a/tests/ui/privacy/no-ice-on-inference-failure.stderr +++ b/tests/ui/privacy/no-ice-on-inference-failure.stderr @@ -8,7 +8,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint + If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated --> $DIR/no-ice-on-inference-failure.rs:2:22 | diff --git a/tests/ui/privacy/private-in-public-warn.rs b/tests/ui/privacy/private-in-public-warn.rs index 6a0ac2b9ade7..f79e4641312e 100644 --- a/tests/ui/privacy/private-in-public-warn.rs +++ b/tests/ui/privacy/private-in-public-warn.rs @@ -49,11 +49,7 @@ mod traits { fn f(arg: T) {} //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::f` fn g() -> impl PrivTr; - //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` - //~| ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` fn h() -> impl PrivTr {} - //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` - //~| ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` } impl Pub {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Pub` impl PubTr for Pub {} // OK, trait impl predicates @@ -93,15 +89,7 @@ mod generics { pub trait Tr5 { fn required() -> impl PrivTr>; - //~^ ERROR trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` - //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` - //~| ERROR trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` - //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` fn provided() -> impl PrivTr> {} - //~^ ERROR trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` - //~| ERROR trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` } } diff --git a/tests/ui/privacy/private-in-public-warn.stderr b/tests/ui/privacy/private-in-public-warn.stderr index 1fa415e27c16..edcffaf6b70a 100644 --- a/tests/ui/privacy/private-in-public-warn.stderr +++ b/tests/ui/privacy/private-in-public-warn.stderr @@ -194,56 +194,8 @@ note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` LL | trait PrivTr {} | ^^^^^^^^^^^^ -error: trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:51:19 - | -LL | fn g() -> impl PrivTr; - | ^^^^^^^^^^^ opaque type `traits::Tr3::g::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:37:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^ - -error: trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:51:19 - | -LL | fn g() -> impl PrivTr; - | ^^^^^^^^^^^ opaque type `traits::Tr3::g::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:37:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^ - -error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:54:19 - | -LL | fn h() -> impl PrivTr {} - | ^^^^^^^^^^^ opaque type `traits::Tr3::h::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:37:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^ - -error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:54:19 - | -LL | fn h() -> impl PrivTr {} - | ^^^^^^^^^^^ opaque type `traits::Tr3::h::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:37:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^ - error: trait `traits::PrivTr` is more private than the item `traits::Pub` - --> $DIR/private-in-public-warn.rs:58:5 + --> $DIR/private-in-public-warn.rs:54:5 | LL | impl Pub {} | ^^^^^^^^^^^^^^^^^^^^^^ implementation `traits::Pub` is reachable at visibility `pub(crate)` @@ -255,199 +207,103 @@ LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Alias` - --> $DIR/private-in-public-warn.rs:67:5 + --> $DIR/private-in-public-warn.rs:63:5 | LL | pub type Alias where T: PrivTr = T; | ^^^^^^^^^^^^^^^^^ type alias `traits_where::Alias` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:63:5 + --> $DIR/private-in-public-warn.rs:59:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Tr2` - --> $DIR/private-in-public-warn.rs:70:5 + --> $DIR/private-in-public-warn.rs:66:5 | LL | pub trait Tr2 where T: PrivTr {} | ^^^^^^^^^^^^^^^^ trait `traits_where::Tr2` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:63:5 + --> $DIR/private-in-public-warn.rs:59:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Tr3::f` - --> $DIR/private-in-public-warn.rs:73:9 + --> $DIR/private-in-public-warn.rs:69:9 | LL | fn f(arg: T) where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function `traits_where::Tr3::f` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:63:5 + --> $DIR/private-in-public-warn.rs:59:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Pub` - --> $DIR/private-in-public-warn.rs:76:5 + --> $DIR/private-in-public-warn.rs:72:5 | LL | impl Pub where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation `traits_where::Pub` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:63:5 + --> $DIR/private-in-public-warn.rs:59:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `generics::PrivTr` is more private than the item `generics::Tr1` - --> $DIR/private-in-public-warn.rs:88:5 + --> $DIR/private-in-public-warn.rs:84:5 | LL | pub trait Tr1: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr1` is reachable at visibility `pub(crate)` | note: but trait `generics::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 + --> $DIR/private-in-public-warn.rs:80:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^^^^ error: type `generics::Priv` is more private than the item `generics::Tr2` - --> $DIR/private-in-public-warn.rs:90:5 + --> $DIR/private-in-public-warn.rs:86:5 | LL | pub trait Tr2: PubTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr2` is reachable at visibility `pub(crate)` | note: but type `generics::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 + --> $DIR/private-in-public-warn.rs:78:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error: type `generics::Priv` is more private than the item `generics::Tr3` - --> $DIR/private-in-public-warn.rs:91:5 + --> $DIR/private-in-public-warn.rs:87:5 | LL | pub trait Tr3: PubTr<[Priv; 1]> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr3` is reachable at visibility `pub(crate)` | note: but type `generics::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 + --> $DIR/private-in-public-warn.rs:78:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error: type `generics::Priv` is more private than the item `Tr4` - --> $DIR/private-in-public-warn.rs:92:5 + --> $DIR/private-in-public-warn.rs:88:5 | LL | pub trait Tr4: PubTr> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `Tr4` is reachable at visibility `pub(crate)` | note: but type `generics::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 - | -LL | struct Priv(T); - | ^^^^^^^^^^^^^^^^^^^ - -error: trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:95:26 - | -LL | fn required() -> impl PrivTr>; - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `generics::PrivTr>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^^^^ - -error: type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:95:26 - | -LL | fn required() -> impl PrivTr>; - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 - | -LL | struct Priv(T); - | ^^^^^^^^^^^^^^^^^^^ - -error: trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:95:26 - | -LL | fn required() -> impl PrivTr>; - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `generics::PrivTr>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^^^^ - -error: type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:95:26 - | -LL | fn required() -> impl PrivTr>; - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 - | -LL | struct Priv(T); - | ^^^^^^^^^^^^^^^^^^^ - -error: trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:100:26 - | -LL | fn provided() -> impl PrivTr> {} - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `generics::PrivTr>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^^^^ - -error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:100:26 - | -LL | fn provided() -> impl PrivTr> {} - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 - | -LL | struct Priv(T); - | ^^^^^^^^^^^^^^^^^^^ - -error: trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:100:26 - | -LL | fn provided() -> impl PrivTr> {} - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `generics::PrivTr>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 - | -LL | trait PrivTr {} - | ^^^^^^^^^^^^^^^ - -error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:100:26 - | -LL | fn provided() -> impl PrivTr> {} - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 + --> $DIR/private-in-public-warn.rs:78:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error[E0446]: private type `impls::Priv` in public interface - --> $DIR/private-in-public-warn.rs:131:9 + --> $DIR/private-in-public-warn.rs:119:9 | LL | struct Priv; | ----------- `impls::Priv` declared as private @@ -456,19 +312,19 @@ LL | type Alias = Priv; | ^^^^^^^^^^ can't leak private type error: type `aliases_pub::Priv` is more private than the item `aliases_pub::::f` - --> $DIR/private-in-public-warn.rs:202:9 + --> $DIR/private-in-public-warn.rs:190:9 | LL | pub fn f(arg: Priv) {} | ^^^^^^^^^^^^^^^^^^^ associated function `aliases_pub::::f` is reachable at visibility `pub(crate)` | note: but type `aliases_pub::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:175:5 + --> $DIR/private-in-public-warn.rs:163:5 | LL | struct Priv; | ^^^^^^^^^^^ error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:205:9 + --> $DIR/private-in-public-warn.rs:193:9 | LL | struct Priv; | ----------- `aliases_pub::Priv` declared as private @@ -477,7 +333,7 @@ LL | type Check = Priv; | ^^^^^^^^^^ can't leak private type error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:208:9 + --> $DIR/private-in-public-warn.rs:196:9 | LL | struct Priv; | ----------- `aliases_pub::Priv` declared as private @@ -486,7 +342,7 @@ LL | type Check = Priv; | ^^^^^^^^^^ can't leak private type error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:211:9 + --> $DIR/private-in-public-warn.rs:199:9 | LL | struct Priv; | ----------- `aliases_pub::Priv` declared as private @@ -495,7 +351,7 @@ LL | type Check = Priv; | ^^^^^^^^^^ can't leak private type error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:214:9 + --> $DIR/private-in-public-warn.rs:202:9 | LL | struct Priv; | ----------- `aliases_pub::Priv` declared as private @@ -504,37 +360,37 @@ LL | type Check = Priv; | ^^^^^^^^^^ can't leak private type error: trait `PrivTr1` is more private than the item `aliases_priv::Tr1` - --> $DIR/private-in-public-warn.rs:244:5 + --> $DIR/private-in-public-warn.rs:232:5 | LL | pub trait Tr1: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr1` is reachable at visibility `pub(crate)` | note: but trait `PrivTr1` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:230:5 + --> $DIR/private-in-public-warn.rs:218:5 | LL | trait PrivTr1 { | ^^^^^^^^^^^^^^^^^^^^^ error: trait `PrivTr1` is more private than the item `aliases_priv::Tr2` - --> $DIR/private-in-public-warn.rs:246:5 + --> $DIR/private-in-public-warn.rs:234:5 | LL | pub trait Tr2: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr2` is reachable at visibility `pub(crate)` | note: but trait `PrivTr1` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:230:5 + --> $DIR/private-in-public-warn.rs:218:5 | LL | trait PrivTr1 { | ^^^^^^^^^^^^^^^^^^^^^ error: type `Priv2` is more private than the item `aliases_priv::Tr2` - --> $DIR/private-in-public-warn.rs:246:5 + --> $DIR/private-in-public-warn.rs:234:5 | LL | pub trait Tr2: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr2` is reachable at visibility `pub(crate)` | note: but type `Priv2` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:228:5 + --> $DIR/private-in-public-warn.rs:216:5 | LL | struct Priv2; | ^^^^^^^^^^^^ @@ -554,7 +410,7 @@ LL | pub type Alias = T; = note: `#[warn(type_alias_bounds)]` on by default warning: where clauses on type aliases are not enforced - --> $DIR/private-in-public-warn.rs:67:29 + --> $DIR/private-in-public-warn.rs:63:29 | LL | pub type Alias where T: PrivTr = T; | ------^^^^^^^^^ @@ -566,6 +422,6 @@ LL | pub type Alias where T: PrivTr = T; see issue #112792 for more information = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics -error: aborting due to 46 previous errors; 2 warnings emitted +error: aborting due to 34 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/privacy/private-inferred-type.rs b/tests/ui/privacy/private-inferred-type.rs index ed22ad44c449..8c07226fe0e4 100644 --- a/tests/ui/privacy/private-inferred-type.rs +++ b/tests/ui/privacy/private-inferred-type.rs @@ -115,11 +115,11 @@ fn main() { m::m!(); - m::leak_anon1(); //~ ERROR trait `m::Trait` is private + m::leak_anon1(); //~ ERROR trait `Trait` is private m::leak_anon2(); //~ ERROR type `Priv` is private m::leak_anon3(); //~ ERROR type `Priv` is private - m::leak_dyn1(); //~ ERROR trait `m::Trait` is private + m::leak_dyn1(); //~ ERROR trait `Trait` is private m::leak_dyn2(); //~ ERROR type `Priv` is private m::leak_dyn3(); //~ ERROR type `Priv` is private diff --git a/tests/ui/privacy/private-inferred-type.stderr b/tests/ui/privacy/private-inferred-type.stderr index 0dfa799a4d95..fc3f9ab62bfa 100644 --- a/tests/ui/privacy/private-inferred-type.stderr +++ b/tests/ui/privacy/private-inferred-type.stderr @@ -172,7 +172,7 @@ LL | m::m!(); | = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: trait `m::Trait` is private +error: trait `Trait` is private --> $DIR/private-inferred-type.rs:118:5 | LL | m::leak_anon1(); @@ -190,7 +190,7 @@ error: type `Priv` is private LL | m::leak_anon3(); | ^^^^^^^^^^^^^^^ private type -error: trait `m::Trait` is private +error: trait `Trait` is private --> $DIR/private-inferred-type.rs:122:5 | LL | m::leak_dyn1(); diff --git a/tests/ui/privacy/pub-priv-dep/auxiliary/pm.rs b/tests/ui/privacy/pub-priv-dep/auxiliary/pm.rs index d45f2639d182..9e2aa898afe8 100644 --- a/tests/ui/privacy/pub-priv-dep/auxiliary/pm.rs +++ b/tests/ui/privacy/pub-priv-dep/auxiliary/pm.rs @@ -1,3 +1,8 @@ +//@ force-host +//@ no-prefer-dynamic + +#![crate_type = "proc-macro"] + extern crate proc_macro; use proc_macro::TokenStream; diff --git a/tests/ui/privacy/pub-priv-dep/pub-priv1.rs b/tests/ui/privacy/pub-priv-dep/pub-priv1.rs index ba947de7f182..eae0f9756a10 100644 --- a/tests/ui/privacy/pub-priv-dep/pub-priv1.rs +++ b/tests/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -1,6 +1,6 @@ //@ aux-crate:priv:priv_dep=priv_dep.rs //@ aux-build:pub_dep.rs -//@ proc-macro:priv:pm.rs +//@ aux-crate:priv:pm=pm.rs //@ compile-flags: -Zunstable-options // Basic behavior check of exported_private_dependencies from either a public @@ -74,12 +74,8 @@ pub trait MyPubTrait { //~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface fn required_impl_trait() -> impl OtherTrait; - //~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface - //~| ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface fn provided_impl_trait() -> impl OtherTrait { OtherType } - //~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface - //~| ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface fn required_concrete() -> OtherType; //~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface diff --git a/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr b/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr index 609dbd77f9c1..e66db53f65dd 100644 --- a/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr +++ b/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -11,55 +11,55 @@ LL | #![deny(exported_private_dependencies)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: macro `m` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:160:9 + --> $DIR/pub-priv1.rs:156:9 | LL | pub use priv_dep::m; | ^^^^^^^^^^^ error: macro `fn_like` from private dependency 'pm' is re-exported - --> $DIR/pub-priv1.rs:162:9 + --> $DIR/pub-priv1.rs:158:9 | LL | pub use pm::fn_like; | ^^^^^^^^^^^ error: derive macro `PmDerive` from private dependency 'pm' is re-exported - --> $DIR/pub-priv1.rs:164:9 + --> $DIR/pub-priv1.rs:160:9 | LL | pub use pm::PmDerive; | ^^^^^^^^^^^^ error: attribute macro `pm_attr` from private dependency 'pm' is re-exported - --> $DIR/pub-priv1.rs:166:9 + --> $DIR/pub-priv1.rs:162:9 | LL | pub use pm::pm_attr; | ^^^^^^^^^^^ error: variant `V1` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:169:9 + --> $DIR/pub-priv1.rs:165:9 | LL | pub use priv_dep::E::V1; | ^^^^^^^^^^^^^^^ error: type alias `Unit` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:172:9 + --> $DIR/pub-priv1.rs:168:9 | LL | pub use priv_dep::Unit; | ^^^^^^^^^^^^^^ error: type alias `PubPub` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:174:9 + --> $DIR/pub-priv1.rs:170:9 | LL | pub use priv_dep::PubPub; | ^^^^^^^^^^^^^^^^ error: type alias `PubPriv` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:176:9 + --> $DIR/pub-priv1.rs:172:9 | LL | pub use priv_dep::PubPriv; | ^^^^^^^^^^^^^^^^^ error: struct `Renamed` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:178:9 + --> $DIR/pub-priv1.rs:174:9 | LL | pub use priv_dep::OtherType as Renamed; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,120 +124,92 @@ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface LL | type Foo: OtherTrait; | ^^^^^^^^^^^^^^^^^^^^ -error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:76:33 - | -LL | fn required_impl_trait() -> impl OtherTrait; - | ^^^^^^^^^^^^^^^ - -error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:76:33 - | -LL | fn required_impl_trait() -> impl OtherTrait; - | ^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:80:33 - | -LL | fn provided_impl_trait() -> impl OtherTrait { OtherType } - | ^^^^^^^^^^^^^^^ - -error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:80:33 - | -LL | fn provided_impl_trait() -> impl OtherTrait { OtherType } - | ^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:84:5 + --> $DIR/pub-priv1.rs:80:5 | LL | fn required_concrete() -> OtherType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:87:5 + --> $DIR/pub-priv1.rs:83:5 | LL | fn provided_concrete() -> OtherType { OtherType } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:91:1 + --> $DIR/pub-priv1.rs:87:1 | LL | pub trait WithSuperTrait: OtherTrait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:100:5 + --> $DIR/pub-priv1.rs:96:5 | LL | type X = OtherType; | ^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:104:1 + --> $DIR/pub-priv1.rs:100:1 | LL | pub fn in_bounds(x: T) { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:107:1 + --> $DIR/pub-priv1.rs:103:1 | LL | pub fn private_return_impl_trait() -> impl OtherTrait { OtherType } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:110:1 + --> $DIR/pub-priv1.rs:106:1 | LL | pub fn private_return() -> OtherType { OtherType } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:113:1 + --> $DIR/pub-priv1.rs:109:1 | LL | pub fn private_in_generic() -> std::num::Saturating { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:116:1 + --> $DIR/pub-priv1.rs:112:1 | LL | pub static STATIC: OtherType = OtherType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:119:1 + --> $DIR/pub-priv1.rs:115:1 | LL | pub const CONST: OtherType = OtherType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:122:1 + --> $DIR/pub-priv1.rs:118:1 | LL | pub type Alias = OtherType; | ^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:125:1 + --> $DIR/pub-priv1.rs:121:1 | LL | pub type AliasOfAlias = priv_dep::PubPub; | ^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:130:1 + --> $DIR/pub-priv1.rs:126:1 | LL | impl OtherTrait for PublicWithPrivateImpl {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:135:1 + --> $DIR/pub-priv1.rs:131:1 | LL | impl PubTraitOnPrivate for OtherType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:135:1 + --> $DIR/pub-priv1.rs:131:1 | LL | impl PubTraitOnPrivate for OtherType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -245,25 +217,25 @@ LL | impl PubTraitOnPrivate for OtherType {} = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:141:1 + --> $DIR/pub-priv1.rs:137:1 | LL | impl From for PublicWithStdImpl { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:143:5 + --> $DIR/pub-priv1.rs:139:5 | LL | fn from(val: OtherType) -> Self { Self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:147:1 + --> $DIR/pub-priv1.rs:143:1 | LL | impl From for OtherType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:147:1 + --> $DIR/pub-priv1.rs:143:1 | LL | impl From for OtherType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -271,18 +243,18 @@ LL | impl From for OtherType { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:150:5 + --> $DIR/pub-priv1.rs:146:5 | LL | fn from(val: PublicWithStdImpl) -> Self { Self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:150:5 + --> $DIR/pub-priv1.rs:146:5 | LL | fn from(val: PublicWithStdImpl) -> Self { Self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 45 previous errors +error: aborting due to 41 previous errors diff --git a/tests/ui/privacy/restricted/test.rs b/tests/ui/privacy/restricted/test.rs index 26018fbb01a6..82432b4db509 100644 --- a/tests/ui/privacy/restricted/test.rs +++ b/tests/ui/privacy/restricted/test.rs @@ -48,6 +48,6 @@ fn main() { } mod pathological { - pub(in bad::path) mod m1 {} //~ ERROR: cannot find module or crate `bad` + pub(in bad::path) mod m1 {} //~ ERROR failed to resolve: use of unresolved module or unlinked crate `bad` pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules } diff --git a/tests/ui/privacy/restricted/test.stderr b/tests/ui/privacy/restricted/test.stderr index ae56e0bf7844..8d7925cf99fc 100644 --- a/tests/ui/privacy/restricted/test.stderr +++ b/tests/ui/privacy/restricted/test.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `bad` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `bad` --> $DIR/test.rs:51:12 | LL | pub(in bad::path) mod m1 {} diff --git a/tests/ui/privacy/unreachable-issue-121455.rs b/tests/ui/privacy/unreachable-issue-121455.rs index c1822034eb19..5da30d6ed639 100644 --- a/tests/ui/privacy/unreachable-issue-121455.rs +++ b/tests/ui/privacy/unreachable-issue-121455.rs @@ -1,6 +1,5 @@ fn test(s: &Self::Id) { -//~^ ERROR: cannot find `Self` -//~| NOTE: `Self` is only available in impls, traits, and type definitions +//~^ ERROR failed to resolve: `Self` is only available in impls, traits, and type definitions match &s[0..3] {} } diff --git a/tests/ui/privacy/unreachable-issue-121455.stderr b/tests/ui/privacy/unreachable-issue-121455.stderr index fe4c38081b74..864e950a98eb 100644 --- a/tests/ui/privacy/unreachable-issue-121455.stderr +++ b/tests/ui/privacy/unreachable-issue-121455.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/unreachable-issue-121455.rs:1:13 | LL | fn test(s: &Self::Id) { diff --git a/tests/ui/proc-macro/amputate-span.stderr b/tests/ui/proc-macro/amputate-span.stderr index bd2f39edec4f..aa797339be46 100644 --- a/tests/ui/proc-macro/amputate-span.stderr +++ b/tests/ui/proc-macro/amputate-span.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `Command` in this scope +error[E0433]: failed to resolve: use of undeclared type `Command` --> $DIR/amputate-span.rs:49:5 | LL | Command::new("git"); @@ -9,7 +9,7 @@ help: consider importing this struct LL + use std::process::Command; | -error[E0433]: cannot find type `Command` in this scope +error[E0433]: failed to resolve: use of undeclared type `Command` --> $DIR/amputate-span.rs:63:9 | LL | Command::new("git"); diff --git a/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs b/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs index d778e46da6b9..4083604e1885 100644 --- a/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs +++ b/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs @@ -8,7 +8,6 @@ extern crate proc_macro; mod cmp; mod ident; mod literal; -mod tokenstream; use proc_macro::TokenStream; @@ -19,7 +18,6 @@ pub fn run(input: TokenStream) -> TokenStream { cmp::test(); ident::test(); literal::test(); - tokenstream::test(); TokenStream::new() } diff --git a/tests/ui/proc-macro/auxiliary/api/tokenstream.rs b/tests/ui/proc-macro/auxiliary/api/tokenstream.rs deleted file mode 100644 index 7078f4413051..000000000000 --- a/tests/ui/proc-macro/auxiliary/api/tokenstream.rs +++ /dev/null @@ -1,28 +0,0 @@ -use proc_macro::*; - -fn assert_eq(l: TokenStream, r: TokenStream) { - assert_eq!(l.to_string(), r.to_string()); - for (lt, rt) in l.into_iter().zip(r) { - assert_eq!(lt.to_string(), rt.to_string()); - } -} - -pub fn test() { - assert_eq(TokenStream::new(), TokenStream::new()); - let mut stream = TokenStream::new(); - assert!(stream.is_empty()); - stream.extend(TokenStream::new()); - assert_eq(stream.clone(), TokenStream::new()); - - let old = stream.clone(); - stream.extend(vec![TokenTree::Ident(Ident::new("foo", Span::call_site()))]); - assert!(!stream.is_empty()); - assert!(old.is_empty()); - - let stream2 = stream - .clone() - .into_iter() - .inspect(|tree| assert_eq!(tree.to_string(), "foo")) - .collect::(); - assert_eq(stream.clone(), stream2); -} diff --git a/tests/ui/proc-macro/bad-projection.stderr b/tests/ui/proc-macro/bad-projection.stderr index 5b472d407044..f2981499367b 100644 --- a/tests/ui/proc-macro/bad-projection.stderr +++ b/tests/ui/proc-macro/bad-projection.stderr @@ -33,7 +33,7 @@ LL | pub fn uwu() -> <() as Project>::Assoc {} | takes 0 arguments | required by a bound introduced by this call | -note: required by a bound in `proc_macro::bridge::client::ProcMacro::bang` +note: required by a bound in `ProcMacro::bang` --> $SRC_DIR/proc_macro/src/bridge/client.rs:LL:COL error[E0277]: the trait bound `(): Project` is not satisfied diff --git a/tests/ui/proc-macro/dollar-crate-issue-62325.stdout b/tests/ui/proc-macro/dollar-crate-issue-62325.stdout index d1b7227c138d..bfd013476f3a 100644 --- a/tests/ui/proc-macro/dollar-crate-issue-62325.stdout +++ b/tests/ui/proc-macro/dollar-crate-issue-62325.stdout @@ -57,54 +57,54 @@ PRINT-ATTR INPUT (DISPLAY): struct B(identity! ($crate :: S)); PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:21:5: 21:11 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:5: 21:11 (#11), }, Ident { ident: "B", - span: $DIR/auxiliary/dollar-crate-external.rs:21:12: 21:13 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:12: 21:13 (#11), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "identity", - span: $DIR/auxiliary/dollar-crate-external.rs:21:14: 21:22 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:14: 21:22 (#11), }, Punct { ch: '!', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:21:22: 21:23 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:22: 21:23 (#11), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:21:24: 21:30 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:24: 21:30 (#11), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:21:30: 21:31 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:30: 21:31 (#11), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:21:31: 21:32 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:31: 21:32 (#11), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:21:32: 21:33 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:32: 21:33 (#11), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:21:23: 21:34 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:23: 21:34 (#11), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:21:13: 21:35 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:13: 21:35 (#11), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:21:35: 21:36 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:35: 21:36 (#11), }, ] diff --git a/tests/ui/proc-macro/dollar-crate.stdout b/tests/ui/proc-macro/dollar-crate.stdout index f39d03540916..0278ef1ad0fc 100644 --- a/tests/ui/proc-macro/dollar-crate.stdout +++ b/tests/ui/proc-macro/dollar-crate.stdout @@ -122,119 +122,119 @@ PRINT-BANG INPUT (DISPLAY): struct M($crate :: S); PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:7:13: 7:19 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:13: 7:19 (#14), }, Ident { ident: "M", - span: $DIR/auxiliary/dollar-crate-external.rs:7:20: 7:21 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:20: 7:21 (#14), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:7:22: 7:28 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:22: 7:28 (#14), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:7:28: 7:29 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:28: 7:29 (#14), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:7:29: 7:30 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:29: 7:30 (#14), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:7:30: 7:31 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:30: 7:31 (#14), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:7:21: 7:32 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:21: 7:32 (#14), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:7:32: 7:33 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:32: 7:33 (#14), }, ] PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S); PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:11:9: 11:15 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:9: 11:15 (#14), }, Ident { ident: "A", - span: $DIR/auxiliary/dollar-crate-external.rs:11:16: 11:17 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:16: 11:17 (#14), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:11:18: 11:24 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:18: 11:24 (#14), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:11:24: 11:25 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:24: 11:25 (#14), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:11:25: 11:26 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:25: 11:26 (#14), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:11:26: 11:27 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:26: 11:27 (#14), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:11:17: 11:28 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:17: 11:28 (#14), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:11:28: 11:29 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:28: 11:29 (#14), }, ] PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S); PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:14:9: 14:15 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:9: 14:15 (#14), }, Ident { ident: "D", - span: $DIR/auxiliary/dollar-crate-external.rs:14:16: 14:17 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:16: 14:17 (#14), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:14:18: 14:24 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:18: 14:24 (#14), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:14:24: 14:25 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:24: 14:25 (#14), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:14:25: 14:26 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:25: 14:26 (#14), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:14:26: 14:27 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:26: 14:27 (#14), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:14:17: 14:28 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:17: 14:28 (#14), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:14:28: 14:29 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:28: 14:29 (#14), }, ] diff --git a/tests/ui/proc-macro/generate-mod.stderr b/tests/ui/proc-macro/generate-mod.stderr index af90df2c3dc3..371fd73e507b 100644 --- a/tests/ui/proc-macro/generate-mod.stderr +++ b/tests/ui/proc-macro/generate-mod.stderr @@ -47,7 +47,6 @@ LL | #[derive(generate_mod::CheckDerive)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 = note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find type `OuterDerive` in this scope --> $DIR/generate-mod.rs:18:10 @@ -57,7 +56,6 @@ LL | #[derive(generate_mod::CheckDerive)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find type `FromOutside` in this scope --> $DIR/generate-mod.rs:25:14 @@ -67,7 +65,6 @@ LL | #[derive(generate_mod::CheckDerive)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find type `OuterDerive` in this scope --> $DIR/generate-mod.rs:25:14 @@ -77,7 +74,6 @@ LL | #[derive(generate_mod::CheckDerive)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors @@ -92,7 +88,6 @@ LL | #[derive(generate_mod::CheckDerive)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 = note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: error: cannot find type `OuterDerive` in this scope @@ -104,7 +99,6 @@ LL | #[derive(generate_mod::CheckDerive)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 = note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: error: cannot find type `FromOutside` in this scope @@ -116,7 +110,6 @@ LL | #[derive(generate_mod::CheckDerive)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 = note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: error: cannot find type `OuterDerive` in this scope @@ -128,7 +121,6 @@ LL | #[derive(generate_mod::CheckDerive)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 = note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: warning: cannot find type `FromOutside` in this scope @@ -139,7 +131,6 @@ LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 - = note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: warning: cannot find type `OuterDeriveLint` in this scope @@ -150,5 +141,4 @@ LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #83583 - = note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs b/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs index 0c66b47b3941..d420f2641daf 100644 --- a/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs +++ b/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs @@ -12,11 +12,12 @@ struct PriorityQueueEntry { } #[derive(PartialOrd, AddImpl)] -//~^ ERROR: the trait bound `PriorityQueue: Eq` is not satisfied -//~| ERROR: can't compare `T` with `T` -//~| ERROR: no method named `cmp` found for struct `BinaryHeap>` -//~| ERROR: no field `height` on type `&PriorityQueue` +//~^ ERROR can't compare `PriorityQueue` with `PriorityQueue` +//~| ERROR the trait bound `PriorityQueue: Eq` is not satisfied +//~| ERROR can't compare `T` with `T` +//~| ERROR no method named `cmp` found for struct `BinaryHeap>` +//~| ERROR no field `height` on type `&PriorityQueue` + struct PriorityQueue(BinaryHeap>); -//~^ ERROR: can't compare `PriorityQueue` with `PriorityQueue` -//~| ERROR: can't compare `BinaryHeap>` with `_` +//~^ ERROR can't compare `BinaryHeap>` with `_` fn main() {} diff --git a/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr b/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr index b53ebe9f7271..b7aed4a8485a 100644 --- a/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr +++ b/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr @@ -1,14 +1,11 @@ error[E0277]: can't compare `PriorityQueue` with `PriorityQueue` - --> $DIR/issue-104884-trait-impl-sugg-err.rs:19:8 + --> $DIR/issue-104884-trait-impl-sugg-err.rs:14:10 | LL | #[derive(PartialOrd, AddImpl)] - | ---------- in this derive macro expansion -... -LL | struct PriorityQueue(BinaryHeap>); - | ^^^^^^^^^^^^^ no implementation for `PriorityQueue == PriorityQueue` + | ^^^^^^^^^^ no implementation for `PriorityQueue == PriorityQueue` | help: the trait `PartialEq` is not implemented for `PriorityQueue` - --> $DIR/issue-104884-trait-impl-sugg-err.rs:19:1 + --> $DIR/issue-104884-trait-impl-sugg-err.rs:21:1 | LL | struct PriorityQueue(BinaryHeap>); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +19,7 @@ LL | #[derive(PartialOrd, AddImpl)] | ^^^^^^^ unsatisfied trait bound | help: the trait `Eq` is not implemented for `PriorityQueue` - --> $DIR/issue-104884-trait-impl-sugg-err.rs:19:1 + --> $DIR/issue-104884-trait-impl-sugg-err.rs:21:1 | LL | struct PriorityQueue(BinaryHeap>); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,19 +34,15 @@ LL | #[derive(PartialOrd, AddImpl)] | ^^^^^^^ no implementation for `T < T` and `T > T` | note: required for `PriorityQueue` to implement `PartialOrd` - --> $DIR/issue-104884-trait-impl-sugg-err.rs:19:8 + --> $DIR/issue-104884-trait-impl-sugg-err.rs:14:10 | LL | #[derive(PartialOrd, AddImpl)] - | ---------- in this derive macro expansion -... -LL | struct PriorityQueue(BinaryHeap>); - | ^^^^^^^^^^^^^ - type parameter would need to implement `PartialOrd` - = help: consider manually implementing `PartialOrd` to avoid undesired bounds + | ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `Ord` --> $SRC_DIR/core/src/cmp.rs:LL:COL error[E0277]: can't compare `BinaryHeap>` with `_` - --> $DIR/issue-104884-trait-impl-sugg-err.rs:19:25 + --> $DIR/issue-104884-trait-impl-sugg-err.rs:21:25 | LL | #[derive(PartialOrd, AddImpl)] | ---------- in this derive macro expansion diff --git a/tests/ui/proc-macro/nested-macro-rules.stdout b/tests/ui/proc-macro/nested-macro-rules.stdout index 89fb7b042218..5b678554b9e0 100644 --- a/tests/ui/proc-macro/nested-macro-rules.stdout +++ b/tests/ui/proc-macro/nested-macro-rules.stdout @@ -2,45 +2,45 @@ PRINT-BANG INPUT (DISPLAY): FirstStruct PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "FirstStruct", - span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#7), + span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#6), }, ] PRINT-ATTR INPUT (DISPLAY): struct FirstAttrStruct {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#6), + span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#5), }, Ident { ident: "FirstAttrStruct", - span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#7), + span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#6), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#6), + span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#5), }, ] PRINT-BANG INPUT (DISPLAY): SecondStruct PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "SecondStruct", - span: $DIR/nested-macro-rules.rs:23:38: 23:50 (#16), + span: $DIR/nested-macro-rules.rs:23:38: 23:50 (#15), }, ] PRINT-ATTR INPUT (DISPLAY): struct SecondAttrStruct {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#15), + span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#14), }, Ident { ident: "SecondAttrStruct", - span: $DIR/nested-macro-rules.rs:23:52: 23:68 (#16), + span: $DIR/nested-macro-rules.rs:23:52: 23:68 (#15), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#15), + span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#14), }, ] diff --git a/tests/ui/proc-macro/pretty-print-hack-hide.rs b/tests/ui/proc-macro/pretty-print-hack-hide.rs new file mode 100644 index 000000000000..fd98f16a780e --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack-hide.rs @@ -0,0 +1,12 @@ +//@ proc-macro: test-macros.rs +//@ compile-flags: -Z span-debug +//@ check-pass + +#![no_std] // Don't load unnecessary hygiene information from std +extern crate std; + +#[macro_use] extern crate test_macros; + +include!("pretty-print-hack/rental-0.5.6/src/lib.rs"); + +fn main() {} diff --git a/tests/ui/proc-macro/pretty-print-hack-hide.stdout b/tests/ui/proc-macro/pretty-print-hack-hide.stdout new file mode 100644 index 000000000000..ea796bb26976 --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack-hide.stdout @@ -0,0 +1,21 @@ +PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input } +PRINT-DERIVE INPUT (DEBUG): TokenStream [ + Ident { + ident: "enum", + span: $DIR/pretty-print-hack/rental-0.5.6/src/lib.rs:4:1: 4:5 (#0), + }, + Ident { + ident: "ProceduralMasqueradeDummyType", + span: $DIR/pretty-print-hack/rental-0.5.6/src/lib.rs:4:6: 4:35 (#0), + }, + Group { + delimiter: Brace, + stream: TokenStream [ + Ident { + ident: "Input", + span: $DIR/pretty-print-hack/rental-0.5.6/src/lib.rs:13:5: 13:10 (#0), + }, + ], + span: $DIR/pretty-print-hack/rental-0.5.6/src/lib.rs:4:36: 14:2 (#0), + }, +] diff --git a/tests/ui/proc-macro/pretty-print-hack-show.local.stderr b/tests/ui/proc-macro/pretty-print-hack-show.local.stderr new file mode 100644 index 000000000000..889cd0c90ebb --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack-show.local.stderr @@ -0,0 +1,6 @@ +error: using an old version of `rental` + | + = note: older versions of the `rental` crate no longer compile; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives + +error: aborting due to 1 previous error + diff --git a/tests/ui/proc-macro/pretty-print-hack-show.remapped.stderr b/tests/ui/proc-macro/pretty-print-hack-show.remapped.stderr new file mode 100644 index 000000000000..889cd0c90ebb --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack-show.remapped.stderr @@ -0,0 +1,6 @@ +error: using an old version of `rental` + | + = note: older versions of the `rental` crate no longer compile; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives + +error: aborting due to 1 previous error + diff --git a/tests/ui/proc-macro/pretty-print-hack-show.rs b/tests/ui/proc-macro/pretty-print-hack-show.rs new file mode 100644 index 000000000000..08e26c811427 --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack-show.rs @@ -0,0 +1,21 @@ +//@ proc-macro: test-macros.rs +//@ compile-flags: -Z span-debug +//@ revisions: local remapped +//@ [remapped] remap-src-base + +#![no_std] // Don't load unnecessary hygiene information from std +extern crate std; + +#[macro_use] extern crate test_macros; + +mod first { + include!("pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs"); +} + +mod second { + include!("pretty-print-hack/rental-0.5.5/src/lib.rs"); +} + +fn main() {} + +//~? ERROR using an old version of `rental` diff --git a/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs b/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs new file mode 100644 index 000000000000..a27176a38e22 --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs @@ -0,0 +1,14 @@ +//@ ignore-auxiliary (used by `../../../pretty-print-hack-show.rs`) + +#[derive(Print)] +enum ProceduralMasqueradeDummyType { +//~^ ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously + Input +} diff --git a/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs new file mode 100644 index 000000000000..a27176a38e22 --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs @@ -0,0 +1,14 @@ +//@ ignore-auxiliary (used by `../../../pretty-print-hack-show.rs`) + +#[derive(Print)] +enum ProceduralMasqueradeDummyType { +//~^ ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously + Input +} diff --git a/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs new file mode 100644 index 000000000000..765ee4be656e --- /dev/null +++ b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs @@ -0,0 +1,14 @@ +//@ ignore-auxiliary (used by `../../../pretty-print-hack/hide.rs`) + +#[derive(Print)] +enum ProceduralMasqueradeDummyType { +//~^ ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously + Input +} diff --git a/tests/ui/proc-macro/proc-macro-abi.stderr b/tests/ui/proc-macro/proc-macro-abi.stderr index ccefdbfa3a86..ccc72e5187ed 100644 --- a/tests/ui/proc-macro/proc-macro-abi.stderr +++ b/tests/ui/proc-macro/proc-macro-abi.stderr @@ -4,8 +4,8 @@ error: function-like proc macro has incorrect signature LL | pub extern "C" fn abi(a: TokenStream) -> TokenStream { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `extern "C" fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `extern "C" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` error: function-like proc macro has incorrect signature --> $DIR/proc-macro-abi.rs:17:1 @@ -13,8 +13,8 @@ error: function-like proc macro has incorrect signature LL | pub extern "system" fn abi2(a: TokenStream) -> TokenStream { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "system" fn | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `extern "system" fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `extern "system" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` error: function-like proc macro has incorrect signature --> $DIR/proc-macro-abi.rs:23:1 @@ -22,8 +22,8 @@ error: function-like proc macro has incorrect signature LL | pub extern fn abi3(a: TokenStream) -> TokenStream { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `extern "C" fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `extern "C" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` error: aborting due to 3 previous errors diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr index 86a00713a456..0bcea9b85f47 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr @@ -5,7 +5,7 @@ LL | quote!($($nonrep $nonrep)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | here the type of `has_iter` is inferred to be `proc_macro::ThereIsNoIteratorInRepetition` + | here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr index 325e50f9796a..d945ab41a12e 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr @@ -5,7 +5,7 @@ LL | quote!($($nonrep)*); | ^^^^^^^^^^^^^^^^^^^ | | | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | here the type of `has_iter` is inferred to be `proc_macro::ThereIsNoIteratorInRepetition` + | here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/not-quotable.stderr b/tests/ui/proc-macro/quote/not-quotable.stderr index 4177d9c672b5..b00d029946d6 100644 --- a/tests/ui/proc-macro/quote/not-quotable.stderr +++ b/tests/ui/proc-macro/quote/not-quotable.stderr @@ -11,11 +11,11 @@ LL | let _ = quote! { $ip }; &T &mut T Box - CStr CString Cow<'_, T> Option Rc + bool and 24 others error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/not-repeatable.rs b/tests/ui/proc-macro/quote/not-repeatable.rs index 55ba1669f1b1..373f0e74dbda 100644 --- a/tests/ui/proc-macro/quote/not-repeatable.rs +++ b/tests/ui/proc-macro/quote/not-repeatable.rs @@ -10,4 +10,5 @@ fn main() { let ip = Ipv4Addr; let _ = quote! { $($ip)* }; //~^ ERROR the method `quote_into_iter` exists for struct `Ipv4Addr`, but its trait bounds were not satisfied + //~| ERROR type annotations needed } diff --git a/tests/ui/proc-macro/quote/not-repeatable.stderr b/tests/ui/proc-macro/quote/not-repeatable.stderr index 611da37f3a1f..5943111efd58 100644 --- a/tests/ui/proc-macro/quote/not-repeatable.stderr +++ b/tests/ui/proc-macro/quote/not-repeatable.stderr @@ -2,7 +2,7 @@ error[E0599]: the method `quote_into_iter` exists for struct `Ipv4Addr`, but its --> $DIR/not-repeatable.rs:11:13 | LL | struct Ipv4Addr; - | --------------- method `quote_into_iter` not found for this struct because `Ipv4Addr` doesn't implement `Iterator` or `ToTokens` + | --------------- method `quote_into_iter` not found for this struct because it doesn't satisfy `Ipv4Addr: Iterator`, `Ipv4Addr: ToTokens`, `Ipv4Addr: proc_macro::ext::RepIteratorExt` or `Ipv4Addr: proc_macro::ext::RepToTokensExt` ... LL | let _ = quote! { $($ip)* }; | ^^^^^^^^^^^^^^^^^^ method cannot be called on `Ipv4Addr` due to unsatisfied trait bounds @@ -20,6 +20,13 @@ note: the traits `Iterator` and `ToTokens` must be implemented --> $SRC_DIR/proc_macro/src/to_tokens.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error: aborting due to 1 previous error +error[E0282]: type annotations needed + --> $DIR/not-repeatable.rs:11:25 + | +LL | let _ = quote! { $($ip)* }; + | ^^ cannot infer type -For more information about this error, try `rustc --explain E0599`. +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0282, E0599. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/proc-macro/signature-proc-macro-attribute.stderr b/tests/ui/proc-macro/signature-proc-macro-attribute.stderr index 9dfb081a10e6..ce832eaa5c7a 100644 --- a/tests/ui/proc-macro/signature-proc-macro-attribute.stderr +++ b/tests/ui/proc-macro/signature-proc-macro-attribute.stderr @@ -4,8 +4,8 @@ error: attribute proc macro has incorrect signature LL | pub fn bad_input(input: String) -> TokenStream { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(TokenStream, TokenStream) -> TokenStream` - found signature `fn(String) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> proc_macro::TokenStream` error: attribute proc macro has incorrect signature --> $DIR/signature-proc-macro-attribute.rs:16:1 @@ -13,8 +13,8 @@ error: attribute proc macro has incorrect signature LL | pub fn bad_output(input: TokenStream) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(TokenStream, TokenStream) -> TokenStream` - found signature `fn(TokenStream) -> String` + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream) -> std::string::String` error: attribute proc macro has incorrect signature --> $DIR/signature-proc-macro-attribute.rs:22:1 @@ -22,8 +22,8 @@ error: attribute proc macro has incorrect signature LL | pub fn bad_everything(input: String) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(TokenStream, TokenStream) -> TokenStream` - found signature `fn(String) -> String` + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> std::string::String` error: attribute proc macro has incorrect signature --> $DIR/signature-proc-macro-attribute.rs:28:52 @@ -31,8 +31,8 @@ error: attribute proc macro has incorrect signature LL | pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { | ^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(TokenStream, TokenStream) -> TokenStream` - found signature `fn(TokenStream, TokenStream, String) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream, proc_macro::TokenStream, std::string::String) -> proc_macro::TokenStream` error: aborting due to 4 previous errors diff --git a/tests/ui/proc-macro/signature-proc-macro-derive.stderr b/tests/ui/proc-macro/signature-proc-macro-derive.stderr index 3539ae7c2e17..03c6abad17d9 100644 --- a/tests/ui/proc-macro/signature-proc-macro-derive.stderr +++ b/tests/ui/proc-macro/signature-proc-macro-derive.stderr @@ -2,28 +2,28 @@ error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:10:25 | LL | pub fn bad_input(input: String) -> TokenStream { - | ^^^^^^ expected `TokenStream`, found `String` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(String) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> proc_macro::TokenStream` error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:16:42 | LL | pub fn bad_output(input: TokenStream) -> String { - | ^^^^^^ expected `TokenStream`, found `String` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(TokenStream) -> String` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream) -> std::string::String` error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:22:30 | LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ expected `TokenStream`, found `String` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(String) -> String` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> std::string::String` error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:28:36 @@ -31,8 +31,8 @@ error: derive proc macro has incorrect signature LL | pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { | ^^^^^^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(TokenStream, TokenStream, String) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream, proc_macro::TokenStream, std::string::String) -> proc_macro::TokenStream` error: aborting due to 4 previous errors diff --git a/tests/ui/proc-macro/signature-proc-macro.stderr b/tests/ui/proc-macro/signature-proc-macro.stderr index 1959d8c6d615..dd2cb0570daa 100644 --- a/tests/ui/proc-macro/signature-proc-macro.stderr +++ b/tests/ui/proc-macro/signature-proc-macro.stderr @@ -2,28 +2,28 @@ error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:10:25 | LL | pub fn bad_input(input: String) -> TokenStream { - | ^^^^^^ expected `TokenStream`, found `String` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(String) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> proc_macro::TokenStream` error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:16:42 | LL | pub fn bad_output(input: TokenStream) -> String { - | ^^^^^^ expected `TokenStream`, found `String` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(TokenStream) -> String` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream) -> std::string::String` error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:22:30 | LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ expected `TokenStream`, found `String` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(String) -> String` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> std::string::String` error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:28:36 @@ -31,8 +31,8 @@ error: function-like proc macro has incorrect signature LL | pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { | ^^^^^^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(TokenStream) -> TokenStream` - found signature `fn(TokenStream, TokenStream, String) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream, proc_macro::TokenStream, std::string::String) -> proc_macro::TokenStream` error: aborting due to 4 previous errors diff --git a/tests/ui/proc-macro/signature.stderr b/tests/ui/proc-macro/signature.stderr index 2c1973eb6e6d..fd679442b6af 100644 --- a/tests/ui/proc-macro/signature.stderr +++ b/tests/ui/proc-macro/signature.stderr @@ -4,7 +4,7 @@ error: derive proc macro has incorrect signature LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | - = note: expected signature `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` found signature `unsafe extern "C" fn(i32, u32) -> u32` error: aborting due to 1 previous error diff --git a/tests/ui/query-system/query-cycle-printing-issue-151226.rs b/tests/ui/query-system/query-cycle-printing-issue-151226.rs deleted file mode 100644 index 9d0a20737c9f..000000000000 --- a/tests/ui/query-system/query-cycle-printing-issue-151226.rs +++ /dev/null @@ -1,8 +0,0 @@ -struct A(std::sync::OnceLock); -//~^ ERROR recursive type `A` has infinite size -//~| ERROR cycle detected when computing layout of `A<()>` - -static B: A<()> = todo!(); -//~^ ERROR cycle occurred during layout computation - -fn main() {} diff --git a/tests/ui/query-system/query-cycle-printing-issue-151226.stderr b/tests/ui/query-system/query-cycle-printing-issue-151226.stderr deleted file mode 100644 index 7e574b5911a3..000000000000 --- a/tests/ui/query-system/query-cycle-printing-issue-151226.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0072]: recursive type `A` has infinite size - --> $DIR/query-cycle-printing-issue-151226.rs:1:1 - | -LL | struct A(std::sync::OnceLock); - | ^^^^^^^^^^^ ------------------------- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | struct A(Box>); - | ++++ + - -error[E0391]: cycle detected when computing layout of `A<()>` - | - = note: ...which requires computing layout of `std::sync::once_lock::OnceLock>`... - = note: ...which requires computing layout of `core::cell::UnsafeCell>>`... - = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit>`... - = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop>`... - = note: ...which requires computing layout of `core::mem::maybe_dangling::MaybeDangling>`... - = note: ...which again requires computing layout of `A<()>`, completing the cycle -note: cycle used when checking that `B` is well-formed - --> $DIR/query-cycle-printing-issue-151226.rs:5:1 - | -LL | static B: A<()> = todo!(); - | ^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error[E0080]: a cycle occurred during layout computation - --> $DIR/query-cycle-printing-issue-151226.rs:5:1 - | -LL | static B: A<()> = todo!(); - | ^^^^^^^^^^^^^^^ evaluation of `B` failed here - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0072, E0080, E0391. -For more information about an error, try `rustc --explain E0072`. diff --git a/tests/ui/query-system/query-cycle-printing-issue-151358.rs b/tests/ui/query-system/query-cycle-printing-issue-151358.rs deleted file mode 100644 index 04d8664420be..000000000000 --- a/tests/ui/query-system/query-cycle-printing-issue-151358.rs +++ /dev/null @@ -1,7 +0,0 @@ -//~ ERROR: cycle detected when looking up span for `Default` -trait Default {} -use std::num::NonZero; -fn main() { - NonZero(); - format!("{}", 0); -} diff --git a/tests/ui/query-system/query-cycle-printing-issue-151358.stderr b/tests/ui/query-system/query-cycle-printing-issue-151358.stderr deleted file mode 100644 index 9c1d7b1de33a..000000000000 --- a/tests/ui/query-system/query-cycle-printing-issue-151358.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0391]: cycle detected when looking up span for `Default` - | - = note: ...which immediately requires looking up span for `Default` again - = note: cycle used when perform lints prior to AST lowering - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/range/new_range_stability.rs b/tests/ui/range/new_range_stability.rs deleted file mode 100644 index 7200e1ac95d2..000000000000 --- a/tests/ui/range/new_range_stability.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Stable - -use std::range::{RangeInclusive, RangeInclusiveIter}; - -fn range_inclusive(mut r: RangeInclusive) { - r.start; - r.last; - r.contains(&5); - r.is_empty(); - r.iter(); - - let mut i = r.into_iter(); - i.next(); - i.remainder(); -} - -// Unstable module - -use std::range::legacy; //~ ERROR unstable - -// Unstable types - -use std::range::RangeFrom; //~ ERROR unstable -use std::range::Range; //~ ERROR unstable -use std::range::RangeFromIter; //~ ERROR unstable -use std::range::RangeIter; //~ ERROR unstable - -fn main() {} diff --git a/tests/ui/range/new_range_stability.stderr b/tests/ui/range/new_range_stability.stderr deleted file mode 100644 index 871d691794ff..000000000000 --- a/tests/ui/range/new_range_stability.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:19:5 - | -LL | use std::range::legacy; - | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #125687 for more information - = help: add `#![feature(new_range_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:23:5 - | -LL | use std::range::RangeFrom; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #125687 for more information - = help: add `#![feature(new_range_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:24:5 - | -LL | use std::range::Range; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #125687 for more information - = help: add `#![feature(new_range_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:25:5 - | -LL | use std::range::RangeFromIter; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #125687 for more information - = help: add `#![feature(new_range_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:26:5 - | -LL | use std::range::RangeIter; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #125687 for more information - = help: add `#![feature(new_range_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/range/range-negative-literal-unsigned-type.rs b/tests/ui/range/range-negative-literal-unsigned-type.rs deleted file mode 100644 index b6152abb340e..000000000000 --- a/tests/ui/range/range-negative-literal-unsigned-type.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Regression tests for: https://github.com/rust-lang/rust/issues/136514 - -#![allow(unreachable_patterns)] -fn main() { - match 0u8 { - -1..=2 => {} - //~^ ERROR the trait bound `u8: Neg` is not satisfied - -0..=0 => {} - //~^ ERROR the trait bound `u8: Neg` is not satisfied - -256..=2 => {} - //~^ ERROR the trait bound `u8: Neg` is not satisfied - -255..=2 => {} - //~^ ERROR the trait bound `u8: Neg` is not satisfied - 0..=-1 => {} - //~^ ERROR the trait bound `u8: Neg` is not satisfied - -2..=-1 => {} - //~^ ERROR the trait bound `u8: Neg` is not satisfied - //~| ERROR the trait bound `u8: Neg` is not satisfied - _ => {} - } -} diff --git a/tests/ui/range/range-negative-literal-unsigned-type.stderr b/tests/ui/range/range-negative-literal-unsigned-type.stderr deleted file mode 100644 index 7ca14c3d7790..000000000000 --- a/tests/ui/range/range-negative-literal-unsigned-type.stderr +++ /dev/null @@ -1,122 +0,0 @@ -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:6:9 - | -LL | -1..=2 => {} - | ^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:8:9 - | -LL | -0..=0 => {} - | ^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:10:9 - | -LL | -256..=2 => {} - | ^^^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:12:9 - | -LL | -255..=2 => {} - | ^^^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:14:13 - | -LL | 0..=-1 => {} - | ^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:16:9 - | -LL | -2..=-1 => {} - | ^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/range-negative-literal-unsigned-type.rs:16:14 - | -LL | -2..=-1 => {} - | ^^ the trait `Neg` is not implemented for `u8` - | - = help: the following other types implement trait `Neg`: - &f128 - &f16 - &f32 - &f64 - &i128 - &i16 - &i32 - &i64 - and 12 others - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/range/range_traits-2.rs b/tests/ui/range/range_traits-2.rs index 7dd91243082c..234d7a64dc8b 100644 --- a/tests/ui/range/range_traits-2.rs +++ b/tests/ui/range/range_traits-2.rs @@ -1,6 +1,6 @@ use std::ops::*; -#[derive(Copy, Clone)] -struct R(Range); //~ ERROR Copy +#[derive(Copy, Clone)] //~ ERROR Copy +struct R(Range); fn main() {} diff --git a/tests/ui/range/range_traits-2.stderr b/tests/ui/range/range_traits-2.stderr index f38539cc648c..2001c85c4348 100644 --- a/tests/ui/range/range_traits-2.stderr +++ b/tests/ui/range/range_traits-2.stderr @@ -1,10 +1,10 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/range_traits-2.rs:4:8 + --> $DIR/range_traits-2.rs:3:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion + | ^^^^ LL | struct R(Range); - | ^ ------------ this field does not implement `Copy` + | ------------ this field does not implement `Copy` error: aborting due to 1 previous error diff --git a/tests/ui/range/range_traits-3.rs b/tests/ui/range/range_traits-3.rs index 79ba1842f62f..2d597cce5ad5 100644 --- a/tests/ui/range/range_traits-3.rs +++ b/tests/ui/range/range_traits-3.rs @@ -1,6 +1,6 @@ use std::ops::*; -#[derive(Copy, Clone)] -struct R(RangeFrom); //~ ERROR Copy +#[derive(Copy, Clone)] //~ ERROR Copy +struct R(RangeFrom); fn main() {} diff --git a/tests/ui/range/range_traits-3.stderr b/tests/ui/range/range_traits-3.stderr index 1f3768ad8d84..71210379c79c 100644 --- a/tests/ui/range/range_traits-3.stderr +++ b/tests/ui/range/range_traits-3.stderr @@ -1,10 +1,10 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/range_traits-3.rs:4:8 + --> $DIR/range_traits-3.rs:3:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion + | ^^^^ LL | struct R(RangeFrom); - | ^ ---------------- this field does not implement `Copy` + | ---------------- this field does not implement `Copy` error: aborting due to 1 previous error diff --git a/tests/ui/range/range_traits-6.rs b/tests/ui/range/range_traits-6.rs index 72c6cecc88d6..bce106bbfe79 100644 --- a/tests/ui/range/range_traits-6.rs +++ b/tests/ui/range/range_traits-6.rs @@ -1,6 +1,6 @@ use std::ops::*; -#[derive(Copy, Clone)] -struct R(RangeInclusive); //~ ERROR Copy +#[derive(Copy, Clone)] //~ ERROR Copy +struct R(RangeInclusive); fn main() {} diff --git a/tests/ui/range/range_traits-6.stderr b/tests/ui/range/range_traits-6.stderr index 53fe2fed0a61..a58022ef7e4f 100644 --- a/tests/ui/range/range_traits-6.stderr +++ b/tests/ui/range/range_traits-6.stderr @@ -1,10 +1,10 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/range_traits-6.rs:4:8 + --> $DIR/range_traits-6.rs:3:10 | LL | #[derive(Copy, Clone)] - | ---- in this derive macro expansion + | ^^^^ LL | struct R(RangeInclusive); - | ^ --------------------- this field does not implement `Copy` + | --------------------- this field does not implement `Copy` error: aborting due to 1 previous error diff --git a/tests/ui/reachable/expr_again.stderr b/tests/ui/reachable/expr_again.stderr index 2e00fdc7b431..5dec512ba5de 100644 --- a/tests/ui/reachable/expr_again.stderr +++ b/tests/ui/reachable/expr_again.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/reachable/expr_block.stderr b/tests/ui/reachable/expr_block.stderr index aaca4053f27f..d5f248a24910 100644 --- a/tests/ui/reachable/expr_block.stderr +++ b/tests/ui/reachable/expr_block.stderr @@ -19,6 +19,8 @@ LL | return; | ------ any code following this expression is unreachable LL | println!("foo"); | ^^^^^^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/reachable/expr_if.stderr b/tests/ui/reachable/expr_if.stderr index 662692ed6f28..ebd0b5a3ebef 100644 --- a/tests/ui/reachable/expr_if.stderr +++ b/tests/ui/reachable/expr_if.stderr @@ -23,6 +23,8 @@ LL | return; ... LL | println!("But I am."); | ^^^^^^^^^^^^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/reachable/expr_loop.stderr b/tests/ui/reachable/expr_loop.stderr index 83b8d024c4fc..918584686050 100644 --- a/tests/ui/reachable/expr_loop.stderr +++ b/tests/ui/reachable/expr_loop.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:21:5 @@ -19,6 +20,8 @@ LL | loop { return; } | ------ any code following this expression is unreachable LL | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:32:5 @@ -27,6 +30,8 @@ LL | loop { 'middle: loop { loop { break 'middle; } } } | -------------------------------------------------- any code following this expression is unreachable LL | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/reachable/expr_match.stderr b/tests/ui/reachable/expr_match.stderr index 92f6d6758d99..ae202a6e0c34 100644 --- a/tests/ui/reachable/expr_match.stderr +++ b/tests/ui/reachable/expr_match.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_match.rs:19:5 @@ -19,6 +20,8 @@ LL | match () { () if false => return, () => return } | ------------------------------------------------ any code following this `match` expression is unreachable, as all arms diverge LL | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable expression --> $DIR/expr_match.rs:25:25 @@ -39,6 +42,8 @@ LL | | } | |_____- any code following this `match` expression is unreachable, as all arms diverge LL | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/reachable/unreachable-code-ret.stderr b/tests/ui/reachable/unreachable-code-ret.stderr index f51273eb4207..d86def536df8 100644 --- a/tests/ui/reachable/unreachable-code-ret.stderr +++ b/tests/ui/reachable/unreachable-code-ret.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/reflection/dump.bit32.run.stdout b/tests/ui/reflection/dump.bit32.run.stdout new file mode 100644 index 000000000000..8d0398bdd53a --- /dev/null +++ b/tests/ui/reflection/dump.bit32.run.stdout @@ -0,0 +1,221 @@ +Type { + kind: Tuple( + Tuple { + fields: [ + Field { + ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + offset: 0, + }, + Field { + ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + offset: 1, + }, + Field { + ty: TypeId(0x41223169ff28813ba79b7268a2a968d9), + offset: 2, + }, + ], + }, + ), + size: Some( + 2, + ), +} +Type { + kind: Array( + Array { + element_ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + len: 2, + }, + ), + size: Some( + 2, + ), +} +Type { + kind: Int( + Int { + bit_width: 8, + signed: true, + }, + ), + size: Some( + 1, + ), +} +Type { + kind: Int( + Int { + bit_width: 32, + signed: true, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Int( + Int { + bit_width: 64, + signed: true, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Int( + Int { + bit_width: 128, + signed: true, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Int( + Int { + bit_width: 32, + signed: true, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Int( + Int { + bit_width: 8, + signed: false, + }, + ), + size: Some( + 1, + ), +} +Type { + kind: Int( + Int { + bit_width: 32, + signed: false, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Int( + Int { + bit_width: 64, + signed: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Int( + Int { + bit_width: 128, + signed: false, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Int( + Int { + bit_width: 32, + signed: false, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Other, + size: Some( + 4, + ), +} +Type { + kind: Other, + size: Some( + 12, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0xda1b6da9bd297bb2900de9303aadea79), + mutable: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c), + mutable: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x641e3def269c37acc6dcb92bf8c5f196), + mutable: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Str( + Str, + ), + size: None, +} +Type { + kind: Other, + size: None, +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: false, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: true, + }, + ), + size: Some( + 4, + ), +} diff --git a/tests/ui/reflection/dump.bit64.run.stdout b/tests/ui/reflection/dump.bit64.run.stdout new file mode 100644 index 000000000000..3564922fc171 --- /dev/null +++ b/tests/ui/reflection/dump.bit64.run.stdout @@ -0,0 +1,221 @@ +Type { + kind: Tuple( + Tuple { + fields: [ + Field { + ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + offset: 0, + }, + Field { + ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + offset: 1, + }, + Field { + ty: TypeId(0x41223169ff28813ba79b7268a2a968d9), + offset: 2, + }, + ], + }, + ), + size: Some( + 2, + ), +} +Type { + kind: Array( + Array { + element_ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + len: 2, + }, + ), + size: Some( + 2, + ), +} +Type { + kind: Int( + Int { + bit_width: 8, + signed: true, + }, + ), + size: Some( + 1, + ), +} +Type { + kind: Int( + Int { + bit_width: 32, + signed: true, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Int( + Int { + bit_width: 64, + signed: true, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Int( + Int { + bit_width: 128, + signed: true, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Int( + Int { + bit_width: 64, + signed: true, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Int( + Int { + bit_width: 8, + signed: false, + }, + ), + size: Some( + 1, + ), +} +Type { + kind: Int( + Int { + bit_width: 32, + signed: false, + }, + ), + size: Some( + 4, + ), +} +Type { + kind: Int( + Int { + bit_width: 64, + signed: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Int( + Int { + bit_width: 128, + signed: false, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Int( + Int { + bit_width: 64, + signed: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Other, + size: Some( + 4, + ), +} +Type { + kind: Other, + size: Some( + 24, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0xda1b6da9bd297bb2900de9303aadea79), + mutable: false, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c), + mutable: false, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x641e3def269c37acc6dcb92bf8c5f196), + mutable: false, + }, + ), + size: Some( + 16, + ), +} +Type { + kind: Str( + Str, + ), + size: None, +} +Type { + kind: Other, + size: None, +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: false, + }, + ), + size: Some( + 8, + ), +} +Type { + kind: Reference( + Reference { + pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb), + mutable: true, + }, + ), + size: Some( + 8, + ), +} diff --git a/tests/ui/reflection/dump.rs b/tests/ui/reflection/dump.rs new file mode 100644 index 000000000000..d42216a62fdc --- /dev/null +++ b/tests/ui/reflection/dump.rs @@ -0,0 +1,45 @@ +// Some types whose length depends on the target pointer length will be dumped. +//@ revisions: bit32 bit64 +//@[bit32] only-32bit +//@[bit64] only-64bit +//@ run-pass +//@ check-run-results + +#![feature(type_info)] +#![allow(dead_code)] + +use std::mem::type_info::Type; + +struct Foo { + a: u32, +} + +enum Bar { + Some(u32), + None, + Foomp { a: (), b: &'static str }, +} + +struct Unsized { + x: u16, + s: str, +} + +macro_rules! dump_types { + ($($ty:ty),+ $(,)?) => { + $(println!("{:#?}", const { Type::of::<$ty>() });)+ + }; +} + +fn main() { + dump_types! { + (u8, u8, ()), + [u8; 2], + i8, i32, i64, i128, isize, + u8, u32, u64, u128, usize, + Foo, Bar, + &Unsized, &str, &[u8], + str, [u8], + &u8, &mut u8, + } +} diff --git a/tests/ui/regions/forall-wf-ref-reflexive.stderr b/tests/ui/regions/forall-wf-ref-reflexive.stderr index 71debe7c297b..5ee7cc7866c9 100644 --- a/tests/ui/regions/forall-wf-ref-reflexive.stderr +++ b/tests/ui/regions/forall-wf-ref-reflexive.stderr @@ -2,7 +2,7 @@ error: `T` does not live long enough --> $DIR/forall-wf-ref-reflexive.rs:12:5 | LL | self_wf2::(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/regions/regions-bound-lists-feature-gate-2.rs b/tests/ui/regions/regions-bound-lists-feature-gate-2.rs index 6cdae0d49081..f4f27a4456df 100644 --- a/tests/ui/regions/regions-bound-lists-feature-gate-2.rs +++ b/tests/ui/regions/regions-bound-lists-feature-gate-2.rs @@ -1,5 +1,8 @@ //@ run-pass #![allow(dead_code)] +#![allow(stable_features)] + +#![feature(issue_5723_bootstrap)] trait Foo { fn dummy(&self) { } diff --git a/tests/ui/regions/regions-bound-lists-feature-gate.rs b/tests/ui/regions/regions-bound-lists-feature-gate.rs index 23878f5b406f..1bc2b7dd03ef 100644 --- a/tests/ui/regions/regions-bound-lists-feature-gate.rs +++ b/tests/ui/regions/regions-bound-lists-feature-gate.rs @@ -1,6 +1,9 @@ //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(stable_features)] + +#![feature(issue_5723_bootstrap)] trait Foo { fn dummy(&self) { } diff --git a/tests/ui/regions/wf-bound-region-in-local-issue-115175.rs b/tests/ui/regions/wf-bound-region-in-local-issue-115175.rs deleted file mode 100644 index b19f96357ad6..000000000000 --- a/tests/ui/regions/wf-bound-region-in-local-issue-115175.rs +++ /dev/null @@ -1,11 +0,0 @@ -// A regression test for https://github.com/rust-lang/rust/issues/115175. -// This used to compile without error despite of unsatisfied outlives bound `T: 'static` on local. - -struct Static(T); - -fn test() { - let _ = None::>; - //~^ ERROR the parameter type `T` may not live long enough -} - -fn main() {} diff --git a/tests/ui/regions/wf-bound-region-in-local-issue-115175.stderr b/tests/ui/regions/wf-bound-region-in-local-issue-115175.stderr deleted file mode 100644 index 1a1b142b9d1d..000000000000 --- a/tests/ui/regions/wf-bound-region-in-local-issue-115175.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/wf-bound-region-in-local-issue-115175.rs:7:13 - | -LL | let _ = None::>; - | ^^^^^^^^^^^^^^^^^ - | | - | the parameter type `T` must be valid for the static lifetime... - | ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound - | -LL | fn test() { - | +++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/regions/wf-bound-region-in-local-soundness-issue-148854.rs b/tests/ui/regions/wf-bound-region-in-local-soundness-issue-148854.rs deleted file mode 100644 index b21669cf7842..000000000000 --- a/tests/ui/regions/wf-bound-region-in-local-soundness-issue-148854.rs +++ /dev/null @@ -1,51 +0,0 @@ -// A regression test for https://github.com/rust-lang/rust/issues/148854. - -use std::cell::OnceCell; -use std::fmt::Display; -use std::marker::PhantomData; -use std::rc::Rc; - -type Storage = Rc>>; - -trait IntoDyn { - fn into_dyn(input: T, output: Storage); -} - -struct Inner(PhantomData); -impl IntoDyn for Inner { - fn into_dyn(input: T, output: Storage) { - output.set(Box::new(input)).ok().unwrap(); - } -} - -struct Outer> { - input: Option, - output: Storage, - _phantom: PhantomData, -} -impl> Drop for Outer { - fn drop(&mut self) { - U::into_dyn(self.input.take().unwrap(), self.output.clone()); - } -} - -fn extend(x: T) -> Box { - let storage = Rc::new(OnceCell::new()); - { - // This has to error due to an unsatisfied outlives bound on - // `Inner` as its implicit drop relies on that - // bound. - let _ = - Outer::> { input: Some(x), output: storage.clone(), _phantom: PhantomData }; - //~^ ERROR: the parameter type `T` may not live long enough - } - Rc::into_inner(storage).unwrap().into_inner().unwrap() -} - -fn main() { - let wrong = { - let data = String::from("abc"); - extend::<&String>(&data) - }; - println!("{wrong}"); -} diff --git a/tests/ui/regions/wf-bound-region-in-local-soundness-issue-148854.stderr b/tests/ui/regions/wf-bound-region-in-local-soundness-issue-148854.stderr deleted file mode 100644 index d79daaf2a6ad..000000000000 --- a/tests/ui/regions/wf-bound-region-in-local-soundness-issue-148854.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/wf-bound-region-in-local-soundness-issue-148854.rs:39:13 - | -LL | Outer::> { input: Some(x), output: storage.clone(), _phantom: PhantomData }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the parameter type `T` must be valid for the static lifetime... - | ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound - | -LL | fn extend(x: T) -> Box { - | +++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr index ba44beb76dbb..c98b9bb38fdb 100644 --- a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr @@ -7,7 +7,7 @@ LL | LL | extract(x).max(2); | ---------- type must be known at this point | -help: consider giving `x` an explicit type, where the type for type parameter `T` is specified +help: consider giving `x` an explicit type, where the placeholders `_` are specified | LL | let x: [Foo; 2] = [Foo(PhantomData); 2]; | +++++++++++++ diff --git a/tests/ui/repeat-expr/repeat_count.rs b/tests/ui/repeat-expr/repeat_count.rs index b1e3a9d8cb3b..2febcdc07c2a 100644 --- a/tests/ui/repeat-expr/repeat_count.rs +++ b/tests/ui/repeat-expr/repeat_count.rs @@ -21,21 +21,16 @@ fn main() { let f = [0; -4_isize]; //~^ ERROR mismatched types //~| NOTE expected `usize`, found `isize` - //~| NOTE `-4_isize` cannot fit into type `usize` - let g = [0_usize; -1_isize]; + let f = [0_usize; -1_isize]; //~^ ERROR mismatched types //~| NOTE expected `usize`, found `isize` - //~| NOTE `-1_isize` cannot fit into type `usize` - let h = [0; 4u8]; - //~^ ERROR the constant `4` is not of type `usize` - //~| NOTE expected `usize`, found `u8` - //~| NOTE the length of array `[{integer}; 4]` must be type `usize` - //~| ERROR mismatched types - //~| NOTE expected `usize`, found `u8` - struct I { - i: (), - } - let i = [0; I { i: () }]; + let f = [0; 4u8]; //~^ ERROR mismatched types - //~| NOTE expected `usize`, found `I` + //~| NOTE expected `usize`, found `u8` + struct G { + g: (), + } + let g = [0; G { g: () }]; + //~^ ERROR mismatched types + //~| NOTE expected `usize`, found `G` } diff --git a/tests/ui/repeat-expr/repeat_count.stderr b/tests/ui/repeat-expr/repeat_count.stderr index 5da9dbe03209..cf94ad41ee36 100644 --- a/tests/ui/repeat-expr/repeat_count.stderr +++ b/tests/ui/repeat-expr/repeat_count.stderr @@ -16,6 +16,12 @@ error[E0308]: mismatched types LL | let b = [0; ()]; | ^^ expected `usize`, found `()` +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:33:17 + | +LL | let g = [0; G { g: () }]; + | ^^^^^^^^^^^ expected `usize`, found `G` + error[E0308]: mismatched types --> $DIR/repeat_count.rs:12:17 | @@ -43,40 +49,26 @@ LL | let f = [0; -4_isize]; = note: `-4_isize` cannot fit into type `usize` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:25:23 + --> $DIR/repeat_count.rs:24:23 | -LL | let g = [0_usize; -1_isize]; +LL | let f = [0_usize; -1_isize]; | ^^^^^^^^ expected `usize`, found `isize` | = note: `-1_isize` cannot fit into type `usize` -error: the constant `4` is not of type `usize` - --> $DIR/repeat_count.rs:29:13 - | -LL | let h = [0; 4u8]; - | ^^^^^^^^ expected `usize`, found `u8` - | - = note: the length of array `[{integer}; 4]` must be type `usize` - error[E0308]: mismatched types - --> $DIR/repeat_count.rs:38:17 + --> $DIR/repeat_count.rs:27:17 | -LL | let i = [0; I { i: () }]; - | ^^^^^^^^^^^ expected `usize`, found `I` - -error[E0308]: mismatched types - --> $DIR/repeat_count.rs:29:17 - | -LL | let h = [0; 4u8]; +LL | let f = [0; 4u8]; | ^^^ expected `usize`, found `u8` | help: change the type of the numeric literal from `u8` to `usize` | -LL - let h = [0; 4u8]; -LL + let h = [0; 4usize]; +LL - let f = [0; 4u8]; +LL + let f = [0; 4usize]; | -error: aborting due to 10 previous errors +error: aborting due to 9 previous errors Some errors have detailed explanations: E0308, E0435. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/repr/align-with-extern-c-fn.rs b/tests/ui/repr/align-with-extern-c-fn.rs index a695f4bffe94..4d17d1e8816f 100644 --- a/tests/ui/repr/align-with-extern-c-fn.rs +++ b/tests/ui/repr/align-with-extern-c-fn.rs @@ -1,9 +1,12 @@ //@ run-pass +#![allow(stable_features)] #![allow(unused_variables)] // #45662 +#![feature(repr_align)] + #[repr(align(16))] pub struct A(#[allow(dead_code)] i64); diff --git a/tests/ui/reserved/meta-is-not-reserved.rs b/tests/ui/reserved/meta-is-not-reserved.rs deleted file mode 100644 index ceefe345ff0c..000000000000 --- a/tests/ui/reserved/meta-is-not-reserved.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Regression test for -// A test for the issue where the variable meta is mistakenly treated as a reserved keyword. - -fn main() { - let xyz = meta; - //~^ ERROR cannot find value `meta` in this scope [E0425] -} diff --git a/tests/ui/reserved/meta-is-not-reserved.stderr b/tests/ui/reserved/meta-is-not-reserved.stderr deleted file mode 100644 index 33f8fd82df85..000000000000 --- a/tests/ui/reserved/meta-is-not-reserved.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0425]: cannot find value `meta` in this scope - --> $DIR/meta-is-not-reserved.rs:5:15 - | -LL | let xyz = meta; - | ^^^^ not found in this scope - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/112590-2.fixed b/tests/ui/resolve/112590-2.fixed index 2bda2197d6d4..bbc8d4b2954a 100644 --- a/tests/ui/resolve/112590-2.fixed +++ b/tests/ui/resolve/112590-2.fixed @@ -16,7 +16,7 @@ mod u { use foo::bar::baz::MyVec; fn _a() { - let _: Vec = MyVec::new(); //~ ERROR cannot find + let _: Vec = MyVec::new(); //~ ERROR failed to resolve } } @@ -24,12 +24,12 @@ mod v { use foo::bar::baz::MyVec; fn _b() { - let _: Vec = MyVec::new(); //~ ERROR cannot find + let _: Vec = MyVec::new(); //~ ERROR failed to resolve } } fn main() { - let _t: Vec = Vec::new(); //~ ERROR cannot find - type _B = vec::Vec::; //~ ERROR cannot find - let _t = AtomicBool::new(true); //~ ERROR cannot find + let _t: Vec = Vec::new(); //~ ERROR failed to resolve + type _B = vec::Vec::; //~ ERROR failed to resolve + let _t = AtomicBool::new(true); //~ ERROR failed to resolve } diff --git a/tests/ui/resolve/112590-2.rs b/tests/ui/resolve/112590-2.rs index a458ff501f97..97d0b0bf2a94 100644 --- a/tests/ui/resolve/112590-2.rs +++ b/tests/ui/resolve/112590-2.rs @@ -10,18 +10,18 @@ mod foo { mod u { fn _a() { - let _: Vec = super::foo::baf::baz::MyVec::new(); //~ ERROR cannot find + let _: Vec = super::foo::baf::baz::MyVec::new(); //~ ERROR failed to resolve } } mod v { fn _b() { - let _: Vec = fox::bar::baz::MyVec::new(); //~ ERROR cannot find + let _: Vec = fox::bar::baz::MyVec::new(); //~ ERROR failed to resolve } } fn main() { - let _t: Vec = vec::new(); //~ ERROR cannot find - type _B = vec::Vec::; //~ ERROR cannot find - let _t = std::sync_error::atomic::AtomicBool::new(true); //~ ERROR cannot find + let _t: Vec = vec::new(); //~ ERROR failed to resolve + type _B = vec::Vec::; //~ ERROR failed to resolve + let _t = std::sync_error::atomic::AtomicBool::new(true); //~ ERROR failed to resolve } diff --git a/tests/ui/resolve/112590-2.stderr b/tests/ui/resolve/112590-2.stderr index 8569dd0c3fa0..d6f4a8f22a45 100644 --- a/tests/ui/resolve/112590-2.stderr +++ b/tests/ui/resolve/112590-2.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `baf` in `foo` +error[E0433]: failed to resolve: could not find `baf` in `foo` --> $DIR/112590-2.rs:13:39 | LL | let _: Vec = super::foo::baf::baz::MyVec::new(); @@ -14,7 +14,7 @@ LL - let _: Vec = super::foo::baf::baz::MyVec::new(); LL + let _: Vec = MyVec::new(); | -error[E0433]: cannot find module or crate `fox` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fox` --> $DIR/112590-2.rs:19:27 | LL | let _: Vec = fox::bar::baz::MyVec::new(); @@ -31,7 +31,7 @@ LL - let _: Vec = fox::bar::baz::MyVec::new(); LL + let _: Vec = MyVec::new(); | -error[E0433]: cannot find module or crate `vec` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `vec` --> $DIR/112590-2.rs:25:15 | LL | type _B = vec::Vec::; @@ -43,7 +43,7 @@ help: consider importing this module LL + use std::vec; | -error[E0433]: cannot find `sync_error` in `std` +error[E0433]: failed to resolve: could not find `sync_error` in `std` --> $DIR/112590-2.rs:26:19 | LL | let _t = std::sync_error::atomic::AtomicBool::new(true); @@ -59,7 +59,7 @@ LL - let _t = std::sync_error::atomic::AtomicBool::new(true); LL + let _t = AtomicBool::new(true); | -error[E0433]: cannot find module or crate `vec` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `vec` --> $DIR/112590-2.rs:24:24 | LL | let _t: Vec = vec::new(); diff --git a/tests/ui/resolve/bad-module.rs b/tests/ui/resolve/bad-module.rs index 0d59222e746f..9fe06ab0f52e 100644 --- a/tests/ui/resolve/bad-module.rs +++ b/tests/ui/resolve/bad-module.rs @@ -1,7 +1,7 @@ fn main() { let foo = thing::len(Vec::new()); - //~^ ERROR cannot find module or crate `thing` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `thing` let foo = foo::bar::baz(); - //~^ ERROR cannot find module or crate `foo` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `foo` } diff --git a/tests/ui/resolve/bad-module.stderr b/tests/ui/resolve/bad-module.stderr index 82c93ca973d1..0f597e126fdc 100644 --- a/tests/ui/resolve/bad-module.stderr +++ b/tests/ui/resolve/bad-module.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `foo` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo` --> $DIR/bad-module.rs:5:15 | LL | let foo = foo::bar::baz(); @@ -6,7 +6,7 @@ LL | let foo = foo::bar::baz(); | = help: you might be missing a crate named `foo` -error[E0433]: cannot find module or crate `thing` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `thing` --> $DIR/bad-module.rs:2:15 | LL | let foo = thing::len(Vec::new()); diff --git a/tests/ui/resolve/editions-crate-root-2015.rs b/tests/ui/resolve/editions-crate-root-2015.rs index 163984b4e8f7..a2e19bfdf1c5 100644 --- a/tests/ui/resolve/editions-crate-root-2015.rs +++ b/tests/ui/resolve/editions-crate-root-2015.rs @@ -2,17 +2,17 @@ mod inner { fn global_inner(_: ::nonexistant::Foo) { - //~^ ERROR: cannot find module or crate `nonexistant` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `nonexistant` } fn crate_inner(_: crate::nonexistant::Foo) { - //~^ ERROR: cannot find module or crate `nonexistant` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `nonexistant` } fn bare_global(_: ::nonexistant) { - //~^ ERROR: cannot find type `nonexistant` in the crate root + //~^ ERROR cannot find type `nonexistant` in the crate root } fn bare_crate(_: crate::nonexistant) { - //~^ ERROR: cannot find type `nonexistant` in the crate root + //~^ ERROR cannot find type `nonexistant` in the crate root } } diff --git a/tests/ui/resolve/editions-crate-root-2015.stderr b/tests/ui/resolve/editions-crate-root-2015.stderr index a4002349387a..989ee547a7c6 100644 --- a/tests/ui/resolve/editions-crate-root-2015.stderr +++ b/tests/ui/resolve/editions-crate-root-2015.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `nonexistant` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nonexistant` --> $DIR/editions-crate-root-2015.rs:4:26 | LL | fn global_inner(_: ::nonexistant::Foo) { @@ -9,7 +9,7 @@ help: you might be missing a crate named `nonexistant`, add it to your project a LL + extern crate nonexistant; | -error[E0433]: cannot find module or crate `nonexistant` in `crate` +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nonexistant` --> $DIR/editions-crate-root-2015.rs:7:30 | LL | fn crate_inner(_: crate::nonexistant::Foo) { diff --git a/tests/ui/resolve/editions-crate-root-2018.rs b/tests/ui/resolve/editions-crate-root-2018.rs index c07f617455ef..0e964d20f9c0 100644 --- a/tests/ui/resolve/editions-crate-root-2018.rs +++ b/tests/ui/resolve/editions-crate-root-2018.rs @@ -2,17 +2,17 @@ mod inner { fn global_inner(_: ::nonexistant::Foo) { - //~^ ERROR: cannot find `nonexistant` + //~^ ERROR failed to resolve: could not find `nonexistant` in the list of imported crates } fn crate_inner(_: crate::nonexistant::Foo) { - //~^ ERROR: cannot find `nonexistant` + //~^ ERROR failed to resolve: could not find `nonexistant` in the crate root } fn bare_global(_: ::nonexistant) { - //~^ ERROR: cannot find crate `nonexistant` + //~^ ERROR cannot find crate `nonexistant` in the list of imported crates } fn bare_crate(_: crate::nonexistant) { - //~^ ERROR: cannot find type `nonexistant` in the crate root + //~^ ERROR cannot find type `nonexistant` in the crate root } } diff --git a/tests/ui/resolve/editions-crate-root-2018.stderr b/tests/ui/resolve/editions-crate-root-2018.stderr index c7ce93670051..1bcef3396199 100644 --- a/tests/ui/resolve/editions-crate-root-2018.stderr +++ b/tests/ui/resolve/editions-crate-root-2018.stderr @@ -1,10 +1,10 @@ -error[E0433]: cannot find `nonexistant` in the crate root +error[E0433]: failed to resolve: could not find `nonexistant` in the list of imported crates --> $DIR/editions-crate-root-2018.rs:4:26 | LL | fn global_inner(_: ::nonexistant::Foo) { | ^^^^^^^^^^^ could not find `nonexistant` in the list of imported crates -error[E0433]: cannot find `nonexistant` in `crate` +error[E0433]: failed to resolve: could not find `nonexistant` in the crate root --> $DIR/editions-crate-root-2018.rs:7:30 | LL | fn crate_inner(_: crate::nonexistant::Foo) { diff --git a/tests/ui/resolve/enum-variant-import-2904.rs b/tests/ui/resolve/enum-variant-import-2904.rs deleted file mode 100644 index 3272ee5fb500..000000000000 --- a/tests/ui/resolve/enum-variant-import-2904.rs +++ /dev/null @@ -1,101 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2904 - -//@ build-pass -#![allow(unused_must_use)] -#![allow(dead_code)] -#![allow(unused_mut)] - -// Map representation - -use Square::{Bot, ClosedLift, Earth, Empty, Lambda, OpenLift, Rock, Wall}; -use std::fmt; -use std::io::prelude::*; - -enum Square { - Bot, - Wall, - Rock, - Lambda, - ClosedLift, - OpenLift, - Earth, - Empty, -} - -impl fmt::Debug for Square { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match *self { - Bot => { - "R".to_string() - } - Wall => { - "#".to_string() - } - Rock => { - "*".to_string() - } - Lambda => { - "\\".to_string() - } - ClosedLift => { - "L".to_string() - } - OpenLift => { - "O".to_string() - } - Earth => { - ".".to_string() - } - Empty => { - " ".to_string() - } - } - ) - } -} - -fn square_from_char(c: char) -> Square { - match c { - 'R' => Bot, - '#' => Wall, - '*' => Rock, - '\\' => Lambda, - 'L' => ClosedLift, - 'O' => OpenLift, - '.' => Earth, - ' ' => Empty, - _ => { - println!("invalid Square: {}", c); - panic!() - } - } -} - -fn read_board_grid(mut input: Rdr) -> Vec> { - let mut input: &mut dyn Read = &mut input; - let mut grid = Vec::new(); - let mut line = [0; 10]; - input.read(&mut line); - let mut row = Vec::new(); - for c in &line { - row.push(square_from_char(*c as char)) - } - grid.push(row); - let width = grid[0].len(); - for row in &grid { - assert_eq!(row.len(), width) - } - grid -} - -mod test { - #[test] - pub fn trivial_to_string() { - assert_eq!(Lambda.to_string(), "\\") - } -} - -pub fn main() {} diff --git a/tests/ui/resolve/export-fully-qualified-2018.rs b/tests/ui/resolve/export-fully-qualified-2018.rs index a6121c2e800c..ce78b64bf256 100644 --- a/tests/ui/resolve/export-fully-qualified-2018.rs +++ b/tests/ui/resolve/export-fully-qualified-2018.rs @@ -5,8 +5,7 @@ // want to change eventually. mod foo { - pub fn bar() { foo::baz(); } //~ ERROR: cannot find - //~^ NOTE: use of unresolved module or unlinked crate `foo` + pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of unresolved module or unlinked crate `foo` fn baz() { } } diff --git a/tests/ui/resolve/export-fully-qualified-2018.stderr b/tests/ui/resolve/export-fully-qualified-2018.stderr index 25c9e6fbdab9..a985669b8b41 100644 --- a/tests/ui/resolve/export-fully-qualified-2018.stderr +++ b/tests/ui/resolve/export-fully-qualified-2018.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `foo` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo` --> $DIR/export-fully-qualified-2018.rs:8:20 | LL | pub fn bar() { foo::baz(); } diff --git a/tests/ui/resolve/export-fully-qualified.rs b/tests/ui/resolve/export-fully-qualified.rs index db0570d64f26..0be3b81ebb8f 100644 --- a/tests/ui/resolve/export-fully-qualified.rs +++ b/tests/ui/resolve/export-fully-qualified.rs @@ -5,7 +5,7 @@ // want to change eventually. mod foo { - pub fn bar() { foo::baz(); } //~ ERROR cannot find module or crate `foo` + pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of unresolved module or unlinked crate `foo` fn baz() { } } diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr index f8433dcfb892..e65483e57eb5 100644 --- a/tests/ui/resolve/export-fully-qualified.stderr +++ b/tests/ui/resolve/export-fully-qualified.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `foo` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo` --> $DIR/export-fully-qualified.rs:8:20 | LL | pub fn bar() { foo::baz(); } diff --git a/tests/ui/resolve/exported-macro-in-mod-147958.rs b/tests/ui/resolve/exported-macro-in-mod-147958.rs deleted file mode 100644 index 5003c410b692..000000000000 --- a/tests/ui/resolve/exported-macro-in-mod-147958.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! Regression test for - -//@ check-pass - -#![feature(decl_macro)] - -macro_rules! exported { - () => { - #[macro_export] - macro_rules! exported { - () => {}; - } - }; -} -use inner1::*; -exported!(); -mod inner1 { - pub macro exported() {} -} - -fn main() {} diff --git a/tests/ui/resolve/extern-prelude-fail.rs b/tests/ui/resolve/extern-prelude-fail.rs index d86ee9550b33..7d0df03e57bb 100644 --- a/tests/ui/resolve/extern-prelude-fail.rs +++ b/tests/ui/resolve/extern-prelude-fail.rs @@ -6,5 +6,5 @@ fn main() { use extern_prelude::S; //~ ERROR unresolved import `extern_prelude` - let s = ::extern_prelude::S; //~ ERROR cannot find module or crate `extern_prelude` + let s = ::extern_prelude::S; //~ ERROR failed to resolve } diff --git a/tests/ui/resolve/extern-prelude-fail.stderr b/tests/ui/resolve/extern-prelude-fail.stderr index a6192051e95a..b9668154f446 100644 --- a/tests/ui/resolve/extern-prelude-fail.stderr +++ b/tests/ui/resolve/extern-prelude-fail.stderr @@ -9,7 +9,7 @@ help: you might be missing a crate named `extern_prelude`, add it to your projec LL + extern crate extern_prelude; | -error[E0433]: cannot find module or crate `extern_prelude` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `extern_prelude` --> $DIR/extern-prelude-fail.rs:9:15 | LL | let s = ::extern_prelude::S; diff --git a/tests/ui/resolve/function-module-ambiguity-error-71406.rs b/tests/ui/resolve/function-module-ambiguity-error-71406.rs index 21163e3486b4..a7964de9ba5e 100644 --- a/tests/ui/resolve/function-module-ambiguity-error-71406.rs +++ b/tests/ui/resolve/function-module-ambiguity-error-71406.rs @@ -3,6 +3,5 @@ use std::sync::mpsc; fn main() { let (tx, rx) = mpsc::channel::new(1); - //~^ ERROR: cannot find `channel` - //~| NOTE: expected type, found function `channel` in `mpsc` + //~^ ERROR expected type, found function `channel` in `mpsc` } diff --git a/tests/ui/resolve/function-module-ambiguity-error-71406.stderr b/tests/ui/resolve/function-module-ambiguity-error-71406.stderr index e5b00f294f3c..c25bafa0a5dd 100644 --- a/tests/ui/resolve/function-module-ambiguity-error-71406.stderr +++ b/tests/ui/resolve/function-module-ambiguity-error-71406.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `channel` in `mpsc` +error[E0433]: failed to resolve: expected type, found function `channel` in `mpsc` --> $DIR/function-module-ambiguity-error-71406.rs:5:26 | LL | let (tx, rx) = mpsc::channel::new(1); diff --git a/tests/ui/resolve/ice-inconsistent-resolution-151213.rs b/tests/ui/resolve/ice-inconsistent-resolution-151213.rs deleted file mode 100644 index ea0f1c2858ef..000000000000 --- a/tests/ui/resolve/ice-inconsistent-resolution-151213.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ edition: 2024 - -#[attr] -//~^ ERROR cannot find attribute `attr` in this scope -extern crate core as std; -//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern` - -mod inner { - use std::str; - - use crate::*; -} - -fn main() {} diff --git a/tests/ui/resolve/ice-inconsistent-resolution-151213.stderr b/tests/ui/resolve/ice-inconsistent-resolution-151213.stderr deleted file mode 100644 index deb1e6c3e1cf..000000000000 --- a/tests/ui/resolve/ice-inconsistent-resolution-151213.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/ice-inconsistent-resolution-151213.rs:5:1 - | -LL | extern crate core as std; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: cannot find attribute `attr` in this scope - --> $DIR/ice-inconsistent-resolution-151213.rs:3:3 - | -LL | #[attr] - | ^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/resolve/impl-items-vis-unresolved.rs b/tests/ui/resolve/impl-items-vis-unresolved.rs index bbdc8170d4f6..1494c1cf9680 100644 --- a/tests/ui/resolve/impl-items-vis-unresolved.rs +++ b/tests/ui/resolve/impl-items-vis-unresolved.rs @@ -19,7 +19,7 @@ pub struct RawFloatState; impl RawFloatState { perftools_inline! { pub(super) fn new() {} - //~^ ERROR: too many leading `super` keywords + //~^ ERROR failed to resolve: there are too many leading `super` keywords } } diff --git a/tests/ui/resolve/impl-items-vis-unresolved.stderr b/tests/ui/resolve/impl-items-vis-unresolved.stderr index e433cb607cda..cccffdcbf541 100644 --- a/tests/ui/resolve/impl-items-vis-unresolved.stderr +++ b/tests/ui/resolve/impl-items-vis-unresolved.stderr @@ -1,4 +1,4 @@ -error[E0433]: too many leading `super` keywords +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/impl-items-vis-unresolved.rs:21:13 | LL | pub(super) fn new() {} diff --git a/tests/ui/resolve/issue-101749-2.rs b/tests/ui/resolve/issue-101749-2.rs index 60846713f63f..636ff07c71ce 100644 --- a/tests/ui/resolve/issue-101749-2.rs +++ b/tests/ui/resolve/issue-101749-2.rs @@ -12,5 +12,5 @@ fn main() { let rect = Rectangle::new(3, 4); // `area` is not implemented for `Rectangle`, so this should not suggest let _ = rect::area(); - //~^ ERROR: cannot find module or crate `rect` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `rect` } diff --git a/tests/ui/resolve/issue-101749-2.stderr b/tests/ui/resolve/issue-101749-2.stderr index f8ed9ceb830d..96a20b4bf5a0 100644 --- a/tests/ui/resolve/issue-101749-2.stderr +++ b/tests/ui/resolve/issue-101749-2.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `rect` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rect` --> $DIR/issue-101749-2.rs:14:13 | LL | let _ = rect::area(); diff --git a/tests/ui/resolve/issue-101749.fixed b/tests/ui/resolve/issue-101749.fixed index ebd6533fe0e0..3244ad7a0313 100644 --- a/tests/ui/resolve/issue-101749.fixed +++ b/tests/ui/resolve/issue-101749.fixed @@ -15,5 +15,5 @@ impl Rectangle { fn main() { let rect = Rectangle::new(3, 4); let _ = rect.area(); - //~^ ERROR: cannot find module or crate `rect` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `rect` } diff --git a/tests/ui/resolve/issue-101749.rs b/tests/ui/resolve/issue-101749.rs index 4c1a2e0f4403..c977df41d2f5 100644 --- a/tests/ui/resolve/issue-101749.rs +++ b/tests/ui/resolve/issue-101749.rs @@ -15,5 +15,5 @@ impl Rectangle { fn main() { let rect = Rectangle::new(3, 4); let _ = rect::area(); - //~^ ERROR: cannot find module or crate `rect` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `rect` } diff --git a/tests/ui/resolve/issue-101749.stderr b/tests/ui/resolve/issue-101749.stderr index 8a508f590161..09e800ec7c31 100644 --- a/tests/ui/resolve/issue-101749.stderr +++ b/tests/ui/resolve/issue-101749.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `rect` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rect` --> $DIR/issue-101749.rs:17:13 | LL | let _ = rect::area(); diff --git a/tests/ui/resolve/issue-109250.rs b/tests/ui/resolve/issue-109250.rs index 99fcae9647bf..68e33f693cef 100644 --- a/tests/ui/resolve/issue-109250.rs +++ b/tests/ui/resolve/issue-109250.rs @@ -1,3 +1,3 @@ fn main() { //~ HELP consider importing - HashMap::new; //~ ERROR cannot find type `HashMap` + HashMap::new; //~ ERROR failed to resolve: use of undeclared type `HashMap` } diff --git a/tests/ui/resolve/issue-109250.stderr b/tests/ui/resolve/issue-109250.stderr index d631232f73bf..ad6cc6986229 100644 --- a/tests/ui/resolve/issue-109250.stderr +++ b/tests/ui/resolve/issue-109250.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `HashMap` in this scope +error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/issue-109250.rs:2:5 | LL | HashMap::new; diff --git a/tests/ui/resolve/issue-117920.rs b/tests/ui/resolve/issue-117920.rs index 6fbc412001f5..928f194c59c3 100644 --- a/tests/ui/resolve/issue-117920.rs +++ b/tests/ui/resolve/issue-117920.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -use super::A; //~ ERROR too many leading `super` keywords +use super::A; //~ ERROR failed to resolve mod b { pub trait A {} diff --git a/tests/ui/resolve/issue-117920.stderr b/tests/ui/resolve/issue-117920.stderr index 810c2c06efe7..c4528d467e9f 100644 --- a/tests/ui/resolve/issue-117920.stderr +++ b/tests/ui/resolve/issue-117920.stderr @@ -1,4 +1,4 @@ -error[E0433]: too many leading `super` keywords +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/issue-117920.rs:3:5 | LL | use super::A; diff --git a/tests/ui/resolve/issue-24968.rs b/tests/ui/resolve/issue-24968.rs index 22f5ea520467..19e16abcee3c 100644 --- a/tests/ui/resolve/issue-24968.rs +++ b/tests/ui/resolve/issue-24968.rs @@ -19,12 +19,12 @@ const FOO: Self = 0; //~^ ERROR cannot find type `Self` const FOO2: u32 = Self::bar(); -//~^ ERROR cannot find `Self` +//~^ ERROR failed to resolve: `Self` static FOO_S: Self = 0; //~^ ERROR cannot find type `Self` static FOO_S2: u32 = Self::bar(); -//~^ ERROR cannot find `Self` +//~^ ERROR failed to resolve: `Self` fn main() {} diff --git a/tests/ui/resolve/issue-24968.stderr b/tests/ui/resolve/issue-24968.stderr index ce8ded2714f4..82f5a1d5b57b 100644 --- a/tests/ui/resolve/issue-24968.stderr +++ b/tests/ui/resolve/issue-24968.stderr @@ -39,13 +39,13 @@ LL | static FOO_S: Self = 0; | | | `Self` not allowed in a static item -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/issue-24968.rs:21:19 | LL | const FOO2: u32 = Self::bar(); | ^^^^ `Self` is only available in impls, traits, and type definitions -error[E0433]: cannot find `Self` in this scope +error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions --> $DIR/issue-24968.rs:27:22 | LL | static FOO_S2: u32 = Self::bar(); diff --git a/tests/ui/resolve/issue-81508.rs b/tests/ui/resolve/issue-81508.rs index 96d5f52feba0..23605cd2fd91 100644 --- a/tests/ui/resolve/issue-81508.rs +++ b/tests/ui/resolve/issue-81508.rs @@ -8,7 +8,7 @@ fn main() { let Baz: &str = ""; - println!("{}", Baz::Bar); //~ ERROR: cannot find type `Baz` + println!("{}", Baz::Bar); //~ ERROR: failed to resolve: use of undeclared type `Baz` } #[allow(non_upper_case_globals)] @@ -17,6 +17,6 @@ pub const Foo: &str = ""; mod submod { use super::Foo; fn function() { - println!("{}", Foo::Bar); //~ ERROR: cannot find type `Foo` + println!("{}", Foo::Bar); //~ ERROR: failed to resolve: use of undeclared type `Foo` } } diff --git a/tests/ui/resolve/issue-81508.stderr b/tests/ui/resolve/issue-81508.stderr index 49fe9fbf6211..7258174ba89b 100644 --- a/tests/ui/resolve/issue-81508.stderr +++ b/tests/ui/resolve/issue-81508.stderr @@ -1,14 +1,20 @@ -error[E0433]: cannot find type `Baz` in this scope +error[E0433]: failed to resolve: use of undeclared type `Baz` --> $DIR/issue-81508.rs:11:20 | +LL | let Baz: &str = ""; + | --- help: `Baz` is defined here, but is not a type +LL | LL | println!("{}", Baz::Bar); - | ^^^ `Baz` is declared as a local binding at `issue-81508.rs:9:9`, not a type + | ^^^ use of undeclared type `Baz` -error[E0433]: cannot find type `Foo` in this scope +error[E0433]: failed to resolve: use of undeclared type `Foo` --> $DIR/issue-81508.rs:20:24 | +LL | use super::Foo; + | ---------- help: `Foo` is defined here, but is not a type +LL | fn function() { LL | println!("{}", Foo::Bar); - | ^^^ `Foo` is declared as a constant at `issue-81508.rs:18:9`, not a type + | ^^^ use of undeclared type `Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/issue-82156.rs b/tests/ui/resolve/issue-82156.rs index fc6840faf636..6215259e4865 100644 --- a/tests/ui/resolve/issue-82156.rs +++ b/tests/ui/resolve/issue-82156.rs @@ -1,3 +1,3 @@ fn main() { - super(); //~ ERROR: too many leading `super` keywords + super(); //~ ERROR failed to resolve: there are too many leading `super` keywords } diff --git a/tests/ui/resolve/issue-82156.stderr b/tests/ui/resolve/issue-82156.stderr index 6fe0d4c4ea15..3894b9573a45 100644 --- a/tests/ui/resolve/issue-82156.stderr +++ b/tests/ui/resolve/issue-82156.stderr @@ -1,4 +1,4 @@ -error[E0433]: too many leading `super` keywords +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/issue-82156.rs:2:5 | LL | super(); diff --git a/tests/ui/resolve/issue-82865.rs b/tests/ui/resolve/issue-82865.rs index 545ca63e0b82..30084b133e0f 100644 --- a/tests/ui/resolve/issue-82865.rs +++ b/tests/ui/resolve/issue-82865.rs @@ -3,7 +3,7 @@ #![feature(decl_macro)] -use x::y::z; //~ ERROR: cannot find module or crate `x` +use x::y::z; //~ ERROR: failed to resolve: use of unresolved module or unlinked crate `x` macro mac () { Box::z //~ ERROR: no function or associated item diff --git a/tests/ui/resolve/issue-82865.stderr b/tests/ui/resolve/issue-82865.stderr index 90059ad5a965..c9184bafd4c9 100644 --- a/tests/ui/resolve/issue-82865.stderr +++ b/tests/ui/resolve/issue-82865.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `x` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `x` --> $DIR/issue-82865.rs:6:5 | LL | use x::y::z; diff --git a/tests/ui/resolve/missing-in-namespace.rs b/tests/ui/resolve/missing-in-namespace.rs index f54d478eb03a..e1dedb072b77 100644 --- a/tests/ui/resolve/missing-in-namespace.rs +++ b/tests/ui/resolve/missing-in-namespace.rs @@ -1,4 +1,4 @@ fn main() { let _map = std::hahmap::HashMap::new(); - //~^ ERROR: cannot find `hahmap` in `std + //~^ ERROR failed to resolve: could not find `hahmap` in `std } diff --git a/tests/ui/resolve/missing-in-namespace.stderr b/tests/ui/resolve/missing-in-namespace.stderr index cefcc097b1db..35585e4240a2 100644 --- a/tests/ui/resolve/missing-in-namespace.stderr +++ b/tests/ui/resolve/missing-in-namespace.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `hahmap` in `std` +error[E0433]: failed to resolve: could not find `hahmap` in `std` --> $DIR/missing-in-namespace.rs:2:21 | LL | let _map = std::hahmap::HashMap::new(); diff --git a/tests/ui/resolve/prelude-order.rs b/tests/ui/resolve/prelude-order.rs index 9bc3793dbf20..c6683bdff22a 100644 --- a/tests/ui/resolve/prelude-order.rs +++ b/tests/ui/resolve/prelude-order.rs @@ -59,7 +59,7 @@ extern crate macro_helpers as _; /* lang and libs implicitly in scope */ // tool/extern -> extern -#[type_ns::inner] //~ ERROR cannot find `inner` in `type_ns` +#[type_ns::inner] //~ ERROR could not find `inner` in `type_ns` fn t1() {} // tool/lang -> tool @@ -71,7 +71,7 @@ fn t2() {} fn t3() {} // extern/lang -> extern -#[usize::inner] //~ ERROR cannot find `inner` in `usize` +#[usize::inner] //~ ERROR could not find `inner` in `usize` fn e1() {} // NOTE: testing with `-> usize` isn't valid, crates aren't considered in that scope // (unless they have generic arguments, for some reason.) diff --git a/tests/ui/resolve/prelude-order.stderr b/tests/ui/resolve/prelude-order.stderr index c7929bf74d51..4dad39fb6d24 100644 --- a/tests/ui/resolve/prelude-order.stderr +++ b/tests/ui/resolve/prelude-order.stderr @@ -1,10 +1,10 @@ -error[E0433]: cannot find `inner` in `type_ns` +error[E0433]: failed to resolve: could not find `inner` in `type_ns` --> $DIR/prelude-order.rs:62:12 | LL | #[type_ns::inner] | ^^^^^ could not find `inner` in `type_ns` -error[E0433]: cannot find `inner` in `usize` +error[E0433]: failed to resolve: could not find `inner` in `usize` --> $DIR/prelude-order.rs:74:10 | LL | #[usize::inner] diff --git a/tests/ui/resolve/query-cycle-issue-124901.rs b/tests/ui/resolve/query-cycle-issue-124901.rs index 6cb1e58b6258..ccaee0e6bc6f 100644 --- a/tests/ui/resolve/query-cycle-issue-124901.rs +++ b/tests/ui/resolve/query-cycle-issue-124901.rs @@ -1,4 +1,4 @@ -//~ ERROR: cycle detected when looking up span for `Default` +//~ ERROR: cycle detected when getting HIR ID of `Default` trait Default { type Id; diff --git a/tests/ui/resolve/query-cycle-issue-124901.stderr b/tests/ui/resolve/query-cycle-issue-124901.stderr index 9c1d7b1de33a..3679925c6db4 100644 --- a/tests/ui/resolve/query-cycle-issue-124901.stderr +++ b/tests/ui/resolve/query-cycle-issue-124901.stderr @@ -1,7 +1,10 @@ -error[E0391]: cycle detected when looking up span for `Default` +error[E0391]: cycle detected when getting HIR ID of `Default` | - = note: ...which immediately requires looking up span for `Default` again - = note: cycle used when perform lints prior to AST lowering + = note: ...which requires getting the crate HIR... + = note: ...which requires perform lints prior to AST lowering... + = note: ...which requires looking up span for `Default`... + = note: ...which again requires getting HIR ID of `Default`, completing the cycle + = note: cycle used when getting the resolver for lowering = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-assoc-suggestions.stderr b/tests/ui/resolve/resolve-assoc-suggestions.stderr index e6311962884f..7d94fb5ca35f 100644 --- a/tests/ui/resolve/resolve-assoc-suggestions.stderr +++ b/tests/ui/resolve/resolve-assoc-suggestions.stderr @@ -41,22 +41,12 @@ error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope | LL | let Type(..); | ^^^^ not found in this scope - | -help: consider importing this tuple variant - | -LL + use std::mem::type_info::Generic::Type; - | error[E0425]: cannot find value `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:27:9 | LL | Type; | ^^^^ not found in this scope - | -help: consider importing this tuple variant - | -LL + use std::mem::type_info::Generic::Type; - | error[E0425]: cannot find type `method` in this scope --> $DIR/resolve-assoc-suggestions.rs:30:16 diff --git a/tests/ui/resolve/resolve-bad-visibility.rs b/tests/ui/resolve/resolve-bad-visibility.rs index 55e381e8be1a..81635611fca9 100644 --- a/tests/ui/resolve/resolve-bad-visibility.rs +++ b/tests/ui/resolve/resolve-bad-visibility.rs @@ -5,8 +5,8 @@ trait Tr {} pub(in E) struct S; //~ ERROR expected module, found enum `E` pub(in Tr) struct Z; //~ ERROR expected module, found trait `Tr` pub(in std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules -pub(in nonexistent) struct G; //~ ERROR cannot find -pub(in too_soon) struct H; //~ ERROR cannot find +pub(in nonexistent) struct G; //~ ERROR failed to resolve +pub(in too_soon) struct H; //~ ERROR failed to resolve // Visibilities are resolved eagerly without waiting for modules becoming fully populated. // Visibilities can only use ancestor modules legally which are always available in time, diff --git a/tests/ui/resolve/resolve-bad-visibility.stderr b/tests/ui/resolve/resolve-bad-visibility.stderr index 4530757c3de5..c7bbdfbd2495 100644 --- a/tests/ui/resolve/resolve-bad-visibility.stderr +++ b/tests/ui/resolve/resolve-bad-visibility.stderr @@ -16,7 +16,7 @@ error[E0742]: visibilities can only be restricted to ancestor modules LL | pub(in std::vec) struct F; | ^^^^^^^^ -error[E0433]: cannot find module or crate `nonexistent` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nonexistent` --> $DIR/resolve-bad-visibility.rs:8:8 | LL | pub(in nonexistent) struct G; @@ -27,7 +27,7 @@ help: you might be missing a crate named `nonexistent`, add it to your project a LL + extern crate nonexistent; | -error[E0433]: cannot find module or crate `too_soon` in the crate root +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `too_soon` --> $DIR/resolve-bad-visibility.rs:9:8 | LL | pub(in too_soon) struct H; diff --git a/tests/ui/resolve/resolve-variant-assoc-item.rs b/tests/ui/resolve/resolve-variant-assoc-item.rs index edf97daa172a..7671dddc819b 100644 --- a/tests/ui/resolve/resolve-variant-assoc-item.rs +++ b/tests/ui/resolve/resolve-variant-assoc-item.rs @@ -3,6 +3,6 @@ enum E { V } use E::V; fn main() { - E::V::associated_item; //~ ERROR: cannot find - V::associated_item; //~ ERROR: cannot find + E::V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module + V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module } diff --git a/tests/ui/resolve/resolve-variant-assoc-item.stderr b/tests/ui/resolve/resolve-variant-assoc-item.stderr index 460cea2dfb91..5528bb2495b5 100644 --- a/tests/ui/resolve/resolve-variant-assoc-item.stderr +++ b/tests/ui/resolve/resolve-variant-assoc-item.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module `V` in `E` +error[E0433]: failed to resolve: `V` is a variant, not a module --> $DIR/resolve-variant-assoc-item.rs:6:8 | LL | E::V::associated_item; @@ -10,7 +10,7 @@ LL - E::V::associated_item; LL + E::associated_item; | -error[E0433]: cannot find module `V` in this scope +error[E0433]: failed to resolve: `V` is a variant, not a module --> $DIR/resolve-variant-assoc-item.rs:7:5 | LL | V::associated_item; diff --git a/tests/ui/resolve/tool-import.rs b/tests/ui/resolve/tool-import.rs index bc34a64e7f93..951505b92a0b 100644 --- a/tests/ui/resolve/tool-import.rs +++ b/tests/ui/resolve/tool-import.rs @@ -1,8 +1,7 @@ //@ edition: 2018 use clippy::time::Instant; -//~^ ERROR: cannot find module `clippy` -//~| NOTE: `clippy` is a tool module +//~^ ERROR `clippy` is a tool module fn main() { Instant::now(); diff --git a/tests/ui/resolve/tool-import.stderr b/tests/ui/resolve/tool-import.stderr index 02e4432fd9e5..b070439d72b7 100644 --- a/tests/ui/resolve/tool-import.stderr +++ b/tests/ui/resolve/tool-import.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module `clippy` in this scope +error[E0433]: failed to resolve: `clippy` is a tool module, not a module --> $DIR/tool-import.rs:3:5 | LL | use clippy::time::Instant; diff --git a/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs b/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs index 706564dc9b21..188e2ca7f113 100644 --- a/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs +++ b/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs @@ -25,18 +25,18 @@ fn main() { //~| NOTE function or associated item not found in `Struct` Struc::foo(); - //~^ ERROR cannot find type `Struc` + //~^ ERROR failed to resolve: use of undeclared type `Struc` //~| NOTE use of undeclared type `Struc` modul::foo(); - //~^ ERROR cannot find module or crate `modul` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `modul` //~| NOTE use of unresolved module or unlinked crate `modul` module::Struc::foo(); - //~^ ERROR cannot find `Struc` in `module` + //~^ ERROR failed to resolve: could not find `Struc` in `module` //~| NOTE could not find `Struc` in `module` Trai::foo(); - //~^ ERROR cannot find type `Trai` + //~^ ERROR failed to resolve: use of undeclared type `Trai` //~| NOTE use of undeclared type `Trai` } diff --git a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr index b1afa703eb03..fef1f52b86b7 100644 --- a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr +++ b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `Struc` in `module` +error[E0433]: failed to resolve: could not find `Struc` in `module` --> $DIR/typo-suggestion-mistyped-in-path.rs:35:13 | LL | module::Struc::foo(); @@ -24,7 +24,7 @@ LL - Struct::fob(); LL + Struct::foo(); | -error[E0433]: cannot find type `Struc` in this scope +error[E0433]: failed to resolve: use of undeclared type `Struc` --> $DIR/typo-suggestion-mistyped-in-path.rs:27:5 | LL | Struc::foo(); @@ -35,7 +35,7 @@ help: a struct with a similar name exists LL | Struct::foo(); | + -error[E0433]: cannot find module or crate `modul` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `modul` --> $DIR/typo-suggestion-mistyped-in-path.rs:31:5 | LL | modul::foo(); @@ -46,7 +46,7 @@ help: there is a crate or module with a similar name LL | module::foo(); | + -error[E0433]: cannot find type `Trai` in this scope +error[E0433]: failed to resolve: use of undeclared type `Trai` --> $DIR/typo-suggestion-mistyped-in-path.rs:39:5 | LL | Trai::foo(); diff --git a/tests/ui/resolve/underscore-bindings-disambiguators.stderr b/tests/ui/resolve/underscore-bindings-disambiguators.stderr index 9208b84c43a2..ec14ede03e3f 100644 --- a/tests/ui/resolve/underscore-bindings-disambiguators.stderr +++ b/tests/ui/resolve/underscore-bindings-disambiguators.stderr @@ -21,36 +21,48 @@ error[E0080]: evaluation panicked: not yet implemented | LL | const _: () = todo!(); | ^^^^^^^ evaluation of `impls::_` failed here + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: not yet implemented --> $DIR/underscore-bindings-disambiguators.rs:20:19 | LL | const _: () = todo!(); | ^^^^^^^ evaluation of `impls::_` failed here + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: not yet implemented --> $DIR/underscore-bindings-disambiguators.rs:21:19 | LL | const _: () = todo!(); | ^^^^^^^ evaluation of `impls::_` failed here + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: not yet implemented --> $DIR/underscore-bindings-disambiguators.rs:22:19 | LL | const _: () = todo!(); | ^^^^^^^ evaluation of `impls::_` failed here + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: not yet implemented --> $DIR/underscore-bindings-disambiguators.rs:23:19 | LL | const _: () = todo!(); | ^^^^^^^ evaluation of `impls::_` failed here + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation panicked: not yet implemented --> $DIR/underscore-bindings-disambiguators.rs:28:15 | LL | const _: () = todo!(); | ^^^^^^^ evaluation of `_` failed here + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors diff --git a/tests/ui/resolve/unresolved-module-error-33293.rs b/tests/ui/resolve/unresolved-module-error-33293.rs index 18906e610dca..354f9914d443 100644 --- a/tests/ui/resolve/unresolved-module-error-33293.rs +++ b/tests/ui/resolve/unresolved-module-error-33293.rs @@ -2,6 +2,6 @@ fn main() { match 0 { aaa::bbb(_) => () - //~^ ERROR: cannot find module or crate `aaa` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `aaa` }; } diff --git a/tests/ui/resolve/unresolved-module-error-33293.stderr b/tests/ui/resolve/unresolved-module-error-33293.stderr index e119a69d2cc2..28528148387f 100644 --- a/tests/ui/resolve/unresolved-module-error-33293.stderr +++ b/tests/ui/resolve/unresolved-module-error-33293.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `aaa` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `aaa` --> $DIR/unresolved-module-error-33293.rs:4:9 | LL | aaa::bbb(_) => () diff --git a/tests/ui/resolve/unresolved-segments-visibility.rs b/tests/ui/resolve/unresolved-segments-visibility.rs index b9695de1e999..fc86b31adfc2 100644 --- a/tests/ui/resolve/unresolved-segments-visibility.rs +++ b/tests/ui/resolve/unresolved-segments-visibility.rs @@ -6,7 +6,6 @@ extern crate alloc as b; mod foo { mod bar { pub(in crate::b::string::String::newy) extern crate alloc as e; - //~^ ERROR: cannot find module `String` in `string` [E0433] - //~| NOTE: `String` is a struct, not a module + //~^ ERROR failed to resolve: `String` is a struct, not a module [E0433] } } diff --git a/tests/ui/resolve/unresolved-segments-visibility.stderr b/tests/ui/resolve/unresolved-segments-visibility.stderr index bfefdd6449d4..082579c9fa11 100644 --- a/tests/ui/resolve/unresolved-segments-visibility.stderr +++ b/tests/ui/resolve/unresolved-segments-visibility.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module `String` in `string` +error[E0433]: failed to resolve: `String` is a struct, not a module --> $DIR/unresolved-segments-visibility.rs:8:34 | LL | pub(in crate::b::string::String::newy) extern crate alloc as e; diff --git a/tests/ui/resolve/use_suggestion.rs b/tests/ui/resolve/use_suggestion.rs index a23a61a39b84..8c9bc6d76b8b 100644 --- a/tests/ui/resolve/use_suggestion.rs +++ b/tests/ui/resolve/use_suggestion.rs @@ -1,6 +1,6 @@ fn main() { - let x1 = HashMap::new(); //~ ERROR cannot find - let x2 = GooMap::new(); //~ ERROR cannot find + let x1 = HashMap::new(); //~ ERROR failed to resolve + let x2 = GooMap::new(); //~ ERROR failed to resolve let y1: HashMap; //~ ERROR cannot find type let y2: GooMap; //~ ERROR cannot find type diff --git a/tests/ui/resolve/use_suggestion.stderr b/tests/ui/resolve/use_suggestion.stderr index 98ef142e6b9c..9981c97b2c17 100644 --- a/tests/ui/resolve/use_suggestion.stderr +++ b/tests/ui/resolve/use_suggestion.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `HashMap` in this scope +error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/use_suggestion.rs:2:14 | LL | let x1 = HashMap::new(); @@ -26,7 +26,7 @@ error[E0425]: cannot find type `GooMap` in this scope LL | let y2: GooMap; | ^^^^^^ not found in this scope -error[E0433]: cannot find type `GooMap` in this scope +error[E0433]: failed to resolve: use of undeclared type `GooMap` --> $DIR/use_suggestion.rs:3:14 | LL | let x2 = GooMap::new(); diff --git a/tests/ui/resolve/visibility-indeterminate.rs b/tests/ui/resolve/visibility-indeterminate.rs index 8033a30b233c..181bb2907743 100644 --- a/tests/ui/resolve/visibility-indeterminate.rs +++ b/tests/ui/resolve/visibility-indeterminate.rs @@ -2,6 +2,6 @@ foo!(); //~ ERROR cannot find macro `foo` in this scope -pub(in ::bar) struct Baz {} //~ ERROR cannot find `bar` +pub(in ::bar) struct Baz {} //~ ERROR failed to resolve: could not find `bar` in the list of imported crates fn main() {} diff --git a/tests/ui/resolve/visibility-indeterminate.stderr b/tests/ui/resolve/visibility-indeterminate.stderr index bd6fc11b6731..bbe28747f7c0 100644 --- a/tests/ui/resolve/visibility-indeterminate.stderr +++ b/tests/ui/resolve/visibility-indeterminate.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `bar` in the crate root +error[E0433]: failed to resolve: could not find `bar` in the list of imported crates --> $DIR/visibility-indeterminate.rs:5:10 | LL | pub(in ::bar) struct Baz {} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/diverge-causes-unreachable-code.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/diverge-causes-unreachable-code.stderr index a55d540dc7f2..c33a5855d506 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/diverge-causes-unreachable-code.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/diverge-causes-unreachable-code.stderr @@ -11,6 +11,7 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::print` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/diverge-causes-unreachable-code.rs:16:5 @@ -19,6 +20,8 @@ LL | fn ref_never_arg(&!: &Void) -> u32 { | -- any code following a never pattern is unreachable LL | println!(); | ^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `$crate::print` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/diverge-causes-unreachable-code.rs:25:5 @@ -28,6 +31,8 @@ LL | let ! = *ptr; LL | } LL | println!(); | ^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `$crate::print` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/diverge-causes-unreachable-code.rs:34:5 @@ -37,6 +42,8 @@ LL | match *ptr { ! }; LL | } LL | println!(); | ^^^^^^^^^^ unreachable statement + | + = note: this error originates in the macro `$crate::print` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs index 35a2ef10c2e3..26fa6fdb57f9 100644 --- a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs @@ -9,5 +9,6 @@ static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = //~^ ERROR missing lifetime specifier [E0106] &(non_elidable as fn(&u8, &u8) -> &u8); //~^ ERROR missing lifetime specifier [E0106] + //~| ERROR non-primitive cast fn main() {} diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr index 05ea6e44486f..77fc3f0412eb 100644 --- a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr @@ -23,6 +23,13 @@ help: consider making the type lifetime-generic with a new `'a` lifetime LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); | +++++++ ++ ++ ++ -error: aborting due to 2 previous errors +error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` + --> $DIR/rfc1623-3.rs:10:6 + | +LL | &(non_elidable as fn(&u8, &u8) -> &u8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0106, E0605. +For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/rfcs/rfc-1861-extern-types/comparison.rs b/tests/ui/rfcs/rfc-1861-extern-types/comparison.rs deleted file mode 100644 index 6504fd64f64d..000000000000 --- a/tests/ui/rfcs/rfc-1861-extern-types/comparison.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Foreign type tests not covering all operations -//@ only-nightly -//@ build-pass - -#![feature(extern_types)] - -#![allow(ambiguous_wide_pointer_comparisons)] - -extern "C" { - type ForeignType; -} - -#[repr(C)] -struct Example { - field: ForeignType, -} - -fn main() { - // pointer comparison - let a = std::ptr::null::(); - let b = std::ptr::null::(); - - assert!(a == b); - - // field address computation - let p = std::ptr::null::(); - unsafe { - let _ = &(*p).field; - } - - // pointer casts involving extern types - let raw = std::ptr::null::<()>(); - let ext = raw as *const ForeignType; - let _ = ext as *const (); -} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs index 2e40819d69ad..b2ebab382bd9 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs @@ -14,6 +14,11 @@ enum Local { Variant(u32), } +#[non_exhaustive] +enum LocalNonExhaustive { + Variant(u32), +} + fn main() { let mut x = ExhaustiveMonovariant::Variant(1); let y = &mut x; @@ -29,4 +34,11 @@ fn main() { _ => {}, } drop(y); + let mut x = LocalNonExhaustive::Variant(1); + let y = &mut x; + match x { + LocalNonExhaustive::Variant(_) => {}, + _ => {}, + } + drop(y); } diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs index a6a369e92a6c..d616f5e5e89a 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs @@ -6,11 +6,6 @@ extern crate monovariants; use monovariants::NonExhaustiveMonovariant; -#[non_exhaustive] -enum LocalNonExhaustive { - Variant(u32), -} - fn main() { let mut x = NonExhaustiveMonovariant::Variant(1); let y = &mut x; @@ -20,11 +15,4 @@ fn main() { _ => {}, } drop(y); - let mut x = LocalNonExhaustive::Variant(1); - let y = &mut x; - match x { //~ ERROR cannot use `x` because it was mutably borrowed - LocalNonExhaustive::Variant(_) => {}, - _ => {}, - } - drop(y); } diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr index d6225adc95cb..70f5b2b84d86 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr @@ -1,5 +1,5 @@ error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-non-exhaustive.rs:17:11 + --> $DIR/borrowck-non-exhaustive.rs:12:11 | LL | let y = &mut x; | ------ `x` is borrowed here @@ -9,17 +9,6 @@ LL | match x { LL | drop(y); | - borrow later used here -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-non-exhaustive.rs:25:11 - | -LL | let y = &mut x; - | ------ `x` is borrowed here -LL | match x { - | ^ use of borrowed `x` -... -LL | drop(y); - | - borrow later used here - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0503`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr index d711c3f2eb12..98e8f1235e6b 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr @@ -21,7 +21,7 @@ error: `#[non_exhaustive]` attribute cannot be used on unions LL | #[non_exhaustive] | ^^^^^^^^^^^^^^^^^ | - = help: `#[non_exhaustive]` can be applied to enum variants, enums, and structs + = help: `#[non_exhaustive]` can be applied to data types and enum variants error: aborting due to 3 previous errors diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs index 95486e37b691..efadddf3ef1d 100644 --- a/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs +++ b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs @@ -3,8 +3,8 @@ struct S; pub mod m { fn f() { - let s = ::m::crate::S; //~ ERROR: `crate` in paths can only be used in start position - let s1 = ::crate::S; //~ ERROR: global paths cannot start with `crate` + let s = ::m::crate::S; //~ ERROR failed to resolve + let s1 = ::crate::S; //~ ERROR failed to resolve let s2 = crate::S; // no error } } diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr index a267c037d1ff..6cb96e5762ad 100644 --- a/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr +++ b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr @@ -1,14 +1,14 @@ -error[E0433]: `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/crate-path-non-absolute.rs:6:22 | LL | let s = ::m::crate::S; - | ^^^^^ can only be used in path start position + | ^^^^^ `crate` in paths can only be used in start position -error[E0433]: global paths cannot start with `crate` +error[E0433]: failed to resolve: global paths cannot start with `crate` --> $DIR/crate-path-non-absolute.rs:7:20 | LL | let s1 = ::crate::S; - | ^^^^^ cannot start with this + | ^^^^^ global paths cannot start with `crate` error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs index f8450d2ba009..6bbfb69800e1 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs @@ -2,5 +2,5 @@ fn main() { let s = ::xcrate::S; - //~^ ERROR cannot find `xcrate` + //~^ ERROR failed to resolve: could not find `xcrate` in the list of imported crates } diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr index 553365c93223..e3875fd843b6 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `xcrate` in the crate root +error[E0433]: failed to resolve: could not find `xcrate` in the list of imported crates --> $DIR/non-existent-2.rs:4:15 | LL | let s = ::xcrate::S; diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr index f8ef315b9cc7..f515cb62c7cd 100644 --- a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -8,6 +8,7 @@ LL | let _ = dbg!(a); LL | let _ = dbg!(a); | ^^^^^^^ value used here after move | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider borrowing instead of transferring ownership | LL | let _ = dbg!(&a); diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index 4cdeb184bd91..4e0ae9184150 100644 --- a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -5,6 +5,7 @@ LL | let _: NotDebug = dbg!(NotDebug); | ^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `NotDebug` | = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NotDebug` with `#[derive(Debug)]` | LL + #[derive(Debug)] diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr index c234cb31bc56..cc08307a18d0 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -389,7 +389,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions = note: requested on the command line with `-W unused-attributes` warning: `#[no_mangle]` attribute cannot be used on function params @@ -408,7 +408,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:70:9 @@ -426,7 +426,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:89:9 @@ -444,7 +444,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:114:9 @@ -462,7 +462,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:137:9 @@ -480,7 +480,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:156:9 @@ -498,7 +498,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:180:9 @@ -516,7 +516,7 @@ LL | #[must_use] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = help: `#[must_use]` can be applied to data types, functions, and traits + = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[no_mangle]` attribute cannot be used on function params --> $DIR/param-attrs-builtin-attrs.rs:201:9 diff --git a/tests/ui/rust-2024/unsafe-before_exec-suggestion.fixed b/tests/ui/rust-2024/unsafe-before_exec-suggestion.fixed deleted file mode 100644 index d850428cc1a5..000000000000 --- a/tests/ui/rust-2024/unsafe-before_exec-suggestion.fixed +++ /dev/null @@ -1,18 +0,0 @@ -//@ edition:2015 -//@ only-unix -//@ run-rustfix - -#![deny(deprecated_safe_2024)] - -use std::process::Command; -use std::os::unix::process::CommandExt; - -#[allow(deprecated)] -fn main() { - let mut cmd = Command::new("sleep"); - // TODO: Audit that the closure is async-signal-safe. - unsafe { cmd.before_exec(|| Ok(())) }; - //~^ ERROR call to deprecated safe function - //~| WARN this is accepted in the current edition - drop(cmd); -} diff --git a/tests/ui/rust-2024/unsafe-before_exec-suggestion.rs b/tests/ui/rust-2024/unsafe-before_exec-suggestion.rs deleted file mode 100644 index c6894ea631ae..000000000000 --- a/tests/ui/rust-2024/unsafe-before_exec-suggestion.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ edition:2015 -//@ only-unix -//@ run-rustfix - -#![deny(deprecated_safe_2024)] - -use std::process::Command; -use std::os::unix::process::CommandExt; - -#[allow(deprecated)] -fn main() { - let mut cmd = Command::new("sleep"); - cmd.before_exec(|| Ok(())); - //~^ ERROR call to deprecated safe function - //~| WARN this is accepted in the current edition - drop(cmd); -} diff --git a/tests/ui/rust-2024/unsafe-before_exec-suggestion.stderr b/tests/ui/rust-2024/unsafe-before_exec-suggestion.stderr deleted file mode 100644 index 33893f30ceca..000000000000 --- a/tests/ui/rust-2024/unsafe-before_exec-suggestion.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: call to deprecated safe function `std::os::unix::process::CommandExt::before_exec` is unsafe and requires unsafe block - --> $DIR/unsafe-before_exec-suggestion.rs:13:5 - | -LL | cmd.before_exec(|| Ok(())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see -note: the lint level is defined here - --> $DIR/unsafe-before_exec-suggestion.rs:5:9 - | -LL | #![deny(deprecated_safe_2024)] - | ^^^^^^^^^^^^^^^^^^^^ -help: you can wrap the call in an `unsafe` block if you can guarantee that the closure is async-signal-safe - | -LL + // TODO: Audit that the closure is async-signal-safe. -LL ~ unsafe { cmd.before_exec(|| Ok(())) }; - | - -error: aborting due to 1 previous error - diff --git a/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs b/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs deleted file mode 100644 index 6bd995449fc6..000000000000 --- a/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ compile-flags: -Zsanitizer=cfi -Cunsafe-allow-abi-mismatch=sanitizer -Ccodegen-units=1 -Clto -//@ needs-rustc-debug-assertions -//@ needs-sanitizer-cfi -//@ build-pass -//@ no-prefer-dynamic - -#![feature(min_generic_const_args)] -#![expect(incomplete_features)] - -trait Trait { - type const N: usize = 0; - fn process(&self, _: [u8; Self::N]) {} -} - -impl Trait for () {} - -fn main() { - let _x: &dyn Trait = &(); -} diff --git a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs index c3046708e4eb..8a724b853e13 100644 --- a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs +++ b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs @@ -5,7 +5,7 @@ //@ build-fail //@ max-llvm-major-version: 20 -//~? ERROR `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later +//~? ERROR `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. #![feature(no_core)] #![no_core] #![no_main] diff --git a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr index c5f886e3a390..ac6bd7411fd8 100644 --- a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr +++ b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later +error: `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. error: aborting due to 1 previous error diff --git a/tests/ui/simd/dont-invalid-bitcast-masks.rs b/tests/ui/simd/dont-invalid-bitcast-masks.rs index 1e2d097198d0..3d8376207cd0 100644 --- a/tests/ui/simd/dont-invalid-bitcast-masks.rs +++ b/tests/ui/simd/dont-invalid-bitcast-masks.rs @@ -12,6 +12,6 @@ use std::simd::num::*; pub unsafe fn mask_to_array(mask: u8) -> [i32; 8] { let mut output = [0; 8]; let m = masksizex8::from_bitmask(mask as _); - output.copy_from_slice(&m.to_simd().cast::().to_array()); + output.copy_from_slice(&m.to_int().cast::().to_array()); output } diff --git a/tests/ui/simd/extern-static-zero-length.rs b/tests/ui/simd/extern-static-zero-length.rs deleted file mode 100644 index 5ca7b63fc523..000000000000 --- a/tests/ui/simd/extern-static-zero-length.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(repr_simd)] - -#[repr(simd)] -struct Simd([T; N]); - -unsafe extern "C" { - static VAR: Simd; - //~^ ERROR the SIMD type `Simd` has zero elements - static VAR2: Simd; - //~^ ERROR the SIMD type `Simd` has more elements than the limit 32768 -} - -fn main() {} diff --git a/tests/ui/simd/extern-static-zero-length.stderr b/tests/ui/simd/extern-static-zero-length.stderr deleted file mode 100644 index 49c05f27d8c5..000000000000 --- a/tests/ui/simd/extern-static-zero-length.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: the SIMD type `Simd` has zero elements - --> $DIR/extern-static-zero-length.rs:7:17 - | -LL | static VAR: Simd; - | ^^^^^^^^^^^ - -error: the SIMD type `Simd` has more elements than the limit 32768 - --> $DIR/extern-static-zero-length.rs:9:18 - | -LL | static VAR2: Simd; - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index ee46f4c48502..680e0dcfd7d6 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -25,7 +25,7 @@ macro_rules! all_eq { }}; } -const fn extract_insert_dyn() { +fn extract_insert_dyn() { let x2 = i32x2::from_array([20, 21]); let x4 = i32x4::from_array([40, 41, 42, 43]); let x8 = i32x8::from_array([80, 81, 82, 83, 84, 85, 86, 87]); @@ -141,7 +141,6 @@ const fn swizzle() { } fn main() { - const { extract_insert_dyn() }; extract_insert_dyn(); const { swizzle() }; swizzle(); diff --git a/tests/ui/simd/intrinsic/splat.rs b/tests/ui/simd/intrinsic/splat.rs deleted file mode 100644 index 38260a124d44..000000000000 --- a/tests/ui/simd/intrinsic/splat.rs +++ /dev/null @@ -1,48 +0,0 @@ -//@ run-pass -#![feature(repr_simd, core_intrinsics)] - -#[path = "../../../auxiliary/minisimd.rs"] -mod minisimd; -use minisimd::*; - -use std::intrinsics::simd::simd_splat; - -fn main() { - unsafe { - let x: Simd = simd_splat(123u32); - let y: Simd = const { simd_splat(123u32) }; - assert_eq!(x.into_array(), [123; 1]); - assert_eq!(x.into_array(), y.into_array()); - - let x: u16x2 = simd_splat(42u16); - let y: u16x2 = const { simd_splat(42u16) }; - assert_eq!(x.into_array(), [42; 2]); - assert_eq!(x.into_array(), y.into_array()); - - let x: u128x4 = simd_splat(42u128); - let y: u128x4 = const { simd_splat(42u128) }; - assert_eq!(x.into_array(), [42; 4]); - assert_eq!(x.into_array(), y.into_array()); - - let x: i32x4 = simd_splat(-7i32); - let y: i32x4 = const { simd_splat(-7i32) }; - assert_eq!(x.into_array(), [-7; 4]); - assert_eq!(x.into_array(), y.into_array()); - - let x: f32x4 = simd_splat(42.0f32); - let y: f32x4 = const { simd_splat(42.0f32) }; - assert_eq!(x.into_array(), [42.0; 4]); - assert_eq!(x.into_array(), y.into_array()); - - let x: f64x2 = simd_splat(42.0f64); - let y: f64x2 = const { simd_splat(42.0f64) }; - assert_eq!(x.into_array(), [42.0; 2]); - assert_eq!(x.into_array(), y.into_array()); - - static ZERO: u8 = 0u8; - let x: Simd<*const u8, 2> = simd_splat(&raw const ZERO); - let y: Simd<*const u8, 2> = const { simd_splat(&raw const ZERO) }; - assert_eq!(x.into_array(), [&raw const ZERO; 2]); - assert_eq!(x.into_array(), y.into_array()); - } -} diff --git a/tests/ui/simd/portable-intrinsics-arent-exposed.stderr b/tests/ui/simd/portable-intrinsics-arent-exposed.stderr index c7c36c841091..043a4ca37618 100644 --- a/tests/ui/simd/portable-intrinsics-arent-exposed.stderr +++ b/tests/ui/simd/portable-intrinsics-arent-exposed.stderr @@ -1,14 +1,11 @@ -error[E0433]: cannot find `core` in the crate root +error[E0433]: failed to resolve: you might be missing crate `core` --> $DIR/portable-intrinsics-arent-exposed.rs:5:5 | LL | use core::simd::intrinsics; - | ^^^^ you might be missing crate `core` - | -help: try using `std` instead of `core` - | -LL - use core::simd::intrinsics; -LL + use std::simd::intrinsics; - | + | ^^^^ + | | + | you might be missing crate `core` + | help: try using `std` instead of `core`: `std` error[E0432]: unresolved import `std::simd::intrinsics` --> $DIR/portable-intrinsics-arent-exposed.rs:6:5 diff --git a/tests/ui/simd/target-feature-mixup.rs b/tests/ui/simd/target-feature-mixup.rs index 5f599f38fb92..014a9966f5cb 100644 --- a/tests/ui/simd/target-feature-mixup.rs +++ b/tests/ui/simd/target-feature-mixup.rs @@ -1,12 +1,13 @@ //@ run-pass #![allow(unused_variables)] +#![allow(stable_features)] #![allow(overflowing_literals)] //@ needs-subprocess //@ ignore-fuchsia must translate zircon signal to SIGILL, FIXME (#58590) //@ ignore-backends: gcc -#![feature(repr_simd)] +#![feature(repr_simd, target_feature, cfg_target_feature)] #[path = "../../auxiliary/minisimd.rs"] mod minisimd; diff --git a/tests/ui/span/E0204.rs b/tests/ui/span/E0204.rs index 841bd5e32b8a..8793a05c8a85 100644 --- a/tests/ui/span/E0204.rs +++ b/tests/ui/span/E0204.rs @@ -4,8 +4,8 @@ struct Foo { impl Copy for Foo { } //~ ERROR cannot be implemented for this type -#[derive(Copy)] -struct Foo2<'a> { //~ ERROR cannot be implemented for this type +#[derive(Copy)] //~ ERROR cannot be implemented for this type +struct Foo2<'a> { ty: &'a mut bool, } @@ -16,8 +16,8 @@ enum EFoo { impl Copy for EFoo { } //~ ERROR cannot be implemented for this type -#[derive(Copy)] -enum EFoo2<'a> { //~ ERROR cannot be implemented for this type +#[derive(Copy)] //~ ERROR cannot be implemented for this type +enum EFoo2<'a> { Bar(&'a mut bool), Baz, } diff --git a/tests/ui/span/E0204.stderr b/tests/ui/span/E0204.stderr index a0b51be17863..fe375b94781b 100644 --- a/tests/ui/span/E0204.stderr +++ b/tests/ui/span/E0204.stderr @@ -8,12 +8,11 @@ LL | impl Copy for Foo { } | ^^^ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/E0204.rs:8:8 + --> $DIR/E0204.rs:7:10 | LL | #[derive(Copy)] - | ---- in this derive macro expansion + | ^^^^ LL | struct Foo2<'a> { - | ^^^^ LL | ty: &'a mut bool, | ---------------- this field does not implement `Copy` @@ -27,12 +26,11 @@ LL | impl Copy for EFoo { } | ^^^^ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/E0204.rs:20:6 + --> $DIR/E0204.rs:19:10 | LL | #[derive(Copy)] - | ---- in this derive macro expansion + | ^^^^ LL | enum EFoo2<'a> { - | ^^^^^ LL | Bar(&'a mut bool), | ------------ this field does not implement `Copy` diff --git a/tests/ui/span/coerce-suggestions.stderr b/tests/ui/span/coerce-suggestions.stderr index d0f76a23edc4..77b01ee08b79 100644 --- a/tests/ui/span/coerce-suggestions.stderr +++ b/tests/ui/span/coerce-suggestions.stderr @@ -56,6 +56,8 @@ error[E0308]: mismatched types | LL | s = format!("foo"); | ^^^^^^^^^^^^^^ expected `&mut String`, found `String` + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/tests/ui/span/vec-macro-outlives-issue-15480.fixed b/tests/ui/span/issue-15480.fixed similarity index 100% rename from tests/ui/span/vec-macro-outlives-issue-15480.fixed rename to tests/ui/span/issue-15480.fixed diff --git a/tests/ui/span/vec-macro-outlives-issue-15480.rs b/tests/ui/span/issue-15480.rs similarity index 100% rename from tests/ui/span/vec-macro-outlives-issue-15480.rs rename to tests/ui/span/issue-15480.rs diff --git a/tests/ui/span/vec-macro-outlives-issue-15480.stderr b/tests/ui/span/issue-15480.stderr similarity index 92% rename from tests/ui/span/vec-macro-outlives-issue-15480.stderr rename to tests/ui/span/issue-15480.stderr index 7fa9b374ad88..45a5d7dfbecb 100644 --- a/tests/ui/span/vec-macro-outlives-issue-15480.stderr +++ b/tests/ui/span/issue-15480.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/vec-macro-outlives-issue-15480.rs:6:10 + --> $DIR/issue-15480.rs:6:10 | LL | &id(3) | ^^^^^ creates a temporary value which is freed while still in use diff --git a/tests/ui/span/issue-33884.stderr b/tests/ui/span/issue-33884.stderr index a5c3e9fa7c45..29490d86fffe 100644 --- a/tests/ui/span/issue-33884.stderr +++ b/tests/ui/span/issue-33884.stderr @@ -3,6 +3,8 @@ error[E0308]: mismatched types | LL | stream.write_fmt(format!("message received")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Arguments<'_>`, found `String` + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/span/issue-39698.stderr b/tests/ui/span/issue-39698.stderr index dd57fa061866..eb18969c3c0d 100644 --- a/tests/ui/span/issue-39698.stderr +++ b/tests/ui/span/issue-39698.stderr @@ -71,6 +71,8 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | binding initialized here in some conditions | binding initialized here in some conditions | binding declared here but left uninitialized + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/tests/ui/span/issue-71363.rs b/tests/ui/span/issue-71363.rs index 4ce8a942c7b1..f186e0526a42 100644 --- a/tests/ui/span/issue-71363.rs +++ b/tests/ui/span/issue-71363.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z ui-testing=no --diagnostic-width=80 +//@ compile-flags: -Z ui-testing=no struct MyError; impl std::error::Error for MyError {} diff --git a/tests/ui/span/let-offset-of.rs b/tests/ui/span/let-offset-of.rs deleted file mode 100644 index 99b34a192847..000000000000 --- a/tests/ui/span/let-offset-of.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![crate_type = "rlib"] -//@ edition: 2024 -//@ check-pass - -// Using `offset_of` in the RHS of a let-else statement should not produce -// malformed spans or a blank diagnostic snippet. -// -// Regression test for . - -fn init_to_offset_of() { - use std::mem::offset_of; - struct Foo { field: u32 } - - if let x = offset_of!(Foo, field) {} - //~^ WARN irrefutable `if let` pattern - - let x = offset_of!(Foo, field) else { return; }; - //~^ WARN irrefutable `let...else` pattern -} diff --git a/tests/ui/span/let-offset-of.stderr b/tests/ui/span/let-offset-of.stderr deleted file mode 100644 index 6ea9b2194a36..000000000000 --- a/tests/ui/span/let-offset-of.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: irrefutable `if let` pattern - --> $DIR/let-offset-of.rs:14:8 - | -LL | if let x = offset_of!(Foo, field) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - = note: `#[warn(irrefutable_let_patterns)]` on by default - -warning: irrefutable `let...else` pattern - --> $DIR/let-offset-of.rs:17:5 - | -LL | let x = offset_of!(Foo, field) else { return; }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match, so the `else` clause is useless - = help: consider removing the `else` clause - -warning: 2 warnings emitted - diff --git a/tests/ui/span/slice-borrow.stderr b/tests/ui/span/slice-borrow.stderr index 6d37019e91b4..48ac20feea72 100644 --- a/tests/ui/span/slice-borrow.stderr +++ b/tests/ui/span/slice-borrow.stderr @@ -10,6 +10,7 @@ LL | y.use_ref(); | - borrow later used here | = note: consider using a `let` binding to create a longer lived value + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/span/visibility-ty-params.rs b/tests/ui/span/visibility-ty-params.rs index 7817d134c77b..05d93e546360 100644 --- a/tests/ui/span/visibility-ty-params.rs +++ b/tests/ui/span/visibility-ty-params.rs @@ -4,7 +4,7 @@ macro_rules! m { struct S(T); m!{ crate::S } //~ ERROR unexpected generic arguments in path - //~| ERROR cannot find + //~| ERROR failed to resolve: `S` is a struct, not a module [E0433] mod m { m!{ crate::m<> } //~ ERROR unexpected generic arguments in path diff --git a/tests/ui/span/visibility-ty-params.stderr b/tests/ui/span/visibility-ty-params.stderr index 2fda6c70de0d..7b02d79a1bc2 100644 --- a/tests/ui/span/visibility-ty-params.stderr +++ b/tests/ui/span/visibility-ty-params.stderr @@ -4,7 +4,7 @@ error: unexpected generic arguments in path LL | m!{ crate::S } | ^^^^ -error[E0433]: cannot find module `S` in `crate` +error[E0433]: failed to resolve: `S` is a struct, not a module --> $DIR/visibility-ty-params.rs:6:12 | LL | m!{ crate::S } diff --git a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs index 578a46c67400..538b0c2b1d46 100644 --- a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs +++ b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs @@ -5,11 +5,12 @@ //~| WARN the feature `min_generic_const_args` is incomplete pub trait IsVoid { - - type const IS_VOID: bool; + #[type_const] + const IS_VOID: bool; } impl IsVoid for T { - default type const IS_VOID: bool = false; + #[type_const] + default const IS_VOID: bool = false; } pub trait NotVoid {} diff --git a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr index 9361f7d6222f..6159c2ed331a 100644 --- a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr +++ b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr @@ -17,7 +17,7 @@ LL | #![feature(min_generic_const_args, specialization)] = help: consider using `min_specialization` instead, which is more stable and complete error[E0119]: conflicting implementations of trait `Maybe<()>` for type `()` - --> $DIR/overlap-due-to-unsatisfied-const-bound.rs:20:1 + --> $DIR/overlap-due-to-unsatisfied-const-bound.rs:21:1 | LL | impl Maybe for T {} | ---------------------- first implementation here diff --git a/tests/ui/specialization/specialization-default-projection.current.stderr b/tests/ui/specialization/specialization-default-projection.current.stderr index b88c1a94baf9..038c379c43e1 100644 --- a/tests/ui/specialization/specialization-default-projection.current.stderr +++ b/tests/ui/specialization/specialization-default-projection.current.stderr @@ -21,8 +21,6 @@ LL | () found unit type `()` = help: consider constraining the associated type `::Assoc` to `()` or calling a method that returns `::Assoc` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type `::Assoc` is defined as `()` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/specialization-default-projection.rs:32:5 @@ -39,8 +37,6 @@ LL | generic::<()>() found associated type `<() as Foo>::Assoc` = help: consider constraining the associated type `<() as Foo>::Assoc` to `()` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type `<() as Foo>::Assoc` is defined as `()` in the implementation, but the where-bound `()` shadows this definition - see issue #152409 for more information error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/specialization/specialization-default-projection.next.stderr b/tests/ui/specialization/specialization-default-projection.next.stderr index a385b16a2d8b..9111f173a9c8 100644 --- a/tests/ui/specialization/specialization-default-projection.next.stderr +++ b/tests/ui/specialization/specialization-default-projection.next.stderr @@ -21,8 +21,6 @@ LL | () found unit type `()` = help: consider constraining the associated type `::Assoc` to `()` or calling a method that returns `::Assoc` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type `::Assoc` is defined as `()` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/specialization-default-projection.rs:32:5 @@ -39,8 +37,6 @@ LL | generic::<()>() found associated type `<() as Foo>::Assoc` = help: consider constraining the associated type `<() as Foo>::Assoc` to `()` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type `<() as Foo>::Assoc` is defined as `()` in the implementation, but the where-bound `()` shadows this definition - see issue #152409 for more information error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/specialization/specialization-default-types.current.stderr b/tests/ui/specialization/specialization-default-types.current.stderr index 8df170cbb767..09689681740f 100644 --- a/tests/ui/specialization/specialization-default-types.current.stderr +++ b/tests/ui/specialization/specialization-default-types.current.stderr @@ -20,8 +20,6 @@ LL | Box::new(self) | = note: expected associated type `::Output` found struct `Box` - = note: the associated type `::Output` is defined as `Box` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:29:5 @@ -35,8 +33,6 @@ LL | Example::generate(t) found associated type `::Output` = help: consider constraining the associated type `::Output` to `Box` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type `::Output` is defined as `Box` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/specialization/specialization-default-types.next.stderr b/tests/ui/specialization/specialization-default-types.next.stderr index 4ea9b996c86a..1535c6473bdd 100644 --- a/tests/ui/specialization/specialization-default-types.next.stderr +++ b/tests/ui/specialization/specialization-default-types.next.stderr @@ -20,8 +20,6 @@ LL | Box::new(self) | = note: expected associated type `::Output` found struct `Box` - = note: the associated type `::Output` is defined as `Box` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:29:5 @@ -35,8 +33,6 @@ LL | Example::generate(t) found associated type `::Output` = help: consider constraining the associated type `::Output` to `Box` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - = note: the associated type `::Output` is defined as `Box` in the implementation, but the where-bound `T` shadows this definition - see issue #152409 for more information error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/static/global-variable-promotion-error-7364.stderr b/tests/ui/static/global-variable-promotion-error-7364.stderr index 9f0026621c13..b9d75676bef8 100644 --- a/tests/ui/static/global-variable-promotion-error-7364.stderr +++ b/tests/ui/static/global-variable-promotion-error-7364.stderr @@ -6,7 +6,7 @@ LL | static boxed: Box> = Box::new(RefCell::new(0)); | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `std::ptr::Unique>` to implement `Sync` + = note: required for `Unique>` to implement `Sync` note: required because it appears within the type `Box>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: shared static variables must have a type that implements `Sync` diff --git a/tests/ui/statics/check-immutable-mut-slices.stderr b/tests/ui/statics/check-immutable-mut-slices.stderr index 1e6dfb78c93d..a9486fc9d781 100644 --- a/tests/ui/statics/check-immutable-mut-slices.stderr +++ b/tests/ui/statics/check-immutable-mut-slices.stderr @@ -4,9 +4,9 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended u LL | static TEST: &'static mut [isize] = &mut []; | ^^^^^^^ this mutable borrow refers to such a temporary | - = note: temporaries in constants and statics can have their lifetime extended until the end of the program - = note: to avoid accidentally creating global mutable state, such temporaries must be immutable - = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/statics/check-values-constraints.rs b/tests/ui/statics/check-values-constraints.rs index c62abd75a304..9df76b5c1497 100644 --- a/tests/ui/statics/check-values-constraints.rs +++ b/tests/ui/statics/check-values-constraints.rs @@ -79,8 +79,8 @@ static STATIC10: UnsafeStruct = UnsafeStruct; struct MyOwned; static STATIC11: Vec = vec![MyOwned]; -//~^ ERROR cannot call non-const function -//~| ERROR cannot call non-const +//~^ ERROR allocations are not allowed in statics +//~^^ ERROR cannot call non-const static mut STATIC12: UnsafeStruct = UnsafeStruct; @@ -93,29 +93,29 @@ static mut STATIC14: SafeStruct = SafeStruct { }; static STATIC15: &'static [Vec] = &[ - vec![MyOwned], //~ ERROR cannot call non-const function - //~| ERROR cannot call non-const - vec![MyOwned], //~ ERROR cannot call non-const function - //~| ERROR cannot call non-const + vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const + vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const ]; static STATIC16: (&'static Vec, &'static Vec) = ( - &vec![MyOwned], //~ ERROR cannot call non-const function - //~| ERROR cannot call non-const - &vec![MyOwned], //~ ERROR cannot call non-const function - //~| ERROR cannot call non-const + &vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const + &vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const ); static mut STATIC17: SafeEnum = SafeEnum::Variant1; static STATIC19: Vec = vec![3]; -//~^ ERROR cannot call non-const function -//~| ERROR cannot call non-const +//~^ ERROR allocations are not allowed in statics +//~^^ ERROR cannot call non-const pub fn main() { let y = { - static x: Vec = vec![3]; //~ ERROR cannot call non-const function - //~| ERROR cannot call non-const + static x: Vec = vec![3]; //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const x //~^ ERROR cannot move out of static }; diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index 94d2b8ce8064..c54f4830533a 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -11,25 +11,23 @@ LL | | } LL | }; | - value is dropped here -error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new_uninit` in statics +error[E0010]: allocations are not allowed in statics --> $DIR/check-values-constraints.rs:81:33 | LL | static STATIC11: Vec = vec![MyOwned]; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ allocation not allowed in statics | - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:81:33 | LL | static STATIC11: Vec = vec![MyOwned]; | ^^^^^^^^^^^^^ | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `::to_string` in statics --> $DIR/check-values-constraints.rs:92:38 @@ -47,7 +45,15 @@ note: method `to_string` is not const because trait `ToString` is not const = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` -error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new_uninit` in statics +error[E0010]: allocations are not allowed in statics + --> $DIR/check-values-constraints.rs:96:5 + | +LL | vec![MyOwned], + | ^^^^^^^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:96:5 | LL | vec![MyOwned], @@ -55,19 +61,17 @@ LL | vec![MyOwned], | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics - --> $DIR/check-values-constraints.rs:96:5 +error[E0010]: allocations are not allowed in statics + --> $DIR/check-values-constraints.rs:98:5 | LL | vec![MyOwned], - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ allocation not allowed in statics | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new_uninit` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:98:5 | LL | vec![MyOwned], @@ -75,19 +79,17 @@ LL | vec![MyOwned], | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics - --> $DIR/check-values-constraints.rs:98:5 +error[E0010]: allocations are not allowed in statics + --> $DIR/check-values-constraints.rs:103:6 | -LL | vec![MyOwned], - | ^^^^^^^^^^^^^ +LL | &vec![MyOwned], + | ^^^^^^^^^^^^^ allocation not allowed in statics | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new_uninit` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:103:6 | LL | &vec![MyOwned], @@ -95,19 +97,17 @@ LL | &vec![MyOwned], | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics - --> $DIR/check-values-constraints.rs:103:6 +error[E0010]: allocations are not allowed in statics + --> $DIR/check-values-constraints.rs:105:6 | LL | &vec![MyOwned], - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ allocation not allowed in statics | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new_uninit` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:105:6 | LL | &vec![MyOwned], @@ -115,19 +115,17 @@ LL | &vec![MyOwned], | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics - --> $DIR/check-values-constraints.rs:105:6 +error[E0010]: allocations are not allowed in statics + --> $DIR/check-values-constraints.rs:111:31 | -LL | &vec![MyOwned], - | ^^^^^^^^^^^^^ +LL | static STATIC19: Vec = vec![3]; + | ^^^^^^^ allocation not allowed in statics | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const associated function `Box::<[isize; 1]>::new_uninit` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:111:31 | LL | static STATIC19: Vec = vec![3]; @@ -135,19 +133,17 @@ LL | static STATIC19: Vec = vec![3]; | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics - --> $DIR/check-values-constraints.rs:111:31 +error[E0010]: allocations are not allowed in statics + --> $DIR/check-values-constraints.rs:117:32 | -LL | static STATIC19: Vec = vec![3]; - | ^^^^^^^ +LL | static x: Vec = vec![3]; + | ^^^^^^^ allocation not allowed in statics | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const associated function `Box::<[isize; 1]>::new_uninit` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:117:32 | LL | static x: Vec = vec![3]; @@ -155,17 +151,7 @@ LL | static x: Vec = vec![3]; | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` - -error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::` in statics - --> $DIR/check-values-constraints.rs:117:32 - | -LL | static x: Vec = vec![3]; - | ^^^^^^^ - | -note: function `box_assume_init_into_vec_unsafe` is not const - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0507]: cannot move out of static item `x` --> $DIR/check-values-constraints.rs:119:9 @@ -184,5 +170,5 @@ LL | x.clone() error: aborting due to 17 previous errors -Some errors have detailed explanations: E0015, E0493, E0507. -For more information about an error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0010, E0015, E0493, E0507. +For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index a48940460f91..11a6bfdfcd29 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -4,11 +4,11 @@ macro-stats Macro Name Uses Lines Avg Lines B macro-stats ----------------------------------------------------------------------------------- macro-stats #[derive(Clone)] 8 67 8.4 1_879 234.9 macro-stats #[derive(PartialOrd)] 1 17 17.0 675 675.0 -macro-stats #[derive(Hash)] 2 17 8.5 565 282.5 +macro-stats #[derive(Hash)] 2 17 8.5 577 288.5 macro-stats q! 1 26 26.0 519 519.0 macro-stats #[derive(Ord)] 1 15 15.0 503 503.0 macro-stats #[derive(Default)] 2 16 8.0 403 201.5 -macro-stats #[derive(Eq)] 1 11 11.0 319 319.0 +macro-stats #[derive(Eq)] 1 11 11.0 325 325.0 macro-stats #[derive(Debug)] 1 8 8.0 277 277.0 macro-stats #[derive(PartialEq)] 1 9 9.0 267 267.0 macro-stats #[derive(Copy)] 1 2 2.0 61 61.0 diff --git a/tests/ui/stdlib-unit-tests/matches2021.rs b/tests/ui/stdlib-unit-tests/matches2021.rs index 0958e82f43e4..78c8be732136 100644 --- a/tests/ui/stdlib-unit-tests/matches2021.rs +++ b/tests/ui/stdlib-unit-tests/matches2021.rs @@ -3,7 +3,9 @@ // regression test for https://github.com/rust-lang/rust/pull/85678 -use std::assert_matches; +#![feature(assert_matches)] + +use std::assert_matches::assert_matches; fn main() { assert!(matches!((), ())); diff --git a/tests/ui/structs/struct-update-syntax-2463.rs b/tests/ui/structs/struct-update-syntax-2463.rs deleted file mode 100644 index 5b2a90a5adf9..000000000000 --- a/tests/ui/structs/struct-update-syntax-2463.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/2463 - -//@ run-pass -#![allow(dead_code)] - -struct Pair { - f: isize, - g: isize, -} - -pub fn main() { - let x = Pair { f: 0, g: 0 }; - - let _y = Pair { f: 1, g: 1, ..x }; - - let _z = Pair { f: 1, ..x }; -} diff --git a/tests/ui/suggestions/bound-suggestions.stderr b/tests/ui/suggestions/bound-suggestions.stderr index ba792578a202..ec1d23fac458 100644 --- a/tests/ui/suggestions/bound-suggestions.stderr +++ b/tests/ui/suggestions/bound-suggestions.stderr @@ -6,6 +6,7 @@ LL | println!("{:?}", t); | | | required by this formatting parameter | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting opaque type `impl Sized` with trait `Debug` | LL | fn test_impl(t: impl Sized + std::fmt::Debug) { @@ -19,6 +20,7 @@ LL | println!("{:?}", t); | | | required by this formatting parameter | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` with trait `Debug` | LL | fn test_no_bounds(t: T) { @@ -32,6 +34,7 @@ LL | println!("{:?}", t); | | | required by this formatting parameter | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `T` with trait `Debug` | LL | fn test_one_bound(t: T) { @@ -45,6 +48,7 @@ LL | println!("{:?} {:?}", x, y); | | | required by this formatting parameter | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `Y` with trait `Debug` | LL | fn test_no_bounds_where(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug { @@ -58,6 +62,7 @@ LL | println!("{:?}", x); | | | required by this formatting parameter | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `X` with trait `Debug` | LL | fn test_one_bound_where(x: X) where X: Sized + std::fmt::Debug { @@ -71,6 +76,7 @@ LL | println!("{:?}", x); | | | required by this formatting parameter | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `X` with trait `Debug` | LL | fn test_many_bounds_where(x: X) where X: Sized + std::fmt::Debug, X: Sized { diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.fixed b/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.fixed index 3ab6ad8b85f5..b7b94a051212 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.fixed +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.fixed @@ -12,7 +12,7 @@ use core::num::NonZero; fn main() { //~^ HELP consider importing this struct let _x = NonZero::new(5u32).unwrap(); - //~^ ERROR cannot find type `NonZero` + //~^ ERROR failed to resolve: use of undeclared type `NonZero` } #[allow(dead_code)] diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.stderr b/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.stderr index 37bfb07b2295..d73f613bf9c8 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.stderr +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.no_std.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `NonZero` in this scope +error[E0433]: failed to resolve: use of undeclared type `NonZero` --> $DIR/core-std-import-order-issue-83564.rs:12:14 | LL | let _x = NonZero::new(5u32).unwrap(); diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.rs b/tests/ui/suggestions/core-std-import-order-issue-83564.rs index e7a56a44d921..4cfc9a6bf742 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.rs +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.rs @@ -10,7 +10,7 @@ fn main() { //~^ HELP consider importing this struct let _x = NonZero::new(5u32).unwrap(); - //~^ ERROR cannot find type `NonZero` + //~^ ERROR failed to resolve: use of undeclared type `NonZero` } #[allow(dead_code)] diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.std.fixed b/tests/ui/suggestions/core-std-import-order-issue-83564.std.fixed index 802177578846..84c7c19d19e2 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.std.fixed +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.std.fixed @@ -12,7 +12,7 @@ use std::num::NonZero; fn main() { //~^ HELP consider importing this struct let _x = NonZero::new(5u32).unwrap(); - //~^ ERROR cannot find type `NonZero` + //~^ ERROR failed to resolve: use of undeclared type `NonZero` } #[allow(dead_code)] diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.std.stderr b/tests/ui/suggestions/core-std-import-order-issue-83564.std.stderr index ad0ac7859a8d..ebfe197b45d6 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.std.stderr +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.std.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `NonZero` in this scope +error[E0433]: failed to resolve: use of undeclared type `NonZero` --> $DIR/core-std-import-order-issue-83564.rs:12:14 | LL | let _x = NonZero::new(5u32).unwrap(); diff --git a/tests/ui/suggestions/crate-or-module-typo.rs b/tests/ui/suggestions/crate-or-module-typo.rs index 8a6df258b452..393fc7a1f72e 100644 --- a/tests/ui/suggestions/crate-or-module-typo.rs +++ b/tests/ui/suggestions/crate-or-module-typo.rs @@ -1,9 +1,9 @@ //@ edition:2018 -use st::cell::Cell; //~ ERROR cannot find module or crate `st` +use st::cell::Cell; //~ ERROR failed to resolve: use of unresolved module or unlinked crate `st` mod bar { - pub fn bar() { bar::baz(); } //~ ERROR cannot find module or crate `bar` + pub fn bar() { bar::baz(); } //~ ERROR failed to resolve: function `bar` is not a crate or module fn baz() {} } @@ -11,7 +11,7 @@ mod bar { use bas::bar; //~ ERROR unresolved import `bas` struct Foo { - bar: st::cell::Cell //~ ERROR cannot find module or crate `st` + bar: st::cell::Cell //~ ERROR failed to resolve: use of unresolved module or unlinked crate `st` } fn main() {} diff --git a/tests/ui/suggestions/crate-or-module-typo.stderr b/tests/ui/suggestions/crate-or-module-typo.stderr index 49ac1c89ab52..2ec4fc7ed6cc 100644 --- a/tests/ui/suggestions/crate-or-module-typo.stderr +++ b/tests/ui/suggestions/crate-or-module-typo.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `st` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `st` --> $DIR/crate-or-module-typo.rs:3:5 | LL | use st::cell::Cell; @@ -21,7 +21,7 @@ LL - use bas::bar; LL + use bar::bar; | -error[E0433]: cannot find module or crate `st` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `st` --> $DIR/crate-or-module-typo.rs:14:10 | LL | bar: st::cell::Cell @@ -41,7 +41,7 @@ LL - bar: st::cell::Cell LL + bar: cell::Cell | -error[E0433]: cannot find module or crate `bar` in this scope +error[E0433]: failed to resolve: function `bar` is not a crate or module --> $DIR/crate-or-module-typo.rs:6:20 | LL | pub fn bar() { bar::baz(); } diff --git a/tests/ui/suggestions/derive-clone-already-present-issue-146515.rs b/tests/ui/suggestions/derive-clone-already-present-issue-146515.rs deleted file mode 100644 index 78b4c017251e..000000000000 --- a/tests/ui/suggestions/derive-clone-already-present-issue-146515.rs +++ /dev/null @@ -1,19 +0,0 @@ -// issue: https://github.com/rust-lang/rust/issues/146515 - -use std::rc::Rc; - -#[derive(Clone)] //~ NOTE in this expansion -struct ContainsRc { //~ NOTE derive introduces an implicit `T: Clone` bound - value: Rc, -} - -fn clone_me(x: &ContainsRc) -> ContainsRc { - //~^ NOTE expected `ContainsRc` because of return type - x.clone() - //~^ ERROR mismatched types - //~| NOTE expected `ContainsRc`, found `&ContainsRc` - //~| NOTE expected struct `ContainsRc<_>` - //~| NOTE `ContainsRc` does not implement `Clone`, so `&ContainsRc` was cloned instead -} - -fn main() {} diff --git a/tests/ui/suggestions/derive-clone-already-present-issue-146515.stderr b/tests/ui/suggestions/derive-clone-already-present-issue-146515.stderr deleted file mode 100644 index 6ecf4e7ca943..000000000000 --- a/tests/ui/suggestions/derive-clone-already-present-issue-146515.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/derive-clone-already-present-issue-146515.rs:12:5 - | -LL | fn clone_me(x: &ContainsRc) -> ContainsRc { - | ------------- expected `ContainsRc` because of return type -LL | -LL | x.clone() - | ^^^^^^^^^ expected `ContainsRc`, found `&ContainsRc` - | - = note: expected struct `ContainsRc<_>` - found reference `&ContainsRc<_>` -note: `ContainsRc` does not implement `Clone`, so `&ContainsRc` was cloned instead - --> $DIR/derive-clone-already-present-issue-146515.rs:12:5 - | -LL | x.clone() - | ^ -help: `Clone` is not implemented because a trait bound is not satisfied - --> $DIR/derive-clone-already-present-issue-146515.rs:6:19 - | -LL | #[derive(Clone)] - | ----- in this derive macro expansion -LL | struct ContainsRc { - | ^ derive introduces an implicit `T: Clone` bound - = help: consider manually implementing `Clone` to avoid the implicit type parameter bounds - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/derive-clone-for-eq.fixed b/tests/ui/suggestions/derive-clone-for-eq.fixed index 17259dd687c6..4dc362f94787 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.fixed +++ b/tests/ui/suggestions/derive-clone-for-eq.fixed @@ -1,8 +1,8 @@ //@ run-rustfix // https://github.com/rust-lang/rust/issues/79076 -#[derive(Clone, Eq)] -pub struct Struct(T); //~ ERROR [E0277] +#[derive(Clone, Eq)] //~ ERROR [E0277] +pub struct Struct(T); impl PartialEq for Struct where diff --git a/tests/ui/suggestions/derive-clone-for-eq.rs b/tests/ui/suggestions/derive-clone-for-eq.rs index 3e4331745be8..b3635000f165 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.rs +++ b/tests/ui/suggestions/derive-clone-for-eq.rs @@ -1,8 +1,8 @@ //@ run-rustfix // https://github.com/rust-lang/rust/issues/79076 -#[derive(Clone, Eq)] -pub struct Struct(T); //~ ERROR [E0277] +#[derive(Clone, Eq)] //~ ERROR [E0277] +pub struct Struct(T); impl PartialEq for Struct where diff --git a/tests/ui/suggestions/derive-clone-for-eq.stderr b/tests/ui/suggestions/derive-clone-for-eq.stderr index bed5ff90c194..eb0355853daa 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.stderr +++ b/tests/ui/suggestions/derive-clone-for-eq.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/derive-clone-for-eq.rs:5:12 + --> $DIR/derive-clone-for-eq.rs:4:17 | LL | #[derive(Clone, Eq)] - | -- in this derive macro expansion -LL | pub struct Struct(T); - | ^^^^^^ the trait `Clone` is not implemented for `T` + | ^^ the trait `Clone` is not implemented for `T` | note: required for `Struct` to implement `PartialEq` --> $DIR/derive-clone-for-eq.rs:7:19 diff --git a/tests/ui/suggestions/derive-trait-for-method-call.stderr b/tests/ui/suggestions/derive-trait-for-method-call.stderr index 0e25b09fedb3..ae3a0391eea2 100644 --- a/tests/ui/suggestions/derive-trait-for-method-call.stderr +++ b/tests/ui/suggestions/derive-trait-for-method-call.stderr @@ -25,14 +25,11 @@ LL | impl Foo { | | | unsatisfied trait bound introduced here | | unsatisfied trait bound introduced here | unsatisfied trait bound introduced here -help: consider annotating `CloneEnum` with `#[derive(Default)]` +note: the trait `Default` must be implemented + --> $SRC_DIR/core/src/default.rs:LL:COL +help: consider annotating `Enum` with `#[derive(Clone)]` | -LL + #[derive(Default)] -LL | enum CloneEnum { - | -help: consider annotating `Enum` with `#[derive(Clone, Default)]` - | -LL + #[derive(Clone, Default)] +LL + #[derive(Clone)] LL | enum Enum { | diff --git a/tests/ui/suggestions/issue-103112.rs b/tests/ui/suggestions/issue-103112.rs index 795fe60fd693..111ae7c73080 100644 --- a/tests/ui/suggestions/issue-103112.rs +++ b/tests/ui/suggestions/issue-103112.rs @@ -1,4 +1,4 @@ fn main() { std::process::abort!(); - //~^ ERROR: cannot find + //~^ ERROR: failed to resolve } diff --git a/tests/ui/suggestions/issue-103112.stderr b/tests/ui/suggestions/issue-103112.stderr index b644eff920d6..b7de57bfd90e 100644 --- a/tests/ui/suggestions/issue-103112.stderr +++ b/tests/ui/suggestions/issue-103112.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `abort` in `process` +error[E0433]: failed to resolve: could not find `abort` in `process` --> $DIR/issue-103112.rs:2:19 | LL | std::process::abort!(); diff --git a/tests/ui/suggestions/issue-112590-suggest-import.rs b/tests/ui/suggestions/issue-112590-suggest-import.rs index ec7a3cbac1de..a7868b719190 100644 --- a/tests/ui/suggestions/issue-112590-suggest-import.rs +++ b/tests/ui/suggestions/issue-112590-suggest-import.rs @@ -1,9 +1,8 @@ pub struct S; -impl fmt::Debug for S { //~ ERROR: cannot find module or crate `fmt` - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - //~^ ERROR: cannot find module or crate `fmt` - //~| ERROR: cannot find module or crate `fmt` +impl fmt::Debug for S { //~ ERROR failed to resolve: use of unresolved module or unlinked crate `fmt` + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { //~ ERROR failed to resolve: use of unresolved module or unlinked crate `fmt` + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `fmt` Ok(()) } } diff --git a/tests/ui/suggestions/issue-112590-suggest-import.stderr b/tests/ui/suggestions/issue-112590-suggest-import.stderr index b44b59bea181..bbbd2c481c1c 100644 --- a/tests/ui/suggestions/issue-112590-suggest-import.stderr +++ b/tests/ui/suggestions/issue-112590-suggest-import.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `fmt` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fmt` --> $DIR/issue-112590-suggest-import.rs:3:6 | LL | impl fmt::Debug for S { @@ -10,7 +10,7 @@ help: consider importing this module LL + use std::fmt; | -error[E0433]: cannot find module or crate `fmt` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fmt` --> $DIR/issue-112590-suggest-import.rs:4:28 | LL | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -22,7 +22,7 @@ help: consider importing this module LL + use std::fmt; | -error[E0433]: cannot find module or crate `fmt` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fmt` --> $DIR/issue-112590-suggest-import.rs:4:51 | LL | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.stderr b/tests/ui/suggestions/issue-71394-no-from-impl.stderr index b8a240f7f07c..9e068c311ae0 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/tests/ui/suggestions/issue-71394-no-from-impl.stderr @@ -13,7 +13,7 @@ LL | let _: &[i8] = data.into(); `[T; 6]` implements `From<(T, T, T, T, T, T)>` `[T; 7]` implements `From<(T, T, T, T, T, T, T)>` `[T; 8]` implements `From<(T, T, T, T, T, T, T, T)>` - and 7 others + and 6 others = note: required for `&[u8]` to implement `Into<&[i8]>` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-97760.stderr b/tests/ui/suggestions/issue-97760.stderr index f3dc3f74efe8..c3cf7e13987b 100644 --- a/tests/ui/suggestions/issue-97760.stderr +++ b/tests/ui/suggestions/issue-97760.stderr @@ -6,6 +6,7 @@ LL | println!("{x}"); | = help: the trait `std::fmt::Display` is not implemented for `::Item` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: introduce a type parameter with a trait bound instead of using `impl Trait` | LL ~ pub fn print_values(values: &I) diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-2.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-2.stderr index 791e2d19f2f9..a48dd30d008a 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-2.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-2.stderr @@ -24,13 +24,12 @@ LL | pub loc: Vector2, | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K` | note: required for `Vector2` to implement `Debug` - --> $DIR/missing-bound-in-derive-copy-impl-2.rs:5:12 + --> $DIR/missing-bound-in-derive-copy-impl-2.rs:4:10 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion + | ^^^^^ LL | pub struct Vector2 { - | ^^^^^^^ ---- unsatisfied trait bound - = help: consider manually implementing `Debug` to avoid undesired bounds + | ---- unsatisfied trait bound introduced in this `derive` macro = note: required for the cast from `&Vector2` to `&dyn Debug` help: consider further restricting type parameter `K` with trait `Copy` | @@ -66,13 +65,12 @@ LL | pub size: Vector2, | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K` | note: required for `Vector2` to implement `Clone` - --> $DIR/missing-bound-in-derive-copy-impl-2.rs:5:12 + --> $DIR/missing-bound-in-derive-copy-impl-2.rs:4:23 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion + | ^^^^^ LL | pub struct Vector2 { - | ^^^^^^^ ---- unsatisfied trait bound - = help: consider manually implementing `Clone` to avoid undesired bounds + | ---- unsatisfied trait bound introduced in this `derive` macro help: consider further restricting type parameter `K` with trait `Copy` | LL | pub struct AABB { diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed index bd1785e35112..74df1d7c7cfd 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed @@ -7,8 +7,8 @@ pub struct Vector2{ pub y: T } -#[derive(Debug, Copy, Clone)] -pub struct AABB { //~ ERROR the trait `Copy` cannot be implemented for this type +#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type +pub struct AABB{ pub loc: Vector2, //~ ERROR `K` doesn't implement `Debug` //~^ ERROR `K` doesn't implement `Debug` pub size: Vector2 //~ ERROR `K` doesn't implement `Debug` diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs index 36502044bd46..8550a4d72476 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs @@ -7,8 +7,8 @@ pub struct Vector2{ pub y: T } -#[derive(Debug, Copy, Clone)] -pub struct AABB { //~ ERROR the trait `Copy` cannot be implemented for this type +#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type +pub struct AABB{ pub loc: Vector2, //~ ERROR `K` doesn't implement `Debug` //~^ ERROR `K` doesn't implement `Debug` pub size: Vector2 //~ ERROR `K` doesn't implement `Debug` diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr index cc80e7297e48..e3375b67c86d 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr @@ -1,10 +1,9 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/missing-bound-in-derive-copy-impl-3.rs:11:12 + --> $DIR/missing-bound-in-derive-copy-impl-3.rs:10:17 | LL | #[derive(Debug, Copy, Clone)] - | ---- in this derive macro expansion -LL | pub struct AABB { - | ^^^^ + | ^^^^ +LL | pub struct AABB{ LL | pub loc: Vector2, | ------------------- this field does not implement `Copy` | @@ -15,7 +14,7 @@ LL | pub loc: Vector2, | ^^^^^^^^^^ help: consider further restricting type parameter `K` with trait `Debug` | -LL | pub struct AABB { +LL | pub struct AABB{ | +++++++ error[E0277]: `K` doesn't implement `Debug` @@ -31,7 +30,7 @@ LL | pub struct Vector2{ | ^^^^^ required by this bound in `Vector2` help: consider further restricting type parameter `K` with trait `Debug` | -LL | pub struct AABB { +LL | pub struct AABB{ | +++++++++++++++++ error[E0277]: `K` doesn't implement `Debug` @@ -39,13 +38,13 @@ error[E0277]: `K` doesn't implement `Debug` | LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion -LL | pub struct AABB { +LL | pub struct AABB{ LL | pub loc: Vector2, | ^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `K` | help: consider further restricting type parameter `K` with trait `Debug` | -LL | pub struct AABB { +LL | pub struct AABB{ | +++++++++++++++++ error[E0277]: `K` doesn't implement `Debug` @@ -59,7 +58,7 @@ LL | pub size: Vector2 | help: consider further restricting type parameter `K` with trait `Debug` | -LL | pub struct AABB { +LL | pub struct AABB{ | +++++++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs index 60a9074e5c0d..0ffc1b8f7a25 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs @@ -6,8 +6,8 @@ pub struct Vector2 { pub y: T, } -#[derive(Debug, Copy, Clone)] -pub struct AABB { //~ ERROR the trait `Copy` cannot be implemented for this type +#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type +pub struct AABB { pub loc: Vector2, //~^ ERROR doesn't implement `Debug` //~| ERROR `K: Copy` is not satisfied diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr index 55d6391f975e..645d6ebb3961 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr @@ -1,10 +1,9 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/missing-bound-in-derive-copy-impl.rs:10:12 + --> $DIR/missing-bound-in-derive-copy-impl.rs:9:17 | LL | #[derive(Debug, Copy, Clone)] - | ---- in this derive macro expansion + | ^^^^ LL | pub struct AABB { - | ^^^^ LL | pub loc: Vector2, | ------------------- this field does not implement `Copy` | @@ -60,13 +59,12 @@ LL | pub loc: Vector2, | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K` | note: required for `Vector2` to implement `Debug` - --> $DIR/missing-bound-in-derive-copy-impl.rs:4:12 + --> $DIR/missing-bound-in-derive-copy-impl.rs:3:10 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion + | ^^^^^ LL | pub struct Vector2 { - | ^^^^^^^ ---- unsatisfied trait bound - = help: consider manually implementing `Debug` to avoid undesired bounds + | ---- unsatisfied trait bound introduced in this `derive` macro = note: required for the cast from `&Vector2` to `&dyn Debug` help: consider restricting type parameter `K` with trait `Copy` | @@ -130,13 +128,12 @@ LL | pub size: Vector2, | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K` | note: required for `Vector2` to implement `Clone` - --> $DIR/missing-bound-in-derive-copy-impl.rs:4:12 + --> $DIR/missing-bound-in-derive-copy-impl.rs:3:23 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion + | ^^^^^ LL | pub struct Vector2 { - | ^^^^^^^ ---- unsatisfied trait bound - = help: consider manually implementing `Clone` to avoid undesired bounds + | ---- unsatisfied trait bound introduced in this `derive` macro help: consider restricting type parameter `K` with trait `Copy` | LL | pub struct AABB { diff --git a/tests/ui/suggestions/path-display.stderr b/tests/ui/suggestions/path-display.stderr index df9e855bb714..0c7271b3c1c3 100644 --- a/tests/ui/suggestions/path-display.stderr +++ b/tests/ui/suggestions/path-display.stderr @@ -10,6 +10,7 @@ LL | println!("{}", path); = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data = note: required for `&Path` to implement `std::fmt::Display` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `PathBuf` doesn't implement `std::fmt::Display` --> $DIR/path-display.rs:9:20 @@ -22,6 +23,7 @@ LL | println!("{}", path); = help: the trait `std::fmt::Display` is not implemented for `PathBuf` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/struct-lit-placeholder-path.rs b/tests/ui/suggestions/struct-lit-placeholder-path.rs deleted file mode 100644 index 190440dd1569..000000000000 --- a/tests/ui/suggestions/struct-lit-placeholder-path.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Regression test for issue #98282. - -mod blah { - pub struct Stuff { x: i32 } - pub fn do_stuff(_: Stuff) {} -} - -fn main() { - blah::do_stuff(_ { x: 10 }); - //~^ ERROR placeholder `_` is not allowed for the path in struct literals - //~| NOTE not allowed in struct literals - //~| HELP replace it with the correct type -} - -#[cfg(FALSE)] -fn disabled() { - blah::do_stuff(_ { x: 10 }); - //~^ ERROR placeholder `_` is not allowed for the path in struct literals - //~| NOTE not allowed in struct literals - //~| HELP replace it with the correct type -} diff --git a/tests/ui/suggestions/struct-lit-placeholder-path.stderr b/tests/ui/suggestions/struct-lit-placeholder-path.stderr deleted file mode 100644 index 8cd24b6f268d..000000000000 --- a/tests/ui/suggestions/struct-lit-placeholder-path.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: placeholder `_` is not allowed for the path in struct literals - --> $DIR/struct-lit-placeholder-path.rs:9:20 - | -LL | blah::do_stuff(_ { x: 10 }); - | ^ not allowed in struct literals - | -help: replace it with the correct type - | -LL - blah::do_stuff(_ { x: 10 }); -LL + blah::do_stuff(/* Type */ { x: 10 }); - | - -error: placeholder `_` is not allowed for the path in struct literals - --> $DIR/struct-lit-placeholder-path.rs:17:20 - | -LL | blah::do_stuff(_ { x: 10 }); - | ^ not allowed in struct literals - | -help: replace it with the correct type - | -LL - blah::do_stuff(_ { x: 10 }); -LL + blah::do_stuff(/* Type */ { x: 10 }); - | - -error: aborting due to 2 previous errors - diff --git a/tests/ui/suggestions/suggest-dereferencing-index.stderr b/tests/ui/suggestions/suggest-dereferencing-index.stderr index 541c625ebb10..1e8beaa3711e 100644 --- a/tests/ui/suggestions/suggest-dereferencing-index.stderr +++ b/tests/ui/suggestions/suggest-dereferencing-index.stderr @@ -13,6 +13,8 @@ help: the following other types implement trait `SliceIndex` | = note: `usize` implements `SliceIndex` = note: required for `[{integer}]` to implement `Index<&usize>` + = note: 1 redundant requirement hidden + = note: required for `[{integer}; 3]` to implement `Index<&usize>` help: dereference this index | LL | let one_item_please: i32 = [1, 2, 3][*i]; diff --git a/tests/ui/suggestions/suggest-derive-default-for-enums.rs b/tests/ui/suggestions/suggest-derive-default-for-enums.rs deleted file mode 100644 index a75123c27d18..000000000000 --- a/tests/ui/suggestions/suggest-derive-default-for-enums.rs +++ /dev/null @@ -1,15 +0,0 @@ -// A test showing that we suggest deriving `Default` for enums. -enum MyEnum { - A, -} - -trait Foo { - fn bar(&self) {} -} -impl Foo for T {} - -fn main() { - let x = MyEnum::A; - x.bar(); - //~^ ERROR the method `bar` exists for enum `MyEnum`, but its trait bounds were not satisfied -} diff --git a/tests/ui/suggestions/suggest-derive-default-for-enums.stderr b/tests/ui/suggestions/suggest-derive-default-for-enums.stderr deleted file mode 100644 index 977535c83dae..000000000000 --- a/tests/ui/suggestions/suggest-derive-default-for-enums.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0599]: the method `bar` exists for enum `MyEnum`, but its trait bounds were not satisfied - --> $DIR/suggest-derive-default-for-enums.rs:13:7 - | -LL | enum MyEnum { - | ----------- method `bar` not found for this enum because it doesn't satisfy `MyEnum: Default` or `MyEnum: Foo` -... -LL | x.bar(); - | ^^^ method cannot be called on `MyEnum` due to unsatisfied trait bounds - | -note: trait bound `MyEnum: Default` was not satisfied - --> $DIR/suggest-derive-default-for-enums.rs:9:9 - | -LL | impl Foo for T {} - | ^^^^^^^ --- - - | | - | unsatisfied trait bound introduced here -help: consider annotating `MyEnum` with `#[derive(Default)]` - | -LL + #[derive(Default)] -LL | enum MyEnum { - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/suggestions/suggest-tryinto-edition-change.rs b/tests/ui/suggestions/suggest-tryinto-edition-change.rs index 06675a8e530b..f45670ae7c1e 100644 --- a/tests/ui/suggestions/suggest-tryinto-edition-change.rs +++ b/tests/ui/suggestions/suggest-tryinto-edition-change.rs @@ -8,17 +8,17 @@ fn test() { //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021 let _i: i16 = TryFrom::try_from(0_i32).unwrap(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of undeclared type //~| NOTE use of undeclared type //~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021 let _i: i16 = TryInto::try_into(0_i32).unwrap(); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of undeclared type //~| NOTE use of undeclared type //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021 let _v: Vec<_> = FromIterator::from_iter(&[1]); - //~^ ERROR cannot find + //~^ ERROR failed to resolve: use of undeclared type //~| NOTE use of undeclared type //~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021 } diff --git a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr index b0d150f49c73..8ab8a1716b14 100644 --- a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr +++ b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find type `TryFrom` in this scope +error[E0433]: failed to resolve: use of undeclared type `TryFrom` --> $DIR/suggest-tryinto-edition-change.rs:10:19 | LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap(); @@ -10,7 +10,7 @@ help: consider importing this trait LL + use std::convert::TryFrom; | -error[E0433]: cannot find type `TryInto` in this scope +error[E0433]: failed to resolve: use of undeclared type `TryInto` --> $DIR/suggest-tryinto-edition-change.rs:15:19 | LL | let _i: i16 = TryInto::try_into(0_i32).unwrap(); @@ -22,7 +22,7 @@ help: consider importing this trait LL + use std::convert::TryInto; | -error[E0433]: cannot find type `FromIterator` in this scope +error[E0433]: failed to resolve: use of undeclared type `FromIterator` --> $DIR/suggest-tryinto-edition-change.rs:20:22 | LL | let _v: Vec<_> = FromIterator::from_iter(&[1]); diff --git a/tests/ui/suggestions/trait-hidden-method.stderr b/tests/ui/suggestions/trait-hidden-method.stderr index c764034d8466..87753e578462 100644 --- a/tests/ui/suggestions/trait-hidden-method.stderr +++ b/tests/ui/suggestions/trait-hidden-method.stderr @@ -2,7 +2,7 @@ error[E0191]: the value of the associated type `Item` in `Iterator` must be spec --> $DIR/trait-hidden-method.rs:4:33 | LL | Box::new(1..=10) as Box - | ^^^^^^^^ help: specify the associated type: `Iterator` + | ^^^^^^^^ help: specify the associated type: `Iterator` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/undeclared-module-alloc.rs b/tests/ui/suggestions/undeclared-module-alloc.rs index a19e828f2a9b..a0bddc94471c 100644 --- a/tests/ui/suggestions/undeclared-module-alloc.rs +++ b/tests/ui/suggestions/undeclared-module-alloc.rs @@ -1,5 +1,5 @@ //@ edition:2018 -use alloc::rc::Rc; //~ ERROR cannot find module or crate `alloc` +use alloc::rc::Rc; //~ ERROR failed to resolve: use of unresolved module or unlinked crate `alloc` fn main() {} diff --git a/tests/ui/suggestions/undeclared-module-alloc.stderr b/tests/ui/suggestions/undeclared-module-alloc.stderr index c73efa8a3614..00e498aa9ba9 100644 --- a/tests/ui/suggestions/undeclared-module-alloc.stderr +++ b/tests/ui/suggestions/undeclared-module-alloc.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `alloc` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `alloc` --> $DIR/undeclared-module-alloc.rs:3:5 | LL | use alloc::rc::Rc; diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr index 0fab0f003375..fd9d693525cc 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr +++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr @@ -1,4 +1,4 @@ -error: target feature `soft-float` cannot be enabled with `#[target_feature]`: use a soft-float target instead +error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI --> $DIR/abi-incompatible-target-feature-attribute.rs:17:32 | LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))] diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs index c6370f01c47d..0cdaf3358d25 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs @@ -19,5 +19,4 @@ extern crate minicore; use minicore::*; //~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly -//[riscv]~? WARN unstable feature specified for `-Ctarget-feature` -//[x86]~? WARN use a soft-float target instead +//~? WARN unstable feature specified for `-Ctarget-feature` diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr index a8395f2d4690..90a9665fb41b 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr @@ -1,7 +1,6 @@ -warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: use a soft-float target instead +warning: unstable feature specified for `-Ctarget-feature`: `soft-float` | - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116344 + = note: this feature is not stably supported; its behavior can change in the future warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly | diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index ea3bbbed273c..fc3763820cbe 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -20,7 +20,6 @@ // gate-test-sparc_target_feature // gate-test-x87_target_feature // gate-test-m68k_target_feature -// gate-test-avr_target_feature #[target_feature(enable = "x87")] //~^ ERROR: currently unstable diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index f0de5a958e86..67df09fd369e 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `x87` is currently unstable - --> $DIR/gate.rs:25:18 + --> $DIR/gate.rs:24:18 | LL | #[target_feature(enable = "x87")] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/target-feature-detection.rs b/tests/ui/target-feature/target-feature-detection.rs index 9a9102bf7d54..41fc24691312 100644 --- a/tests/ui/target-feature/target-feature-detection.rs +++ b/tests/ui/target-feature/target-feature-detection.rs @@ -4,6 +4,9 @@ //@ run-pass //@ ignore-i586 (no SSE2) +#![allow(stable_features)] +#![feature(cfg_target_feature)] + fn main() { if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { assert!( diff --git a/tests/ui/target-feature/x86-soft-float-cfg.rs b/tests/ui/target-feature/x86-soft-float-cfg.rs deleted file mode 100644 index 8718338ca105..000000000000 --- a/tests/ui/target-feature/x86-soft-float-cfg.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! The soft-float target feature is *not* exposed as `cfg` on x86. -//@ revisions: soft hard -//@[hard] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@[hard] needs-llvm-components: x86 -//@[soft] compile-flags: --target=x86_64-unknown-none --crate-type=lib -//@[soft] needs-llvm-components: x86 -//@ check-pass -//@ ignore-backends: gcc -//@ add-minicore -#![feature(no_core)] -#![no_core] -#![allow(unexpected_cfgs)] - -// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this -// complains about the missing macro rather than showing the error... but that's good enough. -#[cfg(target_feature = "soft-float")] -compile_error!("the soft-float feature should NOT be exposed in `cfg`"); diff --git a/tests/ui/target_modifiers/auxiliary/disabled_softfloat.rs b/tests/ui/target_modifiers/auxiliary/disabled_softfloat.rs deleted file mode 100644 index 0063d925deca..000000000000 --- a/tests/ui/target_modifiers/auxiliary/disabled_softfloat.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ add-minicore -//@ no-prefer-dynamic -//@ compile-flags: --target=s390x-unknown-linux-gnu -//@ needs-llvm-components: systemz - -#![feature(no_core)] -#![crate_type = "rlib"] -#![no_core] diff --git a/tests/ui/target_modifiers/auxiliary/enabled_softfloat.rs b/tests/ui/target_modifiers/auxiliary/enabled_softfloat.rs deleted file mode 100644 index 7439a1eb69b5..000000000000 --- a/tests/ui/target_modifiers/auxiliary/enabled_softfloat.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ add-minicore -//@ no-prefer-dynamic -//@ compile-flags: --target=s390x-unknown-none-softfloat -//@ needs-llvm-components: systemz - -#![feature(no_core)] -#![crate_type = "rlib"] -#![no_core] diff --git a/tests/ui/target_modifiers/incompatible_softfloat_targets.disable-softfloat.stderr b/tests/ui/target_modifiers/incompatible_softfloat_targets.disable-softfloat.stderr deleted file mode 100644 index 090ebe6ca14c..000000000000 --- a/tests/ui/target_modifiers/incompatible_softfloat_targets.disable-softfloat.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0461]: couldn't find crate `enabled_softfloat` with expected target triple s390x-unknown-linux-gnu - --> $DIR/incompatible_softfloat_targets.rs:17:1 - | -LL | extern crate enabled_softfloat; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the following crate versions were found: - crate `enabled_softfloat`, target triple s390x-unknown-none-softfloat: $TEST_BUILD_DIR/auxiliary/libenabled_softfloat.rlib - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0461`. diff --git a/tests/ui/target_modifiers/incompatible_softfloat_targets.enable-softfloat.stderr b/tests/ui/target_modifiers/incompatible_softfloat_targets.enable-softfloat.stderr deleted file mode 100644 index 9adb6d265651..000000000000 --- a/tests/ui/target_modifiers/incompatible_softfloat_targets.enable-softfloat.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0461]: couldn't find crate `disabled_softfloat` with expected target triple s390x-unknown-none-softfloat - --> $DIR/incompatible_softfloat_targets.rs:19:1 - | -LL | extern crate disabled_softfloat; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the following crate versions were found: - crate `disabled_softfloat`, target triple s390x-unknown-linux-gnu: $TEST_BUILD_DIR/auxiliary/libdisabled_softfloat.rlib - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0461`. diff --git a/tests/ui/target_modifiers/incompatible_softfloat_targets.rs b/tests/ui/target_modifiers/incompatible_softfloat_targets.rs deleted file mode 100644 index 3d253c5f0c78..000000000000 --- a/tests/ui/target_modifiers/incompatible_softfloat_targets.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ add-minicore -//@ aux-build: disabled_softfloat.rs -//@ aux-build: enabled_softfloat.rs -//@ revisions: disable-softfloat enable-softfloat -//@ check-fail -//@ [enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat -//@ [enable-softfloat] needs-llvm-components: systemz -//@ [disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu -//@ [disable-softfloat] needs-llvm-components: systemz -//@ ignore-backends: gcc - - -#![feature(no_core)] -#![crate_type = "rlib"] -#![no_core] - -extern crate enabled_softfloat; -//[disable-softfloat]~^ ERROR couldn't find crate `enabled_softfloat` with expected target triple s390x-unknown-linux-gnu -extern crate disabled_softfloat; -//[enable-softfloat]~^ ERROR couldn't find crate `disabled_softfloat` with expected target triple s390x-unknown-none-softfloat diff --git a/tests/ui/test-attrs/issue-109816.rs b/tests/ui/test-attrs/issue-109816.rs index f40f99946da1..c7caae67fefa 100644 --- a/tests/ui/test-attrs/issue-109816.rs +++ b/tests/ui/test-attrs/issue-109816.rs @@ -1,5 +1,4 @@ //@ compile-flags: --test -//@ reference: attributes.testing.test.allowed-positions fn align_offset_weird_strides() { #[test] diff --git a/tests/ui/test-attrs/issue-109816.stderr b/tests/ui/test-attrs/issue-109816.stderr index 118c8d878290..270f4e0a6668 100644 --- a/tests/ui/test-attrs/issue-109816.stderr +++ b/tests/ui/test-attrs/issue-109816.stderr @@ -1,5 +1,5 @@ error: the `#[test]` attribute may only be used on a free function - --> $DIR/issue-109816.rs:5:5 + --> $DIR/issue-109816.rs:4:5 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.rs b/tests/ui/test-attrs/test-attr-non-associated-functions.rs index 9d28f59888a0..4bf337d0f1b3 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.rs +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.rs @@ -1,5 +1,4 @@ //@ compile-flags:--test -//@ reference: attributes.testing.test.allowed-positions struct A {} diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr index fda28ee28a07..13914971b558 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr @@ -1,5 +1,5 @@ error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-attr-non-associated-functions.rs:7:5 + --> $DIR/test-attr-non-associated-functions.rs:6:5 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -11,7 +11,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-attr-non-associated-functions.rs:12:5 + --> $DIR/test-attr-non-associated-functions.rs:11:5 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions diff --git a/tests/ui/test-attrs/test-function-signature.rs b/tests/ui/test-attrs/test-function-signature.rs index 4a6c0e8450ce..0f43245be6f6 100644 --- a/tests/ui/test-attrs/test-function-signature.rs +++ b/tests/ui/test-attrs/test-function-signature.rs @@ -1,5 +1,4 @@ //@ compile-flags: --test -//@ reference: attributes.testing.test.allowed-positions #[test] fn foo() -> Result<(), ()> { diff --git a/tests/ui/test-attrs/test-function-signature.stderr b/tests/ui/test-attrs/test-function-signature.stderr index 7fdaaed1aebc..55d09970b320 100644 --- a/tests/ui/test-attrs/test-function-signature.stderr +++ b/tests/ui/test-attrs/test-function-signature.stderr @@ -1,29 +1,29 @@ error: functions used as tests can not have any arguments - --> $DIR/test-function-signature.rs:15:1 + --> $DIR/test-function-signature.rs:14:1 | LL | fn baz(val: i32) {} | ^^^^^^^^^^^^^^^^^^^ error: functions used as tests can not have any non-lifetime generic parameters - --> $DIR/test-function-signature.rs:23:1 + --> $DIR/test-function-signature.rs:22:1 | LL | fn type_generic() {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: functions used as tests can not have any non-lifetime generic parameters - --> $DIR/test-function-signature.rs:26:1 + --> $DIR/test-function-signature.rs:25:1 | LL | fn const_generic() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: functions used as tests can not have any arguments - --> $DIR/test-function-signature.rs:31:5 + --> $DIR/test-function-signature.rs:30:5 | LL | fn foo(arg: ()) {} | ^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `i32: Termination` is not satisfied - --> $DIR/test-function-signature.rs:10:13 + --> $DIR/test-function-signature.rs:9:13 | LL | #[test] | ------- in this attribute macro expansion diff --git a/tests/ui/test-attrs/test-on-not-fn.rs b/tests/ui/test-attrs/test-on-not-fn.rs index 57ae2b19cf5f..16e9cd8d5b8d 100644 --- a/tests/ui/test-attrs/test-on-not-fn.rs +++ b/tests/ui/test-attrs/test-on-not-fn.rs @@ -1,5 +1,4 @@ //@ compile-flags: --test -//@ reference: attributes.testing.test.allowed-positions #[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod test {} diff --git a/tests/ui/test-attrs/test-on-not-fn.stderr b/tests/ui/test-attrs/test-on-not-fn.stderr index 22e479268856..db8bed100a63 100644 --- a/tests/ui/test-attrs/test-on-not-fn.stderr +++ b/tests/ui/test-attrs/test-on-not-fn.stderr @@ -1,5 +1,5 @@ error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:4:1 + --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -13,7 +13,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:7:1 + --> $DIR/test-on-not-fn.rs:6:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -33,7 +33,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:21:1 + --> $DIR/test-on-not-fn.rs:20:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -47,7 +47,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:24:1 + --> $DIR/test-on-not-fn.rs:23:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -61,7 +61,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:27:1 + --> $DIR/test-on-not-fn.rs:26:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -75,7 +75,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:30:1 + --> $DIR/test-on-not-fn.rs:29:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -89,7 +89,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:33:1 + --> $DIR/test-on-not-fn.rs:32:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -103,7 +103,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:36:1 + --> $DIR/test-on-not-fn.rs:35:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -119,7 +119,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:41:1 + --> $DIR/test-on-not-fn.rs:40:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -133,7 +133,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:44:1 + --> $DIR/test-on-not-fn.rs:43:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -150,7 +150,7 @@ LL + #[cfg(test)] | error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:51:1 + --> $DIR/test-on-not-fn.rs:50:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions @@ -168,7 +168,7 @@ LL + #[cfg(test)] | warning: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-not-fn.rs:62:1 + --> $DIR/test-on-not-fn.rs:61:1 | LL | #[test] | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions diff --git a/tests/ui/test-attrs/test-passed.rs b/tests/ui/test-attrs/test-passed.rs index 034051e4eb6d..959470adcc42 100644 --- a/tests/ui/test-attrs/test-passed.rs +++ b/tests/ui/test-attrs/test-passed.rs @@ -4,7 +4,6 @@ //@ run-pass //@ check-run-results //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" -//@ reference: attributes.testing.test.success // Tests the output of the test harness with only passed tests. diff --git a/tests/ui/test-attrs/test-should-panic-attr.rs b/tests/ui/test-attrs/test-should-panic-attr.rs index b095099daad0..e6de07d00941 100644 --- a/tests/ui/test-attrs/test-should-panic-attr.rs +++ b/tests/ui/test-attrs/test-should-panic-attr.rs @@ -1,5 +1,4 @@ //@ compile-flags: --test -//@ reference: attributes.testing.should_panic.syntax #[test] #[should_panic = "foo"] diff --git a/tests/ui/test-attrs/test-should-panic-attr.stderr b/tests/ui/test-attrs/test-should-panic-attr.stderr index 48f6b0d37cb1..475a55ad0cbc 100644 --- a/tests/ui/test-attrs/test-should-panic-attr.stderr +++ b/tests/ui/test-attrs/test-should-panic-attr.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `should_panic` attribute input - --> $DIR/test-should-panic-attr.rs:11:1 + --> $DIR/test-should-panic-attr.rs:10:1 | LL | #[should_panic(expected)] | ^^^^^^^^^^^^^^^--------^^ @@ -19,7 +19,7 @@ LL + #[should_panic] | error[E0539]: malformed `should_panic` attribute input - --> $DIR/test-should-panic-attr.rs:20:1 + --> $DIR/test-should-panic-attr.rs:19:1 | LL | #[should_panic(expect)] | ^^^^^^^^^^^^^^--------^ @@ -39,7 +39,7 @@ LL + #[should_panic] | error[E0539]: malformed `should_panic` attribute input - --> $DIR/test-should-panic-attr.rs:29:1 + --> $DIR/test-should-panic-attr.rs:28:1 | LL | #[should_panic(expected(foo, bar))] | ^^^^^^^^^^^^^^^------------------^^ @@ -60,7 +60,7 @@ LL + #[should_panic] | error[E0805]: malformed `should_panic` attribute input - --> $DIR/test-should-panic-attr.rs:38:1 + --> $DIR/test-should-panic-attr.rs:37:1 | LL | #[should_panic(expected = "foo", bar)] | ^^^^^^^^^^^^^^-----------------------^ diff --git a/tests/ui/test-attrs/test-should-panic-failed-show-span.rs b/tests/ui/test-attrs/test-should-panic-failed-show-span.rs index f8c1840ab79f..22a6f4a835e2 100644 --- a/tests/ui/test-attrs/test-should-panic-failed-show-span.rs +++ b/tests/ui/test-attrs/test-should-panic-failed-show-span.rs @@ -8,7 +8,6 @@ //@ normalize-stdout: "TypeId\(0x[0-9a-f]+\)" -> "TypeId($$HEX)" //@ needs-threads //@ needs-unwind (panic) -//@ reference: attributes.testing.should_panic.expected #[test] #[should_panic] diff --git a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr index 398479f15fa2..ab36bc2beb9e 100644 --- a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr +++ b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr @@ -1,13 +1,13 @@ -thread 'should_panic_with_any_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:16:5: +thread 'should_panic_with_any_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:15:5: Panic! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'should_panic_with_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:22:5: +thread 'should_panic_with_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:21:5: message -thread 'should_panic_with_substring_panics_with_incorrect_string' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:40:5: +thread 'should_panic_with_substring_panics_with_incorrect_string' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:39:5: ZOMGWTFBBQ -thread 'should_panic_with_substring_panics_with_non_string_value' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:47:5: +thread 'should_panic_with_substring_panics_with_non_string_value' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:46:5: Box diff --git a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout index c28403a11e8e..492f54debc82 100644 --- a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout +++ b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout @@ -10,9 +10,9 @@ test should_panic_with_substring_panics_with_non_string_value - should panic ... failures: ---- should_panic_with_any_message_does_not_panic stdout ---- -note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:27:4 +note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:26:4 ---- should_panic_with_message_does_not_panic stdout ---- -note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:33:4 +note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:32:4 ---- should_panic_with_substring_panics_with_incorrect_string stdout ---- note: panic did not contain expected string panic message: "ZOMGWTFBBQ" diff --git a/tests/ui/test-attrs/test-vs-cfg-test.rs b/tests/ui/test-attrs/test-vs-cfg-test.rs index 634511fdff39..d7d9e61103c9 100644 --- a/tests/ui/test-attrs/test-vs-cfg-test.rs +++ b/tests/ui/test-attrs/test-vs-cfg-test.rs @@ -1,6 +1,5 @@ //@ run-pass //@ compile-flags: --cfg test -//@ reference: cfg.test // Make sure `--cfg test` does not inject test harness diff --git a/tests/ui/thir-print/offset_of.stdout b/tests/ui/thir-print/offset_of.stdout index 25c099438754..b3791a2446cb 100644 --- a/tests/ui/thir-print/offset_of.stdout +++ b/tests/ui/thir-print/offset_of.stdout @@ -68,7 +68,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::concrete).10) - span: $DIR/offset_of.rs:37:5: 37:33 (#0) + span: $DIR/offset_of.rs:37:5: 1440:57 (#0) } } Stmt { @@ -117,7 +117,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::concrete).20) - span: $DIR/offset_of.rs:38:5: 38:33 (#0) + span: $DIR/offset_of.rs:38:5: 1440:57 (#0) } } Stmt { @@ -166,7 +166,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::concrete).30) - span: $DIR/offset_of.rs:39:5: 39:34 (#0) + span: $DIR/offset_of.rs:39:5: 1440:57 (#0) } } Stmt { @@ -215,7 +215,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::concrete).40) - span: $DIR/offset_of.rs:40:5: 40:36 (#0) + span: $DIR/offset_of.rs:40:5: 1440:57 (#0) } } Stmt { @@ -264,7 +264,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::concrete).50) - span: $DIR/offset_of.rs:41:5: 41:36 (#0) + span: $DIR/offset_of.rs:41:5: 1440:57 (#0) } } ] @@ -864,7 +864,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::generic).12) - span: $DIR/offset_of.rs:45:5: 45:37 (#0) + span: $DIR/offset_of.rs:45:5: 1440:57 (#0) } } Stmt { @@ -913,7 +913,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::generic).24) - span: $DIR/offset_of.rs:46:5: 46:37 (#0) + span: $DIR/offset_of.rs:46:5: 1440:57 (#0) } } Stmt { @@ -962,7 +962,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::generic).36) - span: $DIR/offset_of.rs:47:5: 47:37 (#0) + span: $DIR/offset_of.rs:47:5: 1440:57 (#0) } } Stmt { @@ -1011,7 +1011,7 @@ body: ) else_block: None hir_id: HirId(DefId(offset_of::generic).48) - span: $DIR/offset_of.rs:48:5: 48:37 (#0) + span: $DIR/offset_of.rs:48:5: 1440:57 (#0) } } ] diff --git a/tests/ui/thir-print/str-patterns.stdout b/tests/ui/thir-print/str-patterns.stdout index 09212e7d68ae..6941ab15130f 100644 --- a/tests/ui/thir-print/str-patterns.stdout +++ b/tests/ui/thir-print/str-patterns.stdout @@ -10,7 +10,6 @@ Thir { span: $DIR/str-patterns.rs:11:9: 11:16 (#0), extra: None, kind: Deref { - pin: Not, subpattern: Pat { ty: str, span: $DIR/str-patterns.rs:11:9: 11:16 (#0), @@ -51,7 +50,6 @@ Thir { }, ), kind: Deref { - pin: Not, subpattern: Pat { ty: str, span: $DIR/str-patterns.rs:12:9: 12:17 (#0), diff --git a/tests/ui/thread-local/no-unstable.stderr b/tests/ui/thread-local/no-unstable.stderr index 438020d00b7d..fbcd804d9178 100644 --- a/tests/ui/thread-local/no-unstable.stderr +++ b/tests/ui/thread-local/no-unstable.stderr @@ -10,6 +10,7 @@ LL | | } = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable = note: the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable = note: the `#[rustc_dummy]` attribute is used for rustc unit tests + = note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0658]: use of an internal attribute --> $DIR/no-unstable.rs:1:1 @@ -23,6 +24,7 @@ LL | | } = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable = note: the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable = note: the `#[rustc_dummy]` attribute is used for rustc unit tests + = note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0658]: `#[used(linker)]` is currently unstable --> $DIR/no-unstable.rs:1:1 @@ -36,6 +38,7 @@ LL | | } = note: see issue #93798 for more information = help: add `#![feature(used_with_arg)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[used]` attribute cannot be used on constants --> $DIR/no-unstable.rs:1:1 @@ -47,6 +50,7 @@ LL | | } | |_^ | = help: `#[used]` can only be applied to statics + = note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/threads-sendsync/tls-init-on-init.rs b/tests/ui/threads-sendsync/tls-init-on-init.rs index d7c110e80e85..1cae19aae86c 100644 --- a/tests/ui/threads-sendsync/tls-init-on-init.rs +++ b/tests/ui/threads-sendsync/tls-init-on-init.rs @@ -1,5 +1,7 @@ //@ run-pass +#![allow(stable_features)] //@ needs-threads +#![feature(thread_local_try_with)] use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; diff --git a/tests/ui/threads-sendsync/tls-try-with.rs b/tests/ui/threads-sendsync/tls-try-with.rs index 1d0c5de7d87f..04071e77daa4 100644 --- a/tests/ui/threads-sendsync/tls-try-with.rs +++ b/tests/ui/threads-sendsync/tls-try-with.rs @@ -1,5 +1,7 @@ //@ run-pass +#![allow(stable_features)] //@ needs-threads +#![feature(thread_local_try_with)] use std::thread; diff --git a/tests/ui/tool-attributes/tool-attributes-shadowing.rs b/tests/ui/tool-attributes/tool-attributes-shadowing.rs index 582c99b089f5..21bbaa3a7105 100644 --- a/tests/ui/tool-attributes/tool-attributes-shadowing.rs +++ b/tests/ui/tool-attributes/tool-attributes-shadowing.rs @@ -1,4 +1,4 @@ mod rustfmt {} -#[rustfmt::skip] //~ ERROR: cannot find `skip` in `rustfmt` +#[rustfmt::skip] //~ ERROR failed to resolve: could not find `skip` in `rustfmt` fn main() {} diff --git a/tests/ui/tool-attributes/tool-attributes-shadowing.stderr b/tests/ui/tool-attributes/tool-attributes-shadowing.stderr index 5ca1fdf586d4..f2da61727228 100644 --- a/tests/ui/tool-attributes/tool-attributes-shadowing.stderr +++ b/tests/ui/tool-attributes/tool-attributes-shadowing.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find `skip` in `rustfmt` +error[E0433]: failed to resolve: could not find `skip` in `rustfmt` --> $DIR/tool-attributes-shadowing.rs:3:12 | LL | #[rustfmt::skip] diff --git a/tests/ui/tool-attributes/unknown-tool-name.rs b/tests/ui/tool-attributes/unknown-tool-name.rs index a87385329eff..ba21aecc230a 100644 --- a/tests/ui/tool-attributes/unknown-tool-name.rs +++ b/tests/ui/tool-attributes/unknown-tool-name.rs @@ -1,3 +1,2 @@ -#[foo::bar] //~ ERROR: cannot find module or crate `foo` -//~^ NOTE: use of unresolved module or unlinked crate `foo` +#[foo::bar] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `foo` fn main() {} diff --git a/tests/ui/tool-attributes/unknown-tool-name.stderr b/tests/ui/tool-attributes/unknown-tool-name.stderr index 5a2b0e840be3..9b636fcb0bdd 100644 --- a/tests/ui/tool-attributes/unknown-tool-name.stderr +++ b/tests/ui/tool-attributes/unknown-tool-name.stderr @@ -1,4 +1,4 @@ -error[E0433]: cannot find module or crate `foo` in this scope +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo` --> $DIR/unknown-tool-name.rs:1:3 | LL | #[foo::bar] diff --git a/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr b/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr index b459ad47e067..4ce936582f43 100644 --- a/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr +++ b/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr @@ -22,7 +22,7 @@ LL | type P = [u8]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `main::Trait::P` +note: required by a bound in `Trait::P` --> $DIR/suggest-maybe-sized-bound.rs:13:9 | LL | type P; diff --git a/tests/ui/traits/alias/object-fail.stderr b/tests/ui/traits/alias/object-fail.stderr index 088af686258a..d60d88434077 100644 --- a/tests/ui/traits/alias/object-fail.stderr +++ b/tests/ui/traits/alias/object-fail.stderr @@ -19,7 +19,7 @@ error[E0191]: the value of the associated type `Item` in `Iterator` must be spec --> $DIR/object-fail.rs:9:17 | LL | let _: &dyn IteratorAlias = &vec![123].into_iter(); - | ^^^^^^^^^^^^^ help: specify the associated type: `IteratorAlias` + | ^^^^^^^^^^^^^ help: specify the associated type: `IteratorAlias` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/associated-item-unsatisfied-trait-bounds.rs b/tests/ui/traits/associated-item-unsatisfied-trait-bounds.rs deleted file mode 100644 index 4fb4cd61ac51..000000000000 --- a/tests/ui/traits/associated-item-unsatisfied-trait-bounds.rs +++ /dev/null @@ -1,9 +0,0 @@ -struct Foo; -trait Bar {} -trait Baz {} -trait Bat { fn bat(&self); } -impl Bat for T where T: 'static + Bar + Baz { fn bat(&self) { println!("generic bat"); } } - -pub fn main() { - Foo::bat(()); //~ ERROR E0599 -} diff --git a/tests/ui/traits/associated-item-unsatisfied-trait-bounds.stderr b/tests/ui/traits/associated-item-unsatisfied-trait-bounds.stderr deleted file mode 100644 index 42969de715eb..000000000000 --- a/tests/ui/traits/associated-item-unsatisfied-trait-bounds.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0599]: the function or associated item `bat` exists for struct `Foo`, but its trait bounds were not satisfied - --> $DIR/associated-item-unsatisfied-trait-bounds.rs:8:10 - | -LL | struct Foo; - | ---------- function or associated item `bat` not found for this struct because `Foo` doesn't implement `Bar` or `Baz` -... -LL | Foo::bat(()); - | ^^^ function or associated item cannot be called on `Foo` due to unsatisfied trait bounds - | -note: for `bat` to be available, `Foo` must implement `Bar` and `Baz` - --> $DIR/associated-item-unsatisfied-trait-bounds.rs:5:38 - | -LL | impl Bat for T where T: 'static + Bar + Baz { fn bat(&self) { println!("generic bat"); } } - | --- - ^^^ ^^^ unsatisfied trait bound introduced here - | | - | unsatisfied trait bound introduced here -note: the traits `Bar` and `Baz` must be implemented - --> $DIR/associated-item-unsatisfied-trait-bounds.rs:2:1 - | -LL | trait Bar {} - | ^^^^^^^^^ -LL | trait Baz {} - | ^^^^^^^^^ - = help: items from traits can only be used if the trait is implemented and in scope -note: `Bat` defines an item `bat`, perhaps you need to implement it - --> $DIR/associated-item-unsatisfied-trait-bounds.rs:4:1 - | -LL | trait Bat { fn bat(&self); } - | ^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/traits/auxiliary/force_unstable.rs b/tests/ui/traits/auxiliary/force_unstable.rs deleted file mode 100644 index ce71e1241f9c..000000000000 --- a/tests/ui/traits/auxiliary/force_unstable.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ edition: 2024 -//@ compile-flags: -Zforce-unstable-if-unmarked - -// Auxiliary crate that uses `-Zforce-unstable-if-unmarked` to export an -// "unstable" trait. - -pub trait ForeignTrait {} diff --git a/tests/ui/traits/bound/on-structs-and-enums-xc.stderr b/tests/ui/traits/bound/on-structs-and-enums-xc.stderr index 472ac187a966..5064b60bfd57 100644 --- a/tests/ui/traits/bound/on-structs-and-enums-xc.stderr +++ b/tests/ui/traits/bound/on-structs-and-enums-xc.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `usize: on_structs_and_enums_xc::Trait` is not satisfied +error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/on-structs-and-enums-xc.rs:7:15 | LL | fn explode(x: Foo) {} - | ^^^^^^^^^^ the trait `on_structs_and_enums_xc::Trait` is not implemented for `usize` + | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` | note: required by a bound in `Foo` --> $DIR/auxiliary/on_structs_and_enums_xc.rs:5:18 @@ -10,11 +10,11 @@ note: required by a bound in `Foo` LL | pub struct Foo { | ^^^^^ required by this bound in `Foo` -error[E0277]: the trait bound `f32: on_structs_and_enums_xc::Trait` is not satisfied +error[E0277]: the trait bound `f32: Trait` is not satisfied --> $DIR/on-structs-and-enums-xc.rs:10:14 | LL | fn kaboom(y: Bar) {} - | ^^^^^^^^ the trait `on_structs_and_enums_xc::Trait` is not implemented for `f32` + | ^^^^^^^^ the trait `Trait` is not implemented for `f32` | note: required by a bound in `Bar` --> $DIR/auxiliary/on_structs_and_enums_xc.rs:9:16 diff --git a/tests/ui/traits/bound/on-structs-and-enums-xc1.stderr b/tests/ui/traits/bound/on-structs-and-enums-xc1.stderr index 5cf682a5045e..1f46415e2436 100644 --- a/tests/ui/traits/bound/on-structs-and-enums-xc1.stderr +++ b/tests/ui/traits/bound/on-structs-and-enums-xc1.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `{integer}: on_structs_and_enums_xc::Trait` is not satisfied +error[E0277]: the trait bound `{integer}: Trait` is not satisfied --> $DIR/on-structs-and-enums-xc1.rs:9:12 | LL | x: 3 - | ^ the trait `on_structs_and_enums_xc::Trait` is not implemented for `{integer}` + | ^ the trait `Trait` is not implemented for `{integer}` | note: required by a bound in `Foo` --> $DIR/auxiliary/on_structs_and_enums_xc.rs:5:18 @@ -10,11 +10,11 @@ note: required by a bound in `Foo` LL | pub struct Foo { | ^^^^^ required by this bound in `Foo` -error[E0277]: the trait bound `f64: on_structs_and_enums_xc::Trait` is not satisfied +error[E0277]: the trait bound `f64: Trait` is not satisfied --> $DIR/on-structs-and-enums-xc1.rs:12:14 | LL | let bar: Bar = return; - | ^^^^^^^^ the trait `on_structs_and_enums_xc::Trait` is not implemented for `f64` + | ^^^^^^^^ the trait `Trait` is not implemented for `f64` | note: required by a bound in `Bar` --> $DIR/auxiliary/on_structs_and_enums_xc.rs:9:16 diff --git a/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs b/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs index 1b04d8f91827..0da68afb5926 100644 --- a/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs +++ b/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs @@ -7,7 +7,7 @@ trait X { trait Y { fn a() -> NOT_EXIST::unknown<{}> {} - //~^ ERROR: cannot find type `NOT_EXIST` + //~^ ERROR: failed to resolve: use of undeclared type `NOT_EXIST` } trait Z { diff --git a/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr b/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr index 6a78fa04fe66..49e41f75ff35 100644 --- a/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr +++ b/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr @@ -10,7 +10,7 @@ error[E0220]: associated type `unknown` not found for `T` LL | fn a() -> T::unknown<{}> {} | ^^^^^^^ associated type `unknown` not found -error[E0433]: cannot find type `NOT_EXIST` in this scope +error[E0433]: failed to resolve: use of undeclared type `NOT_EXIST` --> $DIR/unknown-assoc-with-const-arg.rs:9:15 | LL | fn a() -> NOT_EXIST::unknown<{}> {} diff --git a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr index 6a7d3c850c92..5f4974e6f237 100644 --- a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr +++ b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr @@ -5,7 +5,7 @@ LL | type Output; | ----------- `Output` defined here ... LL | let x = &10 as &dyn Add; - | ^^^ help: specify the associated type: `Add` + | ^^^ help: specify the associated type: `Add` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call.rs b/tests/ui/traits/const-traits/call.rs index 360c08e1b7fe..c36adc4248f0 100644 --- a/tests/ui/traits/const-traits/call.rs +++ b/tests/ui/traits/const-traits/call.rs @@ -6,6 +6,7 @@ const _: () = { assert!((const || true)()); //~^ ERROR }: [const] Fn()` is not satisfied + //~| ERROR }: [const] FnMut()` is not satisfied }; fn main() {} diff --git a/tests/ui/traits/const-traits/call.stderr b/tests/ui/traits/const-traits/call.stderr index 8e32cab6dfcf..b688746e2506 100644 --- a/tests/ui/traits/const-traits/call.stderr +++ b/tests/ui/traits/const-traits/call.stderr @@ -4,6 +4,15 @@ error[E0277]: the trait bound `{closure@$DIR/call.rs:7:14: 7:22}: [const] Fn()` LL | assert!((const || true)()); | ^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error[E0277]: the trait bound `{closure@$DIR/call.rs:7:14: 7:22}: [const] FnMut()` is not satisfied + --> $DIR/call.rs:7:13 + | +LL | assert!((const || true)()); + | ^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `call` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr b/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr index dab3f14161fa..90e87c724f54 100644 --- a/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr +++ b/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr @@ -4,6 +4,15 @@ error[E0277]: the trait bound `{closure@$DIR/const_closure-const_trait_impl-ice- LL | (const || (()).foo())(); | ^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error[E0277]: the trait bound `{closure@$DIR/const_closure-const_trait_impl-ice-113381.rs:15:6: 15:14}: [const] FnMut()` is not satisfied + --> $DIR/const_closure-const_trait_impl-ice-113381.rs:15:5 + | +LL | (const || (()).foo())(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `call` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/issue-102156.stderr b/tests/ui/traits/const-traits/issue-102156.stderr index 1fce5f1b18fe..20505b685f30 100644 --- a/tests/ui/traits/const-traits/issue-102156.stderr +++ b/tests/ui/traits/const-traits/issue-102156.stderr @@ -1,27 +1,22 @@ -error[E0433]: cannot find `core` in the crate root +error[E0433]: failed to resolve: you might be missing crate `core` --> $DIR/issue-102156.rs:5:5 | LL | use core::convert::{From, TryFrom}; - | ^^^^ you might be missing crate `core` - | -help: try using `std` instead of `core` - | -LL - use core::convert::{From, TryFrom}; -LL + use std::convert::{From, TryFrom}; - | + | ^^^^ + | | + | you might be missing crate `core` + | help: try using `std` instead of `core`: `std` -error[E0433]: cannot find `core` in the crate root +error[E0433]: failed to resolve: you might be missing crate `core` --> $DIR/issue-102156.rs:5:5 | LL | use core::convert::{From, TryFrom}; - | ^^^^ you might be missing crate `core` + | ^^^^ + | | + | you might be missing crate `core` + | help: try using `std` instead of `core`: `std` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: try using `std` instead of `core` - | -LL - use core::convert::{From, TryFrom}; -LL + use std::convert::{From, TryFrom}; - | error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/issue-79450.rs b/tests/ui/traits/const-traits/issue-79450.rs index c6234f8616d7..e74da811fc80 100644 --- a/tests/ui/traits/const-traits/issue-79450.rs +++ b/tests/ui/traits/const-traits/issue-79450.rs @@ -5,7 +5,7 @@ const trait Tr { fn req(&self); fn prov(&self) { - println!("lul"); //~ ERROR: cannot call non-const function `std::io::_print` in constant functions + println!("lul"); //~ ERROR: cannot call non-const function `_print` in constant functions self.req(); } } diff --git a/tests/ui/traits/const-traits/issue-79450.stderr b/tests/ui/traits/const-traits/issue-79450.stderr index 82d5ea34582f..c10023e9f0ef 100644 --- a/tests/ui/traits/const-traits/issue-79450.stderr +++ b/tests/ui/traits/const-traits/issue-79450.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const function `std::io::_print` in constant functions +error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/issue-79450.rs:8:9 | LL | println!("lul"); @@ -7,6 +7,7 @@ LL | println!("lul"); note: function `_print` is not const --> $SRC_DIR/std/src/io/stdio.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs index de5bedf0ace7..ee4ff02f4c7c 100644 --- a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs +++ b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs @@ -10,8 +10,7 @@ impl Foo for () { } fn main() { - // #150052 deduplicate diagnostics for const trait supertraits - // so we only get one error here (const || { (()).foo() })(); //~^ ERROR: }: [const] Fn()` is not satisfied + //~| ERROR: }: [const] FnMut()` is not satisfied } diff --git a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr index efbedca1c7e7..69d289537da1 100644 --- a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr +++ b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr @@ -1,9 +1,18 @@ -error[E0277]: the trait bound `{closure@$DIR/non-const-op-const-closure-non-const-outer.rs:15:6: 15:14}: [const] Fn()` is not satisfied - --> $DIR/non-const-op-const-closure-non-const-outer.rs:15:5 +error[E0277]: the trait bound `{closure@$DIR/non-const-op-const-closure-non-const-outer.rs:13:6: 13:14}: [const] Fn()` is not satisfied + --> $DIR/non-const-op-const-closure-non-const-outer.rs:13:5 | LL | (const || { (()).foo() })(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error[E0277]: the trait bound `{closure@$DIR/non-const-op-const-closure-non-const-outer.rs:13:6: 13:14}: [const] FnMut()` is not satisfied + --> $DIR/non-const-op-const-closure-non-const-outer.rs:13:5 + | +LL | (const || { (()).foo() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `call` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/partial/attr-gate.rs b/tests/ui/traits/const-traits/partial/attr-gate.rs deleted file mode 100644 index c59a03de2153..000000000000 --- a/tests/ui/traits/const-traits/partial/attr-gate.rs +++ /dev/null @@ -1,7 +0,0 @@ -trait A { - #[rustc_non_const_trait_method] - //~^ ERROR: use of an internal attribute - fn a(); -} - -fn main() {} diff --git a/tests/ui/traits/const-traits/partial/attr-gate.stderr b/tests/ui/traits/const-traits/partial/attr-gate.stderr deleted file mode 100644 index e46e35d036be..000000000000 --- a/tests/ui/traits/const-traits/partial/attr-gate.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: use of an internal attribute - --> $DIR/attr-gate.rs:2:5 - | -LL | #[rustc_non_const_trait_method] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable - = note: the `#[rustc_non_const_trait_method]` attribute is an internal implementation detail that will never be stable - = note: `#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods as non-const to allow large traits an easier transition to const - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/const-traits/partial/no-const-callers.rs b/tests/ui/traits/const-traits/partial/no-const-callers.rs deleted file mode 100644 index 7c198f41ce42..000000000000 --- a/tests/ui/traits/const-traits/partial/no-const-callers.rs +++ /dev/null @@ -1,39 +0,0 @@ -#![feature(const_trait_impl, rustc_attrs)] - -const trait A { - fn a(); - #[rustc_non_const_trait_method] - fn b() { println!("hi"); } -} - -impl const A for () { - fn a() {} -} - -impl const A for u8 { - fn a() {} - fn b() { println!("hello"); } - //~^ ERROR: cannot call non-const function -} - -impl const A for i8 { - fn a() {} - fn b() {} -} - -const fn foo() { - T::a(); - T::b(); - //~^ ERROR: cannot call non-const associated function - <()>::a(); - <()>::b(); - //~^ ERROR: cannot call non-const associated function - u8::a(); - u8::b(); - //~^ ERROR: cannot call non-const associated function - i8::a(); - i8::b(); - //~^ ERROR: cannot call non-const associated function -} - -fn main() {} diff --git a/tests/ui/traits/const-traits/partial/no-const-callers.stderr b/tests/ui/traits/const-traits/partial/no-const-callers.stderr deleted file mode 100644 index bbb4495943ed..000000000000 --- a/tests/ui/traits/const-traits/partial/no-const-callers.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0015]: cannot call non-const function `std::io::_print` in constant functions - --> $DIR/no-const-callers.rs:15:14 - | -LL | fn b() { println!("hello"); } - | ^^^^^^^^^^^^^^^^^ - | -note: function `_print` is not const - --> $SRC_DIR/std/src/io/stdio.rs:LL:COL - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const associated function `::b` in constant functions - --> $DIR/no-const-callers.rs:26:5 - | -LL | T::b(); - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const associated function `<() as A>::b` in constant functions - --> $DIR/no-const-callers.rs:29:5 - | -LL | <()>::b(); - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const associated function `::b` in constant functions - --> $DIR/no-const-callers.rs:32:5 - | -LL | u8::b(); - | ^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const associated function `::b` in constant functions - --> $DIR/no-const-callers.rs:35:5 - | -LL | i8::b(); - | ^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/staged-api.rs b/tests/ui/traits/const-traits/staged-api.rs index cd74bb45f651..6d0a84797ea2 100644 --- a/tests/ui/traits/const-traits/staged-api.rs +++ b/tests/ui/traits/const-traits/staged-api.rs @@ -5,7 +5,7 @@ #![feature(local_feature)] #![feature(const_trait_impl)] #![feature(staged_api)] -#![feature(rustc_attrs)] +#![feature(rustc_allow_const_fn_unstable)] #![stable(feature = "rust1", since = "1.0.0")] //@ aux-build: staged-api.rs diff --git a/tests/ui/traits/cycle-cache-err-60010.stderr b/tests/ui/traits/cycle-cache-err-60010.stderr index 9665d5badf59..4f5e31818321 100644 --- a/tests/ui/traits/cycle-cache-err-60010.stderr +++ b/tests/ui/traits/cycle-cache-err-60010.stderr @@ -6,7 +6,7 @@ LL | _parse: >::Data, | note: required because it appears within the type `PhantomData` --> $SRC_DIR/core/src/marker.rs:LL:COL -note: required because it appears within the type `std::ptr::Unique` +note: required because it appears within the type `Unique` --> $SRC_DIR/core/src/ptr/unique.rs:LL:COL note: required because it appears within the type `Box` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL @@ -45,7 +45,7 @@ LL | type Storage = SalsaStorage; | note: required because it appears within the type `PhantomData` --> $SRC_DIR/core/src/marker.rs:LL:COL -note: required because it appears within the type `std::ptr::Unique` +note: required because it appears within the type `Unique` --> $SRC_DIR/core/src/ptr/unique.rs:LL:COL note: required because it appears within the type `Box` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL diff --git a/tests/ui/traits/deny-builtin-object-impl.current.stderr b/tests/ui/traits/deny-builtin-object-impl.current.stderr index 928d16aa4329..d6f4762d0996 100644 --- a/tests/ui/traits/deny-builtin-object-impl.current.stderr +++ b/tests/ui/traits/deny-builtin-object-impl.current.stderr @@ -4,67 +4,41 @@ error[E0322]: explicit impls for the `NotImplYesObject` trait are not permitted LL | impl NotImplYesObject for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `NotImplYesObject` not allowed -error[E0038]: the trait `YesImplNotObject2` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:23:28 - | -LL | impl YesImplNotObject2 for dyn YesImplNotObject2 {} - | ^^^^^^^^^^^^^^^^^^^^^ `YesImplNotObject2` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:17:1 - | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility -LL | trait YesImplNotObject2 {} - | ----------------- this trait is not dyn compatible... - -error[E0038]: the trait `NotImplNotObject` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:37:36 +error[E0277]: the trait bound `dyn NotImplNotObject: NotImplNotObject` is not satisfied + --> $DIR/deny-builtin-object-impl.rs:37:32 | LL | test_not_impl_not_object::(); - | ^^^^^^^^^^^^^^^^ `NotImplNotObject` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^ the trait `NotImplNotObject` is not implemented for `dyn NotImplNotObject` | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:11:1 +help: this trait has no implementations, consider adding one + --> $DIR/deny-builtin-object-impl.rs:12:1 | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility LL | trait NotImplNotObject {} - | ---------------- this trait is not dyn compatible... + | ^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `test_not_impl_not_object` + --> $DIR/deny-builtin-object-impl.rs:28:32 + | +LL | fn test_not_impl_not_object() {} + | ^^^^^^^^^^^^^^^^ required by this bound in `test_not_impl_not_object` -error[E0038]: the trait `YesImplNotObject` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:40:36 +error[E0277]: the trait bound `dyn YesImplNotObject: YesImplNotObject` is not satisfied + --> $DIR/deny-builtin-object-impl.rs:40:32 | LL | test_yes_impl_not_object::(); - | ^^^^^^^^^^^^^^^^ `YesImplNotObject` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^ the trait `YesImplNotObject` is not implemented for `dyn YesImplNotObject` | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:14:1 +help: this trait has no implementations, consider adding one + --> $DIR/deny-builtin-object-impl.rs:15:1 | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility LL | trait YesImplNotObject {} - | ---------------- this trait is not dyn compatible... - -error[E0038]: the trait `YesImplNotObject2` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:43:37 + | ^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `test_yes_impl_not_object` + --> $DIR/deny-builtin-object-impl.rs:30:32 | -LL | test_yes_impl_not_object2::(); - | ^^^^^^^^^^^^^^^^^ `YesImplNotObject2` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:17:1 - | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility -LL | trait YesImplNotObject2 {} - | ----------------- this trait is not dyn compatible... +LL | fn test_yes_impl_not_object() {} + | ^^^^^^^^^^^^^^^^ required by this bound in `test_yes_impl_not_object` -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0038, E0322. -For more information about an error, try `rustc --explain E0038`. +Some errors have detailed explanations: E0277, E0322. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/deny-builtin-object-impl.next.stderr b/tests/ui/traits/deny-builtin-object-impl.next.stderr index 928d16aa4329..d6f4762d0996 100644 --- a/tests/ui/traits/deny-builtin-object-impl.next.stderr +++ b/tests/ui/traits/deny-builtin-object-impl.next.stderr @@ -4,67 +4,41 @@ error[E0322]: explicit impls for the `NotImplYesObject` trait are not permitted LL | impl NotImplYesObject for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `NotImplYesObject` not allowed -error[E0038]: the trait `YesImplNotObject2` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:23:28 - | -LL | impl YesImplNotObject2 for dyn YesImplNotObject2 {} - | ^^^^^^^^^^^^^^^^^^^^^ `YesImplNotObject2` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:17:1 - | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility -LL | trait YesImplNotObject2 {} - | ----------------- this trait is not dyn compatible... - -error[E0038]: the trait `NotImplNotObject` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:37:36 +error[E0277]: the trait bound `dyn NotImplNotObject: NotImplNotObject` is not satisfied + --> $DIR/deny-builtin-object-impl.rs:37:32 | LL | test_not_impl_not_object::(); - | ^^^^^^^^^^^^^^^^ `NotImplNotObject` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^ the trait `NotImplNotObject` is not implemented for `dyn NotImplNotObject` | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:11:1 +help: this trait has no implementations, consider adding one + --> $DIR/deny-builtin-object-impl.rs:12:1 | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility LL | trait NotImplNotObject {} - | ---------------- this trait is not dyn compatible... + | ^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `test_not_impl_not_object` + --> $DIR/deny-builtin-object-impl.rs:28:32 + | +LL | fn test_not_impl_not_object() {} + | ^^^^^^^^^^^^^^^^ required by this bound in `test_not_impl_not_object` -error[E0038]: the trait `YesImplNotObject` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:40:36 +error[E0277]: the trait bound `dyn YesImplNotObject: YesImplNotObject` is not satisfied + --> $DIR/deny-builtin-object-impl.rs:40:32 | LL | test_yes_impl_not_object::(); - | ^^^^^^^^^^^^^^^^ `YesImplNotObject` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^ the trait `YesImplNotObject` is not implemented for `dyn YesImplNotObject` | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:14:1 +help: this trait has no implementations, consider adding one + --> $DIR/deny-builtin-object-impl.rs:15:1 | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility LL | trait YesImplNotObject {} - | ---------------- this trait is not dyn compatible... - -error[E0038]: the trait `YesImplNotObject2` is not dyn compatible - --> $DIR/deny-builtin-object-impl.rs:43:37 + | ^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `test_yes_impl_not_object` + --> $DIR/deny-builtin-object-impl.rs:30:32 | -LL | test_yes_impl_not_object2::(); - | ^^^^^^^^^^^^^^^^^ `YesImplNotObject2` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/deny-builtin-object-impl.rs:17:1 - | -LL | #[rustc_dyn_incompatible_trait] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it opted out of dyn-compatibility -LL | trait YesImplNotObject2 {} - | ----------------- this trait is not dyn compatible... +LL | fn test_yes_impl_not_object() {} + | ^^^^^^^^^^^^^^^^ required by this bound in `test_yes_impl_not_object` -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0038, E0322. -For more information about an error, try `rustc --explain E0038`. +Some errors have detailed explanations: E0277, E0322. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/deny-builtin-object-impl.rs b/tests/ui/traits/deny-builtin-object-impl.rs index 5924b3fa2857..9d02ab7bd469 100644 --- a/tests/ui/traits/deny-builtin-object-impl.rs +++ b/tests/ui/traits/deny-builtin-object-impl.rs @@ -8,20 +8,20 @@ trait NotImplYesObject {} #[rustc_deny_explicit_impl] -#[rustc_dyn_incompatible_trait] +#[rustc_do_not_implement_via_object] trait NotImplNotObject {} -#[rustc_dyn_incompatible_trait] +#[rustc_do_not_implement_via_object] trait YesImplNotObject {} -#[rustc_dyn_incompatible_trait] +#[rustc_do_not_implement_via_object] trait YesImplNotObject2 {} impl NotImplYesObject for () {} //~^ ERROR explicit impls for the `NotImplYesObject` trait are not permitted +// If there is no automatic impl then we can add a manual impl: impl YesImplNotObject2 for dyn YesImplNotObject2 {} -//~^ ERROR the trait `YesImplNotObject2` is not dyn compatible fn test_not_impl_yes_object() {} @@ -35,11 +35,10 @@ fn main() { test_not_impl_yes_object::(); test_not_impl_not_object::(); - //~^ ERROR the trait `NotImplNotObject` is not dyn compatible + //~^ ERROR the trait bound `dyn NotImplNotObject: NotImplNotObject` is not satisfied test_yes_impl_not_object::(); - //~^ ERROR the trait `YesImplNotObject` is not dyn compatible + //~^ ERROR the trait bound `dyn YesImplNotObject: YesImplNotObject` is not satisfied test_yes_impl_not_object2::(); - //~^ ERROR the trait `YesImplNotObject2` is not dyn compatible } diff --git a/tests/ui/traits/derive-implicit-bound-on-clone.rs b/tests/ui/traits/derive-implicit-bound-on-clone.rs deleted file mode 100644 index a4c9e88ef576..000000000000 --- a/tests/ui/traits/derive-implicit-bound-on-clone.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Issue #146515 -use std::rc::Rc; - -#[derive(Clone)] -struct ContainsRc { //~ HELP `Clone` is not implemented - value: Rc<(T, K)>, -} - -fn clone_me(x: &ContainsRc) -> ContainsRc { - x.clone() //~ ERROR E0308 - //~^ HELP consider manually implementing `Clone` -} - -#[derive(Clone)] -struct ContainsRcSingle { //~ HELP `Clone` is not implemented - value: Rc, -} - -fn clone_me_single(x: &ContainsRcSingle) -> ContainsRcSingle { - x.clone() //~ ERROR E0308 - //~^ HELP consider manually implementing `Clone` -} - -fn main() {} diff --git a/tests/ui/traits/derive-implicit-bound-on-clone.stderr b/tests/ui/traits/derive-implicit-bound-on-clone.stderr deleted file mode 100644 index 2fb039f96528..000000000000 --- a/tests/ui/traits/derive-implicit-bound-on-clone.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/derive-implicit-bound-on-clone.rs:10:5 - | -LL | fn clone_me(x: &ContainsRc) -> ContainsRc { - | ---------------- expected `ContainsRc` because of return type -LL | x.clone() - | ^^^^^^^^^ expected `ContainsRc`, found `&ContainsRc` - | - = note: expected struct `ContainsRc<_, _>` - found reference `&ContainsRc<_, _>` -note: `ContainsRc` does not implement `Clone`, so `&ContainsRc` was cloned instead - --> $DIR/derive-implicit-bound-on-clone.rs:10:5 - | -LL | x.clone() - | ^ -help: `Clone` is not implemented because the some trait bounds could not be satisfied - --> $DIR/derive-implicit-bound-on-clone.rs:5:19 - | -LL | #[derive(Clone)] - | ----- in this derive macro expansion -LL | struct ContainsRc { - | ^ ^ derive introduces an implicit unsatisfied trait bound `K: Clone` - | | - | derive introduces an implicit unsatisfied trait bound `T: Clone` - = help: consider manually implementing `Clone` to avoid the implicit type parameter bounds - -error[E0308]: mismatched types - --> $DIR/derive-implicit-bound-on-clone.rs:20:5 - | -LL | fn clone_me_single(x: &ContainsRcSingle) -> ContainsRcSingle { - | ------------------- expected `ContainsRcSingle` because of return type -LL | x.clone() - | ^^^^^^^^^ expected `ContainsRcSingle`, found `&ContainsRcSingle` - | - = note: expected struct `ContainsRcSingle<_>` - found reference `&ContainsRcSingle<_>` -note: `ContainsRcSingle` does not implement `Clone`, so `&ContainsRcSingle` was cloned instead - --> $DIR/derive-implicit-bound-on-clone.rs:20:5 - | -LL | x.clone() - | ^ -help: `Clone` is not implemented because a trait bound is not satisfied - --> $DIR/derive-implicit-bound-on-clone.rs:15:25 - | -LL | #[derive(Clone)] - | ----- in this derive macro expansion -LL | struct ContainsRcSingle { - | ^ derive introduces an implicit `T: Clone` bound - = help: consider manually implementing `Clone` to avoid the implicit type parameter bounds - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/derive-implicit-bound.rs b/tests/ui/traits/derive-implicit-bound.rs deleted file mode 100644 index 22fb68f37c5c..000000000000 --- a/tests/ui/traits/derive-implicit-bound.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Second case reported in issue #108894. - -use std::marker::PhantomData; - -#[derive(PartialEq, Eq)] -pub struct Id(PhantomData); - -// manual implementation which would break the usage of const patterns -// impl PartialEq for Id { fn eq(&self, _: &Id) -> bool { true } } -// impl Eq for Id {} - -// This derive is undesired but cannot be removed without -// breaking the usages below -// #[derive(PartialEq, Eq)] -struct SomeNode(); - -fn accept_eq(_: &impl PartialEq) { } - -fn main() { - let node = Id::(PhantomData); - - // this will only work if - // - `Partial/Eq` is implemented manually, or - // - `SomeNode` also needlessly(?) implements `Partial/Eq` - accept_eq(&node); //~ ERROR can't compare `SomeNode` with `SomeNode` - - const CONST_ID: Id:: = Id::(PhantomData); - // this will work only when `Partial/Eq` is being derived - // otherwise: error: to use a constant of type `Id` in a pattern, - // `Id` must be annotated with `#[derive(PartialEq, Eq)]` - match node { - CONST_ID => {} - } -} diff --git a/tests/ui/traits/derive-implicit-bound.stderr b/tests/ui/traits/derive-implicit-bound.stderr deleted file mode 100644 index fe2bc77b9529..000000000000 --- a/tests/ui/traits/derive-implicit-bound.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0277]: can't compare `SomeNode` with `SomeNode` - --> $DIR/derive-implicit-bound.rs:25:15 - | -LL | accept_eq(&node); - | --------- ^^^^^ no implementation for `SomeNode == SomeNode` - | | - | required by a bound introduced by this call - | - = help: the trait `PartialEq` is not implemented for `SomeNode` -note: required for `Id` to implement `PartialEq` - --> $DIR/derive-implicit-bound.rs:6:12 - | -LL | #[derive(PartialEq, Eq)] - | --------- in this derive macro expansion -LL | pub struct Id(PhantomData); - | ^^ - type parameter would need to implement `PartialEq` - = help: consider manually implementing `PartialEq` to avoid undesired bounds -note: required by a bound in `accept_eq` - --> $DIR/derive-implicit-bound.rs:17:23 - | -LL | fn accept_eq(_: &impl PartialEq) { } - | ^^^^^^^^^ required by this bound in `accept_eq` -help: consider annotating `SomeNode` with `#[derive(PartialEq)]` - | -LL + #[derive(PartialEq)] -LL | struct SomeNode(); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/explicit-reference-cast.rs b/tests/ui/traits/explicit-reference-cast.rs deleted file mode 100644 index efb4f10bea67..000000000000 --- a/tests/ui/traits/explicit-reference-cast.rs +++ /dev/null @@ -1,50 +0,0 @@ -// compile-fail - -use std::convert::TryFrom; -use std::path::{Path, PathBuf}; - -pub struct ToolA(PathBuf); -//~^ HELP the trait `From<&PathBuf>` is not implemented for `ToolA` - -impl From<&Path> for ToolA { - //~^ HELP the following other types implement trait `From` - fn from(p: &Path) -> ToolA { - ToolA(p.to_path_buf()) - } -} - -// Add a different From impl to ensure we suggest the correct cast -impl From<&str> for ToolA { - fn from(s: &str) -> ToolA { - ToolA(PathBuf::from(s)) - } -} - -pub struct ToolB(PathBuf); -//~^ HELP the trait `From<&PathBuf>` is not implemented for `ToolB` -//~| HELP the trait `From<&PathBuf>` is not implemented for `ToolB` - -impl TryFrom<&Path> for ToolB { - //~^ HELP the trait `TryFrom<&PathBuf>` is not implemented for `ToolB` - //~| HELP the trait `TryFrom<&PathBuf>` is not implemented for `ToolB` - type Error = (); - - fn try_from(p: &Path) -> Result { - Ok(ToolB(p.to_path_buf())) - } -} - -fn main() { - let path = PathBuf::new(); - - let _ = ToolA::from(&path); - //~^ ERROR the trait bound `ToolA: From<&PathBuf>` is not satisfied - //~| HELP consider casting the `&PathBuf` value to `&Path` - let _ = ToolB::try_from(&path); - //~^ ERROR the trait bound `ToolB: TryFrom<&PathBuf>` is not satisfied - //~| ERROR the trait bound `ToolB: From<&PathBuf>` is not satisfied - //~| HELP consider casting the `&PathBuf` value to `&Path` - //~| HELP consider casting the `&PathBuf` value to `&Path` - //~| HELP for that trait implementation, expected `Path`, found `PathBuf` - //~| HELP for that trait implementation, expected `Path`, found `PathBuf` -} diff --git a/tests/ui/traits/explicit-reference-cast.stderr b/tests/ui/traits/explicit-reference-cast.stderr deleted file mode 100644 index 924de3d5bbe3..000000000000 --- a/tests/ui/traits/explicit-reference-cast.stderr +++ /dev/null @@ -1,68 +0,0 @@ -error[E0277]: the trait bound `ToolA: From<&PathBuf>` is not satisfied - --> $DIR/explicit-reference-cast.rs:40:13 - | -LL | let _ = ToolA::from(&path); - | ^^^^^ unsatisfied trait bound - | - = help: consider casting the `&PathBuf` value to `&Path` -help: the trait `From<&PathBuf>` is not implemented for `ToolA` - --> $DIR/explicit-reference-cast.rs:6:1 - | -LL | pub struct ToolA(PathBuf); - | ^^^^^^^^^^^^^^^^ -help: the following other types implement trait `From` - --> $DIR/explicit-reference-cast.rs:9:1 - | -LL | impl From<&Path> for ToolA { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `ToolA` implements `From<&Path>` -... -LL | impl From<&str> for ToolA { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `ToolA` implements `From<&str>` - -error[E0277]: the trait bound `ToolB: TryFrom<&PathBuf>` is not satisfied - --> $DIR/explicit-reference-cast.rs:43:13 - | -LL | let _ = ToolB::try_from(&path); - | ^^^^^ unsatisfied trait bound - | - = help: consider casting the `&PathBuf` value to `&Path` -help: the trait `From<&PathBuf>` is not implemented for `ToolB` - --> $DIR/explicit-reference-cast.rs:23:1 - | -LL | pub struct ToolB(PathBuf); - | ^^^^^^^^^^^^^^^^ -help: the trait `TryFrom<&PathBuf>` is not implemented for `ToolB` - but trait `TryFrom<&Path>` is implemented for it - --> $DIR/explicit-reference-cast.rs:27:1 - | -LL | impl TryFrom<&Path> for ToolB { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: for that trait implementation, expected `Path`, found `PathBuf` - = note: required for `&PathBuf` to implement `Into` - = note: required for `ToolB` to implement `TryFrom<&PathBuf>` - -error[E0277]: the trait bound `ToolB: From<&PathBuf>` is not satisfied - --> $DIR/explicit-reference-cast.rs:43:13 - | -LL | let _ = ToolB::try_from(&path); - | ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: consider casting the `&PathBuf` value to `&Path` -help: the trait `From<&PathBuf>` is not implemented for `ToolB` - --> $DIR/explicit-reference-cast.rs:23:1 - | -LL | pub struct ToolB(PathBuf); - | ^^^^^^^^^^^^^^^^ -help: the trait `TryFrom<&PathBuf>` is not implemented for `ToolB` - but trait `TryFrom<&Path>` is implemented for it - --> $DIR/explicit-reference-cast.rs:27:1 - | -LL | impl TryFrom<&Path> for ToolB { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: for that trait implementation, expected `Path`, found `PathBuf` - = note: required for `&PathBuf` to implement `Into` - = note: required for `ToolB` to implement `TryFrom<&PathBuf>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/final/dyn-compat.rs b/tests/ui/traits/final/dyn-compat.rs deleted file mode 100644 index d600058820c2..000000000000 --- a/tests/ui/traits/final/dyn-compat.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@ run-pass - -#![feature(final_associated_functions)] - -trait FinalNoReceiver { - final fn no_receiver() {} -} - -trait FinalGeneric { - final fn generic(&self, _value: T) {} -} - -trait FinalSelfParam { - final fn self_param(&self, _other: &Self) {} -} - -trait FinalSelfReturn { - final fn self_return(&self) -> &Self { - self - } -} - -struct S; - -impl FinalNoReceiver for S {} -impl FinalGeneric for S {} -impl FinalSelfParam for S {} -impl FinalSelfReturn for S {} - -fn main() { - let s = S; - ::no_receiver(); - let obj_generic: &dyn FinalGeneric = &s; - let obj_param: &dyn FinalSelfParam = &s; - let obj_return: &dyn FinalSelfReturn = &s; - obj_generic.generic(1u8); - obj_param.self_param(obj_param); - let _ = obj_return.self_return(); - let _: &dyn FinalNoReceiver = &s; -} diff --git a/tests/ui/traits/final/final-kw.gated.stderr b/tests/ui/traits/final/final-kw.gated.stderr deleted file mode 100644 index 62a39d7ca202..000000000000 --- a/tests/ui/traits/final/final-kw.gated.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `final` on trait functions is experimental - --> $DIR/final-kw.rs:5:5 - | -LL | final fn foo() {} - | ^^^^^ - | - = note: see issue #131179 for more information - = help: add `#![feature(final_associated_functions)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/final/final-kw.rs b/tests/ui/traits/final/final-kw.rs deleted file mode 100644 index ed675dea6608..000000000000 --- a/tests/ui/traits/final/final-kw.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ revisions: ungated gated - -#[cfg(ungated)] -trait Trait { - final fn foo() {} - //~^ ERROR `final` on trait functions is experimental -} - -fn main() {} diff --git a/tests/ui/traits/final/final-kw.ungated.stderr b/tests/ui/traits/final/final-kw.ungated.stderr deleted file mode 100644 index 62a39d7ca202..000000000000 --- a/tests/ui/traits/final/final-kw.ungated.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `final` on trait functions is experimental - --> $DIR/final-kw.rs:5:5 - | -LL | final fn foo() {} - | ^^^^^ - | - = note: see issue #131179 for more information - = help: add `#![feature(final_associated_functions)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/final/final-must-have-body.rs b/tests/ui/traits/final/final-must-have-body.rs deleted file mode 100644 index 57ed26c3e78d..000000000000 --- a/tests/ui/traits/final/final-must-have-body.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(final_associated_functions)] - -trait Foo { - final fn method(); - //~^ ERROR `final` is only allowed on associated functions if they have a body -} - -fn main() {} diff --git a/tests/ui/traits/final/final-must-have-body.stderr b/tests/ui/traits/final/final-must-have-body.stderr deleted file mode 100644 index e4f1ffb701e8..000000000000 --- a/tests/ui/traits/final/final-must-have-body.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `final` is only allowed on associated functions if they have a body - --> $DIR/final-must-have-body.rs:4:5 - | -LL | final fn method(); - | -----^^^^^^^^^^^^^ - | | - | `final` because of this - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/final/overriding.rs b/tests/ui/traits/final/overriding.rs deleted file mode 100644 index f91451852ff0..000000000000 --- a/tests/ui/traits/final/overriding.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(final_associated_functions)] - -trait Foo { - final fn method() {} -} - -impl Foo for () { - fn method() {} - //~^ ERROR cannot override `method` because it already has a `final` definition in the trait -} - -fn main() {} diff --git a/tests/ui/traits/final/overriding.stderr b/tests/ui/traits/final/overriding.stderr deleted file mode 100644 index b5598565072f..000000000000 --- a/tests/ui/traits/final/overriding.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: cannot override `method` because it already has a `final` definition in the trait - --> $DIR/overriding.rs:8:5 - | -LL | fn method() {} - | ^^^^^^^^^^^ - | -note: `method` is marked final here - --> $DIR/overriding.rs:4:5 - | -LL | final fn method() {} - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/final/positions.rs b/tests/ui/traits/final/positions.rs deleted file mode 100644 index 9bf659e12431..000000000000 --- a/tests/ui/traits/final/positions.rs +++ /dev/null @@ -1,72 +0,0 @@ -#![feature(final_associated_functions)] - -// Just for exercising the syntax positions -#![feature(associated_type_defaults, extern_types, inherent_associated_types)] -#![allow(incomplete_features)] - -final struct Foo {} -//~^ ERROR a struct cannot be `final` - -final trait Trait { -//~^ ERROR a trait cannot be `final` - - final fn method() {} - // OK! - - final type Foo = (); - //~^ ERROR `final` is only allowed on associated functions in traits - - final const FOO: usize = 1; - //~^ ERROR `final` is only allowed on associated functions in traits -} - -final impl Foo { - final fn method() {} - //~^ ERROR `final` is only allowed on associated functions in traits - - final type Foo = (); - //~^ ERROR `final` is only allowed on associated functions in traits - - final const FOO: usize = 1; - //~^ ERROR `final` is only allowed on associated functions in traits -} - -final impl Trait for Foo { - final fn method() {} - //~^ ERROR `final` is only allowed on associated functions in traits - //~^^ ERROR cannot override `method` because it already has a `final` definition in the trait - - final type Foo = (); - //~^ ERROR `final` is only allowed on associated functions in traits - //~^^ ERROR cannot override `Foo` because it already has a `final` definition in the trait - - final const FOO: usize = 1; - //~^ ERROR `final` is only allowed on associated functions in traits - //~^^ ERROR cannot override `FOO` because it already has a `final` definition in the trait -} - - -final fn foo() {} -//~^ ERROR `final` is only allowed on associated functions in traits - -final type FooTy = (); -//~^ ERROR `final` is only allowed on associated functions in traits - -final const FOO: usize = 0; -//~^ ERROR `final` is only allowed on associated functions in traits - -final unsafe extern "C" { -//~^ ERROR an extern block cannot be `final` - - final fn foo_extern(); - //~^ ERROR `final` is only allowed on associated functions in traits - - final type FooExtern; - //~^ ERROR `final` is only allowed on associated functions in traits - - final static FOO_EXTERN: usize = 0; - //~^ ERROR a static item cannot be `final` - //~| ERROR incorrect `static` inside `extern` block -} - -fn main() {} diff --git a/tests/ui/traits/final/positions.stderr b/tests/ui/traits/final/positions.stderr deleted file mode 100644 index bcb300e49d1a..000000000000 --- a/tests/ui/traits/final/positions.stderr +++ /dev/null @@ -1,187 +0,0 @@ -error: a struct cannot be `final` - --> $DIR/positions.rs:7:1 - | -LL | final struct Foo {} - | ^^^^^ `final` because of this - | - = note: only associated functions in traits can be `final` - -error: a trait cannot be `final` - --> $DIR/positions.rs:10:1 - | -LL | final trait Trait { - | ^^^^^ `final` because of this - | - = note: only associated functions in traits can be `final` - -error: a static item cannot be `final` - --> $DIR/positions.rs:67:5 - | -LL | final static FOO_EXTERN: usize = 0; - | ^^^^^ `final` because of this - | - = note: only associated functions in traits can be `final` - -error: an extern block cannot be `final` - --> $DIR/positions.rs:58:1 - | -LL | final unsafe extern "C" { - | ^^^^^ `final` because of this - | - = note: only associated functions in traits can be `final` - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:16:5 - | -LL | final type Foo = (); - | -----^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:19:5 - | -LL | final const FOO: usize = 1; - | -----^^^^^^^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:24:5 - | -LL | final fn method() {} - | -----^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:27:5 - | -LL | final type Foo = (); - | -----^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:30:5 - | -LL | final const FOO: usize = 1; - | -----^^^^^^^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:35:5 - | -LL | final fn method() {} - | -----^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:39:5 - | -LL | final type Foo = (); - | -----^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:43:5 - | -LL | final const FOO: usize = 1; - | -----^^^^^^^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:49:1 - | -LL | final fn foo() {} - | -----^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:52:1 - | -LL | final type FooTy = (); - | -----^^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:55:1 - | -LL | final const FOO: usize = 0; - | -----^^^^^^^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:61:5 - | -LL | final fn foo_extern(); - | -----^^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: `final` is only allowed on associated functions in traits - --> $DIR/positions.rs:64:5 - | -LL | final type FooExtern; - | -----^^^^^^^^^^^^^^^^ - | | - | `final` because of this - -error: incorrect `static` inside `extern` block - --> $DIR/positions.rs:67:18 - | -LL | final unsafe extern "C" { - | ----------------------- `extern` blocks define existing foreign statics and statics inside of them cannot have a body -... -LL | final static FOO_EXTERN: usize = 0; - | ^^^^^^^^^^ - the invalid body - | | - | cannot have a body - | - = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html - -error: cannot override `method` because it already has a `final` definition in the trait - --> $DIR/positions.rs:35:5 - | -LL | final fn method() {} - | ^^^^^^^^^^^^^^^^^ - | -note: `method` is marked final here - --> $DIR/positions.rs:13:5 - | -LL | final fn method() {} - | ^^^^^^^^^^^^^^^^^ - -error: cannot override `Foo` because it already has a `final` definition in the trait - --> $DIR/positions.rs:39:5 - | -LL | final type Foo = (); - | ^^^^^^^^^^^^^^ - | -note: `Foo` is marked final here - --> $DIR/positions.rs:16:5 - | -LL | final type Foo = (); - | ^^^^^^^^^^^^^^ - -error: cannot override `FOO` because it already has a `final` definition in the trait - --> $DIR/positions.rs:43:5 - | -LL | final const FOO: usize = 1; - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: `FOO` is marked final here - --> $DIR/positions.rs:19:5 - | -LL | final const FOO: usize = 1; - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 21 previous errors - diff --git a/tests/ui/traits/final/works.rs b/tests/ui/traits/final/works.rs deleted file mode 100644 index e756521701a4..000000000000 --- a/tests/ui/traits/final/works.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ check-pass - -#![feature(final_associated_functions)] - -trait Foo { - final fn bar(&self) {} -} - -impl Foo for () {} - -fn main() { - ().bar(); -} diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.rs b/tests/ui/traits/ice-with-dyn-pointee-errors.rs index bb89f103e3f9..46cef2c8bc09 100644 --- a/tests/ui/traits/ice-with-dyn-pointee-errors.rs +++ b/tests/ui/traits/ice-with-dyn-pointee-errors.rs @@ -6,12 +6,10 @@ use core::ptr::Pointee; fn unknown_sized_object_ptr_in(_: &(impl Pointee + ?Sized)) {} fn raw_pointer_in(x: &dyn Pointee) { - //~^ ERROR the trait `Pointee` is not dyn compatible unknown_sized_object_ptr_in(x) - //~^ ERROR the trait `Pointee` is not dyn compatible + //~^ ERROR type mismatch resolving ` as Pointee>::Metadata == ()` } fn main() { raw_pointer_in(&42) - //~^ ERROR the trait `Pointee` is not dyn compatible } diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.stderr b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr index 9ff0445cda09..5299236026d7 100644 --- a/tests/ui/traits/ice-with-dyn-pointee-errors.stderr +++ b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr @@ -1,39 +1,19 @@ -error[E0038]: the trait `Pointee` is not dyn compatible - --> $DIR/ice-with-dyn-pointee-errors.rs:8:23 - | -LL | fn raw_pointer_in(x: &dyn Pointee) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `Pointee` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - | - = note: the trait is not dyn compatible because it opted out of dyn-compatibility - -error[E0038]: the trait `Pointee` is not dyn compatible - --> $DIR/ice-with-dyn-pointee-errors.rs:10:5 +error[E0271]: type mismatch resolving ` as Pointee>::Metadata == ()` + --> $DIR/ice-with-dyn-pointee-errors.rs:9:33 | LL | unknown_sized_object_ptr_in(x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Pointee` is not dyn compatible + | --------------------------- ^ expected `()`, found `DynMetadata>` + | | + | required by a bound introduced by this call | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + = note: expected unit type `()` + found struct `DynMetadata>` +note: required by a bound in `unknown_sized_object_ptr_in` + --> $DIR/ice-with-dyn-pointee-errors.rs:6:50 | - = note: the trait is not dyn compatible because it opted out of dyn-compatibility +LL | fn unknown_sized_object_ptr_in(_: &(impl Pointee + ?Sized)) {} + | ^^^^^^^^^^^^^ required by this bound in `unknown_sized_object_ptr_in` -error[E0038]: the trait `Pointee` is not dyn compatible - --> $DIR/ice-with-dyn-pointee-errors.rs:15:20 - | -LL | raw_pointer_in(&42) - | ^^^ `Pointee` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - | - = note: the trait is not dyn compatible because it opted out of dyn-compatibility +error: aborting due to 1 previous error -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/ice-with-dyn-pointee.rs b/tests/ui/traits/ice-with-dyn-pointee.rs new file mode 100644 index 000000000000..45361cc44600 --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee.rs @@ -0,0 +1,11 @@ +//@ run-pass +#![feature(ptr_metadata)] +// Address issue #112737 -- ICE with dyn Pointee +extern crate core; +use core::ptr::Pointee; + +fn raw_pointer_in(_: &dyn Pointee) {} + +fn main() { + raw_pointer_in(&42) +} diff --git a/tests/ui/traits/issue-106072.rs b/tests/ui/traits/issue-106072.rs index 6b04004621d8..d45668312218 100644 --- a/tests/ui/traits/issue-106072.rs +++ b/tests/ui/traits/issue-106072.rs @@ -1,4 +1,6 @@ -#[derive(Clone)] //~ ERROR: expected a type, found a trait -struct Foo; //~ ERROR: expected a type, found a trait -trait Foo {} //~ ERROR: the name `Foo` is defined multiple times +#[derive(Clone)] +//~^ ERROR expected a type, found a trait +//~| ERROR expected a type, found a trait +struct Foo; +trait Foo {} //~ ERROR the name `Foo` is defined multiple times fn main() {} diff --git a/tests/ui/traits/issue-106072.stderr b/tests/ui/traits/issue-106072.stderr index 57661fda7307..815787c3bfec 100644 --- a/tests/ui/traits/issue-106072.stderr +++ b/tests/ui/traits/issue-106072.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-106072.rs:3:1 + --> $DIR/issue-106072.rs:5:1 | LL | struct Foo; | ----------- previous definition of the type `Foo` here @@ -9,18 +9,18 @@ LL | trait Foo {} = note: `Foo` must be defined only once in the type namespace of this module error[E0782]: expected a type, found a trait - --> $DIR/issue-106072.rs:2:8 + --> $DIR/issue-106072.rs:1:10 | LL | #[derive(Clone)] - | ----- in this derive macro expansion -LL | struct Foo; - | ^^^ + | ^^^^^ error[E0782]: expected a type, found a trait --> $DIR/issue-106072.rs:1:10 | LL | #[derive(Clone)] | ^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 3 previous errors diff --git a/tests/ui/traits/issue-50480.rs b/tests/ui/traits/issue-50480.rs index 2f62906e9df3..ccd35a850f2d 100644 --- a/tests/ui/traits/issue-50480.rs +++ b/tests/ui/traits/issue-50480.rs @@ -1,17 +1,18 @@ #[derive(Clone, Copy)] -struct Foo(N, NotDefined, ::Item, Vec, String); //~^ ERROR the trait `Copy` cannot be implemented for this type -//~| ERROR cannot find type `NotDefined` in this scope +struct Foo(N, NotDefined, ::Item, Vec, String); +//~^ ERROR cannot find type `NotDefined` in this scope //~| ERROR cannot find type `NotDefined` in this scope //~| ERROR cannot find type `N` in this scope //~| ERROR cannot find type `N` in this scope //~| ERROR `i32` is not an iterator //~| ERROR `i32` is not an iterator -#[derive(Clone, Copy)] //~ ERROR `i32` is not an iterator -struct Bar(T, N, NotDefined, ::Item, Vec, String); +#[derive(Clone, Copy)] //~^ ERROR the trait `Copy` cannot be implemented for this type -//~| ERROR cannot find type `NotDefined` in this scope +//~| ERROR `i32` is not an iterator +struct Bar(T, N, NotDefined, ::Item, Vec, String); +//~^ ERROR cannot find type `NotDefined` in this scope //~| ERROR cannot find type `N` in this scope //~| ERROR `i32` is not an iterator //~| ERROR `i32` is not an iterator diff --git a/tests/ui/traits/issue-50480.stderr b/tests/ui/traits/issue-50480.stderr index 1fb5e8b00783..32c8b2cf3ac1 100644 --- a/tests/ui/traits/issue-50480.stderr +++ b/tests/ui/traits/issue-50480.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find type `N` in this scope - --> $DIR/issue-50480.rs:2:12 + --> $DIR/issue-50480.rs:3:12 | LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^ not found in this scope @@ -10,13 +10,13 @@ LL | struct Foo(N, NotDefined, ::Item, Vec, String); | +++ error[E0425]: cannot find type `NotDefined` in this scope - --> $DIR/issue-50480.rs:2:15 + --> $DIR/issue-50480.rs:3:15 | LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^ not found in this scope error[E0425]: cannot find type `N` in this scope - --> $DIR/issue-50480.rs:2:12 + --> $DIR/issue-50480.rs:3:12 | LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^ not found in this scope @@ -27,7 +27,7 @@ LL | struct Foo(N, NotDefined, ::Item, Vec, String); | +++ error[E0425]: cannot find type `NotDefined` in this scope - --> $DIR/issue-50480.rs:2:15 + --> $DIR/issue-50480.rs:3:15 | LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^ not found in this scope @@ -38,7 +38,7 @@ LL | struct Foo(N, NotDefined, ::Item, Vec, St | ++++++++++++ error[E0425]: cannot find type `N` in this scope - --> $DIR/issue-50480.rs:12:18 + --> $DIR/issue-50480.rs:14:18 | LL | struct Bar(T, N, NotDefined, ::Item, Vec, String); | - ^ @@ -56,13 +56,13 @@ LL | struct Bar(T, N, NotDefined, ::Item, Vec, Strin | +++ error[E0425]: cannot find type `NotDefined` in this scope - --> $DIR/issue-50480.rs:12:21 + --> $DIR/issue-50480.rs:14:21 | LL | struct Bar(T, N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^ not found in this scope error[E0277]: `i32` is not an iterator - --> $DIR/issue-50480.rs:2:27 + --> $DIR/issue-50480.rs:3:27 | LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator @@ -70,27 +70,29 @@ LL | struct Foo(N, NotDefined, ::Item, Vec, String); = help: the trait `Iterator` is not implemented for `i32` error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/issue-50480.rs:2:8 + --> $DIR/issue-50480.rs:1:17 | LL | #[derive(Clone, Copy)] - | ---- in this derive macro expansion + | ^^^^ +LL | LL | struct Foo(N, NotDefined, ::Item, Vec, String); - | ^^^ -------- ------ this field does not implement `Copy` + | -------- ------ this field does not implement `Copy` | | | this field does not implement `Copy` error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/issue-50480.rs:12:8 + --> $DIR/issue-50480.rs:11:17 | LL | #[derive(Clone, Copy)] - | ---- in this derive macro expansion + | ^^^^ +... LL | struct Bar(T, N, NotDefined, ::Item, Vec, String); - | ^^^ -------- ------ this field does not implement `Copy` + | -------- ------ this field does not implement `Copy` | | | this field does not implement `Copy` error[E0277]: `i32` is not an iterator - --> $DIR/issue-50480.rs:12:33 + --> $DIR/issue-50480.rs:14:33 | LL | struct Bar(T, N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator @@ -98,7 +100,7 @@ LL | struct Bar(T, N, NotDefined, ::Item, Vec, String); = help: the trait `Iterator` is not implemented for `i32` error[E0277]: `i32` is not an iterator - --> $DIR/issue-50480.rs:2:28 + --> $DIR/issue-50480.rs:3:28 | LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^^^ `i32` is not an iterator @@ -114,10 +116,11 @@ LL | #[derive(Clone, Copy)] = help: the trait `Iterator` is not implemented for `i32` error[E0277]: `i32` is not an iterator - --> $DIR/issue-50480.rs:12:33 + --> $DIR/issue-50480.rs:14:33 | LL | #[derive(Clone, Copy)] | ----- in this derive macro expansion +... LL | struct Bar(T, N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator | diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index acb67af53f18..eb72b307ed0f 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -141,15 +141,15 @@ note: for a trait to be dyn compatible it needs to allow building a vtable --> $DIR/item-privacy.rs:26:15 | LL | const A: u8 = 0; - | ^ ...because it contains associated const `A` + | ^ ...because it contains this associated `const` ... LL | const B: u8 = 0; - | ^ ...because it contains associated const `B` + | ^ ...because it contains this associated `const` ... LL | pub trait C: A + B { | - this trait is not dyn compatible... LL | const C: u8 = 0; - | ^ ...because it contains associated const `C` + | ^ ...because it contains this associated `const` = help: consider moving `C` to another trait = help: consider moving `A` to another trait = help: consider moving `B` to another trait @@ -166,15 +166,15 @@ note: for a trait to be dyn compatible it needs to allow building a vtable --> $DIR/item-privacy.rs:26:15 | LL | const A: u8 = 0; - | ^ ...because it contains associated const `A` + | ^ ...because it contains this associated `const` ... LL | const B: u8 = 0; - | ^ ...because it contains associated const `B` + | ^ ...because it contains this associated `const` ... LL | pub trait C: A + B { | - this trait is not dyn compatible... LL | const C: u8 = 0; - | ^ ...because it contains associated const `C` + | ^ ...because it contains this associated `const` = help: consider moving `C` to another trait = help: consider moving `A` to another trait = help: consider moving `B` to another trait diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index b7d8484e1041..f450f786f608 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -77,12 +77,12 @@ error[E0277]: `dummy2::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:48:13 | LL | is_send(Box::new(TestType)); - | ------- ^^^^^^^^^^^^^^^^^^ the trait `Send` is not implemented for `std::ptr::Unique` + | ------- ^^^^^^^^^^^^^^^^^^ the trait `Send` is not implemented for `Unique` | | | required by a bound introduced by this call | - = note: the trait bound `std::ptr::Unique: Send` is not satisfied - = note: required for `std::ptr::Unique` to implement `Send` + = note: the trait bound `Unique: Send` is not satisfied + = note: required for `Unique` to implement `Send` note: required because it appears within the type `Box` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `is_send` @@ -113,7 +113,7 @@ note: required because it appears within the type `Outer2` | LL | struct Outer2(T); | ^^^^^^ - = note: required for `std::ptr::Unique>` to implement `Send` + = note: required for `Unique>` to implement `Send` note: required because it appears within the type `Box>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `is_send` diff --git a/tests/ui/traits/next-solver-ice.rs b/tests/ui/traits/next-solver-ice.rs deleted file mode 100644 index 889d1094a103..000000000000 --- a/tests/ui/traits/next-solver-ice.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@compile-flags: -Znext-solver=globally -//@check-fail - -fn check() { - ::Item>>::from; - //~^ ERROR the trait bound `f32: From<::Item>` is not satisfied -} - -fn main() {} diff --git a/tests/ui/traits/next-solver-ice.stderr b/tests/ui/traits/next-solver-ice.stderr deleted file mode 100644 index d6b022d70175..000000000000 --- a/tests/ui/traits/next-solver-ice.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `f32: From<::Item>` is not satisfied - --> $DIR/next-solver-ice.rs:5:6 - | -LL | ::Item>>::from; - | ^^^ the nightly-only, unstable trait `ZeroablePrimitive` is not implemented for `f32` - | - = help: the following other types implement trait `ZeroablePrimitive`: - i128 - i16 - i32 - i64 - i8 - isize - u128 - u16 - and 4 others - = note: required for `f32` to implement `From<::Item>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/coercion/unfulfilled-unsize-coercion-recursion-limit.rs b/tests/ui/traits/next-solver/coercion/unfulfilled-unsize-coercion-recursion-limit.rs deleted file mode 100644 index 24b32db3060d..000000000000 --- a/tests/ui/traits/next-solver/coercion/unfulfilled-unsize-coercion-recursion-limit.rs +++ /dev/null @@ -1,35 +0,0 @@ -//@ check-pass -//@ compile-flags: -Znext-solver - -// A regression test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/266. -// Ensure that we do not accidentaly trying unfulfilled unsized coercions due to hitting recursion -// limits while trying to find the right fulfillment error source. - -fn argument_coercion(_: &U) {} - -pub fn test() { - argument_coercion(&{ - Nested(0.0, 0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - .add(0.0) - }); -} - -struct Nested(T, R); - -impl Nested { - fn add(self, value: U) -> Nested> { - Nested(value, self) - } -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/coercion/unsize-coercion-recursion-limit.rs b/tests/ui/traits/next-solver/coercion/unsize-coercion-recursion-limit.rs deleted file mode 100644 index 42802e85cda1..000000000000 --- a/tests/ui/traits/next-solver/coercion/unsize-coercion-recursion-limit.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ check-pass -//@ compile-flags: -Znext-solver - -// A test to ensure that unsized coercion is not aborted when visiting a nested goal that -// exceeds the recursion limit and evaluates to `Certainty::Maybe`. -// See https://github.com/rust-lang/rust/pull/152444. - -#![allow(warnings)] - -struct W(T); -type Four = W>>>; -type Sixteen = Four>>>; - -fn ret(x: T) -> Sixteen { - todo!(); -} - -fn please_coerce() { - let mut y = Default::default(); - let x = ret(y); - let _: &Sixteen = &x; - y = 1u32; -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/generalize/relate-alias-in-lub.rs b/tests/ui/traits/next-solver/generalize/relate-alias-in-lub.rs deleted file mode 100644 index a81e18559a39..000000000000 --- a/tests/ui/traits/next-solver/generalize/relate-alias-in-lub.rs +++ /dev/null @@ -1,30 +0,0 @@ -//@ revisions: old next -//@[next] compile-flags: -Znext-solver -//@ ignore-compare-mode-next-solver (explicit revisions) -//@ check-pass -// Reproduces https://github.com/rust-lang/rust/pull/151746#issuecomment-3822930803. -// -// The change we tried to make there caused relating a type variable with an alias inside lub, -// In 5bd20bbd0ba6c0285664e55a1ffc677d7487c98b, we moved around code -// that adds an alias-relate predicate to be earlier, from one shared codepath into several -// distinct code paths. However, we forgot the codepath in `LatticeOp`, causing an ICE in serde. -// In the end we dropped said commit, but the reproducer is still a useful as test. - -use std::marker::PhantomData; - -pub trait Trait { - type Error; -} - -pub struct Struct(PhantomData); - -impl Trait for () { - type Error = (); -} - -fn main() { - let _: Struct<<() as Trait>::Error> = match loop {} { - b => loop {}, - a => Struct(PhantomData), - }; -} diff --git a/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.rs b/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.rs index ceef87d76abb..2b4f7ba9fa29 100644 --- a/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.rs +++ b/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.rs @@ -12,8 +12,8 @@ // we already face this difficulty, probably. If we need to fix this by reducing the error margin, // we should improve compiletest. -#[derive(Clone, Eq)] -pub struct Struct(T); //~ ERROR [E0277] +#[derive(Clone, Eq)] //~ ERROR [E0277] +pub struct Struct(T); impl PartialEq for Struct where diff --git a/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.stderr b/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.stderr index 912286a48faf..290b1df1665d 100644 --- a/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.stderr +++ b/tests/ui/traits/next-solver/global-cache-and-parallel-frontend.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/global-cache-and-parallel-frontend.rs:16:12 + --> $DIR/global-cache-and-parallel-frontend.rs:15:17 | LL | #[derive(Clone, Eq)] - | -- in this derive macro expansion -LL | pub struct Struct(T); - | ^^^^^^ the trait `Clone` is not implemented for `T` + | ^^ the trait `Clone` is not implemented for `T` | note: required for `Struct` to implement `PartialEq` --> $DIR/global-cache-and-parallel-frontend.rs:18:19 diff --git a/tests/ui/traits/next-solver/global-where-bound-normalization.rs b/tests/ui/traits/next-solver/global-where-bound-normalization.rs deleted file mode 100644 index e57fbf378a0d..000000000000 --- a/tests/ui/traits/next-solver/global-where-bound-normalization.rs +++ /dev/null @@ -1,45 +0,0 @@ -//@ check-pass -//@ compile-flags: -Znext-solver - -// Regression test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/257. - -#![feature(rustc_attrs)] -#![expect(internal_features)] -#![rustc_no_implicit_bounds] - -pub trait Bound {} -impl Bound for u8 {} - -pub trait Proj { - type Assoc; -} -impl Proj for U { - type Assoc = U; -} -impl Proj for MyField { - type Assoc = u8; -} - -// While wf-checking the global bounds of `fn foo`, elaborating this outlives predicate triggered a -// cycle in the search graph along a particular probe path, which was not an actual solution. -// That cycle then resulted in a forced false-positive ambiguity due to a performance hack in the -// search graph and then ended up floundering the root goal evaluation. -pub trait Field: Proj {} - -struct MyField; -impl Field for MyField {} - -trait IdReqField { - type This; -} -impl IdReqField for F { - type This = F; -} - -fn foo() -where - ::This: Field, -{ -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/eventually-constrained-region.rs b/tests/ui/traits/next-solver/opaques/eventually-constrained-region.rs deleted file mode 100644 index 997bcd6ed9b4..000000000000 --- a/tests/ui/traits/next-solver/opaques/eventually-constrained-region.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ check-pass -//@ compile-flags: -Znext-solver - -// Regression test for trait-system-refactor-initiative#264. -// -// Some defining uses of opaque types can't constrain captured regions to universals. -// Previouly, we eagerly report error in this case. -// Now we report error only if there's no fully defining use from all bodies of the typeck root. - -struct Inv<'a>(*mut &'a ()); - -fn mk_static() -> Inv<'static> { todo!() } - -fn guide_closure_sig<'a>(f: impl FnOnce() -> Inv<'a>) {} - -fn unconstrained_in_closure() -> impl Sized { - guide_closure_sig(|| unconstrained_in_closure()); - mk_static() -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs b/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs deleted file mode 100644 index d8375a62bb37..000000000000 --- a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ compile-flags: -Znext-solver - -// Regression test for trait-system-refactor-initiative/issues/263 -// Previously `method_auto_deref_steps` would also return opaque -// types which have already been defined in the parent context. -// -// We then handled these opaque types by emitting `AliasRelate` goals -// when instantiating its result, assuming that operation to be infallible. -// By returning opaque type constraints from the parent context and -// constraining the hidden type without reproving the item bounds of -// the opaque, this ended up causing ICE. - -use std::ops::Deref; -trait Trait {} -struct Inv(*mut T); -impl Trait for i32 {} -impl Deref for Inv { - type Target = u32; - fn deref(&self) -> &Self::Target { - todo!() - } -} - -fn mk() -> T { todo!() } -fn foo() -> Inv { - //~^ ERROR: the trait bound `u32: Trait` is not satisfied [E0277] - let mut x: Inv<_> = mk(); - if false { - return x; - //~^ ERROR: the trait bound `u32: Trait` is not satisfied [E0277] - } - - x.count_ones(); - x - //~^ ERROR: mismatched types [E0308] -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr b/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr deleted file mode 100644 index c421222309a0..000000000000 --- a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0277]: the trait bound `u32: Trait` is not satisfied - --> $DIR/method_autoderef_constraints.rs:29:16 - | -LL | return x; - | ^ the trait `Trait` is not implemented for `u32` - | -help: the trait `Trait` is implemented for `i32` - --> $DIR/method_autoderef_constraints.rs:16:1 - | -LL | impl Trait for i32 {} - | ^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/method_autoderef_constraints.rs:34:5 - | -LL | fn foo() -> Inv { - | --------------- - | | | - | | the expected opaque type - | expected `Inv` because of return type -... -LL | x - | ^ types differ - | - = note: expected struct `Inv` - found struct `Inv` - -error[E0277]: the trait bound `u32: Trait` is not satisfied - --> $DIR/method_autoderef_constraints.rs:25:1 - | -LL | fn foo() -> Inv { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u32` - | -help: the trait `Trait` is implemented for `i32` - --> $DIR/method_autoderef_constraints.rs:16:1 - | -LL | impl Trait for i32 {} - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/opaques/report-all-unexpected-hidden-errors.rs b/tests/ui/traits/next-solver/opaques/report-all-unexpected-hidden-errors.rs deleted file mode 100644 index 61823c1e300d..000000000000 --- a/tests/ui/traits/next-solver/opaques/report-all-unexpected-hidden-errors.rs +++ /dev/null @@ -1,34 +0,0 @@ -//@ compile-flags: -Znext-solver - -// Just for diagnostics completeness. -// This is probably unimportant as we only report one error for such case in HIR typeck. - -#![feature(type_alias_impl_trait)] - -struct Invar<'a>(*mut &'a ()); - -fn mk_invar<'a>(a: &'a i32) -> Invar<'a> { - todo!() -} - -type MultiUse = impl Sized; - -#[define_opaque(MultiUse)] -fn capture_different_universals_not_on_bounds<'a, 'b, 'c>(a: &'a i32, b: &'b i32, c: &'c i32) { - let _ = || -> MultiUse { - //~^ ERROR: hidden type for `MultiUse` captures lifetime that does not appear in bounds [E0700] - mk_invar(a) - }; - let _ = || -> MultiUse { - //~^ ERROR: hidden type for `MultiUse` captures lifetime that does not appear in bounds [E0700] - mk_invar(b) - }; - let _ = || { - let _ = || -> MultiUse { - //~^ ERROR: hidden type for `MultiUse` captures lifetime that does not appear in bounds [E0700] - mk_invar(c) - }; - }; -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/report-all-unexpected-hidden-errors.stderr b/tests/ui/traits/next-solver/opaques/report-all-unexpected-hidden-errors.stderr deleted file mode 100644 index 28d9da3d4666..000000000000 --- a/tests/ui/traits/next-solver/opaques/report-all-unexpected-hidden-errors.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0700]: hidden type for `MultiUse` captures lifetime that does not appear in bounds - --> $DIR/report-all-unexpected-hidden-errors.rs:18:19 - | -LL | type MultiUse = impl Sized; - | ---------- opaque type defined here -... -LL | let _ = || -> MultiUse { - | ^^^^^^^^ - | - = note: hidden type `Invar<'_>` captures lifetime `'_` - -error[E0700]: hidden type for `MultiUse` captures lifetime that does not appear in bounds - --> $DIR/report-all-unexpected-hidden-errors.rs:22:19 - | -LL | type MultiUse = impl Sized; - | ---------- opaque type defined here -... -LL | let _ = || -> MultiUse { - | ^^^^^^^^ - | - = note: hidden type `Invar<'_>` captures lifetime `'_` - -error[E0700]: hidden type for `MultiUse` captures lifetime that does not appear in bounds - --> $DIR/report-all-unexpected-hidden-errors.rs:27:23 - | -LL | type MultiUse = impl Sized; - | ---------- opaque type defined here -... -LL | let _ = || -> MultiUse { - | ^^^^^^^^ - | - = note: hidden type `Invar<'_>` captures lifetime `'_` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs b/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs deleted file mode 100644 index 7c789af9e4cc..000000000000 --- a/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs +++ /dev/null @@ -1,50 +0,0 @@ -//@ edition: 2024 -//@ compile-flags: -Znext-solver --diagnostic-width=300 - -// Previously we check stalled coroutine obligations after borrowck pass. -// And we wrongly assume that these obligations hold in borrowck which leads to -// silent normalization failures. -// In the next solver, we register opaques types via `NormalizesTo` goals. -// So these failures also cause those opaques types not registered in storage. -// -// Regression test for #151322 and #151323. - -#![feature(type_alias_impl_trait)] -#![feature(negative_impls)] -#![feature(auto_traits)] - -fn stalled_copy_clone() { - type T = impl Copy; - let foo: T = async {}; - //~^ ERROR: the trait bound - - type U = impl Clone; - let bar: U = async {}; - //~^ ERROR: the trait bound -} - -auto trait Valid {} -struct False; -impl !Valid for False {} - -fn stalled_auto_traits() { - type T = impl Valid; - let a = False; - let foo: T = async { a }; - //~^ ERROR: the trait bound `False: Valid` is not satisfied -} - - -trait Trait { - fn stalled_send(&self, b: *mut ()) -> impl Future + Send { - //~^ ERROR: type mismatch resolving - //~| ERROR: type mismatch resolving - async move { - //~^ ERROR: type mismatch resolving - b - } - } -} - - -fn main() {} diff --git a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr deleted file mode 100644 index 6afa406bf367..000000000000 --- a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error[E0277]: the trait bound `{async block@$DIR/stalled-coroutine-obligations.rs:18:18: 18:23}: Copy` is not satisfied - --> $DIR/stalled-coroutine-obligations.rs:18:14 - | -LL | let foo: T = async {}; - | ^ the trait `Copy` is not implemented for `{async block@$DIR/stalled-coroutine-obligations.rs:18:18: 18:23}` - -error[E0277]: the trait bound `{async block@$DIR/stalled-coroutine-obligations.rs:22:18: 22:23}: Clone` is not satisfied - --> $DIR/stalled-coroutine-obligations.rs:22:14 - | -LL | let bar: U = async {}; - | ^ the trait `Clone` is not implemented for `{async block@$DIR/stalled-coroutine-obligations.rs:22:18: 22:23}` - -error[E0277]: the trait bound `False: Valid` is not satisfied in `{async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}` - --> $DIR/stalled-coroutine-obligations.rs:33:14 - | -LL | let foo: T = async { a }; - | ^ ----- within this `{async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}` - | | - | unsatisfied trait bound - | -help: within `{async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}`, the trait `Valid` is not implemented for `False` - --> $DIR/stalled-coroutine-obligations.rs:27:1 - | -LL | struct False; - | ^^^^^^^^^^^^ -note: captured value does not implement `Valid` - --> $DIR/stalled-coroutine-obligations.rs:33:26 - | -LL | let foo: T = async { a }; - | ^ has type `False` which does not implement `Valid` - -error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19}` - --> $DIR/stalled-coroutine-obligations.rs:39:5 - | -LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ - -error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19}` - --> $DIR/stalled-coroutine-obligations.rs:42:9 - | -LL | / async move { -LL | | -LL | | b -LL | | } - | |_________^ types differ - -error[E0271]: type mismatch resolving `{async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19} <: impl Future + Send` - --> $DIR/stalled-coroutine-obligations.rs:39:62 - | -LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send { - | ______________________________________________________________^ -LL | | -LL | | -LL | | async move { -... | -LL | | } - | |_____^ types differ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0271, E0277. -For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/nightly-only-unstable.force.stderr b/tests/ui/traits/nightly-only-unstable.force.stderr deleted file mode 100644 index c1b5a45dc827..000000000000 --- a/tests/ui/traits/nightly-only-unstable.force.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0277]: the trait bound `(): LocalTrait` is not satisfied - --> $DIR/nightly-only-unstable.rs:25:21 - | -LL | use_local_trait(()); - | --------------- ^^ the trait `LocalTrait` is not implemented for `()` - | | - | required by a bound introduced by this call - | -help: this trait has no implementations, consider adding one - --> $DIR/nightly-only-unstable.rs:14:1 - | -LL | trait LocalTrait {} - | ^^^^^^^^^^^^^^^^ -note: required by a bound in `use_local_trait` - --> $DIR/nightly-only-unstable.rs:16:28 - | -LL | fn use_local_trait(_: impl LocalTrait) {} - | ^^^^^^^^^^ required by this bound in `use_local_trait` - -error[E0277]: the trait bound `(): ForeignTrait` is not satisfied - --> $DIR/nightly-only-unstable.rs:31:23 - | -LL | use_foreign_trait(()); - | ----------------- ^^ the trait `ForeignTrait` is not implemented for `()` - | | - | required by a bound introduced by this call - | -note: required by a bound in `use_foreign_trait` - --> $DIR/nightly-only-unstable.rs:20:30 - | -LL | fn use_foreign_trait(_: impl force_unstable::ForeignTrait) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `use_foreign_trait` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/nightly-only-unstable.normal.stderr b/tests/ui/traits/nightly-only-unstable.normal.stderr deleted file mode 100644 index 51b896cfefdf..000000000000 --- a/tests/ui/traits/nightly-only-unstable.normal.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0277]: the trait bound `(): LocalTrait` is not satisfied - --> $DIR/nightly-only-unstable.rs:25:21 - | -LL | use_local_trait(()); - | --------------- ^^ the trait `LocalTrait` is not implemented for `()` - | | - | required by a bound introduced by this call - | -help: this trait has no implementations, consider adding one - --> $DIR/nightly-only-unstable.rs:14:1 - | -LL | trait LocalTrait {} - | ^^^^^^^^^^^^^^^^ -note: required by a bound in `use_local_trait` - --> $DIR/nightly-only-unstable.rs:16:28 - | -LL | fn use_local_trait(_: impl LocalTrait) {} - | ^^^^^^^^^^ required by this bound in `use_local_trait` - -error[E0277]: the trait bound `(): ForeignTrait` is not satisfied - --> $DIR/nightly-only-unstable.rs:31:23 - | -LL | use_foreign_trait(()); - | ----------------- ^^ the nightly-only, unstable trait `ForeignTrait` is not implemented for `()` - | | - | required by a bound introduced by this call - | -note: required by a bound in `use_foreign_trait` - --> $DIR/nightly-only-unstable.rs:20:30 - | -LL | fn use_foreign_trait(_: impl force_unstable::ForeignTrait) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `use_foreign_trait` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/nightly-only-unstable.rs b/tests/ui/traits/nightly-only-unstable.rs deleted file mode 100644 index 94f300074390..000000000000 --- a/tests/ui/traits/nightly-only-unstable.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ revisions: normal force -//@ edition: 2024 -//@ aux-crate: force_unstable=force_unstable.rs -//@[force] compile-flags: -Zforce-unstable-if-unmarked - -#![feature(rustc_private)] - -// Regression test for . -// -// When building a crate with `-Zforce-unstable-if-unmarked` (e.g. the compiler or stdlib), -// it's unhelpful to mention that a not-implemented trait is unstable, because that will -// be true of every local and foreign trait that isn't explicitly marked stable. - -trait LocalTrait {} - -fn use_local_trait(_: impl LocalTrait) {} -//~^ NOTE required by a bound in `use_local_trait` -//~| NOTE required by this bound in `use_local_trait` - -fn use_foreign_trait(_: impl force_unstable::ForeignTrait) {} -//~^ NOTE required by a bound in `use_foreign_trait` -//~| NOTE required by this bound in `use_foreign_trait` - -fn main() { - use_local_trait(()); - //~^ ERROR the trait bound `(): LocalTrait` is not satisfied - //[normal]~| NOTE the trait `LocalTrait` is not implemented for `()` - //[force]~| NOTE the trait `LocalTrait` is not implemented for `()` - //~| NOTE required by a bound introduced by this call - - use_foreign_trait(()); - //~^ ERROR the trait bound `(): ForeignTrait` is not satisfied - //[normal]~| NOTE the nightly-only, unstable trait `ForeignTrait` is not implemented for `()` - //[force]~| NOTE the trait `ForeignTrait` is not implemented for `()` - //~| NOTE required by a bound introduced by this call -} diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr index d0cc7f7fc924..c9b36e8d29de 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr @@ -5,7 +5,7 @@ LL | type Output; | ----------- `Output` defined here ... LL | let _x: Box> = Box::new(2u32); - | ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper` + | ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper` error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:48:21 @@ -14,7 +14,7 @@ LL | type Output; | ----------- `Output` defined here ... LL | let _y: Box> = Box::new(2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `NormalizableHelper` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `NormalizableHelper` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/trait-or-new-type-instead.stderr b/tests/ui/traits/trait-or-new-type-instead.stderr index ad12a84a4b80..5f5aa3ac5698 100644 --- a/tests/ui/traits/trait-or-new-type-instead.stderr +++ b/tests/ui/traits/trait-or-new-type-instead.stderr @@ -4,8 +4,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher LL | impl Option { | ^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see + = note: define and implement a trait or new type instead error: aborting due to 1 previous error diff --git a/tests/ui/traits/unspecified-self-in-trait-ref.stderr b/tests/ui/traits/unspecified-self-in-trait-ref.stderr index b7d78a3284e3..86b77193155d 100644 --- a/tests/ui/traits/unspecified-self-in-trait-ref.stderr +++ b/tests/ui/traits/unspecified-self-in-trait-ref.stderr @@ -97,7 +97,7 @@ LL | pub trait Bar { LL | let e = Bar::::lol(); | ^^^^^^^^^^^^ missing reference to `A` | - = note: because the parameter default references `Self`, the parameter must be specified on the trait object type + = note: because the parameter default references `Self`, the parameter must be specified on the object type error: aborting due to 5 previous errors; 5 warnings emitted diff --git a/tests/ui/traits/vtable/missing-generics-issue-151330.rs b/tests/ui/traits/vtable/missing-generics-issue-151330.rs deleted file mode 100644 index 352ad7be3d3a..000000000000 --- a/tests/ui/traits/vtable/missing-generics-issue-151330.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ compile-flags: -Znext-solver=globally -// Regression test for issue https://github.com/rust-lang/rust/issues/151330 - -trait Supertrait {} - -trait Trait