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 6 pull requests #103184

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
810cce8
Adding fuchsia-ignore and needs-unwind to compiler test cases
andrewpollack Oct 13, 2022
48c85c5
Filtering spans
kper Oct 11, 2022
c87dc6d
Running the formatter
kper Oct 11, 2022
2db95d0
Revert "Running the formatter"
kper Oct 11, 2022
795a4fd
Revert "Filtering spans"
kper Oct 11, 2022
da10a05
Addressing feedback
kper Oct 11, 2022
1d970c3
Using the `is_empty` method of a span
kper Oct 12, 2022
8fbd19d
Removing one suggestion
kper Oct 12, 2022
fe3f76c
Fixing suggestions
kper Oct 12, 2022
17e3b73
Revert "Removing one suggestion"
kper Oct 15, 2022
4042468
Adding only suggestion when span not empty
kper Oct 15, 2022
88c3a20
Fixing span by extending it to the first character
kper Oct 15, 2022
3e2e0ea
Running fmt
kper Oct 15, 2022
9e2c2a5
Updating .stderr
kper Oct 15, 2022
684df4d
Make diagnostic for unsatisfied Termination bounds more precise
fmease Oct 17, 2022
9a7e527
Fix typo in `ReverseSearcher` docs
Oct 17, 2022
d7fd1d5
Remove the redundant `Some(try_opt!(..))` in `checked_pow`
cuviper Oct 17, 2022
430bd62
Stabilize asm_sym
Amanieu Oct 17, 2022
1d30a2e
Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk
Dylan-DPC Oct 18, 2022
00a0b4b
Rollup merge of #103023 - andrewpollack:i-fuchsia-finals, r=tmandry
Dylan-DPC Oct 18, 2022
e7d9d3d
Rollup merge of #103142 - fmease:fix-103052, r=oli-obk
Dylan-DPC Oct 18, 2022
4934f6f
Rollup merge of #103154 - H4x5:reverse-searcher-typo, r=Mark-Simulacrum
Dylan-DPC Oct 18, 2022
b753ffd
Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Sim…
Dylan-DPC Oct 18, 2022
008a3b2
Rollup merge of #103168 - Amanieu:stable_asm_sym, r=davidtwco
Dylan-DPC Oct 18, 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
10 changes: 0 additions & 10 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
InlineAsmOperand::Sym { ref sym } => {
if !self.tcx.features().asm_sym {
feature_err(
&sess.parse_sess,
sym::asm_sym,
*op_sp,
"sym operands for inline assembly are unstable",
)
.emit();
}

let static_def_id = self
.resolver
.get_partial_res(sym.id)
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_codegen_gcc/tests/run/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// Run-time:
// status: 0

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::{asm, global_asm};

global_asm!("
global_asm!(
"
.global add_asm
add_asm:
mov rax, rdi
Expand Down Expand Up @@ -132,7 +133,9 @@ fn main() {
assert_eq!(x, 43);

// check sym fn
extern "C" fn foo() -> u64 { 42 }
extern "C" fn foo() -> u64 {
42
}
let x: u64;
unsafe {
asm!("call {}", sym foo, lateout("rax") x);
Expand Down
25 changes: 25 additions & 0 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ impl Diagnostic {
style: SuggestionStyle,
) -> &mut Self {
assert!(!suggestion.is_empty());
debug_assert!(
!(suggestion.iter().any(|(sp, text)| sp.is_empty() && text.is_empty())),
"Span must not be empty and have no suggestion"
);

self.push_suggestion(CodeSuggestion {
substitutions: vec![Substitution {
parts: suggestion
Expand Down Expand Up @@ -644,6 +649,10 @@ impl Diagnostic {
applicability: Applicability,
style: SuggestionStyle,
) -> &mut Self {
debug_assert!(
!(sp.is_empty() && suggestion.to_string().is_empty()),
"Span must not be empty and have no suggestion"
);
self.push_suggestion(CodeSuggestion {
substitutions: vec![Substitution {
parts: vec![SubstitutionPart { snippet: suggestion.to_string(), span: sp }],
Expand Down Expand Up @@ -684,6 +693,12 @@ impl Diagnostic {
) -> &mut Self {
let mut suggestions: Vec<_> = suggestions.collect();
suggestions.sort();

debug_assert!(
!(sp.is_empty() && suggestions.iter().any(|suggestion| suggestion.is_empty())),
"Span must not be empty and have no suggestion"
);

let substitutions = suggestions
.into_iter()
.map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] })
Expand All @@ -705,8 +720,18 @@ impl Diagnostic {
suggestions: impl Iterator<Item = Vec<(Span, String)>>,
applicability: Applicability,
) -> &mut Self {
let suggestions: Vec<_> = suggestions.collect();
debug_assert!(
!(suggestions
.iter()
.flat_map(|suggs| suggs)
.any(|(sp, suggestion)| sp.is_empty() && suggestion.is_empty())),
"Span must not be empty and have no suggestion"
);

self.push_suggestion(CodeSuggestion {
substitutions: suggestions
.into_iter()
.map(|sugg| Substitution {
parts: sugg
.into_iter()
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_span::edition::Edition;
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId};
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{FileName, Span, DUMMY_SP};
use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
use smallvec::{smallvec, SmallVec};

use std::default::Default;
Expand Down Expand Up @@ -1228,8 +1228,9 @@ pub fn expr_to_spanned_string<'a>(
ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)),
ast::LitKind::ByteStr(_) => {
let mut err = cx.struct_span_err(l.span, err_msg);
let span = expr.span.shrink_to_lo();
err.span_suggestion(
expr.span.shrink_to_lo(),
span.with_hi(span.lo() + BytePos(1)),
"consider removing the leading `b`",
"",
Applicability::MaybeIncorrect,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ declare_features! (
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
/// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`.
(accepted, adx_target_feature, "1.61.0", Some(44839), None),
/// Allows using `sym` operands in inline assembly.
(accepted, asm_sym, "CURRENT_RUSTC_VERSION", Some(93333), None),
/// Allows the definition of associated constants in `trait` or `impl` blocks.
(accepted, associated_consts, "1.20.0", Some(29646), None),
/// Allows using associated `type`s in `trait`s.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ declare_features! (
(active, asm_const, "1.58.0", Some(93332), None),
/// Enables experimental inline assembly support for additional architectures.
(active, asm_experimental_arch, "1.58.0", Some(93335), None),
/// Allows using `sym` operands in inline assembly.
(active, asm_sym, "1.58.0", Some(93333), None),
/// Allows the `may_unwind` option in inline assembly.
(active, asm_unwind, "1.58.0", Some(93334), None),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3051,24 +3051,27 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.map_or(false, |s| s.trim_end().ends_with('<'));

let is_global = poly_trait_ref.trait_ref.path.is_global();
let sugg = Vec::from_iter([
(
self_ty.span.shrink_to_lo(),
format!(
"{}dyn {}",
if needs_bracket { "<" } else { "" },
if is_global { "(" } else { "" },
),

let mut sugg = Vec::from_iter([(
self_ty.span.shrink_to_lo(),
format!(
"{}dyn {}",
if needs_bracket { "<" } else { "" },
if is_global { "(" } else { "" },
),
(
)]);

if is_global || needs_bracket {
sugg.push((
self_ty.span.shrink_to_hi(),
format!(
"{}{}",
if is_global { ")" } else { "" },
if needs_bracket { ">" } else { "" },
),
),
]);
));
}

if self_ty.span.edition() >= Edition::Edition2021 {
let msg = "trait objects must include the `dyn` keyword";
let label = "add `dyn` keyword before this trait";
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,9 +1374,17 @@ impl<'a> Parser<'a> {
kind: IncDecRecovery,
(pre_span, post_span): (Span, Span),
) -> MultiSugg {
let mut patches = Vec::new();

if !pre_span.is_empty() {
patches.push((pre_span, String::new()));
}

patches.push((post_span, format!(" {}= 1", kind.op.chr())));

MultiSugg {
msg: format!("use `{}= 1` instead", kind.op.chr()),
patches: vec![(pre_span, String::new()), (post_span, format!(" {}= 1", kind.op.chr()))],
patches,
applicability: Applicability::MachineApplicable,
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ symbols! {
call_once,
caller_location,
capture_disjoint_fields,
cause,
cdylib,
ceilf32,
ceilf64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
}

if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
flags.push((sym::cause, Some("MainFunctionType".to_string())));
}

// Add all types without trimmed paths.
ty::print::with_no_trimmed_paths!({
let generics = self.tcx.generics_of(def_id);
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ macro_rules! int_impl {
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
Some(try_opt!(acc.checked_mul(base)))
acc.checked_mul(base)
}

/// Saturating integer addition. Computes `self + rhs`, saturating at the numeric
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ macro_rules! uint_impl {
// squaring the base afterwards is not necessary and may cause a
// needless overflow.

Some(try_opt!(acc.checked_mul(base)))
acc.checked_mul(base)
}

/// Saturating integer addition. Computes `self + rhs`, saturating at
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub unsafe trait Searcher<'a> {
/// The index ranges returned by this trait are not required
/// to exactly match those of the forward search in reverse.
///
/// For the reason why this trait is marked unsafe, see them
/// For the reason why this trait is marked unsafe, see the
/// parent trait [`Searcher`].
pub unsafe trait ReverseSearcher<'a>: Searcher<'a> {
/// Performs the next search step starting from the back.
Expand Down
12 changes: 10 additions & 2 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2154,8 +2154,16 @@ pub fn id() -> u32 {
#[cfg_attr(not(test), lang = "termination")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
#[rustc_on_unimplemented(
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
on(
all(not(bootstrap), cause = "MainFunctionType"),
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
),
on(
bootstrap,
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
)
)]
pub trait Termination {
/// Is called to get the representation of the value as status code.
Expand Down
13 changes: 0 additions & 13 deletions src/doc/unstable-book/src/language-features/asm-sym.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/assembly/asm/aarch64-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/arm-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: -C target-feature=+neon
// needs-llvm-components: arm

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/avr-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target avr-unknown-gnu-atmega328
// needs-llvm-components: avr

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/bpf-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
// needs-llvm-components: bpf

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
6 changes: 4 additions & 2 deletions src/test/assembly/asm/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C symbol-mangling-version=v0

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]
#![crate_type = "rlib"]

use std::arch::global_asm;
Expand All @@ -28,4 +28,6 @@ global_asm!("lea rax, [rip + {}]", sym MY_STATIC);
// CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar
global_asm!("call {}", sym foobar);
// CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar:
fn foobar() { loop {} }
fn foobar() {
loop {}
}
2 changes: 1 addition & 1 deletion src/test/assembly/asm/hexagon-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/mips-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
//[mips64] needs-llvm-components: mips

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/msp430-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target msp430-none-elf
// needs-llvm-components: msp430

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/nvptx-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: nvptx

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![no_core]

#[rustc_builtin_macro]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/powerpc-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
//[powerpc64] needs-llvm-components: powerpc

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/riscv-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//[riscv32] needs-llvm-components: riscv
// compile-flags: -C target-feature=+d

#![feature(no_core, lang_items, rustc_attrs, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/s390x-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//[s390x] compile-flags: --target s390x-unknown-linux-gnu
//[s390x] needs-llvm-components: systemz

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/wasm-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: webassembly

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![no_core]

#[rustc_builtin_macro]
Expand Down
Loading