1
Fork 0

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:
bors 2023-08-22 16:16:32 +00:00
commit 712d962cef
24 changed files with 296 additions and 57 deletions

View file

@ -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( err.multipart_suggestion(
format!("specify the associated type{}", pluralize!(types_count)), format!("specify the associated type{}", pluralize!(types_count)),
suggestions, suggestions,

View file

@ -289,6 +289,7 @@ fn default_body_is_unstable(
&tcx.sess.parse_sess, &tcx.sess.parse_sess,
feature, feature,
rustc_feature::GateIssue::Library(issue), rustc_feature::GateIssue::Library(issue),
false,
); );
err.emit(); err.emit();

View file

@ -29,6 +29,18 @@ pub use {idx::Idx, slice::IndexSlice, vec::IndexVec};
pub use rustc_macros::newtype_index; pub use rustc_macros::newtype_index;
/// Type size assertion. The first argument is a type and the second argument is its expected size. /// 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_export]
macro_rules! static_assert_size { macro_rules! static_assert_size {
($ty:ty, $size:expr) => { ($ty:ty, $size:expr) => {

View file

@ -966,6 +966,14 @@ pub trait LintContext: Sized {
Applicability::MachineApplicable 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. // Rewrap `db`, and pass control to the user.
decorate(db) decorate(db)

View file

@ -12,7 +12,7 @@ use rustc_ast as ast;
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{DecorateLint, DiagnosticBuilder, DiagnosticMessage, MultiSpan}; use rustc_errors::{DecorateLint, DiagnosticBuilder, DiagnosticMessage, MultiSpan};
use rustc_feature::Features; use rustc_feature::{Features, GateIssue};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::HirId; use rustc_hir::HirId;
@ -24,12 +24,14 @@ use rustc_middle::lint::{
}; };
use rustc_middle::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::ty::{RegisteredTools, TyCtxt}; use rustc_middle::ty::{RegisteredTools, TyCtxt};
use rustc_session::lint::builtin::{RENAMED_AND_REMOVED_LINTS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES};
use rustc_session::lint::{ 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, 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_session::Session;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
@ -566,7 +568,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
continue; 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); let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
self.insert(id, (level, src)); self.insert(id, (level, src));
} }
@ -837,7 +839,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
reason, reason,
}; };
for &id in *ids { 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)); self.insert_spec(id, (level, src));
} }
} }
@ -854,7 +856,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
reason, reason,
}; };
for &id in ids { 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)); self.insert_spec(id, (level, src));
} }
} }
@ -955,7 +957,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
reason, reason,
}; };
for &id in ids { 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)); 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 // 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`. // pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
#[track_caller] #[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 let Some(feature) = lint_id.lint.feature_gate {
if !self.features.enabled(feature) { if !self.features.enabled(feature) {
let lint = builtin::UNKNOWN_LINTS; let lint = builtin::UNKNOWN_LINTS;
@ -1015,7 +1017,13 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|lint| { |lint| {
lint.set_arg("name", lint_id.lint.name_lower()); lint.set_arg("name", lint_id.lint.name_lower());
lint.note(fluent::lint_note); 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 lint
}, },
); );

View file

@ -3376,6 +3376,7 @@ declare_lint_pass! {
DEPRECATED_IN_FUTURE, DEPRECATED_IN_FUTURE,
DEPRECATED_WHERE_CLAUSE_LOCATION, DEPRECATED_WHERE_CLAUSE_LOCATION,
DUPLICATE_MACRO_ATTRIBUTES, DUPLICATE_MACRO_ATTRIBUTES,
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
ELIDED_LIFETIMES_IN_PATHS, ELIDED_LIFETIMES_IN_PATHS,
EXPORTED_PRIVATE_DEPENDENCIES, EXPORTED_PRIVATE_DEPENDENCIES,
FFI_UNWIND_CALLS, FFI_UNWIND_CALLS,
@ -4527,3 +4528,44 @@ declare_lint! {
reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>", 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>",
};
}

View file

@ -573,6 +573,10 @@ pub enum BuiltinLintDiagnostics {
/// The span of the unnecessarily-qualified path to remove. /// The span of the unnecessarily-qualified path to remove.
removal_span: Span, removal_span: Span,
}, },
AssociatedConstElidedLifetime {
elided: bool,
span: Span,
},
} }
/// Lints that are buffered up early on in the `Session` before the /// Lints that are buffered up early on in the `Session` before the

View file

@ -311,6 +311,10 @@ enum LifetimeRibKind {
/// error on default object bounds (e.g., `Box<dyn Foo>`). /// error on default object bounds (e.g., `Box<dyn Foo>`).
AnonymousReportError, 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. /// Signal we cannot find which should be the anonymous lifetime.
ElisionFailure, ElisionFailure,
@ -1148,6 +1152,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
} }
LifetimeRibKind::AnonymousCreateParameter { .. } LifetimeRibKind::AnonymousCreateParameter { .. }
| LifetimeRibKind::AnonymousReportError | LifetimeRibKind::AnonymousReportError
| LifetimeRibKind::AnonymousWarnToStatic(_)
| LifetimeRibKind::Elided(_) | LifetimeRibKind::Elided(_)
| LifetimeRibKind::ElisionFailure | LifetimeRibKind::ElisionFailure
| LifetimeRibKind::ConcreteAnonConst(_) | LifetimeRibKind::ConcreteAnonConst(_)
@ -1515,6 +1520,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
// lifetime would be illegal. // lifetime would be illegal.
LifetimeRibKind::Item LifetimeRibKind::Item
| LifetimeRibKind::AnonymousReportError | LifetimeRibKind::AnonymousReportError
| LifetimeRibKind::AnonymousWarnToStatic(_)
| LifetimeRibKind::ElisionFailure => Some(LifetimeUseSet::Many), | LifetimeRibKind::ElisionFailure => Some(LifetimeUseSet::Many),
// An anonymous lifetime is legal here, and bound to the right // An anonymous lifetime is legal here, and bound to the right
// place, go ahead. // place, go ahead.
@ -1576,7 +1582,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
| LifetimeRibKind::Elided(_) | LifetimeRibKind::Elided(_)
| LifetimeRibKind::Generics { .. } | LifetimeRibKind::Generics { .. }
| LifetimeRibKind::ElisionFailure | 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); self.record_lifetime_res(lifetime.id, res, elision_candidate);
return; 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 => { LifetimeRibKind::AnonymousReportError => {
let (msg, note) = if elided { 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 '_ // impl Foo for std::cell::Ref<u32> // note lack of '_
// async fn foo(_: std::cell::Ref<u32>) { ... } // 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 sess = self.r.tcx.sess;
let mut err = rustc_errors::struct_span_err!( let mut err = rustc_errors::struct_span_err!(
sess, sess,
@ -2898,7 +2925,6 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
match &item.kind { match &item.kind {
AssocItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => { AssocItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => {
debug!("resolve_implementation AssocItemKind::Const"); debug!("resolve_implementation AssocItemKind::Const");
self.with_generic_param_rib( self.with_generic_param_rib(
&generics.params, &generics.params,
RibKind::AssocItem, RibKind::AssocItem,
@ -2908,28 +2934,33 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
kind: LifetimeBinderKind::ConstItem, kind: LifetimeBinderKind::ConstItem,
}, },
|this| { |this| {
// If this is a trait impl, ensure the const this.with_lifetime_rib(
// exists in trait LifetimeRibKind::AnonymousWarnToStatic(item.id),
this.check_trait_item( |this| {
item.id, // If this is a trait impl, ensure the const
item.ident, // exists in trait
&item.kind, this.check_trait_item(
ValueNS, item.id,
item.span, item.ident,
seen_trait_items, &item.kind,
|i, s, c| ConstNotMemberOfTrait(i, s, c), ValueNS,
); item.span,
seen_trait_items,
|i, s, c| ConstNotMemberOfTrait(i, s, c),
);
this.visit_generics(generics); this.visit_generics(generics);
this.visit_ty(ty); this.visit_ty(ty);
if let Some(expr) = expr { if let Some(expr) = expr {
// We allow arbitrary const expressions inside of associated consts, // We allow arbitrary const expressions inside of associated consts,
// even if they are potentially not const evaluatable. // even if they are potentially not const evaluatable.
// //
// Type parameters can already be used and as associated consts are // Type parameters can already be used and as associated consts are
// not used as part of the type system, this is far less surprising. // not used as part of the type system, this is far less surprising.
this.resolve_const_body(expr, None); this.resolve_const_body(expr, None);
} }
},
);
}, },
); );
} }

View file

@ -8,6 +8,9 @@ session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible
session_cgu_not_recorded = session_cgu_not_recorded =
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was 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_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 session_crate_name_empty = crate name must not be empty

View file

@ -57,6 +57,12 @@ pub struct FeatureDiagnosticHelp {
pub feature: Symbol, pub feature: Symbol,
} }
#[derive(Subdiagnostic)]
#[help(session_cli_feature_diagnostic_help)]
pub struct CliFeatureDiagnosticHelp {
pub feature: Symbol,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(session_not_circumvent_feature)] #[diag(session_not_circumvent_feature)]
pub struct NotCircumventFeature; pub struct NotCircumventFeature;

View file

@ -2,7 +2,9 @@
//! It also serves as an input to the parser itself. //! It also serves as an input to the parser itself.
use crate::config::CheckCfg; use crate::config::CheckCfg;
use crate::errors::{FeatureDiagnosticForIssue, FeatureDiagnosticHelp, FeatureGateError}; use crate::errors::{
CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp, FeatureGateError,
};
use crate::lint::{ use crate::lint::{
builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId, 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() }); 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 err
} }
@ -139,7 +141,7 @@ pub fn feature_warn_issue(
explain: &'static str, explain: &'static str,
) { ) {
let mut err = sess.span_diagnostic.struct_span_warn(span, explain); 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 // Decorate this as a future-incompatibility lint as in rustc_middle::lint::struct_lint_level
let lint = UNSTABLE_SYNTAX_PRE_EXPANSION; 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. /// Adds the diagnostics for a feature to an existing error.
pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &ParseSess, feature: Symbol) { 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. /// Adds the diagnostics for a feature to an existing error.
@ -171,6 +173,7 @@ pub fn add_feature_diagnostics_for_issue(
sess: &ParseSess, sess: &ParseSess,
feature: Symbol, feature: Symbol,
issue: GateIssue, issue: GateIssue,
feature_from_cli: bool,
) { ) {
if let Some(n) = find_feature_issue(feature, issue) { if let Some(n) = find_feature_issue(feature, issue) {
err.subdiagnostic(FeatureDiagnosticForIssue { n }); 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 // #23973: do not suggest `#![feature(...)]` if we are in beta/stable
if sess.unstable_features.is_nightly_build() { if sess.unstable_features.is_nightly_build() {
err.subdiagnostic(FeatureDiagnosticHelp { feature }); if feature_from_cli {
err.subdiagnostic(CliFeatureDiagnosticHelp { feature });
} else {
err.subdiagnostic(FeatureDiagnosticHelp { feature });
}
} }
} }

View file

@ -644,7 +644,7 @@ class RustBuild(object):
return False return False
# If the user has asked binaries to be patched for Nix, then # 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": if self.get_toml("patch-binaries-for-nix", "build") == "true":
return True return True
@ -652,14 +652,9 @@ class RustBuild(object):
# The latter one does not exist on NixOS when using tmpfs as root. # The latter one does not exist on NixOS when using tmpfs as root.
try: try:
with open("/etc/os-release", "r") as f: 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 any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f)
return False
except FileNotFoundError: except FileNotFoundError:
return False return False
if os.path.exists("/lib"):
return False
return True
answer = self._should_fix_bins_and_dylibs = get_answer() answer = self._should_fix_bins_and_dylibs = get_answer()
if answer: if answer:

View file

@ -105,7 +105,7 @@ impl Config {
matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"") matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"")
}), }),
}; };
is_nixos && !Path::new("/lib").exists() is_nixos
}); });
if val { if val {
eprintln!("info: You seem to be using Nix."); eprintln!("info: You seem to be using Nix.");

View file

@ -601,7 +601,7 @@ pub struct RustAnalyzer {
} }
impl 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"; "proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink";
} }

View file

@ -313,7 +313,7 @@ impl FixtureWithProjectMeta {
} }
impl MiniCore { 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 { fn has_flag(&self, flag: &str) -> bool {
self.activated_flags.iter().any(|it| it == flag) self.activated_flags.iter().any(|it| it == flag)

View file

@ -5,6 +5,8 @@ trait Trait {
impl Trait for () { impl Trait for () {
const ASSOC: &dyn Fn(_) = 1i32; const ASSOC: &dyn Fn(_) = 1i32;
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants //~^ 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() {} fn main() {}

View file

@ -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 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 --> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:26
| |
LL | const ASSOC: &dyn Fn(_) = 1i32; LL | const ASSOC: &dyn Fn(_) = 1i32;
| ^ not allowed in type signatures | ^ 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`. For more information about this error, try `rustc --explain E0121`.

View file

@ -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() {}

View file

@ -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`.

View 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() {}

View 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

View file

@ -1,18 +1,18 @@
error: unknown lint: `test_unstable_lint` error: unknown lint: `test_unstable_lint`
| |
= note: the `test_unstable_lint` lint is unstable = 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` = note: requested on the command line with `-D unknown-lints`
error: unknown lint: `test_unstable_lint` error: unknown lint: `test_unstable_lint`
| |
= note: the `test_unstable_lint` lint is unstable = 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` error: unknown lint: `test_unstable_lint`
| |
= note: the `test_unstable_lint` lint is unstable = 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 error: aborting due to 3 previous errors

View file

@ -1,18 +1,18 @@
warning: unknown lint: `test_unstable_lint` warning: unknown lint: `test_unstable_lint`
| |
= note: the `test_unstable_lint` lint is unstable = 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` = note: requested on the command line with `-W unknown-lints`
warning: unknown lint: `test_unstable_lint` warning: unknown lint: `test_unstable_lint`
| |
= note: the `test_unstable_lint` lint is unstable = 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` warning: unknown lint: `test_unstable_lint`
| |
= note: the `test_unstable_lint` lint is unstable = 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 warning: 3 warnings emitted

View file

@ -470,6 +470,10 @@ Otherwise, you can ignore this comment.
[mentions."src/tools/x"] [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." 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"] [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." 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"] [mentions."src/bootstrap/defaults/config.codegen.toml"]