Skip to content

Rollup of 10 pull requests #104123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6d45529
Fix #103451, find_width_of_character_at_span return width with 1 when…
chenyukang Oct 25, 2022
f5e390e
Fix rustc_parse_format spans following escaped utf-8 multibyte chars
Alexendoo Oct 27, 2022
8dbd817
Upgrade cc for working is_flag_supported on cross-compiles
palfrey Oct 29, 2022
a9d7cfc
Update cc in Cargo.lock
palfrey Oct 29, 2022
f32e678
Rename some variables.
nnethercote Nov 3, 2022
84ca2c3
Clarify range calculations.
nnethercote Nov 3, 2022
34b32b0
Use `Mode` less.
nnethercote Nov 3, 2022
d43836f
Remove some redundant arguments
oli-obk Nov 3, 2022
402714f
Remove an unhelpful and sometimes misleading label
oli-obk Nov 3, 2022
7dbf2c0
Make non-ASCII errors more consistent.
nnethercote Nov 3, 2022
a21c045
Improve comments.
nnethercote Nov 3, 2022
d963686
Refactor `cook_lexer_literal`.
nnethercote Nov 3, 2022
a203482
Inline and remove `validate_int_literal`.
nnethercote Nov 3, 2022
f8e2cef
Move intra-doc link checks to a separate function.
ehuss Nov 4, 2022
57b2290
Remove reference from the intra-doc link checker.
ehuss Nov 4, 2022
ee7c58b
Update linker-plugin-lto.md to contain up to Rust 1.65
str4d Nov 4, 2022
971a146
Promote {aarch64,i686,x86_64}-unknown-uefi to Tier 2
nicholasbishop Nov 3, 2022
9268133
Print all labels, even if they have no span. Fall back to main item's…
oli-obk Nov 4, 2022
a838952
Remove `unescape_byte_literal`.
nnethercote Nov 4, 2022
43d21b5
Rename some `result` variables as `res`, for consistency.
nnethercote Nov 4, 2022
6994651
fix debuginfo for windows_gnullvm_base.rs
jeremyd2019 Nov 6, 2022
ee7a802
Migrate linker-plugin-lto.md compatibility table to show Rust ranges
str4d Nov 7, 2022
d97fa25
Fix invalid background-image file name
GuillaumeGomez Nov 7, 2022
976973f
Rollup merge of #103521 - chenyukang:yukang/fix-103451-avoid-hang, r=…
GuillaumeGomez Nov 7, 2022
8e0a7a8
Rollup merge of #103651 - Alexendoo:parse-format-unicode-escapes, r=w…
GuillaumeGomez Nov 7, 2022
847cad3
Rollup merge of #103744 - palfrey:unwind-upgrade-cc, r=Mark-Simulacrum
GuillaumeGomez Nov 7, 2022
69ffc17
Rollup merge of #103919 - nnethercote:unescaping-cleanups, r=matklad
GuillaumeGomez Nov 7, 2022
bc3c840
Rollup merge of #103933 - nicholasbishop:bishop-uefi-tier-2, r=JohnTitor
GuillaumeGomez Nov 7, 2022
17e2528
Rollup merge of #103952 - ehuss:dont-intra-linkcheck-reference, r=Mar…
GuillaumeGomez Nov 7, 2022
3956c30
Rollup merge of #103955 - str4d:update-lto-doc-1.65, r=ehuss
GuillaumeGomez Nov 7, 2022
ac8d5c9
Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=davidtwco
GuillaumeGomez Nov 7, 2022
66d2559
Rollup merge of #104067 - jeremyd2019:patch-1, r=davidtwco
GuillaumeGomez Nov 7, 2022
fbf9f42
Rollup merge of #104114 - GuillaumeGomez:background-image-path, r=not…
GuillaumeGomez Nov 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.0.73"
version = "1.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574"
dependencies = [
"jobserver",
]
Expand Down
29 changes: 11 additions & 18 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

use crate::ast::{self, Lit, LitKind};
use crate::token::{self, Token};

use rustc_lexer::unescape::{unescape_byte, unescape_char};
use rustc_lexer::unescape::{unescape_byte_literal, unescape_literal, Mode};
use rustc_lexer::unescape::{byte_from_char, unescape_byte, unescape_char, unescape_literal, Mode};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;

use std::ascii;

pub enum LitError {
Expand Down Expand Up @@ -109,13 +106,11 @@ impl LitKind {
let s = symbol.as_str();
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_byte_literal(&s, Mode::ByteStr, &mut |_, unescaped_byte| {
match unescaped_byte {
Ok(c) => buf.push(c),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
unescape_literal(&s, Mode::ByteStr, &mut |_, c| match c {
Ok(c) => buf.push(byte_from_char(c)),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
}
});
Expand All @@ -127,13 +122,11 @@ impl LitKind {
let bytes = if s.contains('\r') {
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_byte_literal(&s, Mode::RawByteStr, &mut |_, unescaped_byte| {
match unescaped_byte {
Ok(c) => buf.push(c),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
unescape_literal(&s, Mode::RawByteStr, &mut |_, c| match c {
Ok(c) => buf.push(byte_from_char(c)),
Err(err) => {
if err.is_fatal() {
error = Err(LitError::LexerError);
}
}
});
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_error_messages/locales/en-US/passes.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ passes_no_coverage_not_coverable =

passes_should_be_applied_to_fn =
attribute should be applied to a function definition
.label = not a function definition
.label = {$on_crate ->
[true] cannot be applied to crates
*[false] not a function definition
}

passes_naked_tracked_caller =
cannot use `#[track_caller]` with `#[naked]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl Emitter for AnnotateSnippetEmitterWriter {
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);

self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self.source_map,
&mut primary_span,
&mut children,
&diag.level,
Expand Down
60 changes: 40 additions & 20 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ pub trait Emitter: Translate {

fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self,
source_map: &Option<Lrc<SourceMap>>,
span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
level: &Level,
Expand All @@ -340,7 +339,7 @@ pub trait Emitter: Translate {
.collect();

if !backtrace {
self.fix_multispans_in_extern_macros(source_map, span, children);
self.fix_multispans_in_extern_macros(span, children);
}

self.render_multispans_macro_backtrace(span, children, backtrace);
Expand Down Expand Up @@ -480,23 +479,22 @@ pub trait Emitter: Translate {
// this will change the span to point at the use site.
fn fix_multispans_in_extern_macros(
&self,
source_map: &Option<Lrc<SourceMap>>,
span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
) {
let Some(source_map) = source_map else { return };
debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children);
self.fix_multispan_in_extern_macros(source_map, span);
self.fix_multispan_in_extern_macros(span);
for child in children.iter_mut() {
self.fix_multispan_in_extern_macros(source_map, &mut child.span);
self.fix_multispan_in_extern_macros(&mut child.span);
}
debug!("fix_multispans_in_extern_macros: after: span={:?} children={:?}", span, children);
}

// This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros.
// Since these locations are often difficult to read,
// we move these spans from the external macros to their corresponding use site.
fn fix_multispan_in_extern_macros(&self, source_map: &Lrc<SourceMap>, span: &mut MultiSpan) {
fn fix_multispan_in_extern_macros(&self, span: &mut MultiSpan) {
let Some(source_map) = self.source_map() else { return };
// First, find all the spans in external macros and point instead at their use site.
let replacements: Vec<(Span, Span)> = span
.primary_spans()
Expand Down Expand Up @@ -544,7 +542,6 @@ impl Emitter for EmitterWriter {
debug!("emit_diagnostic: suggestions={:?}", suggestions);

self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self.sm,
&mut primary_span,
&mut children,
&diag.level,
Expand Down Expand Up @@ -2213,22 +2210,45 @@ impl FileWithAnnotatedLines {

if let Some(ref sm) = emitter.source_map() {
for span_label in msp.span_labels() {
let fixup_lo_hi = |span: Span| {
let lo = sm.lookup_char_pos(span.lo());
let mut hi = sm.lookup_char_pos(span.hi());

// Watch out for "empty spans". If we get a span like 6..6, we
// want to just display a `^` at 6, so convert that to
// 6..7. This is degenerate input, but it's best to degrade
// gracefully -- and the parser likes to supply a span like
// that for EOF, in particular.

if lo.col_display == hi.col_display && lo.line == hi.line {
hi.col_display += 1;
}
(lo, hi)
};

if span_label.span.is_dummy() {
if let Some(span) = msp.primary_span() {
// if we don't know where to render the annotation, emit it as a note
// on the primary span.

let (lo, hi) = fixup_lo_hi(span);

let ann = Annotation {
start_col: lo.col_display,
end_col: hi.col_display,
is_primary: span_label.is_primary,
label: span_label
.label
.as_ref()
.map(|m| emitter.translate_message(m, args).to_string()),
annotation_type: AnnotationType::Singleline,
};
add_annotation_to_file(&mut output, lo.file, lo.line, ann);
}
continue;
}

let lo = sm.lookup_char_pos(span_label.span.lo());
let mut hi = sm.lookup_char_pos(span_label.span.hi());

// Watch out for "empty spans". If we get a span like 6..6, we
// want to just display a `^` at 6, so convert that to
// 6..7. This is degenerate input, but it's best to degrade
// gracefully -- and the parser likes to supply a span like
// that for EOF, in particular.

if lo.col_display == hi.col_display && lo.line == hi.line {
hi.col_display += 1;
}
let (lo, hi) = fixup_lo_hi(span_label.span);

if lo.line != hi.line {
let ml = MultilineAnnotation {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ pub enum RawStrError {
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Base {
/// Literal starts with "0b".
Binary,
Binary = 2,
/// Literal starts with "0o".
Octal,
/// Literal starts with "0x".
Hexadecimal,
Octal = 8,
/// Literal doesn't contain a prefix.
Decimal,
Decimal = 10,
/// Literal starts with "0x".
Hexadecimal = 16,
}

/// `rustc` allows files to have a shebang, e.g. "#!/usr/bin/rustrun",
Expand Down
Loading