1
Fork 0

Auto merge of #116727 - matthiaskrgr:rollup-3qqdrny, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #116630 (Add ability to get lines/filename for Span in smir)
 - #116644 (remove outdated bootstrap FIXME)
 - #116695 (Fix a comment)
 - #116696 (Misc improvements)
 - #116704 (Fix AFIT lint message to mention pitfall)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-10-14 15:07:25 +00:00
commit 0233608c67
9 changed files with 97 additions and 24 deletions

View file

@ -229,35 +229,61 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool {
#[derive(PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] #[derive(PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
pub enum TokenKind { pub enum TokenKind {
/* Expression-operator symbols. */ /* Expression-operator symbols. */
/// `=`
Eq, Eq,
/// `<`
Lt, Lt,
/// `<=`
Le, Le,
/// `==`
EqEq, EqEq,
/// `!=`
Ne, Ne,
/// `>`
Ge, Ge,
/// `>=`
Gt, Gt,
/// `&&`
AndAnd, AndAnd,
/// `||`
OrOr, OrOr,
/// `!`
Not, Not,
/// `~`
Tilde, Tilde,
BinOp(BinOpToken), BinOp(BinOpToken),
BinOpEq(BinOpToken), BinOpEq(BinOpToken),
/* Structural symbols */ /* Structural symbols */
/// `@`
At, At,
/// `.`
Dot, Dot,
/// `..`
DotDot, DotDot,
/// `...`
DotDotDot, DotDotDot,
/// `..=`
DotDotEq, DotDotEq,
/// `,`
Comma, Comma,
/// `;`
Semi, Semi,
/// `:`
Colon, Colon,
/// `::`
ModSep, ModSep,
/// `->`
RArrow, RArrow,
/// `<-`
LArrow, LArrow,
/// `=>`
FatArrow, FatArrow,
/// `#`
Pound, Pound,
/// `$`
Dollar, Dollar,
/// `?`
Question, Question,
/// Used by proc macros for representing lifetimes, not generated by lexer right now. /// Used by proc macros for representing lifetimes, not generated by lexer right now.
SingleQuote, SingleQuote,
@ -296,6 +322,7 @@ pub enum TokenKind {
/// similarly to symbols in string literal tokens. /// similarly to symbols in string literal tokens.
DocComment(CommentKind, ast::AttrStyle, Symbol), DocComment(CommentKind, ast::AttrStyle, Symbol),
/// End Of File
Eof, Eof,
} }

View file

@ -71,33 +71,35 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
} }
register_bang! { register_bang! {
// tidy-alphabetical-start
asm: asm::expand_asm, asm: asm::expand_asm,
assert: assert::expand_assert, assert: assert::expand_assert,
cfg: cfg::expand_cfg, cfg: cfg::expand_cfg,
column: source_util::expand_column, column: source_util::expand_column,
compile_error: compile_error::expand_compile_error, compile_error: compile_error::expand_compile_error,
concat: concat::expand_concat,
concat_bytes: concat_bytes::expand_concat_bytes, concat_bytes: concat_bytes::expand_concat_bytes,
concat_idents: concat_idents::expand_concat_idents, concat_idents: concat_idents::expand_concat_idents,
concat: concat::expand_concat, const_format_args: format::expand_format_args,
core_panic: edition_panic::expand_panic,
env: env::expand_env, env: env::expand_env,
file: source_util::expand_file, file: source_util::expand_file,
format_args_nl: format::expand_format_args_nl,
format_args: format::expand_format_args, format_args: format::expand_format_args,
const_format_args: format::expand_format_args, format_args_nl: format::expand_format_args_nl,
global_asm: asm::expand_global_asm, global_asm: asm::expand_global_asm,
include: source_util::expand_include,
include_bytes: source_util::expand_include_bytes, include_bytes: source_util::expand_include_bytes,
include_str: source_util::expand_include_str, include_str: source_util::expand_include_str,
include: source_util::expand_include,
line: source_util::expand_line, line: source_util::expand_line,
log_syntax: log_syntax::expand_log_syntax, log_syntax: log_syntax::expand_log_syntax,
module_path: source_util::expand_mod, module_path: source_util::expand_mod,
option_env: env::expand_option_env, option_env: env::expand_option_env,
core_panic: edition_panic::expand_panic,
std_panic: edition_panic::expand_panic, std_panic: edition_panic::expand_panic,
unreachable: edition_panic::expand_unreachable,
stringify: source_util::expand_stringify, stringify: source_util::expand_stringify,
trace_macros: trace_macros::expand_trace_macros, trace_macros: trace_macros::expand_trace_macros,
type_ascribe: type_ascribe::expand_type_ascribe, type_ascribe: type_ascribe::expand_type_ascribe,
unreachable: edition_panic::expand_unreachable,
// tidy-alphabetical-end
} }
register_attr! { register_attr! {

View file

@ -180,7 +180,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
// //
// default impl Foo for Bar { .. } // default impl Foo for Bar { .. }
// //
// we add a default where clause `Foo: Bar`. We do a similar thing for traits // we add a default where clause `Bar: Foo`. We do a similar thing for traits
// (see below). Recall that a default impl is not itself an impl, but rather a // (see below). Recall that a default impl is not itself an impl, but rather a
// set of defaults that can be incorporated into another impl. // set of defaults that can be incorporated into another impl.
if let Some(trait_ref) = is_default_impl_trait { if let Some(trait_ref) = is_default_impl_trait {

View file

@ -7,7 +7,7 @@ lint_array_into_iter =
lint_async_fn_in_trait = use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified lint_async_fn_in_trait = use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified
.note = you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future` .note = you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`
.suggestion = you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send` .suggestion = you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change
lint_atomic_ordering_fence = memory fences cannot have `Relaxed` ordering lint_atomic_ordering_fence = memory fences cannot have `Relaxed` ordering
.help = consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst` .help = consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`

View file

@ -17,8 +17,10 @@ use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc_target::abi::FieldIdx; use rustc_target::abi::FieldIdx;
use stable_mir::mir::{CopyNonOverlapping, Statement, UserTypeProjection, VariantIdx}; use stable_mir::mir::{CopyNonOverlapping, Statement, UserTypeProjection, VariantIdx};
use stable_mir::ty::{FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy}; use stable_mir::ty::{
use stable_mir::{self, opaque, Context}; FloatTy, GenericParamDef, IntTy, LineInfo, Movability, RigidTy, Span, TyKind, UintTy,
};
use stable_mir::{self, opaque, Context, Filename};
use tracing::debug; use tracing::debug;
mod alloc; mod alloc;
@ -50,10 +52,27 @@ impl<'tcx> Context for Tables<'tcx> {
self.tcx.def_path_str(self[def_id]) self.tcx.def_path_str(self[def_id])
} }
fn print_span(&self, span: stable_mir::ty::Span) -> String { fn span_to_string(&self, span: stable_mir::ty::Span) -> String {
self.tcx.sess.source_map().span_to_diagnostic_string(self[span]) self.tcx.sess.source_map().span_to_diagnostic_string(self[span])
} }
fn get_filename(&self, span: &Span) -> Filename {
opaque(
&self
.tcx
.sess
.source_map()
.span_to_filename(self[*span])
.display(rustc_span::FileNameDisplayPreference::Local)
.to_string(),
)
}
fn get_lines(&self, span: &Span) -> LineInfo {
let lines = &self.tcx.sess.source_map().span_to_location_info(self[*span]);
LineInfo { start_line: lines.1, start_col: lines.2, end_line: lines.3, end_col: lines.4 }
}
fn def_kind(&mut self, def_id: stable_mir::DefId) -> stable_mir::DefKind { fn def_kind(&mut self, def_id: stable_mir::DefId) -> stable_mir::DefKind {
self.tcx.def_kind(self[def_id]).stable(self) self.tcx.def_kind(self[def_id]).stable(self)
} }

View file

@ -22,8 +22,8 @@ use std::fmt;
use std::fmt::Debug; use std::fmt::Debug;
use self::ty::{ use self::ty::{
GenericPredicates, Generics, ImplDef, ImplTrait, IndexedVal, Span, TraitDecl, TraitDef, Ty, GenericPredicates, Generics, ImplDef, ImplTrait, IndexedVal, LineInfo, Span, TraitDecl,
TyKind, TraitDef, Ty, TyKind,
}; };
#[macro_use] #[macro_use]
@ -108,6 +108,7 @@ pub struct Crate {
} }
pub type DefKind = Opaque; pub type DefKind = Opaque;
pub type Filename = Opaque;
/// Holds information about an item in the crate. /// Holds information about an item in the crate.
/// For now, it only stores the item DefId. Use functions inside `rustc_internal` module to /// For now, it only stores the item DefId. Use functions inside `rustc_internal` module to
@ -196,13 +197,19 @@ pub trait Context {
/// Find a crate with the given name. /// Find a crate with the given name.
fn find_crates(&self, name: &str) -> Vec<Crate>; fn find_crates(&self, name: &str) -> Vec<Crate>;
/// Prints the name of given `DefId` /// Returns the name of given `DefId`
fn name_of_def_id(&self, def_id: DefId) -> String; fn name_of_def_id(&self, def_id: DefId) -> String;
/// Prints a human readable form of `Span` /// Returns printable, human readable form of `Span`
fn print_span(&self, span: Span) -> String; fn span_to_string(&self, span: Span) -> String;
/// Prints the kind of given `DefId` /// Return filename from given `Span`, for diagnostic purposes
fn get_filename(&self, span: &Span) -> Filename;
/// Return lines corresponding to this `Span`
fn get_lines(&self, span: &Span) -> LineInfo;
/// Returns the `kind` of given `DefId`
fn def_kind(&mut self, def_id: DefId) -> DefKind; fn def_kind(&mut self, def_id: DefId) -> DefKind;
/// `Span` of an item /// `Span` of an item

View file

@ -3,7 +3,7 @@ use super::{
mir::{Body, Mutability}, mir::{Body, Mutability},
with, AllocId, DefId, Symbol, with, AllocId, DefId, Symbol,
}; };
use crate::Opaque; use crate::{Filename, Opaque};
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
@ -81,11 +81,33 @@ impl Debug for Span {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("Span") f.debug_struct("Span")
.field("id", &self.0) .field("id", &self.0)
.field("repr", &with(|cx| cx.print_span(*self))) .field("repr", &with(|cx| cx.span_to_string(*self)))
.finish() .finish()
} }
} }
impl Span {
/// Return filename for diagnostic purposes
pub fn get_filename(&self) -> Filename {
with(|c| c.get_filename(self))
}
/// Return lines that corespond to this `Span`
pub fn get_lines(&self) -> LineInfo {
with(|c| c.get_lines(&self))
}
}
#[derive(Clone, Copy, Debug)]
/// Information you get from `Span` in a struct form.
/// Line and col start from 1.
pub struct LineInfo {
pub start_line: usize,
pub start_col: usize,
pub end_line: usize,
pub end_col: usize,
}
impl IndexedVal for Span { impl IndexedVal for Span {
fn to_val(index: usize) -> Self { fn to_val(index: usize) -> Self {
Span(index) Span(index)

View file

@ -2940,10 +2940,6 @@ impl Step for TestHelpers {
let _guard = builder.msg_unstaged(Kind::Build, "test helpers", target); let _guard = builder.msg_unstaged(Kind::Build, "test helpers", target);
t!(fs::create_dir_all(&dst)); t!(fs::create_dir_all(&dst));
let mut cfg = cc::Build::new(); let mut cfg = cc::Build::new();
// FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013
if target.contains("emscripten") {
cfg.pic(false);
}
// We may have found various cross-compilers a little differently due to our // We may have found various cross-compilers a little differently due to our
// extra configuration, so inform cc of these compilers. Note, though, that // extra configuration, so inform cc of these compilers. Note, though, that

View file

@ -10,7 +10,7 @@ note: the lint level is defined here
| |
LL | #![deny(async_fn_in_trait)] LL | #![deny(async_fn_in_trait)]
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send` help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change
| |
LL - async fn not_send(); LL - async fn not_send();
LL + fn not_send() -> impl std::future::Future<Output = ()> + Send; LL + fn not_send() -> impl std::future::Future<Output = ()> + Send;