Skip to content

Commit 12e4fd0

Browse files
committed
Auto merge of rust-lang#101225 - matthiaskrgr:rollup-9s1chas, r=matthiaskrgr
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
2 parents 7f442f8 + 49ed325 commit 12e4fd0

File tree

69 files changed

+1639
-922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1639
-922
lines changed

compiler/rustc_ast_lowering/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,10 @@ pub struct ArbitraryExpressionInPattern {
327327
#[primary_span]
328328
pub span: Span,
329329
}
330+
331+
#[derive(SessionDiagnostic, Clone, Copy)]
332+
#[diag(ast_lowering::inclusive_range_with_no_end)]
333+
pub struct InclusiveRangeWithNoEnd {
334+
#[primary_span]
335+
pub span: Span,
336+
}

compiler/rustc_ast_lowering/src/expr.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::errors::{
22
AsyncGeneratorsNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks,
33
BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignemnt,
4-
GeneratorTooManyParameters, NotSupportedForLifetimeBinderAsyncClosure, RustcBoxAttributeError,
5-
UnderscoreExprLhsAssign,
4+
GeneratorTooManyParameters, InclusiveRangeWithNoEnd, NotSupportedForLifetimeBinderAsyncClosure,
5+
RustcBoxAttributeError, UnderscoreExprLhsAssign,
66
};
77
use super::ResolverAstLoweringExt;
88
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
@@ -1264,7 +1264,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
12641264
(Some(..), Some(..), HalfOpen) => hir::LangItem::Range,
12651265
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
12661266
(Some(..), Some(..), Closed) => unreachable!(),
1267-
(_, None, Closed) => self.diagnostic().span_fatal(span, "inclusive range with no end"),
1267+
(start, None, Closed) => {
1268+
self.tcx.sess.emit_err(InclusiveRangeWithNoEnd { span });
1269+
match start {
1270+
Some(..) => hir::LangItem::RangeFrom,
1271+
None => hir::LangItem::RangeFull,
1272+
}
1273+
}
12681274
};
12691275

12701276
let fields = self.arena.alloc_from_iter(

compiler/rustc_ast_lowering/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#![feature(never_type)]
3737
#![recursion_limit = "256"]
3838
#![allow(rustc::potential_query_instability)]
39+
#![deny(rustc::untranslatable_diagnostic)]
40+
#![deny(rustc::diagnostic_outside_of_impl)]
3941

4042
#[macro_use]
4143
extern crate tracing;

compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,5 @@ ast_lowering_not_supported_for_lifetime_binder_async_closure =
129129
130130
ast_lowering_arbitrary_expression_in_pattern =
131131
arbitrary expressions aren't allowed in patterns
132+
133+
ast_lowering_inclusive_range_with_no_end = inclusive range with no end

compiler/rustc_errors/src/diagnostic.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -686,19 +686,12 @@ impl Diagnostic {
686686
suggestion: Vec<(Span, String)>,
687687
applicability: Applicability,
688688
) -> &mut Self {
689-
assert!(!suggestion.is_empty());
690-
self.push_suggestion(CodeSuggestion {
691-
substitutions: vec![Substitution {
692-
parts: suggestion
693-
.into_iter()
694-
.map(|(span, snippet)| SubstitutionPart { snippet, span })
695-
.collect(),
696-
}],
697-
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
698-
style: SuggestionStyle::CompletelyHidden,
689+
self.multipart_suggestion_with_style(
690+
msg,
691+
suggestion,
699692
applicability,
700-
});
701-
self
693+
SuggestionStyle::CompletelyHidden,
694+
)
702695
}
703696

704697
/// Prints out a message with a suggested edit of the code.

compiler/rustc_errors/src/lib.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -1249,9 +1249,13 @@ impl HandlerInner {
12491249
}
12501250

12511251
fn treat_err_as_bug(&self) -> bool {
1252-
self.flags
1253-
.treat_err_as_bug
1254-
.map_or(false, |c| self.err_count() + self.lint_err_count >= c.get())
1252+
self.flags.treat_err_as_bug.map_or(false, |c| {
1253+
self.err_count()
1254+
+ self.lint_err_count
1255+
+ self.delayed_span_bugs.len()
1256+
+ self.delayed_good_path_bugs.len()
1257+
>= c.get()
1258+
})
12551259
}
12561260

12571261
fn print_error_count(&mut self, registry: &Registry) {
@@ -1407,7 +1411,14 @@ impl HandlerInner {
14071411
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
14081412
// incrementing `err_count` by one, so we need to +1 the comparing.
14091413
// FIXME: Would be nice to increment err_count in a more coherent way.
1410-
if self.flags.treat_err_as_bug.map_or(false, |c| self.err_count() + 1 >= c.get()) {
1414+
if self.flags.treat_err_as_bug.map_or(false, |c| {
1415+
self.err_count()
1416+
+ self.lint_err_count
1417+
+ self.delayed_span_bugs.len()
1418+
+ self.delayed_good_path_bugs.len()
1419+
+ 1
1420+
>= c.get()
1421+
}) {
14111422
// FIXME: don't abort here if report_delayed_bugs is off
14121423
self.span_bug(sp, msg);
14131424
}

compiler/rustc_lint_defs/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ macro_rules! pluralize {
4141
/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion
4242
/// to determine whether it should be automatically applied or if the user should be consulted
4343
/// before applying the suggestion.
44-
#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable, Serialize, Deserialize)]
44+
#[derive(Copy, Clone, Debug, Hash, Encodable, Decodable, Serialize, Deserialize)]
45+
#[derive(PartialEq, Eq, PartialOrd, Ord)]
4546
pub enum Applicability {
4647
/// The suggestion is definitely what the user intended, or maintains the exact meaning of the code.
4748
/// This suggestion should be automatically applied.

compiler/rustc_llvm/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ fn main() {
342342
};
343343

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

0 commit comments

Comments
 (0)