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 7 pull requests #108863

Merged
merged 16 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 37 additions & 23 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,47 +132,36 @@ checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7"

[[package]]
name = "askama"
version = "0.11.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d8f355701c672c2ba3d718acbd213f740beea577cc4eae66accdffe15be1882"
checksum = "47cbc3cf73fa8d9833727bbee4835ba5c421a0d65b72daf9a7b5d0e0f9cfb57e"
dependencies = [
"askama_derive",
"askama_escape",
"askama_shared",
]

[[package]]
name = "askama_derive"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84704cab5b7ae0fd3a9f78ee5eb7b27f3749df445f04623db6633459ae283267"
dependencies = [
"askama_shared",
"proc-macro2",
"syn",
]

[[package]]
name = "askama_escape"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a1bb320f97e6edf9f756bf015900038e43c7700e059688e5724a928c8f3b8d5"

[[package]]
name = "askama_shared"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dae03eebba55a2697a376e58b573a29fe36893157173ac8df312ad85f3c0e012"
checksum = "e80b5ad1afe82872b7aa3e9de9b206ecb85584aa324f0f60fa4c903ce935936b"
dependencies = [
"askama_escape",
"basic-toml",
"mime",
"mime_guess",
"nom",
"proc-macro2",
"quote",
"serde",
"syn",
"toml 0.5.7",
]

[[package]]
name = "askama_escape"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"

[[package]]
name = "atty"
version = "0.2.14"
Expand Down Expand Up @@ -223,6 +212,15 @@ version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf"

[[package]]
name = "basic-toml"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1"
dependencies = [
"serde",
]

[[package]]
name = "bitflags"
version = "1.3.2"
Expand Down Expand Up @@ -2614,6 +2612,22 @@ dependencies = [
"autocfg",
]

[[package]]
name = "mime"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"

[[package]]
name = "mime_guess"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
"mime",
"unicase",
]

[[package]]
name = "minifier"
version = "0.2.2"
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.downgrade_to_delayed_bug();
}

if tcx.ty_is_opaque_future(rcvr_ty) && item_name.name == sym::poll {
err.help(&format!(
"method `poll` found on `Pin<&mut {ty_str}>`, \
see documentation for `std::pin::Pin`"
));
err.help("self type must be pinned to call `Future::poll`, \
see https://rust-lang.github.io/async-book/04_pinning/01_chapter.html#pinning-in-practice"
);
}

if let Mode::MethodCall = mode && let SelfSource::MethodCall(cal) = source {
self.suggest_await_before_method(
&mut err, item_name, rcvr_ty, cal, span, expected.only_has_type(self),
Expand Down
61 changes: 32 additions & 29 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,26 @@ pub struct InferCtxtInner<'tcx> {
float_unification_storage: ut::UnificationTableStorage<ty::FloatVid>,

/// Tracks the set of region variables and the constraints between them.
///
/// This is initially `Some(_)` but when
/// `resolve_regions_and_report_errors` is invoked, this gets set to `None`
/// -- further attempts to perform unification, etc., may fail if new
/// region constraints would've been added.
region_constraint_storage: Option<RegionConstraintStorage<'tcx>>,

/// A set of constraints that regionck must validate. Each
/// constraint has the form `T:'a`, meaning "some type `T` must
/// A set of constraints that regionck must validate.
///
/// Each constraint has the form `T:'a`, meaning "some type `T` must
/// outlive the lifetime 'a". These constraints derive from
/// instantiated type parameters. So if you had a struct defined
/// like
/// like the following:
/// ```ignore (illustrative)
/// struct Foo<T:'static> { ... }
/// struct Foo<T: 'static> { ... }
/// ```
/// then in some expression `let x = Foo { ... }` it will
/// In some expression `let x = Foo { ... }`, it will
/// instantiate the type parameter `T` with a fresh type `$0`. At
/// the same time, it will record a region obligation of
/// `$0:'static`. This will get checked later by regionck. (We
/// `$0: 'static`. This will get checked later by regionck. (We
/// can't generally check these things right away because we have
/// to wait until types are resolved.)
///
Expand Down Expand Up @@ -268,7 +270,7 @@ pub struct InferCtxt<'tcx> {
/// Caches the results of trait evaluation.
pub evaluation_cache: select::EvaluationCache<'tcx>,

/// the set of predicates on which errors have been reported, to
/// The set of predicates on which errors have been reported, to
/// avoid reporting the same error twice.
pub reported_trait_errors: RefCell<FxIndexMap<Span, Vec<ty::Predicate<'tcx>>>>,

Expand All @@ -291,7 +293,7 @@ pub struct InferCtxt<'tcx> {
tainted_by_errors: Cell<Option<ErrorGuaranteed>>,

/// Track how many errors were reported when this infcx is created.
/// If the number of errors increases, that's also a sign (line
/// If the number of errors increases, that's also a sign (like
/// `tainted_by_errors`) to avoid reporting certain kinds of errors.
// FIXME(matthewjasper) Merge into `tainted_by_errors`
err_count_on_creation: usize,
Expand All @@ -313,7 +315,7 @@ pub struct InferCtxt<'tcx> {
/// During coherence we have to assume that other crates may add
/// additional impls which we currently don't know about.
///
/// To deal with this evaluation should be conservative
/// To deal with this evaluation, we should be conservative
/// and consider the possibility of impls from outside this crate.
/// This comes up primarily when resolving ambiguity. Imagine
/// there is some trait reference `$0: Bar` where `$0` is an
Expand All @@ -323,7 +325,7 @@ pub struct InferCtxt<'tcx> {
/// bound to some type that in a downstream crate that implements
/// `Bar`.
///
/// Outside of coherence we set this to false because we are only
/// Outside of coherence, we set this to false because we are only
/// interested in types that the user could actually have written.
/// In other words, we consider `$0: Bar` to be unimplemented if
/// there is no type that the user could *actually name* that
Expand Down Expand Up @@ -373,7 +375,7 @@ pub enum SubregionOrigin<'tcx> {
Subtype(Box<TypeTrace<'tcx>>),

/// When casting `&'a T` to an `&'b Trait` object,
/// relating `'a` to `'b`
/// relating `'a` to `'b`.
RelateObjectBound(Span),

/// Some type parameter was instantiated with the given type,
Expand All @@ -384,7 +386,7 @@ pub enum SubregionOrigin<'tcx> {
/// that must outlive some other region.
RelateRegionParamBound(Span),

/// Creating a pointer `b` to contents of another reference
/// Creating a pointer `b` to contents of another reference.
Reborrow(Span),

/// (&'a &'b T) where a >= b
Expand All @@ -398,7 +400,7 @@ pub enum SubregionOrigin<'tcx> {
trait_item_def_id: DefId,
},

/// Checking that the bounds of a trait's associated type hold for a given impl
/// Checking that the bounds of a trait's associated type hold for a given impl.
CheckAssociatedTypeBounds {
parent: Box<SubregionOrigin<'tcx>>,
impl_item_def_id: LocalDefId,
Expand Down Expand Up @@ -435,32 +437,33 @@ pub enum LateBoundRegionConversionTime {
AssocTypeProjection(DefId),
}

/// Reasons to create a region inference variable
/// Reasons to create a region inference variable.
///
/// See `error_reporting` module for more details
/// See `error_reporting` module for more details.
#[derive(Copy, Clone, Debug)]
pub enum RegionVariableOrigin {
/// Region variables created for ill-categorized reasons,
/// mostly indicates places in need of refactoring
/// Region variables created for ill-categorized reasons.
///
/// They mostly indicate places in need of refactoring.
MiscVariable(Span),

/// Regions created by a `&P` or `[...]` pattern
/// Regions created by a `&P` or `[...]` pattern.
PatternRegion(Span),

/// Regions created by `&` operator
/// Regions created by `&` operator.
///
AddrOfRegion(Span),

/// Regions created as part of an autoref of a method receiver
/// Regions created as part of an autoref of a method receiver.
Autoref(Span),

/// Regions created as part of an automatic coercion
/// Regions created as part of an automatic coercion.
Coercion(Span),

/// Region variables created as the values for early-bound regions
/// Region variables created as the values for early-bound regions.
EarlyBoundRegion(Span, Symbol),

/// Region variables created for bound regions
/// in a function or method that is called
/// in a function or method that is called.
LateBoundRegion(Span, ty::BoundRegionKind, LateBoundRegionConversionTime),

UpvarRegion(ty::UpvarId, Span),
Expand Down Expand Up @@ -534,7 +537,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
}
}

/// Used to configure inference contexts before their creation
/// Used to configure inference contexts before their creation.
pub struct InferCtxtBuilder<'tcx> {
tcx: TyCtxt<'tcx>,
defining_use_anchor: DefiningAnchor,
Expand Down Expand Up @@ -835,9 +838,9 @@ impl<'tcx> InferCtxt<'tcx> {

/// Scan the constraints produced since `snapshot` began and returns:
///
/// - `None` -- if none of them involve "region outlives" constraints
/// - `Some(true)` -- if there are `'a: 'b` constraints where `'a` or `'b` is a placeholder
/// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders
/// - `None` -- if none of them involves "region outlives" constraints.
/// - `Some(true)` -- if there are `'a: 'b` constraints where `'a` or `'b` is a placeholder.
/// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders.
pub fn region_constraints_added_in_snapshot(
&self,
snapshot: &CombinedSnapshot<'tcx>,
Expand Down Expand Up @@ -1770,7 +1773,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}

/// Helper for `ty_or_const_infer_var_changed` (see comment on that), currently
/// Helper for [InferCtxt::ty_or_const_infer_var_changed] (see comment on that), currently
/// used only for `traits::fulfill`'s list of `stalled_on` inference variables.
#[derive(Copy, Clone, Debug)]
pub enum TyOrConstInferVar<'tcx> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rustc_middle::mir::interpret::{ConstValue, Scalar};
use rustc_middle::mir::tcx::PlaceTy;
use rustc_middle::ty::cast::mir_cast_kind;
use rustc_middle::{mir::*, thir::*, ty};
use rustc_span::Span;
use rustc_target::abi::VariantIdx;
Expand Down Expand Up @@ -142,7 +143,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
}

fn parse_rvalue(&self, expr_id: ExprId) -> PResult<Rvalue<'tcx>> {
parse_by_kind!(self, expr_id, _, "rvalue",
parse_by_kind!(self, expr_id, expr, "rvalue",
@call("mir_discriminant", args) => self.parse_place(args[0]).map(Rvalue::Discriminant),
@call("mir_checked", args) => {
parse_by_kind!(self, args[0], _, "binary op",
Expand All @@ -167,6 +168,12 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
ExprKind::Repeat { value, count } => Ok(
Rvalue::Repeat(self.parse_operand(*value)?, *count)
),
ExprKind::Cast { source } => {
let source = self.parse_operand(*source)?;
let source_ty = source.ty(self.body.local_decls(), self.tcx);
let cast_kind = mir_cast_kind(source_ty, expr.ty);
Ok(Rvalue::Cast(cast_kind, source, expr.ty))
},
_ => self.parse_operand(expr_id).map(Rvalue::Use),
)
}
Expand Down
5 changes: 0 additions & 5 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ changelog-seen = 2
# or alternatively ...
#ccache = "/path/to/ccache"

# If an external LLVM root is specified, we automatically check the version by
# default to make sure it's within the range that we're expecting, but setting
# this flag will indicate that this version check should not be done.
#version-check = true

# When true, link libstdc++ statically into the rustc_llvm.
# This is useful if you don't want to use the dynamic version of that
# library provided by LLVM.
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `remote-test-server`'s `verbose` argument has been removed in favor of the `--verbose` flag
- `remote-test-server`'s `remote` argument has been removed in favor of the `--bind` flag. Use `--bind 0.0.0.0:12345` to replicate the behavior of the `remote` argument.
- `x.py fmt` now formats only files modified between the merge-base of HEAD and the last commit in the master branch of the rust-lang repository and the current working directory. To restore old behaviour, use `x.py fmt .`. The check mode is not affected by this change. [#105702](https://github.com/rust-lang/rust/pull/105702)
- The `llvm.version-check` config option has been removed. Older versions were never supported. If you still need to support older versions (e.g. you are applying custom patches), patch `check_llvm_version` in bootstrap to change the minimum version. [#108619](https://github.com/rust-lang/rust/pull/108619)

### Non-breaking changes

Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pub struct Config {
pub llvm_optimize: bool,
pub llvm_thin_lto: bool,
pub llvm_release_debuginfo: bool,
pub llvm_version_check: bool,
pub llvm_static_stdcpp: bool,
/// `None` if `llvm_from_ci` is true and we haven't yet downloaded llvm.
#[cfg(not(test))]
Expand Down Expand Up @@ -672,7 +671,6 @@ define_config! {
tests: Option<bool> = "tests",
plugins: Option<bool> = "plugins",
ccache: Option<StringOrBool> = "ccache",
version_check: Option<bool> = "version-check",
static_libstdcpp: Option<bool> = "static-libstdcpp",
ninja: Option<bool> = "ninja",
targets: Option<String> = "targets",
Expand Down Expand Up @@ -804,7 +802,6 @@ impl Config {
let mut config = Config::default();
config.llvm_optimize = true;
config.ninja_in_file = true;
config.llvm_version_check = true;
config.llvm_static_stdcpp = false;
config.backtrace = true;
config.rust_optimize = true;
Expand Down Expand Up @@ -1166,7 +1163,6 @@ impl Config {
set(&mut config.llvm_optimize, llvm.optimize);
set(&mut config.llvm_thin_lto, llvm.thin_lto);
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
set(&mut config.llvm_version_check, llvm.version_check);
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
if let Some(v) = llvm.link_shared {
config.llvm_link_shared.set(Some(v));
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def v(*args):
o("llvm-static-stdcpp", "llvm.static-libstdcpp", "statically link to libstdc++ for LLVM")
o("llvm-link-shared", "llvm.link-shared", "prefer shared linking to LLVM (llvm-config --link-shared)")
o("rpath", "rust.rpath", "build rpaths into rustc itself")
o("llvm-version-check", "llvm.version-check", "check if the LLVM version is supported, build anyway")
o("codegen-tests", "rust.codegen-tests", "run the tests/codegen tests")
o("option-checking", None, "complain about unrecognized options in this configure script")
o("ninja", "llvm.ninja", "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)")
Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,6 @@ impl Step for Llvm {
}

fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
if !builder.config.llvm_version_check {
return;
}

if builder.config.dry_run() {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions src/doc/unstable-book/src/compiler-flags/cf-protection.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# `cf-protection`

The tracking issue for this feature is: [#93754](https://github.com/rust-lang/rust/issues/93754).

------------------------

This option enables control-flow enforcement technology (CET) on x86; a more detailed description of
CET is available [here]. Similar to `clang`, this flag takes one of the following values:

Expand Down
Loading