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 11 pull requests #88568

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
565a519
Update Windows arg parsing tests
ChrisDenton Jul 29, 2021
e26dda5
Implement modern Windows arg parsing
ChrisDenton Aug 5, 2021
4870f06
Remove optimization_fuel_crate from Session
bjorn3 Aug 30, 2021
8553c19
Put back display of associated items (types and consts)
GuillaumeGomez Aug 30, 2021
eb91366
Put back "auto-collapse-implementors" setting
GuillaumeGomez Aug 30, 2021
b99038f
use `unwrap_unchecked` where possible
ibraheemdev Aug 30, 2021
32e639d
Remove print_fuel_crate field of Session
bjorn3 Aug 30, 2021
d988278
Use in_incr_comp_dir_sess in cg_clif
bjorn3 Aug 30, 2021
b88ad42
Add explanation for ctfe_backtrace lock
bjorn3 Aug 31, 2021
99a3d64
Remove single use variables
ptrojahn Aug 31, 2021
ffc43b8
add safety annotation to `LinkedList::detach_all_nodes`
ibraheemdev Aug 31, 2021
8d7d488
Lint Abi in ast validation.
cjgillot Jul 8, 2021
7189c85
Improve closure dummy capture suggestion in macros.
m-ou-se Aug 31, 2021
7d18052
Add test for closure migration where body is a block fragment.
m-ou-se Aug 31, 2021
77a96ed
Include debug info for the allocator shim
dpaoliello Aug 31, 2021
59b245e
fix(rustc_lint): better detect when parens are necessary
notriddle Aug 31, 2021
d7159bd
Add tests for implementors associated types display
GuillaumeGomez Aug 30, 2021
fba4149
Clean render_impl arguments
GuillaumeGomez Aug 31, 2021
6c9e708
`fmt::Formatter::pad`: don't call chars().count() more than one time
klensy Sep 1, 2021
f5f489b
fix clippy lints
klensy Sep 1, 2021
a5fd955
add regression test for issue 83190
lqd Sep 1, 2021
92dae39
Remove implementors setting
GuillaumeGomez Sep 1, 2021
6402071
Rollup merge of #87114 - cjgillot:abilint, r=estebank
GuillaumeGomez Sep 1, 2021
c08d0c0
Rollup merge of #87580 - ChrisDenton:win-arg-parse-2008, r=m-ou-se
GuillaumeGomez Sep 1, 2021
9d052cb
Rollup merge of #88490 - GuillaumeGomez:associated-types-implementors…
GuillaumeGomez Sep 1, 2021
d9c75b1
Rollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm
GuillaumeGomez Sep 1, 2021
4f6211b
Rollup merge of #88530 - bjorn3:shrink_session, r=cjgillot
GuillaumeGomez Sep 1, 2021
348305f
Rollup merge of #88532 - ptrojahn:single_use, r=davidtwco
GuillaumeGomez Sep 1, 2021
bcd740c
Rollup merge of #88543 - m-ou-se:closure-migration-macro-block-fragme…
GuillaumeGomez Sep 1, 2021
30142cb
Rollup merge of #88547 - notriddle:notriddle/is-expr-delims-necessary…
GuillaumeGomez Sep 1, 2021
163c0c9
Rollup merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=este…
GuillaumeGomez Sep 1, 2021
66ef9cc
Rollup merge of #88560 - klensy:formatter-pad-shrink, r=m-ou-se
GuillaumeGomez Sep 1, 2021
f230145
Rollup merge of #88565 - lqd:issue-83190, r=spastorino
GuillaumeGomez Sep 1, 2021
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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,7 @@ dependencies = [
"rustc_parse",
"rustc_session",
"rustc_span",
"rustc_target",
"tracing",
]

Expand Down
37 changes: 13 additions & 24 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
);
let sig = hir::FnSig {
decl,
header: this.lower_fn_header(header, fn_sig_span, id),
header: this.lower_fn_header(header),
span: this.lower_span(fn_sig_span),
};
hir::ItemKind::Fn(sig, generics, body_id)
Expand All @@ -291,17 +291,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),
},
ItemKind::ForeignMod(ref fm) => {
if fm.abi.is_none() {
self.maybe_lint_missing_abi(span, id, abi::Abi::C { unwind: false });
}
hir::ItemKind::ForeignMod {
abi: fm.abi.map_or(abi::Abi::C { unwind: false }, |abi| self.lower_abi(abi)),
items: self
.arena
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
}
}
ItemKind::ForeignMod(ref fm) => hir::ItemKind::ForeignMod {
abi: fm.abi.map_or(abi::Abi::FALLBACK, |abi| self.lower_abi(abi)),
items: self
.arena
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
},
ItemKind::GlobalAsm(ref asm) => {
hir::ItemKind::GlobalAsm(self.lower_inline_asm(span, asm))
}
Expand Down Expand Up @@ -807,7 +802,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, None)) => {
let names = self.lower_fn_params_to_names(&sig.decl);
let (generics, sig) =
self.lower_method_sig(generics, sig, trait_item_def_id, false, None, i.id);
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(names)))
}
AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, Some(ref body))) => {
Expand All @@ -820,7 +815,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
trait_item_def_id,
false,
asyncness.opt_return_id(),
i.id,
);
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id)))
}
Expand Down Expand Up @@ -897,7 +891,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
impl_item_def_id,
impl_trait_return_allow,
asyncness.opt_return_id(),
i.id,
);

(generics, hir::ImplItemKind::Fn(sig, body_id))
Expand Down Expand Up @@ -1292,9 +1285,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn_def_id: LocalDefId,
impl_trait_return_allow: bool,
is_async: Option<NodeId>,
id: NodeId,
) -> (hir::Generics<'hir>, hir::FnSig<'hir>) {
let header = self.lower_fn_header(sig.header, sig.span, id);
let header = self.lower_fn_header(sig.header);
let (generics, decl) = self.add_in_band_defs(
generics,
fn_def_id,
Expand All @@ -1311,12 +1303,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
(generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })
}

fn lower_fn_header(&mut self, h: FnHeader, span: Span, id: NodeId) -> hir::FnHeader {
fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
hir::FnHeader {
unsafety: self.lower_unsafety(h.unsafety),
asyncness: self.lower_asyncness(h.asyncness),
constness: self.lower_constness(h.constness),
abi: self.lower_extern(h.ext, span, id),
abi: self.lower_extern(h.ext),
}
}

Expand All @@ -1327,13 +1319,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
})
}

pub(super) fn lower_extern(&mut self, ext: Extern, span: Span, id: NodeId) -> abi::Abi {
pub(super) fn lower_extern(&mut self, ext: Extern) -> abi::Abi {
match ext {
Extern::None => abi::Abi::Rust,
Extern::Implicit => {
self.maybe_lint_missing_abi(span, id, abi::Abi::C { unwind: false });
abi::Abi::C { unwind: false }
}
Extern::Implicit => abi::Abi::FALLBACK,
Extern::Explicit(abi) => self.lower_abi(abi),
}
}
Expand Down
26 changes: 2 additions & 24 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use rustc_hir::definitions::{DefKey, DefPathData, Definitions};
use rustc_hir::intravisit;
use rustc_hir::{ConstArg, GenericArg, InferKind, ParamName};
use rustc_index::vec::{Idx, IndexVec};
use rustc_session::lint::builtin::{BARE_TRAIT_OBJECTS, MISSING_ABI};
use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS;
use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer};
use rustc_session::utils::{FlattenNonterminals, NtToTokenstream};
use rustc_session::Session;
Expand All @@ -62,7 +62,6 @@ use rustc_span::hygiene::ExpnId;
use rustc_span::source_map::{respan, CachingSourceMapView, DesugaringKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::spec::abi::Abi;

use smallvec::SmallVec;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -1361,15 +1360,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
TyKind::BareFn(ref f) => self.with_in_scope_lifetime_defs(&f.generic_params, |this| {
this.with_anonymous_lifetime_mode(AnonymousLifetimeMode::PassThrough, |this| {
let span = this.sess.source_map().next_point(t.span.shrink_to_lo());
hir::TyKind::BareFn(this.arena.alloc(hir::BareFnTy {
generic_params: this.lower_generic_params(
&f.generic_params,
&NodeMap::default(),
ImplTraitContext::disallowed(),
),
unsafety: this.lower_unsafety(f.unsafety),
abi: this.lower_extern(f.ext, span, t.id),
abi: this.lower_extern(f.ext),
decl: this.lower_fn_decl(&f.decl, None, false, None),
param_names: this.lower_fn_params_to_names(&f.decl),
}))
Expand Down Expand Up @@ -2749,26 +2747,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
}

fn maybe_lint_missing_abi(&mut self, span: Span, id: NodeId, default: Abi) {
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
// call site which do not have a macro backtrace. See #61963.
let is_macro_callsite = self
.sess
.source_map()
.span_to_snippet(span)
.map(|snippet| snippet.starts_with("#["))
.unwrap_or(true);
if !is_macro_callsite {
self.resolver.lint_buffer().buffer_lint_with_diagnostic(
MISSING_ABI,
id,
span,
"extern declarations without an explicit ABI are deprecated",
BuiltinLintDiagnostics::MissingAbi(span, default),
)
}
}
}

fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'_>>) -> Vec<hir::BodyId> {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_passes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ rustc_feature = { path = "../rustc_feature" }
rustc_parse = { path = "../rustc_parse" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_ast = { path = "../rustc_ast" }
43 changes: 41 additions & 2 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{error_code, pluralize, struct_span_err, Applicability};
use rustc_parse::validate_attr;
use rustc_session::lint::builtin::PATTERNS_IN_FNS_WITHOUT_BODY;
use rustc_session::lint::builtin::{MISSING_ABI, PATTERNS_IN_FNS_WITHOUT_BODY};
use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer};
use rustc_session::Session;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use rustc_target::spec::abi;
use std::mem;
use std::ops::DerefMut;

Expand Down Expand Up @@ -844,6 +845,10 @@ impl<'a> AstValidator<'a> {
.emit();
});
self.check_late_bound_lifetime_defs(&bfty.generic_params);
if let Extern::Implicit = bfty.ext {
let sig_span = self.session.source_map().next_point(ty.span.shrink_to_lo());
self.maybe_lint_missing_abi(sig_span, ty.id);
}
}
TyKind::TraitObject(ref bounds, ..) => {
let mut any_lifetime_bounds = false;
Expand Down Expand Up @@ -894,6 +899,26 @@ impl<'a> AstValidator<'a> {
_ => {}
}
}

fn maybe_lint_missing_abi(&mut self, span: Span, id: NodeId) {
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
// call site which do not have a macro backtrace. See #61963.
let is_macro_callsite = self
.session
.source_map()
.span_to_snippet(span)
.map(|snippet| snippet.starts_with("#["))
.unwrap_or(true);
if !is_macro_callsite {
self.lint_buffer.buffer_lint_with_diagnostic(
MISSING_ABI,
id,
span,
"extern declarations without an explicit ABI are deprecated",
BuiltinLintDiagnostics::MissingAbi(span, abi::Abi::FALLBACK),
)
}
}
}

/// Checks that generic parameters are in the correct order,
Expand Down Expand Up @@ -1178,7 +1203,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
walk_list!(self, visit_attribute, &item.attrs);
return; // Avoid visiting again.
}
ItemKind::ForeignMod(ForeignMod { unsafety, .. }) => {
ItemKind::ForeignMod(ForeignMod { abi, unsafety, .. }) => {
let old_item = mem::replace(&mut self.extern_mod, Some(item));
self.invalid_visibility(
&item.vis,
Expand All @@ -1187,6 +1212,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
if let Unsafe::Yes(span) = unsafety {
self.err_handler().span_err(span, "extern block cannot be declared unsafe");
}
if abi.is_none() {
self.maybe_lint_missing_abi(item.span, item.id);
}
visit::walk_item(self, item);
self.extern_mod = old_item;
return; // Avoid visiting again.
Expand Down Expand Up @@ -1526,6 +1554,17 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
.emit();
}

if let FnKind::Fn(
_,
_,
FnSig { span: sig_span, header: FnHeader { ext: Extern::Implicit, .. }, .. },
_,
_,
) = fk
{
self.maybe_lint_missing_abi(*sig_span, id);
}

// Functions without bodies cannot have patterns.
if let FnKind::Fn(ctxt, _, sig, _, None) = fk {
Self::check_decl_no_pat(&sig.decl, |span, ident, mut_ident| {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ fn reuse_workproduct_for_cgu(
cgu: &CodegenUnit<'_>,
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
) -> CompiledModule {
let incr_comp_session_dir = tcx.sess.incr_comp_session_dir();
let mut object = None;
let work_product = cgu.work_product(tcx);
if let Some(saved_file) = &work_product.saved_file {
let obj_out =
tcx.output_filenames(()).temp_path(OutputType::Object, Some(&cgu.name().as_str()));
object = Some(obj_out.clone());
let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
tcx.sess.err(&format!(
"unable to copy {} to {}: {}",
Expand Down
15 changes: 12 additions & 3 deletions compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ use libc::c_uint;
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
use rustc_middle::bug;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::DebugInfo;
use rustc_span::symbol::sym;

use crate::debuginfo;
use crate::llvm::{self, False, True};
use crate::ModuleLlvm;

pub(crate) unsafe fn codegen(
tcx: TyCtxt<'_>,
mods: &mut ModuleLlvm,
module_llvm: &mut ModuleLlvm,
module_name: &str,
kind: AllocatorKind,
has_alloc_error_handler: bool,
) {
let llcx = &*mods.llcx;
let llmod = mods.llmod();
let llcx = &*module_llvm.llcx;
let llmod = module_llvm.llmod();
let usize = match tcx.sess.target.pointer_width {
16 => llvm::LLVMInt16TypeInContext(llcx),
32 => llvm::LLVMInt32TypeInContext(llcx),
Expand Down Expand Up @@ -132,4 +135,10 @@ pub(crate) unsafe fn codegen(
llvm::LLVMSetTailCall(ret, True);
llvm::LLVMBuildRetVoid(llbuilder);
llvm::LLVMDisposeBuilder(llbuilder);

if tcx.sess.opts.debuginfo != DebugInfo::None {
let dbg_cx = debuginfo::CrateDebugContext::new(llmod);
debuginfo::metadata::compile_unit_metadata(tcx, module_name, &dbg_cx);
dbg_cx.finalize(tcx.sess);
}
}
Loading