Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
39 changes: 39 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,45 @@ jobs:
name: census
path: ts/target/census

# Every driver on the newest nightly rust-overlay names, so the next bump's breaks are
# known before it starts. It fails no merge and opens no issue: the report waits on
# every job but this one. Each module runs after another's failure.
canary:
name: Newest nightly
runs-on: ubuntu-24.04-arm
timeout-minutes: 90
continue-on-error: true

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: ./.github/actions/nix

- name: Toolchain
id: toolchain
run: |
channel=$(sh/canary.sh)
echo "Canary on \`$channel\`" >> "$GITHUB_STEP_SUMMARY"

- name: Driver
if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }}
run: nix develop --command bash -c 'just driver check && just driver test'

- name: Export
if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }}
run: nix develop --command bash -c 'just ffi check && just ffi test'

- name: Go
if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }}
run: nix develop --command bash -c 'just go check && just go test'

- name: TypeScript
if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }}
run: nix develop --command bash -c 'just ts check && just ts moq && just ts test'
Comment thread
pullfrog[bot] marked this conversation as resolved.
Resolved

# A scheduled run's failure opens one issue, or comments on the one still open, and a
# pass closes it, so a suite only this workflow runs cannot fail unseen. Only the
# schedule, which runs main, gets the write token: a dispatch can run any branch.
Expand Down
37 changes: 24 additions & 13 deletions driver/src/bin/rust2-lint/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
//! part of the copy of the function that defines it. A generic fails when that total
//! exceeds its budget, unless every copy is thin enough to only forward.

use rustc_ast::LitKind;
use rustc_attr_ir::Attribute;
use rustc_ast::token::Delimiter;
use rustc_ast::{LitKind, MetaItemKind};
use rustc_attr_ir::{AttrArgs, AttrItem, Attribute};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::DefKind;
use rustc_middle::mono::{CollectionMode, MonoItem};
use rustc_middle::ty::{GenericArgsRef, Instance, InstanceKind, TyCtxt};
use rustc_middle::ty::{GenericArgs, Instance, InstanceKind, TyCtxt};
use rustc_span::def_id::DefId;
use rustc_span::{Span, Symbol};

Expand All @@ -30,7 +31,7 @@ const ATTRIBUTE: [&str; 2] = ["rust2", "mono_budget"];
struct Cost<'tcx> {
/// The MIR statements of each copy, its closures' included, by the generic's arguments:
/// a closure's own arguments start with them.
copies: FxHashMap<GenericArgsRef<'tcx>, u64>,
copies: FxHashMap<GenericArgs<'tcx>, u64>,
}

impl Cost<'_> {
Expand Down Expand Up @@ -147,9 +148,9 @@ fn callers<'tcx>(

/// The budget `generic`'s own attribute sets, if it has one.
fn limit(tcx: TyCtxt<'_>, generic: DefId) -> Option<Result<u64, ()>> {
let attr = tcx.get_attrs_by_path(generic, &ATTRIBUTE.map(Symbol::intern)).next()?;
let attr = tcx.tool_attrs(generic, &ATTRIBUTE.map(Symbol::intern)).next()?;
Some(parse(attr).map_err(|err| {
tcx.dcx().span_err(attr.span(), err);
tcx.dcx().span_err(attr.span, err);
}))
}

Expand All @@ -160,12 +161,16 @@ pub fn check_attributes(tcx: TyCtxt<'_>) {
let [tool, name] = ATTRIBUTE.map(Symbol::intern);
for owner in tcx.hir_crate_items(()).owners() {
for (local_id, attrs) in tcx.hir_attr_map(owner).map.iter() {
for attr in attrs.iter().filter(|attr| attr.path().first() == Some(&tool)) {
let path = attr.path();
if path.as_slice() != [tool, name] {
let tools = attrs.iter().filter_map(|attr| match attr {
Attribute::Tool(item) => Some(&**item),
_ => None,
});
for attr in tools.filter(|attr| attr.path.segments.first() == Some(&tool)) {
let path = &attr.path.segments;
if **path != [tool, name] {
let path: Vec<&str> = path.iter().map(Symbol::as_str).collect();
tcx.dcx()
.span_err(attr.span(), format!("unknown attribute `{}`", path.join("::")));
.span_err(attr.span, format!("unknown attribute `{}`", path.join("::")));
continue;
}
let def = owner.def_id.to_def_id();
Expand All @@ -177,18 +182,24 @@ pub fn check_attributes(tcx: TyCtxt<'_>) {
false => Err(format!("`{}` goes on a generic function", ATTRIBUTE.join("::"))),
};
if let Err(err) = checked {
tcx.dcx().span_err(attr.span(), err);
tcx.dcx().span_err(attr.span, err);
}
}
}
}
}

/// The limit a budget attribute sets.
fn parse(attr: &Attribute) -> Result<u64, String> {
fn parse(attr: &AttrItem) -> Result<u64, String> {
let mut limit = None;
let mut reason = false;
for item in attr.meta_item_list().unwrap_or_default() {
let list = match &attr.args {
AttrArgs::Delimited(args) if args.delim == Delimiter::Parenthesis => {
MetaItemKind::list_from_tokens(args.tokens.clone())
}
_ => None,
};
for item in list.unwrap_or_default() {
let arg = item
.meta_item()
.and_then(|meta| Some((meta.name()?, &meta.name_value_literal()?.kind)));
Expand Down
4 changes: 2 additions & 2 deletions ffi/fixtures/reject/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Items rust2-ffi cannot export: each is a compile error at its span.
#![feature(allocator_api, pattern)]
#![feature(pattern)]
use std::collections::HashMap;

/// A tuple of references taken: C lends nothing inside a value.
Expand Down Expand Up @@ -738,7 +738,7 @@ pub fn lent() -> impl Iterator<Item = u8> {
/// A pattern of the crate's own, whose searcher a split runs as it is read.
struct Slash;

impl std::str::pattern::Pattern for Slash {
unsafe impl std::str::pattern::Pattern for Slash {
type Searcher<'a> = std::str::pattern::CharSearcher<'a>;

fn into_searcher(self, haystack: &str) -> std::str::pattern::CharSearcher<'_> {
Expand Down
Loading