mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Auto merge of #115104 - compiler-errors:rollup-8235xz5, r=compiler-errors
Rollup of 6 pull requests Successful merges: - #114959 (fix #113702 emit a proper diagnostic message for unstable lints passed from CLI) - #115011 (Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`)) - #115077 (Do not emit invalid suggestion in E0191 when spans overlap) - #115087 (Add disclaimer on size assertion macro) - #115090 (Always use `os-release` rather than `/lib` to detect `NixOS` (bootstrap)) - #115101 (triagebot: add dependency licensing pings) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
712d962cef
@ -597,7 +597,21 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !suggestions.is_empty() {
|
||||
suggestions.sort_by_key(|&(span, _)| span);
|
||||
// There are cases where one bound points to a span within another bound's span, like when
|
||||
// you have code like the following (#115019), so we skip providing a suggestion in those
|
||||
// cases to avoid having a malformed suggestion.
|
||||
//
|
||||
// pub struct Flatten<I> {
|
||||
// inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::core,
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// | ^^^^^^^^^^^^^^^^^^^^^
|
||||
// | |
|
||||
// | associated types `Item`, `IntoIter` must be specified
|
||||
// associated types `Item`, `IntoIter` must be specified
|
||||
// }
|
||||
let overlaps = suggestions.windows(2).any(|pair| pair[0].0.overlaps(pair[1].0));
|
||||
if !suggestions.is_empty() && !overlaps {
|
||||
err.multipart_suggestion(
|
||||
format!("specify the associated type{}", pluralize!(types_count)),
|
||||
suggestions,
|
||||
|
@ -289,6 +289,7 @@ fn default_body_is_unstable(
|
||||
&tcx.sess.parse_sess,
|
||||
feature,
|
||||
rustc_feature::GateIssue::Library(issue),
|
||||
false,
|
||||
);
|
||||
|
||||
err.emit();
|
||||
|
@ -29,6 +29,18 @@ pub use {idx::Idx, slice::IndexSlice, vec::IndexVec};
|
||||
pub use rustc_macros::newtype_index;
|
||||
|
||||
/// Type size assertion. The first argument is a type and the second argument is its expected size.
|
||||
///
|
||||
/// <div class="warning">
|
||||
///
|
||||
/// Emitting hard errors from size assertions like this is generally not
|
||||
/// recommended, especially in libraries, because they can cause build failures if the layout
|
||||
/// algorithm or dependencies change. Here in rustc we control the toolchain and layout algorithm,
|
||||
/// so the former is not a problem. For the latter we have a lockfile as rustc is an application and
|
||||
/// precompiled library.
|
||||
///
|
||||
/// Short version: Don't copy this macro into your own code. Use a `#[test]` instead.
|
||||
///
|
||||
/// </div>
|
||||
#[macro_export]
|
||||
macro_rules! static_assert_size {
|
||||
($ty:ty, $size:expr) => {
|
||||
|
@ -966,6 +966,14 @@ pub trait LintContext: Sized {
|
||||
Applicability::MachineApplicable
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::AssociatedConstElidedLifetime { elided, span } => {
|
||||
db.span_suggestion_verbose(
|
||||
if elided { span.shrink_to_hi() } else { span },
|
||||
"use the `'static` lifetime",
|
||||
if elided { "'static " } else { "'static" },
|
||||
Applicability::MachineApplicable
|
||||
);
|
||||
}
|
||||
}
|
||||
// Rewrap `db`, and pass control to the user.
|
||||
decorate(db)
|
||||
|
@ -12,7 +12,7 @@ use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{DecorateLint, DiagnosticBuilder, DiagnosticMessage, MultiSpan};
|
||||
use rustc_feature::Features;
|
||||
use rustc_feature::{Features, GateIssue};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::HirId;
|
||||
@ -24,12 +24,14 @@ use rustc_middle::lint::{
|
||||
};
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{RegisteredTools, TyCtxt};
|
||||
use rustc_session::lint::builtin::{RENAMED_AND_REMOVED_LINTS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES};
|
||||
use rustc_session::lint::{
|
||||
builtin::{self, FORBIDDEN_LINT_GROUPS, SINGLE_USE_LIFETIMES, UNFULFILLED_LINT_EXPECTATIONS},
|
||||
builtin::{
|
||||
self, FORBIDDEN_LINT_GROUPS, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES,
|
||||
UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES,
|
||||
},
|
||||
Level, Lint, LintExpectationId, LintId,
|
||||
};
|
||||
use rustc_session::parse::{add_feature_diagnostics, feature_err};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
@ -566,7 +568,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if self.check_gated_lint(id, DUMMY_SP) {
|
||||
if self.check_gated_lint(id, DUMMY_SP, true) {
|
||||
let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
|
||||
self.insert(id, (level, src));
|
||||
}
|
||||
@ -837,7 +839,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
reason,
|
||||
};
|
||||
for &id in *ids {
|
||||
if self.check_gated_lint(id, attr.span) {
|
||||
if self.check_gated_lint(id, attr.span, false) {
|
||||
self.insert_spec(id, (level, src));
|
||||
}
|
||||
}
|
||||
@ -854,7 +856,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
reason,
|
||||
};
|
||||
for &id in ids {
|
||||
if self.check_gated_lint(id, attr.span) {
|
||||
if self.check_gated_lint(id, attr.span, false) {
|
||||
self.insert_spec(id, (level, src));
|
||||
}
|
||||
}
|
||||
@ -955,7 +957,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
reason,
|
||||
};
|
||||
for &id in ids {
|
||||
if self.check_gated_lint(id, attr.span) {
|
||||
if self.check_gated_lint(id, attr.span, false) {
|
||||
self.insert_spec(id, (level, src));
|
||||
}
|
||||
}
|
||||
@ -1000,7 +1002,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
// FIXME only emit this once for each attribute, instead of repeating it 4 times for
|
||||
// pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
|
||||
#[track_caller]
|
||||
fn check_gated_lint(&self, lint_id: LintId, span: Span) -> bool {
|
||||
fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) -> bool {
|
||||
if let Some(feature) = lint_id.lint.feature_gate {
|
||||
if !self.features.enabled(feature) {
|
||||
let lint = builtin::UNKNOWN_LINTS;
|
||||
@ -1015,7 +1017,13 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
|lint| {
|
||||
lint.set_arg("name", lint_id.lint.name_lower());
|
||||
lint.note(fluent::lint_note);
|
||||
add_feature_diagnostics(lint, &self.sess.parse_sess, feature);
|
||||
rustc_session::parse::add_feature_diagnostics_for_issue(
|
||||
lint,
|
||||
&self.sess.parse_sess,
|
||||
feature,
|
||||
GateIssue::Language,
|
||||
lint_from_cli,
|
||||
);
|
||||
lint
|
||||
},
|
||||
);
|
||||
|
@ -3376,6 +3376,7 @@ declare_lint_pass! {
|
||||
DEPRECATED_IN_FUTURE,
|
||||
DEPRECATED_WHERE_CLAUSE_LOCATION,
|
||||
DUPLICATE_MACRO_ATTRIBUTES,
|
||||
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
|
||||
ELIDED_LIFETIMES_IN_PATHS,
|
||||
EXPORTED_PRIVATE_DEPENDENCIES,
|
||||
FFI_UNWIND_CALLS,
|
||||
@ -4527,3 +4528,44 @@ declare_lint! {
|
||||
reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>",
|
||||
};
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `elided_lifetimes_in_associated_constant` lint detects elided lifetimes
|
||||
/// that were erroneously allowed in associated constants.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(elided_lifetimes_in_associated_constant)]
|
||||
///
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Foo {
|
||||
/// const STR: &str = "hello, world";
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Previous version of Rust
|
||||
///
|
||||
/// Implicit static-in-const behavior was decided [against] for associated
|
||||
/// constants because of ambiguity. This, however, regressed and the compiler
|
||||
/// erroneously treats elided lifetimes in associated constants as lifetime
|
||||
/// parameters on the impl.
|
||||
///
|
||||
/// This is a [future-incompatible] lint to transition this to a
|
||||
/// hard error in the future.
|
||||
///
|
||||
/// [against]: https://github.com/rust-lang/rust/issues/38831
|
||||
/// [future-incompatible]: ../index.md#future-incompatible-lints
|
||||
pub ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
|
||||
Warn,
|
||||
"elided lifetimes cannot be used in associated constants in impls",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reason: FutureIncompatibilityReason::FutureReleaseError,
|
||||
reference: "issue #115010 <https://github.com/rust-lang/rust/issues/115010>",
|
||||
};
|
||||
}
|
||||
|
@ -573,6 +573,10 @@ pub enum BuiltinLintDiagnostics {
|
||||
/// The span of the unnecessarily-qualified path to remove.
|
||||
removal_span: Span,
|
||||
},
|
||||
AssociatedConstElidedLifetime {
|
||||
elided: bool,
|
||||
span: Span,
|
||||
},
|
||||
}
|
||||
|
||||
/// Lints that are buffered up early on in the `Session` before the
|
||||
|
@ -311,6 +311,10 @@ enum LifetimeRibKind {
|
||||
/// error on default object bounds (e.g., `Box<dyn Foo>`).
|
||||
AnonymousReportError,
|
||||
|
||||
/// Resolves elided lifetimes to `'static`, but gives a warning that this behavior
|
||||
/// is a bug and will be reverted soon.
|
||||
AnonymousWarnToStatic(NodeId),
|
||||
|
||||
/// Signal we cannot find which should be the anonymous lifetime.
|
||||
ElisionFailure,
|
||||
|
||||
@ -1148,6 +1152,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
||||
}
|
||||
LifetimeRibKind::AnonymousCreateParameter { .. }
|
||||
| LifetimeRibKind::AnonymousReportError
|
||||
| LifetimeRibKind::AnonymousWarnToStatic(_)
|
||||
| LifetimeRibKind::Elided(_)
|
||||
| LifetimeRibKind::ElisionFailure
|
||||
| LifetimeRibKind::ConcreteAnonConst(_)
|
||||
@ -1515,6 +1520,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
// lifetime would be illegal.
|
||||
LifetimeRibKind::Item
|
||||
| LifetimeRibKind::AnonymousReportError
|
||||
| LifetimeRibKind::AnonymousWarnToStatic(_)
|
||||
| LifetimeRibKind::ElisionFailure => Some(LifetimeUseSet::Many),
|
||||
// An anonymous lifetime is legal here, and bound to the right
|
||||
// place, go ahead.
|
||||
@ -1576,7 +1582,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
| LifetimeRibKind::Elided(_)
|
||||
| LifetimeRibKind::Generics { .. }
|
||||
| LifetimeRibKind::ElisionFailure
|
||||
| LifetimeRibKind::AnonymousReportError => {}
|
||||
| LifetimeRibKind::AnonymousReportError
|
||||
| LifetimeRibKind::AnonymousWarnToStatic(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1616,6 +1623,25 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
self.record_lifetime_res(lifetime.id, res, elision_candidate);
|
||||
return;
|
||||
}
|
||||
LifetimeRibKind::AnonymousWarnToStatic(node_id) => {
|
||||
self.record_lifetime_res(lifetime.id, LifetimeRes::Static, elision_candidate);
|
||||
let msg = if elided {
|
||||
"`&` without an explicit lifetime name cannot be used here"
|
||||
} else {
|
||||
"`'_` cannot be used here"
|
||||
};
|
||||
self.r.lint_buffer.buffer_lint_with_diagnostic(
|
||||
lint::builtin::ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
|
||||
node_id,
|
||||
lifetime.ident.span,
|
||||
msg,
|
||||
lint::BuiltinLintDiagnostics::AssociatedConstElidedLifetime {
|
||||
elided,
|
||||
span: lifetime.ident.span,
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
LifetimeRibKind::AnonymousReportError => {
|
||||
let (msg, note) = if elided {
|
||||
(
|
||||
@ -1811,7 +1837,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
//
|
||||
// impl Foo for std::cell::Ref<u32> // note lack of '_
|
||||
// async fn foo(_: std::cell::Ref<u32>) { ... }
|
||||
LifetimeRibKind::AnonymousCreateParameter { report_in_path: true, .. } => {
|
||||
LifetimeRibKind::AnonymousCreateParameter { report_in_path: true, .. }
|
||||
| LifetimeRibKind::AnonymousWarnToStatic(_) => {
|
||||
let sess = self.r.tcx.sess;
|
||||
let mut err = rustc_errors::struct_span_err!(
|
||||
sess,
|
||||
@ -2898,7 +2925,6 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
match &item.kind {
|
||||
AssocItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => {
|
||||
debug!("resolve_implementation AssocItemKind::Const");
|
||||
|
||||
self.with_generic_param_rib(
|
||||
&generics.params,
|
||||
RibKind::AssocItem,
|
||||
@ -2908,28 +2934,33 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
kind: LifetimeBinderKind::ConstItem,
|
||||
},
|
||||
|this| {
|
||||
// If this is a trait impl, ensure the const
|
||||
// exists in trait
|
||||
this.check_trait_item(
|
||||
item.id,
|
||||
item.ident,
|
||||
&item.kind,
|
||||
ValueNS,
|
||||
item.span,
|
||||
seen_trait_items,
|
||||
|i, s, c| ConstNotMemberOfTrait(i, s, c),
|
||||
);
|
||||
this.with_lifetime_rib(
|
||||
LifetimeRibKind::AnonymousWarnToStatic(item.id),
|
||||
|this| {
|
||||
// If this is a trait impl, ensure the const
|
||||
// exists in trait
|
||||
this.check_trait_item(
|
||||
item.id,
|
||||
item.ident,
|
||||
&item.kind,
|
||||
ValueNS,
|
||||
item.span,
|
||||
seen_trait_items,
|
||||
|i, s, c| ConstNotMemberOfTrait(i, s, c),
|
||||
);
|
||||
|
||||
this.visit_generics(generics);
|
||||
this.visit_ty(ty);
|
||||
if let Some(expr) = expr {
|
||||
// We allow arbitrary const expressions inside of associated consts,
|
||||
// even if they are potentially not const evaluatable.
|
||||
//
|
||||
// Type parameters can already be used and as associated consts are
|
||||
// not used as part of the type system, this is far less surprising.
|
||||
this.resolve_const_body(expr, None);
|
||||
}
|
||||
this.visit_generics(generics);
|
||||
this.visit_ty(ty);
|
||||
if let Some(expr) = expr {
|
||||
// We allow arbitrary const expressions inside of associated consts,
|
||||
// even if they are potentially not const evaluatable.
|
||||
//
|
||||
// Type parameters can already be used and as associated consts are
|
||||
// not used as part of the type system, this is far less surprising.
|
||||
this.resolve_const_body(expr, None);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible
|
||||
session_cgu_not_recorded =
|
||||
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded
|
||||
|
||||
session_cli_feature_diagnostic_help =
|
||||
add `-Zcrate-attr="feature({$feature})"` to the command-line options to enable
|
||||
|
||||
session_crate_name_does_not_match = `--crate-name` and `#[crate_name]` are required to match, but `{$s}` != `{$name}`
|
||||
|
||||
session_crate_name_empty = crate name must not be empty
|
||||
|
@ -57,6 +57,12 @@ pub struct FeatureDiagnosticHelp {
|
||||
pub feature: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(session_cli_feature_diagnostic_help)]
|
||||
pub struct CliFeatureDiagnosticHelp {
|
||||
pub feature: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_not_circumvent_feature)]
|
||||
pub struct NotCircumventFeature;
|
||||
|
@ -2,7 +2,9 @@
|
||||
//! It also serves as an input to the parser itself.
|
||||
|
||||
use crate::config::CheckCfg;
|
||||
use crate::errors::{FeatureDiagnosticForIssue, FeatureDiagnosticHelp, FeatureGateError};
|
||||
use crate::errors::{
|
||||
CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp, FeatureGateError,
|
||||
};
|
||||
use crate::lint::{
|
||||
builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId,
|
||||
};
|
||||
@ -110,7 +112,7 @@ pub fn feature_err_issue(
|
||||
}
|
||||
|
||||
let mut err = sess.create_err(FeatureGateError { span, explain: explain.into() });
|
||||
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue);
|
||||
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
|
||||
err
|
||||
}
|
||||
|
||||
@ -139,7 +141,7 @@ pub fn feature_warn_issue(
|
||||
explain: &'static str,
|
||||
) {
|
||||
let mut err = sess.span_diagnostic.struct_span_warn(span, explain);
|
||||
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue);
|
||||
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
|
||||
|
||||
// Decorate this as a future-incompatibility lint as in rustc_middle::lint::struct_lint_level
|
||||
let lint = UNSTABLE_SYNTAX_PRE_EXPANSION;
|
||||
@ -158,7 +160,7 @@ pub fn feature_warn_issue(
|
||||
|
||||
/// Adds the diagnostics for a feature to an existing error.
|
||||
pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &ParseSess, feature: Symbol) {
|
||||
add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language);
|
||||
add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false);
|
||||
}
|
||||
|
||||
/// Adds the diagnostics for a feature to an existing error.
|
||||
@ -171,6 +173,7 @@ pub fn add_feature_diagnostics_for_issue(
|
||||
sess: &ParseSess,
|
||||
feature: Symbol,
|
||||
issue: GateIssue,
|
||||
feature_from_cli: bool,
|
||||
) {
|
||||
if let Some(n) = find_feature_issue(feature, issue) {
|
||||
err.subdiagnostic(FeatureDiagnosticForIssue { n });
|
||||
@ -178,7 +181,11 @@ pub fn add_feature_diagnostics_for_issue(
|
||||
|
||||
// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
|
||||
if sess.unstable_features.is_nightly_build() {
|
||||
err.subdiagnostic(FeatureDiagnosticHelp { feature });
|
||||
if feature_from_cli {
|
||||
err.subdiagnostic(CliFeatureDiagnosticHelp { feature });
|
||||
} else {
|
||||
err.subdiagnostic(FeatureDiagnosticHelp { feature });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,7 +644,7 @@ class RustBuild(object):
|
||||
return False
|
||||
|
||||
# If the user has asked binaries to be patched for Nix, then
|
||||
# don't check for NixOS or `/lib`.
|
||||
# don't check for NixOS.
|
||||
if self.get_toml("patch-binaries-for-nix", "build") == "true":
|
||||
return True
|
||||
|
||||
@ -652,14 +652,9 @@ class RustBuild(object):
|
||||
# The latter one does not exist on NixOS when using tmpfs as root.
|
||||
try:
|
||||
with open("/etc/os-release", "r") as f:
|
||||
if not any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f):
|
||||
return False
|
||||
return any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f)
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
if os.path.exists("/lib"):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
answer = self._should_fix_bins_and_dylibs = get_answer()
|
||||
if answer:
|
||||
|
@ -105,7 +105,7 @@ impl Config {
|
||||
matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"")
|
||||
}),
|
||||
};
|
||||
is_nixos && !Path::new("/lib").exists()
|
||||
is_nixos
|
||||
});
|
||||
if val {
|
||||
eprintln!("info: You seem to be using Nix.");
|
||||
|
@ -601,7 +601,7 @@ pub struct RustAnalyzer {
|
||||
}
|
||||
|
||||
impl RustAnalyzer {
|
||||
pub const ALLOW_FEATURES: &str =
|
||||
pub const ALLOW_FEATURES: &'static str =
|
||||
"proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink";
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ impl FixtureWithProjectMeta {
|
||||
}
|
||||
|
||||
impl MiniCore {
|
||||
const RAW_SOURCE: &str = include_str!("./minicore.rs");
|
||||
const RAW_SOURCE: &'static str = include_str!("./minicore.rs");
|
||||
|
||||
fn has_flag(&self, flag: &str) -> bool {
|
||||
self.activated_flags.iter().any(|it| it == flag)
|
||||
|
@ -5,6 +5,8 @@ trait Trait {
|
||||
impl Trait for () {
|
||||
const ASSOC: &dyn Fn(_) = 1i32;
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||
//~| WARN `&` without an explicit lifetime name cannot be used here
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,9 +1,23 @@
|
||||
warning: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:18
|
||||
|
|
||||
LL | const ASSOC: &dyn Fn(_) = 1i32;
|
||||
| ^
|
||||
|
|
||||
= 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 #115010 <https://github.com/rust-lang/rust/issues/115010>
|
||||
= note: `#[warn(elided_lifetimes_in_associated_constant)]` on by default
|
||||
help: use the `'static` lifetime
|
||||
|
|
||||
LL | const ASSOC: &'static dyn Fn(_) = 1i32;
|
||||
| +++++++
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||
--> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:26
|
||||
|
|
||||
LL | const ASSOC: &dyn Fn(_) = 1i32;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0121`.
|
||||
|
@ -0,0 +1,12 @@
|
||||
#![allow(bare_trait_objects)]
|
||||
#![feature(associated_type_bounds)]
|
||||
trait Item {
|
||||
type Core;
|
||||
}
|
||||
pub struct Flatten<I> {
|
||||
inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core,
|
||||
//~^ ERROR E0191
|
||||
//~| ERROR E0223
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,24 @@
|
||||
error[E0191]: the value of the associated types `IntoIter` (from trait `IntoIterator`), `IntoIter` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`) must be specified
|
||||
--> $DIR/overlaping-bound-suggestion.rs:7:13
|
||||
|
|
||||
LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | associated types `Item`, `IntoIter` must be specified
|
||||
| associated types `Item`, `IntoIter` must be specified
|
||||
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/overlaping-bound-suggestion.rs:7:13
|
||||
|
|
||||
LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: if there were a trait named `Example` with associated type `IntoIterator` implemented for `(dyn IntoIterator + 'static)`, you could use the fully-qualified path
|
||||
|
|
||||
LL | inner: <<(dyn IntoIterator + 'static) as Example>::IntoIterator as Item>::Core,
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0191, E0223.
|
||||
For more information about an error, try `rustc --explain E0191`.
|
19
tests/ui/consts/assoc-const-elided-lifetime.rs
Normal file
19
tests/ui/consts/assoc-const-elided-lifetime.rs
Normal file
@ -0,0 +1,19 @@
|
||||
#![deny(elided_lifetimes_in_associated_constant)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
struct Foo<'a> {
|
||||
x: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl<'a> Foo<'a> {
|
||||
const FOO: Foo<'_> = Foo { x: PhantomData::<&()> };
|
||||
//~^ ERROR `'_` cannot be used here
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
||||
const BAR: &() = &();
|
||||
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
}
|
||||
|
||||
fn main() {}
|
33
tests/ui/consts/assoc-const-elided-lifetime.stderr
Normal file
33
tests/ui/consts/assoc-const-elided-lifetime.stderr
Normal file
@ -0,0 +1,33 @@
|
||||
error: `'_` cannot be used here
|
||||
--> $DIR/assoc-const-elided-lifetime.rs:10:20
|
||||
|
|
||||
LL | const FOO: Foo<'_> = Foo { x: PhantomData::<&()> };
|
||||
| ^^
|
||||
|
|
||||
= 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 #115010 <https://github.com/rust-lang/rust/issues/115010>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/assoc-const-elided-lifetime.rs:1:9
|
||||
|
|
||||
LL | #![deny(elided_lifetimes_in_associated_constant)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: use the `'static` lifetime
|
||||
|
|
||||
LL | const FOO: Foo<'static> = Foo { x: PhantomData::<&()> };
|
||||
| ~~~~~~~
|
||||
|
||||
error: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/assoc-const-elided-lifetime.rs:14:16
|
||||
|
|
||||
LL | const BAR: &() = &();
|
||||
| ^
|
||||
|
|
||||
= 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 #115010 <https://github.com/rust-lang/rust/issues/115010>
|
||||
help: use the `'static` lifetime
|
||||
|
|
||||
LL | const BAR: &'static () = &();
|
||||
| +++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -1,18 +1,18 @@
|
||||
error: unknown lint: `test_unstable_lint`
|
||||
|
|
||||
= note: the `test_unstable_lint` lint is unstable
|
||||
= help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
|
||||
= help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable
|
||||
= note: requested on the command line with `-D unknown-lints`
|
||||
|
||||
error: unknown lint: `test_unstable_lint`
|
||||
|
|
||||
= note: the `test_unstable_lint` lint is unstable
|
||||
= help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
|
||||
= help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable
|
||||
|
||||
error: unknown lint: `test_unstable_lint`
|
||||
|
|
||||
= note: the `test_unstable_lint` lint is unstable
|
||||
= help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
|
||||
= help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
warning: unknown lint: `test_unstable_lint`
|
||||
|
|
||||
= note: the `test_unstable_lint` lint is unstable
|
||||
= help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
|
||||
= help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable
|
||||
= note: requested on the command line with `-W unknown-lints`
|
||||
|
||||
warning: unknown lint: `test_unstable_lint`
|
||||
|
|
||||
= note: the `test_unstable_lint` lint is unstable
|
||||
= help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
|
||||
= help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable
|
||||
|
||||
warning: unknown lint: `test_unstable_lint`
|
||||
|
|
||||
= note: the `test_unstable_lint` lint is unstable
|
||||
= help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
|
||||
= help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
@ -470,6 +470,10 @@ Otherwise, you can ignore this comment.
|
||||
[mentions."src/tools/x"]
|
||||
message = "`src/tools/x` was changed. Bump version of Cargo.toml in `src/tools/x` so tidy will suggest installing the new version."
|
||||
|
||||
[mentions."src/tools/tidy/src/deps.rs"]
|
||||
message = "Third-party dependency whitelist may have been modified! You must ensure that any new dependencies have compatible licenses before merging."
|
||||
cc = ["@davidtwco", "@wesleywiser"]
|
||||
|
||||
[mentions."src/bootstrap/defaults/config.compiler.toml"]
|
||||
message = "This PR changes src/bootstrap/defaults/config.compiler.toml. If appropriate, please also update `config.codegen.toml` so the defaults are in sync."
|
||||
[mentions."src/bootstrap/defaults/config.codegen.toml"]
|
||||
|
Loading…
Reference in New Issue
Block a user