Skip to content

Commit

Permalink
Auto merge of rust-lang#101225 - matthiaskrgr:rollup-9s1chas, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#100970 (Allow deriving multipart suggestions)
 - rust-lang#100984 (Reinstate preloading of some dll imports)
 - rust-lang#101011 (Use getentropy when possible on all Apple platforms)
 - rust-lang#101025 (Add tier-3 support for powerpc64 and riscv64 openbsd)
 - rust-lang#101049 (Remove span fatal from ast lowering)
 - rust-lang#101100 (Make call suggestions more general and more accurate)
 - rust-lang#101171 (Fix UB from misalignment and provenance widening in `std::sys::windows`)
 - rust-lang#101185 (Tweak `WellFormedLoc`s a bit)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Aug 31, 2022
2 parents 7f442f8 + 49ed325 commit 12e4fd0
Show file tree
Hide file tree
Showing 69 changed files with 1,639 additions and 922 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_ast_lowering/src/errors.rs
Expand Up @@ -327,3 +327,10 @@ pub struct ArbitraryExpressionInPattern {
#[primary_span]
pub span: Span,
}

#[derive(SessionDiagnostic, Clone, Copy)]
#[diag(ast_lowering::inclusive_range_with_no_end)]
pub struct InclusiveRangeWithNoEnd {
#[primary_span]
pub span: Span,
}
12 changes: 9 additions & 3 deletions compiler/rustc_ast_lowering/src/expr.rs
@@ -1,8 +1,8 @@
use super::errors::{
AsyncGeneratorsNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks,
BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignemnt,
GeneratorTooManyParameters, NotSupportedForLifetimeBinderAsyncClosure, RustcBoxAttributeError,
UnderscoreExprLhsAssign,
GeneratorTooManyParameters, InclusiveRangeWithNoEnd, NotSupportedForLifetimeBinderAsyncClosure,
RustcBoxAttributeError, UnderscoreExprLhsAssign,
};
use super::ResolverAstLoweringExt;
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
Expand Down Expand Up @@ -1264,7 +1264,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
(Some(..), Some(..), HalfOpen) => hir::LangItem::Range,
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
(Some(..), Some(..), Closed) => unreachable!(),
(_, None, Closed) => self.diagnostic().span_fatal(span, "inclusive range with no end"),
(start, None, Closed) => {
self.tcx.sess.emit_err(InclusiveRangeWithNoEnd { span });
match start {
Some(..) => hir::LangItem::RangeFrom,
None => hir::LangItem::RangeFull,
}
}
};

let fields = self.arena.alloc_from_iter(
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Expand Up @@ -36,6 +36,8 @@
#![feature(never_type)]
#![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl
Expand Up @@ -129,3 +129,5 @@ ast_lowering_not_supported_for_lifetime_binder_async_closure =
ast_lowering_arbitrary_expression_in_pattern =
arbitrary expressions aren't allowed in patterns
ast_lowering_inclusive_range_with_no_end = inclusive range with no end
17 changes: 5 additions & 12 deletions compiler/rustc_errors/src/diagnostic.rs
Expand Up @@ -686,19 +686,12 @@ impl Diagnostic {
suggestion: Vec<(Span, String)>,
applicability: Applicability,
) -> &mut Self {
assert!(!suggestion.is_empty());
self.push_suggestion(CodeSuggestion {
substitutions: vec![Substitution {
parts: suggestion
.into_iter()
.map(|(span, snippet)| SubstitutionPart { snippet, span })
.collect(),
}],
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
style: SuggestionStyle::CompletelyHidden,
self.multipart_suggestion_with_style(
msg,
suggestion,
applicability,
});
self
SuggestionStyle::CompletelyHidden,
)
}

/// Prints out a message with a suggested edit of the code.
Expand Down
19 changes: 15 additions & 4 deletions compiler/rustc_errors/src/lib.rs
Expand Up @@ -1249,9 +1249,13 @@ impl HandlerInner {
}

fn treat_err_as_bug(&self) -> bool {
self.flags
.treat_err_as_bug
.map_or(false, |c| self.err_count() + self.lint_err_count >= c.get())
self.flags.treat_err_as_bug.map_or(false, |c| {
self.err_count()
+ self.lint_err_count
+ self.delayed_span_bugs.len()
+ self.delayed_good_path_bugs.len()
>= c.get()
})
}

fn print_error_count(&mut self, registry: &Registry) {
Expand Down Expand Up @@ -1407,7 +1411,14 @@ impl HandlerInner {
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
// incrementing `err_count` by one, so we need to +1 the comparing.
// FIXME: Would be nice to increment err_count in a more coherent way.
if self.flags.treat_err_as_bug.map_or(false, |c| self.err_count() + 1 >= c.get()) {
if self.flags.treat_err_as_bug.map_or(false, |c| {
self.err_count()
+ self.lint_err_count
+ self.delayed_span_bugs.len()
+ self.delayed_good_path_bugs.len()
+ 1
>= c.get()
}) {
// FIXME: don't abort here if report_delayed_bugs is off
self.span_bug(sp, msg);
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_lint_defs/src/lib.rs
Expand Up @@ -41,7 +41,8 @@ macro_rules! pluralize {
/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion
/// to determine whether it should be automatically applied or if the user should be consulted
/// before applying the suggestion.
#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Hash, Encodable, Decodable, Serialize, Deserialize)]
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub enum Applicability {
/// The suggestion is definitely what the user intended, or maintains the exact meaning of the code.
/// This suggestion should be automatically applied.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_llvm/build.rs
Expand Up @@ -342,10 +342,10 @@ fn main() {
};

// RISC-V GCC erroneously requires libatomic for sub-word
// atomic operations. FreeBSD uses Clang as its system
// atomic operations. Some BSD uses Clang as its system
// compiler and provides no libatomic in its base system so
// does not want this.
if !target.contains("freebsd") && target.starts_with("riscv") {
if target.starts_with("riscv") && !target.contains("freebsd") && !target.contains("openbsd") {
println!("cargo:rustc-link-lib=atomic");
}

Expand Down

0 comments on commit 12e4fd0

Please sign in to comment.