Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=estebank

Unhide unknown spans

r? ```@estebank```
This commit is contained in:
Dylan DPC 2022-11-12 12:02:51 +05:30 committed by GitHub
commit fcbe990093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 121 additions and 69 deletions

View File

@ -47,7 +47,10 @@ passes_no_coverage_not_coverable =
passes_should_be_applied_to_fn = passes_should_be_applied_to_fn =
attribute should be applied to a function definition attribute should be applied to a function definition
.label = not a function definition .label = {$on_crate ->
[true] cannot be applied to crates
*[false] not a function definition
}
passes_naked_tracked_caller = passes_naked_tracked_caller =
cannot use `#[track_caller]` with `#[naked]` cannot use `#[track_caller]` with `#[naked]`

View File

@ -52,7 +52,6 @@ impl Emitter for AnnotateSnippetEmitterWriter {
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args); let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);
self.fix_multispans_in_extern_macros_and_render_macro_backtrace( self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self.source_map,
&mut primary_span, &mut primary_span,
&mut children, &mut children,
&diag.level, &diag.level,

View File

@ -314,7 +314,6 @@ pub trait Emitter: Translate {
fn fix_multispans_in_extern_macros_and_render_macro_backtrace( fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self, &self,
source_map: &Option<Lrc<SourceMap>>,
span: &mut MultiSpan, span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>, children: &mut Vec<SubDiagnostic>,
level: &Level, level: &Level,
@ -340,7 +339,7 @@ pub trait Emitter: Translate {
.collect(); .collect();
if !backtrace { if !backtrace {
self.fix_multispans_in_extern_macros(source_map, span, children); self.fix_multispans_in_extern_macros(span, children);
} }
self.render_multispans_macro_backtrace(span, children, backtrace); self.render_multispans_macro_backtrace(span, children, backtrace);
@ -480,15 +479,13 @@ pub trait Emitter: Translate {
// this will change the span to point at the use site. // this will change the span to point at the use site.
fn fix_multispans_in_extern_macros( fn fix_multispans_in_extern_macros(
&self, &self,
source_map: &Option<Lrc<SourceMap>>,
span: &mut MultiSpan, span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>, children: &mut Vec<SubDiagnostic>,
) { ) {
let Some(source_map) = source_map else { return };
debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children); debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children);
self.fix_multispan_in_extern_macros(source_map, span); self.fix_multispan_in_extern_macros(span);
for child in children.iter_mut() { for child in children.iter_mut() {
self.fix_multispan_in_extern_macros(source_map, &mut child.span); self.fix_multispan_in_extern_macros(&mut child.span);
} }
debug!("fix_multispans_in_extern_macros: after: span={:?} children={:?}", span, children); debug!("fix_multispans_in_extern_macros: after: span={:?} children={:?}", span, children);
} }
@ -496,7 +493,8 @@ pub trait Emitter: Translate {
// This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros. // This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros.
// Since these locations are often difficult to read, // Since these locations are often difficult to read,
// we move these spans from the external macros to their corresponding use site. // we move these spans from the external macros to their corresponding use site.
fn fix_multispan_in_extern_macros(&self, source_map: &Lrc<SourceMap>, span: &mut MultiSpan) { fn fix_multispan_in_extern_macros(&self, span: &mut MultiSpan) {
let Some(source_map) = self.source_map() else { return };
// First, find all the spans in external macros and point instead at their use site. // First, find all the spans in external macros and point instead at their use site.
let replacements: Vec<(Span, Span)> = span let replacements: Vec<(Span, Span)> = span
.primary_spans() .primary_spans()
@ -544,7 +542,6 @@ impl Emitter for EmitterWriter {
debug!("emit_diagnostic: suggestions={:?}", suggestions); debug!("emit_diagnostic: suggestions={:?}", suggestions);
self.fix_multispans_in_extern_macros_and_render_macro_backtrace( self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self.sm,
&mut primary_span, &mut primary_span,
&mut children, &mut children,
&diag.level, &diag.level,
@ -2213,22 +2210,45 @@ impl FileWithAnnotatedLines {
if let Some(ref sm) = emitter.source_map() { if let Some(ref sm) = emitter.source_map() {
for span_label in msp.span_labels() { for span_label in msp.span_labels() {
let fixup_lo_hi = |span: Span| {
let lo = sm.lookup_char_pos(span.lo());
let mut hi = sm.lookup_char_pos(span.hi());
// Watch out for "empty spans". If we get a span like 6..6, we
// want to just display a `^` at 6, so convert that to
// 6..7. This is degenerate input, but it's best to degrade
// gracefully -- and the parser likes to supply a span like
// that for EOF, in particular.
if lo.col_display == hi.col_display && lo.line == hi.line {
hi.col_display += 1;
}
(lo, hi)
};
if span_label.span.is_dummy() { if span_label.span.is_dummy() {
if let Some(span) = msp.primary_span() {
// if we don't know where to render the annotation, emit it as a note
// on the primary span.
let (lo, hi) = fixup_lo_hi(span);
let ann = Annotation {
start_col: lo.col_display,
end_col: hi.col_display,
is_primary: span_label.is_primary,
label: span_label
.label
.as_ref()
.map(|m| emitter.translate_message(m, args).to_string()),
annotation_type: AnnotationType::Singleline,
};
add_annotation_to_file(&mut output, lo.file, lo.line, ann);
}
continue; continue;
} }
let lo = sm.lookup_char_pos(span_label.span.lo()); let (lo, hi) = fixup_lo_hi(span_label.span);
let mut hi = sm.lookup_char_pos(span_label.span.hi());
// Watch out for "empty spans". If we get a span like 6..6, we
// want to just display a `^` at 6, so convert that to
// 6..7. This is degenerate input, but it's best to degrade
// gracefully -- and the parser likes to supply a span like
// that for EOF, in particular.
if lo.col_display == hi.col_display && lo.line == hi.line {
hi.col_display += 1;
}
if lo.line != hi.line { if lo.line != hi.line {
let ml = MultilineAnnotation { let ml = MultilineAnnotation {

View File

@ -119,13 +119,13 @@ impl CheckAttrVisitor<'_> {
} }
sym::naked => self.check_naked(hir_id, attr, span, target), sym::naked => self.check_naked(hir_id, attr, span, target),
sym::rustc_legacy_const_generics => { sym::rustc_legacy_const_generics => {
self.check_rustc_legacy_const_generics(&attr, span, target, item) self.check_rustc_legacy_const_generics(hir_id, &attr, span, target, item)
} }
sym::rustc_lint_query_instability => { sym::rustc_lint_query_instability => {
self.check_rustc_lint_query_instability(&attr, span, target) self.check_rustc_lint_query_instability(hir_id, &attr, span, target)
} }
sym::rustc_lint_diagnostics => { sym::rustc_lint_diagnostics => {
self.check_rustc_lint_diagnostics(&attr, span, target) self.check_rustc_lint_diagnostics(hir_id, &attr, span, target)
} }
sym::rustc_lint_opt_ty => self.check_rustc_lint_opt_ty(&attr, span, target), sym::rustc_lint_opt_ty => self.check_rustc_lint_opt_ty(&attr, span, target),
sym::rustc_lint_opt_deny_field_access => { sym::rustc_lint_opt_deny_field_access => {
@ -135,7 +135,9 @@ impl CheckAttrVisitor<'_> {
| sym::rustc_dirty | sym::rustc_dirty
| sym::rustc_if_this_changed | sym::rustc_if_this_changed
| sym::rustc_then_this_would_need => self.check_rustc_dirty_clean(&attr), | sym::rustc_then_this_would_need => self.check_rustc_dirty_clean(&attr),
sym::cmse_nonsecure_entry => self.check_cmse_nonsecure_entry(attr, span, target), sym::cmse_nonsecure_entry => {
self.check_cmse_nonsecure_entry(hir_id, attr, span, target)
}
sym::collapse_debuginfo => self.check_collapse_debuginfo(attr, span, target), sym::collapse_debuginfo => self.check_collapse_debuginfo(attr, span, target),
sym::const_trait => self.check_const_trait(attr, span, target), sym::const_trait => self.check_const_trait(attr, span, target),
sym::must_not_suspend => self.check_must_not_suspend(&attr, span, target), sym::must_not_suspend => self.check_must_not_suspend(&attr, span, target),
@ -386,6 +388,7 @@ impl CheckAttrVisitor<'_> {
self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn { self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn {
attr_span: attr.span, attr_span: attr.span,
defn_span: span, defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
}); });
false false
} }
@ -393,7 +396,13 @@ impl CheckAttrVisitor<'_> {
} }
/// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition. /// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition.
fn check_cmse_nonsecure_entry(&self, attr: &Attribute, span: Span, target: Target) -> bool { fn check_cmse_nonsecure_entry(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
target: Target,
) -> bool {
match target { match target {
Target::Fn Target::Fn
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true, | Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
@ -401,6 +410,7 @@ impl CheckAttrVisitor<'_> {
self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn { self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn {
attr_span: attr.span, attr_span: attr.span,
defn_span: span, defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
}); });
false false
} }
@ -465,9 +475,11 @@ impl CheckAttrVisitor<'_> {
true true
} }
_ => { _ => {
self.tcx self.tcx.sess.emit_err(errors::TrackedCallerWrongLocation {
.sess attr_span,
.emit_err(errors::TrackedCallerWrongLocation { attr_span, defn_span: span }); defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
});
false false
} }
} }
@ -576,6 +588,7 @@ impl CheckAttrVisitor<'_> {
self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn { self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn {
attr_span: attr.span, attr_span: attr.span,
defn_span: span, defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
}); });
false false
} }
@ -1230,7 +1243,7 @@ impl CheckAttrVisitor<'_> {
UNUSED_ATTRIBUTES, UNUSED_ATTRIBUTES,
hir_id, hir_id,
attr.span, attr.span,
errors::Cold { span }, errors::Cold { span, on_crate: hir_id == CRATE_HIR_ID },
); );
} }
} }
@ -1366,6 +1379,7 @@ impl CheckAttrVisitor<'_> {
/// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument. /// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument.
fn check_rustc_legacy_const_generics( fn check_rustc_legacy_const_generics(
&self, &self,
hir_id: HirId,
attr: &Attribute, attr: &Attribute,
span: Span, span: Span,
target: Target, target: Target,
@ -1376,6 +1390,7 @@ impl CheckAttrVisitor<'_> {
self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn { self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn {
attr_span: attr.span, attr_span: attr.span,
defn_span: span, defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
}); });
return false; return false;
} }
@ -1440,12 +1455,19 @@ impl CheckAttrVisitor<'_> {
/// Helper function for checking that the provided attribute is only applied to a function or /// Helper function for checking that the provided attribute is only applied to a function or
/// method. /// method.
fn check_applied_to_fn_or_method(&self, attr: &Attribute, span: Span, target: Target) -> bool { fn check_applied_to_fn_or_method(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
target: Target,
) -> bool {
let is_function = matches!(target, Target::Fn | Target::Method(..)); let is_function = matches!(target, Target::Fn | Target::Method(..));
if !is_function { if !is_function {
self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn { self.tcx.sess.emit_err(errors::AttrShouldBeAppliedToFn {
attr_span: attr.span, attr_span: attr.span,
defn_span: span, defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
}); });
false false
} else { } else {
@ -1457,17 +1479,24 @@ impl CheckAttrVisitor<'_> {
/// or method. /// or method.
fn check_rustc_lint_query_instability( fn check_rustc_lint_query_instability(
&self, &self,
hir_id: HirId,
attr: &Attribute, attr: &Attribute,
span: Span, span: Span,
target: Target, target: Target,
) -> bool { ) -> bool {
self.check_applied_to_fn_or_method(attr, span, target) self.check_applied_to_fn_or_method(hir_id, attr, span, target)
} }
/// Checks that the `#[rustc_lint_diagnostics]` attribute is only applied to a function or /// Checks that the `#[rustc_lint_diagnostics]` attribute is only applied to a function or
/// method. /// method.
fn check_rustc_lint_diagnostics(&self, attr: &Attribute, span: Span, target: Target) -> bool { fn check_rustc_lint_diagnostics(
self.check_applied_to_fn_or_method(attr, span, target) &self,
hir_id: HirId,
attr: &Attribute,
span: Span,
target: Target,
) -> bool {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
} }
/// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct. /// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct.

View File

@ -81,6 +81,7 @@ pub struct AttrShouldBeAppliedToFn {
pub attr_span: Span, pub attr_span: Span,
#[label] #[label]
pub defn_span: Span, pub defn_span: Span,
pub on_crate: bool,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -97,6 +98,7 @@ pub struct TrackedCallerWrongLocation {
pub attr_span: Span, pub attr_span: Span,
#[label] #[label]
pub defn_span: Span, pub defn_span: Span,
pub on_crate: bool,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -367,6 +369,7 @@ pub struct MustNotSuspend {
pub struct Cold { pub struct Cold {
#[label] #[label]
pub span: Span, pub span: Span,
pub on_crate: bool,
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]

View File

@ -241,10 +241,12 @@ impl<'a> Resolver<'a> {
)); ));
err.span_label(span, format!("`{}` re{} here", name, new_participle)); err.span_label(span, format!("`{}` re{} here", name, new_participle));
err.span_label( if !old_binding.span.is_dummy() && old_binding.span != span {
self.session.source_map().guess_head_span(old_binding.span), err.span_label(
format!("previous {} of the {} `{}` here", old_noun, old_kind, name), self.session.source_map().guess_head_span(old_binding.span),
); format!("previous {} of the {} `{}` here", old_noun, old_kind, name),
);
}
// See https://github.com/rust-lang/rust/issues/32354 // See https://github.com/rust-lang/rust/issues/32354
use NameBindingKind::Import; use NameBindingKind::Import;

View File

@ -807,14 +807,16 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
err.code(rustc_errors::error_code!(E0411)); err.code(rustc_errors::error_code!(E0411));
err.span_label(span, "`Self` is only available in impls, traits, and type definitions"); err.span_label(span, "`Self` is only available in impls, traits, and type definitions");
if let Some(item_kind) = self.diagnostic_metadata.current_item { if let Some(item_kind) = self.diagnostic_metadata.current_item {
err.span_label( if !item_kind.ident.span.is_dummy() {
item_kind.ident.span, err.span_label(
format!( item_kind.ident.span,
"`Self` not allowed in {} {}", format!(
item_kind.kind.article(), "`Self` not allowed in {} {}",
item_kind.kind.descr() item_kind.kind.article(),
), item_kind.kind.descr()
); ),
);
}
} }
true true
} }

View File

@ -2445,12 +2445,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
(Ok(l), Ok(r)) => l.line == r.line, (Ok(l), Ok(r)) => l.line == r.line,
_ => true, _ => true,
}; };
if !ident.span.overlaps(span) && !same_line { if !ident.span.is_dummy() && !ident.span.overlaps(span) && !same_line {
multispan.push_span_label(ident.span, "required by a bound in this"); multispan.push_span_label(ident.span, "required by a bound in this");
} }
} }
let descr = format!("required by a bound in `{}`", item_name); let descr = format!("required by a bound in `{}`", item_name);
if span != DUMMY_SP { if !span.is_dummy() {
let msg = format!("required by this bound in `{}`", item_name); let msg = format!("required by this bound in `{}`", item_name);
multispan.push_span_label(span, msg); multispan.push_span_label(span, msg);
err.span_note(multispan, &descr); err.span_note(multispan, &descr);

View File

@ -36,7 +36,7 @@ error: attribute should be applied to a function definition
--> $DIR/naked-invalid-attr.rs:5:1 --> $DIR/naked-invalid-attr.rs:5:1
| |
LL | #![naked] LL | #![naked]
| ^^^^^^^^^ | ^^^^^^^^^ cannot be applied to crates
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@ -110,19 +110,19 @@ error: attribute should be applied to an `extern crate` item
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1 --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1
| |
LL | #![no_link] LL | #![no_link]
| ^^^^^^^^^^^ | ^^^^^^^^^^^ not an `extern crate` item
error: attribute should be applied to a free function, impl method or static error: attribute should be applied to a free function, impl method or static
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:27:1 --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:27:1
| |
LL | #![export_name = "2200"] LL | #![export_name = "2200"]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ not a free function, impl method or static
error[E0518]: attribute should be applied to function or closure error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:29:1 --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:29:1
| |
LL | #![inline] LL | #![inline]
| ^^^^^^^^^^ | ^^^^^^^^^^ not a function or closure
error: `macro_export` attribute cannot be used at crate level error: `macro_export` attribute cannot be used at crate level
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1

View File

@ -1,6 +1,6 @@
//~ NOTE not a function //~ NOTE not a function
//~| NOTE not a foreign function or static //~| NOTE not a foreign function or static
//~| NOTE not a function or static //~| NOTE cannot be applied to crates
//~| NOTE not an `extern` block //~| NOTE not an `extern` block
// This test enumerates as many compiler-builtin ungated attributes as // This test enumerates as many compiler-builtin ungated attributes as
// possible (that is, all the mutually compatible ones), and checks // possible (that is, all the mutually compatible ones), and checks

View File

@ -403,7 +403,7 @@ warning: attribute should be applied to a function definition
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1
| |
LL | #![cold] LL | #![cold]
| ^^^^^^^^ | ^^^^^^^^ cannot be applied to crates
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@ -411,7 +411,7 @@ warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1
| |
LL | #![link()] LL | #![link()]
| ^^^^^^^^^^ | ^^^^^^^^^^ not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@ -419,7 +419,7 @@ warning: attribute should be applied to a foreign function or static
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1
| |
LL | #![link_name = "1900"] LL | #![link_name = "1900"]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ not a foreign function or static
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@ -427,7 +427,7 @@ warning: attribute should be applied to a function or static
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1
| |
LL | #![link_section = "1800"] LL | #![link_section = "1800"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

View File

@ -2,10 +2,7 @@ error[E0428]: the name `A` is defined multiple times
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:13 --> $DIR/issue-69396-const-no-type-in-macro.rs:4:13
| |
LL | const A = "A".$fn(); LL | const A = "A".$fn();
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^ `A` redefined here
| |
| `A` redefined here
| previous definition of the value `A` here
... ...
LL | / suite! { LL | / suite! {
LL | | len; LL | | len;

View File

@ -1,5 +1,4 @@
fn main() { fn main() {
//~^ NOTE required by a bound in this
let whatever: [u32; 10] = (0..10).collect(); let whatever: [u32; 10] = (0..10).collect();
//~^ ERROR an array of type `[u32; 10]` cannot be built directly from an iterator //~^ ERROR an array of type `[u32; 10]` cannot be built directly from an iterator
//~| NOTE try collecting into a `Vec<{integer}>`, then using `.try_into()` //~| NOTE try collecting into a `Vec<{integer}>`, then using `.try_into()`

View File

@ -1,5 +1,5 @@
error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator
--> $DIR/collect-into-array.rs:3:31 --> $DIR/collect-into-array.rs:2:31
| |
LL | let whatever: [u32; 10] = (0..10).collect(); LL | let whatever: [u32; 10] = (0..10).collect();
| ^^^^^^^ ------- required by a bound introduced by this call | ^^^^^^^ ------- required by a bound introduced by this call

View File

@ -1,6 +1,4 @@
fn process_slice(data: &[i32]) { fn process_slice(data: &[i32]) {
//~^ NOTE required by a bound in this
//~| NOTE required by a bound in this
todo!() todo!()
} }

View File

@ -1,5 +1,5 @@
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/collect-into-slice.rs:8:9 --> $DIR/collect-into-slice.rs:6:9
| |
LL | let some_generated_vec = (0..10).collect(); LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@ -9,7 +9,7 @@ LL | let some_generated_vec = (0..10).collect();
= help: unsized locals are gated as an unstable feature = help: unsized locals are gated as an unstable feature
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/collect-into-slice.rs:8:38 --> $DIR/collect-into-slice.rs:6:38
| |
LL | let some_generated_vec = (0..10).collect(); LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^ doesn't have a size known at compile-time | ^^^^^^^ doesn't have a size known at compile-time
@ -22,7 +22,7 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
| ^ required by this bound in `collect` | ^ required by this bound in `collect`
error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size
--> $DIR/collect-into-slice.rs:8:30 --> $DIR/collect-into-slice.rs:6:30
| |
LL | let some_generated_vec = (0..10).collect(); LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^ ------- required by a bound introduced by this call | ^^^^^^^ ------- required by a bound introduced by this call