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 8 pull requests #93245

Merged
merged 36 commits into from
Jan 24, 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
0e24ad5
Implement RFC 3151: Scoped threads.
m-ou-se Jan 4, 2022
cc699e1
Add ScopedJoinHandle::is_running().
m-ou-se Jan 4, 2022
da33da1
Add documentation for scoped threads.
m-ou-se Jan 4, 2022
f521779
Simplify panicking mechanism of thread::scope.
m-ou-se Jan 4, 2022
4300bea
Formatting.
m-ou-se Jan 4, 2022
c5cb2de
Fix variance of thread::Scope.
m-ou-se Jan 4, 2022
2c8cc70
Use > rather than == for overflow check in scoped threads.
m-ou-se Jan 4, 2022
09e6665
Fix typo in documentation.
m-ou-se Jan 4, 2022
c429ade
Fix typo in is_running() docs.
m-ou-se Jan 4, 2022
5b5746f
Fix typo in Scope::spawn docs.
m-ou-se Jan 4, 2022
a9efbaf
Rename n_running_threads to num_running_threads.
m-ou-se Jan 5, 2022
5bd5781
Fix missing .load() in Scope's Debug impl.
m-ou-se Jan 5, 2022
aa9c088
Note the invariance over 'env in Scope<'env>.
m-ou-se Jan 5, 2022
4cb7370
Mention *scoped* thread in panic message.
m-ou-se Jan 5, 2022
bc8cef1
rustc_mir_itertools: Avoid needless `collect` with itertools
mati865 Jan 22, 2022
e572c5a
Simplify Send/Sync of std::thread::Packet.
m-ou-se Jan 22, 2022
12cc7d9
Add tracking issue number for scoped_threads.
m-ou-se Jan 22, 2022
465c405
Add test for thread::Scope invariance.
m-ou-se Jan 22, 2022
cbb0fff
Fix let_chains and if_let_guard feature flags
c410-f3r Jan 22, 2022
4ff7e6e
Normalize field access types during borrowck
compiler-errors Jan 23, 2022
19809ed
Add preliminary support for inline assembly for msp430.
cr1901 Jan 20, 2022
cf382de
Remove DiagnosticBuilder.quiet
mark-i-m Jan 23, 2022
452aa81
rustc_lint: Remove some redundant fields from `EarlyContext`
petrochenkov Sep 27, 2021
51b2338
rustc_lint: Reuse the set of registered tools from resolver
petrochenkov Sep 28, 2021
9c70b6d
Update clippy
petrochenkov Dec 4, 2021
05cd755
rustc_lint: Stop creating a fake `ast::Crate` for running early lints
petrochenkov Dec 7, 2021
67cccaf
expand: Pass everything by reference to pre-expansion lint callback
petrochenkov Dec 11, 2021
4a74ace
Liberate late bound regions when collecting GAT substs in wfcheck
compiler-errors Jan 23, 2022
89baf0f
Rollup merge of #91526 - petrochenkov:earlint, r=cjgillot
matthiaskrgr Jan 23, 2022
bb260e8
Rollup merge of #92555 - m-ou-se:scoped-threads, r=Amanieu
matthiaskrgr Jan 23, 2022
0f2ff4b
Rollup merge of #93213 - c410-f3r:let-chains-feature, r=matthewjasper
matthiaskrgr Jan 23, 2022
552b564
Rollup merge of #93219 - cr1901:msp430-asm-squashed, r=Amanieu
matthiaskrgr Jan 23, 2022
5adef28
Rollup merge of #93226 - compiler-errors:issue-93141, r=jackh726
matthiaskrgr Jan 23, 2022
8810af8
Rollup merge of #93227 - compiler-errors:gat-hrtb-wfcheck, r=jackh726
matthiaskrgr Jan 23, 2022
a1645e5
Rollup merge of #93229 - mark-i-m:noquiet, r=eddyb
matthiaskrgr Jan 23, 2022
eea833f
Rollup merge of #93234 - mati865:mir-transform-use-itertools, r=jackh726
matthiaskrgr Jan 23, 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
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
},
ProjectionElem::Field(field, fty) => {
let fty = self.sanitize_type(place, fty);
let fty = self.cx.normalize(fty, location);
match self.field_ty(place, base, field, location) {
Ok(ty) => {
let ty = self.cx.normalize(ty, location);
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_gcc/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::reg) => unimplemented!(),
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => unimplemented!(),
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => unimplemented!(),
InlineAsmRegClass::Msp430(_) => unimplemented!(),
InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => unimplemented!(),
InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => unimplemented!(),
InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => unimplemented!(),
Expand Down Expand Up @@ -622,6 +623,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => cx.type_f32(),
InlineAsmRegClass::Msp430(_) => unimplemented!(),
InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => cx.type_i16(),
InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => cx.type_i32(),
InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => cx.type_i64(),
Expand Down Expand Up @@ -729,6 +731,7 @@ fn modifier_to_gcc(arch: InlineAsmArch, reg: InlineAsmRegClass, modifier: Option
InlineAsmRegClass::Bpf(_) => unimplemented!(),
InlineAsmRegClass::Hexagon(_) => unimplemented!(),
InlineAsmRegClass::Mips(_) => unimplemented!(),
InlineAsmRegClass::Msp430(_) => unimplemented!(),
InlineAsmRegClass::Nvptx(_) => unimplemented!(),
InlineAsmRegClass::PowerPC(_) => unimplemented!(),
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg)
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
InlineAsmArch::SpirV => {}
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {}
InlineAsmArch::Bpf => {}
InlineAsmArch::Msp430 => {
constraints.push("~{sr}".to_string());
}
}
}
if !options.contains(InlineAsmOptions::NOMEM) {
Expand Down Expand Up @@ -580,6 +583,7 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_ptr) => "e",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => "f",
InlineAsmRegClass::Msp430(Msp430InlineAsmRegClass::reg) => "r",
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
Expand Down Expand Up @@ -666,6 +670,7 @@ fn modifier_to_llvm(
},
InlineAsmRegClass::Avr(_) => None,
InlineAsmRegClass::S390x(_) => None,
InlineAsmRegClass::Msp430(_) => None,
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
Expand Down Expand Up @@ -734,6 +739,7 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_ptr) => cx.type_i16(),
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => cx.type_f64(),
InlineAsmRegClass::Msp430(Msp430InlineAsmRegClass::reg) => cx.type_i16(),
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
Expand Down
17 changes: 1 addition & 16 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,6 @@ struct HandlerInner {
deduplicated_warn_count: usize,

future_breakage_diagnostics: Vec<Diagnostic>,

/// If set to `true`, no warning or error will be emitted.
quiet: bool,
}

/// A key denoting where from a diagnostic was stashed.
Expand Down Expand Up @@ -563,19 +560,10 @@ impl Handler {
emitted_diagnostics: Default::default(),
stashed_diagnostics: Default::default(),
future_breakage_diagnostics: Vec::new(),
quiet: false,
}),
}
}

pub fn with_disabled_diagnostic<T, F: FnOnce() -> T>(&self, f: F) -> T {
let prev = self.inner.borrow_mut().quiet;
self.inner.borrow_mut().quiet = true;
let ret = f();
self.inner.borrow_mut().quiet = prev;
ret
}

// This is here to not allow mutation of flags;
// as of this writing it's only used in tests in librustc_middle.
pub fn can_emit_warnings(&self) -> bool {
Expand Down Expand Up @@ -946,7 +934,7 @@ impl HandlerInner {
}

fn emit_diagnostic(&mut self, diagnostic: &Diagnostic) {
if diagnostic.cancelled() || self.quiet {
if diagnostic.cancelled() {
return;
}

Expand Down Expand Up @@ -1170,9 +1158,6 @@ impl HandlerInner {
}

fn delay_as_bug(&mut self, diagnostic: Diagnostic) {
if self.quiet {
return;
}
if self.flags.report_delayed_bugs {
self.emit_diagnostic(&diagnostic);
}
Expand Down
32 changes: 22 additions & 10 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream};
use rustc_ast::visit::{AssocCtxt, Visitor};
use rustc_ast::{self as ast, AstLike, Attribute, Item, NodeId, PatKind};
use rustc_attr::{self as attr, Deprecation, Stability};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{self, Lrc};
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorReported};
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
Expand Down Expand Up @@ -920,8 +920,25 @@ pub trait ResolverExpand {
/// we generated proc macros harnesses, so that we can map
/// HIR proc macros items back to their harness items.
fn declare_proc_macro(&mut self, id: NodeId);

/// Tools registered with `#![register_tool]` and used by tool attributes and lints.
fn registered_tools(&self) -> &FxHashSet<Ident>;
}

pub trait LintStoreExpand {
fn pre_expansion_lint(
&self,
sess: &Session,
registered_tools: &FxHashSet<Ident>,
node_id: NodeId,
attrs: &[Attribute],
items: &[P<Item>],
name: &str,
);
}

type LintStoreExpandDyn<'a> = Option<&'a (dyn LintStoreExpand + 'a)>;

#[derive(Clone, Default)]
pub struct ModuleData {
/// Path to the module starting from the crate name, like `my_crate::foo::bar`.
Expand Down Expand Up @@ -956,9 +973,6 @@ pub struct ExpansionData {
pub is_trailing_mac: bool,
}

type OnExternModLoaded<'a> =
Option<&'a dyn Fn(Ident, Vec<Attribute>, Vec<P<Item>>, Span) -> (Vec<Attribute>, Vec<P<Item>>)>;

/// One of these is made during expansion and incrementally updated as we go;
/// when a macro expansion occurs, the resulting nodes have the `backtrace()
/// -> expn_data` of their expansion context stored into their span.
Expand All @@ -973,10 +987,8 @@ pub struct ExtCtxt<'a> {
/// (or during eager expansion, but that's a hack).
pub force_mode: bool,
pub expansions: FxHashMap<Span, Vec<String>>,
/// Called directly after having parsed an external `mod foo;` in expansion.
///
/// `Ident` is the module name.
pub(super) extern_mod_loaded: OnExternModLoaded<'a>,
/// Used for running pre-expansion lints on freshly loaded modules.
pub(super) lint_store: LintStoreExpandDyn<'a>,
/// When we 'expand' an inert attribute, we leave it
/// in the AST, but insert it here so that we know
/// not to expand it again.
Expand All @@ -988,14 +1000,14 @@ impl<'a> ExtCtxt<'a> {
sess: &'a Session,
ecfg: expand::ExpansionConfig<'a>,
resolver: &'a mut dyn ResolverExpand,
extern_mod_loaded: OnExternModLoaded<'a>,
lint_store: LintStoreExpandDyn<'a>,
) -> ExtCtxt<'a> {
ExtCtxt {
sess,
ecfg,
reduced_recursion_limit: None,
resolver,
extern_mod_loaded,
lint_store,
root_path: PathBuf::new(),
current_expansion: ExpansionData {
id: LocalExpnId::ROOT,
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ impl InvocationCollectorNode for P<ast::Item> {
ModKind::Unloaded => {
// We have an outline `mod foo;` so we need to parse the file.
let old_attrs_len = attrs.len();
let ParsedExternalMod { mut items, inner_span, file_path, dir_path, dir_ownership } =
let ParsedExternalMod { items, inner_span, file_path, dir_path, dir_ownership } =
parse_external_mod(
&ecx.sess,
ident,
Expand All @@ -1107,8 +1107,15 @@ impl InvocationCollectorNode for P<ast::Item> {
&mut attrs,
);

if let Some(extern_mod_loaded) = ecx.extern_mod_loaded {
(attrs, items) = extern_mod_loaded(ident, attrs, items, inner_span);
if let Some(lint_store) = ecx.lint_store {
lint_store.pre_expansion_lint(
ecx.sess,
ecx.resolver.registered_tools(),
ecx.current_expansion.lint_node_id,
&attrs,
&items,
ident.name.as_str(),
);
}

*mod_kind = ModKind::Loaded(items, Inline::No, inner_span);
Expand Down
67 changes: 40 additions & 27 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ use crate::proc_macro_decls;
use crate::util;

use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::{self as ast, visit, DUMMY_NODE_ID};
use rustc_ast::{self as ast, visit};
use rustc_borrowck as mir_borrowck;
use rustc_codegen_ssa::back::link::emit_metadata;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::parallel;
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{Applicability, ErrorReported, PResult};
use rustc_expand::base::ExtCtxt;
use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
use rustc_hir::Crate;
use rustc_lint::LintStore;
use rustc_lint::{EarlyCheckNode, LintStore};
use rustc_metadata::creader::CStore;
use rustc_metadata::{encode_metadata, EncodedMetadata};
use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::DepGraph;
use rustc_middle::ty::query::{ExternProviders, Providers};
use rustc_middle::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt};
use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, ResolverOutputs, TyCtxt};
use rustc_mir_build as mir_build;
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str, validate_attr};
use rustc_passes::{self, hir_stats, layout_test};
Expand All @@ -34,7 +34,7 @@ use rustc_session::lint;
use rustc_session::output::{filename_for_input, filename_for_metadata};
use rustc_session::search_paths::PathKind;
use rustc_session::{Limit, Session};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{FileName, MultiSpan};
use rustc_trait_selection::traits;
use rustc_typeck as typeck;
Expand Down Expand Up @@ -233,26 +233,43 @@ pub fn register_plugins<'a>(
Ok((krate, lint_store))
}

fn pre_expansion_lint(
fn pre_expansion_lint<'a>(
sess: &Session,
lint_store: &LintStore,
krate: &ast::Crate,
crate_attrs: &[ast::Attribute],
crate_name: &str,
registered_tools: &RegisteredTools,
check_node: impl EarlyCheckNode<'a>,
node_name: &str,
) {
sess.prof.generic_activity_with_arg("pre_AST_expansion_lint_checks", crate_name).run(|| {
rustc_lint::check_ast_crate(
sess.prof.generic_activity_with_arg("pre_AST_expansion_lint_checks", node_name).run(|| {
rustc_lint::check_ast_node(
sess,
lint_store,
krate,
crate_attrs,
true,
lint_store,
registered_tools,
None,
rustc_lint::BuiltinCombinedPreExpansionLintPass::new(),
check_node,
);
});
}

// Cannot implement directly for `LintStore` due to trait coherence.
struct LintStoreExpandImpl<'a>(&'a LintStore);

impl LintStoreExpand for LintStoreExpandImpl<'_> {
fn pre_expansion_lint(
&self,
sess: &Session,
registered_tools: &RegisteredTools,
node_id: ast::NodeId,
attrs: &[ast::Attribute],
items: &[rustc_ast::ptr::P<ast::Item>],
name: &str,
) {
pre_expansion_lint(sess, self.0, registered_tools, (node_id, attrs, items), name);
}
}

/// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins,
/// syntax expansion, secondary `cfg` expansion, synthesis of a test
/// harness if one is to be provided, injection of a dependency on the
Expand All @@ -265,7 +282,7 @@ pub fn configure_and_expand(
resolver: &mut Resolver<'_>,
) -> Result<ast::Crate> {
tracing::trace!("configure_and_expand");
pre_expansion_lint(sess, lint_store, &krate, &krate.attrs, crate_name);
pre_expansion_lint(sess, lint_store, resolver.registered_tools(), &krate, crate_name);
rustc_builtin_macros::register_builtin_macros(resolver);

krate = sess.time("crate_injection", || {
Expand Down Expand Up @@ -321,13 +338,8 @@ pub fn configure_and_expand(
..rustc_expand::expand::ExpansionConfig::default(crate_name.to_string())
};

let crate_attrs = krate.attrs.clone();
let extern_mod_loaded = |ident: Ident, attrs, items, span| {
let krate = ast::Crate { attrs, items, span, id: DUMMY_NODE_ID, is_placeholder: false };
pre_expansion_lint(sess, lint_store, &krate, &crate_attrs, ident.name.as_str());
(krate.attrs, krate.items)
};
let mut ecx = ExtCtxt::new(sess, cfg, resolver, Some(&extern_mod_loaded));
let lint_store = LintStoreExpandImpl(lint_store);
let mut ecx = ExtCtxt::new(sess, cfg, resolver, Some(&lint_store));

// Expand macros now!
let krate = sess.time("expand_crate", || ecx.monotonic_expander().expand_crate(krate));
Expand Down Expand Up @@ -499,14 +511,15 @@ pub fn lower_to_hir<'res, 'tcx>(
);

sess.time("early_lint_checks", || {
rustc_lint::check_ast_crate(
let lint_buffer = Some(std::mem::take(resolver.lint_buffer()));
rustc_lint::check_ast_node(
sess,
lint_store,
&krate,
&krate.attrs,
false,
Some(std::mem::take(resolver.lint_buffer())),
lint_store,
resolver.registered_tools(),
lint_buffer,
rustc_lint::BuiltinCombinedEarlyLintPass::new(),
&*krate,
)
});

Expand Down
Loading