Skip to content
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

Rollup of 15 pull requests #100677

Merged
merged 36 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dacffd2
Rustdoc-Json: Clean up tests
aDotInTheVoid Jul 18, 2022
5798555
interpret: only consider 1-ZST when searching for receiver
RalfJung Jul 28, 2022
64f790f
Jsondocck: New `@ismany` command
aDotInTheVoid Jul 19, 2022
760b972
rustdoc-json: Use `@ismany` in tests
aDotInTheVoid Jul 19, 2022
510ba03
errors: move translation logic into module
davidtwco Aug 10, 2022
a9e6167
triagebot: add mention groups for diag translation
davidtwco Aug 10, 2022
ae02014
triagebot: autolabel `A-translation`
davidtwco Aug 12, 2022
63113c8
unwind: don't build dependency when building for Miri
RalfJung Aug 14, 2022
7d1e5a4
Avoid code duplication in `{MetaItem,MetaItemKind}::value_str`.
nnethercote Aug 1, 2022
d7a041f
Make `ExtCtxt::expr_lit` non-`pub`.
nnethercote Aug 1, 2022
3f379f6
needless separation of impl blocks
tshepang Aug 16, 2022
5309375
Do not report cycle error when inferring return type for suggestion
compiler-errors Aug 10, 2022
5d3cc17
Rename some things related to literals.
nnethercote Aug 1, 2022
8439080
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi
taiki-e Aug 16, 2022
c1a9841
Migrate emoji identifier diagnostics to `SessionDiagnostic`
finalchild Aug 16, 2022
33212bf
Remove deferred sized checks
compiler-errors Aug 16, 2022
b176f8b
Update books
ehuss Aug 17, 2022
f4674b4
Update cargo
ehuss Aug 17, 2022
89d9a35
Fixed a few documentation errors
milescaprio Aug 17, 2022
683b3f4
Fixed a few documentation errors
milescaprio Aug 17, 2022
1cede2c
`is_knowable` use `Result` instead of `Option`
lcnr Aug 13, 2022
0491fda
Rollup merge of #99474 - aDotInTheVoid:rustdoc-json-noinline-test-cle…
matthiaskrgr Aug 17, 2022
bb77336
Rollup merge of #99972 - RalfJung:1zst, r=lcnr
matthiaskrgr Aug 17, 2022
d5dca26
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
matthiaskrgr Aug 17, 2022
989e4ff
Rollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-Simulacrum
matthiaskrgr Aug 17, 2022
1948288
Rollup merge of #100389 - compiler-errors:return-type-suggestion-cycl…
matthiaskrgr Aug 17, 2022
1e93994
Rollup merge of #100489 - lcnr:is_knowable-Result, r=davidtwco
matthiaskrgr Aug 17, 2022
56b02b2
Rollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum
matthiaskrgr Aug 17, 2022
d956734
Rollup merge of #100608 - tshepang:needless-separation, r=TaKO8Ki
matthiaskrgr Aug 17, 2022
64cd657
Rollup merge of #100621 - taiki-e:armv4t-atomics-32, r=cuviper
matthiaskrgr Aug 17, 2022
c0297e2
Rollup merge of #100646 - finalchild:emoji-diag, r=compiler-errors
matthiaskrgr Aug 17, 2022
6eed54a
Rollup merge of #100652 - compiler-errors:no-defer-sized-checks, r=Ta…
matthiaskrgr Aug 17, 2022
c0d9fea
Rollup merge of #100655 - ehuss:update-books, r=ehuss
matthiaskrgr Aug 17, 2022
36d8d55
Rollup merge of #100656 - ehuss:update-cargo, r=ehuss
matthiaskrgr Aug 17, 2022
bd8aa6d
Rollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc
matthiaskrgr Aug 17, 2022
1199dbd
Rollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc
matthiaskrgr Aug 17, 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: 3 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ dependencies = [

[[package]]
name = "cargo"
version = "0.65.0"
version = "0.66.0"
dependencies = [
"anyhow",
"atty",
Expand Down Expand Up @@ -4011,6 +4011,7 @@ dependencies = [
"rustc_hir",
"rustc_incremental",
"rustc_lint",
"rustc_macros",
"rustc_metadata",
"rustc_middle",
"rustc_mir_build",
Expand Down Expand Up @@ -4359,6 +4360,7 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"tracing",
]

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ pub enum StrStyle {
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct Lit {
/// The original literal token as written in source code.
pub token: token::Lit,
pub token_lit: token::Lit,
/// The "semantic" representation of the literal lowered from the original tokens.
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
/// FIXME: Remove this and only create the semantic representation during lowering to HIR.
Expand Down Expand Up @@ -1717,7 +1717,7 @@ impl StrLit {
StrStyle::Raw(n) => token::StrRaw(n),
};
Lit {
token: token::Lit::new(token_kind, self.symbol, self.suffix),
token_lit: token::Lit::new(token_kind, self.symbol, self.suffix),
span: self.span,
kind: LitKind::Str(self.symbol_unescaped, self.style),
}
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ impl MetaItem {
}

pub fn value_str(&self) -> Option<Symbol> {
match self.kind {
MetaItemKind::NameValue(ref v) => match v.kind {
LitKind::Str(ref s, _) => Some(*s),
_ => None,
},
_ => None,
}
self.kind.value_str()
}

pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum LitError {

impl LitKind {
/// Converts literal token into a semantic literal.
pub fn from_lit_token(lit: token::Lit) -> Result<LitKind, LitError> {
pub fn from_token_lit(lit: token::Lit) -> Result<LitKind, LitError> {
let token::Lit { kind, symbol, suffix } = lit;
if suffix.is_some() && !kind.may_have_suffix() {
return Err(LitError::InvalidSuffix);
Expand Down Expand Up @@ -153,7 +153,7 @@ impl LitKind {
/// Attempts to recover a token from semantic literal.
/// This function is used when the original token doesn't exist (e.g. the literal is created
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
pub fn to_lit_token(&self) -> token::Lit {
pub fn to_token_lit(&self) -> token::Lit {
let (kind, symbol, suffix) = match *self {
LitKind::Str(symbol, ast::StrStyle::Cooked) => {
// Don't re-intern unless the escaped string is different.
Expand Down Expand Up @@ -208,8 +208,8 @@ impl LitKind {

impl Lit {
/// Converts literal token into an AST literal.
pub fn from_lit_token(token: token::Lit, span: Span) -> Result<Lit, LitError> {
Ok(Lit { token, kind: LitKind::from_lit_token(token)?, span })
pub fn from_token_lit(token_lit: token::Lit, span: Span) -> Result<Lit, LitError> {
Ok(Lit { token_lit, kind: LitKind::from_token_lit(token_lit)?, span })
}

/// Converts arbitrary token into an AST literal.
Expand All @@ -232,21 +232,21 @@ impl Lit {
_ => return Err(LitError::NotLiteral),
};

Lit::from_lit_token(lit, token.span)
Lit::from_token_lit(lit, token.span)
}

/// Attempts to recover an AST literal from semantic literal.
/// This function is used when the original token doesn't exist (e.g. the literal is created
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
Lit { token: kind.to_lit_token(), kind, span }
Lit { token_lit: kind.to_token_lit(), kind, span }
}

/// Losslessly convert an AST literal into a token.
pub fn to_token(&self) -> Token {
let kind = match self.token.kind {
token::Bool => token::Ident(self.token.symbol, false),
_ => token::Literal(self.token),
let kind = match self.token_lit.kind {
token::Bool => token::Ident(self.token_lit.symbol, false),
_ => token::Literal(self.token_lit),
};
Token::new(kind, self.span)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
lit.clone()
} else {
Lit {
token: token::Lit::new(token::LitKind::Err, kw::Empty, None),
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
kind: LitKind::Err(kw::Empty),
span: DUMMY_SP,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere

fn print_literal(&mut self, lit: &ast::Lit) {
self.maybe_print_comment(lit.span.lo());
self.word(lit.token.to_string())
self.word(lit.token_lit.to_string())
}

fn print_string(&mut self, st: &str, style: ast::StrStyle) {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rustc_ast as ast;
use rustc_ast::{ptr::P, tokenstream::TokenStream};
use rustc_data_structures::sync::Lrc;
use rustc_errors::Applicability;
use rustc_expand::base::{self, DummyResult};

Expand Down Expand Up @@ -185,5 +184,5 @@ pub fn expand_concat_bytes(
return base::MacEager::expr(DummyResult::raw_expr(sp, true));
}
let sp = cx.with_def_site_ctxt(sp);
base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::from(accumulator))))
base::MacEager::expr(cx.expr_byte_str(sp, accumulator))
}
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool {
}

fn report_unexpected_literal(sess: &Session, lit: &ast::Lit) {
let help_msg = match lit.token.kind {
token::Str if rustc_lexer::is_ident(lit.token.symbol.as_str()) => {
format!("try using `#[derive({})]`", lit.token.symbol)
let help_msg = match lit.token_lit.kind {
token::Str if rustc_lexer::is_ident(lit.token_lit.symbol.as_str()) => {
format!("try using `#[derive({})]`", lit.token_lit.symbol)
}
_ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(),
};
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>

// We want to make sure we have the ctxt set so that we can use unstable methods
let span = cx.with_def_site_ctxt(span);
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
let name = cx.expr_str(span, ident.name);
let fmt = substr.nonselflike_args[0].clone();

// Struct and tuples are similar enough that we use the same code for both,
Expand Down Expand Up @@ -89,10 +89,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
for i in 0..fields.len() {
let field = &fields[i];
if is_struct {
let name = cx.expr_lit(
field.span,
ast::LitKind::Str(field.name.unwrap().name, ast::StrStyle::Cooked),
);
let name = cx.expr_str(field.span, field.name.unwrap().name);
args.push(name);
}
// Use an extra indirection to make sure this works for unsized types.
Expand All @@ -108,10 +105,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>

for field in fields {
if is_struct {
name_exprs.push(cx.expr_lit(
field.span,
ast::LitKind::Str(field.name.unwrap().name, ast::StrStyle::Cooked),
));
name_exprs.push(cx.expr_str(field.span, field.name.unwrap().name));
}

// Use an extra indirection to make sure this works for unsized types.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ impl<'a, 'b> Context<'a, 'b> {
}

// Build the format
let fill = self.ecx.expr_lit(sp, ast::LitKind::Char(fill));
let fill = self.ecx.expr_char(sp, fill);
let align = |name| {
let mut p = Context::rtpath(self.ecx, sym::Alignment);
p.push(Ident::new(name, sp));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub fn expand_include_bytes(
}
};
match cx.source_map().load_binary_file(&file) {
Ok(bytes) => base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(bytes.into()))),
Ok(bytes) => base::MacEager::expr(cx.expr_byte_str(sp, bytes)),
Err(e) => {
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
DummyResult::any(sp)
Expand Down
20 changes: 11 additions & 9 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_data_structures::profiling::TimingGuard;
use rustc_data_structures::profiling::VerboseTimingGuard;
use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::Emitter;
use rustc_errors::{DiagnosticId, FatalError, Handler, Level};
use rustc_errors::{translation::Translate, DiagnosticId, FatalError, Handler, Level};
use rustc_fs_util::link_or_copy;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_incremental::{
Expand Down Expand Up @@ -1740,6 +1740,16 @@ impl SharedEmitter {
}
}

impl Translate for SharedEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
None
}

fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
panic!("shared emitter attempted to translate a diagnostic");
}
}

impl Emitter for SharedEmitter {
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
let fluent_args = self.to_fluent_args(diag.args());
Expand All @@ -1761,14 +1771,6 @@ impl Emitter for SharedEmitter {
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
None
}

fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
None
}

fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
panic!("shared emitter attempted to translate a diagnostic");
}
}

impl SharedEmitterMain {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_const_eval/src/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let mut non_zst_field = None;
for i in 0..receiver.layout.fields.count() {
let field = self.operand_field(&receiver, i)?;
if !field.layout.is_zst() {
let zst =
field.layout.is_zst() && field.layout.align.abi.bytes() == 1;
if !zst {
assert!(
non_zst_field.is_none(),
"multiple non-ZST fields in dyn receiver type {}",
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ cfg_if! {
pub fn new(v: T) -> Self {
Atomic(Cell::new(v))
}
}

impl<T: Copy> Atomic<T> {
#[inline]
pub fn into_inner(self) -> T {
self.0.into_inner()
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/interface.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface_ferris_identifier =
Ferris cannot be used as an identifier
.suggestion = try using their name instead

interface_emoji_identifier =
identifiers cannot contain emoji: `{$ident}`
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fluent_messages! {
builtin_macros => "../locales/en-US/builtin_macros.ftl",
const_eval => "../locales/en-US/const_eval.ftl",
expand => "../locales/en-US/expand.ftl",
interface => "../locales/en-US/interface.ftl",
lint => "../locales/en-US/lint.ftl",
parser => "../locales/en-US/parser.ftl",
passes => "../locales/en-US/passes.ftl",
Expand Down
19 changes: 11 additions & 8 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use crate::emitter::FileWithAnnotatedLines;
use crate::snippet::Line;
use crate::translation::Translate;
use crate::{
CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage, Emitter, FluentBundle,
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
Expand All @@ -32,6 +33,16 @@ pub struct AnnotateSnippetEmitterWriter {
macro_backtrace: bool,
}

impl Translate for AnnotateSnippetEmitterWriter {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
self.fluent_bundle.as_ref()
}

fn fallback_fluent_bundle(&self) -> &FluentBundle {
&**self.fallback_bundle
}
}

impl Emitter for AnnotateSnippetEmitterWriter {
/// The entry point for the diagnostics generation
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
Expand Down Expand Up @@ -63,14 +74,6 @@ impl Emitter for AnnotateSnippetEmitterWriter {
self.source_map.as_ref()
}

fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
self.fluent_bundle.as_ref()
}

fn fallback_fluent_bundle(&self) -> &FluentBundle {
&**self.fallback_bundle
}

fn should_show_explain(&self) -> bool {
!self.short_message
}
Expand Down
Loading