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 10 pull requests #104307

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a052f2c
Add the `#[derive_const]` attribute
fee1-dead Sep 20, 2022
9bcc083
run-make-fulldeps: fix split debuginfo test
davidtwco Nov 7, 2022
29dc083
llvm: dwo only emitted when object code emitted
davidtwco Nov 7, 2022
0e0bcd9
prevent uninitialized access in black_box for zero-sized-types
krasimirgg Nov 4, 2022
bdced83
Use ObligationCtxt in expected_inputs_for_expected_outputs
compiler-errors Nov 9, 2022
ed6a7cc
Remove save_and_restore_in_snapshot_flag
compiler-errors Nov 9, 2022
63217e0
make dropck_outlives into a proper canonicalized type query
compiler-errors Nov 9, 2022
3074678
Mark `trait_upcasting` feature no longer incomplete.
crlf0710 Nov 7, 2022
c467006
suggest removing unnecessary . to use a floating point literal
TaKO8Ki Nov 8, 2022
004986b
avoid unnecessary `format!`
TaKO8Ki Nov 8, 2022
6018f11
emit errors when using `RangeFrom` and `RangeTo`
TaKO8Ki Nov 9, 2022
84e1fbc
Add no_std AArch64 support for the QNX Neutrino (nto) 7.1 RTOS
flba-eb Sep 5, 2022
ae71df9
Add `nto` as known `target_os`
flba-eb Oct 5, 2022
014f7f4
Remove some redundant arguments
oli-obk Nov 3, 2022
21ce587
Don't add message that will never be shown to users
oli-obk Nov 11, 2022
df2adc4
Print all labels, even if they have no span. Fall back to main item's…
oli-obk Nov 4, 2022
f149837
Add Tristan as maintainer
flba-eb Nov 11, 2022
f6d7f08
Issue error when `-C link-self-contained` option is used on unsupport…
StackDoubleFlow Nov 8, 2022
934c414
Update cargo
weihanglo Nov 11, 2022
2c5a883
Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obk
Manishearth Nov 11, 2022
293b4f7
Rollup merge of #102701 - flba-eb:add_qnx_nostd_support, r=cjgillot
Manishearth Nov 11, 2022
06244ed
Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=estebank
Manishearth Nov 11, 2022
a36e1ac
Rollup merge of #104105 - davidtwco:split-dwarf-lto, r=michaelwoerister
Manishearth Nov 11, 2022
cc1fddc
Rollup merge of #104110 - krasimirgg:msan-16, r=nagisa
Manishearth Nov 11, 2022
dd4b803
Rollup merge of #104117 - crlf0710:update_feature_gate, r=jackh726
Manishearth Nov 11, 2022
64df701
Rollup merge of #104137 - StackDoubleFlow:err-lsc-unsupported, r=petr…
Manishearth Nov 11, 2022
e944a06
Rollup merge of #104144 - TaKO8Ki:suggest-removing-unnecessary-dot, r…
Manishearth Nov 11, 2022
c77bd67
Rollup merge of #104206 - compiler-errors:ocx-more-2, r=lcnr
Manishearth Nov 11, 2022
e93dae2
Rollup merge of #104302 - weihanglo:update-cargo, r=weihanglo
Manishearth Nov 11, 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
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ dependencies = [

[[package]]
name = "cargo"
version = "0.67.0"
version = "0.68.0"
dependencies = [
"anyhow",
"atty",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/cfg_accessible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl MultiItemModifier for Expander {
span: Span,
meta_item: &ast::MetaItem,
item: Annotatable,
_is_derive_const: bool,
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
let template = AttributeTemplate { list: Some("path"), ..Default::default() };
let attr = &ecx.attribute(meta_item.clone());
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_builtin_macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_session::Session;
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;

pub(crate) struct Expander;
pub(crate) struct Expander(pub bool);

impl MultiItemModifier for Expander {
fn expand(
Expand All @@ -19,6 +19,7 @@ impl MultiItemModifier for Expander {
span: Span,
meta_item: &ast::MetaItem,
item: Annotatable,
_: bool,
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
let sess = ecx.sess;
if report_bad_target(sess, &item, span) {
Expand Down Expand Up @@ -58,20 +59,20 @@ impl MultiItemModifier for Expander {
report_path_args(sess, &meta);
meta.path
})
.map(|path| (path, dummy_annotatable(), None))
.map(|path| (path, dummy_annotatable(), None, self.0))
.collect();

// Do not configure or clone items unless necessary.
match &mut resolutions[..] {
[] => {}
[(_, first_item, _), others @ ..] => {
[(_, first_item, ..), others @ ..] => {
*first_item = cfg_eval(
sess,
features,
item.clone(),
ecx.current_expansion.lint_node_id,
);
for (_, item, _) in others {
for (_, item, _, _) in others {
*item = first_item.clone();
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub fn expand_deriving_copy(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let trait_def = TraitDef {
span,
Expand All @@ -22,6 +23,7 @@ pub fn expand_deriving_copy(
supports_unions: true,
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
};

trait_def.expand(cx, mitem, item, push);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn expand_deriving_clone(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
// The simple form is `fn clone(&self) -> Self { *self }`, possibly with
// some additional `AssertParamIsClone` assertions.
Expand Down Expand Up @@ -87,6 +88,7 @@ pub fn expand_deriving_clone(
combine_substructure: substructure,
}],
associated_types: Vec::new(),
is_const,
};

trait_def.expand_ext(cx, mitem, item, push, is_simple)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn expand_deriving_eq(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let span = cx.with_def_site_ctxt(span);
let inline = cx.meta_word(span, sym::inline);
Expand Down Expand Up @@ -42,6 +43,7 @@ pub fn expand_deriving_eq(
})),
}],
associated_types: Vec::new(),
is_const,
};

super::inject_impl_of_structural_trait(cx, span, item, path_std!(marker::StructuralEq), push);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn expand_deriving_ord(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let inline = cx.meta_word(span, sym::inline);
let attrs = thin_vec![cx.attribute(inline)];
Expand All @@ -34,6 +35,7 @@ pub fn expand_deriving_ord(
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
}],
associated_types: Vec::new(),
is_const,
};

trait_def.expand(cx, mitem, item, push)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn expand_deriving_partial_eq(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let base = true;
Expand Down Expand Up @@ -89,6 +90,7 @@ pub fn expand_deriving_partial_eq(
supports_unions: false,
methods,
associated_types: Vec::new(),
is_const,
};
trait_def.expand(cx, mitem, item, push)
}
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn expand_deriving_partial_ord(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let ordering_ty = Path(path_std!(cmp::Ordering));
let ret_ty =
Expand Down Expand Up @@ -43,6 +44,7 @@ pub fn expand_deriving_partial_ord(
supports_unions: false,
methods: vec![partial_cmp_def],
associated_types: Vec::new(),
is_const,
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn expand_deriving_debug(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
// &mut ::std::fmt::Formatter
let fmtr = Ref(Box::new(Path(path_std!(fmt::Formatter))), ast::Mutability::Mut);
Expand All @@ -37,6 +38,7 @@ pub fn expand_deriving_debug(
})),
}],
associated_types: Vec::new(),
is_const,
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn expand_deriving_rustc_decodable(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let krate = sym::rustc_serialize;
let typaram = sym::__D;
Expand Down Expand Up @@ -55,6 +56,7 @@ pub fn expand_deriving_rustc_decodable(
})),
}],
associated_types: Vec::new(),
is_const,
};

trait_def.expand(cx, mitem, item, push)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn expand_deriving_default(
mitem: &ast::MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
item.visit_with(&mut DetectNonVariantDefaultAttr { cx });

Expand Down Expand Up @@ -47,6 +48,7 @@ pub fn expand_deriving_default(
})),
}],
associated_types: Vec::new(),
is_const,
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub fn expand_deriving_rustc_encodable(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let krate = sym::rustc_serialize;
let typaram = sym::__S;
Expand Down Expand Up @@ -139,6 +140,7 @@ pub fn expand_deriving_rustc_encodable(
})),
}],
associated_types: Vec::new(),
is_const,
};

trait_def.expand(cx, mitem, item, push)
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ use rustc_ast::{GenericArg, GenericParamKind, VariantData};
use rustc_attr as attr;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use rustc_span::{Span, DUMMY_SP};
use std::cell::RefCell;
use std::iter;
use std::ops::Not;
Expand Down Expand Up @@ -204,6 +204,8 @@ pub struct TraitDef<'a> {
pub methods: Vec<MethodDef<'a>>,

pub associated_types: Vec<(Ident, Ty)>,

pub is_const: bool,
}

pub struct MethodDef<'a> {
Expand Down Expand Up @@ -730,7 +732,7 @@ impl<'a> TraitDef<'a> {
unsafety: ast::Unsafe::No,
polarity: ast::ImplPolarity::Positive,
defaultness: ast::Defaultness::Final,
constness: ast::Const::No,
constness: if self.is_const { ast::Const::Yes(DUMMY_SP) } else { ast::Const::No },
generics: trait_generics,
of_trait: opt_trait_ref,
self_ty: self_type,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn expand_deriving_hash(
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let path = Path::new_(pathvec_std!(hash::Hash), vec![], PathKind::Std);

Expand All @@ -39,6 +40,7 @@ pub fn expand_deriving_hash(
})),
}],
associated_types: Vec::new(),
is_const,
};

hash_trait_def.expand(cx, mitem, item, push);
Expand Down
35 changes: 22 additions & 13 deletions compiler/rustc_builtin_macros/src/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ pub mod partial_ord;

pub mod generic;

pub(crate) struct BuiltinDerive(
pub(crate) fn(&mut ExtCtxt<'_>, Span, &MetaItem, &Annotatable, &mut dyn FnMut(Annotatable)),
);
pub(crate) type BuiltinDeriveFn =
fn(&mut ExtCtxt<'_>, Span, &MetaItem, &Annotatable, &mut dyn FnMut(Annotatable), bool);

pub(crate) struct BuiltinDerive(pub(crate) BuiltinDeriveFn);

impl MultiItemModifier for BuiltinDerive {
fn expand(
Expand All @@ -49,6 +50,7 @@ impl MultiItemModifier for BuiltinDerive {
span: Span,
meta_item: &MetaItem,
item: Annotatable,
is_derive_const: bool,
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
// FIXME: Built-in derives often forget to give spans contexts,
// so we are doing it here in a centralized way.
Expand All @@ -57,21 +59,28 @@ impl MultiItemModifier for BuiltinDerive {
match item {
Annotatable::Stmt(stmt) => {
if let ast::StmtKind::Item(item) = stmt.into_inner().kind {
(self.0)(ecx, span, meta_item, &Annotatable::Item(item), &mut |a| {
// Cannot use 'ecx.stmt_item' here, because we need to pass 'ecx'
// to the function
items.push(Annotatable::Stmt(P(ast::Stmt {
id: ast::DUMMY_NODE_ID,
kind: ast::StmtKind::Item(a.expect_item()),
span,
})));
});
(self.0)(
ecx,
span,
meta_item,
&Annotatable::Item(item),
&mut |a| {
// Cannot use 'ecx.stmt_item' here, because we need to pass 'ecx'
// to the function
items.push(Annotatable::Stmt(P(ast::Stmt {
id: ast::DUMMY_NODE_ID,
kind: ast::StmtKind::Item(a.expect_item()),
span,
})));
},
is_derive_const,
);
} else {
unreachable!("should have already errored on non-item statement")
}
}
_ => {
(self.0)(ecx, span, meta_item, &item, &mut |a| items.push(a));
(self.0)(ecx, span, meta_item, &item, &mut |a| items.push(a), is_derive_const);
}
}
ExpandResult::Ready(items)
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
bench: test::expand_bench,
cfg_accessible: cfg_accessible::Expander,
cfg_eval: cfg_eval::expand,
derive: derive::Expander,
derive: derive::Expander(false),
derive_const: derive::Expander(true),
global_allocator: global_allocator::expand,
test: test::expand_test,
test_case: test::expand_test_case,
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,21 @@ pub(crate) unsafe fn codegen(
drop(handlers);
}

// `.dwo` files are only emitted if:
//
// - Object files are being emitted (i.e. bitcode only or metadata only compilations will not
// produce dwarf objects, even if otherwise enabled)
// - Target supports Split DWARF
// - Split debuginfo is enabled
// - Split DWARF kind is `split` (i.e. debuginfo is split into `.dwo` files, not different
// sections in the `.o` files).
let dwarf_object_emitted = matches!(config.emit_obj, EmitObj::ObjectCode(_))
&& cgcx.target_can_use_split_dwarf
&& cgcx.split_debuginfo != SplitDebuginfo::Off
&& cgcx.split_dwarf_kind == SplitDwarfKind::Split;
Ok(module.into_compiled_module(
config.emit_obj != EmitObj::None,
cgcx.target_can_use_split_dwarf
&& cgcx.split_debuginfo != SplitDebuginfo::Off
&& cgcx.split_dwarf_kind == SplitDwarfKind::Split,
dwarf_object_emitted,
config.emit_bc,
&cgcx.output_filenames,
))
Expand Down
15 changes: 12 additions & 3 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,26 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {

sym::black_box => {
args[0].val.store(self, result);

let result_val_span = [result.llval];
// We need to "use" the argument in some way LLVM can't introspect, and on
// targets that support it we can typically leverage inline assembly to do
// this. LLVM's interpretation of inline assembly is that it's, well, a black
// box. This isn't the greatest implementation since it probably deoptimizes
// more than we want, but it's so far good enough.
//
// For zero-sized types, the location pointed to by the result may be
// uninitialized. Do not "use" the result in this case; instead just clobber
// the memory.
let (constraint, inputs): (&str, &[_]) = if result.layout.is_zst() {
("~{memory}", &[])
} else {
("r,~{memory}", &result_val_span)
};
crate::asm::inline_asm_call(
self,
"",
"r,~{memory}",
&[result.llval],
constraint,
inputs,
self.type_void(),
true,
false,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,9 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
/// We only provide such support for a very limited number of targets.
fn self_contained(sess: &Session, crate_type: CrateType) -> bool {
if let Some(self_contained) = sess.opts.cg.link_self_contained {
if sess.target.link_self_contained == LinkSelfContainedDefault::False {
sess.emit_err(errors::UnsupportedLinkSelfContained);
}
return self_contained;
}

Expand Down
Loading