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 16 pull requests #96069

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f427698
Parse inner attributes on inline const block
dtolnay Mar 16, 2022
3f7f5e8
Optimize RcInnerPtr::inc_strong instruction count
mjbshaw Mar 23, 2022
f5dd42b
Format unsafe {} blocks
mjbshaw Mar 23, 2022
8d14c03
Explicitly mention overflow is what we're checking
mjbshaw Mar 23, 2022
9cfdb89
Only add codegen backend to dep info if -Zbinary-dep-depinfo is used
bjorn3 Feb 13, 2022
c681a88
Don't include invalid paths in the depinfo for builtin backends
bjorn3 Feb 13, 2022
147e5da
Add test
bjorn3 Mar 24, 2022
8035796
Stablize `const_extern_fn` for "Rust" and "C"
Aaron1011 Mar 26, 2022
6b75406
Create 2024 edition
jhpratt Feb 28, 2022
98190b7
Revert "Work around invalid DWARF bugs for fat LTO"
cbiffle Apr 4, 2022
42af197
Improve debuginfo test coverage for simple statics.
cbiffle Apr 5, 2022
7bd22e2
only downgrade Error -> Ambiguous if type error is in predicate
compiler-errors Apr 7, 2022
edeb826
Inline shallow_resolve_ty into ShallowResolver
compiler-errors Apr 10, 2022
7f945b2
add simd_arith_offset intrinsics
RalfJung Apr 12, 2022
e886dc5
portable-simd: use simd_arith_offset to avoid ptr-int transmutation
RalfJung Apr 12, 2022
69de213
Fix `x test --doc --stage 0 library/std`
jyn514 Apr 13, 2022
eb905c0
add codegen smoke test
RalfJung Apr 13, 2022
7c2d57e
couple of clippy::complexity fixes
matthiaskrgr Apr 13, 2022
21d3f84
test: add is_superset test cases for BTreeSet
Gumichocopengin8 Apr 14, 2022
50c339e
test: add remove() test cases for BTreeSet
Gumichocopengin8 Apr 14, 2022
1e78a47
:arrow_up: rust-analyzer
lnicola Apr 14, 2022
9d319f3
update: actions/checkout@v2 to actions/checkout@v3
Gumichocopengin8 Apr 14, 2022
c20bb1d
Update issue-92893.stderr
ouz-a Apr 14, 2022
5459e66
docs: Update tests chapter for Termination stabilization
ehuss Apr 14, 2022
8f5fd4c
Rollup merge of #93969 - bjorn3:codegen_backend_dep_info, r=pnkfelix
fee1-dead Apr 15, 2022
9646009
Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix
fee1-dead Apr 15, 2022
a0e3d80
Rollup merge of #94849 - ouz-a:master4, r=oli-obk
fee1-dead Apr 15, 2022
851cb4b
Rollup merge of #94985 - dtolnay:constattr, r=pnkfelix
fee1-dead Apr 15, 2022
3b9b3fb
Rollup merge of #95224 - mjbshaw:patch-1, r=yaahc
fee1-dead Apr 15, 2022
4d3e076
Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelix
fee1-dead Apr 15, 2022
7a815c7
Rollup merge of #95685 - oxidecomputer:restore-static-dwarf, r=pnkfelix
fee1-dead Apr 15, 2022
ef8cf01
Rollup merge of #95749 - compiler-errors:ambig, r=oli-obk
fee1-dead Apr 15, 2022
b82ae65
Rollup merge of #95908 - compiler-errors:shallow_resolve_ty-inline, r…
fee1-dead Apr 15, 2022
95ec29e
Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee
fee1-dead Apr 15, 2022
df2f5f0
Rollup merge of #95993 - jyn514:fix-stage0-doctests, r=Mark-Simulacrum
fee1-dead Apr 15, 2022
c2137f3
Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPC
fee1-dead Apr 15, 2022
ffe46cd
Rollup merge of #96034 - Gumichocopengin8:test/btree-set, r=Dylan-DPC
fee1-dead Apr 15, 2022
0bde871
Rollup merge of #96035 - Gumichocopengin8:feature/update-github-actio…
fee1-dead Apr 15, 2022
0caff27
Rollup merge of #96047 - lnicola:rust-analyzer-2022-04-14, r=lnicola
fee1-dead Apr 15, 2022
21b45bf
Rollup merge of #96062 - ehuss:test-termination, r=Dylan-DPC
fee1-dead Apr 15, 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down Expand Up @@ -454,7 +454,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down Expand Up @@ -567,7 +567,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down Expand Up @@ -670,7 +670,7 @@ jobs:
if: "github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'rust-lang-ci/rust'"
steps:
- name: checkout the source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: publish toolstate
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ impl NonterminalKind {
Edition::Edition2015 | Edition::Edition2018 => {
NonterminalKind::PatParam { inferred: true }
}
Edition::Edition2021 => NonterminalKind::PatWithOr,
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
},
sym::pat_param => NonterminalKind::PatParam { inferred: false },
sym::expr => NonterminalKind::Expr,
Expand Down
37 changes: 20 additions & 17 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,22 @@ struct PostExpansionVisitor<'a> {
}

impl<'a> PostExpansionVisitor<'a> {
fn check_abi(&self, abi: ast::StrLit) {
fn check_abi(&self, abi: ast::StrLit, constness: ast::Const) {
let ast::StrLit { symbol_unescaped, span, .. } = abi;

if let ast::Const::Yes(_) = constness {
match symbol_unescaped.as_str() {
// Stable
"Rust" | "C" => {}
abi => gate_feature_post!(
&self,
const_extern_fn,
span,
&format!("`{}` as a `const fn` ABI is unstable", abi)
),
}
}

match symbol_unescaped.as_str() {
// Stable
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
Expand Down Expand Up @@ -261,9 +274,9 @@ impl<'a> PostExpansionVisitor<'a> {
}
}

fn check_extern(&self, ext: ast::Extern) {
fn check_extern(&self, ext: ast::Extern, constness: ast::Const) {
if let ast::Extern::Explicit(abi) = ext {
self.check_abi(abi);
self.check_abi(abi, constness);
}
}

Expand Down Expand Up @@ -437,7 +450,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
match i.kind {
ast::ItemKind::ForeignMod(ref foreign_module) => {
if let Some(abi) = foreign_module.abi {
self.check_abi(abi);
self.check_abi(abi, ast::Const::No);
}
}

Expand Down Expand Up @@ -560,7 +573,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
fn visit_ty(&mut self, ty: &'a ast::Ty) {
match ty.kind {
ast::TyKind::BareFn(ref bare_fn_ty) => {
self.check_extern(bare_fn_ty.ext);
// Function pointers cannot be `const`
self.check_extern(bare_fn_ty.ext, ast::Const::No);
}
ast::TyKind::Never => {
gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental");
Expand Down Expand Up @@ -660,18 +674,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) {
if let Some(header) = fn_kind.header() {
// Stability of const fn methods are covered in `visit_assoc_item` below.
self.check_extern(header.ext);

if let (ast::Const::Yes(_), ast::Extern::Implicit)
| (ast::Const::Yes(_), ast::Extern::Explicit(_)) = (header.constness, header.ext)
{
gate_feature_post!(
&self,
const_extern_fn,
span,
"`const extern fn` definitions are unstable"
);
}
self.check_extern(header.ext, header.constness);
}

if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() {
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 @@ -959,7 +959,7 @@ impl<'a> State<'a> {
self.word_space("=");
match term {
Term::Ty(ty) => self.print_type(ty),
Term::Const(c) => self.print_expr_anon_const(c),
Term::Const(c) => self.print_expr_anon_const(c, &[]),
}
}
ast::AssocConstraintKind::Bound { bounds } => self.print_type_bounds(":", &*bounds),
Expand Down
17 changes: 14 additions & 3 deletions compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ impl<'a> State<'a> {
self.end();
}

pub(super) fn print_expr_anon_const(&mut self, expr: &ast::AnonConst) {
pub(super) fn print_expr_anon_const(
&mut self,
expr: &ast::AnonConst,
attrs: &[ast::Attribute],
) {
self.ibox(INDENT_UNIT);
self.word("const");
self.print_expr(&expr.value);
self.nbsp();
if let ast::ExprKind::Block(block, None) = &expr.value.kind {
self.cbox(0);
self.ibox(0);
self.print_block_with_attrs(block, attrs);
} else {
self.print_expr(&expr.value);
}
self.end();
}

Expand Down Expand Up @@ -275,7 +286,7 @@ impl<'a> State<'a> {
self.print_expr_vec(exprs);
}
ast::ExprKind::ConstBlock(ref anon_const) => {
self.print_expr_anon_const(anon_const);
self.print_expr_anon_const(anon_const, attrs);
}
ast::ExprKind::Repeat(ref element, ref count) => {
self.print_expr_repeat(element, count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub fn inject(
Edition2015 => sym::rust_2015,
Edition2018 => sym::rust_2018,
Edition2021 => sym::rust_2021,
Edition2024 => sym::rust_2024,
}])
.map(|&symbol| Ident::new(symbol, span))
.collect();
Expand Down
18 changes: 2 additions & 16 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,6 @@ fn fat_lto(
drop(linker);
save_temp_bitcode(cgcx, &module, "lto.input");

// Fat LTO also suffers from the invalid DWARF issue similar to Thin LTO.
// Here we rewrite all `DICompileUnit` pointers if there is only one `DICompileUnit`.
// This only works around the problem when codegen-units = 1.
// Refer to the comments in the `optimize_thin_module` function for more details.
let mut cu1 = ptr::null_mut();
let mut cu2 = ptr::null_mut();
unsafe { llvm::LLVMRustLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2) };
if !cu2.is_null() {
let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_fat_lto_patch_debuginfo", &*module.name);
unsafe { llvm::LLVMRustLTOPatchDICompileUnit(llmod, cu1) };
save_temp_bitcode(cgcx, &module, "fat-lto-after-patch");
}

// Internalize everything below threshold to help strip out more modules and such.
unsafe {
let ptr = symbols_below_threshold.as_ptr();
Expand Down Expand Up @@ -757,7 +743,7 @@ pub unsafe fn optimize_thin_module(
// an error.
let mut cu1 = ptr::null_mut();
let mut cu2 = ptr::null_mut();
llvm::LLVMRustLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
llvm::LLVMRustThinLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
if !cu2.is_null() {
let msg = "multiple source DICompileUnits found";
return Err(write::llvm_err(&diag_handler, msg));
Expand Down Expand Up @@ -846,7 +832,7 @@ pub unsafe fn optimize_thin_module(
let _timer = cgcx
.prof
.generic_activity_with_arg("LLVM_thin_lto_patch_debuginfo", thin_module.name());
llvm::LLVMRustLTOPatchDICompileUnit(llmod, cu1);
llvm::LLVMRustThinLTOPatchDICompileUnit(llmod, cu1);
save_temp_bitcode(cgcx, &module, "thin-lto-after-patch");
}

Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,27 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
simd_neg: Int => neg, Float => fneg;
}

if name == sym::simd_arith_offset {
// This also checks that the first operand is a ptr type.
let pointee = in_elem.builtin_deref(true).unwrap_or_else(|| {
span_bug!(span, "must be called with a vector of pointer types as first argument")
});
let layout = bx.layout_of(pointee.ty);
let ptrs = args[0].immediate();
// The second argument must be a ptr-sized integer.
// (We don't care about the signedness, this is wrapping anyway.)
let (_offsets_len, offsets_elem) = arg_tys[1].simd_size_and_type(bx.tcx());
if !matches!(offsets_elem.kind(), ty::Int(ty::IntTy::Isize) | ty::Uint(ty::UintTy::Usize)) {
span_bug!(
span,
"must be called with a vector of pointer-sized integers as second argument"
);
}
let offsets = args[1].immediate();

return Ok(bx.gep(bx.backend_type(layout), ptrs, &[offsets]));
}

if name == sym::simd_saturating_add || name == sym::simd_saturating_sub {
let lhs = args[0].immediate();
let rhs = args[1].immediate();
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2506,8 +2506,12 @@ extern "C" {
len: usize,
out_len: &mut usize,
) -> *const u8;
pub fn LLVMRustLTOGetDICompileUnit(M: &Module, CU1: &mut *mut c_void, CU2: &mut *mut c_void);
pub fn LLVMRustLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
pub fn LLVMRustThinLTOGetDICompileUnit(
M: &Module,
CU1: &mut *mut c_void,
CU2: &mut *mut c_void,
);
pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);

pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
pub fn LLVMRustLinkerAdd(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ impl Diagnostic {
name: impl Into<Cow<'static, str>>,
arg: DiagnosticArgValue<'static>,
) -> &mut Self {
self.args.push((name.into(), arg.into()));
self.args.push((name.into(), arg));
self
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fn check_binders(
MISSING_FRAGMENT_SPECIFIER,
span,
node_id,
&format!("missing fragment specifier"),
"missing fragment specifier",
);
}
if !macros.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ fn check_matcher_core<'tt>(
err.span_label(sp, format!("not allowed after `{}` fragments", kind));

if kind == NonterminalKind::PatWithOr
&& sess.edition == Edition::Edition2021
&& sess.edition.rust_2021()
&& next_token.is_token(&BinOp(token::BinOpToken::Or))
{
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// common state. Used in coherence.
pub fn fork(&self) -> Self {
Self {
tcx: self.tcx.clone(),
defining_use_anchor: self.defining_use_anchor.clone(),
in_progress_typeck_results: self.in_progress_typeck_results.clone(),
tcx: self.tcx,
defining_use_anchor: self.defining_use_anchor,
in_progress_typeck_results: self.in_progress_typeck_results,
inner: self.inner.clone(),
skip_leak_check: self.skip_leak_check.clone(),
lexical_region_resolutions: self.lexical_region_resolutions.clone(),
Expand Down
83 changes: 39 additions & 44 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1659,49 +1659,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
self.tcx.const_eval_resolve(param_env_erased, unevaluated, span)
}

/// If `typ` is a type variable of some kind, resolve it one level
/// (but do not resolve types found in the result). If `typ` is
/// not a type variable, just return it unmodified.
// FIXME(eddyb) inline into `ShallowResolver::visit_ty`.
fn shallow_resolve_ty(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
match *typ.kind() {
ty::Infer(ty::TyVar(v)) => {
// Not entirely obvious: if `typ` is a type variable,
// it can be resolved to an int/float variable, which
// can then be recursively resolved, hence the
// recursion. Note though that we prevent type
// variables from unifying to other type variables
// directly (though they may be embedded
// structurally), and we prevent cycles in any case,
// so this recursion should always be of very limited
// depth.
//
// Note: if these two lines are combined into one we get
// dynamic borrow errors on `self.inner`.
let known = self.inner.borrow_mut().type_variables().probe(v).known();
known.map_or(typ, |t| self.shallow_resolve_ty(t))
}

ty::Infer(ty::IntVar(v)) => self
.inner
.borrow_mut()
.int_unification_table()
.probe_value(v)
.map(|v| v.to_type(self.tcx))
.unwrap_or(typ),

ty::Infer(ty::FloatVar(v)) => self
.inner
.borrow_mut()
.float_unification_table()
.probe_value(v)
.map(|v| v.to_type(self.tcx))
.unwrap_or(typ),

_ => typ,
}
}

/// `ty_or_const_infer_var_changed` is equivalent to one of these two:
/// * `shallow_resolve(ty) != ty` (where `ty.kind = ty::Infer(_)`)
/// * `shallow_resolve(ct) != ct` (where `ct.kind = ty::ConstKind::Infer(_)`)
Expand Down Expand Up @@ -1831,8 +1788,46 @@ impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
self.infcx.tcx
}

/// If `ty` is a type variable of some kind, resolve it one level
/// (but do not resolve types found in the result). If `typ` is
/// not a type variable, just return it unmodified.
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.infcx.shallow_resolve_ty(ty)
match *ty.kind() {
ty::Infer(ty::TyVar(v)) => {
// Not entirely obvious: if `typ` is a type variable,
// it can be resolved to an int/float variable, which
// can then be recursively resolved, hence the
// recursion. Note though that we prevent type
// variables from unifying to other type variables
// directly (though they may be embedded
// structurally), and we prevent cycles in any case,
// so this recursion should always be of very limited
// depth.
//
// Note: if these two lines are combined into one we get
// dynamic borrow errors on `self.inner`.
let known = self.infcx.inner.borrow_mut().type_variables().probe(v).known();
known.map_or(ty, |t| self.fold_ty(t))
}

ty::Infer(ty::IntVar(v)) => self
.infcx
.inner
.borrow_mut()
.int_unification_table()
.probe_value(v)
.map_or(ty, |v| v.to_type(self.infcx.tcx)),

ty::Infer(ty::FloatVar(v)) => self
.infcx
.inner
.borrow_mut()
.float_unification_table()
.probe_value(v)
.map_or(ty, |v| v.to_type(self.infcx.tcx)),

_ => ty,
}
}

fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
Expand Down
Loading