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 #103079

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
99182dd
std: use semaphore for thread parking on Apple platforms
joboet Oct 6, 2022
0ad4dd4
std: add thread parking tests
joboet Oct 6, 2022
b4c8a7b
std: remove unused linker attribute
joboet Oct 8, 2022
c320ab9
std: do not use dispatch semaphore under miri (yet)
joboet Oct 8, 2022
e8a6e60
resolve: Add some asserts for unexpected lifetime rib combinations
petrochenkov Oct 9, 2022
e94ec30
resolve: Remove redundant item lifetime ribs
petrochenkov Oct 10, 2022
f634106
resolve: Regroup lifetime rib kinds to account for their purpose
petrochenkov Oct 10, 2022
b841848
check if the self type is `ty::Float` before getting second substs
TaKO8Ki Oct 13, 2022
5378677
normalize stderr
TaKO8Ki Oct 13, 2022
40bb4b7
Update cargo
weihanglo Oct 14, 2022
f528414
Add missing checks for `doc(cfg_hide(...))` attribute
GuillaumeGomez Oct 12, 2022
6f0c247
Add UI test for invalid `doc(cfg_hide(...))` attributes
GuillaumeGomez Oct 12, 2022
ae12bb1
Remove execute bit from lock file permissions
Oct 1, 2022
062ea9c
remove no_core feature
TaKO8Ki Oct 14, 2022
4528aa6
Rollup merge of #102543 - daym:patch-1, r=joshtriplett
Dylan-DPC Oct 15, 2022
47d6e99
Rollup merge of #102773 - joboet:apple_parker, r=thomcc
Dylan-DPC Oct 15, 2022
5d29ef5
Rollup merge of #102884 - petrochenkov:liferib, r=cjgillot
Dylan-DPC Oct 15, 2022
2849f8a
Rollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Mani…
Dylan-DPC Oct 15, 2022
a75085f
Rollup merge of #103003 - TaKO8Ki:fix-102989, r=compiler-errors
Dylan-DPC Oct 15, 2022
27501e2
Rollup merge of #103041 - weihanglo:update-cargo, r=ehuss
Dylan-DPC Oct 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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ dependencies = [
"cargo-test-macro",
"cargo-test-support",
"cargo-util",
"clap 4.0.9",
"clap 4.0.15",
"crates-io",
"curl",
"curl-sys",
Expand Down Expand Up @@ -439,7 +439,7 @@ dependencies = [

[[package]]
name = "cargo-util"
version = "0.2.1"
version = "0.2.2"
dependencies = [
"anyhow",
"core-foundation",
Expand Down Expand Up @@ -602,9 +602,9 @@ dependencies = [

[[package]]
name = "clap"
version = "4.0.9"
version = "4.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0"
checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
dependencies = [
"atty",
"bitflags",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/flock/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Lock {
.read(true)
.write(true)
.create(create)
.mode(libc::S_IRWXU as u32)
.mode(0o600)
.open(p)?;

let mut operation = if exclusive { libc::LOCK_EX } else { libc::LOCK_SH };
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/passes.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ passes_doc_test_takes_list =
passes_doc_primitive =
`doc(primitive)` should never have been stable

passes_doc_cfg_hide_takes_list =
`#[doc(cfg_hide(...)]` takes a list of attributes

passes_doc_test_unknown_any =
unknown `doc` attribute `{$path}`

Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,22 @@ impl CheckAttrVisitor<'_> {
is_valid
}

/// Check that the `#![doc(cfg_hide(...))]` attribute only contains a list of attributes.
/// Returns `true` if valid.
fn check_doc_cfg_hide(&self, meta: &NestedMetaItem, hir_id: HirId) -> bool {
if meta.meta_item_list().is_some() {
true
} else {
self.tcx.emit_spanned_lint(
INVALID_DOC_ATTRIBUTES,
hir_id,
meta.span(),
errors::DocCfgHideTakesList,
);
false
}
}

/// Runs various checks on `#[doc]` attributes. Returns `true` if valid.
///
/// `specified_inline` should be initialized to `None` and kept for the scope
Expand Down Expand Up @@ -987,6 +1003,13 @@ impl CheckAttrVisitor<'_> {
is_valid = false;
}

sym::cfg_hide
if !self.check_attr_crate_level(attr, meta, hir_id)
|| !self.check_doc_cfg_hide(meta, hir_id) =>
{
is_valid = false;
}

sym::inline | sym::no_inline
if !self.check_doc_inline(
attr,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ pub struct DocTestUnknown {
#[diag(passes::doc_test_takes_list)]
pub struct DocTestTakesList;

#[derive(LintDiagnostic)]
#[diag(passes::doc_cfg_hide_takes_list)]
pub struct DocCfgHideTakesList;

#[derive(LintDiagnostic)]
#[diag(passes::doc_primitive)]
pub struct DocPrimitive;
Expand Down
142 changes: 77 additions & 65 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,14 @@ enum LifetimeUseSet {

#[derive(Copy, Clone, Debug)]
enum LifetimeRibKind {
/// This rib acts as a barrier to forbid reference to lifetimes of a parent item.
Item,

// -- Ribs introducing named lifetimes
//
/// This rib declares generic parameters.
/// Only for this kind the `LifetimeRib::bindings` field can be non-empty.
Generics { binder: NodeId, span: Span, kind: LifetimeBinderKind },

/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const
/// generics. We are disallowing this until we can decide on how we want to handle non-'static
/// lifetimes in const generics. See issue #74052 for discussion.
ConstGeneric,

/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
/// This function will emit an error if `generic_const_exprs` is not enabled, the body identified by
/// `body_id` is an anonymous constant and `lifetime_ref` is non-static.
AnonConst,

// -- Ribs introducing unnamed lifetimes
//
/// Create a new anonymous lifetime parameter and reference it.
///
/// If `report_in_path`, report an error when encountering lifetime elision in a path:
Expand All @@ -256,16 +248,31 @@ enum LifetimeRibKind {
/// ```
AnonymousCreateParameter { binder: NodeId, report_in_path: bool },

/// Replace all anonymous lifetimes by provided lifetime.
Elided(LifetimeRes),

// -- Barrier ribs that stop lifetime lookup, or continue it but produce an error later.
//
/// Give a hard error when either `&` or `'_` is written. Used to
/// rule out things like `where T: Foo<'_>`. Does not imply an
/// error on default object bounds (e.g., `Box<dyn Foo>`).
AnonymousReportError,

/// Replace all anonymous lifetimes by provided lifetime.
Elided(LifetimeRes),

/// Signal we cannot find which should be the anonymous lifetime.
ElisionFailure,

/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const
/// generics. We are disallowing this until we can decide on how we want to handle non-'static
/// lifetimes in const generics. See issue #74052 for discussion.
ConstGeneric,

/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
/// This function will emit an error if `generic_const_exprs` is not enabled, the body
/// identified by `body_id` is an anonymous constant and `lifetime_ref` is non-static.
AnonConst,

/// This rib acts as a barrier to forbid reference to lifetimes of a parent item.
Item,
}

#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -748,35 +755,31 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) {
match foreign_item.kind {
ForeignItemKind::TyAlias(box TyAlias { ref generics, .. }) => {
self.with_lifetime_rib(LifetimeRibKind::Item, |this| {
this.with_generic_param_rib(
&generics.params,
ItemRibKind(HasGenericParams::Yes(generics.span)),
LifetimeRibKind::Generics {
binder: foreign_item.id,
kind: LifetimeBinderKind::Item,
span: generics.span,
},
|this| visit::walk_foreign_item(this, foreign_item),
)
});
self.with_generic_param_rib(
&generics.params,
ItemRibKind(HasGenericParams::Yes(generics.span)),
LifetimeRibKind::Generics {
binder: foreign_item.id,
kind: LifetimeBinderKind::Item,
span: generics.span,
},
|this| visit::walk_foreign_item(this, foreign_item),
);
}
ForeignItemKind::Fn(box Fn { ref generics, .. }) => {
self.with_lifetime_rib(LifetimeRibKind::Item, |this| {
this.with_generic_param_rib(
&generics.params,
ItemRibKind(HasGenericParams::Yes(generics.span)),
LifetimeRibKind::Generics {
binder: foreign_item.id,
kind: LifetimeBinderKind::Function,
span: generics.span,
},
|this| visit::walk_foreign_item(this, foreign_item),
)
});
self.with_generic_param_rib(
&generics.params,
ItemRibKind(HasGenericParams::Yes(generics.span)),
LifetimeRibKind::Generics {
binder: foreign_item.id,
kind: LifetimeBinderKind::Function,
span: generics.span,
},
|this| visit::walk_foreign_item(this, foreign_item),
);
}
ForeignItemKind::Static(..) => {
self.with_item_rib(|this| {
self.with_static_rib(|this| {
visit::walk_foreign_item(this, foreign_item);
});
}
Expand Down Expand Up @@ -1391,9 +1394,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
return self.resolve_anonymous_lifetime(lifetime, false);
}

let mut indices = (0..self.lifetime_ribs.len()).rev();
for i in &mut indices {
let rib = &self.lifetime_ribs[i];
let mut lifetime_rib_iter = self.lifetime_ribs.iter().rev();
while let Some(rib) = lifetime_rib_iter.next() {
let normalized_ident = ident.normalize_to_macros_2_0();
if let Some(&(_, res)) = rib.bindings.get(&normalized_ident) {
self.record_lifetime_res(lifetime.id, res, LifetimeElisionCandidate::Named);
Expand Down Expand Up @@ -1423,9 +1425,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
} else {
LifetimeUseSet::Many
}),
LifetimeRibKind::Generics { .. }
| LifetimeRibKind::ConstGeneric
| LifetimeRibKind::AnonConst => None,
LifetimeRibKind::Generics { .. } => None,
LifetimeRibKind::ConstGeneric | LifetimeRibKind::AnonConst => {
span_bug!(ident.span, "unexpected rib kind: {:?}", rib.kind)
}
})
.unwrap_or(LifetimeUseSet::Many);
debug!(?use_ctxt, ?use_set);
Expand Down Expand Up @@ -1460,13 +1463,16 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
);
return;
}
_ => {}
LifetimeRibKind::AnonymousCreateParameter { .. }
| LifetimeRibKind::Elided(_)
| LifetimeRibKind::Generics { .. }
| LifetimeRibKind::ElisionFailure
| LifetimeRibKind::AnonymousReportError => {}
}
}

let mut outer_res = None;
for i in indices {
let rib = &self.lifetime_ribs[i];
for rib in lifetime_rib_iter {
let normalized_ident = ident.normalize_to_macros_2_0();
if let Some((&outer, _)) = rib.bindings.get_key_value(&normalized_ident) {
outer_res = Some(outer);
Expand All @@ -1493,8 +1499,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
count: 1,
};
let elision_candidate = LifetimeElisionCandidate::Missing(missing_lifetime);
for i in (0..self.lifetime_ribs.len()).rev() {
let rib = &mut self.lifetime_ribs[i];
for rib in self.lifetime_ribs.iter().rev() {
debug!(?rib.kind);
match rib.kind {
LifetimeRibKind::AnonymousCreateParameter { binder, .. } => {
Expand Down Expand Up @@ -1534,9 +1539,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
return;
}
LifetimeRibKind::Item => break,
LifetimeRibKind::Generics { .. }
| LifetimeRibKind::ConstGeneric
| LifetimeRibKind::AnonConst => {}
LifetimeRibKind::Generics { .. } | LifetimeRibKind::ConstGeneric => {}
LifetimeRibKind::AnonConst => {
// There is always an `Elided(LifetimeRes::Static)` inside an `AnonConst`.
span_bug!(lifetime.ident.span, "unexpected rib kind: {:?}", rib.kind)
}
}
}
self.record_lifetime_res(lifetime.id, LifetimeRes::Error, elision_candidate);
Expand Down Expand Up @@ -1751,9 +1758,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
self.report_missing_lifetime_specifiers(vec![missing_lifetime], None);
break;
}
LifetimeRibKind::Generics { .. }
| LifetimeRibKind::ConstGeneric
| LifetimeRibKind::AnonConst => {}
LifetimeRibKind::Generics { .. } | LifetimeRibKind::ConstGeneric => {}
LifetimeRibKind::AnonConst => {
// There is always an `Elided(LifetimeRes::Static)` inside an `AnonConst`.
span_bug!(elided_lifetime_span, "unexpected rib kind: {:?}", rib.kind)
}
}
}

Expand Down Expand Up @@ -2204,7 +2213,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
}

ItemKind::Static(ref ty, _, ref expr) | ItemKind::Const(_, ref ty, ref expr) => {
self.with_item_rib(|this| {
self.with_static_rib(|this| {
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Static), |this| {
this.visit_ty(ty);
});
Expand Down Expand Up @@ -2399,11 +2408,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
self.label_ribs.pop();
}

fn with_item_rib(&mut self, f: impl FnOnce(&mut Self)) {
fn with_static_rib(&mut self, f: impl FnOnce(&mut Self)) {
let kind = ItemRibKind(HasGenericParams::No);
self.with_lifetime_rib(LifetimeRibKind::Item, |this| {
this.with_rib(ValueNS, kind, |this| this.with_rib(TypeNS, kind, f))
})
self.with_rib(ValueNS, kind, |this| this.with_rib(TypeNS, kind, f))
}

// HACK(min_const_generics,const_evaluatable_unchecked): We
Expand Down Expand Up @@ -3938,7 +3945,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
fn_id: NodeId,
async_node_id: Option<(NodeId, Span)>,
) {
if let Some((async_node_id, _)) = async_node_id {
if let Some((async_node_id, span)) = async_node_id {
let mut extra_lifetime_params =
self.r.extra_lifetime_params_map.get(&fn_id).cloned().unwrap_or_default();
for rib in self.lifetime_ribs.iter().rev() {
Expand All @@ -3952,7 +3959,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
extra_lifetime_params.extend(earlier_fresh);
}
}
_ => {}
LifetimeRibKind::Generics { .. } => {}
_ => {
// We are in a function definition. We should only find `Generics`
// and `AnonymousCreateParameter` inside the innermost `Item`.
span_bug!(span, "unexpected rib kind: {:?}", rib.kind)
}
}
}
self.r.extra_lifetime_params_map.insert(async_node_id, extra_lifetime_params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2937,19 +2937,15 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
ObligationCauseCode::BinOp { rhs_span: Some(span), is_lit, .. } if *is_lit => span,
_ => return,
};
match (
trait_ref.skip_binder().self_ty().kind(),
trait_ref.skip_binder().substs.type_at(1).kind(),
) {
(ty::Float(_), ty::Infer(InferTy::IntVar(_))) => {
err.span_suggestion_verbose(
rhs_span.shrink_to_hi(),
"consider using a floating-point literal by writing it with `.0`",
".0",
Applicability::MaybeIncorrect,
);
}
_ => {}
if let ty::Float(_) = trait_ref.skip_binder().self_ty().kind()
&& let ty::Infer(InferTy::IntVar(_)) = trait_ref.skip_binder().substs.type_at(1).kind()
{
err.span_suggestion_verbose(
rhs_span.shrink_to_hi(),
"consider using a floating-point literal by writing it with `.0`",
".0",
Applicability::MaybeIncorrect,
);
}
}

Expand Down
Loading