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 12 pull requests #100664

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dacffd2
Rustdoc-Json: Clean up tests
aDotInTheVoid Jul 18, 2022
64f790f
Jsondocck: New `@ismany` command
aDotInTheVoid Jul 19, 2022
760b972
rustdoc-json: Use `@ismany` in tests
aDotInTheVoid Jul 19, 2022
63113c8
unwind: don't build dependency when building for Miri
RalfJung Aug 14, 2022
3f379f6
needless separation of impl blocks
tshepang Aug 16, 2022
5309375
Do not report cycle error when inferring return type for suggestion
compiler-errors Aug 10, 2022
8439080
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi
taiki-e Aug 16, 2022
c1a9841
Migrate emoji identifier diagnostics to `SessionDiagnostic`
finalchild Aug 16, 2022
33212bf
Remove deferred sized checks
compiler-errors Aug 16, 2022
0ff8f0b
Update src/test/assembly/x86_64-floating-point-clamp.rs
Alex-Velez Aug 15, 2022
302689f
Update src/test/assembly/x86_64-floating-point-clamp.rs
Alex-Velez Aug 17, 2022
b176f8b
Update books
ehuss Aug 17, 2022
f4674b4
Update cargo
ehuss Aug 17, 2022
89d9a35
Fixed a few documentation errors
milescaprio Aug 17, 2022
683b3f4
Fixed a few documentation errors
milescaprio Aug 17, 2022
bdb6383
Rollup merge of #99474 - aDotInTheVoid:rustdoc-json-noinline-test-cle…
matthiaskrgr Aug 17, 2022
4e490c5
Rollup merge of #100389 - compiler-errors:return-type-suggestion-cycl…
matthiaskrgr Aug 17, 2022
8e576b2
Rollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum
matthiaskrgr Aug 17, 2022
c08511d
Rollup merge of #100556 - Alex-Velez:patch-1, r=scottmcm
matthiaskrgr Aug 17, 2022
a2a4651
Rollup merge of #100608 - tshepang:needless-separation, r=TaKO8Ki
matthiaskrgr Aug 17, 2022
3284895
Rollup merge of #100621 - taiki-e:armv4t-atomics-32, r=cuviper
matthiaskrgr Aug 17, 2022
ff6e60d
Rollup merge of #100646 - finalchild:emoji-diag, r=compiler-errors
matthiaskrgr Aug 17, 2022
711dcf7
Rollup merge of #100652 - compiler-errors:no-defer-sized-checks, r=Ta…
matthiaskrgr Aug 17, 2022
4dc855b
Rollup merge of #100655 - ehuss:update-books, r=ehuss
matthiaskrgr Aug 17, 2022
75e1e31
Rollup merge of #100656 - ehuss:update-cargo, r=ehuss
matthiaskrgr Aug 17, 2022
78d983f
Rollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc
matthiaskrgr Aug 17, 2022
47ddd2d
Rollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc
matthiaskrgr Aug 17, 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
4 changes: 3 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ dependencies = [

[[package]]
name = "cargo"
version = "0.65.0"
version = "0.66.0"
dependencies = [
"anyhow",
"atty",
Expand Down Expand Up @@ -4011,6 +4011,7 @@ dependencies = [
"rustc_hir",
"rustc_incremental",
"rustc_lint",
"rustc_macros",
"rustc_metadata",
"rustc_middle",
"rustc_mir_build",
Expand Down Expand Up @@ -4359,6 +4360,7 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"tracing",
]

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ cfg_if! {
pub fn new(v: T) -> Self {
Atomic(Cell::new(v))
}
}

impl<T: Copy> Atomic<T> {
#[inline]
pub fn into_inner(self) -> T {
self.0.into_inner()
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/interface.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface_ferris_identifier =
Ferris cannot be used as an identifier
.suggestion = try using their name instead

interface_emoji_identifier =
identifiers cannot contain emoji: `{$ident}`
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fluent_messages! {
builtin_macros => "../locales/en-US/builtin_macros.ftl",
const_eval => "../locales/en-US/const_eval.ftl",
expand => "../locales/en-US/expand.ftl",
interface => "../locales/en-US/interface.ftl",
lint => "../locales/en-US/lint.ftl",
parser => "../locales/en-US/parser.ftl",
passes => "../locales/en-US/passes.ftl",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rustc_attr = { path = "../rustc_attr" }
rustc_borrowck = { path = "../rustc_borrowck" }
rustc_builtin_macros = { path = "../rustc_builtin_macros" }
rustc_expand = { path = "../rustc_expand" }
rustc_macros = { path = "../rustc_macros" }
rustc_parse = { path = "../rustc_parse" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
Expand Down
40 changes: 22 additions & 18 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use rustc_borrowck as mir_borrowck;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::parallel;
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, PResult};
use rustc_errors::{ErrorGuaranteed, PResult};
use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
use rustc_hir::def_id::StableCrateId;
use rustc_hir::definitions::Definitions;
use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore};
use rustc_macros::SessionDiagnostic;
use rustc_metadata::creader::CStore;
use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::DepGraph;
Expand All @@ -30,7 +31,7 @@ use rustc_session::output::filename_for_input;
use rustc_session::search_paths::PathKind;
use rustc_session::{Limit, Session};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::FileName;
use rustc_span::{FileName, Span};
use rustc_trait_selection::traits;
use rustc_typeck as typeck;
use tracing::{info, warn};
Expand Down Expand Up @@ -263,6 +264,23 @@ impl LintStoreExpand for LintStoreExpandImpl<'_> {
}
}

#[derive(SessionDiagnostic)]
#[error(interface::ferris_identifier)]
struct FerrisIdentifier {
#[primary_span]
spans: Vec<Span>,
#[suggestion(code = "ferris", applicability = "maybe-incorrect")]
first_span: Span,
}

#[derive(SessionDiagnostic)]
#[error(interface::emoji_identifier)]
struct EmojiIdentifier {
#[primary_span]
spans: Vec<Span>,
ident: Symbol,
}

/// 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 Down Expand Up @@ -443,23 +461,9 @@ pub fn configure_and_expand(
spans.sort();
if ident == sym::ferris {
let first_span = spans[0];
sess.diagnostic()
.struct_span_err(
MultiSpan::from(spans),
"Ferris cannot be used as an identifier",
)
.span_suggestion(
first_span,
"try using their name instead",
"ferris",
Applicability::MaybeIncorrect,
)
.emit();
sess.emit_err(FerrisIdentifier { spans, first_span });
} else {
sess.diagnostic().span_err(
MultiSpan::from(spans),
&format!("identifiers cannot contain emoji: `{}`", ident),
);
sess.emit_err(EmojiIdentifier { spans, ident });
}
}
});
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ rustc_queries! {
desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
separate_provide_extern
cycle_delay_bug
}

/// Performs lint checking for the module.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_query_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rustc_query_system = { path = "../rustc_query_system" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
tracing = "0.1"

[features]
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_query_impl/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,23 @@ impl<'tcx> Value<'tcx> for AdtSizedConstraint<'_> {
}
}
}

impl<'tcx> Value<'tcx> for ty::Binder<'_, ty::FnSig<'_>> {
fn from_cycle_error(tcx: QueryCtxt<'tcx>) -> Self {
let err = tcx.ty_error();
// FIXME(compiler-errors): It would be nice if we could get the
// query key, so we could at least generate a fn signature that
// has the right arity.
let fn_sig = ty::Binder::dummy(tcx.mk_fn_sig(
[].into_iter(),
err,
false,
rustc_hir::Unsafety::Normal,
rustc_target::spec::abi::Abi::Rust,
));

// SAFETY: This is never called when `Self` is not `ty::Binder<'tcx, ty::FnSig<'tcx>>`.
// FIXME: Represent the above fact in the trait system somehow.
unsafe { std::mem::transmute::<ty::PolyFnSig<'tcx>, ty::Binder<'_, ty::FnSig<'_>>>(fn_sig) }
}
}
4 changes: 3 additions & 1 deletion compiler/rustc_target/src/spec/armv4t_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Ld,
linker: Some("arm-none-eabi-ld".into()),
asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",],
features: "+soft-float,+strict-align".into(),
// Force-enable 32-bit atomics, which allows the use of atomic load/store only.
// The resulting atomics are ABI incompatible with atomics backed by libatomic.
features: "+soft-float,+strict-align,+atomics-32".into(),
main_needs_argc_argv: false,
atomic_cas: false,
has_thumb_interworking: true,
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ pub fn target() -> Target {
asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",],

// minimum extra features, these cannot be disabled via -C
features: "+soft-float,+strict-align".into(),
// Also force-enable 32-bit atomics, which allows the use of atomic load/store only.
// The resulting atomics are ABI incompatible with atomics backed by libatomic.
features: "+soft-float,+strict-align,+atomics-32".into(),

panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,16 +561,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// We just want to check sizedness, so instead of introducing
// placeholder lifetimes with probing, we just replace higher lifetimes
// with fresh vars.
let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
let arg_span = args.get(i).map(|a| a.span);
let span = arg_span.unwrap_or(expr.span);
let input = self.replace_bound_vars_with_fresh_vars(
span,
infer::LateBoundRegionConversionTime::FnCall,
fn_sig.input(i),
);
self.require_type_is_sized_deferred(
input,
self.require_type_is_sized(
self.normalize_associated_types_in(span, input),
span,
traits::SizedArgumentType(None),
traits::SizedArgumentType(arg_span),
);
}
}
Expand All @@ -585,7 +586,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
infer::LateBoundRegionConversionTime::FnCall,
fn_sig.output(),
);
self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType);
self.require_type_is_sized(
self.normalize_associated_types_in(expr.span, output),
expr.span,
traits::SizedReturnType,
);
}

// We always require that the type provided as the value for
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

pub fn require_type_is_sized_deferred(
&self,
ty: Ty<'tcx>,
span: Span,
code: traits::ObligationCauseCode<'tcx>,
) {
if !ty.references_error() {
self.deferred_sized_obligations.borrow_mut().push((ty, span, code));
}
}

pub fn register_bound(
&self,
ty: Ty<'tcx>,
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_typeck/src/check/inherited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ pub struct Inherited<'a, 'tcx> {

pub(super) fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,

// Some additional `Sized` obligations badly affect type inference.
// These obligations are added in a later stage of typeck.
pub(super) deferred_sized_obligations:
RefCell<Vec<(Ty<'tcx>, Span, traits::ObligationCauseCode<'tcx>)>>,

// When we process a call like `c()` where `c` is a closure type,
// we may not have decided yet whether `c` is a `Fn`, `FnMut`, or
// `FnOnce` closure. In that case, we defer full resolution of the
Expand Down Expand Up @@ -117,7 +112,6 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
infcx,
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
locals: RefCell::new(Default::default()),
deferred_sized_obligations: RefCell::new(Vec::new()),
deferred_call_resolutions: RefCell::new(Default::default()),
deferred_cast_checks: RefCell::new(Vec::new()),
deferred_transmute_checks: RefCell::new(Vec::new()),
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_typeck/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,6 @@ fn typeck_with_fallback<'tcx>(
fcx.resolve_rvalue_scopes(def_id.to_def_id());
fcx.resolve_generator_interiors(def_id.to_def_id());

for (ty, span, code) in fcx.deferred_sized_obligations.borrow_mut().drain(..) {
let ty = fcx.normalize_ty(span, ty);
fcx.require_type_is_sized(ty, span, code);
}

fcx.select_all_obligations_or_error();

if !fcx.infcx.is_tainted_by_errors() {
Expand Down
19 changes: 9 additions & 10 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ impl f32 {

/// Not a Number (NaN).
///
/// Note that IEEE-745 doesn't define just a single NaN value;
/// Note that IEEE-754 doesn't define just a single NaN value;
/// a plethora of bit patterns are considered to be NaN.
/// Furthermore, the standard makes a difference
/// between a "signaling" and a "quiet" NaN,
Expand Down Expand Up @@ -632,7 +632,7 @@ impl f32 {
}

/// Returns `true` if `self` has a positive sign, including `+0.0`, NaNs with
/// positive sign bit and positive infinity. Note that IEEE-745 doesn't assign any
/// positive sign bit and positive infinity. Note that IEEE-754 doesn't assign any
/// meaning to the sign bit in case of a NaN, and as Rust doesn't guarantee that
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
Expand All @@ -654,7 +654,7 @@ impl f32 {
}

/// Returns `true` if `self` has a negative sign, including `-0.0`, NaNs with
/// negative sign bit and negative infinity. Note that IEEE-745 doesn't assign any
/// negative sign bit and negative infinity. Note that IEEE-754 doesn't assign any
/// meaning to the sign bit in case of a NaN, and as Rust doesn't guarantee that
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
Expand Down Expand Up @@ -1282,15 +1282,14 @@ impl f32 {
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "clamp", since = "1.50.0")]
#[inline]
pub fn clamp(self, min: f32, max: f32) -> f32 {
pub fn clamp(mut self, min: f32, max: f32) -> f32 {
assert!(min <= max);
let mut x = self;
if x < min {
x = min;
if self < min {
self = min;
}
if x > max {
x = max;
if self > max {
self = max;
}
x
self
}
}
19 changes: 9 additions & 10 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl f64 {

/// Not a Number (NaN).
///
/// Note that IEEE-745 doesn't define just a single NaN value;
/// Note that IEEE-754 doesn't define just a single NaN value;
/// a plethora of bit patterns are considered to be NaN.
/// Furthermore, the standard makes a difference
/// between a "signaling" and a "quiet" NaN,
Expand Down Expand Up @@ -624,7 +624,7 @@ impl f64 {
}

/// Returns `true` if `self` has a positive sign, including `+0.0`, NaNs with
/// positive sign bit and positive infinity. Note that IEEE-745 doesn't assign any
/// positive sign bit and positive infinity. Note that IEEE-754 doesn't assign any
/// meaning to the sign bit in case of a NaN, and as Rust doesn't guarantee that
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
Expand Down Expand Up @@ -655,7 +655,7 @@ impl f64 {
}

/// Returns `true` if `self` has a negative sign, including `-0.0`, NaNs with
/// negative sign bit and negative infinity. Note that IEEE-745 doesn't assign any
/// negative sign bit and negative infinity. Note that IEEE-754 doesn't assign any
/// meaning to the sign bit in case of a NaN, and as Rust doesn't guarantee that
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
Expand Down Expand Up @@ -1280,15 +1280,14 @@ impl f64 {
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "clamp", since = "1.50.0")]
#[inline]
pub fn clamp(self, min: f64, max: f64) -> f64 {
pub fn clamp(mut self, min: f64, max: f64) -> f64 {
assert!(min <= max);
let mut x = self;
if x < min {
x = min;
if self < min {
self = min;
}
if x > max {
x = max;
if self > max {
self = max;
}
x
self
}
}
8 changes: 7 additions & 1 deletion library/unwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ use std::env;

fn main() {
println!("cargo:rerun-if-changed=build.rs");
let target = env::var("TARGET").expect("TARGET was not set");
println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");

if env::var_os("CARGO_CFG_MIRI").is_some() {
// Miri doesn't need the linker flags or a libunwind build.
return;
}

let target = env::var("TARGET").expect("TARGET was not set");
if target.contains("android") {
let build = cc::Build::new();

Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Loading