Auto merge of #125183 - cuviper:beta-next, r=cuviper

[beta] backports

- Do not ICE on foreign malformed `diagnostic::on_unimplemented` #124683
- Fix more ICEs in `diagnostic::on_unimplemented` #124875
- rustdoc: use stability, instead of features, to decide what to show #124864
- Don't do post-method-probe error reporting steps if we're in a suggestion #125100
-  Make `non-local-def` lint Allow by default #124950

r? cuviper
This commit is contained in:
bors 2024-05-17 04:18:18 +00:00
commit 0436bf18fc
37 changed files with 725 additions and 171 deletions

View file

@ -942,14 +942,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}
pub fn get_conversion_methods(
pub fn get_conversion_methods_for_diagnostic(
&self,
span: Span,
expected: Ty<'tcx>,
checked_ty: Ty<'tcx>,
hir_id: hir::HirId,
) -> Vec<AssocItem> {
let methods = self.probe_for_return_type(
let methods = self.probe_for_return_type_for_diagnostic(
span,
probe::Mode::MethodCall,
expected,

View file

@ -2414,7 +2414,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let guar = if field.name == kw::Empty {
self.dcx().span_delayed_bug(field.span, "field name with no name")
} else if self.method_exists(field, base_ty, expr.hir_id, expected.only_has_type(self)) {
} else if self.method_exists_for_diagnostic(
field,
base_ty,
expr.hir_id,
expected.only_has_type(self),
) {
self.ban_take_value_of_method(expr, base_ty, field)
} else if !base_ty.is_primitive_ty() {
self.ban_nonexisting_field(field, base, expr, base_ty)
@ -2600,7 +2605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut err = self.private_field_err(field, base_did);
// Also check if an accessible method exists, which is often what is meant.
if self.method_exists(field, expr_t, expr.hir_id, return_ty)
if self.method_exists_for_diagnostic(field, expr_t, expr.hir_id, return_ty)
&& !self.expr_in_place(expr.hir_id)
{
self.suggest_method_call(

View file

@ -290,7 +290,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
) -> bool {
let expr = expr.peel_blocks();
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);
let methods =
self.get_conversion_methods_for_diagnostic(expr.span, expected, found, expr.hir_id);
if let Some((suggestion, msg, applicability, verbose, annotation)) =
self.suggest_deref_or_ref(expr, found, expected)

View file

@ -90,7 +90,7 @@ pub enum CandidateSource {
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Determines whether the type `self_ty` supports a visible method named `method_name` or not.
#[instrument(level = "debug", skip(self))]
pub fn method_exists(
pub fn method_exists_for_diagnostic(
&self,
method_name: Ident,
self_ty: Ty<'tcx>,
@ -101,7 +101,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
probe::Mode::MethodCall,
method_name,
return_type,
IsSuggestion(false),
IsSuggestion(true),
self_ty,
call_expr_id,
ProbeScope::TraitsInScope,

View file

@ -88,6 +88,11 @@ pub(crate) struct ProbeContext<'a, 'tcx> {
>,
scope_expr_id: HirId,
/// Is this probe being done for a diagnostic? This will skip some error reporting
/// machinery, since we don't particularly care about, for example, similarly named
/// candidates if we're *reporting* similarly named candidates.
is_suggestion: IsSuggestion,
}
impl<'a, 'tcx> Deref for ProbeContext<'a, 'tcx> {
@ -218,7 +223,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// would use to decide if a method is a plausible fit for
/// ambiguity purposes).
#[instrument(level = "debug", skip(self, candidate_filter))]
pub fn probe_for_return_type(
pub fn probe_for_return_type_for_diagnostic(
&self,
span: Span,
mode: Mode,
@ -457,6 +462,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&orig_values,
steps.steps,
scope_expr_id,
is_suggestion,
);
probe_cx.assemble_inherent_candidates();
@ -551,6 +557,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
orig_steps_var_values: &'a OriginalQueryValues<'tcx>,
steps: &'tcx [CandidateStep<'tcx>],
scope_expr_id: HirId,
is_suggestion: IsSuggestion,
) -> ProbeContext<'a, 'tcx> {
ProbeContext {
fcx,
@ -568,6 +575,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
static_candidates: RefCell::new(Vec::new()),
unsatisfied_predicates: RefCell::new(Vec::new()),
scope_expr_id,
is_suggestion,
}
}
@ -942,6 +950,18 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
return r;
}
// If it's a `lookup_probe_for_diagnostic`, then quit early. No need to
// probe for other candidates.
if self.is_suggestion.0 {
return Err(MethodError::NoMatch(NoMatchData {
static_candidates: vec![],
unsatisfied_predicates: vec![],
out_of_scope_traits: vec![],
similar_candidate: None,
mode: self.mode,
}));
}
debug!("pick: actual search failed, assemble diagnostics");
let static_candidates = std::mem::take(self.static_candidates.get_mut());
@ -1633,6 +1653,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
self.orig_steps_var_values,
self.steps,
self.scope_expr_id,
IsSuggestion(true),
);
pcx.allow_similar_names = true;
pcx.assemble_inherent_candidates();

View file

@ -2835,7 +2835,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Some(output_ty) => self.resolve_vars_if_possible(output_ty),
_ => return,
};
let method_exists = self.method_exists(item_name, output_ty, call.hir_id, return_type);
let method_exists =
self.method_exists_for_diagnostic(item_name, output_ty, call.hir_id, return_type);
debug!("suggest_await_before_method: is_method_exist={}", method_exists);
if method_exists {
err.span_suggestion_verbose(

View file

@ -46,7 +46,7 @@ declare_lint! {
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
pub NON_LOCAL_DEFINITIONS,
Warn,
Allow,
"checks for non-local definitions",
report_in_external_macro
}

View file

@ -349,12 +349,14 @@ impl IgnoredDiagnosticOption {
option_name: &'static str,
) {
if let (Some(new_item), Some(old_item)) = (new, old) {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
new_item,
IgnoredDiagnosticOption { span: new_item, prev_span: old_item, option_name },
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
new_item,
IgnoredDiagnosticOption { span: new_item, prev_span: old_item, option_name },
);
}
}
}
}
@ -498,12 +500,14 @@ impl<'tcx> OnUnimplementedDirective {
}
if is_diagnostic_namespace_variant {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
vec![item.span()],
MalformedOnUnimplementedAttrLint::new(item.span()),
);
if let Some(def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(def_id),
vec![item.span()],
MalformedOnUnimplementedAttrLint::new(item.span()),
);
}
} else {
// nothing found
tcx.dcx().emit_err(NoValueInOnUnimplemented { span: item.span() });
@ -636,30 +640,38 @@ impl<'tcx> OnUnimplementedDirective {
AttrArgs::Eq(span, AttrArgsEq::Hir(expr)) => span.to(expr.span),
};
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
report_span,
MalformedOnUnimplementedAttrLint::new(report_span),
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
report_span,
MalformedOnUnimplementedAttrLint::new(report_span),
);
}
Ok(None)
}
} else if is_diagnostic_namespace_variant {
match &attr.kind {
AttrKind::Normal(p) if !matches!(p.item.args, AttrArgs::Empty) => {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
attr.span,
MalformedOnUnimplementedAttrLint::new(attr.span),
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
attr.span,
MalformedOnUnimplementedAttrLint::new(attr.span),
);
}
}
_ => {
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
attr.span,
MissingOptionsForOnUnimplementedAttr,
)
}
}
_ => tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
attr.span,
MissingOptionsForOnUnimplementedAttr,
),
};
Ok(None)
@ -788,12 +800,14 @@ impl<'tcx> OnUnimplementedFormatString {
|| format_spec.precision_span.is_some()
|| format_spec.fill_span.is_some())
{
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
self.span,
InvalidFormatSpecifier,
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
self.span,
InvalidFormatSpecifier,
);
}
}
match a.position {
Position::ArgumentNamed(s) => {
@ -809,15 +823,17 @@ impl<'tcx> OnUnimplementedFormatString {
s if generics.params.iter().any(|param| param.name == s) => (),
s => {
if self.is_diagnostic_namespace_variant {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
self.span,
UnknownFormatParameterForOnUnimplementedAttr {
argument_name: s,
trait_name,
},
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
self.span,
UnknownFormatParameterForOnUnimplementedAttr {
argument_name: s,
trait_name,
},
);
}
} else {
result = Err(struct_span_code_err!(
tcx.dcx(),
@ -839,12 +855,14 @@ impl<'tcx> OnUnimplementedFormatString {
// `{:1}` and `{}` are not to be used
Position::ArgumentIs(..) | Position::ArgumentImplicitlyIs(_) => {
if self.is_diagnostic_namespace_variant {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
self.span,
DisallowedPositionalArgument,
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
self.span,
DisallowedPositionalArgument,
);
}
} else {
let reported = struct_span_code_err!(
tcx.dcx(),
@ -867,12 +885,14 @@ impl<'tcx> OnUnimplementedFormatString {
// so that users are aware that something is not correct
for e in parser.errors {
if self.is_diagnostic_namespace_variant {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
self.span,
WrappedParserError { description: e.description, label: e.label },
);
if let Some(item_def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id),
self.span,
WrappedParserError { description: e.description, label: e.label },
);
}
} else {
let reported =
struct_span_code_err!(tcx.dcx(), self.span, E0231, "{}", e.description,).emit();

View file

@ -14,6 +14,7 @@ use rustc_hir::Mutability;
use rustc_metadata::creader::{CStore, LoadedMacro};
use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol};
@ -444,24 +445,24 @@ pub(crate) fn build_impl(
let associated_trait = tcx.impl_trait_ref(did).map(ty::EarlyBinder::skip_binder);
// Do not inline compiler-internal items unless we're a compiler-internal crate.
let is_compiler_internal = |did| {
tcx.lookup_stability(did)
.is_some_and(|stab| stab.is_unstable() && stab.feature == sym::rustc_private)
};
let document_compiler_internal = is_compiler_internal(LOCAL_CRATE.as_def_id());
let is_directly_public = |cx: &mut DocContext<'_>, did| {
cx.cache.effective_visibilities.is_directly_public(tcx, did)
&& (document_compiler_internal || !is_compiler_internal(did))
};
// Only inline impl if the implemented trait is
// reachable in rustdoc generated documentation
if !did.is_local()
&& let Some(traitref) = associated_trait
&& !is_directly_public(cx, traitref.def_id)
{
let did = traitref.def_id;
if !cx.cache.effective_visibilities.is_directly_public(tcx, did) {
return;
}
if !tcx.features().rustc_private && !cx.render_options.force_unstable_if_unmarked {
if let Some(stab) = tcx.lookup_stability(did)
&& stab.is_unstable()
&& stab.feature == sym::rustc_private
{
return;
}
}
return;
}
let impl_item = match did.as_local() {
@ -484,21 +485,11 @@ pub(crate) fn build_impl(
// Only inline impl if the implementing type is
// reachable in rustdoc generated documentation
if !did.is_local() {
if let Some(did) = for_.def_id(&cx.cache) {
if !cx.cache.effective_visibilities.is_directly_public(tcx, did) {
return;
}
if !tcx.features().rustc_private && !cx.render_options.force_unstable_if_unmarked {
if let Some(stab) = tcx.lookup_stability(did)
&& stab.is_unstable()
&& stab.feature == sym::rustc_private
{
return;
}
}
}
if !did.is_local()
&& let Some(did) = for_.def_id(&cx.cache)
&& !is_directly_public(cx, did)
{
return;
}
let document_hidden = cx.render_options.document_hidden;

View file

@ -285,8 +285,6 @@ pub(crate) struct RenderOptions {
pub(crate) no_emit_shared: bool,
/// If `true`, HTML source code pages won't be generated.
pub(crate) html_no_source: bool,
/// Whether `-Zforce-unstable-if-unmarked` unstable option is set
pub(crate) force_unstable_if_unmarked: bool,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -353,7 +351,6 @@ impl Options {
let codegen_options = CodegenOptions::build(early_dcx, matches);
let unstable_opts = UnstableOptions::build(early_dcx, matches);
let force_unstable_if_unmarked = unstable_opts.force_unstable_if_unmarked;
let dcx = new_dcx(error_format, None, diagnostic_width, &unstable_opts);
@ -790,7 +787,6 @@ impl Options {
call_locations,
no_emit_shared: false,
html_no_source,
force_unstable_if_unmarked,
};
Some((options, render_options))
}

View file

@ -1,6 +1,8 @@
//@ aux-build:issue-76736-1.rs
//@ aux-build:issue-76736-2.rs
// https://github.com/rust-lang/rust/issues/124635
#![crate_name = "foo"]
#![feature(rustc_private)]
@ -8,9 +10,9 @@ extern crate issue_76736_1;
extern crate issue_76736_2;
// @has foo/struct.Foo.html
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
pub struct Foo;
// @has foo/struct.Bar.html
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
pub use issue_76736_2::Bar;

View file

@ -0,0 +1,19 @@
//@ aux-build:issue-76736-1.rs
//@ aux-build:issue-76736-2.rs
// https://github.com/rust-lang/rust/issues/124635
#![crate_name = "foo"]
#![feature(rustc_private, staged_api)]
#![unstable(feature = "rustc_private", issue = "none")]
extern crate issue_76736_1;
extern crate issue_76736_2;
// @has foo/struct.Foo.html
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
pub struct Foo;
// @has foo/struct.Bar.html
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
pub use issue_76736_2::Bar;

View file

@ -0,0 +1,26 @@
#[diagnostic::on_unimplemented(aa = "broken")]
pub trait MissingAttr {}
#[diagnostic::on_unimplemented(label = "a", label = "b")]
pub trait DuplicateAttr {}
#[diagnostic::on_unimplemented = "broken"]
pub trait NotMetaList {}
#[diagnostic::on_unimplemented]
pub trait Empty {}
#[diagnostic::on_unimplemented {}]
pub trait WrongDelim {}
#[diagnostic::on_unimplemented(label = "{A:.3}")]
pub trait BadFormatter<A> {}
#[diagnostic::on_unimplemented(label = "test {}")]
pub trait NoImplicitArgs {}
#[diagnostic::on_unimplemented(label = "{missing}")]
pub trait MissingArg {}
#[diagnostic::on_unimplemented(label = "{_}")]
pub trait BadArg {}

View file

@ -0,0 +1,31 @@
//@ edition:2021
//@ aux-build:bad_on_unimplemented.rs
// Do not ICE when encountering a malformed `#[diagnostic::on_unimplemented]` annotation in a
// dependency when incorrectly used (#124651).
extern crate bad_on_unimplemented;
use bad_on_unimplemented::*;
fn missing_attr<T: MissingAttr>(_: T) {}
fn duplicate_attr<T: DuplicateAttr>(_: T) {}
fn not_meta_list<T: NotMetaList>(_: T) {}
fn empty<T: Empty>(_: T) {}
fn wrong_delim<T: WrongDelim>(_: T) {}
fn bad_formatter<T: BadFormatter<()>>(_: T) {}
fn no_implicit_args<T: NoImplicitArgs>(_: T) {}
fn missing_arg<T: MissingArg>(_: T) {}
fn bad_arg<T: BadArg>(_: T) {}
fn main() {
missing_attr(()); //~ ERROR E0277
duplicate_attr(()); //~ ERROR E0277
not_meta_list(()); //~ ERROR E0277
empty(()); //~ ERROR E0277
wrong_delim(()); //~ ERROR E0277
bad_formatter(()); //~ ERROR E0277
no_implicit_args(()); //~ ERROR E0277
missing_arg(()); //~ ERROR E0277
bad_arg(()); //~ ERROR E0277
}

View file

@ -0,0 +1,134 @@
error[E0277]: the trait bound `(): bad_on_unimplemented::MissingAttr` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:22:18
|
LL | missing_attr(());
| ------------ ^^ the trait `bad_on_unimplemented::MissingAttr` is not implemented for `()`
| |
| required by a bound introduced by this call
|
note: required by a bound in `missing_attr`
--> $DIR/malformed_foreign_on_unimplemented.rs:11:20
|
LL | fn missing_attr<T: MissingAttr>(_: T) {}
| ^^^^^^^^^^^ required by this bound in `missing_attr`
error[E0277]: the trait bound `(): bad_on_unimplemented::DuplicateAttr` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:23:20
|
LL | duplicate_attr(());
| -------------- ^^ a
| |
| required by a bound introduced by this call
|
= help: the trait `bad_on_unimplemented::DuplicateAttr` is not implemented for `()`
note: required by a bound in `duplicate_attr`
--> $DIR/malformed_foreign_on_unimplemented.rs:12:22
|
LL | fn duplicate_attr<T: DuplicateAttr>(_: T) {}
| ^^^^^^^^^^^^^ required by this bound in `duplicate_attr`
error[E0277]: the trait bound `(): bad_on_unimplemented::NotMetaList` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:24:19
|
LL | not_meta_list(());
| ------------- ^^ the trait `bad_on_unimplemented::NotMetaList` is not implemented for `()`
| |
| required by a bound introduced by this call
|
note: required by a bound in `not_meta_list`
--> $DIR/malformed_foreign_on_unimplemented.rs:13:21
|
LL | fn not_meta_list<T: NotMetaList>(_: T) {}
| ^^^^^^^^^^^ required by this bound in `not_meta_list`
error[E0277]: the trait bound `(): bad_on_unimplemented::Empty` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:25:11
|
LL | empty(());
| ----- ^^ the trait `bad_on_unimplemented::Empty` is not implemented for `()`
| |
| required by a bound introduced by this call
|
note: required by a bound in `empty`
--> $DIR/malformed_foreign_on_unimplemented.rs:14:13
|
LL | fn empty<T: Empty>(_: T) {}
| ^^^^^ required by this bound in `empty`
error[E0277]: the trait bound `(): bad_on_unimplemented::WrongDelim` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:26:17
|
LL | wrong_delim(());
| ----------- ^^ the trait `bad_on_unimplemented::WrongDelim` is not implemented for `()`
| |
| required by a bound introduced by this call
|
note: required by a bound in `wrong_delim`
--> $DIR/malformed_foreign_on_unimplemented.rs:15:19
|
LL | fn wrong_delim<T: WrongDelim>(_: T) {}
| ^^^^^^^^^^ required by this bound in `wrong_delim`
error[E0277]: the trait bound `(): bad_on_unimplemented::BadFormatter<()>` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:27:19
|
LL | bad_formatter(());
| ------------- ^^ ()
| |
| required by a bound introduced by this call
|
= help: the trait `bad_on_unimplemented::BadFormatter<()>` is not implemented for `()`
note: required by a bound in `bad_formatter`
--> $DIR/malformed_foreign_on_unimplemented.rs:16:21
|
LL | fn bad_formatter<T: BadFormatter<()>>(_: T) {}
| ^^^^^^^^^^^^^^^^ required by this bound in `bad_formatter`
error[E0277]: the trait bound `(): bad_on_unimplemented::NoImplicitArgs` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:28:22
|
LL | no_implicit_args(());
| ---------------- ^^ test {}
| |
| required by a bound introduced by this call
|
= help: the trait `bad_on_unimplemented::NoImplicitArgs` is not implemented for `()`
note: required by a bound in `no_implicit_args`
--> $DIR/malformed_foreign_on_unimplemented.rs:17:24
|
LL | fn no_implicit_args<T: NoImplicitArgs>(_: T) {}
| ^^^^^^^^^^^^^^ required by this bound in `no_implicit_args`
error[E0277]: the trait bound `(): bad_on_unimplemented::MissingArg` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:29:17
|
LL | missing_arg(());
| ----------- ^^ {missing}
| |
| required by a bound introduced by this call
|
= help: the trait `bad_on_unimplemented::MissingArg` is not implemented for `()`
note: required by a bound in `missing_arg`
--> $DIR/malformed_foreign_on_unimplemented.rs:18:19
|
LL | fn missing_arg<T: MissingArg>(_: T) {}
| ^^^^^^^^^^ required by this bound in `missing_arg`
error[E0277]: the trait bound `(): bad_on_unimplemented::BadArg` is not satisfied
--> $DIR/malformed_foreign_on_unimplemented.rs:30:13
|
LL | bad_arg(());
| ------- ^^ {_}
| |
| required by a bound introduced by this call
|
= help: the trait `bad_on_unimplemented::BadArg` is not implemented for `()`
note: required by a bound in `bad_arg`
--> $DIR/malformed_foreign_on_unimplemented.rs:19:15
|
LL | fn bad_arg<T: BadArg>(_: T) {}
| ^^^^^^ required by this bound in `bad_arg`
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -10,6 +10,8 @@
// of the `cargo update` suggestion we assert it here.
//@ error-pattern: `cargo update -p non_local_macro`
#![warn(non_local_definitions)]
extern crate non_local_macro;
struct LocalStruct;

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/cargo-update.rs:17:1
--> $DIR/cargo-update.rs:19:1
|
LL | non_local_macro::non_local_impl!(LocalStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9,7 +9,11 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/cargo-update.rs:13:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted

View file

@ -2,6 +2,8 @@
//@ edition:2021
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
#![warn(non_local_definitions)]
struct Test;
trait Uto {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:13:5
--> $DIR/consts.rs:15:5
|
LL | const Z: () = {
| - help: use a const-anon item to suppress this lint: `_`
@ -11,10 +11,14 @@ LL | impl Uto for &Test {}
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/consts.rs:5:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:24:5
--> $DIR/consts.rs:26:5
|
LL | impl Uto2 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -25,7 +29,7 @@ LL | impl Uto2 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:32:5
--> $DIR/consts.rs:34:5
|
LL | impl Uto3 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -36,7 +40,7 @@ LL | impl Uto3 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:43:5
--> $DIR/consts.rs:45:5
|
LL | / impl Test {
LL | |
@ -50,7 +54,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:50:9
--> $DIR/consts.rs:52:9
|
LL | / impl Test {
LL | |
@ -64,7 +68,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:59:9
--> $DIR/consts.rs:61:9
|
LL | / impl Test {
LL | |
@ -78,7 +82,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:72:9
--> $DIR/consts.rs:74:9
|
LL | impl Uto9 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -89,7 +93,7 @@ LL | impl Uto9 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/consts.rs:79:9
--> $DIR/consts.rs:81:9
|
LL | impl Uto10 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
struct Dog;
fn main() {

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive-trait.rs:7:5
--> $DIR/exhaustive-trait.rs:9:5
|
LL | / impl PartialEq<()> for Dog {
LL | |
@ -13,10 +13,14 @@ LL | | }
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/exhaustive-trait.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive-trait.rs:14:5
--> $DIR/exhaustive-trait.rs:16:5
|
LL | / impl PartialEq<()> for &Dog {
LL | |
@ -32,7 +36,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive-trait.rs:21:5
--> $DIR/exhaustive-trait.rs:23:5
|
LL | / impl PartialEq<Dog> for () {
LL | |
@ -48,7 +52,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive-trait.rs:28:5
--> $DIR/exhaustive-trait.rs:30:5
|
LL | / impl PartialEq<&Dog> for () {
LL | |
@ -64,7 +68,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive-trait.rs:35:5
--> $DIR/exhaustive-trait.rs:37:5
|
LL | / impl PartialEq<Dog> for &Dog {
LL | |
@ -80,7 +84,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive-trait.rs:42:5
--> $DIR/exhaustive-trait.rs:44:5
|
LL | / impl PartialEq<&Dog> for &Dog {
LL | |

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Display;
trait Trait {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:10:5
--> $DIR/exhaustive.rs:12:5
|
LL | / impl Test {
LL | |
@ -11,10 +11,14 @@ LL | | }
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/exhaustive.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:15:5
--> $DIR/exhaustive.rs:17:5
|
LL | / impl Display for Test {
LL | |
@ -30,7 +34,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:22:5
--> $DIR/exhaustive.rs:24:5
|
LL | impl dyn Trait {}
| ^^^^^^^^^^^^^^^^^
@ -41,7 +45,7 @@ LL | impl dyn Trait {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:25:5
--> $DIR/exhaustive.rs:27:5
|
LL | impl<T: Trait> Trait for Vec<T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -52,7 +56,7 @@ LL | impl<T: Trait> Trait for Vec<T> { }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:28:5
--> $DIR/exhaustive.rs:30:5
|
LL | impl Trait for &dyn Trait {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -63,7 +67,7 @@ LL | impl Trait for &dyn Trait {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:31:5
--> $DIR/exhaustive.rs:33:5
|
LL | impl Trait for *mut Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -74,7 +78,7 @@ LL | impl Trait for *mut Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:34:5
--> $DIR/exhaustive.rs:36:5
|
LL | impl Trait for *mut [Test] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -85,7 +89,7 @@ LL | impl Trait for *mut [Test] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:37:5
--> $DIR/exhaustive.rs:39:5
|
LL | impl Trait for [Test; 8] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -96,7 +100,7 @@ LL | impl Trait for [Test; 8] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:40:5
--> $DIR/exhaustive.rs:42:5
|
LL | impl Trait for (Test,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -107,7 +111,7 @@ LL | impl Trait for (Test,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:43:5
--> $DIR/exhaustive.rs:45:5
|
LL | impl Trait for fn(Test) -> () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -118,7 +122,7 @@ LL | impl Trait for fn(Test) -> () {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:46:5
--> $DIR/exhaustive.rs:48:5
|
LL | impl Trait for fn() -> Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -129,7 +133,7 @@ LL | impl Trait for fn() -> Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:50:9
--> $DIR/exhaustive.rs:52:9
|
LL | impl Trait for Test {}
| ^^^^^^^^^^^^^^^^^^^^^^
@ -140,7 +144,7 @@ LL | impl Trait for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:58:5
--> $DIR/exhaustive.rs:60:5
|
LL | impl Trait for *mut InsideMain {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -151,7 +155,7 @@ LL | impl Trait for *mut InsideMain {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:60:5
--> $DIR/exhaustive.rs:62:5
|
LL | impl Trait for *mut [InsideMain] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -162,7 +166,7 @@ LL | impl Trait for *mut [InsideMain] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:62:5
--> $DIR/exhaustive.rs:64:5
|
LL | impl Trait for [InsideMain; 8] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -173,7 +177,7 @@ LL | impl Trait for [InsideMain; 8] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:64:5
--> $DIR/exhaustive.rs:66:5
|
LL | impl Trait for (InsideMain,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -184,7 +188,7 @@ LL | impl Trait for (InsideMain,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:66:5
--> $DIR/exhaustive.rs:68:5
|
LL | impl Trait for fn(InsideMain) -> () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -195,7 +199,7 @@ LL | impl Trait for fn(InsideMain) -> () {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:68:5
--> $DIR/exhaustive.rs:70:5
|
LL | impl Trait for fn() -> InsideMain {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -206,7 +210,7 @@ LL | impl Trait for fn() -> InsideMain {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:72:9
--> $DIR/exhaustive.rs:74:9
|
LL | / impl Display for InsideMain {
LL | |
@ -222,7 +226,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/exhaustive.rs:79:9
--> $DIR/exhaustive.rs:81:9
|
LL | / impl InsideMain {
LL | |

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
struct Cat;
struct Wrap<T>(T);

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/from-local-for-global.rs:8:5
--> $DIR/from-local-for-global.rs:10:5
|
LL | / impl From<Cat> for () {
LL | |
@ -13,10 +13,14 @@ LL | | }
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/from-local-for-global.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/from-local-for-global.rs:18:5
--> $DIR/from-local-for-global.rs:20:5
|
LL | / impl From<Wrap<Wrap<Elephant>>> for () {
LL | |
@ -32,7 +36,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/from-local-for-global.rs:32:5
--> $DIR/from-local-for-global.rs:34:5
|
LL | impl StillNonLocal for &Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -43,7 +47,7 @@ LL | impl StillNonLocal for &Foo {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/from-local-for-global.rs:40:5
--> $DIR/from-local-for-global.rs:42:5
|
LL | / impl From<Local1> for GlobalSameFunction {
LL | |
@ -59,7 +63,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/from-local-for-global.rs:48:5
--> $DIR/from-local-for-global.rs:50:5
|
LL | / impl From<Local2> for GlobalSameFunction {
LL | |

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
trait Global {}
fn main() {

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:9:5
--> $DIR/generics.rs:11:5
|
LL | impl<T: Local> Global for Vec<T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8,10 +8,14 @@ LL | impl<T: Local> Global for Vec<T> { }
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/generics.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:20:5
--> $DIR/generics.rs:22:5
|
LL | impl Uto7 for Test where Local: std::any::Any {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -22,7 +26,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:23:5
--> $DIR/generics.rs:25:5
|
LL | impl<T> Uto8 for T {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -33,7 +37,7 @@ LL | impl<T> Uto8 for T {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:32:5
--> $DIR/generics.rs:34:5
|
LL | / impl Default for UwU<OwO> {
LL | |
@ -49,7 +53,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:43:5
--> $DIR/generics.rs:45:5
|
LL | / impl AsRef<Cat> for () {
LL | |
@ -63,7 +67,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:54:5
--> $DIR/generics.rs:56:5
|
LL | / impl PartialEq<B> for G {
LL | |
@ -79,7 +83,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:69:5
--> $DIR/generics.rs:71:5
|
LL | / impl From<Wrap<Wrap<Lion>>> for () {
LL | |
@ -95,7 +99,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/generics.rs:76:5
--> $DIR/generics.rs:78:5
|
LL | / impl From<()> for Wrap<Lion> {
LL | |

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
macro_rules! m {
() => {
trait MacroTrait {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/inside-macro_rules.rs:9:13
--> $DIR/inside-macro_rules.rs:11:13
|
LL | impl MacroTrait for OutsideStruct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -11,7 +11,11 @@ LL | m!();
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/inside-macro_rules.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted

View file

@ -3,6 +3,8 @@
//@ aux-build:non_local_macro.rs
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
#![warn(non_local_definitions)]
extern crate non_local_macro;
const B: u32 = {

View file

@ -1,5 +1,5 @@
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/macro_rules.rs:10:5
--> $DIR/macro_rules.rs:12:5
|
LL | macro_rules! m0 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8,10 +8,14 @@ LL | macro_rules! m0 { () => { } };
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/macro_rules.rs:6:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/macro_rules.rs:16:1
--> $DIR/macro_rules.rs:18:1
|
LL | non_local_macro::non_local_macro_rules!(my_macro);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +28,7 @@ LL | non_local_macro::non_local_macro_rules!(my_macro);
= note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/macro_rules.rs:21:5
--> $DIR/macro_rules.rs:23:5
|
LL | macro_rules! m { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -35,7 +39,7 @@ LL | macro_rules! m { () => { } };
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/macro_rules.rs:29:13
--> $DIR/macro_rules.rs:31:13
|
LL | macro_rules! m2 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
// https://github.com/rust-lang/rust/issues/123573#issue-2229428739
pub trait Test {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/trait-solver-overflow-123573.rs:12:5
--> $DIR/trait-solver-overflow-123573.rs:14:5
|
LL | impl Test for &Local {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -8,7 +8,11 @@ LL | impl Test for &Local {}
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/trait-solver-overflow-123573.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
trait Uto {}
struct Test;

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/weird-exprs.rs:8:5
--> $DIR/weird-exprs.rs:10:5
|
LL | impl Uto for *mut Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8,10 +8,14 @@ LL | impl Uto for *mut Test {}
= note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/weird-exprs.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/weird-exprs.rs:16:9
--> $DIR/weird-exprs.rs:18:9
|
LL | impl Uto for Test {}
| ^^^^^^^^^^^^^^^^^^^^
@ -22,7 +26,7 @@ LL | impl Uto for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/weird-exprs.rs:25:9
--> $DIR/weird-exprs.rs:27:9
|
LL | / impl Test {
LL | |
@ -36,7 +40,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/weird-exprs.rs:34:9
--> $DIR/weird-exprs.rs:36:9
|
LL | impl Uto for &Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -47,7 +51,7 @@ LL | impl Uto for &Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/weird-exprs.rs:41:9
--> $DIR/weird-exprs.rs:43:9
|
LL | impl Uto for &(Test,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
@ -58,7 +62,7 @@ LL | impl Uto for &(Test,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/weird-exprs.rs:48:9
--> $DIR/weird-exprs.rs:50:9
|
LL | impl Uto for &(Test,Test) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,163 @@
#![allow(non_snake_case)]
// Ensures that we don't spend an unnecessary amount of compiler time building
// suggestions for mistyped methods. This used to happen because when we had method
// lookup failures, we would do subsequent method lookups, and those would themselves
// do extra work that was unnecessary for the purposes of suggestions.
// Fixed by #125100.
macro_rules! traits {
($($name:ident),*) => {
$(
trait $name {
fn $name(&self);
}
)*
}
}
traits!(
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20,
A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37, A38, A39,
A40, A41, A42, A43, A44, A45, A46, A47, A48, A49, A50, A51, A52, A53, A54, A55, A56, A57, A58,
A59, A60, A61, A62, A63, A64, A65, A66, A67, A68, A69, A70, A71, A72, A73, A74, A75, A76, A77,
A78, A79, A80, A81, A82, A83, A84, A85, A86, A87, A88, A89, A90, A91, A92, A93, A94, A95, A96,
A97, A98, A99, A100, A101, A102, A103, A104, A105, A106, A107, A108, A109, A110, A111, A112,
A113, A114, A115, A116, A117, A118, A119, A120, A121, A122, A123, A124, A125, A126, A127, A128,
A129, A130, A131, A132, A133, A134, A135, A136, A137, A138, A139, A140, A141, A142, A143, A144,
A145, A146, A147, A148, A149, A150, A151, A152, A153, A154, A155, A156, A157, A158, A159, A160,
A161, A162, A163, A164, A165, A166, A167, A168, A169, A170, A171, A172, A173, A174, A175, A176,
A177, A178, A179, A180, A181, A182, A183, A184, A185, A186, A187, A188, A189, A190, A191, A192,
A193, A194, A195, A196, A197, A198, A199, A200, A201, A202, A203, A204, A205, A206, A207, A208,
A209, A210, A211, A212, A213, A214, A215, A216, A217, A218, A219, A220, A221, A222, A223, A224,
A225, A226, A227, A228, A229, A230, A231, A232, A233, A234, A235, A236, A237, A238, A239, A240,
A241, A242, A243, A244, A245, A246, A247, A248, A249, A250, A251, A252, A253, A254, A255, A256,
A257, A258, A259, A260, A261, A262, A263, A264, A265, A266, A267, A268, A269, A270, A271, A272,
A273, A274, A275, A276, A277, A278, A279, A280, A281, A282, A283, A284, A285, A286, A287, A288,
A289, A290, A291, A292, A293, A294, A295, A296, A297, A298, A299, A300, A301, A302, A303, A304,
A305, A306, A307, A308, A309, A310, A311, A312, A313, A314, A315, A316, A317, A318, A319, A320,
A321, A322, A323, A324, A325, A326, A327, A328, A329, A330, A331, A332, A333, A334, A335, A336,
A337, A338, A339, A340, A341, A342, A343, A344, A345, A346, A347, A348, A349, A350, A351, A352,
A353, A354, A355, A356, A357, A358, A359, A360, A361, A362, A363, A364, A365, A366, A367, A368,
A369, A370, A371, A372, A373, A374, A375, A376, A377, A378, A379, A380, A381, A382, A383, A384,
A385, A386, A387, A388, A389, A390, A391, A392, A393, A394, A395, A396, A397, A398, A399, A400,
A401, A402, A403, A404, A405, A406, A407, A408, A409, A410, A411, A412, A413, A414, A415, A416,
A417, A418, A419, A420, A421, A422, A423, A424, A425, A426, A427, A428, A429, A430, A431, A432,
A433, A434, A435, A436, A437, A438, A439, A440, A441, A442, A443, A444, A445, A446, A447, A448,
A449, A450, A451, A452, A453, A454, A455, A456, A457, A458, A459, A460, A461, A462, A463, A464,
A465, A466, A467, A468, A469, A470, A471, A472, A473, A474, A475, A476, A477, A478, A479, A480,
A481, A482, A483, A484, A485, A486, A487, A488, A489, A490, A491, A492, A493, A494, A495, A496,
A497, A498, A499, A500, A501, A502, A503, A504, A505, A506, A507, A508, A509, A510, A511, A512,
A513, A514, A515, A516, A517, A518, A519, A520, A521, A522, A523, A524, A525, A526, A527, A528,
A529, A530, A531, A532, A533, A534, A535, A536, A537, A538, A539, A540, A541, A542, A543, A544,
A545, A546, A547, A548, A549, A550, A551, A552, A553, A554, A555, A556, A557, A558, A559, A560,
A561, A562, A563, A564, A565, A566, A567, A568, A569, A570, A571, A572, A573, A574, A575, A576,
A577, A578, A579, A580, A581, A582, A583, A584, A585, A586, A587, A588, A589, A590, A591, A592,
A593, A594, A595, A596, A597, A598, A599, A600, A601, A602, A603, A604, A605, A606, A607, A608,
A609, A610, A611, A612, A613, A614, A615, A616, A617, A618, A619, A620, A621, A622, A623, A624,
A625, A626, A627, A628, A629, A630, A631, A632, A633, A634, A635, A636, A637, A638, A639, A640,
A641, A642, A643, A644, A645, A646, A647, A648, A649, A650, A651, A652, A653, A654, A655, A656,
A657, A658, A659, A660, A661, A662, A663, A664, A665, A666, A667, A668, A669, A670, A671, A672,
A673, A674, A675, A676, A677, A678, A679, A680, A681, A682, A683, A684, A685, A686, A687, A688,
A689, A690, A691, A692, A693, A694, A695, A696, A697, A698, A699, A700, A701, A702, A703, A704,
A705, A706, A707, A708, A709, A710, A711, A712, A713, A714, A715, A716, A717, A718, A719, A720,
A721, A722, A723, A724, A725, A726, A727, A728, A729, A730, A731, A732, A733, A734, A735, A736,
A737, A738, A739, A740, A741, A742, A743, A744, A745, A746, A747, A748, A749, A750, A751, A752,
A753, A754, A755, A756, A757, A758, A759, A760, A761, A762, A763, A764, A765, A766, A767, A768,
A769, A770, A771, A772, A773, A774, A775, A776, A777, A778, A779, A780, A781, A782, A783, A784,
A785, A786, A787, A788, A789, A790, A791, A792, A793, A794, A795, A796, A797, A798, A799, A800,
A801, A802, A803, A804, A805, A806, A807, A808, A809, A810, A811, A812, A813, A814, A815, A816,
A817, A818, A819, A820, A821, A822, A823, A824, A825, A826, A827, A828, A829, A830, A831, A832,
A833, A834, A835, A836, A837, A838, A839, A840, A841, A842, A843, A844, A845, A846, A847, A848,
A849, A850, A851, A852, A853, A854, A855, A856, A857, A858, A859, A860, A861, A862, A863, A864,
A865, A866, A867, A868, A869, A870, A871, A872, A873, A874, A875, A876, A877, A878, A879, A880,
A881, A882, A883, A884, A885, A886, A887, A888, A889, A890, A891, A892, A893, A894, A895, A896,
A897, A898, A899, A900, A901, A902, A903, A904, A905, A906, A907, A908, A909, A910, A911, A912,
A913, A914, A915, A916, A917, A918, A919, A920, A921, A922, A923, A924, A925, A926, A927, A928,
A929, A930, A931, A932, A933, A934, A935, A936, A937, A938, A939, A940, A941, A942, A943, A944,
A945, A946, A947, A948, A949, A950, A951, A952, A953, A954, A955, A956, A957, A958, A959, A960,
A961, A962, A963, A964, A965, A966, A967, A968, A969, A970, A971, A972, A973, A974, A975, A976,
A977, A978, A979, A980, A981, A982, A983, A984, A985, A986, A987, A988, A989, A990, A991, A992,
A993, A994, A995, A996, A997, A998, A999
);
#[derive(Default)]
struct M0 {
m1: M1,
m2: M1,
m3: M1,
m4: M1,
m5: M1,
m6: M1,
m7: M1,
m8: M1,
m9: M1,
m10: M1,
m11: M1,
m12: M1,
m13: M1,
m14: M1,
m15: M1,
}
#[derive(Default)]
struct M1 {
m1: M2,
m2: M2,
m3: M2,
m4: M2,
m5: M2,
m6: M2,
m7: M2,
m8: M2,
m9: M2,
m10: M2,
m11: M2,
m12: M2,
m13: M2,
m14: M2,
m15: M2,
}
#[derive(Default)]
struct M2 {
m1: M3,
m2: M3,
m3: M3,
m4: M3,
m5: M3,
m6: M3,
m7: M3,
m8: M3,
m9: M3,
m10: M3,
m11: M3,
m12: M3,
m13: M3,
m14: M3,
m15: M3,
}
#[derive(Default)]
struct M3 {}
fn main() {
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
M0::default().Au();
//~^ ERROR no method named `Au` found for struct `M0` in the current scope
}

View file

@ -0,0 +1,84 @@
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:145:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:147:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:149:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:151:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:153:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:155:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:157:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:159:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error[E0599]: no method named `Au` found for struct `M0` in the current scope
--> $DIR/probe-for-diagnostic-doesnt-do-extra-work.rs:161:19
|
LL | struct M0 {
| --------- method `Au` not found for this struct
...
LL | M0::default().Au();
| ^^ method not found in `M0`
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0599`.