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 14 pull requests #122711

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c7030e9
Stabilize `imported_main`
clubby789 Jan 30, 2024
c63f3fe
Stabilize associated type bounds
compiler-errors Mar 5, 2024
d0e4a3b
Gracefully handle AnonConst in diagnostic_hir_wf_check()
gurry Mar 12, 2024
d26c572
Reject early-bound params in the type of assoc const bindings
fmease Dec 28, 2023
0b2fb8d
Reject escaping bound vars in the type of assoc const bindings
fmease Jan 10, 2024
d7b4b01
core: document default attribute stabilization
tmfink Mar 15, 2024
23e1b57
Improve wording of `Vec::swap_remove`
pallix Mar 17, 2024
33c274f
move `normalizes_to_hack` to `AliasRelate`
lcnr Mar 18, 2024
f26e1e8
`NormalizesTo` return nested goals
lcnr Mar 18, 2024
935842b
Add tests
veera-sivarajan Mar 18, 2024
efa4269
move tests
lcnr Mar 18, 2024
97cc700
Fix ICE: `global_asm!()` Don't Panic When Unable to Evaluate Constant
veera-sivarajan Mar 18, 2024
39f2d25
Fix heading anchors in doc pages.
ehuss Mar 18, 2024
8124b26
update region debug formatting
BoxyUwU Mar 12, 2024
e34e344
rename `instantiate_canonical_with_fresh_inference_vars`
BoxyUwU Mar 18, 2024
7c5a99b
improve comments
lcnr Mar 18, 2024
0b29b71
cleanup + review
lcnr Mar 18, 2024
4739948
Fix a typo in the 1.77.0 relnotes
cuviper Mar 18, 2024
0db06bf
Detect allocator for box in must_not_suspend lint
compiler-errors Mar 18, 2024
419d205
Deduplicate `associated_body` and `body_id`
oli-obk Mar 5, 2024
69c4e81
Use `hir::Node` helper methods instead of repeat the same impl multip…
oli-obk Mar 5, 2024
9b0cbe3
Remove redundant files, rename base risc32 file
MabezDev Mar 18, 2024
5fd8878
Rollup merge of #121258 - fmease:assoc-const-eq-reject-overly-generic…
workingjubilee Mar 18, 2024
d6a2918
Rollup merge of #122021 - oli-obk:delangitemification, r=compiler-errors
workingjubilee Mar 18, 2024
cb1bc2c
Rollup merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk
workingjubilee Mar 18, 2024
9e6cee5
Rollup merge of #122060 - clubby789:stabilize-imported-main, r=lcnr
workingjubilee Mar 18, 2024
325763c
Rollup merge of #122370 - gurry:122199-ice-unexpected-node, r=davidtwco
workingjubilee Mar 18, 2024
7c8251f
Rollup merge of #122392 - BoxyUwU:misc_cleanup, r=lcnr
workingjubilee Mar 18, 2024
62de306
Rollup merge of #122642 - pallix:improve-wording-for-vec-swap_remove,…
workingjubilee Mar 18, 2024
6007cdd
Rollup merge of #122675 - tmfink:doc-clarify, r=scottmcm
workingjubilee Mar 18, 2024
d0e534c
Rollup merge of #122687 - lcnr:normalizes-to-emit-nested-goals, r=com…
workingjubilee Mar 18, 2024
f8a01f9
Rollup merge of #122691 - veera-sivarajan:bugfix-121099, r=Amanieu
workingjubilee Mar 18, 2024
0e98a61
Rollup merge of #122693 - ehuss:rust-css-header, r=GuillaumeGomez
workingjubilee Mar 18, 2024
02d1965
Rollup merge of #122699 - cuviper:relnotes-1.77.0-as, r=ehuss
workingjubilee Mar 18, 2024
1612955
Rollup merge of #122700 - esp-rs:remove-old-files, r=workingjubilee
workingjubilee Mar 18, 2024
6380d28
Rollup merge of #122701 - compiler-errors:allocator-suspend, r=oli-obk
workingjubilee Mar 18, 2024
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 RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Cargo

- [Extend the build directive syntax with `cargo::`.](https://github.com/rust-lang/cargo/pull/12201/)
- [Stabilize metadata `id` format as `PackageIDSpec`.](https://github.com/rust-lang/cargo/pull/12914/)
- [Pull out as `cargo-util-schemas` as a crate.](https://github.com/rust-lang/cargo/pull/13178/)
- [Pull out `cargo-util-schemas` as a crate.](https://github.com/rust-lang/cargo/pull/13178/)
- [Strip all debuginfo when debuginfo is not requested.](https://github.com/rust-lang/cargo/pull/13257/)
- [Inherit jobserver from env for all kinds of runners.](https://github.com/rust-lang/cargo/pull/12776/)
- [Deprecate rustc plugin support in cargo.](https://github.com/rust-lang/cargo/pull/13248/)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![doc(rust_logo)]
#![allow(internal_features)]
#![feature(rustdoc_internals)]
#![feature(associated_type_bounds)]
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
#![feature(if_let_guard)]
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
constraint.span,
"return type notation is experimental"
);
} else {
gate!(
&self,
associated_type_bounds,
constraint.span,
"associated type bounds are unstable"
);
}
}
visit::walk_assoc_constraint(self, constraint)
Expand Down Expand Up @@ -615,7 +608,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
}

gate_all_legacy_dont_use!(trait_alias, "trait aliases are experimental");
gate_all_legacy_dont_use!(associated_type_bounds, "associated type bounds are unstable");
// Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
// used to be gated under associated_type_bounds, which are right above, so RTN needs to
// be too.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![feature(rustdoc_internals)]
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(associated_type_bounds)]
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(let_chains)]
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Ok(output)
}

pub(super) fn instantiate_canonical_with_fresh_inference_vars<T>(
pub(super) fn instantiate_canonical<T>(
&mut self,
span: Span,
canonical: &Canonical<'tcx, T>,
) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
let (instantiated, _) =
self.infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical);
let (instantiated, _) = self.infcx.instantiate_canonical(span, canonical);
instantiated
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/type_check/input_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// (e.g., the `_` in the code above) with fresh variables.
// Then replace the bound items in the fn sig with fresh variables,
// so that they represent the view from "inside" the closure.
let user_provided_sig = self
.instantiate_canonical_with_fresh_inference_vars(body.span, &user_provided_poly_sig);
let user_provided_sig = self.instantiate_canonical(body.span, &user_provided_poly_sig);
let mut user_provided_sig = self.infcx.instantiate_binder_with_fresh_vars(
body.span,
BoundRegionConversionTime::FnCall,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let tcx = self.tcx();
for user_annotation in self.user_type_annotations {
let CanonicalUserTypeAnnotation { span, ref user_ty, inferred_ty } = *user_annotation;
let annotation = self.instantiate_canonical_with_fresh_inference_vars(span, user_ty);
let annotation = self.instantiate_canonical(span, user_ty);
if let ty::UserType::TypeOf(def, args) = annotation
&& let DefKind::InlineConst = tcx.def_kind(def)
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#![feature(
rustc_private,
decl_macro,
associated_type_bounds,
never_type,
trusted_len,
hash_raw_entry
)]
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![allow(broken_intra_doc_links)]
#![recursion_limit = "256"]
#![warn(rust_2018_idioms)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(associated_type_bounds)]
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(let_chains)]
Expand Down
46 changes: 29 additions & 17 deletions compiler/rustc_codegen_ssa/src/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::base;
use crate::common;
use crate::traits::*;
use rustc_hir as hir;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::ty;
Expand Down Expand Up @@ -40,23 +41,34 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
.iter()
.map(|(op, op_sp)| match *op {
hir::InlineAsmOperand::Const { ref anon_const } => {
let const_value = cx
.tcx()
.const_eval_poly(anon_const.def_id.to_def_id())
.unwrap_or_else(|_| {
span_bug!(*op_sp, "asm const cannot be resolved")
});
let ty = cx
.tcx()
.typeck_body(anon_const.body)
.node_type(anon_const.hir_id);
let string = common::asm_const_to_str(
cx.tcx(),
*op_sp,
const_value,
cx.layout_of(ty),
);
GlobalAsmOperandRef::Const { string }
match cx.tcx().const_eval_poly(anon_const.def_id.to_def_id()) {
Ok(const_value) => {
let ty = cx
.tcx()
.typeck_body(anon_const.body)
.node_type(anon_const.hir_id);
let string = common::asm_const_to_str(
cx.tcx(),
*op_sp,
const_value,
cx.layout_of(ty),
);
GlobalAsmOperandRef::Const { string }
}
Err(ErrorHandled::Reported { .. }) => {
// An error has already been reported and
// compilation is guaranteed to fail if execution
// hits this path. So an empty string instead of
// a stringified constant value will suffice.
GlobalAsmOperandRef::Const { string: String::new() }
}
Err(ErrorHandled::TooGeneric(_)) => {
span_bug!(
*op_sp,
"asm const cannot be resolved; too generic"
)
}
}
}
hir::InlineAsmOperand::SymFn { ref anon_const } => {
let ty = cx
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_error_codes/src/error_codes/E0719.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ An associated type value was specified more than once.
Erroneous code example:

```compile_fail,E0719
#![feature(associated_type_bounds)]
trait FooTrait {}
trait BarTrait {}
Expand All @@ -19,8 +17,6 @@ specify the associated type with the new trait.
Corrected example:

```
#![feature(associated_type_bounds)]
trait FooTrait {}
trait BarTrait {}
trait FooBarTrait: FooTrait + BarTrait {}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![feature(array_windows)]
#![feature(associated_type_bounds)]
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(associated_type_defaults)]
#![feature(if_let_guard)]
#![feature(let_chains)]
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ declare_features! (
(accepted, asm_sym, "1.66.0", Some(93333)),
/// Allows the definition of associated constants in `trait` or `impl` blocks.
(accepted, associated_consts, "1.20.0", Some(29646)),
/// Allows the user of associated type bounds.
(accepted, associated_type_bounds, "CURRENT_RUSTC_VERSION", Some(52662)),
/// Allows using associated `type`s in `trait`s.
(accepted, associated_types, "1.0.0", None),
/// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
Expand Down Expand Up @@ -203,6 +205,8 @@ declare_features! (
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872)),
/// Allows referencing `Self` and projections in impl-trait.
(accepted, impl_trait_projections, "1.74.0", Some(103532)),
/// Allows using imported `main` function
(accepted, imported_main, "CURRENT_RUSTC_VERSION", Some(28937)),
/// Allows using `a..=b` and `..=b` as inclusive range syntaxes.
(accepted, inclusive_range_syntax, "1.26.0", Some(28237)),
/// Allows inferring outlives requirements (RFC 2093).
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ declare_features! (
(unstable, asm_unwind, "1.58.0", Some(93334)),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
(unstable, associated_const_equality, "1.58.0", Some(92827)),
/// Allows the user of associated type bounds.
(unstable, associated_type_bounds, "1.34.0", Some(52662)),
/// Allows associated type defaults.
(unstable, associated_type_defaults, "1.2.0", Some(29661)),
/// Allows `async || body` closures.
Expand Down Expand Up @@ -495,8 +493,6 @@ declare_features! (
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
/// Allows `impl Trait` as output type in `Fn` traits in return position of functions.
(unstable, impl_trait_in_fn_trait_return, "1.64.0", Some(99697)),
/// Allows using imported `main` function
(unstable, imported_main, "1.53.0", Some(28937)),
/// Allows associated types in inherent impls.
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
/// Allow anonymous constants from an inline `const` block
Expand Down
35 changes: 21 additions & 14 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3640,35 +3640,42 @@ impl<'hir> Node<'hir> {
}
}

pub fn body_id(&self) -> Option<BodyId> {
#[inline]
pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
match self {
Node::Item(Item {
owner_id,
kind:
ItemKind::Static(_, _, body)
| ItemKind::Const(_, _, body)
| ItemKind::Fn(_, _, body),
ItemKind::Const(_, _, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body),
..
})
| Node::TraitItem(TraitItem {
owner_id,
kind:
TraitItemKind::Fn(_, TraitFn::Provided(body)) | TraitItemKind::Const(_, Some(body)),
TraitItemKind::Const(_, Some(body)) | TraitItemKind::Fn(_, TraitFn::Provided(body)),
..
})
| Node::ImplItem(ImplItem {
kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, body),
..
})
| Node::Expr(Expr {
kind:
ExprKind::ConstBlock(ConstBlock { body, .. })
| ExprKind::Closure(Closure { body, .. })
| ExprKind::Repeat(_, ArrayLen::Body(AnonConst { body, .. })),
owner_id,
kind: ImplItemKind::Const(_, body) | ImplItemKind::Fn(_, body),
..
}) => Some(*body),
}) => Some((owner_id.def_id, *body)),

Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
Some((*def_id, *body))
}

Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),

_ => None,
}
}

pub fn body_id(&self) -> Option<BodyId> {
Some(self.associated_body()?.1)
}

pub fn generics(self) -> Option<&'hir Generics<'hir>> {
match self {
Node::ForeignItem(ForeignItem {
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ hir_analysis_enum_discriminant_overflowed = enum discriminant overflowed
.label = overflowed on value after {$discr}
.note = explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome

hir_analysis_escaping_bound_var_in_ty_of_assoc_const_binding =
the type of the associated constant `{$assoc_const}` cannot capture late-bound generic parameters
.label = its type cannot capture the late-bound {$var_def_kind} `{$var_name}`
.var_defined_here_label = the late-bound {$var_def_kind} `{$var_name}` is defined here

hir_analysis_field_already_declared =
field `{$field_name}` is already declared
.label = field already declared
Expand Down Expand Up @@ -316,6 +321,22 @@ hir_analysis_opaque_captures_higher_ranked_lifetime = `impl Trait` cannot captur
.label = `impl Trait` implicitly captures all lifetimes in scope
.note = lifetime declared here

hir_analysis_param_in_ty_of_assoc_const_binding =
the type of the associated constant `{$assoc_const}` must not depend on {$param_category ->
[self] `Self`
[synthetic] `impl Trait`
*[normal] generic parameters
}
.label = its type must not depend on {$param_category ->
[self] `Self`
[synthetic] `impl Trait`
*[normal] the {$param_def_kind} `{$param_name}`
}
.param_defined_here_label = {$param_category ->
[synthetic] the `impl Trait` is specified here
*[normal] the {$param_def_kind} `{$param_name}` is defined here
}

hir_analysis_paren_sugar_attribute = the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation
.help = add `#![feature(unboxed_closures)]` to the crate attributes to use it

Expand Down Expand Up @@ -432,6 +453,8 @@ hir_analysis_transparent_non_zero_sized_enum = the variant of a transparent {$de
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
.labels = this field has non-zero size or requires alignment

hir_analysis_ty_of_assoc_const_binding_note = `{$assoc_const}` has type `{$ty}`

hir_analysis_ty_param_first_local = type parameter `{$param_ty}` must be covered by another type when it appears before the first local type (`{$local_type}`)
.label = type parameter `{$param_ty}` must be covered by another type when it appears before the first local type (`{$local_type}`)
.note = implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
Expand Down
Loading
Loading